--- Net2/arch/i386/boot/start.s 2018/04/24 18:12:41 1.1 +++ Net2/arch/i386/boot/start.s 2018/04/24 18:20:54 1.1.1.2 @@ -28,13 +28,69 @@ /* * HISTORY - * $Log: start.s,v $ - * Revision 1.1 2018/04/24 18:12:41 root - * Initial revision + * start.S,v +Revision 1.2 1993/07/11 12:02:24 andrew +Fixes from bde, including support for loading @ any MB boundary (e.g. a +kernel linked for 0xfe100000 will load at the 1MB mark) and read-ahead +buffering to speed booting from floppies. Also works with aha174x +controllers in enhanced mode. + + * + * 93/07/06 bde + * Restored BOOTSEG to 0x9000 for distribution. It should be decided + * at boot time to locate the bootstrap immediately underneath the + * debugger or whatever is in high memory. This isn't safe yet, + * because it might make the read-ahead buffer might lie across a 64K + * DMA boundary. + * + * 93/07/03 bde + * Some floppy BIOS's can only handle reads of one track, so a LOADSZ + * of 16 doesn't work. 15 will do for now. + * + * 93/06/29 bde + * LOADSZ is 16, not 14. The BIOS can handle a minimum of one floppy + * cylinder so it can always handle 16 sectors starting at head 0, + * sector 1. + * + * 93/06/28 bde + * Changed addr16's to addr32's. One before a useless "xor %ecx, %ecx" + * did nothing (removed both prefix and xor). + * + * Initialize head = %dh = 0 for floppy case. + * + * Fixed #ifdef DEBUG ... #endif that split data32; jmp load. If + * DEBUG is defined then the jmp doesn't get prefixed. This is fatal + * iff the jmp is long. Usually the jmp will be short and the prefix + * unnecessary. But it is more likely to be necessary if DEBUG is + * defined. + * + * 93/06/27 bde + * Removed bogus Int 21. There is no Int 21 BIOS call. The drive + * number is passed to here in %dl and the Int 21 is at best a nop. + * Some BIOS's treat Int 21 as a stray hardware interrupt and shut + * down all in-service interrupts. This should not be a problem + * because this are not an interrupt handler so there are no + * in-service interrupts, but ... + * + * Fixed fd/hd decision. "%dl ge 0x80" (signed comparison) was always + * true, so fd's were treated as hd's. This was not a problem because + * the boot block has a partition table. + * + * Reduced BOOTSEG and added breakpoint so that debugger can look at + * this. Having a fixed boot address is bad because some machines don't + * have 640K and others have debuggers and/or BIOS stuff in high memory. * - * Revision 1.1 1993/03/21 18:08:42 cgd - * after 0.2.2 "stable" patches applied + * 93/04/30 bde + * Commented out " # %". It's not C, and gcc-2's + * cpp doesn't allow it. "# identifier" isn't C either but works for now. * + * Use $ EXT instead of $EXT to avoid broken DOLLARS_IN_IDENTIFIERS stuff + * in gcc-2.3.3. (Bug is still in gcc-2.4.5 but is avoided by using .S + * files.) + * +Revision 1.1 1993/03/21 18:08:42 cgd +after 0.2.2 "stable" patches applied + * Revision 2.2 92/04/04 11:36:29 rpd * Fix Intel Copyright as per B. Davies authorization. * [92/04/03 rvb] @@ -86,10 +142,10 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT .file "start.s" -BOOTSEG = 0x9000 # boot will be loaded at 640k-64k +BOOTSEG = 0x9000 # boot will be loaded here (below 640K) BOOTSTACK = 0xe000 # boot stack SIGNATURE = 0xaa55 -LOADSZ = 14 # size of unix boot +LOADSZ = 15 # size of unix boot PARTSTART = 0x1be # starting address of partition table NUMPART = 4 # number of partitions in partition table PARTSZ = 16 # each partition table entry is 16 bytes @@ -99,9 +155,8 @@ BOOTABLE = 0x80 # value of boot_ind, mea .text ENTRY(boot1) - - # boot1 is loaded at 0x0:0x7c00 - # ljmp to the next instruction to set up %cs + # start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 + # ljmp to the next instruction to adjust %cs data32 ljmp $0x7c0, $start @@ -110,7 +165,6 @@ start: mov %cs, %ax mov %ax, %ds - # set up %ss and %esp data32 mov $BOOTSEG, %eax @@ -127,14 +181,11 @@ start: data32 call message #endif - # get the boot drive id - movb $0x33, %ah - movb $0x05, %al - int $0x21 + # bootstrap passes us drive number in %dl cmpb $0x80, %dl data32 - jge hd + jae hd fd: # reset the disk system @@ -148,14 +199,15 @@ fd: int $0x13 data32 mov $0x0001, %ecx # cyl 0, sector 1 - data32 + movb $0, %dh # head #ifdef DEBUG data32 mov $three, %esi data32 call message #endif - jmp load + data32 + jmp load hd: /**** load sector 0 into the BOOTSEG ****/ #ifdef DEBUG @@ -182,13 +234,13 @@ hd: /**** load sector 0 into the BOOTSEG data32 jb read_error - /***# find the bootable partition *****/ + /***# find the first 386BSD partition *****/ data32 mov $PARTSTART, %ebx data32 mov $NUMPART, %ecx again: - addr16 + addr32 movb %es:4(%ebx), %al cmpb $BSDPART, %al data32 @@ -217,12 +269,10 @@ again: */ found: - addr16 + addr32 movb %es:1(%ebx), %dh /* head */ - addr16 - xor %ecx, %ecx - addr16 - movw %es:2(%ebx), %ecx /*sect,cyl (+ 2 bytes junk in top word )*/ + addr32 + movl %es:2(%ebx), %ecx /*sect, cyl (+ 2 bytes junk in top word) */ load: movb $0x2, %ah /* function 2 */ @@ -243,14 +293,13 @@ load: call message #endif data32 - ljmp $BOOTSEG, $EXT(boot2) + ljmp $BOOTSEG, $ EXT(boot2) # # read_error # read_error: - data32 mov $eread, %esi err_stop: @@ -264,9 +313,11 @@ err_stop: # message: +/* # Use BIOS "int 10H Function 0Eh" to write character in teletype mode # %ah = 0xe %al = character # %bh = page %bl = foreground color (graphics modes) +*/ data32 push %eax @@ -312,7 +363,7 @@ eread: String "Read error\r\n\0" enoboot: String "No bootable partition\r\n\0" endofcode: /* throw in a partition in case we are block0 as well */ -/* flag,head,sec,cyl,typ,ehead,esect,ecyl,start,len */ +/* flag, head, sec, cyl, typ, ehead, esect, ecyl, start, len */ . = EXT(boot1) + PARTSTART .byte 0x0,0,0,0,0,0,0,0 .long 0,0