《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
3.8 KiB

10 years ago
  1. #ifndef __KERN_DRIVER_KBDREG_H__
  2. #define __KERN_DRIVER_KBDREG_H__
  3. // Special keycodes
  4. #define KEY_HOME 0xE0
  5. #define KEY_END 0xE1
  6. #define KEY_UP 0xE2
  7. #define KEY_DN 0xE3
  8. #define KEY_LF 0xE4
  9. #define KEY_RT 0xE5
  10. #define KEY_PGUP 0xE6
  11. #define KEY_PGDN 0xE7
  12. #define KEY_INS 0xE8
  13. #define KEY_DEL 0xE9
  14. /* This is i8042reg.h + kbdreg.h from NetBSD. */
  15. #define KBSTATP 0x64 // kbd controller status port(I)
  16. #define KBS_DIB 0x01 // kbd data in buffer
  17. #define KBS_IBF 0x02 // kbd input buffer low
  18. #define KBS_WARM 0x04 // kbd input buffer low
  19. #define BS_OCMD 0x08 // kbd output buffer has command
  20. #define KBS_NOSEC 0x10 // kbd security lock not engaged
  21. #define KBS_TERR 0x20 // kbd transmission error
  22. #define KBS_RERR 0x40 // kbd receive error
  23. #define KBS_PERR 0x80 // kbd parity error
  24. #define KBCMDP 0x64 // kbd controller port(O)
  25. #define KBC_RAMREAD 0x20 // read from RAM
  26. #define KBC_RAMWRITE 0x60 // write to RAM
  27. #define KBC_AUXDISABLE 0xa7 // disable auxiliary port
  28. #define KBC_AUXENABLE 0xa8 // enable auxiliary port
  29. #define KBC_AUXTEST 0xa9 // test auxiliary port
  30. #define KBC_KBDECHO 0xd2 // echo to keyboard port
  31. #define KBC_AUXECHO 0xd3 // echo to auxiliary port
  32. #define KBC_AUXWRITE 0xd4 // write to auxiliary port
  33. #define KBC_SELFTEST 0xaa // start self-test
  34. #define KBC_KBDTEST 0xab // test keyboard port
  35. #define KBC_KBDDISABLE 0xad // disable keyboard port
  36. #define KBC_KBDENABLE 0xae // enable keyboard port
  37. #define KBC_PULSE0 0xfe // pulse output bit 0
  38. #define KBC_PULSE1 0xfd // pulse output bit 1
  39. #define KBC_PULSE2 0xfb // pulse output bit 2
  40. #define KBC_PULSE3 0xf7 // pulse output bit 3
  41. #define KBDATAP 0x60 // kbd data port(I)
  42. #define KBOUTP 0x60 // kbd data port(O)
  43. #define K_RDCMDBYTE 0x20
  44. #define K_LDCMDBYTE 0x60
  45. #define KC8_TRANS 0x40 // convert to old scan codes
  46. #define KC8_MDISABLE 0x20 // disable mouse
  47. #define KC8_KDISABLE 0x10 // disable keyboard
  48. #define KC8_IGNSEC 0x08 // ignore security lock
  49. #define KC8_CPU 0x04 // exit from protected mode reset
  50. #define KC8_MENABLE 0x02 // enable mouse interrupt
  51. #define KC8_KENABLE 0x01 // enable keyboard interrupt
  52. #define CMDBYTE (KC8_TRANS|KC8_CPU|KC8_MENABLE|KC8_KENABLE)
  53. /* keyboard commands */
  54. #define KBC_RESET 0xFF // reset the keyboard
  55. #define KBC_RESEND 0xFE // request the keyboard resend the last byte
  56. #define KBC_SETDEFAULT 0xF6 // resets keyboard to its power-on defaults
  57. #define KBC_DISABLE 0xF5 // as per KBC_SETDEFAULT, but also disable key scanning
  58. #define KBC_ENABLE 0xF4 // enable key scanning
  59. #define KBC_TYPEMATIC 0xF3 // set typematic rate and delay
  60. #define KBC_SETTABLE 0xF0 // set scancode translation table
  61. #define KBC_MODEIND 0xED // set mode indicators(i.e. LEDs)
  62. #define KBC_ECHO 0xEE // request an echo from the keyboard
  63. /* keyboard responses */
  64. #define KBR_EXTENDED 0xE0 // extended key sequence
  65. #define KBR_RESEND 0xFE // needs resend of command
  66. #define KBR_ACK 0xFA // received a valid command
  67. #define KBR_OVERRUN 0x00 // flooded
  68. #define KBR_FAILURE 0xFD // diagnosic failure
  69. #define KBR_BREAK 0xF0 // break code prefix - sent on key release
  70. #define KBR_RSTDONE 0xAA // reset complete
  71. #define KBR_ECHO 0xEE // echo response
  72. #endif /* !__KERN_DRIVER_KBDREG_H__ */