--- Net2/arch/i386/boot/boot.c 2018/04/24 18:12:41 1.1 +++ Net2/arch/i386/boot/boot.c 2018/04/24 18:20:53 1.1.1.2 @@ -28,14 +28,49 @@ /* * HISTORY - * $Log: boot.c,v $ - * Revision 1.1 2018/04/24 18:12:41 root - * Initial revision + * boot.c,v + * Revision 1.8 1993/07/11 12:02:21 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. * - * Revision 1.1 1993/03/21 18:08:26 cgd + * Revision 1.7 1993/06/18 06:50:52 cgd + * convert magic numbers to network byte order, and attendent changes + * + * Revision 1.6 1993/06/14 00:47:08 deraadt + * *whoops*. The previous commit killed a few important characters of code. + * + * Revision 1.5 1993/06/05 22:52:11 cgd + * make sure kernel is small enough; this is a really weird fix from + * rod, pk patch #159. the comment is: + * + * The +28672 is for memory allocated by locore.s that must fit in the bss! + * + * this seems way wrong to me, but i'm not going to fix it in locore right + * now... + * + * Revision 1.4 1993/05/04 10:22:39 deraadt + * if we timeout asking for kernel name, print a \n before proceeding. + * Funny how one character can bug ya so much, eh? + * + * Revision 1.3 1993/04/28 06:37:58 cgd + * bsd->netbsd + * + * Revision 1.2 1993/04/28 05:32:55 cgd + * new kernel name is "bsd" also, add "o*" to list of kernels to boot. + * + * Revision 1.1 1993/03/21 18:08:26 cgd * after 0.2.2 "stable" patches applied * * Revision 2.2 92/04/04 11:34:37 rpd + * + * 93/07/03 bde + * Write first 4096 bytes to load address, not always to address 0. + * + * 93/06/29 bde + * Don't clobber BIOS variables. + * * Change date in banner. * [92/04/03 16:51:14 rvb] * @@ -74,13 +109,13 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT #include #include - struct exec head; int argv[10], esym; char *name; char *names[] = { - "/386bsd", "/386bsd.old", - "/vmunix", "/vmunix.old" + "/netbsd", "/onetbsd", "/netbsd.old", + "/386bsd", "/o386bsd", "/386bsd.old", + "/vmunix", "/ovmunix", "/vmunix.old" }; #define NUMNAMES (sizeof(names)/sizeof(char *)) @@ -89,10 +124,13 @@ boot(drive) int drive; { int loadflags, currname = 0; - printf("\n>> 386bsd BOOT @ 0x%x: %d/%d k of memory [20/9/92]\n", + char *t; + + printf("\n>> NetBSD BOOT @ 0x%x: %d/%d k of memory [%s]\n", ouraddr, argv[7] = memsize(0), - argv[8] = memsize(1)); + argv[8] = memsize(1), + "1.8"); printf("use options hd(1,...... to boot sd0 when wd0 is also installed\n"); gateA20(); loadstart: @@ -124,6 +162,7 @@ loadprog(howto) { long int startaddr; long int addr; /* physical address.. not directly useable */ + long int addr0; int i; static int (*x_entry)() = 0; unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ @@ -131,18 +170,18 @@ loadprog(howto) argv[3] = 0; argv[4] = 0; read(&head, sizeof(head)); - if (head.a_magic == 0413 ) - { - poff = 4096; - } - else - { + if ( N_BADMAG(head)) { printf("Invalid format!\n"); return; } + poff = N_TXTOFF(head); + /*if(poff==0) + poff = 32;*/ + startaddr = (int)head.a_entry; addr = (startaddr & 0x00f00000); /* some MEG boundary */ + addr0 = addr; printf("Booting %s(%d,%c)%s @ 0x%x\n" , devs[maj] , unit @@ -156,7 +195,11 @@ loadprog(howto) printf("kernel will not fit below loader\n"); return; } - if((addr + head.a_text + head.a_data + head.a_bss) > 0xa0000) + /* + * The +28672 is for memory allocated by locore.s that must + * fit in the bss! (XXX - cgd) + */ + if((addr + head.a_text + head.a_data + head.a_bss + 28672) > 0xa0000) { printf("kernel too big, won't fit in 640K with bss\n"); printf("Only hope is to link the kernel for > 1MB\n"); @@ -167,7 +210,7 @@ loadprog(howto) printf("loader overlaps bss, kernel must bzero\n"); } } - printf("text=0x%x", head.a_text); + printf("text=0x%x ", head.a_text); /********************************************************/ /* LOAD THE TEXT SEGMENT */ /* don't clobber the first 4k yet (BIOS NEEDS IT) */ @@ -183,7 +226,7 @@ loadprog(howto) while (addr & CLOFSET) *(char *)addr++ = 0; - printf(" data=0x%x", head.a_data); + printf("data=0x%x ", head.a_data); xread(addr, head.a_data); addr += head.a_data; @@ -191,7 +234,7 @@ loadprog(howto) /* Skip over the uninitialised data */ /* (but clear it) */ /********************************************************/ - printf(" bss=0x%x", head.a_bss); + printf("bss=0x%x ", head.a_bss); if( (addr < ouraddr) && ((addr + head.a_bss) > ouraddr)) { pbzero(addr,ouraddr - (int)addr); @@ -214,7 +257,7 @@ loadprog(howto) /********************************************************/ /* READ in the symbol table */ /********************************************************/ - printf(" symbols=[+0x%x", head.a_syms); + printf("symbols=[+0x%x", head.a_syms); xread(addr, head.a_syms); addr += head.a_syms; @@ -231,7 +274,7 @@ loadprog(howto) /********************************************************/ /* and that many bytes of (debug symbols?) */ /********************************************************/ - printf("+0x%x]", i); + printf("+0x%x] ", i); xread(addr, i); addr += i; } @@ -241,7 +284,7 @@ loadprog(howto) /********************************************************/ argv[4] = ((addr+sizeof(int)-1))&~(sizeof(int)-1); - printf(" total=0x%x",argv[4]); + printf("total=0x%x ",argv[4]); /* @@ -272,8 +315,10 @@ loadprog(howto) /****************************************************************/ /* copy that first page and overwrite any BIOS variables */ /****************************************************************/ - printf(" entry point=0x%x \n" ,((int)startaddr) & 0xffffff); - pcpy(tmpbuf, 0, 4096); + printf("entry point=0x%x\n" ,((int)startaddr) & 0xffffff); + /* Under no circumstances overwrite precious BIOS variables! */ + pcpy(tmpbuf, addr0, 0x400); + pcpy(tmpbuf + 0x500, addr0 + 0x500, 4096 - 0x500); startprog(((int)startaddr & 0xffffff),argv); } @@ -312,6 +357,7 @@ getbootdev(howto) *ptr++ = 0; } } - } + } else + printf("\n"); }