diff options
author | jhb <jhb@FreeBSD.org> | 2003-12-11 22:42:50 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2003-12-11 22:42:50 +0000 |
commit | 634207c60633df27a19122590ecdf259ef70d28a (patch) | |
tree | b43bfba511a7a66f3787f12dc71d62123a2d969a /sys/boot | |
parent | 4b660977b3a9c1a1fc5c78ebbcea353f5051e59f (diff) | |
download | FreeBSD-src-634207c60633df27a19122590ecdf259ef70d28a.zip FreeBSD-src-634207c60633df27a19122590ecdf259ef70d28a.tar.gz |
- Change the lookup() function to report success or failure using the carry
flag rather than explicitly halting if a lookup failed.
- Add a loop around the call to lookup() to traverse an array of
nul-terminated strings for possible paths to the boot loader. A double
nul character denotes the end of the list.
- Add a new message to say that the boot failed if all of the path lookups
for a boot loader file failed.
- Add '/boot/loader' as a second boot path. If you build an ISO using
risky options to mkisofs such as -U then the loader will be called
'/boot/loader' rather than '/BOOT/LOADER;0'. This allows cdboot to work
with such risky ISO images.
- Bump version to 1.2 to denote added functionality.
The basic idea as well as some of the code were provided by the submitter,
but I added some extra code to use a loop rather than hard-code just 2
possible paths.
PR: misc/43543
Submitted by: kientzle
MFC after: 1 week
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/i386/cdboot/cdboot.s | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/sys/boot/i386/cdboot/cdboot.s b/sys/boot/i386/cdboot/cdboot.s index bf30bff..dbbebdf 100644 --- a/sys/boot/i386/cdboot/cdboot.s +++ b/sys/boot/i386/cdboot/cdboot.s @@ -139,10 +139,26 @@ load_vd: push %eax # Save %eax jmp error # Halt have_vd: # Have Primary VD # -# Lookup the loader binary. -# - mov $loader_path,%si # File to lookup - call lookup # Try to find it +# Try to look up the loader binary using the paths in the loader_paths +# array. +# + mov $loader_paths,%si # Point to start of array +lookup_path: push %si # Save file name pointer + call lookup # Try to find file + pop %di # Restore file name pointer + jnc lookup_found # Found this file + xor %al,%al # Look for next + mov $0xffff,%cx # path name by + repnz # scanning for + scasb # nul char + inc %di # Skip nul + mov %di,%si # Point %si at next path + mov (%si),%al # Get first char of next path + or %al,%al # Is it double nul? + jnz lookup_path # No, try it. + mov $msg_failed,%si # Failed message + jmp error # Halt +lookup_found: # Found a loader file # # Load the binary into the buffer. Due to real mode addressing limitations # we have to read it in in 64k chunks. @@ -266,7 +282,8 @@ pm_end: sti # Turn interrupts back on now # Lookup the file in the path at [SI] from the root directory. # # Trashes: All but BX -# Returns: BX = pointer to record +# Returns: CF = 0 (success), BX = pointer to record +# CF = 1 (not found) # lookup: mov $VD_ROOTDIR+MEM_VOLDESC,%bx # Root directory record push %si @@ -286,17 +303,21 @@ lookup_dir: lodsb # Get first char of path dec %si # Undo lodsb side effect call find_file # Lookup first path item jnc lookup_dir # Try next component - mov $msg_lookupfail,%si # Not found. + mov $msg_lookupfail,%si # Not found message + call putstr + stc # Set carry + ret jmp error lookup_done: mov $msg_lookupok,%si # Success message call putstr + clc # Clear carry ret # # Lookup file at [SI] in directory whose record is at [BX]. # # Trashes: All but returns -# Returns: CF = 0 (success), BX = pointer to record, SX = next path item +# Returns: CF = 0 (success), BX = pointer to record, SI = next path item # CF = 1 (not found), SI = preserved # find_file: mov DIR_EXTENT(%bx),%eax # Load extent @@ -536,7 +557,7 @@ name_len: .byte 0x0 # Length of current name twiddle_index: .byte 0x0 -msg_welcome: .asciz "CD Loader 1.01\r\n\n" +msg_welcome: .asciz "CD Loader 1.2\r\n\n" msg_bootinfo: .asciz "Building the boot loader arguments\r\n" msg_relocate: .asciz "Relocating the loader and the BTX\r\n" msg_jump: .asciz "Starting the BTX loader\r\n" @@ -548,6 +569,9 @@ msg_lookup2: .asciz "... " msg_lookupok: .asciz "Found\r\n" msg_lookupfail: .asciz "File not found\r\n" msg_load2big: .asciz "File too big\r\n" -loader_path: .asciz "/BOOT/LOADER" +msg_failed: .asciz "Boot failed\r\n" twiddle_chars: .ascii "|/-\\" +loader_paths: .asciz "/BOOT/LOADER" + .asciz "/boot/loader" + .byte 0 |