diff options
Diffstat (limited to 'sys/dev/atkbdc/atkbd.c')
-rw-r--r-- | sys/dev/atkbdc/atkbd.c | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index 0aae153..59d9632 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -44,10 +44,10 @@ __FBSDID("$FreeBSD$"); #include <machine/bus.h> #include <machine/resource.h> -#ifdef __i386__ +#if defined(__i386__) || defined(__amd64__) #include <machine/md_var.h> #include <machine/psl.h> -#include <machine/vm86.h> +#include <compat/x86bios/x86bios.h> #include <machine/pc/bios.h> #include <vm/vm.h> @@ -55,7 +55,7 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_param.h> #include <isa/isareg.h> -#endif /* __i386__ */ +#endif /* __i386__ || __amd64__ */ #include <sys/kbio.h> #include <dev/kbd/kbdreg.h> @@ -1089,34 +1089,42 @@ atkbd_shutdown_final(void *v) static int get_typematic(keyboard_t *kbd) { -#ifdef __i386__ +#if defined(__i386__) || defined(__amd64__) /* * Only some systems allow us to retrieve the keyboard repeat * rate previously set via the BIOS... */ - struct vm86frame vmf; - u_int32_t p; - - bzero(&vmf, sizeof(vmf)); - vmf.vmf_ax = 0xc000; - vm86_intcall(0x15, &vmf); - if ((vmf.vmf_eflags & PSL_C) || vmf.vmf_ah) - return ENODEV; - p = BIOS_PADDRTOVADDR(((u_int32_t)vmf.vmf_es << 4) + vmf.vmf_bx); - if ((readb(p + 6) & 0x40) == 0) /* int 16, function 0x09 supported? */ - return ENODEV; - vmf.vmf_ax = 0x0900; - vm86_intcall(0x16, &vmf); - if ((vmf.vmf_al & 0x08) == 0) /* int 16, function 0x0306 supported? */ - return ENODEV; - vmf.vmf_ax = 0x0306; - vm86_intcall(0x16, &vmf); - kbd->kb_delay1 = typematic_delay(vmf.vmf_bh << 5); - kbd->kb_delay2 = typematic_rate(vmf.vmf_bl); - return 0; + x86regs_t regs; + uint8_t *p; + + /* Is BIOS system configuration table supported? */ + bzero(®s, sizeof(regs)); + regs.R_AH = 0xc0; + x86bios_intr(®s, 0x15); + if ((regs.R_FLG & PSL_C) != 0 || regs.R_AH != 0) + return (ENODEV); + + /* Is int 16, function 0x09 supported? */ + p = x86bios_offset((regs.R_ES << 4) + regs.R_BX); + if (readw(p) < 5 || (readb(p + 6) & 0x40) == 0) + return (ENODEV); + + /* Is int 16, function 0x0306 supported? */ + bzero(®s, sizeof(regs)); + regs.R_AH = 0x09; + x86bios_intr(®s, 0x16); + if ((regs.R_AL & 0x08) == 0) + return (ENODEV); + + bzero(®s, sizeof(regs)); + regs.R_AX = 0x0306; + x86bios_intr(®s, 0x16); + kbd->kb_delay1 = typematic_delay(regs.R_BH << 5); + kbd->kb_delay2 = typematic_rate(regs.R_BL); + return (0); #else - return ENODEV; -#endif /* __i386__ */ + return (ENODEV); +#endif /* __i386__ || __amd64__ */ } static int |