]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sparc64/sparc64/sc_machdep.c
MFC r341442, r341443:
[FreeBSD/FreeBSD.git] / sys / sparc64 / sparc64 / sc_machdep.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2003 Jake Burkholder.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/bus.h>
35 #include <sys/cons.h>
36 #include <sys/consio.h>
37 #include <sys/kernel.h>
38 #include <sys/limits.h>
39 #include <sys/module.h>
40
41 #include <dev/ofw/ofw_bus.h>
42
43 #include <machine/bus.h>
44
45 #include <dev/syscons/syscons.h>
46
47 #define SC_MD_MAX       8
48 #define SC_MD_FLAGS     SC_AUTODETECT_KBD
49
50 static sc_softc_t sc_softcs[SC_MD_MAX];
51
52 static device_identify_t sc_identify;
53 static device_probe_t sc_probe;
54 static device_attach_t sc_attach;
55
56 static device_method_t sc_methods[] = {
57         /* Device interface */
58         DEVMETHOD(device_identify,      sc_identify),
59         DEVMETHOD(device_probe,         sc_probe),
60         DEVMETHOD(device_attach,        sc_attach),
61
62         DEVMETHOD_END
63 };
64
65 static driver_t sc_driver = {
66         SC_DRIVER_NAME,
67         sc_methods,
68         1,      /* no softc */
69 };
70
71 static devclass_t sc_devclass;
72
73 DRIVER_MODULE(sc, nexus, sc_driver, sc_devclass, 0, 0);
74
75 static void
76 sc_identify(driver_t *driver, device_t parent)
77 {
78
79         /*
80          * Add with a priority guaranteed to make it last on
81          * the device list.
82          */
83         BUS_ADD_CHILD(parent, INT_MAX, SC_DRIVER_NAME, 0);
84 }
85
86 static int
87 sc_probe(device_t dev)
88 {
89         int unit;
90
91         unit = device_get_unit(dev);
92         if (strcmp(ofw_bus_get_name(dev), SC_DRIVER_NAME) != 0 ||
93             unit >= SC_MD_MAX)
94                 return (ENXIO);
95
96         device_set_desc(dev, "System console");
97         return (sc_probe_unit(unit, device_get_flags(dev) | SC_MD_FLAGS));
98 }
99
100 static int
101 sc_attach(device_t dev)
102 {
103
104         return (sc_attach_unit(device_get_unit(dev),
105             device_get_flags(dev) | SC_MD_FLAGS));
106 }
107
108 int
109 sc_get_cons_priority(int *unit, int *flags)
110 {
111
112         *unit = 0;
113         *flags = 0;
114         return (CN_INTERNAL);
115 }
116
117 int
118 sc_max_unit(void)
119 {
120
121         return (devclass_get_maxunit(sc_devclass));
122 }
123
124 sc_softc_t *
125 sc_get_softc(int unit, int flags)
126 {
127         sc_softc_t *sc;
128
129         if (unit < 0 || unit >= SC_MD_MAX)
130                 return (NULL);
131         sc = &sc_softcs[unit];
132         sc->unit = unit;
133         if ((sc->flags & SC_INIT_DONE) == 0) {
134                 sc->keyboard = -1;
135                 sc->adapter = -1;
136                 sc->cursor_char = SC_CURSOR_CHAR;
137                 sc->mouse_char = SC_MOUSE_CHAR;
138         }
139         return (sc);
140 }
141
142 void
143 sc_get_bios_values(bios_values_t *values)
144 {
145
146 }
147
148 int
149 sc_tone(int hz)
150 {
151
152         return (0);
153 }