sc_machdep.c revision 146480
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: head/sys/sparc64/sparc64/sc_machdep.c 146480 2005-05-21 20:38:26Z marius $"); 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 39146480Smarius#include <dev/ofw/openfirm.h> 40146480Smarius 41146480Smarius#include <machine/bus.h> 42146480Smarius#include <machine/nexusvar.h> 43146480Smarius 44119380Sjake#include <dev/syscons/syscons.h> 45119380Sjake 46146480Smarius#define SC_MD_MAX 8 47146480Smarius#define SC_MD_FLAGS SC_AUTODETECT_KBD 48119380Sjake 49146480Smariusstatic sc_softc_t sc_softcs[SC_MD_MAX]; 50146480Smarius 51146480Smariusstatic device_identify_t sc_identify; 52146480Smariusstatic device_probe_t sc_probe; 53146480Smariusstatic device_attach_t sc_attach; 54146480Smarius 55146480Smariusstatic device_method_t sc_methods[] = { 56146480Smarius /* Device interface */ 57146480Smarius DEVMETHOD(device_identify, sc_identify), 58146480Smarius DEVMETHOD(device_probe, sc_probe), 59146480Smarius DEVMETHOD(device_attach, sc_attach), 60146480Smarius 61146480Smarius { 0, 0 } 62146480Smarius}; 63146480Smarius 64146480Smariusstatic driver_t sc_driver = { 65146480Smarius SC_DRIVER_NAME, 66146480Smarius sc_methods, 67146480Smarius 1, /* no softc */ 68146480Smarius}; 69146480Smarius 70146480Smariusstatic devclass_t sc_devclass; 71146480Smarius 72146480SmariusDRIVER_MODULE(sc, nexus, sc_driver, sc_devclass, 0, 0); 73146480Smarius 74146480Smariusstatic void 75146480Smariussc_identify(driver_t *driver, device_t parent) 76146480Smarius{ 77146480Smarius 78146480Smarius /* 79146480Smarius * Add with a priority guaranteed to make it last on 80146480Smarius * the device list. 81146480Smarius */ 82146480Smarius BUS_ADD_CHILD(parent, INT_MAX, SC_DRIVER_NAME, 0); 83146480Smarius} 84146480Smarius 85146480Smariusstatic int 86146480Smariussc_probe(device_t dev) 87146480Smarius{ 88146480Smarius int unit; 89146480Smarius 90146480Smarius unit = device_get_unit(dev); 91146480Smarius if (strcmp(nexus_get_name(dev), SC_DRIVER_NAME) != 0 || 92146480Smarius unit >= SC_MD_MAX) 93146480Smarius return (ENXIO); 94146480Smarius 95146480Smarius device_set_desc(dev, "System console"); 96146480Smarius return (sc_probe_unit(unit, device_get_flags(dev) | SC_MD_FLAGS)); 97146480Smarius} 98146480Smarius 99146480Smariusstatic int 100146480Smariussc_attach(device_t dev) 101146480Smarius{ 102146480Smarius 103146480Smarius return (sc_attach_unit(device_get_unit(dev), 104146480Smarius device_get_flags(dev) | SC_MD_FLAGS)); 105146480Smarius} 106146480Smarius 107119380Sjakeint 108119380Sjakesc_get_cons_priority(int *unit, int *flags) 109119380Sjake{ 110119380Sjake 111119380Sjake *unit = 0; 112119380Sjake *flags = 0; 113119380Sjake return (CN_INTERNAL); 114119380Sjake} 115119380Sjake 116119380Sjakeint 117119380Sjakesc_max_unit(void) 118119380Sjake{ 119146480Smarius 120146480Smarius return (devclass_get_maxunit(sc_devclass)); 121119380Sjake} 122119380Sjake 123119380Sjakesc_softc_t * 124119380Sjakesc_get_softc(int unit, int flags) 125119380Sjake{ 126119380Sjake sc_softc_t *sc; 127119380Sjake 128146480Smarius if (unit < 0 || unit >= SC_MD_MAX) 129119380Sjake return (NULL); 130119380Sjake sc = &sc_softcs[unit]; 131119380Sjake sc->unit = unit; 132119380Sjake if ((sc->flags & SC_INIT_DONE) == 0) { 133119380Sjake sc->keyboard = -1; 134119380Sjake sc->adapter = -1; 135119380Sjake sc->cursor_char = SC_CURSOR_CHAR; 136119380Sjake sc->mouse_char = SC_MOUSE_CHAR; 137119380Sjake } 138119380Sjake return (sc); 139119380Sjake} 140119380Sjake 141119380Sjakevoid 142119380Sjakesc_get_bios_values(bios_values_t *values) 143119380Sjake{ 144146480Smarius 145119380Sjake} 146119380Sjake 147119380Sjakeint 148119380Sjakesc_tone(int hz) 149119380Sjake{ 150146480Smarius 151119380Sjake return (0); 152119380Sjake} 153