diff --git a/sys/boot/i386/cdboot/cdboot.s b/sys/boot/i386/cdboot/cdboot.s index bf30bff5d2f6..dbbebdf61c95 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. +# Try to look up the loader binary using the paths in the loader_paths +# array. # - mov $loader_path,%si # File to lookup - call lookup # Try to find it + 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