summaryrefslogtreecommitdiffstats
path: root/sys/i386/boot/dosboot/dosboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/i386/boot/dosboot/dosboot.c')
-rw-r--r--sys/i386/boot/dosboot/dosboot.c97
1 files changed, 61 insertions, 36 deletions
diff --git a/sys/i386/boot/dosboot/dosboot.c b/sys/i386/boot/dosboot/dosboot.c
index b3b0bc8..d8992e5b 100644
--- a/sys/i386/boot/dosboot/dosboot.c
+++ b/sys/i386/boot/dosboot/dosboot.c
@@ -86,44 +86,47 @@ static void dosxread(FILE *fp, unsigned long addr, long size)
}
}
-static long loadprog(FILE *fp, int howto, long *hsize)
+static long loadprog(FILE *fp, long *hsize)
{
long int addr; /* physical address.. not directly useable */
- long int hmaddress;
+ long int hmaddress, pad, i;
static int (*x_entry)() = 0;
- argv[3] = 0;
- argv[4] = 0;
fread(&head, sizeof(head), 1, fp);
fseek(fp, 4096-sizeof(head), 1);
- if ( N_BADMAG(head)) {
+ if (N_BADMAG(head)) {
printf("Invalid format!\n");
exit(0);
}
- poff = N_TXTOFF(head);
-
startaddr = (long)head.a_entry;
addr = (startaddr & 0x00ffffffl); /* some MEG boundary */
printf("Booting @ 0x%lx\n", addr);
if(addr < 0x100000l)
{
- printf("kernel linked for wrong address!\n");
- printf("Only hope is to link the kernel for > 1MB\n");
+ printf("Start address too low!\n");
exit(0);
}
+ poff = N_TXTOFF(head)+head.a_text+head.a_data+head.a_syms;
+ fseek(fp, poff, 0);
+ fread(&i, sizeof(i), 1, fp);
*hsize = head.a_text+head.a_data+head.a_bss;
+ *hsize = (*hsize+NBPG-1)&~(NBPG-1);
+ *hsize += i+4+head.a_syms;
addr=hmaddress=get_high_memory(*hsize);
if (!hmaddress) {
printf("Sorry, can't allocate enough memory!\n");
exit(0);
}
- printf("text=0x%lx ", head.a_text);
+ poff = N_TXTOFF(head);
+ fseek(fp, poff, 0);
+
/********************************************************/
/* LOAD THE TEXT SEGMENT */
/********************************************************/
+ printf("text=0x%lx ", head.a_text);
dosxread(fp, addr, head.a_text);
addr += head.a_text;
@@ -143,41 +146,61 @@ static long loadprog(FILE *fp, int howto, long *hsize)
/********************************************************/
printf("bss=0x%lx ", head.a_bss);
pbzero(addr, head.a_bss);
- argv[3] = (addr += head.a_bss);
- argv[3] += -hmaddress+0x100000l;
+ addr += head.a_bss;
+
+ /* Pad to a page boundary. */
+ pad = (unsigned long)(addr-hmaddress+(startaddr & 0x00ffffffl)) % NBPG;
+ if (pad != 0) {
+ pad = NBPG - pad;
+ addr += pad;
+ }
+ bootinfo.bi_symtab = addr-hmaddress+(startaddr & 0x00ffffffl);
/********************************************************/
- /* and note the end address of all this */
+ /* Copy the symbol table size */
/********************************************************/
+ pm_copy((char *)&head.a_syms, addr, sizeof(head.a_syms));
+ addr += sizeof(head.a_syms);
- addr = addr-hmaddress+0x100000l;
- argv[4] = ((addr+(long) sizeof(long)-1l))&~((long)sizeof(long)-1l);
- printf("total=0x%lx ",argv[4]);
+ /********************************************************/
+ /* Load the symbol table */
+ /********************************************************/
+ printf("symbols=[+0x%lx+0x%lx+0x%lx", pad, (long) sizeof(head.a_syms),
+ (long) head.a_syms);
+ dosxread(fp, addr, head.a_syms);
+ addr += head.a_syms;
+
+ /********************************************************/
+ /* Load the string table size */
+ /********************************************************/
+ fread((void *)&i, sizeof(long), 1, fp);
+ pm_copy((char *)&i, addr, sizeof(long));
+ i -= sizeof(long);
+ addr += sizeof(long);
+
+ /********************************************************/
+ /* Load the string table */
+ /********************************************************/
+ printf("+0x%x+0x%lx] ", sizeof(long), i);
+ dosxread(fp, addr, i);
+ addr += i;
+
+ bootinfo.bi_esymtab = addr-hmaddress+(startaddr & 0x00ffffffl);
/*
- * We now pass the various bootstrap parameters to the loaded
- * image via the argument list
- * (THIS IS A BIT OF HISTORY FROM MACH.. LEAVE FOR NOW)
- * arg1 = boot flags
- * arg2 = boot device
- * arg3 = start of symbol table (0 if not loaded)
- * arg4 = end of symbol table (0 if not loaded)
- * arg5 = transfer address from image
- * arg6 = transfer address for next image pointer
+ * For backwards compatibility, use the previously-unused adaptor
+ * and controller bitfields to hold the slice number.
*/
- argv[1] = howto;
- argv[2] = (MAKEBOOTDEV(maj, (slice>>4), (slice&0xf), unit, part)) ;
- argv[5] = (head.a_entry &= 0xfffffff);
- argv[6] = (long) &x_entry;
- argv[0] = 8;
+ printf("total=0x%lx entry point=0x%lx\n",
+ addr-hmaddress+(startaddr & 0x00ffffffl),
+ startaddr & 0x00ffffffl);
- printf("entry point=0x%lx\n" ,((long)startaddr) & 0xffffff);
return hmaddress;
}
-void dosboot(int howto, char *kernel)
+void dosboot(long howto, char *kernel)
{
- long hmaddress, size;
+ long hmaddress, size, bootdev;
FILE *fp;
fp = fopen(kernel, "rb"); /* open kernel for reading */
@@ -185,8 +208,10 @@ void dosboot(int howto, char *kernel)
fprintf(stderr, "Sorry, can't open %s!\n", kernel);
return;
}
- hmaddress = loadprog(fp, howto, &size);
+ hmaddress = loadprog(fp, &size);
fclose(fp);
- startprog(hmaddress, size, (startaddr & 0xffffffl), argv);
-}
+ bootdev = MAKEBOOTDEV(maj, (slice >> 4), slice & 0xf, unit, part);
+ startprog(hmaddress, size, ((long)startaddr & 0xffffffl),
+ howto | RB_BOOTINFO, bootdev);
+}
OpenPOWER on IntegriCloud