- 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
This commit is contained in:
parent
4b660977b3
commit
634207c606
@ -139,10 +139,26 @@ load_vd: push %eax # Save %eax
|
|||||||
jmp error # Halt
|
jmp error # Halt
|
||||||
have_vd: # Have Primary VD
|
have_vd: # Have Primary VD
|
||||||
#
|
#
|
||||||
# Lookup the loader binary.
|
# Try to look up the loader binary using the paths in the loader_paths
|
||||||
|
# array.
|
||||||
#
|
#
|
||||||
mov $loader_path,%si # File to lookup
|
mov $loader_paths,%si # Point to start of array
|
||||||
call lookup # Try to find it
|
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
|
# Load the binary into the buffer. Due to real mode addressing limitations
|
||||||
# we have to read it in in 64k chunks.
|
# 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.
|
# Lookup the file in the path at [SI] from the root directory.
|
||||||
#
|
#
|
||||||
# Trashes: All but BX
|
# 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
|
lookup: mov $VD_ROOTDIR+MEM_VOLDESC,%bx # Root directory record
|
||||||
push %si
|
push %si
|
||||||
@ -286,17 +303,21 @@ lookup_dir: lodsb # Get first char of path
|
|||||||
dec %si # Undo lodsb side effect
|
dec %si # Undo lodsb side effect
|
||||||
call find_file # Lookup first path item
|
call find_file # Lookup first path item
|
||||||
jnc lookup_dir # Try next component
|
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
|
jmp error
|
||||||
lookup_done: mov $msg_lookupok,%si # Success message
|
lookup_done: mov $msg_lookupok,%si # Success message
|
||||||
call putstr
|
call putstr
|
||||||
|
clc # Clear carry
|
||||||
ret
|
ret
|
||||||
|
|
||||||
#
|
#
|
||||||
# Lookup file at [SI] in directory whose record is at [BX].
|
# Lookup file at [SI] in directory whose record is at [BX].
|
||||||
#
|
#
|
||||||
# Trashes: All but returns
|
# 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
|
# CF = 1 (not found), SI = preserved
|
||||||
#
|
#
|
||||||
find_file: mov DIR_EXTENT(%bx),%eax # Load extent
|
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
|
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_bootinfo: .asciz "Building the boot loader arguments\r\n"
|
||||||
msg_relocate: .asciz "Relocating the loader and the BTX\r\n"
|
msg_relocate: .asciz "Relocating the loader and the BTX\r\n"
|
||||||
msg_jump: .asciz "Starting the BTX loader\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_lookupok: .asciz "Found\r\n"
|
||||||
msg_lookupfail: .asciz "File not found\r\n"
|
msg_lookupfail: .asciz "File not found\r\n"
|
||||||
msg_load2big: .asciz "File too big\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 "|/-\\"
|
twiddle_chars: .ascii "|/-\\"
|
||||||
|
loader_paths: .asciz "/BOOT/LOADER"
|
||||||
|
.asciz "/boot/loader"
|
||||||
|
.byte 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user