1*ce099b40Smartin /* $NetBSD: prom.c,v 1.6 2008/04/28 20:23:28 martin Exp $ */
29ac68bcbSwdk
39ac68bcbSwdk /*
49ac68bcbSwdk * Copyright (c) 2000 The NetBSD Foundation, Inc.
59ac68bcbSwdk * All rights reserved.
69ac68bcbSwdk *
79ac68bcbSwdk * This code is derived from software contributed to The NetBSD Foundation
89ac68bcbSwdk * by Wayne Knowles
99ac68bcbSwdk *
109ac68bcbSwdk * Redistribution and use in source and binary forms, with or without
119ac68bcbSwdk * modification, are permitted provided that the following conditions
129ac68bcbSwdk * are met:
139ac68bcbSwdk * 1. Redistributions of source code must retain the above copyright
149ac68bcbSwdk * notice, this list of conditions and the following disclaimer.
159ac68bcbSwdk * 2. Redistributions in binary form must reproduce the above copyright
169ac68bcbSwdk * notice, this list of conditions and the following disclaimer in the
179ac68bcbSwdk * documentation and/or other materials provided with the distribution.
189ac68bcbSwdk *
199ac68bcbSwdk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
209ac68bcbSwdk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
219ac68bcbSwdk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
229ac68bcbSwdk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
239ac68bcbSwdk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
249ac68bcbSwdk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
259ac68bcbSwdk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
269ac68bcbSwdk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
279ac68bcbSwdk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
289ac68bcbSwdk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
299ac68bcbSwdk * POSSIBILITY OF SUCH DAMAGE.
309ac68bcbSwdk */
319ac68bcbSwdk
324b2744bfSlukem #include <sys/cdefs.h>
33*ce099b40Smartin __KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.6 2008/04/28 20:23:28 martin Exp $");
344b2744bfSlukem
359ac68bcbSwdk #include <sys/param.h>
369ac68bcbSwdk #include <sys/systm.h>
379ac68bcbSwdk #include <sys/mbuf.h>
389ac68bcbSwdk
399ac68bcbSwdk #include <machine/cpu.h>
409ac68bcbSwdk #include <machine/prom.h>
419ac68bcbSwdk
429ac68bcbSwdk static struct mips_prom callvec;
439ac68bcbSwdk
449ac68bcbSwdk struct mips_prom *callv;
459ac68bcbSwdk
46bd338a51Smatt typedef void (*funcp_t)(void);
479ac68bcbSwdk
489ac68bcbSwdk void
prom_init(void)49bd338a51Smatt prom_init(void)
509ac68bcbSwdk {
519ac68bcbSwdk int i;
529ac68bcbSwdk funcp_t *fp;
539ac68bcbSwdk
549ac68bcbSwdk fp = (void *)&callvec;
559ac68bcbSwdk for (i=0; i < sizeof(struct mips_prom)/sizeof(funcp_t); i++ ) {
567980486eSwdk fp[i] = (funcp_t)MIPS_PROM_ENTRY(i);
579ac68bcbSwdk }
589ac68bcbSwdk callv = &callvec;
599ac68bcbSwdk }
609ac68bcbSwdk
619ac68bcbSwdk /*
629ac68bcbSwdk * Read the environment variable 'console' to determine which serial
639ac68bcbSwdk * port will be used for the console.
649ac68bcbSwdk */
659ac68bcbSwdk int
prom_getconsole(void)66bd338a51Smatt prom_getconsole(void)
679ac68bcbSwdk {
689ac68bcbSwdk char *cp;
699ac68bcbSwdk
709ac68bcbSwdk cp = MIPS_PROM(getenv)("console");
719ac68bcbSwdk if (cp == NULL) {
729ac68bcbSwdk MIPS_PROM(printf)("WARNING: defaulting to serial port 1\n");
739ac68bcbSwdk return 1;
749ac68bcbSwdk }
759ac68bcbSwdk return (*cp == '0') ? 0 : 1;
769ac68bcbSwdk }
77