machdep.c revision 1.6 1 /* $NetBSD: machdep.c,v 1.6 1995/05/31 20:45:14 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1994, 1995 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 */
29
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/signalvar.h>
33 #include <sys/kernel.h>
34 #include <sys/map.h>
35 #include <sys/proc.h>
36 #include <sys/buf.h>
37 #include <sys/reboot.h>
38 #include <sys/conf.h>
39 #include <sys/file.h>
40 #ifdef REAL_CLISTS
41 #include <sys/clist.h>
42 #endif
43 #include <sys/callout.h>
44 #include <sys/malloc.h>
45 #include <sys/mbuf.h>
46 #include <sys/msgbuf.h>
47 #include <sys/ioctl.h>
48 #include <sys/tty.h>
49 #include <sys/user.h>
50 #include <sys/exec.h>
51 #include <sys/exec_ecoff.h>
52 #include <sys/sysctl.h>
53 #ifdef SYSVMSG
54 #include <sys/msg.h>
55 #endif
56 #ifdef SYSVSEM
57 #include <sys/sem.h>
58 #endif
59 #ifdef SYSVSHM
60 #include <sys/shm.h>
61 #endif
62
63 #include <sys/mount.h>
64 #include <sys/syscallargs.h>
65
66 #include <vm/vm_kern.h>
67
68 #include <dev/cons.h>
69
70 #include <machine/cpu.h>
71 #include <machine/reg.h>
72 #include <machine/rpb.h>
73 #include <machine/prom.h>
74
75 #include <net/netisr.h>
76 #include "ether.h"
77
78 #include "le.h" /* XXX for le_iomem creation */
79 #include "esp.h" /* XXX for esp_iomem creation */
80
81 vm_map_t buffer_map;
82
83 /*
84 * Declare these as initialized data so we can patch them.
85 */
86 int nswbuf = 0;
87 #ifdef NBUF
88 int nbuf = NBUF;
89 #else
90 int nbuf = 0;
91 #endif
92 #ifdef BUFPAGES
93 int bufpages = BUFPAGES;
94 #else
95 int bufpages = 0;
96 #endif
97 int msgbufmapped = 0; /* set when safe to use msgbuf */
98 int maxmem; /* max memory per process */
99 int physmem; /* amount of physical memory in system */
100 int resvmem; /* amount of memory reserved for PROM */
101
102 int cputype; /* system type, from the RPB */
103
104 /*
105 * XXX We need an address to which we can assign things so that they
106 * won't be optimized away because we didn't use the value.
107 */
108 u_int32_t no_optimize;
109
110 /* the following is used externally (sysctl_hw) */
111 char machine[] = "alpha";
112 char *cpu_model;
113 char *model_names[] = {
114 "UNKNOWN (0)",
115 "Alpha Demonstration Unit",
116 "DEC 4000 (\"Cobra\")",
117 "DEC 7000 (\"Ruby\")",
118 "DEC 3000/500 (\"Flamingo\") family",
119 "UNKNOWN (5)",
120 "DEC 2000/300 (\"Jensen\")",
121 "DEC 3000/300 (\"Pelican\")",
122 "UNKNOWN (8)",
123 "DEC 2100/A500 (\"Sable\")",
124 "AXPvme 64",
125 "AXPpci 33 (\"NoName\")",
126 "UNKNOWN (12)",
127 "DEC 2100/A50 (\"Avanti\")",
128 "Mustang",
129 "DEC 1000 (\"Mikasa\")",
130 };
131 int nmodel_names = sizeof model_names/sizeof model_names[0];
132
133 struct user *proc0paddr;
134
135 /* Number of machine cycles per microsecond */
136 u_int64_t cycles_per_usec;
137
138 /* some memory areas for device DMA. "ick." */
139 caddr_t le_iomem; /* XXX iomem for LANCE DMA */
140 caddr_t esp_iomem; /* XXX iomem for SCSI DMA */
141
142 /* Interrupt vectors (in locore) */
143 extern int XentInt(), XentArith(), XentMM(), XentIF(), XentUna(), XentSys();
144
145 int
146 alpha_init(pfn, ptb, argc, argv, envp)
147 u_long pfn; /* first free PFN number */
148 u_long ptb; /* PFN of current level 1 page table */
149 u_long argc;
150 char *argv[], *envp[];
151 {
152 extern char _end[];
153 caddr_t start, v;
154 struct mddt *mddtp;
155 int i;
156 char *p;
157
158 /*
159 * Turn off interrupts and floating point.
160 * Make sure the instruction and data streams are consistent.
161 */
162 (void)splhigh();
163 pal_wrfen(0);
164 TBIA();
165 IMB();
166
167 /*
168 * get address of the restart block, while we the bootstrap
169 * mapping is still around.
170 */
171 hwrpb = (struct rpb *) phystok0seg(*(struct rpb **)HWRPB_ADDR);
172
173 /*
174 * Remember how many cycles there are per microsecond,
175 * so that we can use delay()
176 */
177 cycles_per_usec = hwrpb->rpb_cc_freq / 1000000;
178
179 /*
180 * Init the PROM interface, so we can use printf
181 * until PROM mappings go away in consinit.
182 */
183 init_prom_interface();
184
185 /*
186 * Point interrupt/exception vectors to our own.
187 */
188 pal_wrent(XentInt, 0);
189 pal_wrent(XentArith, 1);
190 pal_wrent(XentMM, 2);
191 pal_wrent(XentIF, 3);
192 pal_wrent(XentUna, 4);
193 pal_wrent(XentSys, 5);
194
195 /*
196 * Find out how much memory is available, by looking at
197 * the memory cluster descriptors.
198 * XXX Assumes that the first "system" cluster is the
199 * only one we can use. Can there be more than two clusters?
200 * Is the second (etc.) system cluster guaranteed to be
201 * discontiguous?
202 */
203 mddtp = (struct mddt *)(((caddr_t)hwrpb) + hwrpb->rpb_memdat_off);
204 physmem = 0;
205 if (mddtp->mddt_cluster_cnt != 2) {
206 printf("warning: strange number of memory clusters (%d).\n",
207 mddtp->mddt_cluster_cnt);
208 printf("memory cluster information:\n");
209 for (i = 0; i < mddtp->mddt_cluster_cnt; i++) {
210 printf("mddt %d:\n", i);
211 printf("\tpfn %lx\n",
212 mddtp->mddt_clusters[i].mddt_pfn);
213 printf("\tcnt %lx\n",
214 mddtp->mddt_clusters[i].mddt_pg_cnt);
215 printf("\ttest %lx\n",
216 mddtp->mddt_clusters[i].mddt_pg_test);
217 printf("\tbva %lx\n",
218 mddtp->mddt_clusters[i].mddt_v_bitaddr);
219 printf("\tbpa %lx\n",
220 mddtp->mddt_clusters[i].mddt_p_bitaddr);
221 printf("\tbcksum %lx\n",
222 mddtp->mddt_clusters[i].mddt_bit_cksum);
223 printf("\tusage %lx\n",
224 mddtp->mddt_clusters[i].mddt_usage);
225 }
226 }
227
228 physmem = 0;
229 for (i = 0; i < mddtp->mddt_cluster_cnt; i++) {
230 /* add up physmem, stopping on first OS-available space. */
231 physmem += mddtp->mddt_clusters[i].mddt_pg_cnt;
232 if ((mddtp->mddt_clusters[i].mddt_usage & 0x01) == 0)
233 break;
234 else
235 resvmem += mddtp->mddt_clusters[i].mddt_pg_cnt;
236 }
237 if (physmem == 0)
238 panic("can't happen: system seems to have no memory!");
239 maxmem = physmem;
240
241 /*
242 * find out this CPU's page size
243 */
244 PAGE_SIZE = hwrpb->rpb_page_size;
245
246 v = (caddr_t)alpha_round_page(_end);
247 /*
248 * Init mapping for u page(s) for proc 0
249 */
250 start = v;
251 curproc->p_addr = proc0paddr = (struct user *)v;
252 v += UPAGES * NBPG;
253
254 /*
255 * Find out what hardware we're on, and remember its type name.
256 * XXX and start dealing with config?
257 */
258 cputype = hwrpb->rpb_type;
259 switch (cputype) {
260 #ifdef ADU
261 case ST_ADU:
262 THIS SYSTEM NOT SUPPORTED
263 #endif
264
265 #ifdef DEC_4000
266 case ST_DEC_4000:
267 THIS SYSTEM NOT SUPPORTED
268 #endif
269
270 #ifdef DEC_7000
271 case ST_DEC_7000:
272 THIS SYSTEM NOT SUPPORTED
273 #endif
274
275 #ifdef DEC_3000_500 /* and 400, [6-9]00 */
276 case ST_DEC_3000_500:
277 switch (hwrpb->rpb_variation & SV_ST_MASK) {
278 case SV_ST_SANDPIPER:
279 systype_sandpiper:
280 cpu_model = "DEC 3000/400 (\"Sandpiper\")";
281 break;
282
283 case SV_ST_FLAMINGO:
284 systype_flamingo:
285 cpu_model = "DEC 3000/500 (\"Flamingo\")";
286 break;
287
288 case SV_ST_HOTPINK:
289 cpu_model = "DEC 3000/500X (\"Hot Pink\")";
290 break;
291
292 case SV_ST_FLAMINGOPLUS:
293 case SV_ST_ULTRA:
294 cpu_model = "DEC 3000/800 (\"Flamingo+\")";
295 break;
296
297 case SV_ST_SANDPLUS:
298 cpu_model = "DEC 3000/600 (\"Sandpiper+\")";
299 break;
300
301 case SV_ST_SANDPIPER45:
302 cpu_model = "DEC 3000/700 (\"Sandpiper45\")";
303 break;
304
305 case SV_ST_FLAMINGO45:
306 cpu_model = "DEC 3000/900 (\"Flamingo45\")";
307 break;
308
309 case SV_ST_RESERVED: /* this is how things used to be done */
310 if (hwrpb->rpb_variation & SV_GRAPHICS)
311 goto systype_flamingo;
312 else
313 goto systype_sandpiper;
314 /* NOTREACHED */
315
316 default:
317 printf("unknown system variation %lx\n",
318 hwrpb->rpb_variation & SV_ST_MASK);
319 }
320 break;
321 #endif
322
323 #ifdef DEC_2000_300
324 case ST_DEC_2000_300:
325 /* XXX XXX XXX */
326 break;
327 #endif
328
329 #ifdef DEC_3000_300
330 case ST_DEC_3000_300:
331 switch (hwrpb->rpb_variation & SV_ST_MASK) {
332 case SV_ST_PELICAN:
333 cpu_model = "DEC 3000/300 (\"Pelican\")";
334 break;
335
336 case SV_ST_PELICA:
337 cpu_model = "DEC 3000/300L (\"Pelica\")";
338 break;
339
340 case SV_ST_PELICANPLUS:
341 cpu_model = "DEC 3000/300X (\"Pelican+\")";
342 break;
343
344 case SV_ST_PELICAPLUS:
345 cpu_model = "DEC 3000/300LX (\"Pelica+\")";
346 break;
347
348 default:
349 printf("unknown system variation %lx\n",
350 hwrpb->rpb_variation & SV_ST_MASK);
351 }
352 break;
353 #endif
354
355 #ifdef DEC_2100_A500
356 case ST_DEC_2100_A500:
357 THIS SYSTEM NOT SUPPORTED
358 #endif
359
360 #ifdef DEC_AXPVME_64
361 case ST_DEC_AXPVME_64:
362 THIS SYSTEM NOT SUPPORTED
363 #endif
364
365 #ifdef DEC_AXPPCI_33
366 case ST_DEC_AXPPCI_33:
367 THIS SYSTEM NOT SUPPORTED
368 #endif
369
370 #ifdef DEC_2100_A50
371 case ST_DEC_2100_A50:
372 /* XXX */
373 printf("unknown system variation %lx\n",
374 hwrpb->rpb_variation & SV_ST_MASK);
375 break;
376 #endif
377
378 #ifdef DEC_MUSTANG
379 case ST_DEC_MUSTANG:
380 THIS SYSTEM NOT SUPPORTED
381 #endif
382
383 #ifdef DEC_1000
384 case ST_DEC_1000:
385 THIS SYSTEM NOT SUPPORTED
386 #endif
387
388 default:
389 if (cputype > nmodel_names)
390 panic("Unknown system type %d", cputype);
391 else
392 panic("Support for %s system type not in kernel.",
393 model_names[cputype]);
394 }
395 if (cpu_model == NULL)
396 cpu_model = model_names[cputype];
397
398 #if NLE > 0
399 /*
400 * Grab 128K at the top of physical memory for the lance chip
401 * on machines where it does dma through the I/O ASIC.
402 * It must be physically contiguous and aligned on a 128K boundary.
403 */
404 if (cputype == ST_DEC_3000_500 ||
405 cputype == ST_DEC_3000_300) { /* XXX possibly others? */
406 maxmem -= btoc(128 * 1024);
407 le_iomem = (caddr_t)phystok0seg(maxmem << PGSHIFT);
408 }
409 #endif /* NLE */
410 #if NESP > 0
411 /*
412 * Ditto for the scsi chip. There is probably a way to make esp.c
413 * do dma without these buffers, but it would require major
414 * re-engineering of the esp driver.
415 * They must be 8K in size and page aligned.
416 */
417 if (cputype == ST_DEC_3000_500 ||
418 cputype == ST_DEC_3000_300) { /* XXX possibly others? */
419 maxmem -= btoc(NESP * 8192);
420 esp_iomem = (caddr_t)phystok0seg(maxmem << PGSHIFT);
421 }
422 #endif /* NESP */
423
424 /*
425 * Initialize error message buffer (at end of core).
426 */
427 maxmem -= btoc(sizeof (struct msgbuf));
428 msgbufp = (struct msgbuf *)phystok0seg(maxmem << PGSHIFT);
429 msgbufmapped = 1;
430
431 /*
432 * Allocate space for system data structures.
433 * The first available kernel virtual address is in "v".
434 * As pages of kernel virtual memory are allocated, "v" is incremented.
435 *
436 * These data structures are allocated here instead of cpu_startup()
437 * because physical memory is directly addressable. We don't have
438 * to map these into virtual address space.
439 */
440 #define valloc(name, type, num) \
441 (name) = (type *)v; v = (caddr_t)((name)+(num))
442 #define valloclim(name, type, num, lim) \
443 (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
444 #ifdef REAL_CLISTS
445 valloc(cfree, struct cblock, nclist);
446 #endif
447 valloc(callout, struct callout, ncallout);
448 valloc(swapmap, struct map, nswapmap = maxproc * 2);
449 #ifdef SYSVSHM
450 valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
451 #endif
452 #ifdef SYSVSEM
453 valloc(sema, struct semid_ds, seminfo.semmni);
454 valloc(sem, struct sem, seminfo.semmns);
455 /* This is pretty disgusting! */
456 valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
457 #endif
458 #ifdef SYSVMSG
459 valloc(msgpool, char, msginfo.msgmax);
460 valloc(msgmaps, struct msgmap, msginfo.msgseg);
461 valloc(msghdrs, struct msg, msginfo.msgtql);
462 valloc(msqids, struct msqid_ds, msginfo.msgmni);
463 #endif
464
465 /*
466 * Determine how many buffers to allocate.
467 * We allocate the BSD standard of 10% of memory for the first
468 * 2 Meg, and 5% of remaining memory for buffer space. Insure a
469 * minimum of 16 buffers. We allocate 1/2 as many swap buffer
470 * headers as file i/o buffers.
471 */
472 if (bufpages == 0)
473 bufpages = (btoc(2 * 1024 * 1024) + (physmem - resvmem)) /
474 (20 * CLSIZE);
475 if (nbuf == 0) {
476 nbuf = bufpages;
477 if (nbuf < 16)
478 nbuf = 16;
479 }
480 if (nswbuf == 0) {
481 nswbuf = (nbuf / 2) &~ 1; /* force even */
482 if (nswbuf > 256)
483 nswbuf = 256; /* sanity */
484 }
485 valloc(swbuf, struct buf, nswbuf);
486 valloc(buf, struct buf, nbuf);
487
488 /*
489 * Clear allocated memory.
490 */
491 bzero(start, v - start);
492
493 /*
494 * Initialize the virtual memory system, and set the
495 * page table base register in proc 0's PCB.
496 */
497 pmap_bootstrap((vm_offset_t)v, phystok0seg(ptb << PGSHIFT));
498
499 /*
500 * Initialize the rest of proc 0's PCB, and cache its physical
501 * address.
502 */
503 proc0.p_md.md_pcbpaddr =
504 (struct pcb *)k0segtophys(&proc0paddr->u_pcb);
505
506 /*
507 * Set the kernel sp, reserving space for an (empty) trapframe,
508 * and make proc0's trapframe pointer point to it for sanity.
509 */
510 proc0paddr->u_pcb.pcb_ksp =
511 (u_int64_t)proc0paddr + USPACE - sizeof(struct trapframe);
512 proc0.p_md.md_tf = (struct trapframe *)proc0paddr->u_pcb.pcb_ksp;
513
514 /*
515 * Look at arguments and compute bootdev.
516 *
517 * XXX
518 * Boot currently doesn't pass any arguments concerning booting
519 * or the root device.
520 */
521 { extern dev_t bootdev;
522 bootdev = MAKEBOOTDEV(8, 0, 0, 0, 0); /* sd0a. XXX */
523 }
524
525 /*
526 * Look at arguments passed to us and compute boothowto.
527 */
528 #ifdef GENERIC
529 boothowto = RB_SINGLE | RB_ASKNAME;
530 #else
531 boothowto = RB_SINGLE;
532 #endif
533 #ifdef KADB
534 boothowto |= RB_KDB;
535 #endif
536
537 printf("argc = %d\n", argc);
538 printf("argv = %lx\n", argv);
539 for (i = 0; i < argc; i++)
540 printf("argv[%d] = (%lx) \"%s\"\n", i, argv[i], argv[i]);
541
542 if (argc > 1) {
543 /* we have arguments. argv[1] is the flags. */
544 for (p = argv[1]; *p != '\0'; p++) {
545 switch (*p) {
546 case 'a': /* autoboot */
547 case 'A': /* DEC's notion of autoboot */
548 boothowto &= ~RB_SINGLE;
549 break;
550
551 case 'd': /* use compiled in default root */
552 boothowto |= RB_DFLTROOT;
553 break;
554
555 case 'm': /* mini root present in memory */
556 boothowto |= RB_MINIROOT;
557 break;
558
559 case 'n': /* ask for names */
560 boothowto |= RB_ASKNAME;
561 break;
562
563 case 'N': /* don't ask for names */
564 boothowto &= ~RB_ASKNAME;
565 }
566 }
567 }
568
569 return (0);
570 }
571
572 /* for cons.c */
573 struct consdev constab[] = {
574 { 0 },
575 };
576
577 consinit()
578 {
579 /* XXX SET UP THE CONSOLE TAB TO HAVE REASONABLE ENTRIES */
580 /* XXX */
581
582 /* XXX PICK A NEW CONSOLE DEVICE */
583 /* cninit(); */
584
585 pmap_unmap_prom();
586 }
587
588 cpu_startup()
589 {
590 register unsigned i;
591 register caddr_t v;
592 int base, residual;
593 vm_offset_t minaddr, maxaddr;
594 vm_size_t size;
595 #ifdef DEBUG
596 extern int pmapdebug;
597 int opmapdebug = pmapdebug;
598
599 pmapdebug = 0;
600 #endif
601
602 /*
603 * Good {morning,afternoon,evening,night}.
604 */
605 printf(version);
606 identifycpu();
607 printf("real mem = %d (%d reserved for PROM)\n", ctob(physmem),
608 ctob(resvmem));
609
610 /*
611 * Allocate virtual address space for file I/O buffers.
612 * Note they are different than the array of headers, 'buf',
613 * and usually occupy more virtual memory than physical.
614 */
615 size = MAXBSIZE * nbuf;
616 buffer_map = kmem_suballoc(kernel_map, (vm_offset_t *)&buffers,
617 &maxaddr, size, TRUE);
618 minaddr = (vm_offset_t)buffers;
619 if (vm_map_find(buffer_map, vm_object_allocate(size), (vm_offset_t)0,
620 &minaddr, size, FALSE) != KERN_SUCCESS)
621 panic("startup: cannot allocate buffers");
622 base = bufpages / nbuf;
623 residual = bufpages % nbuf;
624 for (i = 0; i < nbuf; i++) {
625 vm_size_t curbufsize;
626 vm_offset_t curbuf;
627
628 /*
629 * First <residual> buffers get (base+1) physical pages
630 * allocated for them. The rest get (base) physical pages.
631 *
632 * The rest of each buffer occupies virtual space,
633 * but has no physical memory allocated for it.
634 */
635 curbuf = (vm_offset_t)buffers + i * MAXBSIZE;
636 curbufsize = CLBYTES * (i < residual ? base+1 : base);
637 vm_map_pageable(buffer_map, curbuf, curbuf+curbufsize, FALSE);
638 vm_map_simplify(buffer_map, curbuf);
639 }
640 /*
641 * Allocate a submap for exec arguments. This map effectively
642 * limits the number of processes exec'ing at any time.
643 */
644 exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
645 16 * NCARGS, TRUE);
646
647 /*
648 * Allocate a submap for physio
649 */
650 phys_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
651 VM_PHYS_SIZE, TRUE);
652
653 /*
654 * Finally, allocate mbuf pool. Since mclrefcnt is an off-size
655 * we use the more space efficient malloc in place of kmem_alloc.
656 */
657 mclrefcnt = (char *)malloc(NMBCLUSTERS+CLBYTES/MCLBYTES,
658 M_MBUF, M_NOWAIT);
659 bzero(mclrefcnt, NMBCLUSTERS+CLBYTES/MCLBYTES);
660 mb_map = kmem_suballoc(kernel_map, (vm_offset_t *)&mbutl, &maxaddr,
661 VM_MBUF_SIZE, FALSE);
662 /*
663 * Initialize callouts
664 */
665 callfree = callout;
666 for (i = 1; i < ncallout; i++)
667 callout[i-1].c_next = &callout[i];
668 callout[i-1].c_next = NULL;
669
670 #ifdef DEBUG
671 pmapdebug = opmapdebug;
672 #endif
673 printf("avail mem = %ld\n", (long)ptoa(cnt.v_free_count));
674 printf("using %ld buffers containing %ld bytes of memory\n",
675 (long)nbuf, (long)(bufpages * CLBYTES));
676
677 /*
678 * Set up buffers, so they can be used to read disk labels.
679 */
680 bufinit();
681
682 /*
683 * Configure the system.
684 */
685 configure();
686 }
687
688 identifycpu()
689 {
690
691 /* most of the work here is taken care of in alpha_init(). */
692 printf("%s, serial number 0x%lx 0x%lx\n", cpu_model,
693 ((long *)hwrpb->rpb_ssn)[0], ((long *)hwrpb->rpb_ssn)[1]);
694 printf("variation: 0x%lx, revision 0x%lx\n",
695 hwrpb->rpb_variation, *(long *)hwrpb->rpb_revision);
696 printf("%d byte page size, %d processor%s.\n", hwrpb->rpb_page_size,
697 hwrpb->rpb_pcs_cnt, hwrpb->rpb_pcs_cnt == 1 ? "" : "s");
698 }
699
700 int waittime = -1;
701
702 boot(howto)
703 int howto;
704 {
705 extern int cold;
706
707 /* Take a snapshot before clobbering any registers. */
708 if (curproc)
709 savectx(curproc->p_addr, 0);
710
711 #ifdef HALTLOOP
712 while (1)
713 ;
714 #endif
715
716 /* If system is cold, just halt. */
717 if (cold) {
718 howto |= RB_HALT;
719 goto haltsys;
720 }
721
722 /* Sync the disks, if appropriate */
723 if ((howto & RB_NOSYNC) == 0 && waittime < 0 && 0 /* XXX */) {
724 register struct buf *bp;
725 int iter, nbusy;
726
727 waittime = 0;
728 (void) spl0();
729 printf("syncing disks... ");
730 #ifdef notdef /* XXX */
731 /*
732 * Release vnodes held by texts before sync.
733 */
734 if (panicstr == 0)
735 vnode_pager_umount(NULL);
736
737 sync(&proc0, (void *)NULL, (int *)NULL);
738
739 for (iter = 0; iter < 20; iter++) {
740 nbusy = 0;
741 for (bp = &buf[nbuf]; --bp >= buf; )
742 if ((bp->b_flags & (B_BUSY|B_INVAL)) == B_BUSY)
743 nbusy++;
744 if (nbusy == 0)
745 break;
746 printf("%d ", nbusy);
747 DELAY(40000 * iter);
748 }
749 if (nbusy)
750 printf("giving up\n");
751 else
752 #endif
753 printf("done\n");
754 #ifdef notdef /* XXX */
755 /*
756 * If we've been adjusting the clock, the todr
757 * will be out of synch; adjust it now.
758 */
759 resettodr();
760 #endif
761 }
762
763 /* Disable interrupts. */
764 splhigh();
765
766 #ifdef notdef /* XXX */
767 /* If rebooting and a dump is requested do the dump. */
768 if ((howto & (RB_DUMP|RB_HALT)) == RB_DUMP)
769 dumpsys();
770 #endif
771
772 /* run any shutdown hooks */
773 doshutdownhooks();
774
775 haltsys:
776 /* Finally, halt/reboot the system. */
777 printf("%s\n\n", howto & RB_HALT ? "halted." : "rebooting...");
778 prom_halt(howto & RB_HALT);
779 /*NOTREACHED*/
780 }
781
782 void
783 frametoreg(framep, regp)
784 struct trapframe *framep;
785 struct reg *regp;
786 {
787
788 regp->r_regs[R_V0] = framep->tf_regs[FRAME_V0];
789 regp->r_regs[R_T0] = framep->tf_regs[FRAME_T0];
790 regp->r_regs[R_T1] = framep->tf_regs[FRAME_T1];
791 regp->r_regs[R_T2] = framep->tf_regs[FRAME_T2];
792 regp->r_regs[R_T3] = framep->tf_regs[FRAME_T3];
793 regp->r_regs[R_T4] = framep->tf_regs[FRAME_T4];
794 regp->r_regs[R_T5] = framep->tf_regs[FRAME_T5];
795 regp->r_regs[R_T6] = framep->tf_regs[FRAME_T6];
796 regp->r_regs[R_T7] = framep->tf_regs[FRAME_T7];
797 regp->r_regs[R_S0] = framep->tf_regs[FRAME_S0];
798 regp->r_regs[R_S1] = framep->tf_regs[FRAME_S1];
799 regp->r_regs[R_S2] = framep->tf_regs[FRAME_S2];
800 regp->r_regs[R_S3] = framep->tf_regs[FRAME_S3];
801 regp->r_regs[R_S4] = framep->tf_regs[FRAME_S4];
802 regp->r_regs[R_S5] = framep->tf_regs[FRAME_S5];
803 regp->r_regs[R_S6] = framep->tf_regs[FRAME_S6];
804 regp->r_regs[R_A0] = framep->tf_a0;
805 regp->r_regs[R_A1] = framep->tf_a1;
806 regp->r_regs[R_A2] = framep->tf_a2;
807 regp->r_regs[R_A3] = framep->tf_regs[FRAME_A3];
808 regp->r_regs[R_A4] = framep->tf_regs[FRAME_A4];
809 regp->r_regs[R_A5] = framep->tf_regs[FRAME_A5];
810 regp->r_regs[R_T8] = framep->tf_regs[FRAME_T8];
811 regp->r_regs[R_T9] = framep->tf_regs[FRAME_T9];
812 regp->r_regs[R_T10] = framep->tf_regs[FRAME_T10];
813 regp->r_regs[R_T11] = framep->tf_regs[FRAME_T11];
814 regp->r_regs[R_RA] = framep->tf_regs[FRAME_RA];
815 regp->r_regs[R_T12] = framep->tf_regs[FRAME_T12];
816 regp->r_regs[R_AT] = framep->tf_regs[FRAME_AT];
817 regp->r_regs[R_GP] = framep->tf_gp;
818 regp->r_regs[R_SP] = framep->tf_regs[FRAME_SP];
819 regp->r_regs[R_ZERO] = 0;
820 }
821
822 void
823 regtoframe(regp, framep)
824 struct reg *regp;
825 struct trapframe *framep;
826 {
827
828 framep->tf_regs[FRAME_V0] = regp->r_regs[R_V0];
829 framep->tf_regs[FRAME_T0] = regp->r_regs[R_T0];
830 framep->tf_regs[FRAME_T1] = regp->r_regs[R_T1];
831 framep->tf_regs[FRAME_T2] = regp->r_regs[R_T2];
832 framep->tf_regs[FRAME_T3] = regp->r_regs[R_T3];
833 framep->tf_regs[FRAME_T4] = regp->r_regs[R_T4];
834 framep->tf_regs[FRAME_T5] = regp->r_regs[R_T5];
835 framep->tf_regs[FRAME_T6] = regp->r_regs[R_T6];
836 framep->tf_regs[FRAME_T7] = regp->r_regs[R_T7];
837 framep->tf_regs[FRAME_S0] = regp->r_regs[R_S0];
838 framep->tf_regs[FRAME_S1] = regp->r_regs[R_S1];
839 framep->tf_regs[FRAME_S2] = regp->r_regs[R_S2];
840 framep->tf_regs[FRAME_S3] = regp->r_regs[R_S3];
841 framep->tf_regs[FRAME_S4] = regp->r_regs[R_S4];
842 framep->tf_regs[FRAME_S5] = regp->r_regs[R_S5];
843 framep->tf_regs[FRAME_S6] = regp->r_regs[R_S6];
844 framep->tf_a0 = regp->r_regs[R_A0];
845 framep->tf_a1 = regp->r_regs[R_A1];
846 framep->tf_a2 = regp->r_regs[R_A2];
847 framep->tf_regs[FRAME_A3] = regp->r_regs[R_A3];
848 framep->tf_regs[FRAME_A4] = regp->r_regs[R_A4];
849 framep->tf_regs[FRAME_A5] = regp->r_regs[R_A5];
850 framep->tf_regs[FRAME_T8] = regp->r_regs[R_T8];
851 framep->tf_regs[FRAME_T9] = regp->r_regs[R_T9];
852 framep->tf_regs[FRAME_T10] = regp->r_regs[R_T10];
853 framep->tf_regs[FRAME_T11] = regp->r_regs[R_T11];
854 framep->tf_regs[FRAME_RA] = regp->r_regs[R_RA];
855 framep->tf_regs[FRAME_T12] = regp->r_regs[R_T12];
856 framep->tf_regs[FRAME_AT] = regp->r_regs[R_AT];
857 framep->tf_gp = regp->r_regs[R_GP];
858 framep->tf_regs[FRAME_SP] = regp->r_regs[R_SP];
859 /* ??? = regp->r_regs[R_ZERO]; */
860 }
861
862 void
863 printregs(regp)
864 struct reg *regp;
865 {
866 int i;
867
868 for (i = 0; i < 32; i++)
869 printf("R%d:\t0x%016lx%s", i, regp->r_regs[i],
870 i & 1 ? "\n" : "\t");
871 }
872
873 void
874 regdump(framep)
875 struct trapframe *framep;
876 {
877 struct reg reg;
878
879 frametoreg(framep, ®);
880 printf("REGISTERS:\n");
881 printregs(®);
882 }
883
884 #ifdef DEBUG
885 int sigdebug = 0;
886 int sigpid = 0;
887 #define SDB_FOLLOW 0x01
888 #define SDB_KSTACK 0x02
889 #endif
890
891 /*
892 * Send an interrupt to process.
893 */
894 void
895 sendsig(catcher, sig, mask, code)
896 sig_t catcher;
897 int sig, mask;
898 u_long code;
899 {
900 struct proc *p = curproc;
901 struct sigcontext *scp, ksc;
902 struct trapframe *frame;
903 struct sigacts *psp = p->p_sigacts;
904 int oonstack, fsize, rndfsize;
905 extern char sigcode[], esigcode[];
906 extern struct proc *fpcurproc;
907
908 frame = p->p_md.md_tf;
909 oonstack = psp->ps_sigstk.ss_flags & SA_ONSTACK;
910 fsize = sizeof ksc;
911 rndfsize = ((fsize + 15) / 16) * 16;
912 /*
913 * Allocate and validate space for the signal handler
914 * context. Note that if the stack is in P0 space, the
915 * call to grow() is a nop, and the useracc() check
916 * will fail if the process has not already allocated
917 * the space with a `brk'.
918 */
919 if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack &&
920 (psp->ps_sigonstack & sigmask(sig))) {
921 scp = (struct sigcontext *)(psp->ps_sigstk.ss_base +
922 psp->ps_sigstk.ss_size - rndfsize);
923 psp->ps_sigstk.ss_flags |= SA_ONSTACK;
924 } else
925 scp = (struct sigcontext *)(frame->tf_regs[FRAME_SP] -
926 rndfsize);
927 if ((u_long)scp <= USRSTACK - ctob(p->p_vmspace->vm_ssize))
928 (void)grow(p, (u_long)scp);
929 #ifdef DEBUG
930 if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
931 printf("sendsig(%d): sig %d ssp %lx usp %lx\n", p->p_pid,
932 sig, &oonstack, scp);
933 #endif
934 if (useracc((caddr_t)scp, fsize, B_WRITE) == 0) {
935 #ifdef DEBUG
936 if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
937 printf("sendsig(%d): useracc failed on sig %d\n",
938 p->p_pid, sig);
939 #endif
940 /*
941 * Process has trashed its stack; give it an illegal
942 * instruction to halt it in its tracks.
943 */
944 SIGACTION(p, SIGILL) = SIG_DFL;
945 sig = sigmask(SIGILL);
946 p->p_sigignore &= ~sig;
947 p->p_sigcatch &= ~sig;
948 p->p_sigmask &= ~sig;
949 psignal(p, SIGILL);
950 return;
951 }
952
953 /*
954 * Build the signal context to be used by sigreturn.
955 */
956 ksc.sc_onstack = oonstack;
957 ksc.sc_mask = mask;
958 ksc.sc_pc = frame->tf_pc;
959 ksc.sc_ps = frame->tf_ps;
960
961 /* copy the registers. */
962 frametoreg(frame, (struct reg *)ksc.sc_regs);
963 ksc.sc_regs[R_ZERO] = 0xACEDBADE; /* magic number */
964
965 /* save the floating-point state, if necessary, then copy it. */
966 if (p == fpcurproc) {
967 pal_wrfen(1);
968 savefpstate(&p->p_addr->u_pcb.pcb_fp);
969 pal_wrfen(0);
970 fpcurproc = NULL;
971 }
972 ksc.sc_ownedfp = p->p_md.md_flags & MDP_FPUSED;
973 bcopy(&p->p_addr->u_pcb.pcb_fp, (struct fpreg *)ksc.sc_fpregs,
974 sizeof(struct fpreg));
975 ksc.sc_fp_control = 0; /* XXX ? */
976 bzero(ksc.sc_reserved, sizeof ksc.sc_reserved); /* XXX */
977 bzero(ksc.sc_xxx, sizeof ksc.sc_xxx); /* XXX */
978
979
980 #ifdef COMPAT_OSF1
981 /*
982 * XXX Create an OSF/1-style sigcontext and associated goo.
983 */
984 #endif
985
986 /*
987 * copy the frame out to userland.
988 */
989 (void) copyout((caddr_t)&ksc, (caddr_t)scp, fsize);
990 #ifdef DEBUG
991 if (sigdebug & SDB_FOLLOW)
992 printf("sendsig(%d): sig %d scp %lx code %lx\n", p->p_pid, sig,
993 scp, code);
994 #endif
995
996 /*
997 * Set up the registers to return to sigcode.
998 */
999 frame->tf_pc = (u_int64_t)PS_STRINGS - (esigcode - sigcode);
1000 frame->tf_regs[FRAME_SP] = (u_int64_t)scp;
1001 frame->tf_a0 = sig;
1002 frame->tf_a1 = code;
1003 frame->tf_a2 = (u_int64_t)scp;
1004 frame->tf_regs[FRAME_T12] = (u_int64_t)catcher; /* t12 is pv */
1005
1006 #ifdef DEBUG
1007 if (sigdebug & SDB_FOLLOW)
1008 printf("sendsig(%d): pc %lx, catcher %lx\n", p->p_pid,
1009 frame->tf_pc, frame->tf_regs[FRAME_A3]);
1010 if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
1011 printf("sendsig(%d): sig %d returns\n",
1012 p->p_pid, sig);
1013 #endif
1014 }
1015
1016 /*
1017 * System call to cleanup state after a signal
1018 * has been taken. Reset signal mask and
1019 * stack state from context left by sendsig (above).
1020 * Return to previous pc and psl as specified by
1021 * context left by sendsig. Check carefully to
1022 * make sure that the user has not modified the
1023 * psl to gain improper priviledges or to cause
1024 * a machine fault.
1025 */
1026 /* ARGSUSED */
1027 sigreturn(p, uap, retval)
1028 struct proc *p;
1029 struct sigreturn_args /* {
1030 syscallarg(struct sigcontext *) sigcntxp;
1031 } */ *uap;
1032 register_t *retval;
1033 {
1034 struct sigcontext *scp, ksc;
1035 extern struct proc *fpcurproc;
1036
1037 scp = SCARG(uap, sigcntxp);
1038 #ifdef DEBUG
1039 if (sigdebug & SDB_FOLLOW)
1040 printf("sigreturn: pid %d, scp %lx\n", p->p_pid, scp);
1041 #endif
1042
1043 if (ALIGN(scp) != (u_int64_t)scp)
1044 return (EINVAL);
1045
1046 /*
1047 * Test and fetch the context structure.
1048 * We grab it all at once for speed.
1049 */
1050 if (useracc((caddr_t)scp, sizeof (*scp), B_WRITE) == 0 ||
1051 copyin((caddr_t)scp, (caddr_t)&ksc, sizeof ksc))
1052 return (EINVAL);
1053
1054 if (ksc.sc_regs[R_ZERO] != 0xACEDBADE) /* magic number */
1055 return (EINVAL);
1056 /*
1057 * Restore the user-supplied information
1058 */
1059 if (ksc.sc_onstack)
1060 p->p_sigacts->ps_sigstk.ss_flags |= SA_ONSTACK;
1061 else
1062 p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK;
1063 p->p_sigmask = ksc.sc_mask &~ sigcantmask;
1064
1065 p->p_md.md_tf->tf_pc = ksc.sc_pc;
1066 p->p_md.md_tf->tf_ps = (ksc.sc_ps | PSL_USERSET) & ~PSL_USERCLR;
1067
1068 regtoframe((struct reg *)ksc.sc_regs, p->p_md.md_tf);
1069
1070 /* XXX ksc.sc_ownedfp ? */
1071 if (p == fpcurproc)
1072 fpcurproc = NULL;
1073 bcopy((struct fpreg *)ksc.sc_fpregs, &p->p_addr->u_pcb.pcb_fp,
1074 sizeof(struct fpreg));
1075 /* XXX ksc.sc_fp_control ? */
1076
1077 #ifdef DEBUG
1078 if (sigdebug & SDB_FOLLOW)
1079 printf("sigreturn(%d): returns\n", p->p_pid);
1080 #endif
1081 return (EJUSTRETURN);
1082 }
1083
1084 /*
1085 * machine dependent system variables.
1086 */
1087 cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
1088 int *name;
1089 u_int namelen;
1090 void *oldp;
1091 size_t *oldlenp;
1092 void *newp;
1093 size_t newlen;
1094 struct proc *p;
1095 {
1096 dev_t consdev;
1097
1098 /* all sysctl names at this level are terminal */
1099 if (namelen != 1)
1100 return (ENOTDIR); /* overloaded */
1101
1102 switch (name[0]) {
1103 case CPU_CONSDEV:
1104 if (cn_tab != NULL)
1105 consdev = cn_tab->cn_dev;
1106 else
1107 consdev = NODEV;
1108 return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
1109 sizeof consdev));
1110 default:
1111 return (EOPNOTSUPP);
1112 }
1113 /* NOTREACHED */
1114 }
1115
1116 /*
1117 * Set registers on exec.
1118 */
1119 void
1120 setregs(p, pack, stack, retval)
1121 register struct proc *p;
1122 struct exec_package *pack;
1123 u_long stack;
1124 register_t *retval;
1125 {
1126 struct trapframe *tfp = p->p_md.md_tf;
1127 int i;
1128 extern struct proc *fpcurproc;
1129
1130 #ifdef DEBUG
1131 for (i = 0; i < FRAME_NSAVEREGS; i++)
1132 tfp->tf_regs[i] = 0xbabefacedeadbeef;
1133 tfp->tf_gp = 0xbabefacedeadbeef;
1134 tfp->tf_a0 = 0xbabefacedeadbeef;
1135 tfp->tf_a1 = 0xbabefacedeadbeef;
1136 tfp->tf_a2 = 0xbabefacedeadbeef;
1137 #else
1138 bzero(tfp->tf_regs, FRAME_NSAVEREGS * sizeof tfp->tf_regs[0]);
1139 tfp->tf_gp = 0;
1140 tfp->tf_a0 = 0;
1141 tfp->tf_a1 = 0;
1142 tfp->tf_a2 = 0;
1143 #endif
1144 bzero(&p->p_addr->u_pcb.pcb_fp, sizeof p->p_addr->u_pcb.pcb_fp);
1145
1146 tfp->tf_regs[FRAME_SP] = stack; /* restored to usp in trap return */
1147 tfp->tf_ps = PSL_USERSET;
1148 tfp->tf_pc = pack->ep_entry & ~3;
1149
1150 p->p_md.md_flags & ~MDP_FPUSED;
1151 if (fpcurproc == p)
1152 fpcurproc = NULL;
1153
1154 retval[0] = retval[1] = 0;
1155 }
1156
1157 void
1158 netintr()
1159 {
1160 #ifdef INET
1161 #if NETHER > 0
1162 if (netisr & (1 << NETISR_ARP)) {
1163 netisr &= ~(1 << NETISR_ARP);
1164 arpintr();
1165 }
1166 #endif
1167 if (netisr & (1 << NETISR_IP)) {
1168 netisr &= ~(1 << NETISR_IP);
1169 ipintr();
1170 }
1171 #endif
1172 #ifdef NS
1173 if (netisr & (1 << NETISR_NS)) {
1174 netisr &= ~(1 << NETISR_NS);
1175 nsintr();
1176 }
1177 #endif
1178 #ifdef ISO
1179 if (netisr & (1 << NETISR_ISO)) {
1180 netisr &= ~(1 << NETISR_ISO);
1181 clnlintr();
1182 }
1183 #endif
1184 #ifdef CCITT
1185 if (netisr & (1 << NETISR_CCITT)) {
1186 netisr &= ~(1 << NETISR_CCITT);
1187 ccittintr();
1188 }
1189 #endif
1190 }
1191
1192 void
1193 do_sir()
1194 {
1195
1196 if (ssir & SIR_NET) {
1197 siroff(SIR_NET);
1198 cnt.v_soft++;
1199 netintr();
1200 }
1201 if (ssir & SIR_CLOCK) {
1202 siroff(SIR_CLOCK);
1203 cnt.v_soft++;
1204 softclock();
1205 }
1206 }
1207
1208 int
1209 spl0()
1210 {
1211
1212 if (ssir) {
1213 splsoft();
1214 do_sir();
1215 }
1216
1217 return (pal_swpipl(PSL_IPL_0));
1218 }
1219
1220 /*
1221 * The following primitives manipulate the run queues. _whichqs tells which
1222 * of the 32 queues _qs have processes in them. Setrunqueue puts processes
1223 * into queues, Remrq removes them from queues. The running process is on
1224 * no queue, other processes are on a queue related to p->p_priority, divided
1225 * by 4 actually to shrink the 0-127 range of priorities into the 32 available
1226 * queues.
1227 */
1228 /*
1229 * setrunqueue(p)
1230 * proc *p;
1231 *
1232 * Call should be made at splclock(), and p->p_stat should be SRUN.
1233 */
1234
1235 void
1236 setrunqueue(p)
1237 struct proc *p;
1238 {
1239 int bit;
1240
1241 /* firewall: p->p_back must be NULL */
1242 if (p->p_back != NULL)
1243 panic("setrunqueue");
1244
1245 bit = p->p_priority >> 2;
1246 whichqs |= (1 << bit);
1247 p->p_forw = (struct proc *)&qs[bit];
1248 p->p_back = qs[bit].ph_rlink;
1249 p->p_back->p_forw = p;
1250 qs[bit].ph_rlink = p;
1251 }
1252
1253 /*
1254 * Remrq(p)
1255 *
1256 * Call should be made at splclock().
1257 */
1258 void
1259 remrq(p)
1260 struct proc *p;
1261 {
1262 int bit;
1263
1264 bit = p->p_priority >> 2;
1265 if ((whichqs & (1 << bit)) == 0)
1266 panic("remrq");
1267
1268 p->p_back->p_forw = p->p_forw;
1269 p->p_forw->p_back = p->p_back;
1270 p->p_back = NULL; /* for firewall checking. */
1271
1272 if ((struct proc *)&qs[bit] == qs[bit].ph_link)
1273 whichqs &= ~(1 << bit);
1274 }
1275
1276 /*
1277 * Return the best possible estimate of the time in the timeval
1278 * to which tvp points. Unfortunately, we can't read the hardware registers.
1279 * We guarantee that the time will be greater than the value obtained by a
1280 * previous call.
1281 */
1282 void
1283 microtime(tvp)
1284 register struct timeval *tvp;
1285 {
1286 int s = splclock();
1287 static struct timeval lasttime;
1288
1289 *tvp = time;
1290 #ifdef notdef
1291 tvp->tv_usec += clkread();
1292 while (tvp->tv_usec > 1000000) {
1293 tvp->tv_sec++;
1294 tvp->tv_usec -= 1000000;
1295 }
1296 #endif
1297 if (tvp->tv_sec == lasttime.tv_sec &&
1298 tvp->tv_usec <= lasttime.tv_usec &&
1299 (tvp->tv_usec = lasttime.tv_usec + 1) > 1000000) {
1300 tvp->tv_sec++;
1301 tvp->tv_usec -= 1000000;
1302 }
1303 lasttime = *tvp;
1304 splx(s);
1305 }
1306
1307 #ifdef COMPAT_OSF1
1308 void
1309 cpu_exec_ecoff_setregs(p, pack, stack, retval)
1310 struct proc *p;
1311 struct exec_package *pack;
1312 u_long stack;
1313 register_t *retval;
1314 {
1315 struct ecoff_aouthdr *eap;
1316
1317 setregs(p, pack, stack, retval);
1318
1319 eap = (struct ecoff_aouthdr *)
1320 ((caddr_t)pack->ep_hdr + sizeof(struct ecoff_filehdr));
1321 p->p_md.md_tf->tf_gp = eap->ea_gp_value;
1322 }
1323
1324 /*
1325 * cpu_exec_ecoff_hook():
1326 * cpu-dependent ECOFF format hook for execve().
1327 *
1328 * Do any machine-dependent diddling of the exec package when doing ECOFF.
1329 *
1330 */
1331 int
1332 cpu_exec_ecoff_hook(p, epp, eap)
1333 struct proc *p;
1334 struct exec_package *epp;
1335 struct ecoff_aouthdr *eap;
1336 {
1337 struct ecoff_filehdr *efp = epp->ep_hdr;
1338 extern struct emul emul_netbsd;
1339 #ifdef COMPAT_OSF1
1340 extern struct emul emul_osf1;
1341 #endif
1342
1343 switch (efp->ef_magic) {
1344 #ifdef COMPAT_OSF1
1345 case ECOFF_MAGIC_ALPHA:
1346 epp->ep_emul = &emul_osf1;
1347 break;
1348 #endif
1349
1350 case ECOFF_MAGIC_NETBSD_ALPHA:
1351 epp->ep_emul = &emul_netbsd;
1352 break;
1353
1354 #ifdef DIAGNOSTIC
1355 default:
1356 panic("cpu_exec_ecoff_hook: can't get here from there.");
1357 #endif
1358 }
1359 return 0;
1360 }
1361 #endif
1362