1. BOOTSEG and BOOTSTACK are now set from the Makefile, the boot code has
been relocated to run in the 64k segment at 0x10000 with the stack at the top of this segment. This corrects the problems machines with 512K base memory had booting. 2. startprog routing rewritten to convert the BOOTSEG ss to a KERNELSEG ss, this eliminated the last of the >512K memory references. Additional cleanup in here included a better way to copy the arguments to the kernel stack. 3. Elimination of argv and esym cruft saved a few bytes. 4. Only need to truncate the head.a_entry to a meg boundary once intead of every time we used it! [Saving more bytes]. 5. Addition of version 1 bootinfo structure support. These boot blocks pass the kernel name in to the kernel now. 6. Removed historical comments about MACH argv stuff, as it is useless now.
This commit is contained in:
parent
76b993fbbe
commit
9949ebf656
@ -1,4 +1,4 @@
|
||||
# $Id$
|
||||
# $Id: Makefile,v 1.17 1994/10/02 05:18:23 rgrimes Exp $
|
||||
#
|
||||
|
||||
PROG= boot
|
||||
@ -8,6 +8,7 @@ SRCS= start.S table.c boot2.S boot.c asm.S bios.S io.c disk.c sys.c
|
||||
BINDIR= /usr/mdec
|
||||
BINMODE= 444
|
||||
CFLAGS+= -O2 -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT}
|
||||
CFLAGS+= -DBOOTSEG=${BOOTSEG} -DBOOTSTACK=${BOOTSTACK}
|
||||
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../..
|
||||
CLEANFILES+= boot.nohdr boot.strip boot1 boot2
|
||||
DPADD= ${LIBC}
|
||||
@ -24,6 +25,12 @@ STRIP=
|
||||
# tunable timeout parameter, waiting for keypress, calibrated in mS
|
||||
BOOTWAIT?= 5000
|
||||
|
||||
# Location that boot2 is loaded at
|
||||
BOOTSEG= 0x1000
|
||||
|
||||
# Offset in BOOTSEG for the top of the stack, keep this 16 byte aligned
|
||||
BOOTSTACK= 0xFFF0
|
||||
|
||||
boot.strip: boot
|
||||
cp -p boot boot.strip
|
||||
strip boot.strip
|
||||
|
@ -24,7 +24,7 @@
|
||||
* the rights to redistribute these changes.
|
||||
*
|
||||
* from: Mach, Revision 2.2 92/04/04 11:34:13 rpd
|
||||
* $Id: asm.S,v 1.3 1994/08/30 01:38:02 bde Exp $
|
||||
* $Id: asm.S,v 1.4 1994/10/02 05:18:24 rgrimes Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -164,32 +164,36 @@ xreal:
|
||||
/*
|
||||
* startprog(phyaddr)
|
||||
* start the program on protected mode where phyaddr is the entry point
|
||||
*
|
||||
* XXX This whole mess should go away and we should run the boot code in
|
||||
* flat 32 bit mode with it linked -T BOOTSEG. See the netboot code for
|
||||
* how this is done.
|
||||
*/
|
||||
|
||||
ENTRY(startprog)
|
||||
push %ebp
|
||||
mov %esp, %ebp
|
||||
movl %esp, %eax /* Use eax as the old stack pointer */
|
||||
|
||||
/* get things we need into registers */
|
||||
movl 0x8(%ebp), %ecx /* entry offset */
|
||||
movl 0x0c(%ebp), %eax /* &argv */
|
||||
|
||||
/* make a new stack at 0:0xa0000 (big segs) */
|
||||
/* convert the current stack to a 32 bit flat model */
|
||||
mov $0x10, %ebx
|
||||
movw %bx, %ss
|
||||
movl $0xa0000, %ebx
|
||||
movl %ebx, %esp
|
||||
addl $(BOOTSEG<<4),%esp
|
||||
|
||||
/* push some number of args onto the stack */
|
||||
pushl $0 /* was a cyl offset in the boot. */
|
||||
pushl 0x8(%eax) /* argv[2] = bootdev */
|
||||
pushl 0x4(%eax) /* argv[1] = howto */
|
||||
pushl $0 /* dummy 'return' address */
|
||||
/* copy the arguments from the old stack to the new stack */
|
||||
pushl 0x14(%eax) /* &bootinfo */
|
||||
pushl $0 /* was &nfsdiskless */
|
||||
pushl $0 /* was esym */
|
||||
pushl $0 /* was cyloffset */
|
||||
pushl 0x10(%eax) /* bootdev */
|
||||
pushl 0x0C(%eax) /* howto */
|
||||
movl $(ourreturn),%ebx
|
||||
addl $(BOOTSEG<<4),%ebx /* Fix it up for flat segments */
|
||||
pushl %ebx /* our return address */
|
||||
|
||||
/* push on our entry address */
|
||||
mov $0x08, %ebx /* segment */
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
pushl $0x08 /* segment selector */
|
||||
pushl 0x08(%eax) /* kernel entry address */
|
||||
|
||||
/* convert over the other data segs */
|
||||
mov $0x10, %ebx
|
||||
@ -198,6 +202,10 @@ ENTRY(startprog)
|
||||
|
||||
/* convert the PC (and code seg) */
|
||||
lret
|
||||
ourreturn:
|
||||
/* For now there is not much we can do, just lock in a loop */
|
||||
jmp ourreturn
|
||||
|
||||
/*
|
||||
*
|
||||
* pbzero( dst, cnt)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id$
|
||||
# $Id: Makefile,v 1.17 1994/10/02 05:18:23 rgrimes Exp $
|
||||
#
|
||||
|
||||
PROG= boot
|
||||
@ -8,6 +8,7 @@ SRCS= start.S table.c boot2.S boot.c asm.S bios.S io.c disk.c sys.c
|
||||
BINDIR= /usr/mdec
|
||||
BINMODE= 444
|
||||
CFLAGS+= -O2 -DDO_BAD144 -DBOOTWAIT=${BOOTWAIT}
|
||||
CFLAGS+= -DBOOTSEG=${BOOTSEG} -DBOOTSTACK=${BOOTSTACK}
|
||||
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../..
|
||||
CLEANFILES+= boot.nohdr boot.strip boot1 boot2
|
||||
DPADD= ${LIBC}
|
||||
@ -24,6 +25,12 @@ STRIP=
|
||||
# tunable timeout parameter, waiting for keypress, calibrated in mS
|
||||
BOOTWAIT?= 5000
|
||||
|
||||
# Location that boot2 is loaded at
|
||||
BOOTSEG= 0x1000
|
||||
|
||||
# Offset in BOOTSEG for the top of the stack, keep this 16 byte aligned
|
||||
BOOTSTACK= 0xFFF0
|
||||
|
||||
boot.strip: boot
|
||||
cp -p boot boot.strip
|
||||
strip boot.strip
|
||||
|
@ -24,7 +24,7 @@
|
||||
* the rights to redistribute these changes.
|
||||
*
|
||||
* from: Mach, Revision 2.2 92/04/04 11:34:13 rpd
|
||||
* $Id: asm.S,v 1.3 1994/08/30 01:38:02 bde Exp $
|
||||
* $Id: asm.S,v 1.4 1994/10/02 05:18:24 rgrimes Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -164,32 +164,36 @@ xreal:
|
||||
/*
|
||||
* startprog(phyaddr)
|
||||
* start the program on protected mode where phyaddr is the entry point
|
||||
*
|
||||
* XXX This whole mess should go away and we should run the boot code in
|
||||
* flat 32 bit mode with it linked -T BOOTSEG. See the netboot code for
|
||||
* how this is done.
|
||||
*/
|
||||
|
||||
ENTRY(startprog)
|
||||
push %ebp
|
||||
mov %esp, %ebp
|
||||
movl %esp, %eax /* Use eax as the old stack pointer */
|
||||
|
||||
/* get things we need into registers */
|
||||
movl 0x8(%ebp), %ecx /* entry offset */
|
||||
movl 0x0c(%ebp), %eax /* &argv */
|
||||
|
||||
/* make a new stack at 0:0xa0000 (big segs) */
|
||||
/* convert the current stack to a 32 bit flat model */
|
||||
mov $0x10, %ebx
|
||||
movw %bx, %ss
|
||||
movl $0xa0000, %ebx
|
||||
movl %ebx, %esp
|
||||
addl $(BOOTSEG<<4),%esp
|
||||
|
||||
/* push some number of args onto the stack */
|
||||
pushl $0 /* was a cyl offset in the boot. */
|
||||
pushl 0x8(%eax) /* argv[2] = bootdev */
|
||||
pushl 0x4(%eax) /* argv[1] = howto */
|
||||
pushl $0 /* dummy 'return' address */
|
||||
/* copy the arguments from the old stack to the new stack */
|
||||
pushl 0x14(%eax) /* &bootinfo */
|
||||
pushl $0 /* was &nfsdiskless */
|
||||
pushl $0 /* was esym */
|
||||
pushl $0 /* was cyloffset */
|
||||
pushl 0x10(%eax) /* bootdev */
|
||||
pushl 0x0C(%eax) /* howto */
|
||||
movl $(ourreturn),%ebx
|
||||
addl $(BOOTSEG<<4),%ebx /* Fix it up for flat segments */
|
||||
pushl %ebx /* our return address */
|
||||
|
||||
/* push on our entry address */
|
||||
mov $0x08, %ebx /* segment */
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
pushl $0x08 /* segment selector */
|
||||
pushl 0x08(%eax) /* kernel entry address */
|
||||
|
||||
/* convert over the other data segs */
|
||||
mov $0x10, %ebx
|
||||
@ -198,6 +202,10 @@ ENTRY(startprog)
|
||||
|
||||
/* convert the PC (and code seg) */
|
||||
lret
|
||||
ourreturn:
|
||||
/* For now there is not much we can do, just lock in a loop */
|
||||
jmp ourreturn
|
||||
|
||||
/*
|
||||
*
|
||||
* pbzero( dst, cnt)
|
||||
|
@ -24,7 +24,7 @@
|
||||
* the rights to redistribute these changes.
|
||||
*
|
||||
* from: Mach, [92/04/03 16:51:14 rvb]
|
||||
* $Id: boot.c,v 1.14 1994/06/16 03:53:27 adam Exp $
|
||||
* $Id: boot.c,v 1.15 1994/08/21 17:47:25 paul Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -55,9 +55,10 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#include "boot.h"
|
||||
#include <a.out.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <machine/bootinfo.h>
|
||||
|
||||
struct exec head;
|
||||
int argv[10], esym;
|
||||
struct bootinfo_t bootinfo;
|
||||
char *name;
|
||||
char *names[] = {
|
||||
"/kernel"
|
||||
@ -73,8 +74,8 @@ int drive;
|
||||
|
||||
printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n",
|
||||
ouraddr,
|
||||
argv[7] = memsize(0),
|
||||
argv[8] = memsize(1));
|
||||
memsize(0),
|
||||
memsize(1));
|
||||
printf("use hd(1,a)/kernel to boot sd0 when wd0 is also installed\n");
|
||||
gateA20();
|
||||
loadstart:
|
||||
@ -106,13 +107,11 @@ loadprog(howto)
|
||||
{
|
||||
long int startaddr;
|
||||
long int addr; /* physical address.. not directly useable */
|
||||
long int addr0;
|
||||
long int bootdev;
|
||||
long int total;
|
||||
int i;
|
||||
static int (*x_entry)() = 0;
|
||||
unsigned char tmpbuf[4096]; /* we need to load the first 4k here */
|
||||
|
||||
argv[3] = 0;
|
||||
argv[4] = 0;
|
||||
read(&head, sizeof(head));
|
||||
if ( N_BADMAG(head)) {
|
||||
printf("Invalid format!\n");
|
||||
@ -123,9 +122,8 @@ loadprog(howto)
|
||||
/*if(poff==0)
|
||||
poff = 32;*/
|
||||
|
||||
startaddr = (int)head.a_entry;
|
||||
addr = (startaddr & 0x00ffffff); /* some MEG boundary */
|
||||
addr0 = addr;
|
||||
startaddr = (int)head.a_entry & 0x00FFFFFF; /* some MEG boundary */
|
||||
addr = startaddr;
|
||||
printf("Booting %s(%d,%c)%s @ 0x%x\n"
|
||||
, devs[maj]
|
||||
, unit
|
||||
@ -178,7 +176,7 @@ loadprog(howto)
|
||||
{
|
||||
pbzero(addr,head.a_bss);
|
||||
}
|
||||
argv[3] = (addr += head.a_bss);
|
||||
addr += head.a_bss;
|
||||
|
||||
#ifdef LOADSYMS /* not yet, haven't worked this out yet */
|
||||
if (addr > 0x100000)
|
||||
@ -218,20 +216,12 @@ loadprog(howto)
|
||||
/* and note the end address of all this */
|
||||
/********************************************************/
|
||||
|
||||
argv[4] = ((addr+sizeof(int)-1))&~(sizeof(int)-1);
|
||||
printf("total=0x%x ",argv[4]);
|
||||
|
||||
total = ((addr+sizeof(int)-1))&~(sizeof(int)-1);
|
||||
printf("total=0x%x ", total);
|
||||
|
||||
/*
|
||||
* 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
|
||||
* If we are booting from floppy prompt for a filesystem floppy
|
||||
* before we call the kernel
|
||||
*/
|
||||
switch(maj)
|
||||
{
|
||||
@ -249,19 +239,19 @@ loadprog(howto)
|
||||
case 4:
|
||||
break;
|
||||
}
|
||||
argv[1] = howto;
|
||||
argv[2] = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ;
|
||||
argv[5] = (head.a_entry &= 0xfffffff);
|
||||
argv[6] = (int) &x_entry;
|
||||
argv[0] = 8;
|
||||
bootdev = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ;
|
||||
/****************************************************************/
|
||||
/* copy that first page and overwrite any BIOS variables */
|
||||
/****************************************************************/
|
||||
printf("entry point=0x%x\n" ,((int)startaddr) & 0xffffff);
|
||||
printf("entry point=0x%x\n" ,(int)startaddr);
|
||||
/* Under no circumstances overwrite precious BIOS variables! */
|
||||
pcpy(tmpbuf, addr0, 0x400);
|
||||
pcpy(tmpbuf + 0x500, addr0 + 0x500, 4096 - 0x500);
|
||||
startprog(((int)startaddr & 0xffffff),argv);
|
||||
pcpy(tmpbuf, startaddr, 0x400);
|
||||
pcpy(tmpbuf + 0x500, startaddr + 0x500, 4096 - 0x500);
|
||||
bootinfo.version=1;
|
||||
bootinfo.kernelname=(char *)((int)name + (BOOTSEG<<4));
|
||||
bootinfo.nfs_diskless=0;
|
||||
startprog((int)startaddr, howto, bootdev, (int)&bootinfo+(BOOTSEG<<4));
|
||||
return;
|
||||
}
|
||||
|
||||
char namebuf[100];
|
||||
|
@ -24,7 +24,7 @@
|
||||
* the rights to redistribute these changes.
|
||||
*
|
||||
* from: Mach, Revision 2.2 92/04/04 11:36:29 rpd
|
||||
* $Id: start.S,v 1.3 1994/06/13 19:27:52 jkh Exp $
|
||||
* $Id: start.S,v 1.4 1994/10/02 05:18:26 rgrimes Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -53,8 +53,6 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
.file "start.s"
|
||||
|
||||
BOOTSEG= 0x9000 /* boot will be loaded here (below 640K) */
|
||||
BOOTSTACK= 0xe000 /* boot stack */
|
||||
SIGNATURE= 0xaa55
|
||||
LOADSZ= 15 /* size of unix boot */
|
||||
PARTSTART= 0x1be /* starting address of partition table */
|
||||
|
@ -24,7 +24,7 @@
|
||||
* the rights to redistribute these changes.
|
||||
*
|
||||
* from: Mach, [92/04/03 16:51:14 rvb]
|
||||
* $Id: boot.c,v 1.14 1994/06/16 03:53:27 adam Exp $
|
||||
* $Id: boot.c,v 1.15 1994/08/21 17:47:25 paul Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -55,9 +55,10 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#include "boot.h"
|
||||
#include <a.out.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <machine/bootinfo.h>
|
||||
|
||||
struct exec head;
|
||||
int argv[10], esym;
|
||||
struct bootinfo_t bootinfo;
|
||||
char *name;
|
||||
char *names[] = {
|
||||
"/kernel"
|
||||
@ -73,8 +74,8 @@ int drive;
|
||||
|
||||
printf("\n>> FreeBSD BOOT @ 0x%x: %d/%d k of memory\n",
|
||||
ouraddr,
|
||||
argv[7] = memsize(0),
|
||||
argv[8] = memsize(1));
|
||||
memsize(0),
|
||||
memsize(1));
|
||||
printf("use hd(1,a)/kernel to boot sd0 when wd0 is also installed\n");
|
||||
gateA20();
|
||||
loadstart:
|
||||
@ -106,13 +107,11 @@ loadprog(howto)
|
||||
{
|
||||
long int startaddr;
|
||||
long int addr; /* physical address.. not directly useable */
|
||||
long int addr0;
|
||||
long int bootdev;
|
||||
long int total;
|
||||
int i;
|
||||
static int (*x_entry)() = 0;
|
||||
unsigned char tmpbuf[4096]; /* we need to load the first 4k here */
|
||||
|
||||
argv[3] = 0;
|
||||
argv[4] = 0;
|
||||
read(&head, sizeof(head));
|
||||
if ( N_BADMAG(head)) {
|
||||
printf("Invalid format!\n");
|
||||
@ -123,9 +122,8 @@ loadprog(howto)
|
||||
/*if(poff==0)
|
||||
poff = 32;*/
|
||||
|
||||
startaddr = (int)head.a_entry;
|
||||
addr = (startaddr & 0x00ffffff); /* some MEG boundary */
|
||||
addr0 = addr;
|
||||
startaddr = (int)head.a_entry & 0x00FFFFFF; /* some MEG boundary */
|
||||
addr = startaddr;
|
||||
printf("Booting %s(%d,%c)%s @ 0x%x\n"
|
||||
, devs[maj]
|
||||
, unit
|
||||
@ -178,7 +176,7 @@ loadprog(howto)
|
||||
{
|
||||
pbzero(addr,head.a_bss);
|
||||
}
|
||||
argv[3] = (addr += head.a_bss);
|
||||
addr += head.a_bss;
|
||||
|
||||
#ifdef LOADSYMS /* not yet, haven't worked this out yet */
|
||||
if (addr > 0x100000)
|
||||
@ -218,20 +216,12 @@ loadprog(howto)
|
||||
/* and note the end address of all this */
|
||||
/********************************************************/
|
||||
|
||||
argv[4] = ((addr+sizeof(int)-1))&~(sizeof(int)-1);
|
||||
printf("total=0x%x ",argv[4]);
|
||||
|
||||
total = ((addr+sizeof(int)-1))&~(sizeof(int)-1);
|
||||
printf("total=0x%x ", total);
|
||||
|
||||
/*
|
||||
* 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
|
||||
* If we are booting from floppy prompt for a filesystem floppy
|
||||
* before we call the kernel
|
||||
*/
|
||||
switch(maj)
|
||||
{
|
||||
@ -249,19 +239,19 @@ loadprog(howto)
|
||||
case 4:
|
||||
break;
|
||||
}
|
||||
argv[1] = howto;
|
||||
argv[2] = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ;
|
||||
argv[5] = (head.a_entry &= 0xfffffff);
|
||||
argv[6] = (int) &x_entry;
|
||||
argv[0] = 8;
|
||||
bootdev = (MAKEBOOTDEV(maj, 0, 0, unit, part)) ;
|
||||
/****************************************************************/
|
||||
/* copy that first page and overwrite any BIOS variables */
|
||||
/****************************************************************/
|
||||
printf("entry point=0x%x\n" ,((int)startaddr) & 0xffffff);
|
||||
printf("entry point=0x%x\n" ,(int)startaddr);
|
||||
/* Under no circumstances overwrite precious BIOS variables! */
|
||||
pcpy(tmpbuf, addr0, 0x400);
|
||||
pcpy(tmpbuf + 0x500, addr0 + 0x500, 4096 - 0x500);
|
||||
startprog(((int)startaddr & 0xffffff),argv);
|
||||
pcpy(tmpbuf, startaddr, 0x400);
|
||||
pcpy(tmpbuf + 0x500, startaddr + 0x500, 4096 - 0x500);
|
||||
bootinfo.version=1;
|
||||
bootinfo.kernelname=(char *)((int)name + (BOOTSEG<<4));
|
||||
bootinfo.nfs_diskless=0;
|
||||
startprog((int)startaddr, howto, bootdev, (int)&bootinfo+(BOOTSEG<<4));
|
||||
return;
|
||||
}
|
||||
|
||||
char namebuf[100];
|
||||
|
@ -24,7 +24,7 @@
|
||||
* the rights to redistribute these changes.
|
||||
*
|
||||
* from: Mach, Revision 2.2 92/04/04 11:36:29 rpd
|
||||
* $Id: start.S,v 1.3 1994/06/13 19:27:52 jkh Exp $
|
||||
* $Id: start.S,v 1.4 1994/10/02 05:18:26 rgrimes Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -53,8 +53,6 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
.file "start.s"
|
||||
|
||||
BOOTSEG= 0x9000 /* boot will be loaded here (below 640K) */
|
||||
BOOTSTACK= 0xe000 /* boot stack */
|
||||
SIGNATURE= 0xaa55
|
||||
LOADSZ= 15 /* size of unix boot */
|
||||
PARTSTART= 0x1be /* starting address of partition table */
|
||||
|
Loading…
Reference in New Issue
Block a user