xref: /netbsd-src/sys/arch/mipsco/mipsco/machdep.c (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1 /*	$NetBSD: machdep.c,v 1.42 2004/03/08 06:35:23 jmc Exp $	*/
2 
3 /*
4  * Copyright (c) 1992, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * the Systems Programming Group of the University of Utah Computer
9  * Science Department, The Mach Operating System project at
10  * Carnegie-Mellon University and Ralph Campbell.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  *	@(#)machdep.c	8.3 (Berkeley) 1/12/94
37  */
38 /*
39  * Copyright (c) 1988 University of Utah.
40  *
41  * This code is derived from software contributed to Berkeley by
42  * the Systems Programming Group of the University of Utah Computer
43  * Science Department, The Mach Operating System project at
44  * Carnegie-Mellon University and Ralph Campbell.
45  *
46  * Redistribution and use in source and binary forms, with or without
47  * modification, are permitted provided that the following conditions
48  * are met:
49  * 1. Redistributions of source code must retain the above copyright
50  *    notice, this list of conditions and the following disclaimer.
51  * 2. Redistributions in binary form must reproduce the above copyright
52  *    notice, this list of conditions and the following disclaimer in the
53  *    documentation and/or other materials provided with the distribution.
54  * 3. All advertising materials mentioning features or use of this software
55  *    must display the following acknowledgement:
56  *	This product includes software developed by the University of
57  *	California, Berkeley and its contributors.
58  * 4. Neither the name of the University nor the names of its contributors
59  *    may be used to endorse or promote products derived from this software
60  *    without specific prior written permission.
61  *
62  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72  * SUCH DAMAGE.
73  *
74  *	@(#)machdep.c	8.3 (Berkeley) 1/12/94
75  */
76 
77 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
78 
79 __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.42 2004/03/08 06:35:23 jmc Exp $");
80 
81 /* from: Utah Hdr: machdep.c 1.63 91/04/24 */
82 
83 #include "opt_ddb.h"
84 #include "opt_kgdb.h"
85 
86 #include <sys/param.h>
87 #include <sys/signalvar.h>
88 #include <sys/kernel.h>
89 #include <sys/proc.h>
90 #include <sys/buf.h>
91 #include <sys/reboot.h>
92 #include <sys/conf.h>
93 #include <sys/file.h>
94 #include <sys/callout.h>
95 #include <sys/malloc.h>
96 #include <sys/mbuf.h>
97 #include <sys/msgbuf.h>
98 #include <sys/ioctl.h>
99 #include <sys/device.h>
100 #include <sys/user.h>
101 #include <sys/exec.h>
102 #include <sys/mount.h>
103 #include <sys/sa.h>
104 #include <sys/syscallargs.h>
105 #include <sys/kcore.h>
106 #include <sys/ksyms.h>
107 
108 #include <uvm/uvm_extern.h>
109 
110 #include <ufs/mfs/mfs_extern.h>		/* mfs_initminiroot() */
111 
112 #include <machine/cpu.h>
113 #include <machine/reg.h>
114 #include <machine/psl.h>
115 #include <machine/pte.h>
116 
117 #ifdef DDB
118 #include <machine/db_machdep.h>
119 #include <ddb/db_extern.h>
120 #endif
121 
122 #include <machine/intr.h>
123 #include <machine/mainboard.h>
124 #include <machine/sysconf.h>
125 #include <machine/autoconf.h>
126 #include <machine/bootinfo.h>
127 #include <machine/prom.h>
128 #include <dev/clock_subr.h>
129 #include <dev/cons.h>
130 
131 #include <sys/boot_flag.h>
132 
133 #include "fs_mfs.h"
134 #include "opt_ddb.h"
135 #include "opt_execfmt.h"
136 
137 #include "zsc.h"			/* XXX */
138 #include "com.h"			/* XXX */
139 #include "ksyms.h"
140 
141 /* the following is used externally (sysctl_hw) */
142 extern char  cpu_model[];
143 
144 /* Our exported CPU info; we can have only one. */
145 struct cpu_info cpu_info_store;
146 
147 /* maps for VM objects */
148 
149 struct vm_map *exec_map = NULL;
150 struct vm_map *mb_map = NULL;
151 struct vm_map *phys_map = NULL;
152 
153 int	physmem;		/* max supported memory, changes to actual */
154 char	*bootinfo = NULL;	/* pointer to bootinfo structure */
155 
156 phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
157 int mem_cluster_cnt;
158 
159 void to_monitor __P((int)) __attribute__((__noreturn__));
160 void prom_halt __P((int)) __attribute__((__noreturn__));
161 
162 #ifdef	KGDB
163 void zs_kgdb_init __P((void));
164 void kgdb_connect __P((int));
165 #endif
166 
167 struct evcnt soft_evcnt[IPL_NSOFT];
168 
169 /*
170  *  Local functions.
171  */
172 int initcpu __P((void));
173 void configure __P((void));
174 
175 void mach_init __P((int, char *[], char*[], u_int, char *));
176 int  memsize_scan __P((caddr_t));
177 
178 #ifdef DEBUG
179 /* stacktrace code violates prototypes to get callee's registers */
180 extern void stacktrace __P((void)); /*XXX*/
181 #endif
182 
183 /*
184  * safepri is a safe priority for sleep to set for a spin-wait
185  * during autoconfiguration or after a panic.  Used as an argument to splx().
186  * XXX disables interrupt 5 to disable mips3 on-chip clock, which also
187  * disables mips1 FPU interrupts.
188  */
189 int	safepri = MIPS3_PSL_LOWIPL;	/* XXX */
190 extern struct user *proc0paddr;
191 
192 /* locore callback-vector setup */
193 extern void mips_vector_init  __P((void));
194 extern void prom_init  __P((void));
195 extern void pizazz_init __P((void));
196 
197 /* platform-specific initialization vector */
198 static void	unimpl_cons_init __P((void));
199 static void	unimpl_iointr __P((unsigned, unsigned, unsigned, unsigned));
200 static int	unimpl_memsize __P((caddr_t));
201 static unsigned	unimpl_clkread __P((void));
202 static void	unimpl_todr __P((struct clock_ymdhms *));
203 static void	unimpl_intr_establish __P((int, int (*)__P((void *)), void *));
204 
205 struct platform platform = {
206 	"iobus not set",
207 	unimpl_cons_init,
208 	unimpl_iointr,
209 	unimpl_memsize,
210 	unimpl_clkread,
211 	unimpl_todr,
212 	unimpl_todr,
213 	unimpl_intr_establish,
214 };
215 
216 struct consdev *cn_tab = NULL;
217 extern struct consdev consdev_prom;
218 extern struct consdev consdev_zs;
219 
220 static void null_cnprobe __P((struct consdev *));
221 static void prom_cninit __P((struct consdev *));
222 static int  prom_cngetc __P((dev_t));
223 static void prom_cnputc __P((dev_t, int));
224 static void null_cnpollc __P((dev_t, int));
225 
226 struct consdev consdev_prom = {
227         null_cnprobe,
228 	prom_cninit,
229 	prom_cngetc,
230 	prom_cnputc,
231         null_cnpollc,
232 };
233 
234 
235 /*
236  * Do all the stuff that locore normally does before calling main().
237  * Process arguments passed to us by the prom monitor.
238  * Return the first page address following the system.
239  */
240 void
241 mach_init(argc, argv, envp, bim, bip)
242 	int    argc;
243 	char   *argv[];
244 	char   *envp[];
245 	u_int  bim;
246 	char   *bip;
247 {
248 	u_long first, last;
249 	caddr_t kernend, v;
250 	char *cp;
251 	int i, howto;
252 	extern char edata[], end[];
253 	char *bi_msg;
254 #if NKSYMS || defined(DDB) || defined(LKM)
255 	int nsym = 0;
256 	caddr_t ssym = 0;
257 	caddr_t esym = 0;
258 	struct btinfo_symtab *bi_syms;
259 #endif
260 
261 
262 	/* Check for valid bootinfo passed from bootstrap */
263 	if (bim == BOOTINFO_MAGIC) {
264 		struct btinfo_magic *bi_magic;
265 
266 		bootinfo = (char *)BOOTINFO_ADDR; /* XXX */
267 		bi_magic = lookup_bootinfo(BTINFO_MAGIC);
268 		if (bi_magic == NULL || bi_magic->magic != BOOTINFO_MAGIC)
269 			bi_msg = "invalid bootinfo structure.\n";
270 		else
271 			bi_msg = NULL;
272 	} else
273 		bi_msg = "invalid bootinfo (standalone boot?)\n";
274 
275 	/* clear the BSS segment */
276 	kernend = (caddr_t)mips_round_page(end);
277 	memset(edata, 0, end - edata);
278 
279 #if NKSYMS || defined(DDB) || defined(LKM)
280 	bi_syms = lookup_bootinfo(BTINFO_SYMTAB);
281 
282 	/* Load sysmbol table if present */
283 	if (bi_syms != NULL) {
284 		nsym = bi_syms->nsym;
285 		ssym = (caddr_t)bi_syms->ssym;
286 		esym = (caddr_t)bi_syms->esym;
287 		kernend = (caddr_t)mips_round_page(esym);
288 	}
289 #endif
290 
291 	prom_init();
292 	consinit();
293 
294 	if (bi_msg != NULL)
295 		printf(bi_msg);
296 
297 	/*
298 	 * Set the VM page size.
299 	 */
300 	uvm_setpagesize();
301 
302 	/* Find out how much memory is available. */
303 	physmem = memsize_scan(kernend);
304 
305 	/*
306 	 * Now that we know how much memory we have, initialize the
307 	 * mem cluster array.
308 	 */
309 	mem_clusters[0].start = 0;		/* XXX is this correct? */
310 	mem_clusters[0].size  = ctob(physmem);
311 	mem_cluster_cnt = 1;
312 
313 	/*
314 	 * Copy exception-dispatch code down to exception vector.
315 	 * Initialize locore-function vector.
316 	 * Clear out the I and D caches.
317 	 */
318 	mips_vector_init();
319 
320 	/* Look at argv[0] and compute bootdev */
321 	makebootdev(argv[0]);
322 
323 	/*
324 	 * Look at arguments passed to us and compute boothowto.
325 	 */
326 	boothowto = RB_AUTOBOOT;
327 	for (i = 1; i < argc; i++) {
328 		for (cp = argv[i]; *cp; cp++) {
329 			/* Ignore superfluous '-', if there is one */
330 			if (*cp == '-')
331 				continue;
332 
333 			howto = 0;
334 			BOOT_FLAG(*cp, howto);
335 			if (! howto)
336 				printf("bootflag '%c' not recognised\n", *cp);
337 			else
338 				boothowto |= howto;
339 		}
340 	}
341 
342 
343 #if NKSYMS || defined(DDB) || defined(LKM)
344 	/* init symbols if present */
345 	if (esym)
346 		ksyms_init(esym - ssym, ssym, esym);
347 #endif
348 #ifdef DDB
349 	if (boothowto & RB_KDB)
350 		Debugger();
351 #endif
352 #ifdef KGDB
353 	zs_kgdb_init();			/* XXX */
354 	if (boothowto & RB_KDB)
355 		kgdb_connect(0);
356 #endif
357 
358 #ifdef MFS
359 	/*
360 	 * Check to see if a mini-root was loaded into memory. It resides
361 	 * at the start of the next page just after the end of BSS.
362 	 */
363 	if (boothowto & RB_MINIROOT)
364 		kernend += round_page(mfs_initminiroot(kernend));
365 #endif
366 
367 	/*
368 	 * Load the rest of the available pages into the VM system.
369 	 */
370 	first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
371 	last = mem_clusters[0].start + mem_clusters[0].size;
372 	uvm_page_physload(atop(first), atop(last), atop(first), atop(last),
373 	    VM_FREELIST_DEFAULT);
374 
375 	/*
376 	 * Initialize error message buffer (at end of core).
377 	 */
378 	mips_init_msgbuf();
379 
380 	/*
381 	 * Initialize the virtual memory system.
382 	 */
383 	pmap_bootstrap();
384 
385 	/*
386 	 * Allocate space for proc0's USPACE.
387 	 */
388 	v = (caddr_t)uvm_pageboot_alloc(USPACE);
389 	lwp0.l_addr = proc0paddr = (struct user *)v;
390 	lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1;
391 	curpcb = &lwp0.l_addr->u_pcb;
392 	curpcb->pcb_context[11] = MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
393 
394 	/*
395 	 * Set up interrupt handling and I/O addresses.
396 	 */
397 	pizazz_init();
398 }
399 
400 
401 
402 /*
403  * cpu_startup: allocate memory for variable-sized tables,
404  * initialize CPU, and do autoconfiguration.
405  */
406 void
407 cpu_startup()
408 {
409 	vaddr_t minaddr, maxaddr;
410 	char pbuf[9];
411 #ifdef DEBUG
412 	extern int pmapdebug;
413 	int opmapdebug = pmapdebug;
414 
415 	pmapdebug = 0;
416 #endif
417 
418 	/*
419 	 * Good {morning,afternoon,evening,night}.
420 	 */
421 	printf(version);
422 	printf("%s\n", cpu_model);
423 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
424 	printf("total memory = %s\n", pbuf);
425 
426 	minaddr = 0;
427 	/*
428 	 * Allocate a submap for exec arguments.  This map effectively
429 	 * limits the number of processes exec'ing at any time.
430 	 */
431 	exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
432 				   16 * NCARGS, TRUE, FALSE, NULL);
433 	/*
434 	 * Allocate a submap for physio
435 	 */
436 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
437 				   VM_PHYS_SIZE, TRUE, FALSE, NULL);
438 
439 	/*
440 	 * No need to allocate an mbuf cluster submap.  Mbuf clusters
441 	 * are allocated via the pool allocator, and we use KSEG to
442 	 * map those pages.
443 	 */
444 
445 #ifdef DEBUG
446 	pmapdebug = opmapdebug;
447 #endif
448 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
449 	printf("avail memory = %s\n", pbuf);
450 }
451 
452 /*
453  * Look up information in bootinfo of boot loader.
454  */
455 void *
456 lookup_bootinfo(type)
457 	int type;
458 {
459 	struct btinfo_common *bt;
460 	char *help = bootinfo;
461 
462 	/* Check for a bootinfo record first. */
463 	if (help == NULL)
464 		return (NULL);
465 
466 	do {
467 		bt = (struct btinfo_common *)help;
468 		if (bt->type == type)
469 			return ((void *)help);
470 		help += bt->next;
471 	} while (bt->next != 0 &&
472 		(size_t)help < (size_t)bootinfo + BOOTINFO_SIZE);
473 
474 	return (NULL);
475 }
476 
477 int	waittime = -1;
478 
479 /*
480  * call PROM to halt or reboot.
481  */
482 void
483 prom_halt(howto)
484 	int howto;
485 {
486 	if (howto & RB_HALT)
487 		MIPS_PROM(reinit)();
488 	MIPS_PROM(reboot)();
489 	/* NOTREACHED */
490 }
491 
492 void
493 cpu_reboot(howto, bootstr)
494 	volatile int howto;
495 	char *bootstr;
496 {
497 	/* take a snap shot before clobbering any registers */
498 	if (curlwp)
499 		savectx((struct user *)curpcb);
500 
501 #ifdef DEBUG
502 	if (panicstr)
503 		stacktrace();
504 #endif
505 
506 	/* If system is cold, just halt. */
507 	if (cold) {
508 		howto |= RB_HALT;
509 		goto haltsys;
510 	}
511 
512 	/* If "always halt" was specified as a boot flag, obey. */
513 	if ((boothowto & RB_HALT) != 0)
514 		howto |= RB_HALT;
515 
516 	boothowto = howto;
517 	if ((howto & RB_NOSYNC) == 0 && waittime < 0) {
518 		/*
519 		 * Synchronize the disks....
520 		 */
521 		waittime = 0;
522 		vfs_shutdown();
523 
524 		/*
525 		 * If we've been adjusting the clock, the todr
526 		 * will be out of synch; adjust it now.
527 		 */
528 		resettodr();
529 	}
530 
531 	/* Disable interrupts. */
532 	splhigh();
533 
534 	/* If rebooting and a dump is requested do it. */
535 #if 0
536 	if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
537 #else
538 	if (howto & RB_DUMP)
539 #endif
540 		dumpsys();
541 
542 haltsys:
543 
544 	/* run any shutdown hooks */
545 	doshutdownhooks();
546 
547 	if ((howto & RB_POWERDOWN) == RB_POWERDOWN)
548 		prom_halt(0x80);	/* rom monitor RB_PWOFF */
549 
550 	/* Finally, halt/reboot the system. */
551 	printf("%s\n\n", howto & RB_HALT ? "halted." : "rebooting...");
552 	prom_halt(howto & RB_HALT);
553 	/*NOTREACHED*/
554 }
555 
556 /*
557  * Return the best possible estimate of the time in the timeval
558  * to which tvp points.  Unfortunately, we can't read the hardware registers.
559  * We guarantee that the time will be greater than the value obtained by a
560  * previous call.
561  */
562 void
563 microtime(tvp)
564 	register struct timeval *tvp;
565 {
566 	static struct timeval lasttime;
567 	int s = splclock();
568 
569 	*tvp = time;
570 
571 	tvp->tv_usec += (*platform.clkread)();
572 
573 	while (tvp->tv_usec >= 1000000) {
574 		tvp->tv_usec -= 1000000;
575 		tvp->tv_sec++;
576 	}
577 
578 	if (tvp->tv_sec == lasttime.tv_sec &&
579 	    tvp->tv_usec <= lasttime.tv_usec &&
580 	    (tvp->tv_usec = lasttime.tv_usec + 1) > 1000000) {
581 		tvp->tv_sec++;
582 		tvp->tv_usec -= 1000000;
583 	}
584 	lasttime = *tvp;
585 	splx(s);
586 }
587 
588 int
589 initcpu()
590 {
591 	spl0();		/* safe to turn interrupts on now */
592 	return 0;
593 }
594 
595 static void
596 unimpl_cons_init()
597 {
598 
599 	panic("sysconf.init didn't set cons_init");
600 }
601 
602 static void
603 unimpl_iointr(mask, pc, statusreg, causereg)
604 	u_int mask;
605 	u_int pc;
606 	u_int statusreg;
607 	u_int causereg;
608 {
609 
610 	panic("sysconf.init didn't set intr");
611 }
612 
613 static int
614 unimpl_memsize(first)
615 caddr_t first;
616 {
617 
618 	panic("sysconf.init didn't set memsize");
619 }
620 
621 static unsigned
622 unimpl_clkread()
623 {
624 	return 0;	/* No microtime available */
625 }
626 
627 static void
628 unimpl_todr(dt)
629 	struct clock_ymdhms *dt;
630 {
631 	panic("sysconf.init didn't init TOD");
632 }
633 
634 void
635 unimpl_intr_establish(level, func, arg)
636 	int level;
637 	int (*func) __P((void *));
638 	void *arg;
639 {
640 	panic("sysconf.init didn't init intr_establish");
641 }
642 
643 void
644 delay(n)
645 	int n;
646 {
647 	DELAY(n);
648 }
649 
650 /*
651  * Find out how much memory is available by testing memory.
652  * Be careful to save and restore the original contents for msgbuf.
653  */
654 int
655 memsize_scan(first)
656 	caddr_t first;
657 {
658 	volatile int *vp, *vp0;
659 	int mem, tmp, tmp0;
660 
661 #define PATTERN1 0xa5a5a5a5
662 #define	PATTERN2 ~PATTERN1
663 
664 	/*
665 	 * Non destructive scan of memory to determine the size
666 	 * Use the first page to test for memory aliases.  This
667 	 * also has the side effect of flushing the bus alignment
668 	 * buffer
669 	 */
670 	mem = btoc((paddr_t)first - MIPS_KSEG0_START);
671 	vp = (int *)MIPS_PHYS_TO_KSEG1(mem << PGSHIFT);
672 	vp0 = (int *)MIPS_PHYS_TO_KSEG1(0); /* Start of physical memory */
673 	tmp0 = *vp0;
674 	while (vp < (int *)MIPS_MAX_MEM_ADDR) {
675 		tmp = *vp;
676 		*vp  = PATTERN1;
677 		*vp0 = PATTERN2;
678 		wbflush();
679 		if (*vp != PATTERN1)
680 			break;
681 		*vp  = PATTERN2;
682 		*vp0 = PATTERN1;
683 		wbflush();
684 		if (*vp != PATTERN2)
685 			break;
686 		*vp = tmp;
687 		vp += PAGE_SIZE/sizeof(int);
688 		mem++;
689 	}
690 	*vp0 = tmp0;
691 	return mem;
692 }
693 
694 /*
695  * Console initialization: called early on from main,
696  * before vm init or startup.  Do enough configuration
697  * to choose and initialize a console.
698  */
699 
700 static void
701 null_cnprobe(cn)
702      struct consdev *cn;
703 {
704 }
705 
706 static void
707 prom_cninit(cn)
708 	struct consdev *cn;
709 {
710 	extern const struct cdevsw cons_cdevsw;
711 
712 	cn->cn_dev = makedev(cdevsw_lookup_major(&cons_cdevsw), 0);
713 	cn->cn_pri = CN_REMOTE;
714 }
715 
716 static int
717 prom_cngetc(dev)
718 	dev_t dev;
719 {
720 	return MIPS_PROM(getchar)();
721 }
722 
723 static void
724 prom_cnputc(dev, c)
725 	dev_t dev;
726 	int c;
727 {
728 	MIPS_PROM(putchar)(c);
729 }
730 
731 static void
732 null_cnpollc(dev, on)
733 	dev_t dev;
734 	int on;
735 {
736 }
737 
738 void
739 consinit()
740 {
741 	int zs_unit;
742 
743 	zs_unit = 0;
744 	cn_tab = &consdev_zs;
745 
746 	(*cn_tab->cn_init)(cn_tab);
747 }
748