support.4th (65616) | support.4th (65630) |
---|---|
1\ Copyright (c) 1999 Daniel C. Sobral <dcs@freebsd.org> 2\ All rights reserved. 3\ 4\ Redistribution and use in source and binary forms, with or without 5\ modification, are permitted provided that the following conditions 6\ are met: 7\ 1. Redistributions of source code must retain the above copyright 8\ notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 17\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23\ SUCH DAMAGE. 24\ | 1\ Copyright (c) 1999 Daniel C. Sobral <dcs@freebsd.org> 2\ All rights reserved. 3\ 4\ Redistribution and use in source and binary forms, with or without 5\ modification, are permitted provided that the following conditions 6\ are met: 7\ 1. Redistributions of source code must retain the above copyright 8\ notice, this list of conditions and the following disclaimer. --- 8 unchanged lines hidden (view full) --- 17\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23\ SUCH DAMAGE. 24\ |
25\ $FreeBSD: head/sys/boot/forth/support.4th 65616 2000-09-08 16:58:31Z dcs $ | 25\ $FreeBSD: head/sys/boot/forth/support.4th 65630 2000-09-09 04:52:34Z dcs $ |
26 27\ Loader.rc support functions: 28\ 29\ initialize_support ( -- ) initialize global variables 30\ initialize ( addr len -- ) as above, plus load_conf_files 31\ load_conf ( addr len -- ) load conf file given 32\ include_conf_files ( -- ) load all conf files in load_conf_files 33\ print_syntax_error ( -- ) print line and marker of where a syntax --- 1179 unchanged lines hidden (view full) --- 1213 dup load_module? if 1214 ['] process_module catch 1215 process_module_errors 1216 then 1217 module.next @ 1218 repeat 1219; 1220 | 26 27\ Loader.rc support functions: 28\ 29\ initialize_support ( -- ) initialize global variables 30\ initialize ( addr len -- ) as above, plus load_conf_files 31\ load_conf ( addr len -- ) load conf file given 32\ include_conf_files ( -- ) load all conf files in load_conf_files 33\ print_syntax_error ( -- ) print line and marker of where a syntax --- 1179 unchanged lines hidden (view full) --- 1213 dup load_module? if 1214 ['] process_module catch 1215 process_module_errors 1216 then 1217 module.next @ 1218 repeat 1219; 1220 |
1221\ Additional functions used in "start" | 1221\ h00h00 magic used to try loading either a kernel with a given name, 1222\ or a kernel with the default name in a directory of a given name 1223\ (the pain!) |
1222 | 1224 |
1225: bootpath s" /boot/" ; 1226: modulepath s" module_path" ; 1227 1228\ Functions used to save and restore module_path's value. 1229: saveenv ( addr len | -1 -- addr' len | 0 -1 ) 1230 dup -1 = if 0 swap exit then 1231 strdup 1232; 1233: freeenv ( addr len | 0 -1 ) 1234 -1 = if drop else free abort" Freeing error" then 1235; 1236: restoreenv ( addr len | 0 -1 -- ) 1237 dup -1 = if ( it wasn't set ) 1238 2drop 1239 modulepath unsetenv 1240 else 1241 over >r 1242 modulepath setenv 1243 r> free abort" Freeing error" 1244 then 1245; 1246 1247: clip_args \ Drop second string if only one argument is passed 1248 1 = if 1249 2swap 2drop 1250 1 1251 else 1252 2 1253 then 1254; 1255 1256also builtins 1257 1258\ Parse filename from a comma-separated list 1259 1260: parse-; ( addr len -- addr' len-x addr x ) 1261 over 0 2swap 1262 begin 1263 dup 0 <> 1264 while 1265 over c@ [char] ; <> 1266 while 1267 1- swap 1+ swap 1268 2swap 1+ 2swap 1269 repeat then 1270 dup 0 <> if 1271 1- swap 1+ swap 1272 then 1273 2swap 1274; 1275 1276\ Try loading one of multiple kernels specified 1277 1278: try_multiple_kernels ( addr len addr' len' args -- flag ) 1279 >r 1280 begin 1281 parse-; 2>r 1282 2over 2r> 1283 r@ clip_args 1 load 1284 while 1285 dup 0= 1286 until 1287 1 >r \ Failure 1288 else 1289 0 >r \ Success 1290 then 1291 2drop 2drop 1292 r> 1293 r> drop 1294; 1295 1296\ Try to load a kernel; the kernel name is taken from one of 1297\ the following lists, as ordered: 1298\ 1299\ 1. The "kernel" environment variable 1300\ 2. The "bootfile" environment variable 1301\ 1302\ Flags are passed, if available. The parameter args must be 2 1303\ if flags are being passed, or 1 if they should be ignored. 1304\ Dummy flags and len must be passed in the latter case. 1305\ 1306\ The kernel gets loaded from the current module_path. 1307 1308: load_a_kernel ( flags len args -- flag ) 1309 local args 1310 2local flags 1311 0 0 2local kernel 1312 end-locals 1313 1314 \ Check if a default kernel name exists at all, exits if not 1315 s" kernel" getenv dup -1 <> if 1316 to kernel 1317 flags kernel args try_multiple_kernels 1318 dup 0= if exit then 1319 then 1320 drop 1321 1322 s" bootfile" getenv dup -1 <> if 1323 to kernel 1324 else 1325 drop 1326 1 exit \ Failure 1327 then 1328 1329 \ Try all default kernel names 1330 flags kernel args try_multiple_kernels 1331; 1332 1333\ Try to load a kernel; the kernel name is taken from one of 1334\ the following lists, as ordered: 1335\ 1336\ 1. The "kernel" environment variable 1337\ 2. The "bootfile" environment variable 1338\ 1339\ Flags are passed, if provided. 1340\ 1341\ The kernel will be loaded from a directory computed from the 1342\ path given. Two directories will be tried in the following order: 1343\ 1344\ 1. /boot/path 1345\ 2. path 1346\ 1347\ The module_path variable is overridden if load is succesful, by 1348\ prepending the successful path. 1349 1350: load_from_directory ( path len 1 | flags len' path len 2 -- flag ) 1351 local args 1352 2local path 1353 args 1 = if 0 0 then 1354 2local flags 1355 0 0 2local oldmodulepath 1356 0 0 2local newmodulepath 1357 end-locals 1358 1359 \ Set the environment variable module_path, and try loading 1360 \ the kernel again. 1361 modulepath getenv saveenv to oldmodulepath 1362 1363 \ Try prepending /boot/ first 1364 bootpath nip path nip + 1365 oldmodulepath nip dup -1 = if 1366 drop 1367 else 1368 1+ + 1369 then 1370 allocate 1371 if ( out of memory ) 1372 1 exit 1373 then 1374 1375 0 1376 bootpath strcat 1377 path strcat 1378 2dup to newmodulepath 1379 modulepath setenv 1380 1381 \ Try all default kernel names 1382 flags args load_a_kernel 1383 0= if ( success ) 1384 oldmodulepath nip -1 <> if 1385 newmodulepath s" ;" strcat 1386 oldmodulepath strcat 1387 modulepath setenv 1388 newmodulepath drop free-memory 1389 oldmodulepath drop free-memory 1390 then 1391 0 exit 1392 then 1393 1394 \ Well, try without the prepended /boot/ 1395 path newmodulepath drop swap move 1396 path nip 1397 2dup to newmodulepath 1398 modulepath setenv 1399 1400 \ Try all default kernel names 1401 flags args load_a_kernel 1402 if ( failed once more ) 1403 oldmodulepath restoreenv 1404 newmodulepath drop free-memory 1405 1 1406 else 1407 oldmodulepath nip -1 <> if 1408 newmodulepath s" ;" strcat 1409 oldmodulepath strcat 1410 modulepath setenv 1411 newmodulepath drop free-memory 1412 oldmodulepath drop free-memory 1413 then 1414 0 1415 then 1416; 1417 1418\ Try to load a kernel; the kernel name is taken from one of 1419\ the following lists, as ordered: 1420\ 1421\ 1. The "kernel" environment variable 1422\ 2. The "bootfile" environment variable 1423\ 3. The "path" argument 1424\ 1425\ Flags are passed, if provided. 1426\ 1427\ The kernel will be loaded from a directory computed from the 1428\ path given. Two directories will be tried in the following order: 1429\ 1430\ 1. /boot/path 1431\ 2. path 1432\ 1433\ Unless "path" is meant to be kernel name itself. In that case, it 1434\ will first be tried as a full path, and, next, search on the 1435\ directories pointed by module_path. 1436\ 1437\ The module_path variable is overridden if load is succesful, by 1438\ prepending the successful path. 1439 1440: load_directory_or_file ( path len 1 | flags len' path len 2 -- flag ) 1441 local args 1442 2local path 1443 args 1 = if 0 0 then 1444 2local flags 1445 end-locals 1446 1447 \ First, assume path is an absolute path to a directory 1448 flags path args clip_args load_from_directory 1449 dup 0= if exit else drop then 1450 1451 \ Next, assume path points to the kernel 1452 flags path args try_multiple_kernels 1453; 1454 1455: load_kernel_and_modules ( flags len path len' 2 | path len' 1 -- flag ) 1456 load_directory_or_file 1457 0= if ['] load_modules catch then 1458; 1459 |
|
1223: initialize ( addr len -- ) 1224 strdup conf_files .len ! conf_files .addr ! 1225; 1226 | 1460: initialize ( addr len -- ) 1461 strdup conf_files .len ! conf_files .addr ! 1462; 1463 |
1227: load_kernel ( -- ) ( throws: abort ) 1228 s" load ${kernel} ${kernel_options}" ['] evaluate catch 1229 if s" echo Unable to load kernel: ${kernel}" evaluate abort then | 1464: kernel_options ( -- addr len 2 | 0 0 1 ) 1465 s" kernel_options" getenv 1466 dup -1 = if 0 0 1 else 2 then |
1230; 1231 | 1467; 1468 |
1469: kernel_and_options 1470 kernel_options 1471 s" kernel" getenv 1472 rot 1473; 1474 1475: load_kernel ( -- ) ( throws: abort ) 1476 s" kernel" getenv 1477 dup -1 = if 1478 \ If unset, try any kernel 1479 drop 1480 kernel_options load_a_kernel 1481 else 1482 \ If set, try first directory, next file name 1483 kernel_options >r 2swap r> clip_args load_from_directory 1484 dup if 1485 drop 1486 kernel_and_options try_multiple_kernels 1487 then 1488 then 1489 abort" Unable to load a kernel!" 1490; 1491 |
|
1232: read-password { size | buf len -- } 1233 size allocate if out_of_memory throw then 1234 to buf 1235 0 to len 1236 begin 1237 key 1238 dup backspace = if 1239 drop --- 23 unchanged lines hidden --- | 1492: read-password { size | buf len -- } 1493 size allocate if out_of_memory throw then 1494 to buf 1495 0 to len 1496 begin 1497 key 1498 dup backspace = if 1499 drop --- 23 unchanged lines hidden --- |