#include "all.h" #include "ureg.h" #include void arginit(void); int diskid(void); /* * args passed by boot process */ int _argc; char **_argv; char **_env; /* * environment passed to any kernel started by this kernel */ char envbuf[512]; char *env[8]; /* * environment that we use */ char consname[NAMELEN]; char debug[NAMELEN]; char defaultpart[] = "boot"; char bootpart[NAMELEN] = "boot"; char bootline[2*NAMELEN]; void main(void) { struct mipsexec hdr; long off; int i, c; delay(1000); icflush(0, 32*1024); tlbinit(); arginit(); screeninit(consname[0]); vecinit(); devinit(); kbdinit(); print("SCSI boot\n"); scsidebug = debug[1]; scsireset(); spllo(); biogetdev(diskid()); Loop: strcpy(bootpart, defaultpart); while(getc(&kbdq) != -1) ; getstr("boot partition", bootpart, sizeof bootpart, bootpart, 5); off = findpart(bootpart); if(off < 0){ print("\npartition %s not found\n", bootpart); goto Loop; } sprint(bootline, "partboot"); if(bioread(&hdr, off, sizeof hdr)){ print("\ncan't read %s\n", bootpart); goto Loop; } off += (sizeof hdr + 0x04); /* header is actually padded to 0x50 bytes */ print("%ld", hdr.tsize); if(bioread((void *)hdr.text_start, off, hdr.tsize)){ print("\ncan't read %s\n", bootpart); goto Loop; } off += hdr.tsize; print("+%ld", hdr.dsize); if(bioread((void *)hdr.data_start, off, hdr.dsize)){ print("\ncan't read %s\n", bootpart); goto Loop; } print("+%ld\n", hdr.bsize); memset((void *)hdr.bss_start, 0, hdr.bsize); print("starting..."); delay(1000); splhi(); boot(hdr.mentry); } void tlbinit(void) { int i; for(i=0; i>3, i&7); else sprint(ep, "bootdisk=#w%d", i>>3); *envp = 0; _env = env; p = getenv("console"); if(p) strncpy(consname, p, NAMELEN-1); else strcpy(consname, "m"); _argv[0] = bootline; } void exit(void) { int i; splhi(); screenputs("\nexiting", 8); delay(2000); firmware(); } int sprint(char *buf, char *fmt, ...) { return doprint(buf, buf+PRINTSIZE, fmt, (&fmt+1)) - buf; } int print(char *fmt, ...) { char buf[PRINTSIZE]; int n; n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; screenputs(buf, n); return n; } void panic(char *fmt, ...) { char buf[PRINTSIZE]; int i, n; screenputs("\npanic: ", 8); n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf; screenputs(buf, n); for(i=0; i<1000000; i++) ; firmware(); } void delay(int ms) { ulong t, *p; int i; ms *= 7000; /* experimentally determined */ for(i=0; i