mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Keyboard driver update in preparation for the USB keyboard driver.
- Refined internal interface in keyboard drivers so that: 1. the side effect of device probe is kept minimal, 2. polling mode function is added, 3. and new ioctl and configuration options are added (see below). - Added new ioctl: KDSETREPEAT Set keyboard typematic rate. There has existed an ioctl command, KDSETRAD, for the same purpose. However, KDSETRAD is dependent on the AT keyboard. KDSETREPEAT provides more generic interface. KDSETRAD will still be supported in the atkbd driver. - Added new configuration options: ATKBD_DFLT_KEYMAP Specify a keymap to be used as the default, built-in keymap. (There has been undocumented options, DKKEYMAP, UKKEYMAP, GRKEYMAP, SWKEYMAP, RUKEYMAP, ESKEYMAP, and ISKEYMAP to set the default keymap. These options are now gone for good. The new option is more general.) KBD_DISABLE_KEYMAP_LOADING Don't allow the user to change the keymap.
This commit is contained in:
parent
fda82fc2b9
commit
e9deda23ae
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=44628
@ -1,7 +1,7 @@
|
||||
# This file tells config what files go into building a kernel,
|
||||
# files marked standard are always included.
|
||||
#
|
||||
# $Id: files.alpha,v 1.15 1999/01/18 20:26:50 gallatin Exp $
|
||||
# $Id: files.alpha,v 1.16 1999/01/23 16:53:26 dfr Exp $
|
||||
#
|
||||
# The long compile-with and dependency lines are required because of
|
||||
# limitations in config: backslash-newline doesn't work in strings, and
|
||||
@ -12,7 +12,11 @@ font8x16.o optional std8x16font \
|
||||
compile-with "uudecode < /usr/share/syscons/fonts/${STD8X16FONT}-8x16.fnt && file2c 'unsigned char font_16[16*256] = {' '};' < ${STD8X16FONT}-8x16 > font8x16.c && ${CC} -c ${CFLAGS} font8x16.c" \
|
||||
no-implicit-rule before-depend \
|
||||
clean "${STD8X16FONT}-8x16 font8x16.c"
|
||||
|
||||
#
|
||||
atkbdmap.h optional atkbd_dflt_keymap \
|
||||
compile-with "kbdcontrol -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "atkbdmap.h"
|
||||
#
|
||||
alpha/alpha/autoconf.c standard device-driver
|
||||
alpha/alpha/cpuconf.c standard
|
||||
@ -148,7 +152,7 @@ dev/kbd/atkbdc.c optional atkbdc device-driver
|
||||
isa/atkbdc_isa.c optional atkbdc device-driver
|
||||
dev/kbd/kbd.c optional atkbd device-driver
|
||||
dev/kbd/kbd.c optional kbd device-driver
|
||||
#dev/kbd/kbd.c optional ukbd device-driver
|
||||
dev/kbd/kbd.c optional ukbd device-driver
|
||||
dev/syscons/syscons.c optional sc device-driver
|
||||
dev/syscons/scvidctl.c optional sc device-driver
|
||||
isa/syscons_isa.c optional sc device-driver
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: options.alpha,v 1.8 1999/01/18 20:26:50 gallatin Exp $
|
||||
# $Id: options.alpha,v 1.9 1999/01/23 16:53:26 dfr Exp $
|
||||
|
||||
EV5 opt_global.h
|
||||
EV4 opt_global.h
|
||||
@ -41,7 +41,11 @@ PSM_DEBUG opt_psm.h
|
||||
# Fb options
|
||||
FB_INSTALL_CDEV opt_fb.h
|
||||
|
||||
# Atkbd options
|
||||
ATKBD_DFLT_KEYMAP opt_atkbd.h
|
||||
|
||||
# Kbd options
|
||||
KBD_DISABLE_KEYMAP_LOAD opt_kbd.h
|
||||
KBD_INSTALL_CDEV opt_kbd.h
|
||||
KBD_MAXRETRY opt_kbd.h
|
||||
KBD_MAXWAIT opt_kbd.h
|
||||
|
@ -25,7 +25,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: console.h,v 1.42 1999/01/23 16:53:27 dfr Exp $
|
||||
* $Id: console.h,v 1.43 1999/02/05 11:51:56 yokota Exp $
|
||||
* from: i386/include console.h,v 1.43
|
||||
*/
|
||||
|
||||
@ -51,9 +51,10 @@
|
||||
#define KDGKBTYPE _IOR('K', 64, int)
|
||||
#define KDGETLED _IOR('K', 65, int)
|
||||
#define KDSETLED _IO('K', 66 /*, int */)
|
||||
#define KDSETRAD _IO('K', 67 /*, int */)
|
||||
#define KDSETRAD _IO('K', 67 /*, int */) /* obsolete */
|
||||
#define KDRASTER _IOW('K', 100, scr_size_t)
|
||||
#define KDGKBINFO _IOR('K', 101, keyboard_info_t)
|
||||
#define KDSETREPEAT _IOW('K', 102, keyboard_delay_t)
|
||||
|
||||
#define GETFKEY _IOWR('k', 0, fkeyarg_t)
|
||||
#define SETFKEY _IOWR('k', 1, fkeyarg_t)
|
||||
@ -394,6 +395,7 @@ typedef struct video_adapter_info video_adapter_info_t;
|
||||
typedef struct video_info video_info_t;
|
||||
typedef struct keyboard_info keyboard_info_t;
|
||||
typedef struct {int scr_size[3];} scr_size_t;
|
||||
typedef struct {int kbd_delay[2];} keyboard_delay_t;
|
||||
|
||||
/* defines for "special" keys (spcl bit set in keymap) */
|
||||
#define NOP 0x00 /* nothing (dead key) */
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file tells config what files go into building a kernel,
|
||||
# files marked standard are always included.
|
||||
#
|
||||
# $Id: files.alpha,v 1.15 1999/01/18 20:26:50 gallatin Exp $
|
||||
# $Id: files.alpha,v 1.16 1999/01/23 16:53:26 dfr Exp $
|
||||
#
|
||||
# The long compile-with and dependency lines are required because of
|
||||
# limitations in config: backslash-newline doesn't work in strings, and
|
||||
@ -12,7 +12,11 @@ font8x16.o optional std8x16font \
|
||||
compile-with "uudecode < /usr/share/syscons/fonts/${STD8X16FONT}-8x16.fnt && file2c 'unsigned char font_16[16*256] = {' '};' < ${STD8X16FONT}-8x16 > font8x16.c && ${CC} -c ${CFLAGS} font8x16.c" \
|
||||
no-implicit-rule before-depend \
|
||||
clean "${STD8X16FONT}-8x16 font8x16.c"
|
||||
|
||||
#
|
||||
atkbdmap.h optional atkbd_dflt_keymap \
|
||||
compile-with "kbdcontrol -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "atkbdmap.h"
|
||||
#
|
||||
alpha/alpha/autoconf.c standard device-driver
|
||||
alpha/alpha/cpuconf.c standard
|
||||
@ -148,7 +152,7 @@ dev/kbd/atkbdc.c optional atkbdc device-driver
|
||||
isa/atkbdc_isa.c optional atkbdc device-driver
|
||||
dev/kbd/kbd.c optional atkbd device-driver
|
||||
dev/kbd/kbd.c optional kbd device-driver
|
||||
#dev/kbd/kbd.c optional ukbd device-driver
|
||||
dev/kbd/kbd.c optional ukbd device-driver
|
||||
dev/syscons/syscons.c optional sc device-driver
|
||||
dev/syscons/scvidctl.c optional sc device-driver
|
||||
isa/syscons_isa.c optional sc device-driver
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file tells config what files go into building a kernel,
|
||||
# files marked standard are always included.
|
||||
#
|
||||
# $Id: files.i386,v 1.226 1999/03/07 16:11:12 hm Exp $
|
||||
# $Id: files.i386,v 1.227 1999/03/10 10:11:41 julian Exp $
|
||||
#
|
||||
# The long compile-with and dependency lines are required because of
|
||||
# limitations in config: backslash-newline doesn't work in strings, and
|
||||
@ -24,6 +24,16 @@ font8x16.o optional std8x16font \
|
||||
no-implicit-rule before-depend \
|
||||
clean "${STD8X16FONT}-8x16 font8x16.c"
|
||||
#
|
||||
atkbdmap.h optional atkbd_dflt_keymap \
|
||||
compile-with "kbdcontrol -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "atkbdmap.h"
|
||||
#
|
||||
ukbdmap.h optional ukbd_dflt_keymap \
|
||||
compile-with "kbdcontrol -L ${UKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > ukbdmap.h" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "ukbdmap.h"
|
||||
#
|
||||
dev/ata/ata-all.c optional ata device-driver
|
||||
dev/ata/atapi-all.c optional ata device-driver
|
||||
dev/ata/ata-disk.c optional atadisk device-driver
|
||||
@ -37,7 +47,7 @@ dev/kbd/atkbd.c optional atkbd device-driver
|
||||
dev/kbd/atkbdc.c optional atkbdc device-driver
|
||||
dev/kbd/kbd.c optional atkbd device-driver
|
||||
dev/kbd/kbd.c optional kbd device-driver
|
||||
#dev/kbd/kbd.c optional ukbd device-driver
|
||||
dev/kbd/kbd.c optional ukbd device-driver
|
||||
dev/syscons/syscons.c optional sc device-driver
|
||||
dev/syscons/scvidctl.c optional sc device-driver
|
||||
dev/syscons/scvesactl.c optional sc device-driver
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: options.alpha,v 1.8 1999/01/18 20:26:50 gallatin Exp $
|
||||
# $Id: options.alpha,v 1.9 1999/01/23 16:53:26 dfr Exp $
|
||||
|
||||
EV5 opt_global.h
|
||||
EV4 opt_global.h
|
||||
@ -41,7 +41,11 @@ PSM_DEBUG opt_psm.h
|
||||
# Fb options
|
||||
FB_INSTALL_CDEV opt_fb.h
|
||||
|
||||
# Atkbd options
|
||||
ATKBD_DFLT_KEYMAP opt_atkbd.h
|
||||
|
||||
# Kbd options
|
||||
KBD_DISABLE_KEYMAP_LOAD opt_kbd.h
|
||||
KBD_INSTALL_CDEV opt_kbd.h
|
||||
KBD_MAXRETRY opt_kbd.h
|
||||
KBD_MAXWAIT opt_kbd.h
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: options.i386,v 1.107 1999/03/09 20:20:02 phk Exp $
|
||||
# $Id: options.i386,v 1.108 1999/03/10 10:11:42 julian Exp $
|
||||
|
||||
DISABLE_PSE
|
||||
IDE_DELAY
|
||||
@ -89,6 +89,10 @@ PSM_DEBUG opt_psm.h
|
||||
|
||||
PCIC_RESUME_RESET opt_pcic.h
|
||||
|
||||
ATKBD_DFLT_KEYMAP opt_atkbd.h
|
||||
UKBD_DFLT_KEYMAP opt_ukbd.h
|
||||
|
||||
KBD_DISABLE_KEYMAP_LOAD opt_kbd.h
|
||||
KBD_INSTALL_CDEV opt_kbd.h
|
||||
KBD_MAXRETRY opt_kbd.h
|
||||
KBD_MAXWAIT opt_kbd.h
|
||||
|
@ -23,11 +23,12 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: atkbd.c,v 1.3 1999/01/19 11:31:14 yokota Exp $
|
||||
* $Id: atkbd.c,v 1.4 1999/01/28 10:55:55 yokota Exp $
|
||||
*/
|
||||
|
||||
#include "atkbd.h"
|
||||
#include "opt_kbd.h"
|
||||
#include "opt_atkbd.h"
|
||||
#include "opt_devfs.h"
|
||||
|
||||
#if NATKBD > 0
|
||||
@ -47,8 +48,11 @@
|
||||
|
||||
#ifndef __i386__
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <isa/isareg.h>
|
||||
|
||||
extern devclass_t atkbd_devclass;
|
||||
|
||||
#define ATKBD_SOFTC(unit) \
|
||||
((atkbd_softc_t *)devclass_get_softc(atkbd_devclass, unit))
|
||||
|
||||
@ -61,7 +65,8 @@ extern struct isa_driver atkbddriver; /* XXX: a kludge; see below */
|
||||
|
||||
static atkbd_softc_t *atkbd_softc[NATKBD];
|
||||
|
||||
#define ATKBD_SOFTC(unit) atkbd_softc[(unit)]
|
||||
#define ATKBD_SOFTC(unit) \
|
||||
(((unit) >= NATKBD) ? NULL : atkbd_softc[(unit)])
|
||||
|
||||
#endif /* __i386__ */
|
||||
|
||||
@ -107,13 +112,11 @@ atkbd_softc_t
|
||||
#endif /* __i386__ */
|
||||
|
||||
int
|
||||
atkbd_probe_unit(int unit, atkbd_softc_t *sc, int port, int irq, int flags)
|
||||
atkbd_probe_unit(int unit, int port, int irq, int flags)
|
||||
{
|
||||
keyboard_switch_t *sw;
|
||||
int args[2];
|
||||
|
||||
if (sc->flags & ATKBD_ATTACHED)
|
||||
return 0;
|
||||
int error;
|
||||
|
||||
sw = kbd_get_switch(ATKBD_DRIVER_NAME);
|
||||
if (sw == NULL)
|
||||
@ -121,13 +124,17 @@ atkbd_probe_unit(int unit, atkbd_softc_t *sc, int port, int irq, int flags)
|
||||
|
||||
args[0] = port;
|
||||
args[1] = irq;
|
||||
return (*sw->probe)(unit, &sc->kbd, args, flags);
|
||||
error = (*sw->probe)(unit, args, flags);
|
||||
if (error)
|
||||
return error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
atkbd_attach_unit(int unit, atkbd_softc_t *sc)
|
||||
atkbd_attach_unit(int unit, atkbd_softc_t *sc, int port, int irq, int flags)
|
||||
{
|
||||
keyboard_switch_t *sw;
|
||||
int args[2];
|
||||
int error;
|
||||
|
||||
if (sc->flags & ATKBD_ATTACHED)
|
||||
@ -138,9 +145,15 @@ atkbd_attach_unit(int unit, atkbd_softc_t *sc)
|
||||
return ENXIO;
|
||||
|
||||
/* reset, initialize and enable the device */
|
||||
error = (*sw->init)(sc->kbd);
|
||||
args[0] = port;
|
||||
args[1] = irq;
|
||||
sc->kbd = NULL;
|
||||
error = (*sw->probe)(unit, args, flags);
|
||||
if (error)
|
||||
return ENXIO;
|
||||
return error;
|
||||
error = (*sw->init)(unit, &sc->kbd, args, flags);
|
||||
if (error)
|
||||
return error;
|
||||
(*sw->enable)(sc->kbd);
|
||||
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
@ -194,7 +207,7 @@ atkbd_timeout(void *arg)
|
||||
*/
|
||||
(*kbdsw[kbd->kb_index]->lock)(kbd, FALSE);
|
||||
if ((*kbdsw[kbd->kb_index]->check_char)(kbd))
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd);
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
|
||||
}
|
||||
splx(s);
|
||||
timeout(atkbd_timeout, arg, hz/10);
|
||||
@ -208,10 +221,9 @@ static int
|
||||
atkbdopen(dev_t dev, int flag, int mode, struct proc *p)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
int unit;
|
||||
|
||||
unit = ATKBD_UNIT(dev);
|
||||
if ((unit >= NATKBD) || ((sc = ATKBD_SOFTC(unit)) == NULL))
|
||||
sc = ATKBD_SOFTC(ATKBD_UNIT(dev));
|
||||
if (sc == NULL)
|
||||
return ENXIO;
|
||||
if (mode & (FWRITE | O_CREAT | O_APPEND | O_TRUNC))
|
||||
return ENODEV;
|
||||
@ -274,6 +286,7 @@ typedef struct atkbd_state {
|
||||
int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */
|
||||
int ks_flags; /* flags */
|
||||
#define COMPOSE (1 << 0)
|
||||
int ks_polling;
|
||||
int ks_state; /* shift/lock key state */
|
||||
int ks_accents; /* accent key index (> 0) */
|
||||
u_int ks_composed_char; /* composed char code (> 0) */
|
||||
@ -298,6 +311,7 @@ static kbd_lock_t atkbd_lock;
|
||||
static kbd_clear_state_t atkbd_clear_state;
|
||||
static kbd_get_state_t atkbd_get_state;
|
||||
static kbd_set_state_t atkbd_set_state;
|
||||
static kbd_poll_mode_t atkbd_poll;
|
||||
|
||||
keyboard_switch_t atkbdsw = {
|
||||
atkbd_probe,
|
||||
@ -317,6 +331,7 @@ keyboard_switch_t atkbdsw = {
|
||||
atkbd_get_state,
|
||||
atkbd_set_state,
|
||||
genkbd_get_fkeystr,
|
||||
atkbd_poll,
|
||||
genkbd_diag,
|
||||
};
|
||||
|
||||
@ -329,10 +344,15 @@ static int probe_keyboard(KBDC kbdc, int flags);
|
||||
static int init_keyboard(KBDC kbdc, int *type, int flags);
|
||||
static int write_kbd(KBDC kbdc, int command, int data);
|
||||
static int get_kbd_id(KBDC kbdc);
|
||||
static int typematic(int delay, int rate);
|
||||
|
||||
/* local variables */
|
||||
|
||||
/* the initial key map, accent map and fkey strings */
|
||||
#ifdef ATKBD_DFLT_KEYMAP
|
||||
#define KBD_DFLT_KEYMAP
|
||||
#include "atkbdmap.h"
|
||||
#endif
|
||||
#include <dev/kbd/kbdtables.h>
|
||||
|
||||
/* structures for the default keyboard */
|
||||
@ -355,15 +375,26 @@ static int
|
||||
atkbd_configure(int flags)
|
||||
{
|
||||
keyboard_t *kbd;
|
||||
KBDC kbdc;
|
||||
int arg[2];
|
||||
#ifdef __i386__
|
||||
struct isa_device *dev;
|
||||
int i;
|
||||
|
||||
/* XXX: a kludge to obtain the device configuration flags */
|
||||
dev = find_isadev(isa_devtab_tty, &atkbddriver, 0);
|
||||
if (dev != NULL)
|
||||
if (dev != NULL) {
|
||||
flags |= dev->id_flags;
|
||||
/* if the driver is disabled, unregister the keyboard if any */
|
||||
if (!dev->id_enabled) {
|
||||
i = kbd_find_keyboard(ATKBD_DRIVER_NAME, ATKBD_DEFAULT);
|
||||
if (i >= 0) {
|
||||
kbd = kbd_get_keyboard(i);
|
||||
kbd_unregister(kbd);
|
||||
kbd->kb_flags &= ~KB_REGISTERED;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* probe the keyboard controller */
|
||||
@ -372,34 +403,44 @@ atkbd_configure(int flags)
|
||||
/* probe the default keyboard */
|
||||
arg[0] = -1;
|
||||
arg[1] = -1;
|
||||
if (atkbd_probe(ATKBD_DEFAULT, &kbd, arg, flags))
|
||||
kbd = NULL;
|
||||
if (atkbd_probe(ATKBD_DEFAULT, arg, flags))
|
||||
return 0;
|
||||
if (atkbd_init(ATKBD_DEFAULT, &kbd, arg, flags))
|
||||
return 0;
|
||||
|
||||
/* initialize it */
|
||||
kbdc = ((atkbd_state_t *)kbd->kb_data)->kbdc;
|
||||
if (!(flags & KB_CONF_PROBE_ONLY) && !KBD_IS_INITIALIZED(kbd)) {
|
||||
if (KBD_HAS_DEVICE(kbd)
|
||||
&& init_keyboard(kbdc, &kbd->kb_type, flags)
|
||||
&& (flags & KB_CONF_FAIL_IF_NO_KBD))
|
||||
return 0;
|
||||
KBD_INIT_DONE(kbd);
|
||||
}
|
||||
|
||||
/* and register */
|
||||
if (!KBD_IS_CONFIGURED(kbd)) {
|
||||
if (kbd_register(kbd) < 0)
|
||||
return 0;
|
||||
KBD_CONFIG_DONE(kbd);
|
||||
}
|
||||
|
||||
return 1; /* return the number of found keyboards */
|
||||
/* return the number of found keyboards */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* low-level functions */
|
||||
|
||||
/* initialize the keyboard_t structure and try to detect a keyboard */
|
||||
/* detect a keyboard */
|
||||
static int
|
||||
atkbd_probe(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
atkbd_probe(int unit, void *arg, int flags)
|
||||
{
|
||||
KBDC kbdc;
|
||||
int *data = (int *)arg;
|
||||
|
||||
/* XXX */
|
||||
if (unit == ATKBD_DEFAULT) {
|
||||
if (KBD_IS_PROBED(&default_kbd))
|
||||
return 0;
|
||||
}
|
||||
|
||||
kbdc = kbdc_open(data[0]);
|
||||
if (kbdc == NULL)
|
||||
return ENXIO;
|
||||
if (probe_keyboard(kbdc, flags)) {
|
||||
if (flags & KB_CONF_FAIL_IF_NO_KBD)
|
||||
return ENXIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* reset and initialize the device */
|
||||
static int
|
||||
atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
{
|
||||
keyboard_t *kbd;
|
||||
atkbd_state_t *state;
|
||||
@ -407,13 +448,12 @@ atkbd_probe(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
accentmap_t *accmap;
|
||||
fkeytab_t *fkeymap;
|
||||
int fkeymap_size;
|
||||
KBDC kbdc;
|
||||
int *data = (int *)arg;
|
||||
|
||||
/* XXX */
|
||||
if (unit == ATKBD_DEFAULT) {
|
||||
*kbdp = kbd = &default_kbd;
|
||||
if (KBD_IS_PROBED(kbd))
|
||||
if (KBD_IS_INITIALIZED(kbd) && KBD_IS_CONFIGURED(kbd))
|
||||
return 0;
|
||||
state = &default_kbd_state;
|
||||
keymap = &default_keymap;
|
||||
@ -445,7 +485,7 @@ atkbd_probe(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
return ENOMEM;
|
||||
}
|
||||
bzero(state, sizeof(*state));
|
||||
} else if (KBD_IS_PROBED(*kbdp)) {
|
||||
} else if (KBD_IS_INITIALIZED(*kbdp) && KBD_IS_CONFIGURED(*kbdp)) {
|
||||
return 0;
|
||||
} else {
|
||||
kbd = *kbdp;
|
||||
@ -457,54 +497,39 @@ atkbd_probe(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
fkeymap_size = kbd->kb_fkeytab_size;
|
||||
}
|
||||
|
||||
state->kbdc = kbdc = kbdc_open(data[0]);
|
||||
if (kbdc == NULL)
|
||||
return ENXIO;
|
||||
kbd_init_struct(kbd, ATKBD_DRIVER_NAME, KB_OTHER, unit, flags, data[0],
|
||||
IO_KBDSIZE);
|
||||
bcopy(&key_map, keymap, sizeof(key_map));
|
||||
bcopy(&accent_map, accmap, sizeof(accent_map));
|
||||
bcopy(fkey_tab, fkeymap,
|
||||
imin(fkeymap_size*sizeof(fkeymap[0]), sizeof(fkey_tab)));
|
||||
kbd_set_maps(kbd, keymap, accmap, fkeymap, fkeymap_size);
|
||||
kbd->kb_data = (void *)state;
|
||||
|
||||
if (probe_keyboard(kbdc, flags)) {
|
||||
if (flags & KB_CONF_FAIL_IF_NO_KBD)
|
||||
if (!KBD_IS_PROBED(kbd)) {
|
||||
state->kbdc = kbdc_open(data[0]);
|
||||
if (state->kbdc == NULL)
|
||||
return ENXIO;
|
||||
} else {
|
||||
KBD_FOUND_DEVICE(kbd);
|
||||
kbd_init_struct(kbd, ATKBD_DRIVER_NAME, KB_OTHER, unit, flags,
|
||||
data[0], IO_KBDSIZE);
|
||||
bcopy(&key_map, keymap, sizeof(key_map));
|
||||
bcopy(&accent_map, accmap, sizeof(accent_map));
|
||||
bcopy(fkey_tab, fkeymap,
|
||||
imin(fkeymap_size*sizeof(fkeymap[0]), sizeof(fkey_tab)));
|
||||
kbd_set_maps(kbd, keymap, accmap, fkeymap, fkeymap_size);
|
||||
kbd->kb_data = (void *)state;
|
||||
|
||||
if (probe_keyboard(state->kbdc, flags)) { /* shouldn't happen */
|
||||
if (flags & KB_CONF_FAIL_IF_NO_KBD)
|
||||
return ENXIO;
|
||||
} else {
|
||||
KBD_FOUND_DEVICE(kbd);
|
||||
}
|
||||
atkbd_clear_state(kbd);
|
||||
state->ks_mode = K_XLATE;
|
||||
/*
|
||||
* FIXME: set the initial value for lock keys in ks_state
|
||||
* according to the BIOS data?
|
||||
*/
|
||||
KBD_PROBE_DONE(kbd);
|
||||
}
|
||||
atkbd_clear_state(kbd);
|
||||
state->ks_mode = K_XLATE;
|
||||
/*
|
||||
* FIXME: set the initial value for lock keys in ks_state
|
||||
* according to the BIOS data?
|
||||
*/
|
||||
|
||||
KBD_PROBE_DONE(kbd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* reset and initialize the device */
|
||||
static int
|
||||
atkbd_init(keyboard_t *kbd)
|
||||
{
|
||||
KBDC kbdc;
|
||||
|
||||
if ((kbd == NULL) || !KBD_IS_PROBED(kbd))
|
||||
return ENXIO; /* shouldn't happen */
|
||||
kbdc = ((atkbd_state_t *)kbd->kb_data)->kbdc;
|
||||
if (kbdc == NULL)
|
||||
return ENXIO; /* shouldn't happen */
|
||||
|
||||
if (!KBD_IS_INITIALIZED(kbd)) {
|
||||
if (!KBD_IS_INITIALIZED(kbd) && !(flags & KB_CONF_PROBE_ONLY)) {
|
||||
if (KBD_HAS_DEVICE(kbd)
|
||||
&& init_keyboard(kbdc, &kbd->kb_type, kbd->kb_config)
|
||||
&& (kbd->kb_config & KB_CONF_FAIL_IF_NO_KBD))
|
||||
&& init_keyboard(state->kbdc, &kbd->kb_type, kbd->kb_config)
|
||||
&& (kbd->kb_config & KB_CONF_FAIL_IF_NO_KBD))
|
||||
return ENXIO;
|
||||
atkbd_ioctl(kbd, KDSETLED,
|
||||
(caddr_t)&((atkbd_state_t *)(kbd->kb_data))->ks_state);
|
||||
atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
|
||||
KBD_INIT_DONE(kbd);
|
||||
}
|
||||
if (!KBD_IS_CONFIGURED(kbd)) {
|
||||
@ -526,7 +551,7 @@ atkbd_term(keyboard_t *kbd)
|
||||
|
||||
/* keyboard interrupt routine */
|
||||
static int
|
||||
atkbd_intr(keyboard_t *kbd)
|
||||
atkbd_intr(keyboard_t *kbd, void *arg)
|
||||
{
|
||||
atkbd_state_t *state;
|
||||
int c;
|
||||
@ -954,12 +979,18 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
/* set LEDs and quit */
|
||||
return atkbd_ioctl(kbd, KDSETLED, arg);
|
||||
|
||||
case KDSETRAD: /* set keyboard repeat rate */
|
||||
case KDSETREPEAT: /* set keyboard repeat rate (new interface) */
|
||||
splx(s);
|
||||
if (!KBD_HAS_DEVICE(kbd))
|
||||
return 0;
|
||||
return write_kbd(state->kbdc, KBDC_SET_TYPEMATIC,
|
||||
*(int *)arg);
|
||||
i = typematic(((int *)arg)[0], ((int *)arg)[1]);
|
||||
return write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, i);
|
||||
|
||||
case KDSETRAD: /* set keyboard repeat rate (old interface) */
|
||||
splx(s);
|
||||
if (!KBD_HAS_DEVICE(kbd))
|
||||
return 0;
|
||||
return write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, *(int *)arg);
|
||||
|
||||
case PIO_KEYMAP: /* set keyboard translation table */
|
||||
case PIO_KEYMAPENT: /* set keyboard translation table entry */
|
||||
@ -990,6 +1021,7 @@ atkbd_clear_state(keyboard_t *kbd)
|
||||
|
||||
state = (atkbd_state_t *)kbd->kb_data;
|
||||
state->ks_flags = 0;
|
||||
state->ks_polling = 0;
|
||||
state->ks_state &= LOCK_MASK; /* preserve locking key state */
|
||||
state->ks_accents = 0;
|
||||
state->ks_composed_char = 0;
|
||||
@ -1023,6 +1055,22 @@ atkbd_set_state(keyboard_t *kbd, void *buf, size_t len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
atkbd_poll(keyboard_t *kbd, int on)
|
||||
{
|
||||
atkbd_state_t *state;
|
||||
int s;
|
||||
|
||||
state = (atkbd_state_t *)kbd->kb_data;
|
||||
s = spltty();
|
||||
if (on)
|
||||
++state->ks_polling;
|
||||
else
|
||||
--state->ks_polling;
|
||||
splx(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
|
||||
static int
|
||||
@ -1347,4 +1395,28 @@ get_kbd_id(KBDC kbdc)
|
||||
return ((id2 << 8) | id1);
|
||||
}
|
||||
|
||||
static int
|
||||
typematic(int delay, int rate)
|
||||
{
|
||||
static int delays[] = { 250, 500, 750, 1000 };
|
||||
static int rates[] = { 34, 38, 42, 46, 50, 55, 59, 63,
|
||||
68, 76, 84, 92, 100, 110, 118, 126,
|
||||
136, 152, 168, 184, 200, 220, 236, 252,
|
||||
272, 304, 336, 368, 400, 440, 472, 504 };
|
||||
int value;
|
||||
int i;
|
||||
|
||||
for (i = sizeof(delays)/sizeof(delays[0]) - 1; i > 0; --i) {
|
||||
if (delay >= delays[i])
|
||||
break;
|
||||
}
|
||||
value = i << 5;
|
||||
for (i = sizeof(rates)/sizeof(rates[0]) - 1; i > 0; --i) {
|
||||
if (rate >= rates[i])
|
||||
break;
|
||||
}
|
||||
value |= i;
|
||||
return value;
|
||||
}
|
||||
|
||||
#endif /* NATKBD > 0 */
|
||||
|
@ -23,7 +23,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: $
|
||||
* $Id: atkbd_isa.c,v 1.1 1999/01/23 16:53:27 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "atkbd.h"
|
||||
@ -52,6 +52,7 @@ devclass_t atkbd_devclass;
|
||||
|
||||
static int atkbdprobe(device_t dev);
|
||||
static int atkbdattach(device_t dev);
|
||||
static void atkbd_isa_intr(void *arg);
|
||||
|
||||
static device_method_t atkbd_methods[] = {
|
||||
DEVMETHOD(device_probe, atkbdprobe),
|
||||
@ -69,13 +70,10 @@ static driver_t atkbd_driver = {
|
||||
static int
|
||||
atkbdprobe(device_t dev)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
u_long port;
|
||||
u_long irq;
|
||||
u_long flags;
|
||||
|
||||
sc = (atkbd_softc_t *)device_get_softc(dev);
|
||||
|
||||
device_set_desc(dev, "AT Keyboard");
|
||||
|
||||
/* obtain parameters */
|
||||
@ -84,14 +82,16 @@ atkbdprobe(device_t dev)
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
|
||||
|
||||
/* probe the device */
|
||||
return atkbd_probe_unit(device_get_unit(dev), sc, port, irq, flags);
|
||||
return atkbd_probe_unit(device_get_unit(dev), port, irq, flags);
|
||||
}
|
||||
|
||||
static int
|
||||
atkbdattach(device_t dev)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
u_long port;
|
||||
u_long irq;
|
||||
u_long flags;
|
||||
struct resource *res;
|
||||
void *ih;
|
||||
int zero = 0;
|
||||
@ -99,21 +99,32 @@ atkbdattach(device_t dev)
|
||||
|
||||
sc = (atkbd_softc_t *)device_get_softc(dev);
|
||||
|
||||
error = atkbd_attach_unit(device_get_unit(dev), sc);
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
|
||||
|
||||
error = atkbd_attach_unit(device_get_unit(dev), sc, port, irq, flags);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* declare our interrupt handler */
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
|
||||
res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
|
||||
RF_SHAREABLE | RF_ACTIVE);
|
||||
BUS_SETUP_INTR(device_get_parent(dev), dev, res,
|
||||
(driver_intr_t *) kbdsw[sc->kbd->kb_index]->intr, sc->kbd,
|
||||
BUS_SETUP_INTR(device_get_parent(dev), dev, res, atkbd_isa_intr, sc,
|
||||
&ih);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
atkbd_isa_intr(void *arg)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
|
||||
sc = (atkbd_softc_t *)arg;
|
||||
(*kbdsw[sc->kbd->kb_index]->intr)(sc->kbd, NULL);
|
||||
}
|
||||
|
||||
DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
|
||||
|
||||
#endif /* NATKBD > 0 */
|
||||
|
@ -23,7 +23,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: $
|
||||
* $Id: atkbd_isa.c,v 1.1 1999/01/23 16:53:27 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "atkbd.h"
|
||||
@ -52,6 +52,7 @@ devclass_t atkbd_devclass;
|
||||
|
||||
static int atkbdprobe(device_t dev);
|
||||
static int atkbdattach(device_t dev);
|
||||
static void atkbd_isa_intr(void *arg);
|
||||
|
||||
static device_method_t atkbd_methods[] = {
|
||||
DEVMETHOD(device_probe, atkbdprobe),
|
||||
@ -69,13 +70,10 @@ static driver_t atkbd_driver = {
|
||||
static int
|
||||
atkbdprobe(device_t dev)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
u_long port;
|
||||
u_long irq;
|
||||
u_long flags;
|
||||
|
||||
sc = (atkbd_softc_t *)device_get_softc(dev);
|
||||
|
||||
device_set_desc(dev, "AT Keyboard");
|
||||
|
||||
/* obtain parameters */
|
||||
@ -84,14 +82,16 @@ atkbdprobe(device_t dev)
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
|
||||
|
||||
/* probe the device */
|
||||
return atkbd_probe_unit(device_get_unit(dev), sc, port, irq, flags);
|
||||
return atkbd_probe_unit(device_get_unit(dev), port, irq, flags);
|
||||
}
|
||||
|
||||
static int
|
||||
atkbdattach(device_t dev)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
u_long port;
|
||||
u_long irq;
|
||||
u_long flags;
|
||||
struct resource *res;
|
||||
void *ih;
|
||||
int zero = 0;
|
||||
@ -99,21 +99,32 @@ atkbdattach(device_t dev)
|
||||
|
||||
sc = (atkbd_softc_t *)device_get_softc(dev);
|
||||
|
||||
error = atkbd_attach_unit(device_get_unit(dev), sc);
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
|
||||
|
||||
error = atkbd_attach_unit(device_get_unit(dev), sc, port, irq, flags);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* declare our interrupt handler */
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
|
||||
res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
|
||||
RF_SHAREABLE | RF_ACTIVE);
|
||||
BUS_SETUP_INTR(device_get_parent(dev), dev, res,
|
||||
(driver_intr_t *) kbdsw[sc->kbd->kb_index]->intr, sc->kbd,
|
||||
BUS_SETUP_INTR(device_get_parent(dev), dev, res, atkbd_isa_intr, sc,
|
||||
&ih);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
atkbd_isa_intr(void *arg)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
|
||||
sc = (atkbd_softc_t *)arg;
|
||||
(*kbdsw[sc->kbd->kb_index]->intr)(sc->kbd, NULL);
|
||||
}
|
||||
|
||||
DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
|
||||
|
||||
#endif /* NATKBD > 0 */
|
||||
|
@ -23,7 +23,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: $
|
||||
* $Id: atkbdreg.h,v 1.1 1999/01/09 02:44:50 yokota Exp $
|
||||
*/
|
||||
|
||||
#ifndef _DEV_KBD_ATKBDREG_H_
|
||||
@ -52,9 +52,9 @@ typedef struct atkbd_softc {
|
||||
#ifdef __i386__
|
||||
atkbd_softc_t *atkbd_get_softc(int unit);
|
||||
#endif
|
||||
int atkbd_probe_unit(int unit, atkbd_softc_t *sc,
|
||||
int atkbd_probe_unit(int unit, int port, int irq, int flags);
|
||||
int atkbd_attach_unit(int unit, atkbd_softc_t *sc,
|
||||
int port, int irq, int flags);
|
||||
int atkbd_attach_unit(int unit, atkbd_softc_t *sc);
|
||||
|
||||
#endif /* KERNEL */
|
||||
|
||||
|
@ -23,11 +23,12 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: atkbd.c,v 1.3 1999/01/19 11:31:14 yokota Exp $
|
||||
* $Id: atkbd.c,v 1.4 1999/01/28 10:55:55 yokota Exp $
|
||||
*/
|
||||
|
||||
#include "atkbd.h"
|
||||
#include "opt_kbd.h"
|
||||
#include "opt_atkbd.h"
|
||||
#include "opt_devfs.h"
|
||||
|
||||
#if NATKBD > 0
|
||||
@ -47,8 +48,11 @@
|
||||
|
||||
#ifndef __i386__
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <isa/isareg.h>
|
||||
|
||||
extern devclass_t atkbd_devclass;
|
||||
|
||||
#define ATKBD_SOFTC(unit) \
|
||||
((atkbd_softc_t *)devclass_get_softc(atkbd_devclass, unit))
|
||||
|
||||
@ -61,7 +65,8 @@ extern struct isa_driver atkbddriver; /* XXX: a kludge; see below */
|
||||
|
||||
static atkbd_softc_t *atkbd_softc[NATKBD];
|
||||
|
||||
#define ATKBD_SOFTC(unit) atkbd_softc[(unit)]
|
||||
#define ATKBD_SOFTC(unit) \
|
||||
(((unit) >= NATKBD) ? NULL : atkbd_softc[(unit)])
|
||||
|
||||
#endif /* __i386__ */
|
||||
|
||||
@ -107,13 +112,11 @@ atkbd_softc_t
|
||||
#endif /* __i386__ */
|
||||
|
||||
int
|
||||
atkbd_probe_unit(int unit, atkbd_softc_t *sc, int port, int irq, int flags)
|
||||
atkbd_probe_unit(int unit, int port, int irq, int flags)
|
||||
{
|
||||
keyboard_switch_t *sw;
|
||||
int args[2];
|
||||
|
||||
if (sc->flags & ATKBD_ATTACHED)
|
||||
return 0;
|
||||
int error;
|
||||
|
||||
sw = kbd_get_switch(ATKBD_DRIVER_NAME);
|
||||
if (sw == NULL)
|
||||
@ -121,13 +124,17 @@ atkbd_probe_unit(int unit, atkbd_softc_t *sc, int port, int irq, int flags)
|
||||
|
||||
args[0] = port;
|
||||
args[1] = irq;
|
||||
return (*sw->probe)(unit, &sc->kbd, args, flags);
|
||||
error = (*sw->probe)(unit, args, flags);
|
||||
if (error)
|
||||
return error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
atkbd_attach_unit(int unit, atkbd_softc_t *sc)
|
||||
atkbd_attach_unit(int unit, atkbd_softc_t *sc, int port, int irq, int flags)
|
||||
{
|
||||
keyboard_switch_t *sw;
|
||||
int args[2];
|
||||
int error;
|
||||
|
||||
if (sc->flags & ATKBD_ATTACHED)
|
||||
@ -138,9 +145,15 @@ atkbd_attach_unit(int unit, atkbd_softc_t *sc)
|
||||
return ENXIO;
|
||||
|
||||
/* reset, initialize and enable the device */
|
||||
error = (*sw->init)(sc->kbd);
|
||||
args[0] = port;
|
||||
args[1] = irq;
|
||||
sc->kbd = NULL;
|
||||
error = (*sw->probe)(unit, args, flags);
|
||||
if (error)
|
||||
return ENXIO;
|
||||
return error;
|
||||
error = (*sw->init)(unit, &sc->kbd, args, flags);
|
||||
if (error)
|
||||
return error;
|
||||
(*sw->enable)(sc->kbd);
|
||||
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
@ -194,7 +207,7 @@ atkbd_timeout(void *arg)
|
||||
*/
|
||||
(*kbdsw[kbd->kb_index]->lock)(kbd, FALSE);
|
||||
if ((*kbdsw[kbd->kb_index]->check_char)(kbd))
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd);
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
|
||||
}
|
||||
splx(s);
|
||||
timeout(atkbd_timeout, arg, hz/10);
|
||||
@ -208,10 +221,9 @@ static int
|
||||
atkbdopen(dev_t dev, int flag, int mode, struct proc *p)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
int unit;
|
||||
|
||||
unit = ATKBD_UNIT(dev);
|
||||
if ((unit >= NATKBD) || ((sc = ATKBD_SOFTC(unit)) == NULL))
|
||||
sc = ATKBD_SOFTC(ATKBD_UNIT(dev));
|
||||
if (sc == NULL)
|
||||
return ENXIO;
|
||||
if (mode & (FWRITE | O_CREAT | O_APPEND | O_TRUNC))
|
||||
return ENODEV;
|
||||
@ -274,6 +286,7 @@ typedef struct atkbd_state {
|
||||
int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */
|
||||
int ks_flags; /* flags */
|
||||
#define COMPOSE (1 << 0)
|
||||
int ks_polling;
|
||||
int ks_state; /* shift/lock key state */
|
||||
int ks_accents; /* accent key index (> 0) */
|
||||
u_int ks_composed_char; /* composed char code (> 0) */
|
||||
@ -298,6 +311,7 @@ static kbd_lock_t atkbd_lock;
|
||||
static kbd_clear_state_t atkbd_clear_state;
|
||||
static kbd_get_state_t atkbd_get_state;
|
||||
static kbd_set_state_t atkbd_set_state;
|
||||
static kbd_poll_mode_t atkbd_poll;
|
||||
|
||||
keyboard_switch_t atkbdsw = {
|
||||
atkbd_probe,
|
||||
@ -317,6 +331,7 @@ keyboard_switch_t atkbdsw = {
|
||||
atkbd_get_state,
|
||||
atkbd_set_state,
|
||||
genkbd_get_fkeystr,
|
||||
atkbd_poll,
|
||||
genkbd_diag,
|
||||
};
|
||||
|
||||
@ -329,10 +344,15 @@ static int probe_keyboard(KBDC kbdc, int flags);
|
||||
static int init_keyboard(KBDC kbdc, int *type, int flags);
|
||||
static int write_kbd(KBDC kbdc, int command, int data);
|
||||
static int get_kbd_id(KBDC kbdc);
|
||||
static int typematic(int delay, int rate);
|
||||
|
||||
/* local variables */
|
||||
|
||||
/* the initial key map, accent map and fkey strings */
|
||||
#ifdef ATKBD_DFLT_KEYMAP
|
||||
#define KBD_DFLT_KEYMAP
|
||||
#include "atkbdmap.h"
|
||||
#endif
|
||||
#include <dev/kbd/kbdtables.h>
|
||||
|
||||
/* structures for the default keyboard */
|
||||
@ -355,15 +375,26 @@ static int
|
||||
atkbd_configure(int flags)
|
||||
{
|
||||
keyboard_t *kbd;
|
||||
KBDC kbdc;
|
||||
int arg[2];
|
||||
#ifdef __i386__
|
||||
struct isa_device *dev;
|
||||
int i;
|
||||
|
||||
/* XXX: a kludge to obtain the device configuration flags */
|
||||
dev = find_isadev(isa_devtab_tty, &atkbddriver, 0);
|
||||
if (dev != NULL)
|
||||
if (dev != NULL) {
|
||||
flags |= dev->id_flags;
|
||||
/* if the driver is disabled, unregister the keyboard if any */
|
||||
if (!dev->id_enabled) {
|
||||
i = kbd_find_keyboard(ATKBD_DRIVER_NAME, ATKBD_DEFAULT);
|
||||
if (i >= 0) {
|
||||
kbd = kbd_get_keyboard(i);
|
||||
kbd_unregister(kbd);
|
||||
kbd->kb_flags &= ~KB_REGISTERED;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* probe the keyboard controller */
|
||||
@ -372,34 +403,44 @@ atkbd_configure(int flags)
|
||||
/* probe the default keyboard */
|
||||
arg[0] = -1;
|
||||
arg[1] = -1;
|
||||
if (atkbd_probe(ATKBD_DEFAULT, &kbd, arg, flags))
|
||||
kbd = NULL;
|
||||
if (atkbd_probe(ATKBD_DEFAULT, arg, flags))
|
||||
return 0;
|
||||
if (atkbd_init(ATKBD_DEFAULT, &kbd, arg, flags))
|
||||
return 0;
|
||||
|
||||
/* initialize it */
|
||||
kbdc = ((atkbd_state_t *)kbd->kb_data)->kbdc;
|
||||
if (!(flags & KB_CONF_PROBE_ONLY) && !KBD_IS_INITIALIZED(kbd)) {
|
||||
if (KBD_HAS_DEVICE(kbd)
|
||||
&& init_keyboard(kbdc, &kbd->kb_type, flags)
|
||||
&& (flags & KB_CONF_FAIL_IF_NO_KBD))
|
||||
return 0;
|
||||
KBD_INIT_DONE(kbd);
|
||||
}
|
||||
|
||||
/* and register */
|
||||
if (!KBD_IS_CONFIGURED(kbd)) {
|
||||
if (kbd_register(kbd) < 0)
|
||||
return 0;
|
||||
KBD_CONFIG_DONE(kbd);
|
||||
}
|
||||
|
||||
return 1; /* return the number of found keyboards */
|
||||
/* return the number of found keyboards */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* low-level functions */
|
||||
|
||||
/* initialize the keyboard_t structure and try to detect a keyboard */
|
||||
/* detect a keyboard */
|
||||
static int
|
||||
atkbd_probe(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
atkbd_probe(int unit, void *arg, int flags)
|
||||
{
|
||||
KBDC kbdc;
|
||||
int *data = (int *)arg;
|
||||
|
||||
/* XXX */
|
||||
if (unit == ATKBD_DEFAULT) {
|
||||
if (KBD_IS_PROBED(&default_kbd))
|
||||
return 0;
|
||||
}
|
||||
|
||||
kbdc = kbdc_open(data[0]);
|
||||
if (kbdc == NULL)
|
||||
return ENXIO;
|
||||
if (probe_keyboard(kbdc, flags)) {
|
||||
if (flags & KB_CONF_FAIL_IF_NO_KBD)
|
||||
return ENXIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* reset and initialize the device */
|
||||
static int
|
||||
atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
{
|
||||
keyboard_t *kbd;
|
||||
atkbd_state_t *state;
|
||||
@ -407,13 +448,12 @@ atkbd_probe(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
accentmap_t *accmap;
|
||||
fkeytab_t *fkeymap;
|
||||
int fkeymap_size;
|
||||
KBDC kbdc;
|
||||
int *data = (int *)arg;
|
||||
|
||||
/* XXX */
|
||||
if (unit == ATKBD_DEFAULT) {
|
||||
*kbdp = kbd = &default_kbd;
|
||||
if (KBD_IS_PROBED(kbd))
|
||||
if (KBD_IS_INITIALIZED(kbd) && KBD_IS_CONFIGURED(kbd))
|
||||
return 0;
|
||||
state = &default_kbd_state;
|
||||
keymap = &default_keymap;
|
||||
@ -445,7 +485,7 @@ atkbd_probe(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
return ENOMEM;
|
||||
}
|
||||
bzero(state, sizeof(*state));
|
||||
} else if (KBD_IS_PROBED(*kbdp)) {
|
||||
} else if (KBD_IS_INITIALIZED(*kbdp) && KBD_IS_CONFIGURED(*kbdp)) {
|
||||
return 0;
|
||||
} else {
|
||||
kbd = *kbdp;
|
||||
@ -457,54 +497,39 @@ atkbd_probe(int unit, keyboard_t **kbdp, void *arg, int flags)
|
||||
fkeymap_size = kbd->kb_fkeytab_size;
|
||||
}
|
||||
|
||||
state->kbdc = kbdc = kbdc_open(data[0]);
|
||||
if (kbdc == NULL)
|
||||
return ENXIO;
|
||||
kbd_init_struct(kbd, ATKBD_DRIVER_NAME, KB_OTHER, unit, flags, data[0],
|
||||
IO_KBDSIZE);
|
||||
bcopy(&key_map, keymap, sizeof(key_map));
|
||||
bcopy(&accent_map, accmap, sizeof(accent_map));
|
||||
bcopy(fkey_tab, fkeymap,
|
||||
imin(fkeymap_size*sizeof(fkeymap[0]), sizeof(fkey_tab)));
|
||||
kbd_set_maps(kbd, keymap, accmap, fkeymap, fkeymap_size);
|
||||
kbd->kb_data = (void *)state;
|
||||
|
||||
if (probe_keyboard(kbdc, flags)) {
|
||||
if (flags & KB_CONF_FAIL_IF_NO_KBD)
|
||||
if (!KBD_IS_PROBED(kbd)) {
|
||||
state->kbdc = kbdc_open(data[0]);
|
||||
if (state->kbdc == NULL)
|
||||
return ENXIO;
|
||||
} else {
|
||||
KBD_FOUND_DEVICE(kbd);
|
||||
kbd_init_struct(kbd, ATKBD_DRIVER_NAME, KB_OTHER, unit, flags,
|
||||
data[0], IO_KBDSIZE);
|
||||
bcopy(&key_map, keymap, sizeof(key_map));
|
||||
bcopy(&accent_map, accmap, sizeof(accent_map));
|
||||
bcopy(fkey_tab, fkeymap,
|
||||
imin(fkeymap_size*sizeof(fkeymap[0]), sizeof(fkey_tab)));
|
||||
kbd_set_maps(kbd, keymap, accmap, fkeymap, fkeymap_size);
|
||||
kbd->kb_data = (void *)state;
|
||||
|
||||
if (probe_keyboard(state->kbdc, flags)) { /* shouldn't happen */
|
||||
if (flags & KB_CONF_FAIL_IF_NO_KBD)
|
||||
return ENXIO;
|
||||
} else {
|
||||
KBD_FOUND_DEVICE(kbd);
|
||||
}
|
||||
atkbd_clear_state(kbd);
|
||||
state->ks_mode = K_XLATE;
|
||||
/*
|
||||
* FIXME: set the initial value for lock keys in ks_state
|
||||
* according to the BIOS data?
|
||||
*/
|
||||
KBD_PROBE_DONE(kbd);
|
||||
}
|
||||
atkbd_clear_state(kbd);
|
||||
state->ks_mode = K_XLATE;
|
||||
/*
|
||||
* FIXME: set the initial value for lock keys in ks_state
|
||||
* according to the BIOS data?
|
||||
*/
|
||||
|
||||
KBD_PROBE_DONE(kbd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* reset and initialize the device */
|
||||
static int
|
||||
atkbd_init(keyboard_t *kbd)
|
||||
{
|
||||
KBDC kbdc;
|
||||
|
||||
if ((kbd == NULL) || !KBD_IS_PROBED(kbd))
|
||||
return ENXIO; /* shouldn't happen */
|
||||
kbdc = ((atkbd_state_t *)kbd->kb_data)->kbdc;
|
||||
if (kbdc == NULL)
|
||||
return ENXIO; /* shouldn't happen */
|
||||
|
||||
if (!KBD_IS_INITIALIZED(kbd)) {
|
||||
if (!KBD_IS_INITIALIZED(kbd) && !(flags & KB_CONF_PROBE_ONLY)) {
|
||||
if (KBD_HAS_DEVICE(kbd)
|
||||
&& init_keyboard(kbdc, &kbd->kb_type, kbd->kb_config)
|
||||
&& (kbd->kb_config & KB_CONF_FAIL_IF_NO_KBD))
|
||||
&& init_keyboard(state->kbdc, &kbd->kb_type, kbd->kb_config)
|
||||
&& (kbd->kb_config & KB_CONF_FAIL_IF_NO_KBD))
|
||||
return ENXIO;
|
||||
atkbd_ioctl(kbd, KDSETLED,
|
||||
(caddr_t)&((atkbd_state_t *)(kbd->kb_data))->ks_state);
|
||||
atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
|
||||
KBD_INIT_DONE(kbd);
|
||||
}
|
||||
if (!KBD_IS_CONFIGURED(kbd)) {
|
||||
@ -526,7 +551,7 @@ atkbd_term(keyboard_t *kbd)
|
||||
|
||||
/* keyboard interrupt routine */
|
||||
static int
|
||||
atkbd_intr(keyboard_t *kbd)
|
||||
atkbd_intr(keyboard_t *kbd, void *arg)
|
||||
{
|
||||
atkbd_state_t *state;
|
||||
int c;
|
||||
@ -954,12 +979,18 @@ atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
/* set LEDs and quit */
|
||||
return atkbd_ioctl(kbd, KDSETLED, arg);
|
||||
|
||||
case KDSETRAD: /* set keyboard repeat rate */
|
||||
case KDSETREPEAT: /* set keyboard repeat rate (new interface) */
|
||||
splx(s);
|
||||
if (!KBD_HAS_DEVICE(kbd))
|
||||
return 0;
|
||||
return write_kbd(state->kbdc, KBDC_SET_TYPEMATIC,
|
||||
*(int *)arg);
|
||||
i = typematic(((int *)arg)[0], ((int *)arg)[1]);
|
||||
return write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, i);
|
||||
|
||||
case KDSETRAD: /* set keyboard repeat rate (old interface) */
|
||||
splx(s);
|
||||
if (!KBD_HAS_DEVICE(kbd))
|
||||
return 0;
|
||||
return write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, *(int *)arg);
|
||||
|
||||
case PIO_KEYMAP: /* set keyboard translation table */
|
||||
case PIO_KEYMAPENT: /* set keyboard translation table entry */
|
||||
@ -990,6 +1021,7 @@ atkbd_clear_state(keyboard_t *kbd)
|
||||
|
||||
state = (atkbd_state_t *)kbd->kb_data;
|
||||
state->ks_flags = 0;
|
||||
state->ks_polling = 0;
|
||||
state->ks_state &= LOCK_MASK; /* preserve locking key state */
|
||||
state->ks_accents = 0;
|
||||
state->ks_composed_char = 0;
|
||||
@ -1023,6 +1055,22 @@ atkbd_set_state(keyboard_t *kbd, void *buf, size_t len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
atkbd_poll(keyboard_t *kbd, int on)
|
||||
{
|
||||
atkbd_state_t *state;
|
||||
int s;
|
||||
|
||||
state = (atkbd_state_t *)kbd->kb_data;
|
||||
s = spltty();
|
||||
if (on)
|
||||
++state->ks_polling;
|
||||
else
|
||||
--state->ks_polling;
|
||||
splx(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* local functions */
|
||||
|
||||
static int
|
||||
@ -1347,4 +1395,28 @@ get_kbd_id(KBDC kbdc)
|
||||
return ((id2 << 8) | id1);
|
||||
}
|
||||
|
||||
static int
|
||||
typematic(int delay, int rate)
|
||||
{
|
||||
static int delays[] = { 250, 500, 750, 1000 };
|
||||
static int rates[] = { 34, 38, 42, 46, 50, 55, 59, 63,
|
||||
68, 76, 84, 92, 100, 110, 118, 126,
|
||||
136, 152, 168, 184, 200, 220, 236, 252,
|
||||
272, 304, 336, 368, 400, 440, 472, 504 };
|
||||
int value;
|
||||
int i;
|
||||
|
||||
for (i = sizeof(delays)/sizeof(delays[0]) - 1; i > 0; --i) {
|
||||
if (delay >= delays[i])
|
||||
break;
|
||||
}
|
||||
value = i << 5;
|
||||
for (i = sizeof(rates)/sizeof(rates[0]) - 1; i > 0; --i) {
|
||||
if (rate >= rates[i])
|
||||
break;
|
||||
}
|
||||
value |= i;
|
||||
return value;
|
||||
}
|
||||
|
||||
#endif /* NATKBD > 0 */
|
||||
|
@ -23,7 +23,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: $
|
||||
* $Id: atkbdreg.h,v 1.1 1999/01/09 02:44:50 yokota Exp $
|
||||
*/
|
||||
|
||||
#ifndef _DEV_KBD_ATKBDREG_H_
|
||||
@ -52,9 +52,9 @@ typedef struct atkbd_softc {
|
||||
#ifdef __i386__
|
||||
atkbd_softc_t *atkbd_get_softc(int unit);
|
||||
#endif
|
||||
int atkbd_probe_unit(int unit, atkbd_softc_t *sc,
|
||||
int atkbd_probe_unit(int unit, int port, int irq, int flags);
|
||||
int atkbd_attach_unit(int unit, atkbd_softc_t *sc,
|
||||
int port, int irq, int flags);
|
||||
int atkbd_attach_unit(int unit, atkbd_softc_t *sc);
|
||||
|
||||
#endif /* KERNEL */
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: kbd.c,v 1.2 1999/01/12 10:35:58 yokota Exp $
|
||||
* $Id: kbd.c,v 1.3 1999/01/12 12:23:00 yokota Exp $
|
||||
*/
|
||||
|
||||
#include "kbd.h"
|
||||
@ -59,48 +59,73 @@ static keyboard_switch_t *kbdsw_ini;
|
||||
keyboard_switch_t **kbdsw = &kbdsw_ini;
|
||||
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
static struct cdevsw *kbdcdevsw_ini;
|
||||
static struct cdevsw **kbdcdevsw = &kbdcdevsw_ini;
|
||||
#endif
|
||||
|
||||
#define ARRAY_DELTA 4
|
||||
|
||||
static struct cdevsw *kbdcdevsw_ini;
|
||||
static struct cdevsw **kbdcdevsw = &kbdcdevsw_ini;
|
||||
|
||||
static void
|
||||
static int
|
||||
kbd_realloc_array(void)
|
||||
{
|
||||
keyboard_t **new_kbd;
|
||||
keyboard_switch_t **new_kbdsw;
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
struct cdevsw **new_cdevsw;
|
||||
#endif
|
||||
int newsize;
|
||||
int s;
|
||||
|
||||
s = spltty();
|
||||
newsize = ((keyboards + ARRAY_DELTA)/ARRAY_DELTA)*ARRAY_DELTA;
|
||||
new_kbd = malloc(sizeof(*new_kbd)*newsize, M_DEVBUF, M_NOWAIT);
|
||||
if (new_kbd == NULL) {
|
||||
splx(s);
|
||||
return ENOMEM;
|
||||
}
|
||||
new_kbdsw = malloc(sizeof(*new_kbdsw)*newsize, M_DEVBUF, M_NOWAIT);
|
||||
if (new_kbdsw == NULL) {
|
||||
free(new_kbd, M_DEVBUF);
|
||||
splx(s);
|
||||
return ENOMEM;
|
||||
}
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
new_cdevsw = malloc(sizeof(*new_cdevsw)*newsize, M_DEVBUF, M_NOWAIT);
|
||||
if (new_cdevsw == NULL) {
|
||||
free(new_kbd, M_DEVBUF);
|
||||
free(new_kbdsw, M_DEVBUF);
|
||||
splx(s);
|
||||
return ENOMEM;
|
||||
}
|
||||
#endif
|
||||
bzero(new_kbd, sizeof(*new_kbd)*newsize);
|
||||
bzero(new_kbdsw, sizeof(*new_kbdsw)*newsize);
|
||||
bzero(new_cdevsw, sizeof(*new_cdevsw)*newsize);
|
||||
bcopy(keyboard, new_kbd, sizeof(*keyboard)*keyboards);
|
||||
bcopy(kbdsw, new_kbdsw, sizeof(*kbdsw)*keyboards);
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
bzero(new_cdevsw, sizeof(*new_cdevsw)*newsize);
|
||||
bcopy(kbdcdevsw, new_cdevsw, sizeof(*kbdcdevsw)*keyboards);
|
||||
#endif
|
||||
if (keyboards > 1) {
|
||||
free(keyboard, M_DEVBUF);
|
||||
free(kbdsw, M_DEVBUF);
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
free(kbdcdevsw, M_DEVBUF);
|
||||
#endif
|
||||
}
|
||||
keyboard = new_kbd;
|
||||
kbdsw = new_kbdsw;
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
kbdcdevsw = new_cdevsw;
|
||||
#endif
|
||||
keyboards = newsize;
|
||||
splx(s);
|
||||
|
||||
if (bootverbose)
|
||||
printf("kbd: new array size %d\n", keyboards);
|
||||
}
|
||||
|
||||
#endif /* KBD_INSTALL_CDEV */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Low-level keyboard driver functions
|
||||
@ -118,7 +143,7 @@ kbd_init_struct(keyboard_t *kbd, char *name, int type, int unit, int config,
|
||||
kbd->kb_name = name;
|
||||
kbd->kb_type = type;
|
||||
kbd->kb_unit = unit;
|
||||
kbd->kb_config = config;
|
||||
kbd->kb_config = config & ~KB_CONF_PROBE_ONLY;
|
||||
kbd->kb_led = 0; /* unknown */
|
||||
kbd->kb_io_base = port;
|
||||
kbd->kb_io_size = port_size;
|
||||
@ -127,6 +152,8 @@ kbd_init_struct(keyboard_t *kbd, char *name, int type, int unit, int config,
|
||||
kbd->kb_accentmap = NULL;
|
||||
kbd->kb_fkeytab = NULL;
|
||||
kbd->kb_fkeytab_size = 0;
|
||||
kbd->kb_delay1 = KB_DELAY1; /* these values are advisory only */
|
||||
kbd->kb_delay2 = KB_DELAY2;
|
||||
}
|
||||
|
||||
void
|
||||
@ -151,8 +178,10 @@ kbd_register(keyboard_t *kbd)
|
||||
if (keyboard[index] == NULL)
|
||||
break;
|
||||
}
|
||||
if (index >= keyboards)
|
||||
return -1;
|
||||
if (index >= keyboards) {
|
||||
if (kbd_realloc_array())
|
||||
return -1;
|
||||
}
|
||||
|
||||
kbd->kb_index = index;
|
||||
KBD_UNBUSY(kbd);
|
||||
@ -416,9 +445,6 @@ kbd_attach(dev_t dev, keyboard_t *kbd, struct cdevsw *cdevsw)
|
||||
|
||||
/* XXX: DEVFS? */
|
||||
|
||||
if (kbd->kb_index + 1 >= keyboards)
|
||||
kbd_realloc_array();
|
||||
|
||||
printf("kbd%d at %s%d\n", kbd->kb_index, kbd->kb_name, kbd->kb_unit);
|
||||
return 0;
|
||||
}
|
||||
@ -845,9 +871,14 @@ genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
bcopy(kbd->kb_keymap, arg, sizeof(*kbd->kb_keymap));
|
||||
break;
|
||||
case PIO_KEYMAP: /* set keyboard translation table */
|
||||
#ifndef KBD_DISABLE_KEYMAP_LOAD
|
||||
bzero(kbd->kb_accentmap, sizeof(*kbd->kb_accentmap));
|
||||
bcopy(arg, kbd->kb_keymap, sizeof(*kbd->kb_keymap));
|
||||
break;
|
||||
#else
|
||||
splx(s);
|
||||
return ENODEV;
|
||||
#endif
|
||||
|
||||
case GIO_KEYMAPENT: /* get keyboard translation table entry */
|
||||
keyp = (keyarg_t *)arg;
|
||||
@ -860,6 +891,7 @@ genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
sizeof(keyp->key));
|
||||
break;
|
||||
case PIO_KEYMAPENT: /* set keyboard translation table entry */
|
||||
#ifndef KBD_DISABLE_KEYMAP_LOAD
|
||||
keyp = (keyarg_t *)arg;
|
||||
if (keyp->keynum >= sizeof(kbd->kb_keymap->key)
|
||||
/sizeof(kbd->kb_keymap->key[0])) {
|
||||
@ -869,13 +901,22 @@ genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
bcopy(&keyp->key, &kbd->kb_keymap->key[keyp->keynum],
|
||||
sizeof(keyp->key));
|
||||
break;
|
||||
#else
|
||||
splx(s);
|
||||
return ENODEV;
|
||||
#endif
|
||||
|
||||
case GIO_DEADKEYMAP: /* get accent key translation table */
|
||||
bcopy(kbd->kb_accentmap, arg, sizeof(*kbd->kb_accentmap));
|
||||
break;
|
||||
case PIO_DEADKEYMAP: /* set accent key translation table */
|
||||
#ifndef KBD_DISABLE_KEYMAP_LOAD
|
||||
bcopy(arg, kbd->kb_accentmap, sizeof(*kbd->kb_accentmap));
|
||||
break;
|
||||
#else
|
||||
splx(s);
|
||||
return ENODEV;
|
||||
#endif
|
||||
|
||||
case GETFKEY: /* get functionkey string */
|
||||
fkeyp = (fkeyarg_t *)arg;
|
||||
@ -888,6 +929,7 @@ genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
fkeyp->flen = kbd->kb_fkeytab[fkeyp->keynum].len;
|
||||
break;
|
||||
case SETFKEY: /* set functionkey string */
|
||||
#ifndef KBD_DISABLE_KEYMAP_LOAD
|
||||
fkeyp = (fkeyarg_t *)arg;
|
||||
if (fkeyp->keynum >= kbd->kb_fkeytab_size) {
|
||||
splx(s);
|
||||
@ -897,6 +939,10 @@ genkbd_commonioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
bcopy(fkeyp->keydef, kbd->kb_fkeytab[fkeyp->keynum].str,
|
||||
kbd->kb_fkeytab[fkeyp->keynum].len);
|
||||
break;
|
||||
#else
|
||||
splx(s);
|
||||
return ENODEV;
|
||||
#endif
|
||||
|
||||
default:
|
||||
splx(s);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: kbdreg.h,v 1.1 1999/01/09 02:44:50 yokota Exp $
|
||||
* $Id: kbdreg.h,v 1.2 1999/01/19 11:31:14 yokota Exp $
|
||||
*/
|
||||
|
||||
#ifndef _DEV_KBD_KBDREG_H_
|
||||
@ -83,6 +83,10 @@ struct keyboard {
|
||||
struct fkeytab *kb_fkeytab; /* function key strings */
|
||||
int kb_fkeytab_size;/* # of function key strings */
|
||||
void *kb_data; /* the driver's private data */
|
||||
int kb_delay1;
|
||||
int kb_delay2;
|
||||
#define KB_DELAY1 500
|
||||
#define KB_DELAY2 100
|
||||
};
|
||||
|
||||
#define KBD_IS_VALID(k) ((k)->kb_flags & KB_VALID)
|
||||
@ -105,11 +109,11 @@ struct keyboard {
|
||||
#define KBD_LED_VAL(k) ((k)->kb_led)
|
||||
|
||||
/* keyboard function table */
|
||||
typedef int kbd_probe_t(int unit, keyboard_t **kbdp, void *arg,
|
||||
int flags);
|
||||
typedef int kbd_init_t(keyboard_t *kbd);
|
||||
typedef int kbd_probe_t(int unit, void *arg, int flags);
|
||||
typedef int kbd_init_t(int unit, keyboard_t **kbdp, void *arg,
|
||||
int flags);
|
||||
typedef int kbd_term_t(keyboard_t *kbd);
|
||||
typedef int kbd_intr_t(keyboard_t *kbd);
|
||||
typedef int kbd_intr_t(keyboard_t *kbd, void *arg);
|
||||
typedef int kbd_test_if_t(keyboard_t *kbd);
|
||||
typedef int kbd_enable_t(keyboard_t *kbd);
|
||||
typedef int kbd_disable_t(keyboard_t *kbd);
|
||||
@ -124,6 +128,7 @@ typedef int kbd_get_state_t(keyboard_t *kbd, void *buf, size_t len);
|
||||
typedef int kbd_set_state_t(keyboard_t *kbd, void *buf, size_t len);
|
||||
typedef u_char *kbd_get_fkeystr_t(keyboard_t *kbd, int fkey,
|
||||
size_t *len);
|
||||
typedef int kbd_poll_mode_t(keyboard_t *kbd, int on);
|
||||
typedef void kbd_diag_t(keyboard_t *kbd, int level);
|
||||
|
||||
typedef struct keyboard_switch {
|
||||
@ -144,6 +149,7 @@ typedef struct keyboard_switch {
|
||||
kbd_get_state_t *get_state;
|
||||
kbd_set_state_t *set_state;
|
||||
kbd_get_fkeystr_t *get_fkeystr;
|
||||
kbd_poll_mode_t *poll;
|
||||
kbd_diag_t *diag;
|
||||
} keyboard_switch_t;
|
||||
|
||||
@ -157,10 +163,10 @@ typedef struct keyboard_driver {
|
||||
#ifdef KERNEL
|
||||
|
||||
#define KEYBOARD_DRIVER(name, sw, config) \
|
||||
static struct keyboard_driver name##_driver = { \
|
||||
static struct keyboard_driver name##_kbd_driver = { \
|
||||
#name, &sw, config \
|
||||
}; \
|
||||
DATA_SET(kbddriver_set, name##_driver);
|
||||
DATA_SET(kbddriver_set, name##_kbd_driver);
|
||||
|
||||
/* global variables */
|
||||
extern keyboard_switch_t **kbdsw;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: syscons.c,v 1.297 1999/01/30 12:17:30 phk Exp $
|
||||
* $Id: syscons.c,v 1.298 1999/02/05 11:52:11 yokota Exp $
|
||||
*/
|
||||
|
||||
#include "sc.h"
|
||||
@ -263,6 +263,8 @@ static const int nsccons = MAXCONS+2;
|
||||
(*kbdsw[(kbd)->kb_index]->clear_state)((kbd))
|
||||
#define kbd_get_fkeystr(kbd, fkey, len) \
|
||||
(*kbdsw[(kbd)->kb_index]->get_fkeystr)((kbd), (fkey), (len))
|
||||
#define kbd_poll(kbd, on) \
|
||||
(*kbdsw[(kbd)->kb_index]->poll)((kbd), (on))
|
||||
|
||||
/* prototypes */
|
||||
static kbd_callback_func_t sckbdevent;
|
||||
@ -1566,10 +1568,16 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
|
||||
*(int *)data = scp->status & LOCK_MASK;
|
||||
return 0;
|
||||
|
||||
case KDSETRAD: /* set keyboard repeat & delay rates */
|
||||
case KDSETREPEAT: /* set keyboard repeat & delay rates (new) */
|
||||
error = kbd_ioctl(kbd, cmd, data);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return error;
|
||||
|
||||
case KDSETRAD: /* set keyboard repeat & delay rates (old) */
|
||||
if (*(int *)data & ~0x7f)
|
||||
return EINVAL;
|
||||
error = kbd_ioctl(kbd, KDSETRAD, data);
|
||||
error = kbd_ioctl(kbd, cmd, data);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return error;
|
||||
@ -1996,7 +2004,9 @@ sccngetch(int flags)
|
||||
cur_console->kbd_mode = K_XLATE;
|
||||
kbd_ioctl(kbd, KDSKBMODE, (caddr_t)&cur_console->kbd_mode);
|
||||
|
||||
kbd_poll(kbd, TRUE);
|
||||
c = scgetc(kbd, SCGETC_CN | flags);
|
||||
kbd_poll(kbd, FALSE);
|
||||
|
||||
cur_console->kbd_mode = cur_mode;
|
||||
kbd_ioctl(kbd, KDSKBMODE, (caddr_t)&cur_console->kbd_mode);
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file tells config what files go into building a kernel,
|
||||
# files marked standard are always included.
|
||||
#
|
||||
# $Id: files.i386,v 1.226 1999/03/07 16:11:12 hm Exp $
|
||||
# $Id: files.i386,v 1.227 1999/03/10 10:11:41 julian Exp $
|
||||
#
|
||||
# The long compile-with and dependency lines are required because of
|
||||
# limitations in config: backslash-newline doesn't work in strings, and
|
||||
@ -24,6 +24,16 @@ font8x16.o optional std8x16font \
|
||||
no-implicit-rule before-depend \
|
||||
clean "${STD8X16FONT}-8x16 font8x16.c"
|
||||
#
|
||||
atkbdmap.h optional atkbd_dflt_keymap \
|
||||
compile-with "kbdcontrol -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "atkbdmap.h"
|
||||
#
|
||||
ukbdmap.h optional ukbd_dflt_keymap \
|
||||
compile-with "kbdcontrol -L ${UKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > ukbdmap.h" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "ukbdmap.h"
|
||||
#
|
||||
dev/ata/ata-all.c optional ata device-driver
|
||||
dev/ata/atapi-all.c optional ata device-driver
|
||||
dev/ata/ata-disk.c optional atadisk device-driver
|
||||
@ -37,7 +47,7 @@ dev/kbd/atkbd.c optional atkbd device-driver
|
||||
dev/kbd/atkbdc.c optional atkbdc device-driver
|
||||
dev/kbd/kbd.c optional atkbd device-driver
|
||||
dev/kbd/kbd.c optional kbd device-driver
|
||||
#dev/kbd/kbd.c optional ukbd device-driver
|
||||
dev/kbd/kbd.c optional ukbd device-driver
|
||||
dev/syscons/syscons.c optional sc device-driver
|
||||
dev/syscons/scvidctl.c optional sc device-driver
|
||||
dev/syscons/scvesactl.c optional sc device-driver
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: options.i386,v 1.107 1999/03/09 20:20:02 phk Exp $
|
||||
# $Id: options.i386,v 1.108 1999/03/10 10:11:42 julian Exp $
|
||||
|
||||
DISABLE_PSE
|
||||
IDE_DELAY
|
||||
@ -89,6 +89,10 @@ PSM_DEBUG opt_psm.h
|
||||
|
||||
PCIC_RESUME_RESET opt_pcic.h
|
||||
|
||||
ATKBD_DFLT_KEYMAP opt_atkbd.h
|
||||
UKBD_DFLT_KEYMAP opt_ukbd.h
|
||||
|
||||
KBD_DISABLE_KEYMAP_LOAD opt_kbd.h
|
||||
KBD_INSTALL_CDEV opt_kbd.h
|
||||
KBD_MAXRETRY opt_kbd.h
|
||||
KBD_MAXWAIT opt_kbd.h
|
||||
|
@ -25,7 +25,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: console.h,v 1.43 1999/01/11 03:18:04 yokota Exp $
|
||||
* $Id: console.h,v 1.44 1999/02/05 11:52:09 yokota Exp $
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_CONSOLE_H_
|
||||
@ -50,9 +50,10 @@
|
||||
#define KDGKBTYPE _IOR('K', 64, int)
|
||||
#define KDGETLED _IOR('K', 65, int)
|
||||
#define KDSETLED _IO('K', 66 /*, int */)
|
||||
#define KDSETRAD _IO('K', 67 /*, int */)
|
||||
#define KDSETRAD _IO('K', 67 /*, int */) /* obsolete */
|
||||
#define KDRASTER _IOW('K', 100, scr_size_t)
|
||||
#define KDGKBINFO _IOR('K', 101, keyboard_info_t)
|
||||
#define KDSETREPEAT _IOW('K', 102, keyboard_delay_t)
|
||||
|
||||
#define GETFKEY _IOWR('k', 0, fkeyarg_t)
|
||||
#define SETFKEY _IOWR('k', 1, fkeyarg_t)
|
||||
@ -393,6 +394,7 @@ typedef struct video_adapter_info video_adapter_info_t;
|
||||
typedef struct video_info video_info_t;
|
||||
typedef struct keyboard_info keyboard_info_t;
|
||||
typedef struct {int scr_size[3];} scr_size_t;
|
||||
typedef struct {int kbd_delay[2];} keyboard_delay_t;
|
||||
|
||||
/* defines for "special" keys (spcl bit set in keymap) */
|
||||
#define NOP 0x00 /* nothing (dead key) */
|
||||
|
@ -23,7 +23,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: atkbd_isa.c,v 1.1 1999/01/09 02:44:40 yokota Exp $
|
||||
* $Id: atkbd_isa.c,v 1.2 1999/01/19 11:30:55 yokota Exp $
|
||||
*/
|
||||
|
||||
#include "atkbd.h"
|
||||
@ -57,23 +57,8 @@ struct isa_driver atkbddriver = {
|
||||
static int
|
||||
atkbdprobe(struct isa_device *dev)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
int error;
|
||||
|
||||
sc = atkbd_get_softc(dev->id_unit);
|
||||
if (sc == NULL)
|
||||
return 0;
|
||||
|
||||
/* try to find a keyboard */
|
||||
error = atkbd_probe_unit(dev->id_unit, sc, dev->id_iobase,
|
||||
dev->id_irq, dev->id_flags);
|
||||
if (error)
|
||||
return 0;
|
||||
|
||||
/* declare our interrupt handler */
|
||||
dev->id_ointr = atkbd_isa_intr;
|
||||
|
||||
return -1;
|
||||
return ((atkbd_probe_unit(dev->id_unit, dev->id_iobase,
|
||||
dev->id_irq, dev->id_flags)) ? 0 : -1);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -85,7 +70,9 @@ atkbdattach(struct isa_device *dev)
|
||||
if (sc == NULL)
|
||||
return 0;
|
||||
|
||||
return ((atkbd_attach_unit(dev->id_unit, sc)) ? 0 : 1);
|
||||
dev->id_ointr = atkbd_isa_intr;
|
||||
return ((atkbd_attach_unit(dev->id_unit, sc, dev->id_iobase,
|
||||
dev->id_irq, dev->id_flags)) ? 0 : 1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -94,7 +81,7 @@ atkbd_isa_intr(int unit)
|
||||
keyboard_t *kbd;
|
||||
|
||||
kbd = atkbd_get_softc(unit)->kbd;
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd);
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
|
||||
}
|
||||
|
||||
#endif /* NATKBD > 0 */
|
||||
|
@ -635,7 +635,7 @@ r_entry:
|
||||
|
||||
if (kbd == NULL)
|
||||
return; /* shouldn't happen */
|
||||
(*kbdsw[kbd->kb_index]->init)(kbd);
|
||||
kbd_configure(0);
|
||||
|
||||
ledstate = LEDSTATE_UPDATE_PENDING;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: $
|
||||
* $Id: atkbd_isa.c,v 1.1 1999/01/23 16:53:27 dfr Exp $
|
||||
*/
|
||||
|
||||
#include "atkbd.h"
|
||||
@ -52,6 +52,7 @@ devclass_t atkbd_devclass;
|
||||
|
||||
static int atkbdprobe(device_t dev);
|
||||
static int atkbdattach(device_t dev);
|
||||
static void atkbd_isa_intr(void *arg);
|
||||
|
||||
static device_method_t atkbd_methods[] = {
|
||||
DEVMETHOD(device_probe, atkbdprobe),
|
||||
@ -69,13 +70,10 @@ static driver_t atkbd_driver = {
|
||||
static int
|
||||
atkbdprobe(device_t dev)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
u_long port;
|
||||
u_long irq;
|
||||
u_long flags;
|
||||
|
||||
sc = (atkbd_softc_t *)device_get_softc(dev);
|
||||
|
||||
device_set_desc(dev, "AT Keyboard");
|
||||
|
||||
/* obtain parameters */
|
||||
@ -84,14 +82,16 @@ atkbdprobe(device_t dev)
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
|
||||
|
||||
/* probe the device */
|
||||
return atkbd_probe_unit(device_get_unit(dev), sc, port, irq, flags);
|
||||
return atkbd_probe_unit(device_get_unit(dev), port, irq, flags);
|
||||
}
|
||||
|
||||
static int
|
||||
atkbdattach(device_t dev)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
u_long port;
|
||||
u_long irq;
|
||||
u_long flags;
|
||||
struct resource *res;
|
||||
void *ih;
|
||||
int zero = 0;
|
||||
@ -99,21 +99,32 @@ atkbdattach(device_t dev)
|
||||
|
||||
sc = (atkbd_softc_t *)device_get_softc(dev);
|
||||
|
||||
error = atkbd_attach_unit(device_get_unit(dev), sc);
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
|
||||
|
||||
error = atkbd_attach_unit(device_get_unit(dev), sc, port, irq, flags);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/* declare our interrupt handler */
|
||||
BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
|
||||
res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
|
||||
RF_SHAREABLE | RF_ACTIVE);
|
||||
BUS_SETUP_INTR(device_get_parent(dev), dev, res,
|
||||
(driver_intr_t *) kbdsw[sc->kbd->kb_index]->intr, sc->kbd,
|
||||
BUS_SETUP_INTR(device_get_parent(dev), dev, res, atkbd_isa_intr, sc,
|
||||
&ih);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
atkbd_isa_intr(void *arg)
|
||||
{
|
||||
atkbd_softc_t *sc;
|
||||
|
||||
sc = (atkbd_softc_t *)arg;
|
||||
(*kbdsw[sc->kbd->kb_index]->intr)(sc->kbd, NULL);
|
||||
}
|
||||
|
||||
DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
|
||||
|
||||
#endif /* NATKBD > 0 */
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: kbdcontrol.c,v 1.21 1999/01/12 23:06:29 mjacob Exp $";
|
||||
"$Id: kbdcontrol.c,v 1.22 1999/01/23 17:04:13 dfr Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
@ -88,13 +88,6 @@ char fkey_table[96][MAXFK] = {
|
||||
/* 93-96 */ "" , "" , "" , "" ,
|
||||
};
|
||||
|
||||
const int delays[] = {250, 500, 750, 1000};
|
||||
const int repeats[] = { 34, 38, 42, 46, 50, 55, 59, 63,
|
||||
68, 76, 84, 92, 100, 110, 118, 126,
|
||||
136, 152, 168, 184, 200, 220, 236, 252,
|
||||
272, 304, 336, 368, 400, 440, 472, 504};
|
||||
const int ndelays = (sizeof(delays) / sizeof(int));
|
||||
const int nrepeats = (sizeof(repeats) / sizeof(int));
|
||||
int hex = 0;
|
||||
int number;
|
||||
char letter;
|
||||
@ -417,8 +410,13 @@ print_entry(FILE *fp, int value)
|
||||
}
|
||||
|
||||
|
||||
#ifdef __i386__
|
||||
void
|
||||
print_key_definition_line(FILE *fp, int scancode, struct keyent_t *key)
|
||||
#else
|
||||
void
|
||||
print_key_definition_line(FILE *fp, int scancode, struct key_t *key)
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -814,13 +812,14 @@ badopt:
|
||||
void
|
||||
set_keyrates(char *opt)
|
||||
{
|
||||
int arg[2];
|
||||
int repeat;
|
||||
int delay;
|
||||
|
||||
if (!strcmp(opt, "slow"))
|
||||
delay = 3, repeat = 31;
|
||||
delay = 1000, repeat = 500;
|
||||
else if (!strcmp(opt, "normal"))
|
||||
delay = 1, repeat = 15;
|
||||
delay = 500, repeat = 125;
|
||||
else if (!strcmp(opt, "fast"))
|
||||
delay = repeat = 0;
|
||||
else {
|
||||
@ -837,17 +836,11 @@ badopt:
|
||||
warnx("argument to -r must be delay.repeat");
|
||||
return;
|
||||
}
|
||||
for (n = 0; n < ndelays - 1; n++)
|
||||
if (delay <= delays[n])
|
||||
break;
|
||||
delay = n;
|
||||
for (n = 0; n < nrepeats - 1; n++)
|
||||
if (repeat <= repeats[n])
|
||||
break;
|
||||
repeat = n;
|
||||
}
|
||||
|
||||
if (ioctl(0, KDSETRAD, (delay << 5) | repeat) < 0)
|
||||
arg[0] = delay;
|
||||
arg[1] = repeat;
|
||||
if (ioctl(0, KDSETREPEAT, arg))
|
||||
warn("setting keyboard rate");
|
||||
}
|
||||
|
||||
@ -866,7 +859,6 @@ set_history(char *opt)
|
||||
warn("setting history buffer size");
|
||||
}
|
||||
|
||||
#ifdef __i386__
|
||||
static char
|
||||
*get_kbd_type_name(int type)
|
||||
{
|
||||
@ -960,22 +952,15 @@ release_keyboard(void)
|
||||
if (ioctl(0, CONS_RELKBD, 0) == -1)
|
||||
warn("unable to release the keyboard");
|
||||
}
|
||||
#endif /* __i386__ */
|
||||
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "%s\n%s\n%s\n",
|
||||
#ifdef __i386__
|
||||
"usage: kbdcontrol [-dFKix] [-b duration.pitch | [quiet.]belltype]",
|
||||
" [-r delay.repeat | speed] [-l mapfile] [-f # string]",
|
||||
" [-h size] [-k device] [-L mapfile]");
|
||||
#else
|
||||
"usage: kbdcontrol [-dFx] [-b duration.pitch | [quiet.]belltype]",
|
||||
" [-r delay.repeat | speed] [-l mapfile] [-f # string]",
|
||||
" [-h size] [-L mapfile]");
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -985,11 +970,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
|
||||
#ifdef __i386__
|
||||
while((opt = getopt(argc, argv, "b:df:h:iKk:Fl:L:r:x")) != -1)
|
||||
#else
|
||||
while((opt = getopt(argc, argv, "b:df:h:Fl:L:r:x")) != -1)
|
||||
#endif
|
||||
switch(opt) {
|
||||
case 'b':
|
||||
set_bell_values(optarg);
|
||||
@ -1013,7 +994,6 @@ main(int argc, char **argv)
|
||||
case 'h':
|
||||
set_history(optarg);
|
||||
break;
|
||||
#ifdef __i386__
|
||||
case 'i':
|
||||
show_kbd_info();
|
||||
break;
|
||||
@ -1023,7 +1003,6 @@ main(int argc, char **argv)
|
||||
case 'k':
|
||||
set_keyboard(optarg);
|
||||
break;
|
||||
#endif /* __i386__ */
|
||||
case 'r':
|
||||
set_keyrates(optarg);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user