Revision 60
changes
lab3.c | ||
---|---|---|
5 | 5 |
#include <stdint.h> |
6 | 6 |
|
7 | 7 |
#include "kbc.h" |
8 |
#include "kbc_func.h" |
|
9 |
#include "timer_func.h" |
|
8 |
#include "kbc_macros.h" |
|
9 |
#include "keyboard.h" |
|
10 |
#include "timer.h" |
|
11 |
#include "utils.h" |
|
10 | 12 |
|
11 | 13 |
int main(int argc, char *argv[]) { |
12 | 14 |
// sets the language of LCF messages (can be either EN-US or PT-PT) |
... | ... | |
32 | 34 |
return 0; |
33 | 35 |
} |
34 | 36 |
|
35 |
extern uint8_t scancode[2]; |
|
36 |
extern int sz; |
|
37 |
extern int done; |
|
38 |
extern int got_error; |
|
39 |
extern uint32_t sys_inb_counter; |
|
40 |
|
|
41 | 37 |
int(kbd_test_scan)() { |
42 | 38 |
/// loop stuff |
43 | 39 |
int ipc_status, r; |
... | ... | |
46 | 42 |
uint8_t kbc_irq_bit = 1; |
47 | 43 |
int kbc_id = 0; |
48 | 44 |
int kbc_irq = BIT(kbc_irq_bit); |
49 |
if (subscribe_kbc_interrupt(kbc_irq_bit, &kbc_id)) return 1;
|
|
45 |
if (subscribe_keyboard_interrupt(kbc_irq_bit, &kbc_id)) return 1;
|
|
50 | 46 |
/// cycle |
51 | 47 |
int good = 1; |
52 | 48 |
while (good) { |
... | ... | |
60 | 56 |
case HARDWARE: /* hardware interrupt notification */ |
61 | 57 |
if (msg.m_notify.interrupts & kbc_irq) { /* subscribed interrupt */ |
62 | 58 |
kbc_ih(); |
59 |
if (!(two_byte_scancode || got_error_keyboard)) { /* finished processing a scancode */ |
|
60 |
if (scancode[0] == TWO_BYTE_CODE) kbd_print_scancode(!(scancode[1] & BREAK_CODE_BIT), 2, scancode); |
|
61 |
else kbd_print_scancode(!(scancode[0] & BREAK_CODE_BIT), 1, scancode); |
|
62 |
} else { break; } |
|
63 | 63 |
if(done) |
64 | 64 |
kbd_print_scancode(!(scancode[sz-1] & BREAK_CODE_BIT), sz, scancode); |
65 |
|
|
66 | 65 |
if (scancode[0] == ESC_BREAK_CODE) good = 0; |
67 | 66 |
} |
68 | 67 |
break; |
... | ... | |
84 | 83 |
int(kbd_test_poll)() { |
85 | 84 |
uint8_t c[2]; uint8_t size; |
86 | 85 |
do{ |
87 |
if(kbd_poll(c, &size)) return 1;
|
|
86 |
if(keyboard_poll(c, &size)) return 1;
|
|
88 | 87 |
if(kbd_print_scancode((~c[size-1])&BREAK_CODE_BIT, size, c)) return 1; |
89 | 88 |
}while(!(size == 1 && c[0] == ESC_BREAK_CODE)); |
90 | 89 |
|
91 |
if(kbc_restore_kbd()) return 1;
|
|
90 |
if(kbc_restore_keyboard()) return 1;
|
|
92 | 91 |
|
93 | 92 |
if(kbd_print_no_sysinb(sys_inb_counter)) return 1; |
94 | 93 |
|
95 | 94 |
return 0; |
96 | 95 |
} |
97 | 96 |
|
98 |
extern int no_interrupts; |
|
99 |
|
|
100 | 97 |
int(kbd_test_timed_scan)(uint8_t idle) { |
101 | 98 |
/// loop stuff |
102 | 99 |
int ipc_status, r; |
... | ... | |
114 | 111 |
uint8_t kbc_irq_bit = 1; |
115 | 112 |
int kbc_id = 0; |
116 | 113 |
int kbc_irq = BIT(kbc_irq_bit); |
117 |
if(subscribe_kbc_interrupt(kbc_irq_bit, &kbc_id)) return 1;
|
|
114 |
if(subscribe_keyboard_interrupt(kbc_irq_bit, &kbc_id)) return 1;
|
|
118 | 115 |
/// cycle |
119 | 116 |
int good = 1; |
120 | 117 |
while (good) { |
... | ... | |
134 | 131 |
} |
135 | 132 |
if (msg.m_notify.interrupts & kbc_irq) { /// subscribed interrupt |
136 | 133 |
kbc_ih(); |
134 |
|
|
135 |
if (!(two_byte_scancode || got_error_keyboard)) { /// finished processing a scancode |
|
136 |
if (scancode[0] == TWO_BYTE_CODE) kbd_print_scancode(!(scancode[1] & BREAK_CODE_BIT), 2, scancode); |
|
137 |
else kbd_print_scancode(!(scancode[0] & BREAK_CODE_BIT), 1, scancode); |
|
137 | 138 |
if(done) { |
138 | 139 |
kbd_print_scancode(!(scancode[sz-1] & BREAK_CODE_BIT), sz, scancode); |
139 | 140 |
time = 0; |
Also available in: Unified diff