boot0.S (138048) | boot0.S (139948) |
---|---|
1/* 2 * Copyright (c) 2002 Bruce M. Simpson 3 * Copyright (c) 1998 Robert Nordier 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms are freely 7 * permitted provided that the above copyright notice and this 8 * paragraph and the following disclaimer are duplicated in all 9 * such forms. 10 * 11 * This software is provided "AS IS" and without any express or 12 * implied warranties, including, without limitation, the implied 13 * warranties of merchantability and fitness for a particular 14 * purpose. 15 * | 1/* 2 * Copyright (c) 2002 Bruce M. Simpson 3 * Copyright (c) 1998 Robert Nordier 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms are freely 7 * permitted provided that the above copyright notice and this 8 * paragraph and the following disclaimer are duplicated in all 9 * such forms. 10 * 11 * This software is provided "AS IS" and without any express or 12 * implied warranties, including, without limitation, the implied 13 * warranties of merchantability and fitness for a particular 14 * purpose. 15 * |
16 * $FreeBSD: head/sys/boot/i386/boot0/boot0.S 138048 2004-11-24 15:39:04Z jhb $ | 16 * $FreeBSD: head/sys/boot/i386/boot0/boot0.S 139948 2005-01-09 23:30:35Z peadar $ |
17 */ 18 19/* A 512-byte boot manager. */ 20#ifdef SIO 21/* ... using a serial console on COM1. */ 22#endif 23 24 .set NHRDRV,0x475 # Number of hard drives --- 74 unchanged lines hidden (view full) --- 99 movw COMSPEED,%ax # defined by Makefile 100 callw bioscom 101#endif 102/* 103 * Check what flags were loaded with us, specifically if a predefined drive 104 * number should be used. If what the bios gives us is bad, use the '0' in 105 * the block instead. 106 */ | 17 */ 18 19/* A 512-byte boot manager. */ 20#ifdef SIO 21/* ... using a serial console on COM1. */ 22#endif 23 24 .set NHRDRV,0x475 # Number of hard drives --- 74 unchanged lines hidden (view full) --- 99 movw COMSPEED,%ax # defined by Makefile 100 callw bioscom 101#endif 102/* 103 * Check what flags were loaded with us, specifically if a predefined drive 104 * number should be used. If what the bios gives us is bad, use the '0' in 105 * the block instead. 106 */ |
107 testb $0x20,_FLAGS(%bp) # Set number drive? | 107 testb $0x20,_FLAGS(%bp) # Set drive number? |
108 jnz main.1 # Yes 109 testb %dl,%dl # Drive number valid? 110 js main.2 # Possibly (0x80 set) | 108 jnz main.1 # Yes 109 testb %dl,%dl # Drive number valid? 110 js main.2 # Possibly (0x80 set) |
111/* 112 * Only update the boot-sector when there is a valid drive number or 113 * the drive number is set manually. 114 */ 115 orb $0x40,_FLAGS(%bp) # Disable updates |
|
111main.1: movb _SETDRV(%bp),%dl # Drive number to use 112/* 113 * Whatever we decided to use, now store it into the fake 114 * partition entry that lives in the data space above us. 115 */ 116main.2: movb %dl,_FAKE(%bp) # Save drive number 117 callw putn # To new line 118 pushw %dx # Save drive number --- 21 unchanged lines hidden (view full) --- 140 movw $tables,%di # Lookup tables 141 movb $TBL0SZ,%cl # Number of entries 142 repne # Exclude 143 scasb # partition? 144 je main.5 # Yes 145/* 146 * Now scan the table of known types 147 */ | 116main.1: movb _SETDRV(%bp),%dl # Drive number to use 117/* 118 * Whatever we decided to use, now store it into the fake 119 * partition entry that lives in the data space above us. 120 */ 121main.2: movb %dl,_FAKE(%bp) # Save drive number 122 callw putn # To new line 123 pushw %dx # Save drive number --- 21 unchanged lines hidden (view full) --- 145 movw $tables,%di # Lookup tables 146 movb $TBL0SZ,%cl # Number of entries 147 repne # Exclude 148 scasb # partition? 149 je main.5 # Yes 150/* 151 * Now scan the table of known types 152 */ |
148 movb $TBL1SZ,%cl # Number of entries 149 repne # Known 150 scasb # type? 151 jne main.4 # No | 153 movb $TBL1SZ+1,%cl # Number of entries 154 repne # Locate 155 scasb # type |
152/* | 156/* |
153 * If it matches get the matching element in the next array. If it doesn't, 154 * we are already pointing at its first element which points to a "?". | 157 * Get the matching element in the next array. |
155 */ | 158 */ |
156 addw $TBL1SZ,%di # Adjust 157main.4: movb (%di),%cl # Partition | 159 addw $TBL1SZ-1, %di # Adjust 160 movb (%di),%cl # Partition |
158 addw %cx,%di # description 159 callw putx # Display it 160main.5: incw %dx # Next item 161 addb $0x10,%bl # Next entry 162 jnc main.3 # Till done 163/* 164 * Passed a 256 byte boundary; the table is finished. 165 * Add one to the drive number and check it is valid. --- 134 unchanged lines hidden (view full) --- 300 * Remember to un-ascii it. Hey 0x80 is already set, cool! 301 */ 302 jne main.15 # If not F5/#5 303 movb _NXTDRV(%bp),%dl # Next drive 304 subb $'0',%dl # number 305/* 306 * Load selected bootsector to the LOAD location in RAM. 307 * If it fails to read or isn't marked bootable, treat it as a bad selection. | 161 addw %cx,%di # description 162 callw putx # Display it 163main.5: incw %dx # Next item 164 addb $0x10,%bl # Next entry 165 jnc main.3 # Till done 166/* 167 * Passed a 256 byte boundary; the table is finished. 168 * Add one to the drive number and check it is valid. --- 134 unchanged lines hidden (view full) --- 303 * Remember to un-ascii it. Hey 0x80 is already set, cool! 304 */ 305 jne main.15 # If not F5/#5 306 movb _NXTDRV(%bp),%dl # Next drive 307 subb $'0',%dl # number 308/* 309 * Load selected bootsector to the LOAD location in RAM. 310 * If it fails to read or isn't marked bootable, treat it as a bad selection. |
308 * XXX: What does %si carry? | |
309 */ 310main.15: movw $LOAD,%bx # Address for read 311 movb $0x2,%ah # Read sector 312 callw intx13 # from disk 313 jc main.10 # If error 314 cmpw $MAGIC,0x1fe(%bx) # Bootable? 315 jne main.10 # No | 311 */ 312main.15: movw $LOAD,%bx # Address for read 313 movb $0x2,%ah # Read sector 314 callw intx13 # from disk 315 jc main.10 # If error 316 cmpw $MAGIC,0x1fe(%bx) # Bootable? 317 jne main.10 # No |
316 pushw %si # Save | |
317 movw $crlf,%si # Leave some 318 callw puts # space | 318 movw $crlf,%si # Leave some 319 callw puts # space |
319 popw %si # Restore | |
320 jmp *%bx # Invoke bootstrap 321 322/* 323 * Display routines 324 */ 325putkey: 326#ifndef SIO 327 movb $'F',%al # Display --- 80 unchanged lines hidden (view full) --- 408 .byte 0x0, 0x5, 0xf 409/* 410 * These values indicate bootable types we know the names of. 411 */ 412 .byte 0x1, 0x4, 0x6, 0xb, 0xc, 0xe, 0x83 413 .byte 0x9f, 0xa5, 0xa6, 0xa9 414/* 415 * These are offsets that match the known names above and point to the strings | 320 jmp *%bx # Invoke bootstrap 321 322/* 323 * Display routines 324 */ 325putkey: 326#ifndef SIO 327 movb $'F',%al # Display --- 80 unchanged lines hidden (view full) --- 408 .byte 0x0, 0x5, 0xf 409/* 410 * These values indicate bootable types we know the names of. 411 */ 412 .byte 0x1, 0x4, 0x6, 0xb, 0xc, 0xe, 0x83 413 .byte 0x9f, 0xa5, 0xa6, 0xa9 414/* 415 * These are offsets that match the known names above and point to the strings |
416 * that will be printed. | 416 * that will be printed. os_misc will be used if the search of the above table 417 * runs over. |
417 */ | 418 */ |
418 .byte os_misc-. # Unknown | |
419 .byte os_dos-. # DOS 420 .byte os_dos-. # DOS 421 .byte os_dos-. # DOS 422 .byte os_dos-. # Windows 423 .byte os_dos-. # Windows 424 .byte os_dos-. # Windows 425 .byte os_linux-. # Linux 426 .byte os_bsd-. # BSD/OS 427 .byte os_freebsd-. # FreeBSD 428 .byte os_bsd-. # OpenBSD 429 .byte os_bsd-. # NetBSD | 419 .byte os_dos-. # DOS 420 .byte os_dos-. # DOS 421 .byte os_dos-. # DOS 422 .byte os_dos-. # Windows 423 .byte os_dos-. # Windows 424 .byte os_dos-. # Windows 425 .byte os_linux-. # Linux 426 .byte os_bsd-. # BSD/OS 427 .byte os_freebsd-. # FreeBSD 428 .byte os_bsd-. # OpenBSD 429 .byte os_bsd-. # NetBSD |
430 .byte os_misc-. # Unknown |
|
430/* 431 * And here are the strings themselves. 0x80 or'd into a byte indicates 432 * the end of the string. (not so great for Russians but...) 433 */ 434os_misc: .ascii "?"; .byte '?'|0x80 435os_dos: .ascii "DO"; .byte 'S'|0x80 436os_linux: .ascii "Linu"; .byte 'x'|0x80 437os_freebsd: .ascii "Free" --- 23 unchanged lines hidden --- | 431/* 432 * And here are the strings themselves. 0x80 or'd into a byte indicates 433 * the end of the string. (not so great for Russians but...) 434 */ 435os_misc: .ascii "?"; .byte '?'|0x80 436os_dos: .ascii "DO"; .byte 'S'|0x80 437os_linux: .ascii "Linu"; .byte 'x'|0x80 438os_freebsd: .ascii "Free" --- 23 unchanged lines hidden --- |