Changeset ff685c9 in mainline for uspace/srv/kbd/port/i8042.c
- Timestamp:
- 2009-03-03T23:00:33Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 150385b9
- Parents:
- 9cd98796
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/kbd/port/i8042.c
r9cd98796 rff685c9 36 36 */ 37 37 38 #include <ddi.h> 39 #include <libarch/ddi.h> 38 40 #include <ipc/ipc.h> 39 41 #include <async.h> … … 67 69 { 68 70 .cmd = CMD_PIO_READ_8, 69 .addr = (void *) 0x64,71 .addr = NULL, /* will be patched in run-time */ 70 72 .dstarg = 1 71 73 }, … … 83 85 { 84 86 .cmd = CMD_PIO_READ_8, 85 .addr = (void *) 0x60,87 .addr = NULL, /* will be patched in run-time */ 86 88 .dstarg = 2 87 89 }, … … 96 98 }; 97 99 100 static uintptr_t i8042_physical; 101 static uintptr_t i8042_kernel; 102 static i8042_t * i8042; 103 98 104 static void wait_ready(void) { 99 while ( i8042_status_read() & i8042_INPUT_FULL)100 105 while (pio_read_8(&i8042->status) & i8042_INPUT_FULL) 106 ; 101 107 } 102 108 … … 105 111 int kbd_port_init(void) 106 112 { 107 // int i;108 113 int mouseenabled = 0; 114 void *vaddr; 115 116 i8042_physical = sysinfo_value("kbd.address.physical"); 117 i8042_kernel = sysinfo_value("kbd.address.kernel"); 118 if (pio_enable((void *) i8042_physical, sizeof(i8042_t), &vaddr) != 0) 119 return -1; 120 i8042 = vaddr; 109 121 110 122 async_set_interrupt_received(i8042_irq_handler); 111 iospace_enable(task_get_id(), (void *) i8042_DATA, 5);112 123 113 124 /* Disable kbd, enable mouse */ 114 i8042_command_write(i8042_CMD_KBD);125 pio_write_8(&i8042->status, i8042_CMD_KBD); 115 126 wait_ready(); 116 i8042_command_write(i8042_CMD_KBD);127 pio_write_8(&i8042->status, i8042_CMD_KBD); 117 128 wait_ready(); 118 i8042_data_write(i8042_KBD_DISABLE);129 pio_write_8(&i8042->data, i8042_KBD_DISABLE); 119 130 wait_ready(); 120 131 121 132 /* Flush all current IO */ 122 while ( i8042_status_read() & i8042_OUTPUT_FULL)123 i8042_data_read();133 while (pio_read_8(&i8042->status) & i8042_OUTPUT_FULL) 134 (void) pio_read_8(&i8042->data); 124 135 125 /* Initialize mouse */126 /* i8042_command_write(i8042_CMD_MOUSE);127 wait_ready();128 i8042_data_write(MOUSE_OUT_INIT);129 wait_ready();130 131 int mouseanswer = 0;132 for (i=0;i < 1000; i++) {133 int status = i8042_status_read();134 if (status & i8042_OUTPUT_FULL) {135 int data = i8042_data_read();136 if (status & i8042_MOUSE_DATA) {137 mouseanswer = data;138 break;139 }140 }141 usleep(1000);142 }*/143 // if (mouseanswer == MOUSE_ACK) {144 // /* enable mouse */145 // mouseenabled = 1;146 //147 // ipc_register_irq(sysinfo_value("mouse.inr"), sysinfo_value("mouse.devno"), 0, &i8042_kbd);148 // }149 150 136 /* Enable kbd */ 137 i8042_kbd.cmds[0].addr = &((i8042_t *) i8042_kernel)->status; 138 i8042_kbd.cmds[3].addr = &((i8042_t *) i8042_kernel)->data; 151 139 ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &i8042_kbd); 152 140 … … 155 143 newcontrol |= i8042_MOUSE_IE; 156 144 157 i8042_command_write(i8042_CMD_KBD);145 pio_write_8(&i8042->status, i8042_CMD_KBD); 158 146 wait_ready(); 159 i8042_data_write(newcontrol);147 pio_write_8(&i8042->data, newcontrol); 160 148 wait_ready(); 161 149 … … 168 156 169 157 if ((status & i8042_MOUSE_DATA)) 170 return 0;158 return; 171 159 172 160 int scan_code = IPC_GET_ARG2(*call); 173 161 174 162 kbd_push_scancode(scan_code); 175 return 1;163 return; 176 164 } 177 165
Note:
See TracChangeset
for help on using the changeset viewer.