/*-
* 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.
*/
/*
* 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 = {
.cn_probe = prom_cnprobe,
.cn_init = prom_cninit,
.cn_getc = prom_cngetc,
.cn_putc = prom_cnputc,
.cn_pollc = prom_cnpollc,
};
#ifdef DEBUG
#define DBPRINT(x) prom_printf x
#else
#define DBPRINT(x)
#endif
int prom_stdin_node;
int prom_stdout_node;
/*
* This function replaces sys/dev/cninit.c
* Determine which device is the console using
* the PROM "input source" and "output sink".
*/
void
consinit(void)
{
char buffer[128];
const char *consname = "unknown";
DBPRINT(("consinit()\n"));
if (cn_tab != &consdev_prom)
return;
if ((prom_stdin_node = prom_instance_to_package(prom_stdin())) == 0) {
printf("WARNING: no PROM stdin\n");
}
DBPRINT(("stdin node = %x\n", prom_stdin_node));
if ((prom_stdout_node = prom_instance_to_package(prom_stdout())) == 0)
printf("WARNING: no PROM stdout\n");
DBPRINT(("stdout package = %x\n", prom_stdout_node));
DBPRINT(("buffer @ %p\n", buffer));
if (prom_stdin_node != 0 &&
(prom_getproplen(prom_stdin_node, "keyboard") >= 0)) {
#if NUKBD > 0
if ((OF_instance_to_path(prom_stdin(), buffer, sizeof(buffer)) >= 0) &&
(strstr(buffer, "/usb@") != NULL)) {
/*
* If we have a USB keyboard, it will show up as (e.g.)
* /pci@1f,0/usb@c,3/keyboard@1 (Blade 100)
*/
consname = "usb-keyboard/display";
ukbd_cnattach();
} else
#endif
consname = "sun-keyboard/display";
} else if (prom_stdin_node != 0 &&
(OF_instance_to_path(prom_stdin(), buffer, sizeof(buffer)) >= 0)) {
consname = buffer;
}
DBPRINT(("console is %s\n", consname));
#ifndef DEBUG
(void)consname;
#endif