kbd.c (54543) | kbd.c (54545) |
---|---|
1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 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 --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 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 --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/dev/kbd/kbd.c 54543 1999-12-13 09:31:43Z yokota $ | 26 * $FreeBSD: head/sys/dev/kbd/kbd.c 54545 1999-12-13 10:36:36Z yokota $ |
27 */ 28 29#include "kbd.h" 30#include "opt_kbd.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> --- 13 unchanged lines hidden (view full) --- 48 49typedef struct genkbd_softc { 50 int gkb_flags; /* flag/status bits */ 51#define KB_ASLEEP (1 << 0) 52 struct clist gkb_q; /* input queue */ 53 struct selinfo gkb_rsel; 54} genkbd_softc_t; 55 | 27 */ 28 29#include "kbd.h" 30#include "opt_kbd.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> --- 13 unchanged lines hidden (view full) --- 48 49typedef struct genkbd_softc { 50 int gkb_flags; /* flag/status bits */ 51#define KB_ASLEEP (1 << 0) 52 struct clist gkb_q; /* input queue */ 53 struct selinfo gkb_rsel; 54} genkbd_softc_t; 55 |
56static SLIST_HEAD(, keyboard_driver) keyboard_drivers = 57 SLIST_HEAD_INITIALIZER(keyboard_drivers); 58 |
|
56/* local arrays */ 57 58/* 59 * We need at least one entry each in order to initialize a keyboard 60 * for the kernel console. The arrays will be increased dynamically 61 * when necessary. 62 */ 63 --- 81 unchanged lines hidden (view full) --- 145 fkeytab_t *fkeymap, int fkeymap_size) 146{ 147 kbd->kb_keymap = keymap; 148 kbd->kb_accentmap = accmap; 149 kbd->kb_fkeytab = fkeymap; 150 kbd->kb_fkeytab_size = fkeymap_size; 151} 152 | 59/* local arrays */ 60 61/* 62 * We need at least one entry each in order to initialize a keyboard 63 * for the kernel console. The arrays will be increased dynamically 64 * when necessary. 65 */ 66 --- 81 unchanged lines hidden (view full) --- 148 fkeytab_t *fkeymap, int fkeymap_size) 149{ 150 kbd->kb_keymap = keymap; 151 kbd->kb_accentmap = accmap; 152 kbd->kb_fkeytab = fkeymap; 153 kbd->kb_fkeytab_size = fkeymap_size; 154} 155 |
156/* declare a new keyboard driver */ 157int 158kbd_add_driver(keyboard_driver_t *driver) 159{ 160 if (SLIST_NEXT(driver, link)) 161 return EINVAL; 162 SLIST_INSERT_HEAD(&keyboard_drivers, driver, link); 163 return 0; 164} 165 166int 167kbd_delete_driver(keyboard_driver_t *driver) 168{ 169 SLIST_REMOVE(&keyboard_drivers, driver, keyboard_driver, link); 170 SLIST_NEXT(driver, link) = NULL; 171 return 0; 172} 173 |
|
153/* register a keyboard and associate it with a function table */ 154int 155kbd_register(keyboard_t *kbd) 156{ 157 const keyboard_driver_t **list; 158 const keyboard_driver_t *p; 159 int index; 160 --- 9 unchanged lines hidden (view full) --- 170 kbd->kb_index = index; 171 KBD_UNBUSY(kbd); 172 KBD_VALID(kbd); 173 kbd->kb_active = 0; /* disabled until someone calls kbd_enable() */ 174 kbd->kb_token = NULL; 175 kbd->kb_callback.kc_func = NULL; 176 kbd->kb_callback.kc_arg = NULL; 177 | 174/* register a keyboard and associate it with a function table */ 175int 176kbd_register(keyboard_t *kbd) 177{ 178 const keyboard_driver_t **list; 179 const keyboard_driver_t *p; 180 int index; 181 --- 9 unchanged lines hidden (view full) --- 191 kbd->kb_index = index; 192 KBD_UNBUSY(kbd); 193 KBD_VALID(kbd); 194 kbd->kb_active = 0; /* disabled until someone calls kbd_enable() */ 195 kbd->kb_token = NULL; 196 kbd->kb_callback.kc_func = NULL; 197 kbd->kb_callback.kc_arg = NULL; 198 |
199 SLIST_FOREACH(p, &keyboard_drivers, link) { 200 if (strcmp(p->name, kbd->kb_name) == 0) { 201 keyboard[index] = kbd; 202 kbdsw[index] = p->kbdsw; 203 return index; 204 } 205 } |
|
178 list = (const keyboard_driver_t **)kbddriver_set.ls_items; 179 while ((p = *list++) != NULL) { 180 if (strcmp(p->name, kbd->kb_name) == 0) { 181 keyboard[index] = kbd; 182 kbdsw[index] = p->kbdsw; 183 return index; 184 } 185 } --- 35 unchanged lines hidden (view full) --- 221 222/* find a funciton table by the driver name */ 223keyboard_switch_t 224*kbd_get_switch(char *driver) 225{ 226 const keyboard_driver_t **list; 227 const keyboard_driver_t *p; 228 | 206 list = (const keyboard_driver_t **)kbddriver_set.ls_items; 207 while ((p = *list++) != NULL) { 208 if (strcmp(p->name, kbd->kb_name) == 0) { 209 keyboard[index] = kbd; 210 kbdsw[index] = p->kbdsw; 211 return index; 212 } 213 } --- 35 unchanged lines hidden (view full) --- 249 250/* find a funciton table by the driver name */ 251keyboard_switch_t 252*kbd_get_switch(char *driver) 253{ 254 const keyboard_driver_t **list; 255 const keyboard_driver_t *p; 256 |
257 SLIST_FOREACH(p, &keyboard_drivers, link) { 258 if (strcmp(p->name, driver) == 0) 259 return p->kbdsw; 260 } |
|
229 list = (const keyboard_driver_t **)kbddriver_set.ls_items; 230 while ((p = *list++) != NULL) { 231 if (strcmp(p->name, driver) == 0) 232 return p->kbdsw; 233 } 234 235 return NULL; 236} --- 119 unchanged lines hidden (view full) --- 356 */ 357 358int 359kbd_configure(int flags) 360{ 361 const keyboard_driver_t **list; 362 const keyboard_driver_t *p; 363 | 261 list = (const keyboard_driver_t **)kbddriver_set.ls_items; 262 while ((p = *list++) != NULL) { 263 if (strcmp(p->name, driver) == 0) 264 return p->kbdsw; 265 } 266 267 return NULL; 268} --- 119 unchanged lines hidden (view full) --- 388 */ 389 390int 391kbd_configure(int flags) 392{ 393 const keyboard_driver_t **list; 394 const keyboard_driver_t *p; 395 |
396 SLIST_FOREACH(p, &keyboard_drivers, link) { 397 if (p->configure != NULL) 398 (*p->configure)(flags); 399 } |
|
364 list = (const keyboard_driver_t **)kbddriver_set.ls_items; 365 while ((p = *list++) != NULL) { 366 if (p->configure != NULL) 367 (*p->configure)(flags); 368 } 369 370 return 0; 371} --- 53 unchanged lines hidden (view full) --- 425 426 printf("kbd%d at %s%d\n", kbd->kb_index, kbd->kb_name, kbd->kb_unit); 427 return 0; 428} 429 430int 431kbd_detach(keyboard_t *kbd) 432{ | 400 list = (const keyboard_driver_t **)kbddriver_set.ls_items; 401 while ((p = *list++) != NULL) { 402 if (p->configure != NULL) 403 (*p->configure)(flags); 404 } 405 406 return 0; 407} --- 53 unchanged lines hidden (view full) --- 461 462 printf("kbd%d at %s%d\n", kbd->kb_index, kbd->kb_name, kbd->kb_unit); 463 return 0; 464} 465 466int 467kbd_detach(keyboard_t *kbd) 468{ |
469 dev_t dev; 470 |
|
433 if (kbd->kb_index >= keyboards) 434 return EINVAL; 435 if (keyboard[kbd->kb_index] != kbd) 436 return EINVAL; 437 | 471 if (kbd->kb_index >= keyboards) 472 return EINVAL; 473 if (keyboard[kbd->kb_index] != kbd) 474 return EINVAL; 475 |
438 /* XXX: unmake_dev() ? */ | 476 dev = makedev(kbd_cdevsw.d_maj, kbd->kb_index); 477 if (dev->si_drv1) 478 free(dev->si_drv1, M_DEVBUF); 479 destroy_dev(dev); 480 |
439 return 0; 440} 441 442/* 443 * Generic keyboard cdev driver functions 444 * Keyboard subdrivers may call these functions to implement common 445 * driver functions. 446 */ --- 750 unchanged lines hidden --- | 481 return 0; 482} 483 484/* 485 * Generic keyboard cdev driver functions 486 * Keyboard subdrivers may call these functions to implement common 487 * driver functions. 488 */ --- 750 unchanged lines hidden --- |