Deleted Added
sdiff udiff text old ( 8013:2dfcde2e9998 ) new ( 8015:37634fc80b3c )
full compact
1/*
2 * Copyright (c) 2003, 2004
3 * The Regents of The University of Michigan
4 * All Rights Reserved
5 *
6 * This code is part of the M5 simulator, developed by Nathan Binkert,
7 * Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions
8 * from Ron Dreslinski, Dave Greene, Lisa Hsu, Ali Saidi, and Andrew
9 * Schultz.
10 *
11 * Permission is granted to use, copy, create derivative works and
12 * redistribute this software and such derivative works for any purpose,
13 * so long as the copyright notice above, this grant of permission, and
14 * the disclaimer below appear in all copies made; and so long as the
15 * name of The University of Michigan is not used in any advertising or
16 * publicity pertaining to the use or distribution of this software
17 * without specific, written prior authorization.
18 *
19 * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE
20 * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND WITHOUT
21 * WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER EXPRESS OR
22 * IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS OF
24 * THE UNIVERSITY OF MICHIGAN SHALL NOT BE LIABLE FOR ANY DAMAGES,
25 * INCLUDING DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
26 * DAMAGES, WITH RESPECT TO ANY CLAIM ARISING OUT OF OR IN CONNECTION
27 * WITH THE USE OF THE SOFTWARE, EVEN IF IT HAS BEEN OR IS HEREAFTER
28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
29 */
30
31/*
32 * Copyright 1993 Hewlett-Packard Development Company, L.P.
33 *
34 * Permission is hereby granted, free of charge, to any person
35 * obtaining a copy of this software and associated documentation
36 * files (the "Software"), to deal in the Software without
37 * restriction, including without limitation the rights to use, copy,
38 * modify, merge, publish, distribute, sublicense, and/or sell copies
39 * of the Software, and to permit persons to whom the Software is
40 * furnished to do so, subject to the following conditions:
41 *
42 * The above copyright notice and this permission notice shall be
43 * included in all copies or substantial portions of the Software.
44 *
45 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
46 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
49 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
50 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
51 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52 * SOFTWARE.
53 */
54
55/* ******************************************
56 * M5 Console
57 * ******************************************/
58
59#include <linux/stddef.h>
60#include <sys/types.h>
61
62#define CONSOLE
63#include "alpha_access.h"
64#include "cserve.h"
65#include "rpb.h"
66
67#define CONS_INT_TX 0x01 /* interrupt enable / state bits */
68#define CONS_INT_RX 0x02
69
70#define PAGE_SIZE (8192)
71
72#define KSEG 0xfffffc0000000000
73#define K1BASE 0xfffffc8000000000
74#define KSEG_TO_PHYS(x) (((ulong)x) & ~KSEG)
75
76#ifdef TSUNAMI
77#define ALPHA_ACCESS_BASE 0xfffffd0200000000
78#elif TLASER
79#define ALPHA_ACCESS_BASE 0xfffffc8000a00000
80#else
81#error TSUNAMI/TLASER not defined.
82#endif
83
84#define ROUNDUP8(x) ((ulong)(((ulong)x)+7) & ~7)
85#define ROUNDUP128(x) ((ulong)(((ulong)x) + 127) & ~127)
86#define ROUNDUP8K(x) ((ulong)(((ulong)(x)) + 8191) & ~8191)
87
88#define FIRST(x) ((((ulong)(x)) >> 33) & 0x3ff)
89#define SECOND(x) ((((ulong)(x)) >> 23) & 0x3ff)
90#define THIRD(x) ((((ulong)(x)) >> 13) & 0x3ff)
91#define THIRD_XXX(x) ((((ulong)(x)) >> 13) & 0xfff)
92#define PFN(x) ((((ulong)(x) & ~KSEG) >> 13))
93
94/* Kernel write | kernel read | valid */
95#define KPTE(x) ((ulong)((((ulong)(x)) << 32) | 0x1101))
96
97#define HWRPB_PAGES 16
98#define MDT_BITMAP_PAGES 4
99
100#define NUM_KERNEL_THIRD (4)
101
102#define printf_lock(args...) \
103 do { \
104 SpinLock(&theLock); \
105 printf(args); \
106 SpinUnlock(&theLock); \
107 } while (0)
108
109
110void unixBoot(int go, int argc, char **argv);
111void JToKern(char *bootadr, ulong rpb_percpu, ulong free_pfn, ulong k_argc,
112 char **k_argv, char **envp);
113void JToPal(ulong bootadr);
114void SlaveLoop(int cpu);
115
116struct AlphaAccess m5Conf;
117
118ulong theLock;
119
120extern void SpinLock(ulong *lock);
121#define SpinUnlock(_x) *(_x) = 0;
122
123struct _kernel_params {
124 char *bootadr;
125 ulong rpb_percpu;
126 ulong free_pfn;
127 ulong argc;
128 ulong argv;
129 ulong envp; /* NULL */
130};
131
132extern consoleCallback[];
133extern consoleFixup[];
134long CallBackDispatcher();
135long CallBackFixup();
136
137/*
138 * m5 console output
139 */
140
141void
142InitConsole()
143{
144}
145
146char
147GetChar()
148{
149 struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE);
150 return k1Conf->inputChar;
151}
152
153void
154PutChar(char c)
155{
156 struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE);
157 k1Conf->outputChar = c;
158}
159
160int
161passArgs(int argc)
162{
163 return 0;
164}
165
166int
167main(int argc, char **argv)
168{
169 int x, i;
170 struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE);
171 uint *k1ptr, *ksegptr;
172
173 InitConsole();
174 printf_lock("M5 console\n");
175
176 /*
177 * get configuration from backdoor
178 */
179 m5Conf.last_offset = k1Conf->last_offset;
180 printf_lock("Got Configuration %d\n", m5Conf.last_offset);
181
182 m5Conf.last_offset = k1Conf->last_offset;
183 m5Conf.version = k1Conf->version;
184 m5Conf.numCPUs = k1Conf->numCPUs;
185 m5Conf.intrClockFrequency = k1Conf->intrClockFrequency;
186 m5Conf.cpuClock = k1Conf->cpuClock;
187 m5Conf.mem_size = k1Conf->mem_size;
188 m5Conf.kernStart = k1Conf->kernStart;
189 m5Conf.kernEnd = k1Conf->kernEnd;
190 m5Conf.entryPoint = k1Conf->entryPoint;
191 m5Conf.diskUnit = k1Conf->diskUnit;
192 m5Conf.diskCount = k1Conf->diskCount;
193 m5Conf.diskPAddr = k1Conf->diskPAddr;
194 m5Conf.diskBlock = k1Conf->diskBlock;
195 m5Conf.diskOperation = k1Conf->diskOperation;
196 m5Conf.outputChar = k1Conf->outputChar;
197 m5Conf.inputChar = k1Conf->inputChar;
198 m5Conf.bootStrapImpure = k1Conf->bootStrapImpure;
199 m5Conf.bootStrapCPU = k1Conf->bootStrapCPU;
200
201 if (m5Conf.version != ALPHA_ACCESS_VERSION) {
202 panic("Console version mismatch. Console expects %d. has %d \n",
203 ALPHA_ACCESS_VERSION, m5Conf.version);
204 }
205
206 /*
207 * setup arguments to kernel
208 */
209 unixBoot(1, argc, argv);
210
211 x = *(volatile int *)(K1BASE-4);
212 while (1)
213 continue;
214 return x;
215}
216
217/*
218 * BOOTING
219 */
220struct rpb m5_rpb = {
221 NULL, /* 000: physical self-reference */
222 ((long)'H') | (((long)'W') << 8) | (((long)'R') << 16) |
223 ((long)'P' << 24) | (((long)'B') << 32), /* 008: contains "HWRPB" */
224 6, /* 010: HWRPB version number */
225 /* the byte count is wrong, but who needs it? - lance */
226 0, /* 018: bytes in RPB perCPU CTB CRB MEDSC */
227 0, /* 020: primary cpu id */
228 PAGE_SIZE, /* 028: page size in bytes */
229 43, /* 030: number of phys addr bits */
230 127, /* 038: max valid ASN */
231 {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1'},
232 /* 040: system serial num: 10 ascii chars */
233 0, /* OVERRIDDEN */
234 (1<<10), /* 058: system variation */
235 'c'|('o'<<8)|('o'<<16)|('l'<< 24), /* 060: system revision */
236 1024*4096, /* 068: scaled interval clock intr freq */
237 0, /* 070: cycle counter frequency */
238 0x200000000, /* 078: virtual page table base */
239 0, /* 080: reserved */
240 0, /* 088: offset to translation buffer hint */
241 1, /* 090: number of processor slots OVERRIDDEN*/
242 sizeof(struct rpb_percpu), /* 098: per-cpu slot size. OVERRIDDEN */
243 0, /* 0A0: offset to per_cpu slots */
244 1, /* 0A8: number of CTBs */
245 sizeof(struct ctb_tt),
246 0, /* 0B8: offset to CTB (cons term block) */
247 0, /* 0C0: offset to CRB (cons routine block) */
248 0, /* 0C8: offset to memory descriptor table */
249 0, /* 0D0: offset to config data block */
250 0, /* 0D8: offset to FRU table */
251 0, /* 0E0: virt addr of save term routine */
252 0, /* 0E8: proc value for save term routine */
253 0, /* 0F0: virt addr of restore term routine */
254 0, /* 0F8: proc value for restore term routine */
255 0, /* 100: virt addr of CPU restart routine */
256 0, /* 108: proc value for CPU restart routine */
257 0, /* 110: used to determine presence of kdebug */
258 0, /* 118: reserved for hardware */
259/* the checksum is wrong, but who needs it? - lance */
260 0, /* 120: checksum of prior entries in rpb */
261 0, /* 128: receive ready bitmask */
262 0, /* 130: transmit ready bitmask */
263 0, /* 138: Dynamic System Recog. offset */
264};
265
266ulong m5_tbb[] = { 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e,
267 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e,
268 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e,
269 0x1e1e1e1e1e1e1e1e, 0x1e1e1e1e1e1e1e1e };
270
271struct rpb_percpu m5_rpb_percpu = {
272 {0,0,0,0,0,0,1,{0,0},{0,0,0,0,0,0,0,0}}, /* 000: boot/restart HWPCB */
273 (STATE_PA | STATE_PP | STATE_CV |
274 STATE_PV | STATE_PMV | STATE_PL), /* 080: per-cpu state bits */
275 0xc000, /* 088: palcode memory length */
276 0x2000, /* 090: palcode scratch length */
277 0x4000, /* 098: paddr of pal mem space */
278 0x2000, /* 0A0: paddr of pal scratch space */
279 (2 << 16) | (5 << 8) | 1, /* 0A8: PALcode rev required */
280 11 | (2L << 32), /* 0B0: processor type */
281 7, /* 0B8: processor variation */
282 'M'|('5'<<8)|('A'<<16)|('0'<<24), /* 0C0: processor revision */
283 {'M','5','/','A','l','p','h','a','0','0','0','0','0','0','0','0'},
284 /* 0C8: proc serial num: 10 chars */
285 0, /* 0D8: phys addr of logout area */
286 0, /* 0E0: len in bytes of logout area */
287 0, /* 0E8: halt pcb base */
288 0, /* 0F0: halt pc */
289 0, /* 0F8: halt ps */
290 0, /* 100: halt arg list (R25) */
291 0, /* 108: halt return address (R26) */
292 0, /* 110: halt procedure value (R27) */
293 0, /* 118: reason for halt */
294 0, /* 120: for software */
295 {0}, /* 128: inter-console comm buffer */
296 {1,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0}, /* 1D0: PALcode revs available */
297 0 /* 250: reserved for arch use */
298/* the dump stack grows from the end of the rpb page not to reach here */
299};
300
301struct _m5_rpb_mdt {
302 long rpb_checksum; /* 000: checksum of entire mem desc table */
303 long rpb_impaddr; /* 008: PA of implementation dep info */
304 long rpb_numcl; /* 010: number of clusters */
305 struct rpb_cluster rpb_cluster[3]; /* first instance of a cluster */
306};
307
308struct _m5_rpb_mdt m5_rpb_mdt = {
309 0, /* 000: checksum of entire mem desc table */
310 0, /* 008: PA of implementation dep info */
311 0, /* 010: number of clusters */
312 {{ 0, /* 000: starting PFN of this cluster */
313 0, /* 008: count of PFNs in this cluster */
314 0, /* 010: count of tested PFNs in cluster */
315 0, /* 018: va of bitmap */
316 0, /* 020: pa of bitmap */
317 0, /* 028: checksum of bitmap */
318 1 /* 030: usage of cluster */
319 },
320 { 0, /* 000: starting PFN of this cluster */
321 0, /* 008: count of PFNs in this cluster */
322 0, /* 010: count of tested PFNs in cluster */
323 0, /* 018: va of bitmap */
324 0, /* 020: pa of bitmap */
325 0, /* 028: checksum of bitmap */
326 0 /* 030: usage of cluster */
327 },
328 { 0, /* 000: starting PFN of this cluster */
329 0, /* 008: count of PFNs in this cluster */
330 0, /* 010: count of tested PFNs in cluster */
331 0, /* 018: va of bitmap */
332 0, /* 020: pa of bitmap */
333 0, /* 028: checksum of bitmap */
334 0 /* 030: usage of cluster */
335 }}
336};
337
338/* constants for slotinfo bus_type subfield */
339#define SLOTINFO_TC 0
340#define SLOTINFO_ISA 1
341#define SLOTINFO_EISA 2
342#define SLOTINFO_PCI 3
343
344struct rpb_ctb m5_rpb_ctb = {
345 CONS_DZ, /* 000: console type */
346 0, /* 008: console unit */
347 0, /* 010: reserved */
348 0 /* 018: byte length of device dep portion */
349};
350
351/* we don't do any fixup (aka relocate the console) - we hope */
352struct rpb_crb m5_rpb_crb = {
353 0, /* va of call-back dispatch rtn */
354 0, /* pa of call-back dispatch rtn */
355 0, /* va of call-back fixup rtn */
356 0, /* pa of call-back fixup rtn */
357 0, /* number of entries in phys/virt map */
358 0 /* Number of pages to be mapped */
359};
360
361struct _rpb_name {
362 ulong length;
363 char name[16];
364};
365
366extern struct _rpb_name m5_name;
367
368struct rpb_dsr m5_rpb_dsr = {
369 0,
370 0,
371 0,
372};
373
374struct _rpb_name m5_name = {
375 16,
376 {'U','M','I','C','H',' ','M','5','/','A','L','P','H','A',' ',0},
377};
378
379/*
380 * M5 has one LURT entry:
381 * 1050 is for workstations
382 * 1100 is servers (and is needed for CXX)
383 */
384long m5_lurt[10] = { 9, 12, -1, -1, -1, -1, -1, -1, 1100, 1100 };
385
386ulong unix_boot_mem;
387ulong bootadr;
388
389char **kargv;
390int kargc;
391ulong free_pfn;
392struct rpb_percpu *rpb_percpu;
393
394#define MAX_CPUS 32
395
396ulong bootStrapImpure[MAX_CPUS];
397
398char *
399unix_boot_alloc(int pages)
400{
401 char *ret = (char *) unix_boot_mem;
402 unix_boot_mem += (pages * PAGE_SIZE);
403 return ret;
404}
405
406ulong *first = 0;
407ulong *third_rpb = 0;
408ulong *reservedFixup = 0;
409
410int strcpy(char *dst, char *src);
411
412struct rpb *rpb;
413extern ulong _end;
414
415void
416unixBoot(int go, int argc, char **argv)
417{
418 ulong *second, *third_kernel, ptr, *tbb, size, *percpu_logout;
419 unsigned char *mdt_bitmap;
420 long *lp1, *lp2, sum;
421 int i, cl;
422 int kern_first_page;
423 int mem_size = m5Conf.mem_size;
424
425 int mem_pages = mem_size / PAGE_SIZE, cons_pages;
426 ulong kernel_bytes, ksp, kernel_end, *unix_kernel_stack, bss,
427 ksp_bottom, ksp_top;
428 struct rpb_ctb *rpb_ctb;
429 struct ctb_tt *ctb_tt;
430 struct rpb_dsr *rpb_dsr;
431 struct rpb_crb *rpb_crb;
432 struct _m5_rpb_mdt *rpb_mdt;
433 int *rpb_lurt;
434 char *rpb_name;
435 ulong nextPtr;
436
437 printf_lock("memsize %x pages %x \n", mem_size, mem_pages);
438
439 /* Allocate:
440 * two pages for the HWRPB
441 * five page table pages:
442 * 1: First level page table
443 * 1: Second level page table
444 * 1: Third level page table for HWRPB
445 * 2: Third level page table for kernel (for up to 16MB)
446 * set up the page tables
447 * load the kernel at the physical address 0x230000
448 * build the HWRPB
449 * set up memory descriptor table to give up the
450 * physical memory between the end of the page
451 * tables and the start of the kernel
452 * enable kseg addressing
453 * jump to the kernel
454 */
455
456 unix_boot_mem = ROUNDUP8K(&_end);
457
458 printf_lock("First free page after ROM 0x%x\n", unix_boot_mem);
459
460 rpb = (struct rpb *) unix_boot_alloc( HWRPB_PAGES);
461
462 mdt_bitmap = (unsigned char *) unix_boot_alloc(MDT_BITMAP_PAGES);
463 first = (ulong *)unix_boot_alloc(1);
464 second = (ulong *)unix_boot_alloc(1);
465 third_rpb = (ulong *)unix_boot_alloc(1);
466 reservedFixup = (ulong*) unix_boot_alloc(1);
467 third_kernel = (ulong *)unix_boot_alloc(NUM_KERNEL_THIRD);
468 percpu_logout = (ulong*)unix_boot_alloc(1);
469
470 cons_pages = KSEG_TO_PHYS(unix_boot_mem) / PAGE_SIZE;
471
472 /* Set up the page tables */
473 bzero((char *)first, PAGE_SIZE);
474 bzero((char *)second, PAGE_SIZE);
475 bzero((char *)reservedFixup, PAGE_SIZE);
476 bzero((char *)third_rpb, HWRPB_PAGES * PAGE_SIZE);
477 bzero((char *)third_kernel, PAGE_SIZE * NUM_KERNEL_THIRD);
478
479 first[0] = KPTE(PFN(second));
480 first[1] = KPTE(PFN(first)); /* Region 3 */
481
482 /* Region 0 */
483 second[SECOND(0x10000000)] = KPTE(PFN(third_rpb));
484
485 for (i = 0; i < NUM_KERNEL_THIRD; i++) {
486 /* Region 1 */
487 second[SECOND(0x20000000) + i] = KPTE(PFN(third_kernel) + i);
488 }
489 /* Region 2 */
490 second[SECOND(0x40000000)] = KPTE(PFN(second));
491
492
493 /* For some obscure reason, Dec Unix's database read
494 * from /etc/sysconfigtab is written to this fixed
495 * mapped memory location. Go figure, since it is
496 * not initialized by the console. Maybe it is
497 * to look at the database from the console
498 * after a boot/crash.
499 *
500 * Black magic to estimate the max size. SEGVs on overflow
501 * bugnion
502 */
503
504#define DATABASE_BASE 0x20000000
505#define DATABASE_END 0x20020000
506
507 ulong *dbPage = (ulong*)unix_boot_alloc(1);
508 second[SECOND(DATABASE_BASE)] = KPTE(PFN(dbPage));
509 for (i = DATABASE_BASE; i < DATABASE_END ; i += 8096) {
510 ulong *db = (ulong*)unix_boot_alloc(1);
511 dbPage[THIRD(i)] = KPTE(PFN(db));
512 }
513
514 /* Region 0 */
515 /* Map the HWRPB */
516 for (i = 0; i < HWRPB_PAGES; i++)
517 third_rpb[i] = KPTE(PFN(rpb) + i);
518
519 /* Map the MDT bitmap table */
520 for (i = 0; i < MDT_BITMAP_PAGES; i++) {
521 third_rpb[HWRPB_PAGES + i] = KPTE(PFN(mdt_bitmap) + i);
522 }
523
524 /* Protect the PAL pages */
525 for (i = 1; i < PFN(first); i++)
526 third_rpb[HWRPB_PAGES + MDT_BITMAP_PAGES + i] = KPTE(i);
527
528 /* Set up third_kernel after it's loaded, when we know where it is */
529 kern_first_page = (KSEG_TO_PHYS(m5Conf.kernStart)/PAGE_SIZE);
530 kernel_end = ksp_top = ROUNDUP8K(m5Conf.kernEnd);
531 bootadr = m5Conf.entryPoint;
532
533 printf_lock("HWRPB 0x%x l1pt 0x%x l2pt 0x%x l3pt_rpb 0x%x l3pt_kernel 0x%x"
534 " l2reserv 0x%x\n",
535 rpb, first, second, third_rpb, third_kernel, reservedFixup);
536 if (kernel_end - m5Conf.kernStart > (0x800000*NUM_KERNEL_THIRD)) {
537 printf_lock("Kernel is more than 8MB 0x%x - 0x%x = 0x%x\n",
538 kernel_end, m5Conf.kernStart,
539 kernel_end - m5Conf.kernStart );
540 panic("kernel too big\n");
541 }
542
543 /* Map the kernel's pages into the third level of region 2 */
544 for (ptr = m5Conf.kernStart; ptr < kernel_end; ptr += PAGE_SIZE) {
545 third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr));
546 }
547
548 /* blow 2 pages of phys mem for guards since it maintains 1-to-1 mapping */
549 ksp = ksp_top + (3 * PAGE_SIZE);
550 if (ksp - m5Conf.kernStart > (0x800000*NUM_KERNEL_THIRD)) {
551 printf_lock("Kernel stack pushd us over 8MB\n");
552 panic("ksp too big\n");
553 }
554 if (THIRD_XXX((ulong)ksp_top) > NUM_KERNEL_THIRD * 1024) {
555 panic("increase NUM_KERNEL_THIRD, and change THIRD_XXX\n");
556 }
557 ptr = (ulong) ksp_top;
558 bzero((char *)ptr, PAGE_SIZE * 2);
559 third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */
560 ptr += PAGE_SIZE;
561 third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr)); /* Kernel Stack Pages */
562 ptr += PAGE_SIZE;
563 third_kernel[THIRD_XXX(ptr)] = KPTE(PFN(ptr));
564 ptr += PAGE_SIZE;
565 third_kernel[THIRD_XXX(ptr)] = 0; /* Stack Guard Page */
566
567 /* put argv into the bottom of the stack - argv starts at 1 because
568 * the command thatr got us here (i.e. "unixboot) is in argv[0].
569 */
570 ksp -= 8; /* Back up one longword */
571 ksp -= argc * sizeof(char *); /* Make room for argv */
572 kargv = (char **) ksp;
573 for (i = 1; i < argc; i++) { /* Copy arguments to stack */
574 ksp -= ((strlen(argv[i]) + 1) + 7) & ~0x7;
575 kargv[i-1] = (char *) ksp;
576 strcpy(kargv[i - 1], argv[i]);
577 }
578 kargc = i - 1;
579 kargv[kargc] = NULL; /* just to be sure; doesn't seem to be used */
580 ksp -= sizeof(char *); /* point above last arg for no real reason */
581
582 free_pfn = PFN(ptr);
583
584 bcopy((char *)&m5_rpb, (char *)rpb, sizeof(struct rpb));
585
586 rpb->rpb_selfref = (struct rpb *) KSEG_TO_PHYS(rpb);
587 rpb->rpb_string = 0x0000004250525748;
588
589 tbb = (ulong *) (((char *) rpb) + ROUNDUP8(sizeof(struct rpb)));
590 rpb->rpb_trans_off = (ulong)tbb - (ulong)rpb;
591 bcopy((char *)m5_tbb, (char *)tbb, sizeof(m5_tbb));
592
593 /*
594 * rpb_counter. Use to determine timeouts in OS.
595 * XXX must be patched after a checkpoint restore (I guess)
596 */
597
598 printf_lock("CPU Clock at %d MHz IntrClockFrequency=%d \n",
599 m5Conf.cpuClock, m5Conf.intrClockFrequency);
600 rpb->rpb_counter = m5Conf.cpuClock * 1000 * 1000;
601
602 /*
603 * By definition, the rpb_clock is scaled by 4096 (in hz)
604 */
605 rpb->rpb_clock = m5Conf.intrClockFrequency * 4096;
606
607 /*
608 * Per CPU Slots. Multiprocessor support.
609 */
610 int percpu_size = ROUNDUP128(sizeof(struct rpb_percpu));
611
612 printf_lock("Booting with %d processor(s) \n", m5Conf.numCPUs);
613
614 rpb->rpb_numprocs = m5Conf.numCPUs;
615 rpb->rpb_slotsize = percpu_size;
616 rpb_percpu = (struct rpb_percpu *)
617 ROUNDUP128(((ulong)tbb) + (sizeof(m5_tbb)));
618
619 rpb->rpb_percpu_off = (ulong)rpb_percpu - (ulong)rpb;
620
621 for (i = 0; i < m5Conf.numCPUs; i++) {
622 struct rpb_percpu *thisCPU = (struct rpb_percpu*)
623 ((ulong)rpb_percpu + percpu_size * i);
624
625 bzero((char *)thisCPU, percpu_size);
626 bcopy((char *)&m5_rpb_percpu, (char *)thisCPU,
627 sizeof(struct rpb_percpu));
628
629 thisCPU->rpb_pcb.rpb_ksp = ksp;
630 thisCPU->rpb_pcb.rpb_ptbr = PFN(first);
631
632 thisCPU->rpb_logout = KSEG_TO_PHYS(percpu_logout);
633 thisCPU->rpb_logout_len = PAGE_SIZE;
634
635 printf_lock("KSP: 0x%x PTBR 0x%x\n",
636 thisCPU->rpb_pcb.rpb_ksp, thisCPU->rpb_pcb.rpb_ptbr);
637
638 if (i) {
639 bootStrapImpure[i] = (ulong)unix_boot_alloc(1);
640 }
641 }
642
643 nextPtr = (ulong)rpb_percpu + percpu_size * m5Conf.numCPUs;
644
645 /*
646 * Console Terminal Block
647 */
648 rpb_ctb = (struct rpb_ctb *) nextPtr;
649 ctb_tt = (struct ctb_tt*) rpb_ctb;
650
651 rpb->rpb_ctb_off = ((ulong)rpb_ctb) - (ulong)rpb;
652 rpb->rpb_ctb_size = sizeof(struct rpb_ctb);
653
654 bzero((char *)rpb_ctb, sizeof(struct ctb_tt));
655
656 rpb_ctb->rpb_type = CONS_DZ;
657 rpb_ctb->rpb_length = sizeof(ctb_tt) - sizeof(rpb_ctb);
658
659 /*
660 * uart initizliation
661 */
662 ctb_tt->ctb_csr = 0;
663 ctb_tt->ctb_tivec = 0x6c0; /* matches tlaser pal code */
664 ctb_tt->ctb_rivec = 0x680; /* matches tlaser pal code */
665 ctb_tt->ctb_baud = 9600;
666 ctb_tt->ctb_put_sts = 0;
667 ctb_tt->ctb_get_sts = 0;
668
669 rpb_crb = (struct rpb_crb *) (((ulong)rpb_ctb) + sizeof(struct ctb_tt));
670 rpb->rpb_crb_off = ((ulong)rpb_crb) - (ulong)rpb;
671
672 bzero((char *)rpb_crb, sizeof(struct rpb_crb));
673
674 /*
675 * console callback stuff (m5)
676 */
677 rpb_crb->rpb_num = 1;
678 rpb_crb->rpb_mapped_pages = HWRPB_PAGES;
679 rpb_crb->rpb_map[0].rpb_virt = 0x10000000;
680 rpb_crb->rpb_map[0].rpb_phys = KSEG_TO_PHYS(((ulong)rpb) & ~0x1fff);
681 rpb_crb->rpb_map[0].rpb_pgcount = HWRPB_PAGES;
682
683 printf_lock("Console Callback at 0x%x, fixup at 0x%x, crb offset: 0x%x\n",
684 rpb_crb->rpb_va_disp, rpb_crb->rpb_va_fixup, rpb->rpb_crb_off);
685
686 rpb_mdt = (struct _m5_rpb_mdt *)((ulong)rpb_crb + sizeof(struct rpb_crb));
687 rpb->rpb_mdt_off = (ulong)rpb_mdt - (ulong)rpb;
688 bcopy((char *)&m5_rpb_mdt, (char *)rpb_mdt, sizeof(struct _m5_rpb_mdt));
689
690
691 cl = 0;
692 rpb_mdt->rpb_cluster[cl].rpb_pfncount = kern_first_page;
693 cl++;
694
695 rpb_mdt->rpb_cluster[cl].rpb_pfn = kern_first_page;
696 rpb_mdt->rpb_cluster[cl].rpb_pfncount = mem_pages - kern_first_page;
697 rpb_mdt->rpb_cluster[cl].rpb_pfntested =
698 rpb_mdt->rpb_cluster[cl].rpb_pfncount;
699 rpb_mdt->rpb_cluster[cl].rpb_pa = KSEG_TO_PHYS(mdt_bitmap);
700 rpb_mdt->rpb_cluster[cl].rpb_va = 0x10000000 + HWRPB_PAGES * PAGE_SIZE;
701 cl++;
702
703 rpb_mdt->rpb_numcl = cl;
704
705 for (i = 0; i < cl; i++)
706 printf_lock("Memory cluster %d [%d - %d]\n", i,
707 rpb_mdt->rpb_cluster[i].rpb_pfn,
708 rpb_mdt->rpb_cluster[i].rpb_pfncount);
709
710 /* Checksum the rpb for good luck */
711 sum = 0;
712 lp1 = (long *)&rpb_mdt->rpb_impaddr;
713 lp2 = (long *)&rpb_mdt->rpb_cluster[cl];
714 while (lp1 < lp2) sum += *lp1++;
715 rpb_mdt->rpb_checksum = sum;
716
717 /* XXX should checksum the cluster descriptors */
718 bzero((char *)mdt_bitmap, MDT_BITMAP_PAGES * PAGE_SIZE);
719 for (i = 0; i < mem_pages/8; i++)
720 ((unsigned char *)mdt_bitmap)[i] = 0xff;
721
722 printf_lock("Initalizing mdt_bitmap addr 0x%x mem_pages %x \n",
723 (long)mdt_bitmap,(long)mem_pages);
724
725 m5_rpb.rpb_config_off = 0;
726 m5_rpb.rpb_fru_off = 0;
727
728 rpb_dsr = (struct rpb_dsr *)((ulong)rpb_mdt + sizeof(struct _m5_rpb_mdt));
729 rpb->rpb_dsr_off = (ulong)rpb_dsr - (ulong)rpb;
730 bzero((char *)rpb_dsr, sizeof(struct rpb_dsr));
731 rpb_dsr->rpb_smm = 1578; /* Official XXM SMM number as per SRM */
732 rpb_dsr->rpb_smm = 1089; /* Official Alcor SMM number as per SRM */
733
734 rpb_lurt = (int *) ROUNDUP8((ulong)rpb_dsr + sizeof(struct rpb_dsr));
735 rpb_dsr->rpb_lurt_off = ((ulong) rpb_lurt) - (ulong) rpb_dsr;
736 bcopy((char *)m5_lurt, (char *)rpb_lurt, sizeof(m5_lurt));
737
738 rpb_name = (char *) ROUNDUP8(((ulong)rpb_lurt) + sizeof(m5_lurt));
739 rpb_dsr->rpb_sysname_off = ((ulong) rpb_name) - (ulong) rpb_dsr;
740#define THENAME " M5/Alpha "
741 sum = sizeof(THENAME);
742 bcopy(THENAME, rpb_name, sum);
743 *(ulong *)rpb_name = sizeof(THENAME); /* put in length field */
744
745 /* calculate size of rpb */
746 rpb->rpb_size = ((ulong) &rpb_name[sum]) - (ulong)rpb;
747
748 if (rpb->rpb_size > PAGE_SIZE * HWRPB_PAGES) {
749 panic("HWRPB_PAGES=%d too small for HWRPB !!! \n");
750 }
751
752 ulong *rpbptr = (ulong*)((char*)rpb_dsr + sizeof(struct rpb_dsr));
753 rpb_crb->rpb_pa_disp = KSEG_TO_PHYS(rpbptr);
754 rpb_crb->rpb_va_disp = 0x10000000 +
755 (((ulong)rpbptr - (ulong)rpb) & (0x2000 * HWRPB_PAGES - 1));
756 printf_lock("ConsoleDispatch at virt %x phys %x val %x\n",
757 rpb_crb->rpb_va_disp, rpb_crb->rpb_pa_disp, consoleCallback);
758 *rpbptr++ = 0;
759 *rpbptr++ = (ulong) consoleCallback;
760 rpb_crb->rpb_pa_fixup = KSEG_TO_PHYS(rpbptr);
761 rpb_crb->rpb_va_fixup = 0x10000000 +
762 (((ulong)rpbptr - (ulong)rpb) & (0x2000 * HWRPB_PAGES - 1));
763 *rpbptr++ = 0;
764
765 *rpbptr++ = (ulong) consoleFixup;
766
767 /* Checksum the rpb for good luck */
768 sum = 0;
769 lp1 = (long *)rpb;
770 lp2 = &rpb->rpb_checksum;
771 while (lp1 < lp2)
772 sum += *lp1++;
773 *lp2 = sum;
774
775 /*
776 * MP bootstrap
777 */
778 for (i = 1; i < m5Conf.numCPUs; i++) {
779 volatile struct AlphaAccess *k1Conf;
780 k1Conf = (volatile struct AlphaAccess *)(ALPHA_ACCESS_BASE);
781 printf_lock("Bootstraping CPU %d with sp=0x%x\n",
782 i, bootStrapImpure[i]);
783 k1Conf->bootStrapImpure = bootStrapImpure[i];
784 k1Conf->bootStrapCPU = i;
785 }
786
787 /*
788 * Make sure that we are not stepping on the kernel
789 */
790 if ((ulong)unix_boot_mem >= (ulong)m5Conf.kernStart) {
791 panic("CONSOLE: too much memory. Smashing kernel\n");
792 } else {
793 printf_lock("unix_boot_mem ends at %x \n", unix_boot_mem);
794 }
795
796 if (go)
797 JToKern((char *)bootadr, (ulong)rpb_percpu, free_pfn, kargc, kargv,
798 NULL);
799}
800
801
802void
803JToKern(char *bootadr, ulong rpb_percpu, ulong free_pfn, ulong k_argc,
804 char **k_argv, char **envp)
805{
806 extern ulong palJToKern[];
807
808 struct _kernel_params *kernel_params = (struct _kernel_params *) KSEG;
809 int i;
810
811 printf_lock("k_argc = %d ", k_argc);
812 for (i = 0; i < k_argc; i++) {
813 printf_lock("'%s' ", k_argv[i]);
814 }
815 printf_lock("\n");
816
817 kernel_params->bootadr = bootadr;
818 kernel_params->rpb_percpu = KSEG_TO_PHYS(rpb_percpu);
819 kernel_params->free_pfn = free_pfn;
820 kernel_params->argc = k_argc;
821 kernel_params->argv = (ulong)k_argv;
822 kernel_params->envp = (ulong)envp;
823 printf_lock("jumping to kernel at 0x%x, (PCBB 0x%x pfn %d)\n",
824 bootadr, rpb_percpu, free_pfn);
825 JToPal(KSEG_TO_PHYS(palJToKern));
826 printf_lock("returned from JToPal. Looping\n");
827 while (1)
828 continue;
829}
830
831void
832JToPal(ulong bootadr)
833{
834 cServe(bootadr, 0, CSERVE_K_JTOPAL);
835
836 /*
837 * Make sure that floating point is enabled incase
838 * it was disabled by the user program.
839 */
840 wrfen(1);
841}
842
843int
844strcpy(char *dst, char *src)
845{
846 int i = 0;
847 while (*src) {
848 *dst++ = *src++;
849 i++;
850 }
851 return i;
852}
853
854/*
855 * Console I/O
856 *
857 */
858
859int numOpenDevices = 11;
860struct {
861 char name[128];
862} deviceState[32];
863
864#define BOOTDEVICE_NAME "SCSI 1 0 0 1 100 0"
865
866void
867DeviceOperation(long op, long channel, long count, long address, long block)
868{
869 struct AlphaAccess *k1Conf = (struct AlphaAccess *)(ALPHA_ACCESS_BASE);
870 long pAddr;
871
872 if (strcmp(deviceState[channel].name, BOOTDEVICE_NAME )) {
873 panic("DeviceRead: only implemented for root disk \n");
874 }
875 pAddr = KSEG_TO_PHYS(address);
876 if (pAddr + count > m5Conf.mem_size) {
877 panic("DeviceRead: request out of range \n");
878 }
879
880 k1Conf->diskCount = count;
881 k1Conf->diskPAddr = pAddr;
882 k1Conf->diskBlock = block;
883 k1Conf->diskOperation = op; /* launch */
884}
885
886/*
887 * M5 Console callbacks
888 *
889 */
890
891/* AXP manual 2-31 */
892#define CONSCB_GETC 0x1
893#define CONSCB_PUTS 0x2
894#define CONSCB_RESET_TERM 0x3
895#define CONSCB_SET_TERM_INT 0x4
896#define CONSCB_SET_TERM_CTL 0x5
897#define CONSCB_PROCESS_KEY 0x6
898#define CONSCB_OPEN_CONSOLE 0x7
899#define CONSCB_CLOSE_CONSOLE 0x8
900
901#define CONSCB_OPEN 0x10
902#define CONSCB_CLOSE 0x11
903#define CONSCB_READ 0x13
904
905#define CONSCB_GETENV 0x22
906
907/* AXP manual 2-26 */
908#define ENV_AUTO_ACTION 0X01
909#define ENV_BOOT_DEV 0X02
910#define ENV_BOOTDEF_DEV 0X03
911#define ENV_BOOTED_DEV 0X04
912#define ENV_BOOT_FILE 0X05
913#define ENV_BOOTED_FILE 0X06
914#define ENV_BOOT_OSFLAGS 0X07
915#define ENV_BOOTED_OSFLAGS 0X08
916#define ENV_BOOT_RESET 0X09
917#define ENV_DUMP_DEV 0X0A
918#define ENV_ENABLE_AUDIT 0X0B
919#define ENV_LICENSE 0X0C
920#define ENV_CHAR_SET 0X0D
921#define ENV_LANGUAGE 0X0E
922#define ENV_TTY_DEV 0X0F
923#define ENV_SCSIID 0X42
924#define ENV_SCSIFAST 0X43
925#define ENV_COM1_BAUD 0X44
926#define ENV_COM1_MODEM 0X45
927#define ENV_COM1_FLOW 0X46
928#define ENV_COM1_MISC 0X47
929#define ENV_COM2_BAUD 0X48
930#define ENV_COM2_MODEM 0X49
931#define ENV_COM2_FLOW 0X4A
932#define ENV_COM2_MISC 0X4B
933#define ENV_PASSWORD 0X4C
934#define ENV_SECURE 0X4D
935#define ENV_LOGFAIL 0X4E
936#define ENV_SRM2DEV_ID 0X4F
937
938#define MAX_ENVLEN 32
939
940char env_auto_action[MAX_ENVLEN] = "BOOT";
941char env_boot_dev[MAX_ENVLEN] = "";
942char env_bootdef_dev[MAX_ENVLEN] = "";
943char env_booted_dev[MAX_ENVLEN] = BOOTDEVICE_NAME;
944char env_boot_file[MAX_ENVLEN] = "";
945char env_booted_file[MAX_ENVLEN] = "";
946char env_boot_osflags[MAX_ENVLEN] = "";
947char env_booted_osflags[MAX_ENVLEN] = "";
948char env_boot_reset[MAX_ENVLEN] = "";
949char env_dump_dev[MAX_ENVLEN] = "";
950char env_enable_audit[MAX_ENVLEN] = "";
951char env_license[MAX_ENVLEN] = "";
952char env_char_set[MAX_ENVLEN] = "";
953char env_language[MAX_ENVLEN] = "";
954char env_tty_dev[MAX_ENVLEN] = "0";
955char env_scsiid[MAX_ENVLEN] = "";
956char env_scsifast[MAX_ENVLEN] = "";
957char env_com1_baud[MAX_ENVLEN] = "";
958char env_com1_modem[MAX_ENVLEN] = "";
959char env_com1_flow[MAX_ENVLEN] = "";
960char env_com1_misc[MAX_ENVLEN] = "";
961char env_com2_baud[MAX_ENVLEN] = "";
962char env_com2_modem[MAX_ENVLEN] = "";
963char env_com2_flow[MAX_ENVLEN] = "";
964char env_com2_misc[MAX_ENVLEN] = "";
965char env_password[MAX_ENVLEN] = "";
966char env_secure[MAX_ENVLEN] = "";
967char env_logfail[MAX_ENVLEN] = "";
968char env_srm2dev_id[MAX_ENVLEN] = "";
969
970#define MAX_ENV_INDEX 100
971char *envptr[MAX_ENV_INDEX] = {
972 0, /* 0x00 */
973 env_auto_action, /* 0x01 */
974 env_boot_dev, /* 0x02 */
975 env_bootdef_dev, /* 0x03 */
976 env_booted_dev, /* 0x04 */
977 env_boot_file, /* 0x05 */
978 env_booted_file, /* 0x06 */
979 env_boot_osflags, /* 0x07 */
980 env_booted_osflags, /* 0x08 */
981 env_boot_reset, /* 0x09 */
982 env_dump_dev, /* 0x0A */
983 env_enable_audit, /* 0x0B */
984 env_license, /* 0x0C */
985 env_char_set, /* 0x0D */
986 (char *)&env_language, /* 0x0E */
987 env_tty_dev, /* 0x0F */
988 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* 0x10 - 0x1F */
989 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* 0x20 - 0x2F */
990 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* 0x30 - 0x3F */
991 0, /* 0x40 */
992 0, /* 0x41 */
993 env_scsiid, /* 0x42 */
994 env_scsifast, /* 0x43 */
995 env_com1_baud, /* 0x44 */
996 env_com1_modem, /* 0x45 */
997 env_com1_flow, /* 0x46 */
998 env_com1_misc, /* 0x47 */
999 env_com2_baud, /* 0x48 */
1000 env_com2_modem, /* 0x49 */
1001 env_com2_flow, /* 0x4A */
1002 env_com2_misc, /* 0x4B */
1003 env_password, /* 0x4C */
1004 env_secure, /* 0x4D */
1005 env_logfail, /* 0x4E */
1006 env_srm2dev_id, /* 0x4F */
1007 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* 0x50 - 0x5F */
1008 0, /* 0x60 */
1009 0, /* 0x61 */
1010 0, /* 0x62 */
1011 0, /* 0x63 */
1012};
1013
1014long
1015CallBackDispatcher(long a0, long a1, long a2, long a3, long a4)
1016{
1017 long i;
1018 switch (a0) {
1019 case CONSCB_GETC:
1020 return GetChar();
1021
1022 case CONSCB_PUTS:
1023 for (i = 0; i < a3; i++)
1024 PutChar(*((char *)a2 + i));
1025 return a3;
1026
1027 case CONSCB_GETENV:
1028 if (a1 >= 0 && a1 < MAX_ENV_INDEX && envptr[a1] != 0 && *envptr[a1]) {
1029 i = strcpy((char*)a2, envptr[a1]);
1030 } else {
1031 strcpy((char*)a2, "");
1032 i = (long)0xc000000000000000;
1033 if (a1 >= 0 && a1 < MAX_ENV_INDEX)
1034 printf_lock("GETENV unsupported option %d (0x%x)\n", a1, a1);
1035 else
1036 printf_lock("GETENV unsupported option %s\n", a1);
1037 }
1038
1039 if (i > a3)
1040 panic("CONSCB_GETENV overwrote buffer\n");
1041 return i;
1042
1043 case CONSCB_OPEN:
1044 bcopy((char*)a1, deviceState[numOpenDevices].name, a2);
1045 deviceState[numOpenDevices].name[a2] = '\0';
1046 printf_lock("CONSOLE OPEN : %s --> success \n",
1047 deviceState[numOpenDevices].name);
1048 return numOpenDevices++;
1049
1050 case CONSCB_READ:
1051 DeviceOperation(a0, a1, a2, a3, a4);
1052 break;
1053
1054 case CONSCB_CLOSE:
1055 break;
1056
1057 case CONSCB_OPEN_CONSOLE:
1058 printf_lock("CONSOLE OPEN\n");
1059 return 0; /* success */
1060 break; /* not reached */
1061
1062 case CONSCB_CLOSE_CONSOLE:
1063 printf_lock("CONSOLE CLOSE\n");
1064 return 0; /* success */
1065 break; /* not reached */
1066
1067 default:
1068 panic("CallBackDispatcher(%x,%x,%x,%x,%x)\n", a0, a1, a2, a3, a4);
1069 }
1070
1071 return 0;
1072}
1073
1074long
1075CallBackFixup(int a0, int a1, int a2)
1076{
1077 long temp;
1078 /*
1079 * Linux uses r8 for the current pointer (pointer to data
1080 * structure contating info about currently running process). It
1081 * is set when the kernel starts and is expected to remain
1082 * there... Problem is that the unlike the kernel, the console
1083 * does not prevent the assembler from using r8. So here is a work
1084 * around. So far this has only been a problem in CallBackFixup()
1085 * but any other call back functions couldd cause a problem at
1086 * some point
1087 */
1088
1089 /* save off the current pointer to a temp variable */
1090 asm("bis $8, $31, %0" : "=r" (temp));
1091
1092 /* call original code */
1093 printf_lock("CallbackFixup %x %x, t7=%x\n", a0, a1, temp);
1094
1095 /* restore the current pointer */
1096 asm("bis %0, $31, $8" : : "r" (temp) : "$8");
1097
1098 return 0;
1099}
1100
1101void
1102SlaveCmd(int cpu, struct rpb_percpu *my_rpb)
1103{
1104 extern ulong palJToSlave[];
1105
1106 printf_lock("Slave CPU %d console command %s", cpu,
1107 my_rpb->rpb_iccb.iccb_rxbuf);
1108
1109 my_rpb->rpb_state |= STATE_BIP;
1110 my_rpb->rpb_state &= ~STATE_RC;
1111
1112 printf_lock("SlaveCmd: restart %x %x vptb %x my_rpb %x my_rpb_phys %x\n",
1113 rpb->rpb_restart, rpb->rpb_restart_pv, rpb->rpb_vptb, my_rpb,
1114 KSEG_TO_PHYS(my_rpb));
1115
1116 cServe(KSEG_TO_PHYS(palJToSlave), (ulong)rpb->rpb_restart,
1117 CSERVE_K_JTOPAL, rpb->rpb_restart_pv, rpb->rpb_vptb,
1118 KSEG_TO_PHYS(my_rpb));
1119
1120 panic("SlaveCmd returned \n");
1121}
1122
1123void
1124SlaveLoop(int cpu)
1125{
1126 int size = ROUNDUP128(sizeof(struct rpb_percpu));
1127 struct rpb_percpu *my_rpb = (struct rpb_percpu*)
1128 ((ulong)rpb_percpu + size * cpu);
1129
1130 if (cpu == 0) {
1131 panic("CPU�0 entering slaveLoop. Reenetering the console. HOSED\n");
1132 } else {
1133 printf_lock("Entering slaveloop for cpu %d my_rpb=%x\n", cpu, my_rpb);
1134 }
1135
1136 // swap the processors context to the one in the
1137 // rpb_percpu struct very carefully (i.e. no stack usage)
1138 // so that linux knows which processor ends up in __smp_callin
1139 // and we don't trash any data is the process
1140 SlaveSpin(cpu, my_rpb, &my_rpb->rpb_iccb.iccb_rxlen);
1141}