Deleted Added
full compact
cdboot.S (86164) cdboot.S (123476)
1#
2# Copyright (c) 2001 John Baldwin
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms are freely
6# permitted provided that the above copyright notice and this
7# paragraph and the following disclaimer are duplicated in all
8# such forms.
9#
10# This software is provided "AS IS" and without any express or
11# implied warranties, including, without limitation, the implied
12# warranties of merchantability and fitness for a particular
13# purpose.
14#
15
1#
2# Copyright (c) 2001 John Baldwin
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms are freely
6# permitted provided that the above copyright notice and this
7# paragraph and the following disclaimer are duplicated in all
8# such forms.
9#
10# This software is provided "AS IS" and without any express or
11# implied warranties, including, without limitation, the implied
12# warranties of merchantability and fitness for a particular
13# purpose.
14#
15
16# $FreeBSD: head/sys/boot/i386/cdboot/cdboot.s 86164 2001-11-07 01:20:33Z jhb $
16# $FreeBSD: head/sys/boot/i386/cdboot/cdboot.s 123476 2003-12-11 22:42:50Z jhb $
17
18#
19# This program is a freestanding boot program to load an a.out binary
20# from a CD-ROM booted with no emulation mode as described by the El
21# Torito standard. Due to broken BIOSen that do not load the desired
22# number of sectors, we try to fit this in as small a space as possible.
23#
24# Basically, we first create a set of boot arguments to pass to the loaded

--- 109 unchanged lines hidden (view full) ---

134 pop %eax # Prepare to
135 inc %eax # try next
136 cmpb $VD_END,(%bx) # Last VD?
137 jne load_vd # No, read next
138 mov $msg_novd,%si # No VD
139 jmp error # Halt
140have_vd: # Have Primary VD
141#
17
18#
19# This program is a freestanding boot program to load an a.out binary
20# from a CD-ROM booted with no emulation mode as described by the El
21# Torito standard. Due to broken BIOSen that do not load the desired
22# number of sectors, we try to fit this in as small a space as possible.
23#
24# Basically, we first create a set of boot arguments to pass to the loaded

--- 109 unchanged lines hidden (view full) ---

134 pop %eax # Prepare to
135 inc %eax # try next
136 cmpb $VD_END,(%bx) # Last VD?
137 jne load_vd # No, read next
138 mov $msg_novd,%si # No VD
139 jmp error # Halt
140have_vd: # Have Primary VD
141#
142# Lookup the loader binary.
142# Try to look up the loader binary using the paths in the loader_paths
143# array.
143#
144#
144 mov $loader_path,%si # File to lookup
145 call lookup # Try to find it
145 mov $loader_paths,%si # Point to start of array
146lookup_path: push %si # Save file name pointer
147 call lookup # Try to find file
148 pop %di # Restore file name pointer
149 jnc lookup_found # Found this file
150 xor %al,%al # Look for next
151 mov $0xffff,%cx # path name by
152 repnz # scanning for
153 scasb # nul char
154 inc %di # Skip nul
155 mov %di,%si # Point %si at next path
156 mov (%si),%al # Get first char of next path
157 or %al,%al # Is it double nul?
158 jnz lookup_path # No, try it.
159 mov $msg_failed,%si # Failed message
160 jmp error # Halt
161lookup_found: # Found a loader file
146#
147# Load the binary into the buffer. Due to real mode addressing limitations
148# we have to read it in in 64k chunks.
149#
150 mov DIR_SIZE(%bx),%eax # Read file length
151 add $SECTOR_SIZE-1,%eax # Convert length to sectors
152 shr $11,%eax
153 cmp $BUFFER_LEN,%eax

--- 107 unchanged lines hidden (view full) ---

261 mov $msg_jump,%si # Display the
262 call putstr # jump message
263 ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point
264
265#
266# Lookup the file in the path at [SI] from the root directory.
267#
268# Trashes: All but BX
162#
163# Load the binary into the buffer. Due to real mode addressing limitations
164# we have to read it in in 64k chunks.
165#
166 mov DIR_SIZE(%bx),%eax # Read file length
167 add $SECTOR_SIZE-1,%eax # Convert length to sectors
168 shr $11,%eax
169 cmp $BUFFER_LEN,%eax

--- 107 unchanged lines hidden (view full) ---

