Print this page
11581 'debug' loader option is a little obscure
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Rob Johnston <rob.johnston@joyent.com>


 122      s" YES" compare-insensitive 0= if
 123        [char] s addr len + c! len 1+ to len
 124      then
 125   else
 126     drop
 127   then
 128   s" boot_verbose" getenv dup -1 <> if
 129      s" YES" compare-insensitive 0= if
 130        [char] v addr len + c! len 1+ to len
 131      then
 132   else
 133     drop
 134   then
 135   s" boot_kmdb" getenv dup -1 <> if
 136      s" YES" compare-insensitive 0= if
 137        [char] k addr len + c! len 1+ to len
 138      then
 139   else
 140     drop
 141   then
 142   s" boot_debug" getenv dup -1 <> if
 143      s" YES" compare-insensitive 0= if
 144        [char] d addr len + c! len 1+ to len
 145      then
 146   else
 147     drop
 148   then
 149   s" boot_reconfigure" getenv dup -1 <>   if
 150      s" YES" compare-insensitive 0= if
 151        [char] r addr len + c! len 1+ to len
 152      then
 153   else
 154     drop
 155   then
 156   s" boot_ask" getenv dup -1 <>   if
 157      s" YES" compare-insensitive 0= if
 158        [char] a addr len + c! len 1+ to len
 159      then
 160   else
 161     drop
 162   then


 239   load_kernel_and_modules
 240   ?dup 0= if bootmsg 0 1 boot then ;
 241 
 242  ***** boot-conf    Prepares to boot as specified by loaded configuration
 243 files.
 244 
 245 : boot-conf
 246   0= if ( interpreted ) get_arguments then
 247   0 1 unload drop
 248   load_kernel_and_modules
 249   ?dup 0= if 0 1 autoboot then ;
 250 
 251 also forth definitions previous
 252 
 253 builtin: boot builtin: boot-conf
 254 
 255 only forth definitions also support-functions
 256 
 257    in case the boot-args is set, parse it and extract following options:  -a
 258 to boot_ask=YES  -s to boot_single=YES  -v to boot_verbose=YES  -k to
 259 boot_kmdb=YES  -d to boot_debug=YES  -r to boot_reconfigure=YES  -B acpi-user-
 260 options=X to acpi-user-options=X    This is needed so that the menu can manage
 261 these options. Unfortunately, this  also means that boot-args will override
 262 previously set options, but we have no  way to control the processing order
 263 here. boot-args will be rebuilt at boot.     NOTE: The best way to address the
 264 order is to *not* set any above options  in boot-args.
 265 
 266 : parse-boot-args  { | baddr blen -- }
 267   s" boot-args" getenv dup -1 = if drop exit then
 268   to blen
 269   to baddr
 270 
 271   baddr blen
 272 
 273    loop over all instances of switch blocks, starting with '-'
 274   begin
 275     [char] - strchr
 276     2dup to blen to baddr
 277     dup 0<>
 278   while                  ( addr len )  points to -
 279      block for switch B. keep it on top of the stack for case
 280      the property list will get empty.
 281 
 282     over 1+ c@ [char] B = if  2dup            save "-B ...." in case options
 283 is empty  2 - swap 2 +        ( addr len len-2 addr+2 )  skip -B
 284 


 343        2swap 2drop       ( len' proplen )      nip               ( proplen )
 344        baddr blen rot -    s" boot-args" setenv     recurse        exit
 345      else                     ( addr len len' addr' )     not acpi option,
 346 skip to next option in list      loop to first , or bl or 0        begin
 347          dup c@ [char] , <> >r        dup c@ bl <> >r         dup c@ 0<> r>
 348 r> and and    while       1+ swap 1- swap        repeat     if its ',',
 349 skip over        dup c@ [char] , = if       1+ swap 1- swap        then
 350      then
 351       repeat                  ( addr len len' addr' )
 352        this block is done, remove addr and len from stack
 353       2swap 2drop swap
 354     then
 355 
 356     over c@ [char] - = if     ( addr len )
 357       2dup 1- swap 1+         ( addr len len' addr' )
 358       begin               loop till ' ' or 0      dup c@ dup 0<> swap bl <>
 359 and
 360       while    dup c@ [char] s = if       s" set boot_single=YES" evaluate
 361 TRUE      else dup c@ [char] v = if       s" set boot_verbose=YES" evaluate
 362 TRUE      else dup c@ [char] k = if       s" set boot_kmdb=YES" evaluate TRUE
 363      else dup c@ [char] d = if       s" set boot_debug=YES" evaluate TRUE
 364      else dup c@ [char] r = if       s" set boot_reconfigure=YES" evaluate
 365 TRUE      else dup c@ [char] a = if       s" set boot_ask=YES" evaluate TRUE
 366      then then then then then then      dup TRUE = if    drop      dup >r
 367           ( addr len len' addr' R: addr' )     1+ swap 1-        ( addr len
 368 addr'+1 len'-1 R: addr' )       r> swap      move      ( addr len )
 369 
 370        2drop baddr blen 1-       check if we have space after '-', if so, drop
 371 '- '        swap dup 1+ c@ bl = if            2 + swap 2 -    else
 372            swap       then      dup dup 0= swap 1 = or if    empty or only '-'
 373 is left.           2drop          s" boot-args" unsetenv        exit    else
 374          s" boot-args" setenv        then      recurse        exit    then
 375      1+ swap 1- swap
 376       repeat
 377 
 378       2swap 2drop
 379       dup c@ 0= if        end of string      2drop     exit
 380       else     swap
 381       then
 382     then
 383   repeat
 384 
 385   2drop ;
 386 




 122      s" YES" compare-insensitive 0= if
 123        [char] s addr len + c! len 1+ to len
 124      then
 125   else
 126     drop
 127   then
 128   s" boot_verbose" getenv dup -1 <> if
 129      s" YES" compare-insensitive 0= if
 130        [char] v addr len + c! len 1+ to len
 131      then
 132   else
 133     drop
 134   then
 135   s" boot_kmdb" getenv dup -1 <> if
 136      s" YES" compare-insensitive 0= if
 137        [char] k addr len + c! len 1+ to len
 138      then
 139   else
 140     drop
 141   then
 142   s" boot_drop_into_kmdb" getenv dup -1 <> if
 143      s" YES" compare-insensitive 0= if
 144        [char] d addr len + c! len 1+ to len
 145      then
 146   else
 147     drop
 148   then
 149   s" boot_reconfigure" getenv dup -1 <>   if
 150      s" YES" compare-insensitive 0= if
 151        [char] r addr len + c! len 1+ to len
 152      then
 153   else
 154     drop
 155   then
 156   s" boot_ask" getenv dup -1 <>   if
 157      s" YES" compare-insensitive 0= if
 158        [char] a addr len + c! len 1+ to len
 159      then
 160   else
 161     drop
 162   then


 239   load_kernel_and_modules
 240   ?dup 0= if bootmsg 0 1 boot then ;
 241 
 242  ***** boot-conf    Prepares to boot as specified by loaded configuration
 243 files.
 244 
 245 : boot-conf
 246   0= if ( interpreted ) get_arguments then
 247   0 1 unload drop
 248   load_kernel_and_modules
 249   ?dup 0= if 0 1 autoboot then ;
 250 
 251 also forth definitions previous
 252 
 253 builtin: boot builtin: boot-conf
 254 
 255 only forth definitions also support-functions
 256 
 257    in case the boot-args is set, parse it and extract following options:  -a
 258 to boot_ask=YES  -s to boot_single=YES  -v to boot_verbose=YES  -k to
 259 boot_kmdb=YES  -d to boot_drop_into_kmdb=YES  -r to boot_reconfigure=YES  -B
 260 acpi-user-options=X to acpi-user-options=X    This is needed so that the menu
 261 can manage these options. Unfortunately, this  also means that boot-args will
 262 override previously set options, but we have no  way to control the processing
 263 order here. boot-args will be rebuilt at boot.     NOTE: The best way to
 264 address the order is to *not* set any above options  in boot-args.
 265 
 266 : parse-boot-args  { | baddr blen -- }
 267   s" boot-args" getenv dup -1 = if drop exit then
 268   to blen
 269   to baddr
 270 
 271   baddr blen
 272 
 273    loop over all instances of switch blocks, starting with '-'
 274   begin
 275     [char] - strchr
 276     2dup to blen to baddr
 277     dup 0<>
 278   while                  ( addr len )  points to -
 279      block for switch B. keep it on top of the stack for case
 280      the property list will get empty.
 281 
 282     over 1+ c@ [char] B = if  2dup            save "-B ...." in case options
 283 is empty  2 - swap 2 +        ( addr len len-2 addr+2 )  skip -B
 284 


 343        2swap 2drop       ( len' proplen )      nip               ( proplen )
 344        baddr blen rot -    s" boot-args" setenv     recurse        exit
 345      else                     ( addr len len' addr' )     not acpi option,
 346 skip to next option in list      loop to first , or bl or 0        begin
 347          dup c@ [char] , <> >r        dup c@ bl <> >r         dup c@ 0<> r>
 348 r> and and    while       1+ swap 1- swap        repeat     if its ',',
 349 skip over        dup c@ [char] , = if       1+ swap 1- swap        then
 350      then
 351       repeat                  ( addr len len' addr' )
 352        this block is done, remove addr and len from stack
 353       2swap 2drop swap
 354     then
 355 
 356     over c@ [char] - = if     ( addr len )
 357       2dup 1- swap 1+         ( addr len len' addr' )
 358       begin               loop till ' ' or 0      dup c@ dup 0<> swap bl <>
 359 and
 360       while    dup c@ [char] s = if       s" set boot_single=YES" evaluate
 361 TRUE      else dup c@ [char] v = if       s" set boot_verbose=YES" evaluate
 362 TRUE      else dup c@ [char] k = if       s" set boot_kmdb=YES" evaluate TRUE
 363      else dup c@ [char] d = if       s" set boot_drop_into_kmdb=YES" evaluate
 364 TRUE      else dup c@ [char] r = if       s" set boot_reconfigure=YES"
 365 evaluate TRUE  else dup c@ [char] a = if       s" set boot_ask=YES" evaluate
 366 TRUE      then then then then then then      dup TRUE = if    drop      dup >r
 367           ( addr len len' addr' R: addr' )     1+ swap 1-        ( addr len
 368 addr'+1 len'-1 R: addr' )       r> swap      move      ( addr len )
 369 
 370        2drop baddr blen 1-       check if we have space after '-', if so, drop
 371 '- '        swap dup 1+ c@ bl = if            2 + swap 2 -    else
 372            swap       then      dup dup 0= swap 1 = or if    empty or only '-'
 373 is left.           2drop          s" boot-args" unsetenv        exit    else
 374          s" boot-args" setenv        then      recurse        exit    then
 375      1+ swap 1- swap
 376       repeat
 377 
 378       2swap 2drop
 379       dup c@ 0= if        end of string      2drop     exit
 380       else     swap
 381       then
 382     then
 383   repeat
 384 
 385   2drop ;
 386