pckbd.c (44635) | pckbd.c (45783) |
---|---|
1/* 2 * Copyright (c) 1999 FreeBSD(98) port team. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/* 2 * Copyright (c) 1999 FreeBSD(98) port team. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $Id: pc98kbd.c,v 1.4 1999/01/19 14:08:04 kato Exp $ | 28 * $Id: pc98kbd.c,v 1.5 1999/03/10 14:51:53 kato Exp $ |
29 */ 30 31#include "pckbd.h" 32#include "opt_kbd.h" 33#include "opt_devfs.h" 34 35#if NPCKBD > 0 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/kernel.h> 40#include <sys/conf.h> 41#include <sys/proc.h> | 29 */ 30 31#include "pckbd.h" 32#include "opt_kbd.h" 33#include "opt_devfs.h" 34 35#if NPCKBD > 0 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/kernel.h> 40#include <sys/conf.h> 41#include <sys/proc.h> |
42#include <sys/module.h> |
|
42#include <sys/tty.h> 43#include <sys/fcntl.h> | 43#include <sys/tty.h> 44#include <sys/fcntl.h> |
44#include <sys/bus.h> | |
45#include <sys/malloc.h> | 45#include <sys/malloc.h> |
46#include <sys/bus.h> 47#include <machine/bus.h> 48#include <sys/rman.h> |
|
46 47#include <machine/resource.h> 48 49#include <dev/kbd/kbdreg.h> 50 51#include <pc98/pc98/pc98.h> 52#include <pc98/pc98/pc98_machdep.h> 53 | 49 50#include <machine/resource.h> 51 52#include <dev/kbd/kbdreg.h> 53 54#include <pc98/pc98/pc98.h> 55#include <pc98/pc98/pc98_machdep.h> 56 |
57#include <isa/isavar.h> 58#include <machine/lock.h> 59 |
|
54#ifdef __i386__ 55#include <i386/isa/isa_device.h> 56#endif 57 58#define DRIVER_NAME "pckbd" 59 60/* device configuration flags */ 61#define KB_CONF_FAIL_IF_NO_KBD (1 << 0) /* don't install if no kbd is found */ --- 9 unchanged lines hidden (view full) --- 71#define PC98KBD_ATTACHED (1 << 0) 72 keyboard_t *kbd; 73#ifdef KBD_INSTALL_CDEV 74 genkbd_softc_t gensc; 75#endif 76} pckbd_softc_t; 77 78#define PC98KBD_SOFTC(unit) \ | 60#ifdef __i386__ 61#include <i386/isa/isa_device.h> 62#endif 63 64#define DRIVER_NAME "pckbd" 65 66/* device configuration flags */ 67#define KB_CONF_FAIL_IF_NO_KBD (1 << 0) /* don't install if no kbd is found */ --- 9 unchanged lines hidden (view full) --- 77#define PC98KBD_ATTACHED (1 << 0) 78 keyboard_t *kbd; 79#ifdef KBD_INSTALL_CDEV 80 genkbd_softc_t gensc; 81#endif 82} pckbd_softc_t; 83 84#define PC98KBD_SOFTC(unit) \ |
79 (((unit) >= NPCKBD) ? NULL : pckbd_softc[(unit)]) | 85 ((pckbd_softc_t)devclass_get_softc(pckbd_devclass, unit)) |
80 | 86 |
81static pckbd_softc_t *pckbd_softc[NPCKBD]; | 87static devclass_t pckbd_devclass; |
82 | 88 |
83static int pckbdprobe(struct isa_device *dev); 84static int pckbdattach(struct isa_device *dev); | 89static int pckbdprobe(device_t dev); 90static int pckbdattach(device_t dev); 91static void pckbd_isa_intr(void *arg); |
85 | 92 |
86static ointhand2_t pckbd_isa_intr; | 93static device_method_t pckbd_methods[] = { 94 /* Device interface */ 95 DEVMETHOD(device_probe, pckbdprobe), 96 DEVMETHOD(device_attach, pckbdattach), 97 { 0, 0 } 98}; |
87 | 99 |
88/* driver declaration for isa_devtab_tty[] */ 89struct isa_driver pckbddriver = { 90 pckbdprobe, 91 pckbdattach, | 100static driver_t pckbd_driver = { |
92 DRIVER_NAME, | 101 DRIVER_NAME, |
93 0, | 102 pckbd_methods, 103 DRIVER_TYPE_TTY, 104 sizeof(pckbd_softc_t), |
94}; 95 | 105}; 106 |
107DRIVER_MODULE(pckbd, isa, pckbd_driver, pckbd_devclass, 0, 0); 108 |
|
96static int pckbd_probe_unit(int unit, int port, int irq, 97 int flags); 98static int pckbd_attach_unit(int unit, pckbd_softc_t *sc, 99 int port, int irq, int flags); 100static timeout_t pckbd_timeout; 101 102#ifdef KBD_INSTALL_CDEV 103 --- 8 unchanged lines hidden (view full) --- 112 pckbdioctl, nostop, nullreset, nodevtotty, 113 pckbdpoll, nommap, NULL, DRIVER_NAME, 114 NULL, -1, 115}; 116 117#endif /* KBD_INSTALL_CDEV */ 118 119static int | 109static int pckbd_probe_unit(int unit, int port, int irq, 110 int flags); 111static int pckbd_attach_unit(int unit, pckbd_softc_t *sc, 112 int port, int irq, int flags); 113static timeout_t pckbd_timeout; 114 115#ifdef KBD_INSTALL_CDEV 116 --- 8 unchanged lines hidden (view full) --- 125 pckbdioctl, nostop, nullreset, nodevtotty, 126 pckbdpoll, nommap, NULL, DRIVER_NAME, 127 NULL, -1, 128}; 129 130#endif /* KBD_INSTALL_CDEV */ 131 132static int |
120pckbdprobe(struct isa_device *dev) | 133pckbdprobe(device_t dev) |
121{ | 134{ |
122 return ((pckbd_probe_unit(dev->id_unit, dev->id_iobase, dev->id_irq, 123 dev->id_flags)) ? 0 : IO_KBDSIZE); | 135 device_set_desc(dev, "PC-98 Keyboard"); 136 137 return pckbd_probe_unit(device_get_unit(dev), isa_get_port(dev), 138 (1 << isa_get_irq(dev)), isa_get_flags(dev)); |
124} 125 126static int | 139} 140 141static int |
127pckbdattach(struct isa_device *dev) | 142pckbdattach(device_t dev) |
128{ | 143{ |
129 pckbd_softc_t *sc; | 144 void *ih; 145 struct resource *res; 146 int zero = 0; |
130 | 147 |
131 if (dev->id_unit >= sizeof(pckbd_softc)/sizeof(pckbd_softc[0])) 132 return 0; 133 sc = pckbd_softc[dev->id_unit] 134 = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); 135 if (sc == NULL) 136 return 0; | 148 pckbd_softc_t *sc = device_get_softc(dev); |
137 bzero(sc, sizeof(*sc)); 138 | 149 bzero(sc, sizeof(*sc)); 150 |
139 dev->id_ointr = pckbd_isa_intr; 140 return ((pckbd_attach_unit(dev->id_unit, sc, dev->id_iobase, 141 dev->id_irq, dev->id_flags)) ? 0 : 1); | 151 pckbd_attach_unit(device_get_unit(dev), sc, isa_get_port(dev), 152 (1 << isa_get_irq(dev)), isa_get_flags(dev)); 153 154 res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, 0ul, ~0ul, 1, 155 RF_SHAREABLE | RF_ACTIVE); 156 BUS_SETUP_INTR(device_get_parent(dev), dev, res, pckbd_isa_intr, 157 sc, &ih); 158 159 return (0); |
142} 143 144static void | 160} 161 162static void |
145pckbd_isa_intr(int unit) | 163pckbd_isa_intr(void *arg) |
146{ | 164{ |
147 keyboard_t *kbd; | 165 pckbd_softc_t *sc = arg; 166 keyboard_t *kbd = sc->kbd; |
148 | 167 |
149 kbd = pckbd_softc[unit]->kbd; | |
150 (*kbdsw[kbd->kb_index]->intr)(kbd, NULL); 151} 152 153static int 154pckbd_probe_unit(int unit, int port, int irq, int flags) 155{ 156 keyboard_switch_t *sw; 157 int args[2]; --- 251 unchanged lines hidden (view full) --- 409 * NOTE: because of the way the low-level conole is initialized, this routine 410 * may be called more than once!! 411 */ 412static int 413pckbd_configure(int flags) 414{ 415 keyboard_t *kbd; 416 int arg[2]; | 168 (*kbdsw[kbd->kb_index]->intr)(kbd, NULL); 169} 170 171static int 172pckbd_probe_unit(int unit, int port, int irq, int flags) 173{ 174 keyboard_switch_t *sw; 175 int args[2]; --- 251 unchanged lines hidden (view full) --- 427 * NOTE: because of the way the low-level conole is initialized, this routine 428 * may be called more than once!! 429 */ 430static int 431pckbd_configure(int flags) 432{ 433 keyboard_t *kbd; 434 int arg[2]; |
417 struct isa_device *dev; | |
418 int i; 419 420 /* XXX: a kludge to obtain the device configuration flags */ | 435 int i; 436 437 /* XXX: a kludge to obtain the device configuration flags */ |
421 dev = find_isadev(isa_devtab_tty, &pckbddriver, 0); 422 if (dev != NULL) { 423 flags |= dev->id_flags; | 438 if (resource_int_value(DRIVER_NAME, 0, "flags", &i) == 0) { 439 flags |= i; |
424 /* if the driver is disabled, unregister the keyboard if any */ | 440 /* if the driver is disabled, unregister the keyboard if any */ |
425 if (!dev->id_enabled) { | 441 if (resource_int_value(DRIVER_NAME, 0, "disabled", &i) == 0 442 && i != 0) { |
426 i = kbd_find_keyboard(DRIVER_NAME, PC98KBD_DEFAULT); 427 if (i >= 0) { 428 kbd = kbd_get_keyboard(i); 429 kbd_unregister(kbd); 430 kbd->kb_flags &= ~KB_REGISTERED; 431 return 0; 432 } 433 } --- 581 unchanged lines hidden --- | 443 i = kbd_find_keyboard(DRIVER_NAME, PC98KBD_DEFAULT); 444 if (i >= 0) { 445 kbd = kbd_get_keyboard(i); 446 kbd_unregister(kbd); 447 kbd->kb_flags &= ~KB_REGISTERED; 448 return 0; 449 } 450 } --- 581 unchanged lines hidden --- |