Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


(no commit message)
[palacios.git] / palacios / include / geekos / keyboard.h
1 /*
2  * Keyboard driver
3  * Copyright (c) 2001, David H. Hovemeyer <daveho@cs.umd.edu>
4  * $Revision: 1.1.1.1 $
5  * 
6  * This is free software.  You are permitted to use,
7  * redistribute, and modify it as specified in the file "COPYING".
8  */
9
10 #ifndef GEEKOS_KEYBOARD_H
11 #define GEEKOS_KEYBOARD_H
12
13 #include <geekos/ktypes.h>
14
15 /* ----------------------------------------------------------------------
16  * Hardware stuff
17  * ---------------------------------------------------------------------- */
18
19 #ifdef GEEKOS
20
21 #define KB_IRQ 1
22
23 /*
24  * I/O ports
25  */
26 #define KB_CMD 0x64
27 #define KB_DATA 0x60
28
29 /*
30  * Bits in status port
31  */
32 #define KB_OUTPUT_FULL 0x01
33
34 /*
35  * High bit in scan code is set when key is released
36  */
37 #define KB_KEY_RELEASE 0x80
38
39 #endif  /* GEEKOS */
40
41 /* ----------------------------------------------------------------------
42  * Software keycodes
43  * ---------------------------------------------------------------------- */
44
45 /*
46  * Each keyboard event generates a 16 bit code.
47  * - The low 10 bits indicate which key was used.
48  * - If bit 8 (KEY_SPECIAL_FLAG) is 0, then the low 8 bits contain
49  *   the ASCII code.
50  * - The flags indicate the shift/alt/control state,
51  *   and whether the event was a make or release.
52  */
53
54 typedef ushort_t Keycode;
55
56 /*
57  * Flags
58  */
59 #define KEY_SPECIAL_FLAG 0x0100
60 #define KEY_KEYPAD_FLAG  0x0200
61 #define KEY_SHIFT_FLAG   0x1000
62 #define KEY_ALT_FLAG     0x2000
63 #define KEY_CTRL_FLAG    0x4000
64 #define KEY_RELEASE_FLAG 0x8000
65
66 /*
67  * Special key codes
68  */
69 #define _SPECIAL(num) (KEY_SPECIAL_FLAG | (num))
70 #define KEY_UNKNOWN _SPECIAL(0)
71 #define KEY_F1      _SPECIAL(1)
72 #define KEY_F2      _SPECIAL(2)
73 #define KEY_F3      _SPECIAL(3)
74 #define KEY_F4      _SPECIAL(4)
75 #define KEY_F5      _SPECIAL(5)
76 #define KEY_F6      _SPECIAL(6)
77 #define KEY_F7      _SPECIAL(7)
78 #define KEY_F8      _SPECIAL(8)
79 #define KEY_F9      _SPECIAL(9)
80 #define KEY_F10     _SPECIAL(10)
81 #define KEY_F11     _SPECIAL(11)
82 #define KEY_F12     _SPECIAL(12)
83 #define KEY_LCTRL   _SPECIAL(13)
84 #define KEY_RCTRL   _SPECIAL(14)
85 #define KEY_LSHIFT  _SPECIAL(15)
86 #define KEY_RSHIFT  _SPECIAL(16)
87 #define KEY_LALT    _SPECIAL(17)
88 #define KEY_RALT    _SPECIAL(18)
89 #define KEY_PRINTSCRN _SPECIAL(19)
90 #define KEY_CAPSLOCK _SPECIAL(20)
91 #define KEY_NUMLOCK _SPECIAL(21)
92 #define KEY_SCRLOCK _SPECIAL(22)
93 #define KEY_SYSREQ  _SPECIAL(23)
94
95 /*
96  * Keypad keys
97  */
98 #define KEYPAD_START 128
99 #define _KEYPAD(num) (KEY_KEYPAD_FLAG | KEY_SPECIAL_FLAG | (num+KEYPAD_START))
100 #define KEY_KPHOME  _KEYPAD(0)
101 #define KEY_KPUP    _KEYPAD(1)
102 #define KEY_KPPGUP  _KEYPAD(2)
103 #define KEY_KPMINUS _KEYPAD(3)
104 #define KEY_KPLEFT  _KEYPAD(4)
105 #define KEY_KPCENTER _KEYPAD(5)
106 #define KEY_KPRIGHT _KEYPAD(6)
107 #define KEY_KPPLUS  _KEYPAD(7)
108 #define KEY_KPEND   _KEYPAD(8)
109 #define KEY_KPDOWN  _KEYPAD(9)
110 #define KEY_KPPGDN  _KEYPAD(10)
111 #define KEY_KPINSERT _KEYPAD(11)
112 #define KEY_KPDEL   _KEYPAD(12)
113
114 /*
115  * ASCII codes for which there is no convenient C representation
116  */
117 #define ASCII_ESC 0x1B
118 #define ASCII_BS  0x08
119
120 #ifdef GEEKOS
121
122 /*
123  * Public functions
124  */
125 void Init_Keyboard(void);
126 bool Read_Key(Keycode* keycode);
127 Keycode Wait_For_Key(void);
128
129 #endif  /* GEEKOS */
130
131 #endif  /* GEEKOS_KEYBOARD_H */