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