/*-
* Copyright (c) 2001 Matthew Fredette
* Copyright (c) 1999 Eduardo E. Horvath
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifdef PROM_OBP_V2
/*
* The following several variables are related to
* the configuration process, and are used in initializing
* the machine.
*/
int prom_stdin_node; /* node ID of ROM's console input device */
int prom_stdout_node; /* node ID of ROM's console output device */
char prom_stdin_args[16];
char prom_stdout_args[16];
#endif /* PROM_OBP_V2 */
/*
* The console is set to this one initially,
* which lets us use the PROM until consinit()
* is called to select a real console.
*/
struct consdev consdev_prom = {
prom_cnprobe,
prom_cninit,
prom_cngetc,
prom_cnputc,
prom_cnpollc,
NULL,
};
/*
* This function replaces sys/dev/cninit.c
* Determine which device is the console using
* the PROM "input source" and "output sink".
*/
void
consinit(void)
{
#ifdef notyet /* PROM_OBP_V2 */
char buffer[128];
#endif /* PROM_OBP_V2 */
const char *consname = "unknown";
#if KGDB
#if NZS > 0
extern const struct cdevsw zstty_cdevsw;
#endif
#endif
DBPRINT(("consinit()\r\n"));
if (cn_tab != &consdev_prom) return;
switch(prom_version()) {
#ifdef PROM_OLDMON
case PROM_OLDMON:
case PROM_OBP_V0:
switch(prom_stdin()) {
case PROMDEV_KBD:
consname = "keyboard/display";
break;
case PROMDEV_TTYA:
consname = "ttya";
break;
case PROMDEV_TTYB:
consname = "ttyb";
break;
}
break;
#endif /* PROM_OLDMON */
#ifdef notyet /* PROM_OBP_V2 */
case PROM_OBP_V2:
case PROM_OBP_V3:
case PROM_OPENFIRM:
/* Save PROM arguments for device matching */
prom_get_device_args("stdin-path",
buffer,
sizeof(buffer),
prom_stdin_args,
sizeof(prom_stdin_args));
prom_get_device_args("stdout-path",
buffer,
sizeof(buffer),
prom_stdout_args,
sizeof(prom_stdout_args));
/*
* Translate the STDIO package instance (`ihandle') -- that
* the PROM has already opened for us -- to a device tree
* node (i.e. a `phandle').
*/
DBPRINT(("stdin instance = %x\r\n", prom_stdin()));
if ((prom_stdin_node = prom_instance_to_package(prom_stdin())) == 0) {
printf("WARNING: no PROM stdin\n");
}
DBPRINT(("stdin package = %x\r\n", prom_stdin_node));