Rev 3657 | Rev 3900 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3657 | Rev 3877 | ||
---|---|---|---|
Line 37... | Line 37... | ||
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 | #include <arch/drivers/kbd.h> |
41 | #include <arch/drivers/kbd.h> |
42 | #ifndef ia64 |
- | |
43 | #include <arch/drivers/ns16550.h> |
- | |
44 | #endif |
- | |
45 | #include <ddi/irq.h> |
42 | #include <ddi/irq.h> |
46 | #include <ipc/irq.h> |
43 | #include <ipc/irq.h> |
47 | #include <cpu.h> |
44 | #include <cpu.h> |
48 | #include <arch/asm.h> |
45 | #include <arch/asm.h> |
49 | #include <arch.h> |
46 | #include <arch.h> |
Line 128... | Line 125... | ||
128 | ns16550_irq.claim = ns16550_claim; |
125 | ns16550_irq.claim = ns16550_claim; |
129 | ns16550_irq.handler = ns16550_irq_handler; |
126 | ns16550_irq.handler = ns16550_irq_handler; |
130 | ns16550_irq.cir = cir; |
127 | ns16550_irq.cir = cir; |
131 | ns16550_irq.cir_arg = cir_arg; |
128 | ns16550_irq.cir_arg = cir_arg; |
132 | irq_register(&ns16550_irq); |
129 | irq_register(&ns16550_irq); |
133 | - | ||
134 | 130 | ||
135 | while ((ns16550_lsr_read(&ns16550) & LSR_DATA_READY)) |
131 | while ((ns16550_lsr_read(&ns16550) & LSR_DATA_READY)) |
136 | ns16550_rbr_read(&ns16550); |
132 | ns16550_rbr_read(&ns16550); |
137 | - | ||
138 | 133 | ||
139 | sysinfo_set_item_val("kbd", NULL, true); |
134 | sysinfo_set_item_val("kbd", NULL, true); |
140 | sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550); |
135 | sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550); |
141 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
136 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
142 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
137 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
143 | sysinfo_set_item_val("kbd.address.virtual", NULL, port); |
138 | sysinfo_set_item_val("kbd.address.virtual", NULL, port); |
144 | sysinfo_set_item_val("kbd.port", NULL, port); |
139 | sysinfo_set_item_val("kbd.port", NULL, port); |
145 | 140 | ||
146 | #ifdef CONFIG_NS16550_INTERRUPT_DRIVEN |
141 | #ifdef CONFIG_NS16550_INTERRUPT_DRIVEN |
147 | /* Enable interrupts */ |
142 | /* Enable interrupts */ |
148 | ns16550_ier_write(&ns16550, IER_ERBFI); |
143 | ns16550_ier_write(&ns16550, IER_ERBFI); |
149 | ns16550_mcr_write(&ns16550, MCR_OUT2); |
144 | ns16550_mcr_write(&ns16550, MCR_OUT2); |
150 | #endif |
145 | #endif |
151 | 146 | ||
152 | #ifdef ia64 |
- | |
153 | uint8_t c; |
147 | uint8_t c; |
154 | // This switches rbr & ier to mode when accept baudrate constant |
148 | // This switches rbr & ier to mode when accept baudrate constant |
155 | c = ns16550_lcr_read(&ns16550); |
149 | c = ns16550_lcr_read(&ns16550); |
156 | ns16550_lcr_write(&ns16550, 0x80 | c); |
150 | ns16550_lcr_write(&ns16550, 0x80 | c); |
157 | ns16550_rbr_write(&ns16550, 0x0c); |
151 | ns16550_rbr_write(&ns16550, 0x0c); |
158 | ns16550_ier_write(&ns16550, 0x00); |
152 | ns16550_ier_write(&ns16550, 0x00); |
159 | ns16550_lcr_write(&ns16550, c); |
153 | ns16550_lcr_write(&ns16550, c); |
160 | #endif |
- | |
161 | 154 | ||
162 | ns16550_grab(); |
155 | ns16550_grab(); |
163 | } |
156 | } |
164 | 157 | ||
165 | /** Process ns16550 interrupt. */ |
158 | /** Process ns16550 interrupt. */ |
Line 183... | Line 176... | ||
183 | { |
176 | { |
184 | char ch; |
177 | char ch; |
185 | 178 | ||
186 | while(!(ch = active_read_buff_read())) { |
179 | while(!(ch = active_read_buff_read())) { |
187 | uint8_t x; |
180 | uint8_t x; |
188 | while (!(ns16550_lsr_read(&ns16550) & LSR_DATA_READY)) |
181 | while (!(ns16550_lsr_read(&ns16550) & LSR_DATA_READY)); |
189 | ; |
182 | |
190 | x = ns16550_rbr_read(&ns16550); |
183 | x = ns16550_rbr_read(&ns16550); |
191 | #ifndef ia64 |
184 | |
192 | if (x != IGNORE_CODE) { |
185 | if (x != IGNORE_CODE) { |
193 | if (x & KEY_RELEASE) |
186 | if (x & KEY_RELEASE) |
194 | key_released(x ^ KEY_RELEASE); |
187 | key_released(x ^ KEY_RELEASE); |
195 | else |
188 | else |
196 | active_read_key_pressed(x); |
189 | active_read_key_pressed(x); |
197 | } |
190 | } |
198 | #else |
- | |
199 | extern chardev_t kbrd; |
- | |
200 | if(x != 0x0d) { |
- | |
201 | if(x == 0x7f) |
- | |
202 | x = '\b'; |
- | |
203 | chardev_push_character(&kbrd, x); |
- | |
204 | } |
- | |
205 | #endif |
- | |
206 | - | ||
207 | } |
191 | } |
208 | return ch; |
192 | return ch; |
209 | } |
193 | } |
210 | 194 | ||
211 | /** Poll for key press and release events. |
195 | /** Poll for key press and release events. |
212 | * |
196 | * |
213 | * This function can be used to implement keyboard polling. |
197 | * This function can be used to implement keyboard polling. |
214 | */ |
198 | */ |
215 | void ns16550_poll(void) |
199 | void ns16550_poll(void) |
216 | { |
200 | { |
217 | #ifndef CONFIG_NS16550_INTERRUPT_DRIVEN |
201 | #ifndef CONFIG_NS16550_INTERRUPT_DRIVEN |
218 | ipl_t ipl; |
202 | ipl_t ipl; |
219 | 203 | ||
220 | ipl = interrupts_disable(); |
204 | ipl = interrupts_disable(); |
221 | spinlock_lock(&ns16550_irq.lock); |
205 | spinlock_lock(&ns16550_irq.lock); |
222 | 206 | ||
Line 238... | Line 222... | ||
238 | 222 | ||
239 | while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { |
223 | while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) { |
240 | uint8_t x; |
224 | uint8_t x; |
241 | 225 | ||
242 | x = ns16550_rbr_read(&ns16550); |
226 | x = ns16550_rbr_read(&ns16550); |
243 | #ifndef ia64 |
227 | |
244 | if (x != IGNORE_CODE) { |
228 | if (x != IGNORE_CODE) { |
245 | if (x & KEY_RELEASE) |
229 | if (x & KEY_RELEASE) |
246 | key_released(x ^ KEY_RELEASE); |
230 | key_released(x ^ KEY_RELEASE); |
247 | else |
231 | else |
248 | key_pressed(x); |
232 | key_pressed(x); |
249 | } |
233 | } |
250 | #else |
- | |
251 | extern chardev_t kbrd; |
- | |
252 | if(x != 0x0d) { |
- | |
253 | if (x == 0x7f) |
- | |
254 | x = '\b'; |
- | |
255 | chardev_push_character(&kbrd, x); |
- | |
256 | } |
- | |
257 | #endif |
- | |
258 | - | ||
259 | } |
234 | } |
260 | } |
235 | } |
261 | 236 | ||
262 | irq_ownership_t ns16550_claim(void) |
237 | irq_ownership_t ns16550_claim(void) |
263 | { |
238 | { |