• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <errno.h>
4 #include <string.h>
5 #include <sys/cpu.h>
6 
drain_keyboard(void)7 void drain_keyboard(void)
8 {
9     /* Prevent "ghost typing" and keyboard buffer snooping */
10     volatile char junk;
11     int rv;
12 
13     do {
14 	rv = read(0, (char *)&junk, 1);
15     } while (rv > 0);
16 
17     junk = 0;
18 
19     cli();
20     *(volatile uint8_t *)0x419 = 0;	/* Alt-XXX keyboard area */
21     *(volatile uint16_t *)0x41a = 0x1e;	/* Keyboard buffer empty */
22     *(volatile uint16_t *)0x41c = 0x1e;
23     memset((void *)0x41e, 0, 32);	/* Clear the actual keyboard buffer */
24     sti();
25 }
26