h04427
s 00101/00000/00000
d D 1.1 82/08/02 16:05:42 cecily 1 0
e
u
U
t
T
I 1
#include <sys/param.h>
#include <sys/ino.h>
#include <sys/inode.h>
#include <sys/filsys.h>
#include <sys/dir.h>
#include <saio.h>

#define STACKSIZE       (8*1024)        /* Minimum size for stack */

char line[100];

int *
main(bootaddr)
int *bootaddr;
{
	register int i;
	register int *top;

	for (;;) {
		printf("\nBoot\n");
		do {
			printf(": "); gets(line);
			i = open(line,0);
		} while (i < 0);
	
		if ((top = copyunix(i, bootaddr)) != 0)
			return(top);
		close(i);
	}
}


copyunix(io, bootaddr)
register io;
register char *bootaddr;
{
	register char   *addr, *top;
	unsigned        txtsiz,datsiz,bsssiz,stksiz;
	int             magic;
	register int	*wtop, *waddr;

	lseek(io, (off_t)0, 0);
	magic = getw(io);
	txtsiz = getw(io);
	datsiz = getw(io);
	bsssiz = getw(io);
	getw(io); getw(io);
	stksiz = getw(io);
	getw(io);
	if (stksiz < STACKSIZE)
		stksiz = STACKSIZE;

	switch (magic) {
/***
	case 0411:
		setseg(0);
		lseek(io, (long)(020+txtsiz), 0);

		for(addr=0; addr!=datsiz; addr+=2)  {
			mtpi(getw(io),addr);
		}

		clrseg(addr,bsssiz);

		phys = (long)datsiz + (long)bsssiz + 63L;
		phys =/ 64;
		setseg((int)phys);

		lseek(io, 020L, 0);

		for(addr=0; addr!=txtsiz; addr+=2) {
			mtpi(getw(io),addr);
		}
		return;
***/

	case 0407:
		/*
		 * zero memory to avoid mm faults for initial
		 * boots of systems > 256k
		 */
		waddr = bootaddr;
		wtop  = bootaddr + txtsiz + datsiz + bsssiz + stksiz;
		while (waddr <= wtop)
			*waddr++ = 0;

		/*
		 *   load unix proper
		 */
		top = bootaddr + txtsiz + datsiz;
		for (addr = bootaddr; addr != top; addr++)
			*addr = getc(io);

		/* size of unix loaded in */
		return(txtsiz+datsiz+bsssiz+stksiz);

	default:
		printf("Can't load %o files\n", magic);
		return(0);
	}
}
E 1