277 mov $msg_jump,%si # Display the
278 call putstr # jump message
279 ljmp $0,$MEM_BTX_ENTRY # Jump to the BTX entry point
280
281#
282# Lookup the file in the path at [SI] from the root directory.
283#
284# Trashes: All but BX
269# Returns: BX = pointer to record
285# Returns: CF = 0 (success), BX = pointer to record
286# CF = 1 (not found)
270#
271lookup: mov $VD_ROOTDIR+MEM_VOLDESC,%bx # Root directory record
272 push %si
273 mov $msg_lookup,%si # Display lookup message
274 call putstr
275 pop %si
276 push %si
277 call putstr
278 mov $msg_lookup2,%si
279 call putstr
280 pop %si
281lookup_dir: lodsb # Get first char of path
282 cmp $0,%al # Are we done?
283 je lookup_done # Yes
284 cmp $'/',%al # Skip path separator.
285 je lookup_dir
286 dec %si # Undo lodsb side effect
287 call find_file # Lookup first path item
288 jnc lookup_dir # Try next component
287#
288lookup: mov $VD_ROOTDIR+MEM_VOLDESC,%bx # Root directory record
289 push %si
290 mov $msg_lookup,%si # Display lookup message
291 call putstr
292 pop %si
293 push %si
294 call putstr
295 mov $msg_lookup2,%si
296 call putstr
297 pop %si
298lookup_dir: lodsb # Get first char of path
299 cmp $0,%al # Are we done?
300 je lookup_done # Yes
301 cmp $'/',%al # Skip path separator.
302 je lookup_dir
303 dec %si # Undo lodsb side effect
304 call find_file # Lookup first path item
305 jnc lookup_dir # Try next component
289 mov $msg_lookupfail,%si # Not found.
306 mov $msg_lookupfail,%si # Not found message
307 call putstr
308 stc # Set carry
309 ret
290 jmp error
291lookup_done: mov $msg_lookupok,%si # Success message
292 call putstr
310 jmp error
311lookup_done: mov $msg_lookupok,%si # Success message
312 call putstr
313 clc # Clear carry
293 ret
294
295#
296# Lookup file at [SI] in directory whose record is at [BX].
297#
298# Trashes: All but returns
314 ret
315
316#
317# Lookup file at [SI] in directory whose record is at [BX].
318#
319# Trashes: All but returns
299# Returns: CF = 0 (success), BX = pointer to record, SX = next path item
320# Returns: CF = 0 (success), BX = pointer to record, SI = next path item
300# CF = 1 (not found), SI = preserved
301#
302find_file: mov DIR_EXTENT(%bx),%eax # Load extent
303 xor %edx,%edx
304 mov DIR_EA_LEN(%bx),%dl
305 add %edx,%eax # Skip extended attributes
306 mov %eax,rec_lba # Save LBA
307 mov DIR_SIZE(%bx),%eax # Save size

--- 223 unchanged lines hidden (view full) ---

531# State for searching dir
532#
533rec_lba: .long 0x0 # LBA (adjusted for EA)
534rec_size: .long 0x0 # File size
535name_len: .byte 0x0 # Length of current name
536
537twiddle_index: .byte 0x0
538
321# CF = 1 (not found), SI = preserved
322#
323find_file: mov DIR_EXTENT(%bx),%eax # Load extent
324 xor %edx,%edx
325 mov DIR_EA_LEN(%bx),%dl
326 add %edx,%eax # Skip extended attributes
327 mov %eax,rec_lba # Save LBA
328 mov DIR_SIZE(%bx),%eax # Save size

--- 223 unchanged lines hidden (view full) ---

552# State for searching dir
553#
554rec_lba: .long 0x0 # LBA (adjusted for EA)
555rec_size: .long 0x0 # File size
556name_len: .byte 0x0 # Length of current name
557
558twiddle_index: .byte 0x0
559
539msg_welcome: .asciz "CD Loader 1.01\r\n\n"
560msg_welcome: .asciz "CD Loader 1.2\r\n\n"
540msg_bootinfo: .asciz "Building the boot loader arguments\r\n"
541msg_relocate: .asciz "Relocating the loader and the BTX\r\n"
542msg_jump: .asciz "Starting the BTX loader\r\n"
543msg_badread: .ascii "Read Error: 0x"
544hex_error: .ascii "00\r\n"
545msg_novd: .asciz "Could not find Primary Volume Descriptor\r\n"
546msg_lookup: .asciz "Looking up "
547msg_lookup2: .asciz "... "
548msg_lookupok: .asciz "Found\r\n"
549msg_lookupfail: .asciz "File not found\r\n"
550msg_load2big: .asciz "File too big\r\n"
561msg_bootinfo: .asciz "Building the boot loader arguments\r\n"
562msg_relocate: .asciz "Relocating the loader and the BTX\r\n"
563msg_jump: .asciz "Starting the BTX loader\r\n"
564msg_badread: .ascii "Read Error: 0x"
565hex_error: .ascii "00\r\n"
566msg_novd: .asciz "Could not find Primary Volume Descriptor\r\n"
567msg_lookup: .asciz "Looking up "
568msg_lookup2: .asciz "... "
569msg_lookupok: .asciz "Found\r\n"
570msg_lookupfail: .asciz "File not found\r\n"
571msg_load2big: .asciz "File too big\r\n"
551loader_path: .asciz "/BOOT/LOADER"
572msg_failed: .asciz "Boot failed\r\n"
552twiddle_chars: .ascii "|/-\\"
573twiddle_chars: .ascii "|/-\\"
574loader_paths: .asciz "/BOOT/LOADER"
575 .asciz "/boot/loader"
576 .byte 0
553
577