Changeset 4544884 in mainline for kernel/genarch/src/kbd/i8042.c
- Timestamp:
- 2009-02-19T22:04:20Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 91825d90
- Parents:
- 5cb223f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/kbd/i8042.c
r5cb223f r4544884 51 51 #include <ipc/irq.h> 52 52 53 #define i8042_DATA 0x60 54 #define i8042_STATUS 0x64 53 i8042_instance_t lgcy_i8042_instance = { 54 .i8042 = (i8042_t *) 0x60, 55 }; 55 56 56 57 /* Keyboard commands. */ … … 128 129 static irq_ownership_t i8042_claim(void *instance) 129 130 { 130 return IRQ_ACCEPT; 131 i8042_instance_t *i8042_instance = instance; 132 i8042_t *dev = i8042_instance->i8042; 133 if (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) 134 return IRQ_ACCEPT; 135 else 136 return IRQ_DECLINE; 131 137 } 132 138 133 139 static void i8042_irq_handler(irq_t *irq) 134 140 { 135 if (irq->notif_cfg.notify && irq->notif_cfg.answerbox) 141 if (irq->notif_cfg.notify && irq->notif_cfg.answerbox) { 142 /* 143 * This will hopefully go to the IRQ dispatcher code soon. 144 */ 136 145 ipc_irq_send_notif(irq); 137 else { 138 uint8_t data; 139 uint8_t status; 146 return; 147 } 148 149 i8042_instance_t *instance = irq->instance; 150 i8042_t *dev = instance->i8042; 151 152 uint8_t data; 153 uint8_t status; 140 154 141 while (((status = pio_read_8(i8042_STATUS)) & 142 i8042_BUFFER_FULL_MASK)) { 143 data = pio_read_8(i8042_DATA); 155 if (((status = pio_read_8(&dev->status)) & i8042_BUFFER_FULL_MASK)) { 156 data = pio_read_8(&dev->data); 144 157 145 if ((status & i8042_MOUSE_DATA)) 146 continue; 147 148 if (data & KEY_RELEASE) 149 key_released(data ^ KEY_RELEASE); 150 else 151 key_pressed(data); 152 } 158 if ((status & i8042_MOUSE_DATA)) 159 return; 160 161 if (data & KEY_RELEASE) 162 key_released(data ^ KEY_RELEASE); 163 else 164 key_pressed(data); 153 165 } 154 166 } … … 159 171 inr_t mouse_inr) 160 172 { 173 i8042_t *dev = lgcy_i8042_instance.i8042; 174 161 175 chardev_initialize("i8042_kbd", &kbrd, &ops); 162 176 stdin = &kbrd; … … 167 181 i8042_kbd_irq.claim = i8042_claim; 168 182 i8042_kbd_irq.handler = i8042_irq_handler; 183 i8042_kbd_irq.instance = &lgcy_i8042_instance; 169 184 irq_register(&i8042_kbd_irq); 170 185 … … 174 189 i8042_mouse_irq.claim = i8042_claim; 175 190 i8042_mouse_irq.handler = i8042_irq_handler; 191 i8042_mouse_irq.instance = &lgcy_i8042_instance; 176 192 irq_register(&i8042_mouse_irq); 177 193 … … 184 200 */ 185 201 int i; 186 for (i = 0; (pio_read_8( i8042_STATUS) & i8042_BUFFER_FULL_MASK) &&202 for (i = 0; (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) && 187 203 i < 100; i++) { 188 (void) pio_read_8( i8042_DATA);204 (void) pio_read_8(&dev->data); 189 205 } 190 206 … … 214 230 char i8042_key_read(chardev_t *d) 215 231 { 232 i8042_t *dev = lgcy_i8042_instance.i8042; 216 233 char ch; 217 234 … … 219 236 uint8_t x; 220 237 221 while (!(pio_read_8( i8042_STATUS) & i8042_BUFFER_FULL_MASK))238 while (!(pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)) 222 239 ; 223 240 224 x = pio_read_8( i8042_STATUS);241 x = pio_read_8(&dev->data); 225 242 if (x & KEY_RELEASE) 226 243 key_released(x ^ KEY_RELEASE);
Note:
See TracChangeset
for help on using the changeset viewer.