|
|
1.1 ! root 1: /* boot.c 6.1 83/07/29 */ ! 2: ! 3: #include "../h/param.h" ! 4: #include "../h/inode.h" ! 5: #include "../h/fs.h" ! 6: #include "../h/vm.h" ! 7: #include "../machine/mtpr.h" ! 8: #include <a.out.h> ! 9: #include "saio.h" ! 10: #include "../h/reboot.h" ! 11: ! 12: /* ! 13: * Boot program... arguments passed in r10 and r11 determine ! 14: * whether boot stops to ask for system name and which device ! 15: * boot comes from. ! 16: */ ! 17: ! 18: /* r11 = 0 -> automatic boot, load file '/vmunix' */ ! 19: /* r11 = 1 -> ask user for file to load */ ! 20: ! 21: /* Types in r10 specifying major device */ ! 22: char devname[][3] = { ! 23: 'f','s','d', /* 0 = fsd */ ! 24: 's','m','d', /* 1 = smd or cmd */ ! 25: 'x','f','d', /* 2 = xfd */ ! 26: 'x','s','d', /* 2 = xsd */ ! 27: 'c','y','p', /* 3 = cypher tape */ ! 28: }; ! 29: ! 30: #ifdef FSD ! 31: char line[100] = "fsd(0,0)vmunix"; ! 32: #endif ! 33: #ifdef SMD ! 34: char line[100] = "smd(0,0)vmunix"; ! 35: #endif ! 36: #ifdef XFD ! 37: char line[100] = "xfd(0,0)vmunix"; ! 38: #endif ! 39: #ifdef XSD ! 40: char line[100] = "xsd(0,0)vmunix"; ! 41: #endif ! 42: #ifdef JUSTASK ! 43: char line[100]; ! 44: #endif ! 45: ! 46: int retry = 0; ! 47: ! 48: main() ! 49: { ! 50: register dummy; /* skip r12 */ ! 51: register howto, devtype; /* howto=r11, devtype=r10 */ ! 52: int io; ! 53: ! 54: #ifdef lint ! 55: howto = 0; devtype = 0; ! 56: #endif ! 57: printf("\nBoot\n"); ! 58: #ifdef JUSTASK ! 59: howto = RB_ASKNAME|RB_SINGLE; ! 60: #endif ! 61: for (;;) { ! 62: if (howto & RB_ASKNAME) { ! 63: printf(": "); ! 64: gets(line); ! 65: } else ! 66: printf(": %s\n", line); ! 67: io = open(line, 0); ! 68: if (io >= 0) ! 69: copyunix(howto, io); ! 70: if (++retry > 2) ! 71: howto |= RB_SINGLE|RB_ASKNAME; ! 72: } ! 73: } ! 74: ! 75: /*ARGSUSED*/ ! 76: copyunix(howto, io) ! 77: register io, howto; ! 78: { ! 79: struct exec x; ! 80: register int i; ! 81: char *addr; ! 82: ! 83: i = read(io, (char *)&x, sizeof x); ! 84: if (i != sizeof x || ! 85: (x.a_magic != 0407 && x.a_magic != 0413 && x.a_magic != 0410)) ! 86: _stop("Bad format\n"); ! 87: printf("%d", x.a_text); ! 88: if (x.a_magic == 0413 && lseek(io, 0x400, 0) == -1) ! 89: goto shread; ! 90: if (read(io, (char *)0x800, x.a_text) != x.a_text) ! 91: goto shread; ! 92: addr = (char *)(x.a_text + 0x800); ! 93: if (x.a_magic == 0413 || x.a_magic == 0410) ! 94: while ((int)addr & CLOFSET) ! 95: *addr++ = 0; ! 96: printf("+%d", x.a_data); ! 97: if (read(io, addr, x.a_data) != x.a_data) ! 98: goto shread; ! 99: addr += x.a_data; ! 100: printf("+%d", x.a_bss); ! 101: x.a_bss += 32*1024; /* slop */ ! 102: for (i = 0; i < x.a_bss; i++) ! 103: *addr++ = 0; ! 104: x.a_entry &= 0x1fffffff; ! 105: printf(" start 0x%x\n", x.a_entry); ! 106: mtpr (0, PADC); /* Purge data cache */ ! 107: mtpr (0, PACC); /* Purge code cache */ ! 108: if (!(howto & RB_DCOFF)) ! 109: mtpr (1, DCR); /* Enable data cache */ ! 110: (*((int (*)()) x.a_entry))(); ! 111: shread: ! 112: _stop("Short read\n"); ! 113: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.