1119380Sjake/*- 2119380Sjake * Copyright (c) 2003 Jake Burkholder. 3119380Sjake * All rights reserved. 4119380Sjake * 5119380Sjake * Redistribution and use in source and binary forms, with or without 6119380Sjake * modification, are permitted provided that the following conditions 7119380Sjake * are met: 8119380Sjake * 1. Redistributions of source code must retain the above copyright 9119380Sjake * notice, this list of conditions and the following disclaimer. 10119380Sjake * 2. Redistributions in binary form must reproduce the above copyright 11119380Sjake * notice, this list of conditions and the following disclaimer in the 12119380Sjake * documentation and/or other materials provided with the distribution. 13119380Sjake * 14119380Sjake * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15119380Sjake * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16119380Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17119380Sjake * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18119380Sjake * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19119380Sjake * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20119380Sjake * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21119380Sjake * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22119380Sjake * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23119380Sjake * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24119380Sjake * SUCH DAMAGE. 25119380Sjake */ 26119380Sjake 27146480Smarius#include <sys/cdefs.h> 28146480Smarius__FBSDID("$FreeBSD$"); 29146480Smarius 30119380Sjake#include <sys/param.h> 31119380Sjake#include <sys/systm.h> 32119380Sjake#include <sys/bus.h> 33119380Sjake#include <sys/cons.h> 34119380Sjake#include <sys/consio.h> 35146480Smarius#include <sys/kernel.h> 36146480Smarius#include <sys/limits.h> 37146480Smarius#include <sys/module.h> 38119380Sjake 39167308Smarius#include <dev/ofw/ofw_bus.h> 40146480Smarius 41146480Smarius#include <machine/bus.h> 42146480Smarius 43119380Sjake#include <dev/syscons/syscons.h> 44119380Sjake 45146480Smarius#define SC_MD_MAX 8 46146480Smarius#define SC_MD_FLAGS SC_AUTODETECT_KBD 47119380Sjake 48146480Smariusstatic sc_softc_t sc_softcs[SC_MD_MAX]; 49146480Smarius 50146480Smariusstatic device_identify_t sc_identify; 51146480Smariusstatic device_probe_t sc_probe; 52146480Smariusstatic device_attach_t sc_attach; 53146480Smarius 54146480Smariusstatic device_method_t sc_methods[] = { 55146480Smarius /* Device interface */ 56146480Smarius DEVMETHOD(device_identify, sc_identify), 57146480Smarius DEVMETHOD(device_probe, sc_probe), 58146480Smarius DEVMETHOD(device_attach, sc_attach), 59146480Smarius 60227848Smarius DEVMETHOD_END 61146480Smarius}; 62146480Smarius 63146480Smariusstatic driver_t sc_driver = { 64146480Smarius SC_DRIVER_NAME, 65146480Smarius sc_methods, 66146480Smarius 1, /* no softc */ 67146480Smarius}; 68146480Smarius 69146480Smariusstatic devclass_t sc_devclass; 70146480Smarius 71146480SmariusDRIVER_MODULE(sc, nexus, sc_driver, sc_devclass, 0, 0); 72146480Smarius 73146480Smariusstatic void 74146480Smariussc_identify(driver_t *driver, device_t parent) 75146480Smarius{ 76146480Smarius 77146480Smarius /* 78146480Smarius * Add with a priority guaranteed to make it last on 79146480Smarius * the device list. 80146480Smarius */ 81146480Smarius BUS_ADD_CHILD(parent, INT_MAX, SC_DRIVER_NAME, 0); 82146480Smarius} 83146480Smarius 84146480Smariusstatic int 85146480Smariussc_probe(device_t dev) 86146480Smarius{ 87146480Smarius int unit; 88146480Smarius 89146480Smarius unit = device_get_unit(dev); 90167308Smarius if (strcmp(ofw_bus_get_name(dev), SC_DRIVER_NAME) != 0 || 91146480Smarius unit >= SC_MD_MAX) 92146480Smarius return (ENXIO); 93146480Smarius 94146480Smarius device_set_desc(dev, "System console"); 95146480Smarius return (sc_probe_unit(unit, device_get_flags(dev) | SC_MD_FLAGS)); 96146480Smarius} 97146480Smarius 98146480Smariusstatic int 99146480Smariussc_attach(device_t dev) 100146480Smarius{ 101146480Smarius 102146480Smarius return (sc_attach_unit(device_get_unit(dev), 103146480Smarius device_get_flags(dev) | SC_MD_FLAGS)); 104146480Smarius} 105146480Smarius 106119380Sjakeint 107119380Sjakesc_get_cons_priority(int *unit, int *flags) 108119380Sjake{ 109119380Sjake 110119380Sjake *unit = 0; 111119380Sjake *flags = 0; 112119380Sjake return (CN_INTERNAL); 113119380Sjake} 114119380Sjake 115119380Sjakeint 116119380Sjakesc_max_unit(void) 117119380Sjake{ 118146480Smarius 119146480Smarius return (devclass_get_maxunit(sc_devclass)); 120119380Sjake} 121119380Sjake 122119380Sjakesc_softc_t * 123119380Sjakesc_get_softc(int unit, int flags) 124119380Sjake{ 125119380Sjake sc_softc_t *sc; 126119380Sjake 127146480Smarius if (unit < 0 || unit >= SC_MD_MAX) 128119380Sjake return (NULL); 129119380Sjake sc = &sc_softcs[unit]; 130119380Sjake sc->unit = unit; 131119380Sjake if ((sc->flags & SC_INIT_DONE) == 0) { 132119380Sjake sc->keyboard = -1; 133119380Sjake sc->adapter = -1; 134119380Sjake sc->cursor_char = SC_CURSOR_CHAR; 135119380Sjake sc->mouse_char = SC_MOUSE_CHAR; 136119380Sjake } 137119380Sjake return (sc); 138119380Sjake} 139119380Sjake 140119380Sjakevoid 141119380Sjakesc_get_bios_values(bios_values_t *values) 142119380Sjake{ 143146480Smarius 144119380Sjake} 145119380Sjake 146119380Sjakeint 147119380Sjakesc_tone(int hz) 148119380Sjake{ 149146480Smarius 150119380Sjake return (0); 151119380Sjake} 152