Changeset 1adbf90 in mainline
- Timestamp:
- 2011-12-08T14:09:24Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 28f8f170, c5ebb59
- Parents:
- 190c943
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/drivers/i8042/i8042.c
r190c943 r1adbf90 44 44 #include <mm/slab.h> 45 45 #include <ddi/device.h> 46 #include <time/delay.h> 46 47 47 48 #define i8042_SET_COMMAND 0x60 … … 51 52 #define i8042_BUFFER_FULL_MASK 0x01 52 53 #define i8042_WAIT_MASK 0x02 54 55 #define i8042_TIMEOUT 65536 53 56 54 57 static irq_ownership_t i8042_claim(irq_t *irq) … … 77 80 static void i8042_clear_buffer(i8042_t *dev) 78 81 { 79 while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) 82 for (uint32_t i = 0; i < i8042_TIMEOUT; i++) { 83 if ((pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) == 0) 84 break; 85 80 86 (void) pio_read_8(&dev->data); 87 delay(50); /* 50 us think time */ 88 } 89 } 90 91 static void i8042_send_command(i8042_t *dev, uint8_t cmd) 92 { 93 for (uint32_t i = 0; i < i8042_TIMEOUT; i++) { 94 if ((pio_read_8(&dev->status) & i8042_WAIT_MASK) == 0) 95 break; 96 97 delay(50); /* 50 us think time */ 98 } 99 100 pio_write_8(&dev->status, cmd); 101 delay(10000); /* 10 ms think time */ 81 102 } 82 103 … … 84 105 i8042_instance_t *i8042_init(i8042_t *dev, inr_t inr) 85 106 { 86 i8042_instance_t *instance 87 =malloc(sizeof(i8042_instance_t), FRAME_ATOMIC);107 i8042_instance_t *instance = 108 malloc(sizeof(i8042_instance_t), FRAME_ATOMIC); 88 109 if (instance) { 89 110 instance->i8042 = dev; … … 96 117 instance->irq.handler = i8042_irq_handler; 97 118 instance->irq.instance = instance; 98 99 119 } 100 120 … … 107 127 ASSERT(kbrdin); 108 128 129 i8042_clear_buffer(instance->i8042); 130 109 131 instance->kbrdin = kbrdin; 110 132 irq_register(&instance->irq); 111 i8042_clear_buffer(instance->i8042);112 133 } 113 134 … … 116 137 { 117 138 interrupts_disable(); 118 119 139 i8042_clear_buffer(dev); 120 121 /* Reset CPU */ 122 pio_write_8(&dev->status, i8042_CPU_RESET); 140 i8042_send_command(dev, i8042_CPU_RESET); 123 141 } 124 142
Note:
See TracChangeset
for help on using the changeset viewer.