6 #include "opt_syscons.h"
10 #include <sys/param.h>
11 #include <sys/systm.h>
12 #include <sys/kernel.h>
13 #include <sys/module.h>
16 #include <machine/cons.h>
17 #include <machine/console.h>
18 #include <machine/clock.h>
20 #include <pc98/pc98/pc98.h>
21 #include <pc98/pc98/pc98_machdep.h>
23 #include <dev/syscons/syscons.h>
25 #include <i386/isa/timerreg.h>
27 #include <isa/isavar.h>
29 static devclass_t sc_devclass;
31 static int scprobe(device_t dev);
32 static int scattach(device_t dev);
33 static int scresume(device_t dev);
35 static device_method_t sc_methods[] = {
36 DEVMETHOD(device_probe, scprobe),
37 DEVMETHOD(device_attach, scattach),
38 DEVMETHOD(device_resume, scresume),
42 static driver_t sc_driver = {
48 static sc_softc_t main_softc = { 0, 0, 0, -1, NULL, -1, NULL, };
54 if (isa_get_vendorid(dev))
57 device_set_desc(dev, "System console");
58 return sc_probe_unit(device_get_unit(dev), isa_get_flags(dev));
62 scattach(device_t dev)
64 return sc_attach_unit(device_get_unit(dev), isa_get_flags(dev));
68 scresume(device_t dev)
70 return sc_resume_unit(device_get_unit(dev));
76 return devclass_get_maxunit(sc_devclass);
80 *sc_get_softc(int unit, int flags)
84 if ((unit < 0) || (unit >= NSC))
86 if (flags & SC_KERNEL_CONSOLE) {
87 /* FIXME: clear if it is wired to another unit! */
88 main_softc.unit = unit;
91 sc = (sc_softc_t *)devclass_get_softc(sc_devclass, unit);
92 if (!(sc->flags & SC_INIT_DONE)) {
102 *sc_find_softc(struct video_adapter *adp, struct keyboard *kbd)
109 if (((adp == NULL) || (adp == sc->adp))
110 && ((kbd == NULL) || (kbd == sc->kbd)))
112 units = devclass_get_maxunit(sc_devclass);
113 for (i = 0; i < units; ++i) {
114 sc = (sc_softc_t *)devclass_get_softc(sc_devclass, i);
117 if (((adp == NULL) || (adp == sc->adp))
118 && ((kbd == NULL) || (kbd == sc->kbd)))
125 sc_get_cons_priority(int *unit, int *flags)
132 for (i = -1; (i = resource_locate(i, SC_DRIVER_NAME)) >= 0;) {
133 u = resource_query_unit(i);
134 if ((resource_int_value(SC_DRIVER_NAME, u, "disabled",
135 &disabled) == 0) && disabled)
137 if (resource_int_value(SC_DRIVER_NAME, u, "flags", &f) != 0)
139 if (f & SC_KERNEL_CONSOLE) {
140 /* the user designates this unit to be the console */
146 /* ...otherwise remember the first found unit */
151 if ((i < 0) && (*unit < 0))
157 sc_get_bios_values(bios_values_t *values)
159 values->cursor_start = 0;
160 values->cursor_end = 16;
161 values->shift_state = 0;
162 if (pc98_machine_type & M_8M)
163 values->bell_pitch = BELL_PITCH_8M;
165 values->bell_pitch = BELL_PITCH_5M;
174 /* enable counter 1 */
175 outb(0x35, inb(0x35) & 0xf7);
176 /* set command for counter 1, 2 byte write */
177 if (acquire_timer1(TIMER_16BIT | TIMER_SQWAVE))
180 pitch = timer_freq/herz;
181 outb(TIMER_CNTR1, pitch);
182 outb(TIMER_CNTR1, pitch >> 8);
184 /* disable counter 1 */
185 outb(0x35, inb(0x35) | 0x08);
191 DRIVER_MODULE(sc, isa, sc_driver, sc_devclass, 0, 0);