boot0.S (185776) | boot0.S (186598) |
---|---|
1/* 2 * Copyright (c) 2008 Luigi Rizzo (mostly documentation) 3 * Copyright (c) 2002 Bruce M. Simpson 4 * Copyright (c) 1998 Robert Nordier 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms are freely 8 * permitted provided that the above copyright notice and this 9 * paragraph and the following disclaimer are duplicated in all 10 * such forms. 11 * 12 * This software is provided "AS IS" and without any express or 13 * implied warranties, including, without limitation, the implied 14 * warranties of merchantability and fitness for a particular 15 * purpose. 16 * | 1/* 2 * Copyright (c) 2008 Luigi Rizzo (mostly documentation) 3 * Copyright (c) 2002 Bruce M. Simpson 4 * Copyright (c) 1998 Robert Nordier 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms are freely 8 * permitted provided that the above copyright notice and this 9 * paragraph and the following disclaimer are duplicated in all 10 * such forms. 11 * 12 * This software is provided "AS IS" and without any express or 13 * implied warranties, including, without limitation, the implied 14 * warranties of merchantability and fitness for a particular 15 * purpose. 16 * |
17 * $FreeBSD: head/sys/boot/i386/boot0/boot0.S 185776 2008-12-08 20:53:27Z sobomax $ | 17 * $FreeBSD: head/sys/boot/i386/boot0/boot0.S 186598 2008-12-30 09:40:50Z luigi $ |
18 */ 19 20/* build options: */ 21#ifdef SIO /* use serial console on COM1. */ 22#endif 23 24#ifdef PXE /* enable PXE/INT18 booting with F6 */ | 18 */ 19 20/* build options: */ 21#ifdef SIO /* use serial console on COM1. */ 22#endif 23 24#ifdef PXE /* enable PXE/INT18 booting with F6 */ |
25#define SAVE_MORE_MEMORY |
|
25#endif 26 27#ifdef CHECK_DRIVE /* make sure we boot from a HD. */ 28#endif 29 30#ifdef ONLY_F_KEYS /* Only F1..F6, no digits on console */ 31#endif 32 --- 236 unchanged lines hidden (view full) --- 269 jnc next_entry # No 270 movb (%bx),%al # Load type 271 test %al, %al # skip empty partition 272 jz next_entry 273 /* 274 * Scan the table of bootable ids, which starts at %di and has 275 * length TLEN. On a match, %di points to the element following the 276 * match; the corresponding offset to the description is $(TLEN-1) | 26#endif 27 28#ifdef CHECK_DRIVE /* make sure we boot from a HD. */ 29#endif 30 31#ifdef ONLY_F_KEYS /* Only F1..F6, no digits on console */ 32#endif 33 --- 236 unchanged lines hidden (view full) --- 270 jnc next_entry # No 271 movb (%bx),%al # Load type 272 test %al, %al # skip empty partition 273 jz next_entry 274 /* 275 * Scan the table of bootable ids, which starts at %di and has 276 * length TLEN. On a match, %di points to the element following the 277 * match; the corresponding offset to the description is $(TLEN-1) |
277 * bytes ahead. If we don't find a match, we hit the 'unknown' entry. | 278 * bytes ahead. We use a count of TLEN+1 so if we don't find a match 279 * within the first TLEN entries, we hit the 'unknown' entry. |
278 */ 279 movw $bootable_ids,%di # Lookup tables | 280 */ 281 movw $bootable_ids,%di # Lookup tables |
280 movb $(TLEN),%cl # Number of entries | 282 movb $(TLEN+1),%cl # Number of entries |
281 repne # Locate 282 scasb # type 283 /* 284 * Get the matching element in the next array. 285 * The byte at $(TLEN-1)(%di) contains the offset of the description 286 * string from %di, so we add the number and print the string. 287 */ 288 addw $(TLEN-1), %di # Adjust --- 30 unchanged lines hidden (view full) --- 319 * to indicate end of string. 320 */ 321print_drive: addb $'0'|0x80,%al # Save next 322 movb %al,_NXTDRV(%bp) # drive number 323 movw $drive,%di # Display 324 callw putx # item 325 /* 326 * Menu is complete, display a prompt followed by current selection. | 283 repne # Locate 284 scasb # type 285 /* 286 * Get the matching element in the next array. 287 * The byte at $(TLEN-1)(%di) contains the offset of the description 288 * string from %di, so we add the number and print the string. 289 */ 290 addw $(TLEN-1), %di # Adjust --- 30 unchanged lines hidden (view full) --- 321 * to indicate end of string. 322 */ 323print_drive: addb $'0'|0x80,%al # Save next 324 movb %al,_NXTDRV(%bp) # drive number 325 movw $drive,%di # Display 326 callw putx # item 327 /* 328 * Menu is complete, display a prompt followed by current selection. |
327 * 'decw %si' makes the register point to the space after 'Default: ' | 329 * 'decw %si' makes the register point to the space after 'Boot: ' |
328 * so we do not see an extra CRLF on the screen. 329 */ 330print_prompt: movw $prompt,%si # Display 331 callw putstr # prompt 332 movb _OPT(%bp),%dl # Display 333 decw %si # default 334 callw putkey # key 335 jmp start_input # Skip beep --- 30 unchanged lines hidden (view full) --- 366 int $0x1a # get system time 367 cmpw %di,%dx # Timeout? 368 jb read_key # No 369 370 /* 371 * Timed out or default selection 372 */ 373use_default: movb _OPT(%bp),%al # Load default | 330 * so we do not see an extra CRLF on the screen. 331 */ 332print_prompt: movw $prompt,%si # Display 333 callw putstr # prompt 334 movb _OPT(%bp),%dl # Display 335 decw %si # default 336 callw putkey # key 337 jmp start_input # Skip beep --- 30 unchanged lines hidden (view full) --- 368 int $0x1a # get system time 369 cmpw %di,%dx # Timeout? 370 jb read_key # No 371 372 /* 373 * Timed out or default selection 374 */ 375use_default: movb _OPT(%bp),%al # Load default |
376 orb $NOUPDATE,_FLAGS(%bp) # Disable updates |
|
374 jmp check_selection # Join common code 375 376 /* 377 * Get the keystroke. 378 * ENTER or CR confirm the current selection (same as a timeout). 379 * Otherwise convert F1..F6 (or '1'..'6') to 0..5 and check if the 380 * selection is valid. 381 * The SIO code uses ascii chars, the console code uses scancodes. --- 198 unchanged lines hidden (view full) --- 580 movw %di,%sp # Restore 581 popw %si # Restore 582 retw # To caller 583 584/* 585 * Various menu strings. 'item' goes after 'prompt' to save space. 586 * Also use shorter versions to make room for the PXE/INT18 code. 587 */ | 377 jmp check_selection # Join common code 378 379 /* 380 * Get the keystroke. 381 * ENTER or CR confirm the current selection (same as a timeout). 382 * Otherwise convert F1..F6 (or '1'..'6') to 0..5 and check if the 383 * selection is valid. 384 * The SIO code uses ascii chars, the console code uses scancodes. --- 198 unchanged lines hidden (view full) --- 583 movw %di,%sp # Restore 584 popw %si # Restore 585 retw # To caller 586 587/* 588 * Various menu strings. 'item' goes after 'prompt' to save space. 589 * Also use shorter versions to make room for the PXE/INT18 code. 590 */ |
591prompt: |
|
588#ifdef PXE | 592#ifdef PXE |
589prompt: .ascii "\nBoot:" 590item: .ascii " "; .byte ' '|0x80 591#else 592prompt: .ascii "\nDefault:" 593item: .ascii " "; .byte ' '|0x80 | 593 .ascii "\nF6 PXE\r" |
594#endif | 594#endif |
595 .ascii "\nBoot:" 596item: .ascii " "; .byte ' '|0x80 |
|
595crlf: .ascii "\r"; .byte '\n'|0x80 596 597/* Partition type tables */ 598 599bootable_ids: 600 /* 601 * These values indicate bootable types we know about. 602 * Corresponding descriptions are at desc_ofs: 603 * Entries don't need to be sorted. 604 */ | 597crlf: .ascii "\r"; .byte '\n'|0x80 598 599/* Partition type tables */ 600 601bootable_ids: 602 /* 603 * These values indicate bootable types we know about. 604 * Corresponding descriptions are at desc_ofs: 605 * Entries don't need to be sorted. 606 */ |
605 .byte 0x1, 0x6, 0x7, 0xb, 0xc 606#ifndef SAVE_MEMORY 607 .byte 0xe 608#endif 609 .byte 0x83, 0xa5, 0xa6, 0xa9, 0x4 | 607 .byte 0x83, 0xa5, 0xa6, 0xa9, 0x06, 0x07, 0x0b |
610#ifndef SAVE_MORE_MEMORY | 608#ifndef SAVE_MORE_MEMORY |
611 .byte 0x5, 0xf | 609 .byte 0x05 # extended partition |
612#endif | 610#endif |
611#ifndef SAVE_MEMORY /* other DOS partitions */ 612 .byte 0x01 # FAT12 613 .byte 0x04 # FAT16 < 32M 614#endif |
|
613 614desc_ofs: 615 /* 616 * Offsets that match the known types above, used to point to the 617 * actual partition name. The last entry must point to os_misc, 618 * which is used for non-matching names. 619 */ | 615 616desc_ofs: 617 /* 618 * Offsets that match the known types above, used to point to the 619 * actual partition name. The last entry must point to os_misc, 620 * which is used for non-matching names. 621 */ |
620 .byte os_dos-. # 1, FAT12 DOS 621 .byte os_dos-. # 6, FAT16 <32M, DOS/WIN 622 .byte os_win-. # 7, FAT16 >=32M Windows 623 .byte os_win-. # 11, FAT32 624 .byte os_win-. # 12, FAT32-LBA 625#ifndef SAVE_MEMORY 626 .byte os_win-. # 14, FAT16-LBA 627#endif | |
628 .byte os_linux-. # 131, Linux 629 .byte os_freebsd-. # 165, FreeBSD 630 .byte os_bsd-. # 166, OpenBSD 631 .byte os_bsd-. # 169, NetBSD | 622 .byte os_linux-. # 131, Linux 623 .byte os_freebsd-. # 165, FreeBSD 624 .byte os_bsd-. # 166, OpenBSD 625 .byte os_bsd-. # 169, NetBSD |
632 .byte os_dos-. # 4, FAT16 < 32M | 626 .byte os_dos-. # 6, FAT16 >= 32M 627 .byte os_win-. # 7, NTFS 628 .byte os_win-. # 11, FAT32 629 |
633#ifndef SAVE_MORE_MEMORY 634 .byte os_ext-. # 5, DOS Ext | 630#ifndef SAVE_MORE_MEMORY 631 .byte os_ext-. # 5, DOS Ext |
635 .byte os_ext-. # 15, DOS Ext-LBA | |
636#endif | 632#endif |
637 | 633#ifndef SAVE_MEMORY 634 .byte os_dos-. # 1, FAT12 DOS 635 .byte os_dos-. # 4, FAT16 <32M 636#endif |
638 .byte os_misc-. # Unknown 639 640 /* 641 * And here are the strings themselves. The last byte of 642 * the string has bit 7 set. 643 */ 644os_misc: .byte '?'|0x80 645os_dos: | 637 .byte os_misc-. # Unknown 638 639 /* 640 * And here are the strings themselves. The last byte of 641 * the string has bit 7 set. 642 */ 643os_misc: .byte '?'|0x80 644os_dos: |
646#ifndef SAVE_MEMORY /* DOS string only if room */ | 645#ifndef SAVE_MORE_MEMORY /* 'DOS' remapped to 'WIN' if no room */ |
647 .ascii "DO"; .byte 'S'|0x80 648#endif | 646 .ascii "DO"; .byte 'S'|0x80 647#endif |
649os_win: .ascii "WI"; .byte 'N'|0x80 | 648os_win: .ascii "Wi"; .byte 'n'|0x80 |
650os_linux: .ascii "Linu"; .byte 'x'|0x80 651os_freebsd: .ascii "Free" 652os_bsd: .ascii "BS"; .byte 'D'|0x80 653#ifndef SAVE_MORE_MEMORY 654os_ext: .ascii "EX"; .byte 'T'|0x80 655#endif 656 657 .org (0x200 + B0_OFF),0x90 --- 26 unchanged lines hidden --- | 649os_linux: .ascii "Linu"; .byte 'x'|0x80 650os_freebsd: .ascii "Free" 651os_bsd: .ascii "BS"; .byte 'D'|0x80 652#ifndef SAVE_MORE_MEMORY 653os_ext: .ascii "EX"; .byte 'T'|0x80 654#endif 655 656 .org (0x200 + B0_OFF),0x90 --- 26 unchanged lines hidden --- |