Rev 4148 | Rev 4311 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4148 | Rev 4223 | ||
---|---|---|---|
Line 39... | Line 39... | ||
39 | #include <arch/drivers/pic.h> |
39 | #include <arch/drivers/pic.h> |
40 | #include <sysinfo/sysinfo.h> |
40 | #include <sysinfo/sysinfo.h> |
41 | #include <interrupt.h> |
41 | #include <interrupt.h> |
42 | #include <stdarg.h> |
42 | #include <stdarg.h> |
43 | #include <ddi/device.h> |
43 | #include <ddi/device.h> |
- | 44 | #include <string.h> |
|
44 | 45 | ||
45 | #define CUDA_IRQ 10 |
46 | #define CUDA_IRQ 10 |
46 | #define SPECIAL '?' |
- | |
47 | 47 | ||
48 | #define PACKET_ADB 0x00 |
48 | #define PACKET_ADB 0x00 |
49 | #define PACKET_CUDA 0x01 |
49 | #define PACKET_CUDA 0x01 |
50 | 50 | ||
51 | #define CUDA_POWERDOWN 0x0a |
51 | #define CUDA_POWERDOWN 0x0a |
52 | #define CUDA_RESET 0x11 |
52 | #define CUDA_RESET 0x11 |
53 | 53 | ||
54 | #define RS 0x200 |
54 | #define RS 0x200 |
55 | #define B (0 * RS) |
55 | #define B (0 * RS) |
56 | #define A (1 * RS) |
56 | #define A (1 * RS) |
57 | #define SR (10 * RS) |
57 | #define SR (10 * RS) |
58 | #define ACR (11 * RS) |
58 | #define ACR (11 * RS) |
59 | 59 | ||
60 | #define SR_OUT 0x10 |
60 | #define SR_OUT 0x10 |
61 | #define TACK 0x10 |
61 | #define TACK 0x10 |
62 | #define TIP 0x20 |
62 | #define TIP 0x20 |
63 | 63 | ||
- | 64 | #define SCANCODES 128 |
|
64 | 65 | ||
65 | static volatile uint8_t *cuda = NULL; |
66 | static volatile uint8_t *cuda = NULL; |
66 | static irq_t cuda_irq; /**< Cuda's IRQ. */ |
67 | static irq_t cuda_irq; /**< Cuda's IRQ. */ |
67 | 68 | ||
68 | static char lchars[0x80] = { |
69 | static wchar_t lchars[SCANCODES] = { |
69 | 'a', |
70 | 'a', 's', 'd', 'f', 'h', 'g', 'z', 'x', 'c', 'v', |
70 | 's', |
71 | U_SPECIAL, |
71 | 'd', |
72 | 'b', 'q', 'w', 'e', 'r', 'y', 't', '1', '2', '3', '4', '6', '5', |
72 | 'f', |
73 | '=', '9', '7', '-', '8', '0', ']', 'o', 'u', '[', 'i', 'p', |
73 | 'h', |
74 | '\n', /* Enter */ |
74 | 'g', |
75 | 'l', 'j', '\'', 'k', ';', '\\', ',', '/', 'n', 'm', '.', |
75 | 'z', |
76 | '\t', /* Tab */ |
76 | 'x', |
77 | ' ', '`', |
77 | 'c', |
78 | '\b', /* Backspace */ |
78 | 'v', |
79 | U_SPECIAL, |
79 | SPECIAL, |
80 | U_ESCAPE, /* Escape */ |
80 | 'b', |
81 | U_SPECIAL, /* Ctrl */ |
81 | 'q', |
82 | U_SPECIAL, /* Alt */ |
82 | 'w', |
83 | U_SPECIAL, /* Shift */ |
83 | 'e', |
84 | U_SPECIAL, /* CapsLock */ |
84 | 'r', |
85 | U_SPECIAL, /* Right Alt */ |
85 | 'y', |
86 | U_LEFT_ARROW, /* Left */ |
86 | 't', |
87 | U_RIGHT_ARROW, /* Right */ |
87 | '1', |
88 | U_DOWN_ARROW, /* Down */ |
88 | '2', |
89 | U_UP_ARROW, /* Up */ |
89 | '3', |
90 | U_SPECIAL, |
90 | '4', |
91 | U_SPECIAL, |
91 | '6', |
92 | '.', /* Keypad . */ |
92 | '5', |
93 | U_SPECIAL, |
93 | '=', |
94 | '*', /* Keypad * */ |
94 | '9', |
95 | U_SPECIAL, |
95 | '7', |
96 | '+', /* Keypad + */ |
96 | '-', |
97 | U_SPECIAL, |
97 | '8', |
98 | U_SPECIAL, /* NumLock */ |
98 | '0', |
99 | U_SPECIAL, |
99 | ']', |
100 | U_SPECIAL, |
100 | 'o', |
101 | U_SPECIAL, |
101 | 'u', |
102 | '/', /* Keypad / */ |
102 | '[', |
103 | '\n', /* Keypad Enter */ |
103 | 'i', |
104 | U_SPECIAL, |
104 | 'p', |
105 | '-', /* Keypad - */ |
105 | '\n', /* Enter */ |
106 | U_SPECIAL, |
106 | 'l', |
107 | U_SPECIAL, |
107 | 'j', |
108 | U_SPECIAL, |
108 | '\'', |
109 | '0', /* Keypad 0 */ |
109 | 'k', |
110 | '1', /* Keypad 1 */ |
110 | ';', |
111 | '2', /* Keypad 2 */ |
111 | '\\', |
112 | '3', /* Keypad 3 */ |
112 | ',', |
113 | '4', /* Keypad 4 */ |
113 | '/', |
114 | '5', /* Keypad 5 */ |
114 | 'n', |
115 | '6', /* Keypad 6 */ |
115 | 'm', |
116 | '7', /* Keypad 7 */ |
116 | '.', |
117 | U_SPECIAL, |
117 | '\t', /* Tab */ |
118 | '8', /* Keypad 8 */ |
118 | ' ', |
119 | '9', /* Keypad 9 */ |
119 | '`', |
120 | U_SPECIAL, |
120 | '\b', /* Backspace */ |
121 | U_SPECIAL, |
121 | SPECIAL, |
122 | U_SPECIAL, |
122 | SPECIAL, /* Escape */ |
123 | U_SPECIAL, /* F5 */ |
123 | SPECIAL, /* Ctrl */ |
124 | U_SPECIAL, /* F6 */ |
124 | SPECIAL, /* Alt */ |
125 | U_SPECIAL, /* F7 */ |
125 | SPECIAL, /* Shift */ |
126 | U_SPECIAL, /* F3 */ |
126 | SPECIAL, /* Caps-Lock */ |
127 | U_SPECIAL, /* F8 */ |
127 | SPECIAL, /* RAlt */ |
128 | U_SPECIAL, /* F9 */ |
128 | SPECIAL, /* Left */ |
129 | U_SPECIAL, |
129 | SPECIAL, /* Right */ |
130 | U_SPECIAL, /* F11 */ |
130 | SPECIAL, /* Down */ |
131 | U_SPECIAL, |
131 | SPECIAL, /* Up */ |
132 | U_SPECIAL, /* F13 */ |
132 | SPECIAL, |
133 | U_SPECIAL, |
133 | SPECIAL, |
134 | U_SPECIAL, /* ScrollLock */ |
134 | '.', /* Keypad . */ |
135 | U_SPECIAL, |
135 | SPECIAL, |
136 | U_SPECIAL, /* F10 */ |
136 | '*', /* Keypad * */ |
137 | U_SPECIAL, |
137 | SPECIAL, |
138 | U_SPECIAL, /* F12 */ |
138 | '+', /* Keypad + */ |
139 | U_SPECIAL, |
139 | SPECIAL, |
140 | U_SPECIAL, /* Pause */ |
140 | SPECIAL, /* NumLock */ |
141 | U_SPECIAL, /* Insert */ |
141 | SPECIAL, |
142 | U_HOME_ARROW, /* Home */ |
142 | SPECIAL, |
143 | U_PAGE_UP, /* Page Up */ |
143 | SPECIAL, |
144 | U_DELETE, /* Delete */ |
144 | '/', /* Keypad / */ |
145 | U_SPECIAL, /* F4 */ |
145 | '\n', /* Keypad Enter */ |
146 | U_END_ARROW, /* End */ |
146 | SPECIAL, |
147 | U_SPECIAL, /* F2 */ |
147 | '-', /* Keypad - */ |
148 | U_PAGE_DOWN, /* Page Down */ |
148 | SPECIAL, |
149 | U_SPECIAL /* F1 */ |
149 | SPECIAL, |
- | |
150 | SPECIAL, |
- | |
151 | '0', /* Keypad 0 */ |
- | |
152 | '1', /* Keypad 1 */ |
- | |
153 | '2', /* Keypad 2 */ |
- | |
154 | '3', /* Keypad 3 */ |
- | |
155 | '4', /* Keypad 4 */ |
- | |
156 | '5', /* Keypad 5 */ |
- | |
157 | '6', /* Keypad 6 */ |
- | |
158 | '7', /* Keypad 7 */ |
- | |
159 | SPECIAL, |
- | |
160 | '8', /* Keypad 8 */ |
- | |
161 | '9', /* Keypad 9 */ |
- | |
162 | SPECIAL, |
- | |
163 | SPECIAL, |
- | |
164 | SPECIAL, |
- | |
165 | SPECIAL, /* F5 */ |
- | |
166 | SPECIAL, /* F6 */ |
- | |
167 | SPECIAL, /* F7 */ |
- | |
168 | SPECIAL, /* F3 */ |
- | |
169 | SPECIAL, /* F8 */ |
- | |
170 | SPECIAL, /* F9 */ |
- | |
171 | SPECIAL, |
- | |
172 | SPECIAL, /* F11 */ |
- | |
173 | SPECIAL, |
- | |
174 | SPECIAL, /* F13 */ |
- | |
175 | SPECIAL, |
- | |
176 | SPECIAL, /* ScrollLock */ |
- | |
177 | SPECIAL, |
- | |
178 | SPECIAL, /* F10 */ |
- | |
179 | SPECIAL, |
- | |
180 | SPECIAL, /* F12 */ |
- | |
181 | SPECIAL, |
- | |
182 | SPECIAL, /* Pause */ |
- | |
183 | SPECIAL, /* Insert */ |
- | |
184 | SPECIAL, /* Home */ |
- | |
185 | SPECIAL, /* PageUp */ |
- | |
186 | SPECIAL, /* Delete */ |
- | |
187 | SPECIAL, /* F4 */ |
- | |
188 | SPECIAL, /* End */ |
- | |
189 | SPECIAL, /* F2 */ |
- | |
190 | SPECIAL, /* PageDown */ |
- | |
191 | SPECIAL /* F1 */ |
- | |
192 | }; |
150 | }; |
193 | 151 | ||
194 | - | ||
195 | static void receive_packet(uint8_t *kind, index_t count, uint8_t data[]) |
152 | static void receive_packet(uint8_t *kind, index_t count, uint8_t data[]) |
196 | { |
153 | { |
197 | cuda[B] = cuda[B] & ~TIP; |
154 | cuda[B] = cuda[B] & ~TIP; |
198 | *kind = cuda[SR]; |
155 | *kind = cuda[SR]; |
199 | 156 | ||
Line 202... | Line 159... | ||
202 | data[i] = cuda[SR]; |
159 | data[i] = cuda[SR]; |
203 | 160 | ||
204 | cuda[B] = cuda[B] | TIP; |
161 | cuda[B] = cuda[B] | TIP; |
205 | } |
162 | } |
206 | 163 | ||
207 | - | ||
208 | static indev_t kbrd; |
164 | static indev_t kbrd; |
209 | static indev_operations_t ops = { |
165 | static indev_operations_t ops = { |
210 | .poll = NULL |
166 | .poll = NULL |
211 | }; |
167 | }; |
212 | 168 | ||
213 | - | ||
214 | int cuda_get_scancode(void) |
169 | int cuda_get_scancode(void) |
215 | { |
170 | { |
216 | if (cuda) { |
171 | if (cuda) { |
217 | uint8_t kind; |
172 | uint8_t kind; |
218 | uint8_t data[4]; |
173 | uint8_t data[4]; |
Line 261... | Line 216... | ||
261 | sysinfo_set_item_val("kbd", NULL, true); |
216 | sysinfo_set_item_val("kbd", NULL, true); |
262 | sysinfo_set_item_val("kbd.inr", NULL, CUDA_IRQ); |
217 | sysinfo_set_item_val("kbd.inr", NULL, CUDA_IRQ); |
263 | sysinfo_set_item_val("kbd.address.virtual", NULL, base); |
218 | sysinfo_set_item_val("kbd.address.virtual", NULL, base); |
264 | } |
219 | } |
265 | 220 | ||
266 | - | ||
267 | static void send_packet(const uint8_t kind, count_t count, ...) |
221 | static void send_packet(const uint8_t kind, count_t count, ...) |
268 | { |
222 | { |
269 | index_t i; |
223 | index_t i; |
270 | va_list va; |
224 | va_list va; |
271 | 225 | ||
Line 285... | Line 239... | ||
285 | va_end(va); |
239 | va_end(va); |
286 | 240 | ||
287 | cuda[B] = cuda[B] | TIP; |
241 | cuda[B] = cuda[B] | TIP; |
288 | } |
242 | } |
289 | 243 | ||
290 | - | ||
291 | void cpu_halt(void) { |
244 | void cpu_halt(void) { |
292 | asm volatile ( |
245 | asm volatile ( |
293 | "b 0\n" |
246 | "b 0\n" |
294 | ); |
247 | ); |
295 | } |
248 | } |