summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2009-09-25 19:49:07 +0000
committerjkim <jkim@FreeBSD.org>2009-09-25 19:49:07 +0000
commit1e05d21cdd005b91bfe7df21692f0ce6c5eaa929 (patch)
treee6e9e4b0977953514ca637b6eb0d2f582ca416ca
parent57ef38956f8d5f95111c82b8348b8365a5a17dcd (diff)
downloadFreeBSD-src-1e05d21cdd005b91bfe7df21692f0ce6c5eaa929.zip
FreeBSD-src-1e05d21cdd005b91bfe7df21692f0ce6c5eaa929.tar.gz
- Use x86bios_offset() instead of BIOS_PADDRTOVADDR() macro.[1]
- Clear all registers before calling real mode interrupt handlers as we did for dpms and vesa and re-enable the function as it should be fixed by this. - Tidy up register access. For example, when we call INT 0x15, AH=0xc0, we used to initialize AX=0xc000 to clear AL at the same time but it is very confusing. We don't have to do this any more because we are explicitly clearing all registers now. - Check size of system configuration table although it is almost always 8. This is to make sure we are not reading some random low physical memory. Hopefully it is just zero in that case. :-) - Fix some style nits and add more comments. Submitted by: paradox (ddkprog yahoo com)[1]
-rw-r--r--sys/dev/atkbdc/atkbd.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c
index beaee1e..6fc2a1f 100644
--- a/sys/dev/atkbdc/atkbd.c
+++ b/sys/dev/atkbdc/atkbd.c
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <machine/resource.h>
-#if 0
+#if defined(__i386__) || defined(__amd64__)
#include <machine/md_var.h>
#include <machine/psl.h>
#include <compat/x86bios/x86bios.h>
@@ -1089,32 +1089,41 @@ atkbd_shutdown_final(void *v)
static int
get_typematic(keyboard_t *kbd)
{
-#if 0
+#if defined(__i386__) || defined(__amd64__)
/*
* Only some systems allow us to retrieve the keyboard repeat
* rate previously set via the BIOS...
*/
x86regs_t regs;
- vm_offset_t p;
+ uint8_t *p;
- regs.R_AX = 0xc000;
+ /* Is BIOS system configuration table supported? */
+ bzero(&regs, sizeof(regs));
+ regs.R_AH = 0xc0;
x86bios_intr(&regs, 0x15);
- if ((regs.R_EFLG & PSL_C) || regs.R_AH)
- return ENODEV;
- p = BIOS_PADDRTOVADDR((regs.R_ES << 4) + regs.R_BX);
- if ((readb(p + 6) & 0x40) == 0) /* int 16, function 0x09 supported? */
- return ENODEV;
- regs.R_AX = 0x0900;
+ if ((regs.R_FLG & PSL_C) || regs.R_AH)
+ 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(&regs, sizeof(regs));
+ regs.R_AH = 0x09;
x86bios_intr(&regs, 0x16);
- if ((regs.R_AL & 0x08) == 0) /* int 16, function 0x0306 supported? */
- return ENODEV;
+ if ((regs.R_AL & 0x08) == 0)
+ return (ENODEV);
+
+ bzero(&regs, sizeof(regs));
regs.R_AX = 0x0306;
x86bios_intr(&regs, 0x16);
kbd->kb_delay1 = typematic_delay(regs.R_BH << 5);
kbd->kb_delay2 = typematic_rate(regs.R_BL);
- return 0;
+ return (0);
#else
- return ENODEV;
+ return (ENODEV);
#endif /* __i386__ || __amd64__ */
}
OpenPOWER on IntegriCloud