diff options
Diffstat (limited to 'sys/i386/isa/pcvt')
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_drv.c | 162 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_hdr.h | 32 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_kbd.c | 284 |
3 files changed, 203 insertions, 275 deletions
diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index 26c02f3..c4ed5a1 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -114,6 +114,11 @@ static void vgapelinit(void); /* read initial VGA DAC palette */ static int pcvt_xmode_set(int on, struct proc *p); /* initialize for X mode */ #endif /* XSERVER && !PCVT_USL_VT_COMPAT */ +#ifdef _DEV_KBD_KBDREG_H_ +static void detect_kbd(void *arg); +static kbd_callback_func_t pcevent; +#endif + static cn_probe_t pccnprobe; static cn_init_t pccninit; static cn_getc_t pccngetc; @@ -161,17 +166,19 @@ pcprobe(struct isa_device *dev) #endif /* PCVT_NETBSD > 9 */ #endif /* PCVT_NETBSD > 100 */ { -#ifdef _I386_ISA_KBDIO_H_ - kbdc = kbdc_open(IO_KBD); +#ifdef _DEV_KBD_KBDREG_H_ + int i; - if(kbdc == NULL) + kbd = NULL; + kbd_configure(KB_CONF_PROBE_ONLY); + i = kbd_allocate("*", -1, (void *)&kbd, pcevent, (void *)dev->id_unit); + if ((i < 0) || ((kbd = kbd_get_keyboard(i)) == NULL)) { reset_keyboard = 0; - return 1; + return (-1); } - reset_keyboard = 1; /* it's now safe to do kbd reset */ -#endif /* _I386_ISA_KBDIO_H_ */ +#endif /* _DEV_KBD_KBDREG_H_ */ kbd_code_init(); @@ -179,7 +186,9 @@ pcprobe(struct isa_device *dev) ((struct isa_attach_args *)aux)->ia_iosize = 16; return 1; #else -#if PCVT_NETBSD || PCVT_FREEBSD +#ifdef _DEV_KBD_KBDREG_H_ + return (-1); +#elif PCVT_NETBSD || PCVT_FREEBSD return (16); #else return 1; @@ -207,6 +216,11 @@ pcattach(struct isa_device *dev) vt_coldmalloc(); /* allocate memory for screens */ +#ifdef _DEV_KBD_KBDREG_H_ + if (kbd == NULL) + timeout(detect_kbd, (void *)dev->id_unit, hz*2); +#endif /* _DEV_KBD_KBDREG_H_ */ + #if PCVT_NETBSD || PCVT_FREEBSD #if PCVT_NETBSD > 9 @@ -849,6 +863,50 @@ pcvt_timeout(void *arg) } #endif +#ifdef _DEV_KBD_KBDREG_H_ +static void +detect_kbd(void *arg) +{ + int unit = (int)arg; + int i; + + if (kbd != NULL) + return; + i = kbd_allocate("*", -1, (void *)&kbd, pcevent, (void *)unit); + if (i >= 0) + kbd = kbd_get_keyboard(i); + if (kbd != NULL) + { + reset_keyboard = 1; /* ok to reset the keyboard */ + kbd_code_init(); + return; + } + reset_keyboard = 0; + timeout(detect_kbd, (void *)unit, hz*2); +} + +int +pcevent(keyboard_t *thiskbd, int event, void *arg) +{ + int unit = (int)arg; + + if (thiskbd != kbd) + return EINVAL; /* shouldn't happen */ + + switch (event) { + case KBDIO_KEYINPUT: + pcrint(unit); + return 0; + case KBDIO_UNLOADING: + kbd = NULL; + kbd_release(thiskbd, (void *)&kbd); + timeout(detect_kbd, (void *)unit, hz*4); + return 0; + default: + return EINVAL; + } +} +#endif /* _DEV_KBD_KBDREG_H_ */ void pcrint(int unit) @@ -862,7 +920,7 @@ pcrint(int unit) int s; # endif -# ifdef _I386_ISA_KBDIO_H_ +# ifdef _DEV_KBD_KBDREG_H_ int c; # endif @@ -870,25 +928,6 @@ pcrint(int unit) u_char *cp; #endif /* PCVT_KBD_FIFO */ - /* - * in case the keyboard was not plugged in while booting, kbdc - * was set to NULL at that time. When a keyboard IRQ occurs and - * kbdc is NULL, the keyboard was probably reconnected to the - * keyboard controller and we have to initialize the keyboard. - */ - - if(kbdc == NULL) - { - kbdc = kbdc_open(IO_KBD); - if(kbdc == NULL) - { - reset_keyboard = 0; - return; - } - reset_keyboard = 1; - kbd_code_init(); - } - #if PCVT_SCREENSAVER pcvt_scrnsv_reset(); #endif /* PCVT_SCREENSAVER */ @@ -900,7 +939,7 @@ pcrint(int unit) return; } -# ifndef _I386_ISA_KBDIO_H_ +# ifndef _DEV_KBD_KBDREG_H_ while (inb(CONTROLLER_CTRL) & STATUS_OUTPBF) /* check 8042 buffer */ { ret = 1; /* got something */ @@ -909,11 +948,11 @@ pcrint(int unit) dt = inb(CONTROLLER_DATA); /* get it 8042 data */ # else - while ((c = read_kbd_data_no_wait(kbdc)) != -1) + while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) != -1) { ret = 1; /* got something */ dt = c; -# endif /* _I386_ISA_KBDIO_H_ */ +# endif /* _DEV_KBD_KBDREG_H_ */ if (pcvt_kbd_count >= PCVT_KBD_FIFO_SZ) /* fifo overflow ? */ { @@ -1131,32 +1170,40 @@ int pccnprobe(struct consdev *cp) { struct isa_device *dvp; + int i; + + /* + * Take control if we are the highest priority enabled display device. + */ + dvp = find_display(); + if (dvp == NULL || dvp->id_driver != &vtdriver) { + cp->cn_pri = CN_DEAD; + return; + } + +#ifdef _DEV_KBD_KBDREG_H_ + kbd = NULL; + kbd_configure(KB_CONF_PROBE_ONLY); + i = kbd_allocate("*", -1, (void *)&kbd, pcevent, (void *)dvp->id_unit); + if (i >= 0) + kbd = kbd_get_keyboard(i); -#ifdef _I386_ISA_KBDIO_H_ - kbdc = kbdc_open(IO_KBD); /* * Don't reset the keyboard via `kbdio' just yet. * The system clock has not been calibrated... */ reset_keyboard = 0; + #if PCVT_SCANSET == 2 /* * Turn off scancode translation early so that UserConfig * and DDB can read the keyboard. */ - empty_both_buffers(kbdc, 10); - set_controller_command_byte(kbdc, KBD_TRANSLATION, 0); + empty_both_buffers(*(KBDC *)kbd->kb_data, 10); + set_controller_command_byte(*(KBDC *)kbd->kb_data, KBD_TRANSLATION, 0); #endif /* PCVT_SCANSET == 2 */ -#endif /* _I386_ISA_KBDIO_H_ */ - /* - * Take control if we are the highest priority enabled display device. - */ - dvp = find_display(); - if (dvp == NULL || dvp->id_driver != &vtdriver) { - cp->cn_pri = CN_DEAD; - return; - } +#endif /* _DEV_KBD_KBDREG_H_ */ /* initialize required fields */ @@ -1254,7 +1301,13 @@ pccngetc(Dev_t dev) s = spltty(); /* block pcrint while we poll */ kbd_polling = 1; +#ifdef _DEV_KBD_KBDREG_H_ + (*kbdsw[kbd->kb_index]->enable)(kbd); +#endif cp = sgetc(0); +#ifdef _DEV_KBD_KBDREG_H_ + (*kbdsw[kbd->kb_index]->disable)(kbd); +#endif kbd_polling = 0; splx(s); c = *cp++; @@ -1281,7 +1334,13 @@ pccncheckc(Dev_t dev) char *cp; int x = spltty(); kbd_polling = 1; +#ifdef _DEV_KBD_KBDREG_H_ + (*kbdsw[kbd->kb_index]->enable)(kbd); +#endif cp = sgetc(1); +#ifdef _DEV_KBD_KBDREG_H_ + (*kbdsw[kbd->kb_index]->disable)(kbd); +#endif kbd_polling = 0; splx(x); return (cp == NULL ? -1 : *cp); @@ -1520,7 +1579,7 @@ pcvt_xmode_set(int on, struct proc *p) vsp->Crtat = vsp->Memory; /* operate in memory now */ -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ #if PCVT_SCANSET == 2 /* put keyboard to return ancient PC scan codes */ @@ -1534,15 +1593,15 @@ pcvt_xmode_set(int on, struct proc *p) #endif /* PCVT_USEKBDSEC */ #endif /* PCVT_SCANSET == 2 */ -#else /* _I386_ISA_KBDIO_H_ */ +#else /* _DEV_KBD_KBDREG_H_ */ #if PCVT_SCANSET == 2 /* put keyboard to return ancient PC scan codes */ - set_controller_command_byte(kbdc, + set_controller_command_byte(*(KBDC *)kbd->kb_data, KBD_TRANSLATION, KBD_TRANSLATION); #endif /* PCVT_SCANSET == 2 */ -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ #if PCVT_NETBSD > 9 fp->tf_eflags |= PSL_IOPL; @@ -1579,7 +1638,7 @@ pcvt_xmode_set(int on, struct proc *p) pcvt_set_scrnsv_tmo(saved_scrnsv_tmo); #endif /* PCVT_SCREENSAVER */ -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ #if PCVT_SCANSET == 2 kbc_8042cmd(CONTR_WRITE); @@ -1592,13 +1651,14 @@ pcvt_xmode_set(int on, struct proc *p) #endif /* PCVT_USEKBDSEC */ #endif /* PCVT_SCANSET == 2 */ -#else /* _I386_ISA_KBDIO_H_ */ +#else /* _DEV_KBD_KBDREG_H_ */ #if PCVT_SCANSET == 2 - set_controller_command_byte(kbdc, KBD_TRANSLATION, 0); + set_controller_command_byte(*(KBDC *)kbd->kb_data, + KBD_TRANSLATION, 0); #endif /* PCVT_SCANSET == 2 */ -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ if(adaptor_type == MDA_ADAPTOR) { diff --git a/sys/i386/isa/pcvt/pcvt_hdr.h b/sys/i386/isa/pcvt/pcvt_hdr.h index 11adc9c..2c9aac8 100644 --- a/sys/i386/isa/pcvt/pcvt_hdr.h +++ b/sys/i386/isa/pcvt/pcvt_hdr.h @@ -107,7 +107,9 @@ #endif /* PCVT_FREEBSD >= 200 */ #include <i386/isa/pcvt/pcvt_conf.h> -#include <i386/isa/kbdio.h> + +#include <dev/kbd/kbdreg.h> +#include <dev/kbd/atkbdcreg.h> #if PCVT_NETBSD > 9 #include "device.h" @@ -168,6 +170,14 @@ #include <machine/clock.h> #include <machine/md_var.h> #endif +/* + * The following values are defined in machine/console.h, but the header + * file is not included here due to conflicts with pcvt_ioctl.h. + */ +#define KDGKBTYPE _IOR('K', 64, int) +#define KB_84 1 +#define KB_101 2 +#define KB_OTHER 3 #else /* PCVT_FREEBSD >= 200 */ #include "machine/pc/display.h" #endif /* PCVT_FREEBSD >= 200 */ @@ -260,7 +270,7 @@ in the config file" * Keyboard and Keyboard Controller *---------------------------------------------------------------------------*/ -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ #define CONTROLLER_CTRL 0x64 /* W - command, R - status */ #define CONTROLLER_DATA 0x60 /* R/W - data */ @@ -308,7 +318,7 @@ in the config file" #define KEYB_C_ECHO 0xee /* diagnostic, echo 0xee */ #define KEYB_C_LEDS 0xed /* set/reset numlock,capslock & scroll lock */ -#endif /* _I386_ISA_KBDIO_H_ */ +#endif /* _DEV_KBD_KBDREG_H_ */ /* responses from the KEYBOARD (via the 8042 controller on mainboard..) */ @@ -1000,10 +1010,10 @@ u_char chargen_access = 0; /* synchronize access */ u_char keyboard_type = KB_UNKNOWN; /* type of keyboard */ u_char keyboard_is_initialized = 0; /* for ddb sanity */ u_char kbd_polling = 0; /* keyboard is being polled */ -#ifdef _I386_ISA_KBDIO_H_ +#ifdef _DEV_KBD_KBDREG_H_ u_char reset_keyboard = 0; /* OK to reset keyboard */ -KBDC kbdc = NULL; /* keyboard controller */ -#endif /* _I386_ISA_KBDIO_H_ */ +keyboard_t *kbd = NULL; +#endif /* _DEV_KBD_KBDREG_H_ */ #if PCVT_SHOWKEYS u_char keyboard_show = 0; /* normal display */ @@ -1141,10 +1151,10 @@ extern u_char can_do_132col; extern u_char vga_family; extern u_char keyboard_is_initialized; extern u_char kbd_polling; -#ifdef _I386_ISA_KBDIO_H_ +#ifdef _DEV_KBD_KBDREG_H_ extern u_char reset_keyboard; -extern KBDC kbdc; -#endif /* _I386_ISA_KBDIO_H_ */ +extern keyboard_t *kbd; +#endif /* _DEV_KBD_KBDREG_H_ */ #if PCVT_SHOWKEYS extern u_char keyboard_show; @@ -1268,10 +1278,10 @@ void fkl_on ( struct video_state *svsp ); struct tty *get_pccons ( Dev_t dev ); void init_sfkl ( struct video_state *svsp ); void init_ufkl ( struct video_state *svsp ); -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ int kbd_cmd ( int val ); int kbd_response ( void ); -#endif /* _I386_ISA_KBDIO_H_ */ +#endif /* _DEV_KBD_KBDREG_H_ */ void kbd_code_init ( void ); void kbd_code_init1 ( void ); diff --git a/sys/i386/isa/pcvt/pcvt_kbd.c b/sys/i386/isa/pcvt/pcvt_kbd.c index 2113ee0..c7a2cfc 100644 --- a/sys/i386/isa/pcvt/pcvt_kbd.c +++ b/sys/i386/isa/pcvt/pcvt_kbd.c @@ -91,11 +91,9 @@ static void doreset ( void ); static void ovlinit ( int force ); static void settpmrate ( int rate ); static void setlockkeys ( int snc ); -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ static int kbc_8042cmd ( int val ); -#else -static int set_keyboard_param( int command, int data ); -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ static int getokeydef ( unsigned key, struct kbd_ovlkey *thisdef ); static int getckeydef ( unsigned key, struct kbd_ovlkey *thisdef ); static int rmkeydef ( int key ); @@ -170,7 +168,7 @@ do_vgapage(int page) #define PCVT_UPDLED_LOSES_INTR 0 /* disabled for now */ -#if PCVT_UPDLED_LOSES_INTR || defined(_I386_ISA_KBDIO_H_) +#if PCVT_UPDLED_LOSES_INTR || defined(_DEV_KBD_KBDREG_H_) /*---------------------------------------------------------------------------* * check for lost keyboard interrupts @@ -203,7 +201,7 @@ static struct callout_handle lost_intr_ch = static void check_for_lost_intr (void *arg) { -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ lost_intr_timeout_queued = 0; if (inb(CONTROLLER_CTRL) & STATUS_OUTPBF) { @@ -215,19 +213,20 @@ check_for_lost_intr (void *arg) int opri; lost_intr_timeout_queued = 0; - if (kbdc_lock(kbdc, TRUE)) { + if ((*kbdsw[kbd->kb_index]->lock)(kbd, TRUE)) { opri = spltty (); - kbdc_lock(kbdc, FALSE); - if (kbdc_data_ready(kbdc)) + (*kbdsw[kbd->kb_index]->lock)(kbd, FALSE); + if ((*kbdsw[kbd->kb_index]->check)(kbd)) pcrint (0); splx (opri); } + lost_intr_ch = timeout(check_for_lost_intr, (void *)NULL, hz); lost_intr_timeout_queued = 1; -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ } -#endif /* PCVT_UPDLED_LOSES_INTR || defined(_I386_ISA_KBDIO_H_) */ +#endif /* PCVT_UPDLED_LOSES_INTR || defined(_DEV_KBD_KBDREG_H_) */ /*---------------------------------------------------------------------------* * update keyboard led's @@ -242,13 +241,19 @@ update_led(void) int opri, new_ledstate; opri = spltty(); +#ifndef _DEV_KBD_KBDREG_H_ new_ledstate = (vsp->scroll_lock) | (vsp->num_lock * 2) | (vsp->caps_lock * 4); +#else + new_ledstate = ((vsp->scroll_lock) ? LED_SCR : 0) | + ((vsp->num_lock) ? LED_NUM : 0) | + ((vsp->caps_lock) ? LED_CAP : 0); +#endif /* _DEV_KBD_KBDREG_H_ */ if (new_ledstate != ledstate) { -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ int response1, response2; ledstate = LEDSTATE_UPDATE_PENDING; @@ -296,19 +301,20 @@ update_led(void) printf( "Keyboard LED command not ACKed (responses %#x %#x)\n", response1, response2); -#else /* _I386_ISA_KBDIO_H_ */ +#else /* _DEV_KBD_KBDREG_H_ */ - if (kbdc == NULL) { + if (kbd == NULL) { ledstate = new_ledstate; splx(opri); } else { ledstate = LEDSTATE_UPDATE_PENDING; splx(opri); - if (set_keyboard_param(KBDC_SET_LEDS, new_ledstate) == 0) + if ((*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETLED, + (caddr_t)&new_ledstate) == 0) ledstate = new_ledstate; } -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ #if PCVT_UPDLED_LOSES_INTR if (lost_intr_timeout_queued) @@ -320,7 +326,7 @@ update_led(void) } -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ splx(opri); #endif @@ -333,7 +339,7 @@ update_led(void) static void settpmrate(int rate) { -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ tpmrate = rate & 0x7f; if(kbd_cmd(KEYB_C_TYPEM) != 0) printf("Keyboard TYPEMATIC command timeout\n"); @@ -341,12 +347,13 @@ settpmrate(int rate) printf("Keyboard TYPEMATIC data timeout\n"); #else tpmrate = rate & 0x7f; - if (set_keyboard_param(KBDC_SET_TYPEMATIC, tpmrate) != 0) + if ((*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETRAD, + (caddr_t)&tpmrate) == 0) printf("pcvt: failed to set keyboard TYPEMATIC.\n"); -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ } -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ /*---------------------------------------------------------------------------* * Pass command to keyboard controller (8042) *---------------------------------------------------------------------------*/ @@ -408,64 +415,7 @@ kbd_response(void) return ch; } -#else -static int -set_keyboard_param(int command, int data) -{ - int s; -#if 0 - int c; -#endif - - if (kbdc == NULL) - return 1; - - /* prevent the timeout routine from polling the keyboard */ - if (!kbdc_lock(kbdc, TRUE)) - return 1; - - /* disable the keyboard and mouse interrupt */ - s = spltty(); -#if 0 - c = get_controller_command_byte(kbdc); - if ((c == -1) - || !set_controller_command_byte(kbdc, - kbdc_get_device_mask(kbdc), - KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT - | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) { - /* CONTROLLER ERROR */ - kbdc_lock(kbdc, FALSE); - splx(s); - return 1; - } - /* - * Now that the keyboard controller is told not to generate - * the keyboard and mouse interrupts, call `splx()' to allow - * the other tty interrupts. The clock interrupt may also occur, - * but the timeout routine (`scrn_timer()') will be blocked - * by the lock flag set via `kbdc_lock()' - */ - splx(s); -#endif - - if (send_kbd_command_and_data(kbdc, command, data) != KBD_ACK) - send_kbd_command(kbdc, KBDC_ENABLE_KBD); - -#if 0 - /* restore the interrupts */ - if (!set_controller_command_byte(kbdc, - kbdc_get_device_mask(kbdc), - c & (KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS))) { - /* CONTROLLER ERROR */ - } -#else - splx(s); -#endif - kbdc_lock(kbdc, FALSE); - - return 0; -} -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* _DEV_KBD_KBDREG_H_ */ #if PCVT_SCANSET > 1 /*---------------------------------------------------------------------------* @@ -474,7 +424,7 @@ set_keyboard_param(int command, int data) void kbd_emulate_pc(int do_emulation) { -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ int cmd, timeo = 10000; cmd = COMMAND_SYSFLG|COMMAND_IRQEN; /* common base cmd */ @@ -492,9 +442,9 @@ kbd_emulate_pc(int do_emulation) break; outb(CONTROLLER_DATA, cmd); #else - set_controller_command_byte(kbdc, KBD_TRANSLATION, + set_controller_command_byte(*(KBDC *)kbd->kb_data, KBD_TRANSLATION, (do_emulation) ? KBD_TRANSLATION : 0); -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ } #endif /* PCVT_SCANSET > 1 */ @@ -510,7 +460,7 @@ kbd_emulate_pc(int do_emulation) static void doreset(void) { -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ int again = 0; int once = 0; int response, opri; @@ -671,10 +621,8 @@ r_entry: #endif /* PCVT_KEYBDID */ -#else /* _I386_ISA_KBDIO_H_ */ - int c; - int m; - int s; +#else /* _DEV_KBD_KBDREG_H_ */ + int type; if (!reset_keyboard) /* no, we are not ready to reset */ return; @@ -684,29 +632,11 @@ r_entry: lost_intr_timeout_queued = 0; } - if (kbdc == NULL) - kbdc = kbdc_open(IO_KBD); + if (kbd == NULL) + return; /* shouldn't happen */ + (*kbdsw[kbd->kb_index]->init)(kbd); - if (!kbdc_lock(kbdc, TRUE)) /* strange, somebody got there first */ - return; - - /* remove any noise */ - empty_both_buffers(kbdc, 10); - - s = spltty(); - - /* save the current controller command byte */ - m = kbdc_get_device_mask(kbdc) & ~KBD_KBD_CONTROL_BITS; - c = get_controller_command_byte(kbdc); - if (c == -1) { - /* CONTROLLER ERROR */ - kbdc_set_device_mask(kbdc, m); - kbdc_lock(kbdc, FALSE); - kbdc = NULL; - splx(s); - printf("pcvt: unable to get the command byte.\n"); - return; - } + ledstate = LEDSTATE_UPDATE_PENDING; #if PCVT_USEKBDSEC /* security enabled */ @@ -726,105 +656,33 @@ r_entry: #endif /* PCVT_USEKBDSEC */ - /* disable the keyboard interrupt and the aux port and interrupt */ - if (!set_controller_command_byte(kbdc, - KBD_KBD_CONTROL_BITS | KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK, - KBD_ENABLE_KBD_PORT | KBD_DISABLE_KBD_INT | KBDINITCMD)) { - /* CONTROLLER ERROR: there is very little we can do... */ - kbdc_set_device_mask(kbdc, m); - kbdc_lock(kbdc, FALSE); - kbdc = NULL; - splx(s); - printf("pcvt: unable to set the command byte.\n"); - return; - } - splx(s); - - /* reset keyboard hardware */ - ledstate = LEDSTATE_UPDATE_PENDING; - if (!reset_kbd(kbdc)) { - /* KEYBOARD ERROR */ - empty_both_buffers(kbdc, 10); - test_controller(kbdc); - test_kbd_port(kbdc); - /* - * We could disable the keyboard port and interrupt now... - * but, the keyboard may still exist. - */ - printf("pcvt: failed to reset the keyboard.\n"); - /* try to restore the original command byte */ - set_controller_command_byte(kbdc, 0xff, c); - kbdc_set_device_mask(kbdc, m); - kbdc_lock(kbdc, FALSE); - kbdc = NULL; - return; - } - -#if PCVT_KEYBDID - - keyboard_type = KB_UNKNOWN; - if (send_kbd_command(kbdc, KBDC_SEND_DEV_ID) == KBD_ACK) { - DELAY(10000); /* 10msec delay */ - switch (read_kbd_data(kbdc)) { - case KEYB_R_MF2ID1: - switch (read_kbd_data(kbdc)) { - case KEYB_R_MF2ID2: - case KEYB_R_MF2ID2HP: - keyboard_type = KB_MFII; - break; - case -1: - default: - break; - } - break; - case -1: - keyboard_type = KB_AT; - /* fall through */ - default: - /* XXX: should we read the second byte? */ - empty_both_buffers(kbdc, 10); /* XXX */ - break; - } - } else { - /* - * The send ID command failed. This error is considered - * benign, but may need recovery. - */ - empty_both_buffers(kbdc, 10); - test_controller(kbdc); - test_kbd_port(kbdc); - } - -#else /* PCVT_KEYBDID */ + set_controller_command_byte(*(KBDC *)kbd->kb_data, + KBD_OVERRIDE_KBD_LOCK | KBD_TRANSLATION, KBDINITCMD); keyboard_type = KB_MFII; /* force it .. */ - -#endif /* PCVT_KEYBDID */ - - /* enable the keyboard port and intr. */ - if (!set_controller_command_byte(kbdc, - KBD_KBD_CONTROL_BITS, - KBD_ENABLE_KBD_PORT | KBD_ENABLE_KBD_INT)) { - /* CONTROLLER ERROR - * This is serious; we are left with the disabled - * keyboard intr. - */ - printf("pcvt: failed to enable the keyboard port and intr.\n"); - kbdc_set_device_mask(kbdc, m); - kbdc_lock(kbdc, FALSE); - kbdc = NULL; - return; +#if PCVT_KEYBDID + type = KB_101; + (*kbdsw[kbd->kb_index]->ioctl)(kbd, KDGKBTYPE, (caddr_t)&type); + switch (type) + { + case KB_84: + keyboard_type = KB_AT; + break; + case KB_101: + keyboard_type = KB_MFII; + break; + default: + keyboard_type = KB_UNKNOWN; + break; } - - kbdc_set_device_mask(kbdc, m | KBD_KBD_CONTROL_BITS); - kbdc_lock(kbdc, FALSE); +#endif /* PCVT_KEYBDID */ update_led(); lost_intr_ch = timeout(check_for_lost_intr, (void *)NULL, hz); lost_intr_timeout_queued = 1; -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ } /*---------------------------------------------------------------------------* @@ -1246,15 +1104,15 @@ sgetc(int noblock) static char keybuf[2] = {0}; /* the second 0 is a delimiter! */ #endif /* XSERVER */ -#ifdef _I386_ISA_KBDIO_H_ +#ifdef _DEV_KBD_KBDREG_H_ int c; -#endif /* _I386_ISA_KBDIO_H_ */ +#endif /* _DEV_KBD_KBDREG_H_ */ loop: #ifdef XSERVER -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ #if PCVT_KBD_FIFO @@ -1289,7 +1147,7 @@ loop: #endif /* !PCVT_KBD_FIFO */ -#else /* _I386_ISA_KBDIO_H_ */ +#else /* _DEV_KBD_KBDREG_H_ */ #if PCVT_KBD_FIFO if (pcvt_kbd_count) { @@ -1302,18 +1160,18 @@ loop: } else #endif /* PCVT_KBD_FIFO */ if (!noblock) { - while ((c = read_kbd_data(kbdc)) == -1) + while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, TRUE)) == -1) ; dt = c; } else { - if ((c = read_kbd_data_no_wait(kbdc)) == -1) + if ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) == -1) return NULL; dt = c; } { -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ /* * If x mode is active, only care for locking keys, then @@ -1591,7 +1449,7 @@ no_mouse_event: #else /* !XSERVER */ -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ # if PCVT_KBD_FIFO @@ -1628,7 +1486,7 @@ no_mouse_event: #endif /* !PCVT_KBD_FIFO */ -#else /* _I386_ISA_KBDIO_H_ */ +#else /* _DEV_KBD_KBDREG_H_ */ #if PCVT_KBD_FIFO if (pcvt_kbd_count) { @@ -1641,20 +1499,20 @@ no_mouse_event: } else #endif /* PCVT_KBD_FIFO */ if (!noblock) { - while ((c = read_kbd_data(kbdc)) == -1) + while ((c = (*kbdsw[kbd->kb_index]->read)(kbd, TRUE)) == -1) ; dt = c; } else { - if ((c = read_kbd_data_no_wait(kbdc)) == -1) + if ((c = (*kbdsw[kbd->kb_index]->read)(kbd, FALSE)) == -1) return NULL; dt = c; } -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ #endif /* !XSERVER */ -#ifndef _I386_ISA_KBDIO_H_ +#ifndef _DEV_KBD_KBDREG_H_ else { if(noblock) @@ -1662,7 +1520,7 @@ no_mouse_event: else goto loop; } -#endif /* !_I386_ISA_KBDIO_H_ */ +#endif /* !_DEV_KBD_KBDREG_H_ */ #if PCVT_SHOWKEYS showkey (' ', dt); |