|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)boot.c 7.10 (Berkeley) 3/4/88 ! 7: */ ! 8: ! 9: #include "param.h" ! 10: #include "inode.h" ! 11: #include "fs.h" ! 12: #include "vm.h" ! 13: #include "reboot.h" ! 14: ! 15: #include <a.out.h> ! 16: #include "saio.h" ! 17: ! 18: /* ! 19: * Boot program... arguments passed in r10 and r11 determine ! 20: * whether boot stops to ask for system name and which device ! 21: * boot comes from. ! 22: */ ! 23: ! 24: char line[100]; ! 25: ! 26: extern unsigned opendev; ! 27: ! 28: main() ! 29: { ! 30: register unsigned howto, devtype; /* howto=r11, devtype=r10 */ ! 31: int io, retry, type; ! 32: ! 33: #ifdef lint ! 34: howto = 0; devtype = 0; ! 35: #endif ! 36: printf("\nBoot\n"); ! 37: #ifdef JUSTASK ! 38: howto = RB_ASKNAME|RB_SINGLE; ! 39: #else ! 40: if ((howto & RB_ASKNAME) == 0) { ! 41: type = (devtype >> B_TYPESHIFT) & B_TYPEMASK; ! 42: if ((unsigned)type < ndevs && devsw[type].dv_name) ! 43: strcpy(line, UNIX); ! 44: else ! 45: howto |= RB_SINGLE|RB_ASKNAME; ! 46: } ! 47: #endif ! 48: for (retry = 0;;) { ! 49: if (howto & RB_ASKNAME) { ! 50: printf(": "); ! 51: gets(line); ! 52: if (line[0] == 0) { ! 53: strcpy(line, UNIX); ! 54: printf(": %s\n", line); ! 55: } ! 56: } else ! 57: printf(": %s\n", line); ! 58: io = open(line, 0); ! 59: if (io >= 0) { ! 60: #ifdef VAX750 ! 61: loadpcs(); ! 62: #endif ! 63: copyunix(howto, opendev, io); ! 64: close(io); ! 65: howto |= RB_SINGLE|RB_ASKNAME; ! 66: } ! 67: if (++retry > 2) ! 68: howto |= RB_SINGLE|RB_ASKNAME; ! 69: } ! 70: } ! 71: ! 72: /*ARGSUSED*/ ! 73: copyunix(howto, devtype, aio) ! 74: register howto, devtype; /* howto=r11, devtype=r10 */ ! 75: int aio; ! 76: { ! 77: register int esym; /* must be r9 */ ! 78: struct exec x; ! 79: register int io = aio, i; ! 80: char *addr; ! 81: ! 82: i = read(io, (char *)&x, sizeof(x)); ! 83: if (i != sizeof(x) || (x.a_magic != OMAGIC && x.a_magic != ZMAGIC ! 84: && x.a_magic != NMAGIC)) { ! 85: printf("Bad format\n"); ! 86: return; ! 87: } ! 88: printf("%d", x.a_text); ! 89: if (x.a_magic == ZMAGIC && lseek(io, 0x400, L_SET) == -1) ! 90: goto shread; ! 91: if (read(io, (char *)0, x.a_text) != x.a_text) ! 92: goto shread; ! 93: addr = (char *)x.a_text; ! 94: if (x.a_magic == ZMAGIC || x.a_magic == NMAGIC) ! 95: while ((int)addr & CLOFSET) ! 96: *addr++ = 0; ! 97: printf("+%d", x.a_data); ! 98: if (read(io, addr, x.a_data) != x.a_data) ! 99: goto shread; ! 100: addr += x.a_data; ! 101: printf("+%d", x.a_bss); ! 102: for (i = 0; i < x.a_bss; i++) ! 103: *addr++ = 0; ! 104: if (howto & RB_KDB && x.a_syms) { ! 105: *(int *)addr = x.a_syms; /* symbol table size */ ! 106: addr += sizeof (int); ! 107: printf("[+%d", x.a_syms); ! 108: if (read(io, addr, x.a_syms) != x.a_syms) ! 109: goto shread; ! 110: addr += x.a_syms; ! 111: if (read(io, addr, sizeof (int)) != sizeof (int)) ! 112: goto shread; ! 113: i = *(int *)addr - sizeof (int); /* string table size */ ! 114: addr += sizeof (int); ! 115: printf("+%d]", i); ! 116: if (read(io, addr, i) != i) ! 117: goto shread; ! 118: addr += i; ! 119: esym = roundup((int)addr, sizeof (int)); ! 120: x.a_bss = 0; ! 121: } else ! 122: howto &= ~RB_KDB; ! 123: for (i = 0; i < 128*512; i++) /* slop */ ! 124: *addr++ = 0; ! 125: x.a_entry &= 0x7fffffff; ! 126: printf(" start 0x%x\n", x.a_entry); ! 127: (*((int (*)()) x.a_entry))(); ! 128: return; ! 129: shread: ! 130: printf("Short read\n"); ! 131: return; ! 132: } ! 133: ! 134: #ifdef VAX750 ! 135: /* 750 Patchable Control Store magic */ ! 136: ! 137: #include "../vax/mtpr.h" ! 138: #include "../vax/cpu.h" ! 139: #define PCS_BITCNT 0x2000 /* number of patchbits */ ! 140: #define PCS_MICRONUM 0x400 /* number of ucode locs */ ! 141: #define PCS_PATCHADDR 0xf00000 /* start addr of patchbits */ ! 142: #define PCS_PCSADDR (PCS_PATCHADDR+0x8000) /* start addr of pcs */ ! 143: #define PCS_PATCHBIT (PCS_PATCHADDR+0xc000) /* patchbits enable reg */ ! 144: #define PCS_ENABLE 0xfff00000 /* enable bits for pcs */ ! 145: ! 146: loadpcs() ! 147: { ! 148: register int *ip; /* known to be r11 below */ ! 149: register int i; /* known to be r10 below */ ! 150: register int *jp; /* known to be r9 below */ ! 151: register int j; ! 152: static int pcsdone = 0; ! 153: union cpusid sid; ! 154: char pcs[100]; ! 155: char *cp; ! 156: ! 157: sid.cpusid = mfpr(SID); ! 158: if (sid.cpuany.cp_type!=VAX_750 || sid.cpu750.cp_urev<95 || pcsdone) ! 159: return; ! 160: printf("Updating 11/750 microcode: "); ! 161: for (cp = line; *cp; cp++) ! 162: if (*cp == ')' || *cp == ':') ! 163: break; ! 164: if (*cp) { ! 165: strncpy(pcs, line, 99); ! 166: pcs[99] = 0; ! 167: i = cp - line + 1; ! 168: } else ! 169: i = 0; ! 170: strcpy(pcs + i, "pcs750.bin"); ! 171: i = open(pcs, 0); ! 172: if (i < 0) ! 173: return; ! 174: /* ! 175: * We ask for more than we need to be sure we get only what we expect. ! 176: * After read: ! 177: * locs 0 - 1023 packed patchbits ! 178: * 1024 - 11264 packed microcode ! 179: */ ! 180: if (read(i, (char *)0, 23*512) != 22*512) { ! 181: printf("Error reading %s\n", pcs); ! 182: close(i); ! 183: return; ! 184: } ! 185: close(i); ! 186: ! 187: /* ! 188: * Enable patchbit loading and load the bits one at a time. ! 189: */ ! 190: *((int *)PCS_PATCHBIT) = 1; ! 191: ip = (int *)PCS_PATCHADDR; ! 192: jp = (int *)0; ! 193: for (i=0; i < PCS_BITCNT; i++) { ! 194: asm(" extzv r10,$1,(r9),(r11)+"); ! 195: } ! 196: *((int *)PCS_PATCHBIT) = 0; ! 197: ! 198: /* ! 199: * Load PCS microcode 20 bits at a time. ! 200: */ ! 201: ip = (int *)PCS_PCSADDR; ! 202: jp = (int *)1024; ! 203: for (i=j=0; j < PCS_MICRONUM * 4; i+=20, j++) { ! 204: asm(" extzv r10,$20,(r9),(r11)+"); ! 205: } ! 206: ! 207: /* ! 208: * Enable PCS. ! 209: */ ! 210: i = *jp; /* get 1st 20 bits of microcode again */ ! 211: i &= 0xfffff; ! 212: i |= PCS_ENABLE; /* reload these bits with PCS enable set */ ! 213: *((int *)PCS_PCSADDR) = i; ! 214: ! 215: sid.cpusid = mfpr(SID); ! 216: printf("new rev level=%d\n", sid.cpu750.cp_urev); ! 217: pcsdone = 1; ! 218: } ! 219: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.