Rev 3343 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3343 | Rev 3593 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | 36 | ||
37 | #include <genarch/kbd/ns16550.h> |
37 | #include <genarch/kbd/ns16550.h> |
38 | #include <genarch/kbd/key.h> |
38 | #include <genarch/kbd/key.h> |
39 | #include <genarch/kbd/scanc.h> |
39 | #include <genarch/kbd/scanc.h> |
40 | #include <genarch/kbd/scanc_sun.h> |
40 | #include <genarch/kbd/scanc_sun.h> |
- | 41 | #ifndef ia64 |
|
41 | #include <arch/drivers/kbd.h> |
42 | #include <arch/drivers/kbd.h> |
42 | #include <arch/drivers/ns16550.h> |
43 | #include <arch/drivers/ns16550.h> |
- | 44 | #endif |
|
43 | #include <ddi/irq.h> |
45 | #include <ddi/irq.h> |
44 | #include <ipc/irq.h> |
46 | #include <ipc/irq.h> |
45 | #include <cpu.h> |
47 | #include <cpu.h> |
46 | #include <arch/asm.h> |
48 | #include <arch/asm.h> |
47 | #include <arch.h> |
49 | #include <arch.h> |
Line 107... | Line 109... | ||
107 | * |
109 | * |
108 | * @param devno Device number. |
110 | * @param devno Device number. |
109 | * @param inr Interrupt number. |
111 | * @param inr Interrupt number. |
110 | * @param vaddr Virtual address of device's registers. |
112 | * @param vaddr Virtual address of device's registers. |
111 | */ |
113 | */ |
112 | void ns16550_init(devno_t devno, inr_t inr, uintptr_t vaddr) |
114 | void ns16550_init(devno_t devno, inr_t inr, ioport_t port) |
113 | { |
115 | { |
114 | chardev_initialize("ns16550_kbd", &kbrd, &ops); |
116 | chardev_initialize("ns16550_kbd", &kbrd, &ops); |
115 | stdin = &kbrd; |
117 | stdin = &kbrd; |
116 | 118 | ||
117 | ns16550.devno = devno; |
119 | ns16550.devno = devno; |
118 | ns16550.reg = (uint8_t *) vaddr; |
120 | ns16550.io_port = port; |
119 | 121 | ||
120 | irq_initialize(&ns16550_irq); |
122 | irq_initialize(&ns16550_irq); |
121 | ns16550_irq.devno = devno; |
123 | ns16550_irq.devno = devno; |
122 | ns16550_irq.inr = inr; |
124 | ns16550_irq.inr = inr; |
123 | ns16550_irq.claim = ns16550_claim; |
125 | ns16550_irq.claim = ns16550_claim; |
124 | ns16550_irq.handler = ns16550_irq_handler; |
126 | ns16550_irq.handler = ns16550_irq_handler; |
125 | irq_register(&ns16550_irq); |
127 | irq_register(&ns16550_irq); |
126 | 128 | ||
127 | sysinfo_set_item_val("kbd", NULL, true); |
129 | sysinfo_set_item_val("kbd", NULL, true); |
- | 130 | #ifndef ia64 |
|
128 | sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550); |
131 | sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550); |
- | 132 | #endif |
|
129 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
133 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
130 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
134 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
131 | sysinfo_set_item_val("kbd.address.virtual", NULL, vaddr); |
135 | sysinfo_set_item_val("kbd.address.virtual", NULL, port); |
- | 136 | ||
- | 137 | #ifdef ia64 |
|
- | 138 | uint8_t c; |
|
- | 139 | c = ns16550_lcr_read(&ns16550); |
|
- | 140 | ns16550_lcr_write(&ns16550, 0x80 | c); |
|
- | 141 | ns16550_rbr_write(&ns16550, 0x0c); |
|
- | 142 | ns16550_ier_write(&ns16550, 0x00); |
|
- | 143 | ns16550_lcr_write(&ns16550, c); |
|
- | 144 | #endif |
|
132 | 145 | ||
133 | ns16550_grab(); |
146 | ns16550_grab(); |
134 | } |
147 | } |
135 | 148 | ||
136 | /** Process ns16550 interrupt. */ |
149 | /** Process ns16550 interrupt. */ |
Line 150... | Line 163... | ||
150 | /* Called from getc(). */ |
163 | /* Called from getc(). */ |
151 | void ns16550_suspend(chardev_t *d) |
164 | void ns16550_suspend(chardev_t *d) |
152 | { |
165 | { |
153 | } |
166 | } |
154 | 167 | ||
- | 168 | ||
155 | char ns16550_key_read(chardev_t *d) |
169 | char ns16550_key_read(chardev_t *d) |
156 | { |
170 | { |
157 | char ch; |
171 | char ch; |
158 | 172 | ||
159 | while(!(ch = active_read_buff_read())) { |
173 | while(!(ch = active_read_buff_read())) { |
160 | uint8_t x; |
174 | uint8_t x; |
161 | while (!(ns16550_lsr_read(&ns16550) & LSR_DATA_READY)) |
175 | while (!(ns16550_lsr_read(&ns16550) & LSR_DATA_READY)) |
162 | ; |
176 | ; |
163 | x = ns16550_rbr_read(&ns16550); |
177 | x = ns16550_rbr_read(&ns16550); |
- | 178 | #ifndef ia64 |
|
164 | if (x != IGNORE_CODE) { |
179 | if (x != IGNORE_CODE) { |
165 | if (x & KEY_RELEASE) |
180 | if (x & KEY_RELEASE) |
166 | key_released(x ^ KEY_RELEASE); |
181 | key_released(x ^ KEY_RELEASE); |
167 | else |
182 | else |
168 | active_read_key_pressed(x); |
183 | active_read_key_pressed(x); |
169 | } |
184 | } |
- | 185 | #else |
|
- | 186 | extern chardev_t kbrd; |
|
- | 187 | if(x != 0x0d) { |
|
- | 188 | if(x == 0x7f) |
|
- | 189 | x = '\b'; |
|
- | 190 | chardev_push_character(&kbrd, x); |
|
- | 191 | } |
|
- | 192 | #endif |
|
- | 193 | ||
170 | } |
194 | } |
171 | return ch; |
195 | return ch; |
172 | } |
196 | } |
173 | 197 | ||
174 | /** Poll for key press and release events. |
198 | /** Poll for key press and release events. |
Line 199... | Line 223... | ||
199 | 223 | ||
200 | while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { |
224 | while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { |
201 | uint8_t x; |
225 | uint8_t x; |
202 | 226 | ||
203 | x = ns16550_rbr_read(&ns16550); |
227 | x = ns16550_rbr_read(&ns16550); |
- | 228 | #ifndef ia64 |
|
204 | if (x != IGNORE_CODE) { |
229 | if (x != IGNORE_CODE) { |
205 | if (x & KEY_RELEASE) |
230 | if (x & KEY_RELEASE) |
206 | key_released(x ^ KEY_RELEASE); |
231 | key_released(x ^ KEY_RELEASE); |
207 | else |
232 | else |
208 | key_pressed(x); |
233 | key_pressed(x); |
209 | } |
234 | } |
- | 235 | #else |
|
- | 236 | extern chardev_t kbrd; |
|
- | 237 | if(x != 0x0d) { |
|
- | 238 | if (x == 0x7f) |
|
- | 239 | x = '\b'; |
|
- | 240 | chardev_push_character(&kbrd, x); |
|
- | 241 | } |
|
- | 242 | #endif |
|
- | 243 | ||
210 | } |
244 | } |
211 | } |
245 | } |
212 | 246 | ||
213 | irq_ownership_t ns16550_claim(void) |
247 | irq_ownership_t ns16550_claim(void) |
214 | { |
248 | { |