Changeset 4687fcd4 in mainline for uspace/drv
- Timestamp:
- 2011-01-29T10:19:04Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 72e19f50
- Parents:
- 67a1b78 (diff), a09128c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/drv
- Files:
-
- 5 added
- 11 edited
- 7 moved
-
uhci/Makefile (modified) (1 diff)
-
uhci/main.c (modified) (2 diffs)
-
uhci/pci.c (added)
-
uhci/uhci.c (modified) (2 diffs)
-
uhci/uhci.h (modified) (3 diffs)
-
usbhid/Makefile (moved) (moved from uspace/drv/usbkbd/Makefile ) (2 diffs)
-
usbhid/conv.c (added)
-
usbhid/conv.h (added)
-
usbhid/descdump.c (moved) (moved from uspace/drv/usbkbd/descdump.c ) (1 diff)
-
usbhid/descdump.h (moved) (moved from uspace/drv/usbkbd/descdump.h ) (1 diff)
-
usbhid/descparser.c (moved) (moved from uspace/drv/usbkbd/descparser.c ) (1 diff)
-
usbhid/descparser.h (moved) (moved from uspace/drv/usbkbd/descparser.h ) (1 diff)
-
usbhid/kbd.h (added)
-
usbhid/layout.h (added)
-
usbhid/main.c (moved) (moved from uspace/drv/usbkbd/main.c ) (11 diffs)
-
usbhid/usbhid.ma (moved) (moved from uspace/drv/usbkbd/usbkbd.ma )
-
usbhub/main.c (modified) (2 diffs)
-
usbhub/usbhub.c (modified) (4 diffs)
-
usbhub/usbhub_private.h (modified) (2 diffs)
-
vhc/hub.c (modified) (2 diffs)
-
vhc/hub/hub.h (modified) (1 diff)
-
vhc/hub/virthub.c (modified) (1 diff)
-
vhc/hub/virthub.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci/Makefile
r67a1b78 r4687fcd4 41 41 transfer_list.c \ 42 42 uhci.c \ 43 uhci_struct/transfer_descriptor.c 43 uhci_struct/transfer_descriptor.c \ 44 pci.c 44 45 45 46 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/uhci/main.c
r67a1b78 r4687fcd4 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 #include <driver.h> 29 #include <errno.h> 30 #include <str_error.h> 28 31 #include <usb_iface.h> 29 #include <errno.h>30 32 31 33 #include "debug.h" … … 57 59 device->ops = &uhci_ops; 58 60 59 // TODO: get this value out of pci driver 60 return uhci_init(device, (void*)0xc020); 61 uintptr_t io_reg_base; 62 size_t io_reg_size; 63 int irq; 64 65 int rc = pci_get_my_registers(device, 66 &io_reg_base, &io_reg_size, &irq); 67 68 if (rc != EOK) { 69 uhci_print_fatal("failed to get I/O registers addresses: %s.\n", 70 str_error(rc)); 71 return rc; 72 } 73 74 uhci_print_info("I/O regs at 0x%X (size %zu), IRQ %d.\n", 75 io_reg_base, io_reg_size, irq); 76 77 return uhci_init(device, (void*)io_reg_base, io_reg_size); 61 78 } 62 79 -
uspace/drv/uhci/uhci.c
r67a1b78 r4687fcd4 13 13 static int uhci_debug_checker(void *arg); 14 14 15 int uhci_init(device_t *device, void *regs )15 int uhci_init(device_t *device, void *regs, size_t reg_size) 16 16 { 17 17 assert(device); … … 40 40 /* allow access to hc control registers */ 41 41 regs_t *io; 42 ret = pio_enable(regs, sizeof(regs_t), (void**)&io); 42 assert(reg_size >= sizeof(regs_t)); 43 ret = pio_enable(regs, reg_size, (void**)&io); 43 44 CHECK_RET_FREE_INSTANCE("Failed to gain access to registers at %p.\n", io); 44 45 instance->registers = io; -
uspace/drv/uhci/uhci.h
r67a1b78 r4687fcd4 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup usb 28 29 /** @addtogroup drvusbuhci 29 30 * @{ 30 31 */ … … 86 87 87 88 /* init uhci specifics in device.driver_data */ 88 int uhci_init( device_t *device, void *regs );89 int uhci_init( device_t *device, void *regs, size_t reg_size ); 89 90 90 91 int uhci_destroy( device_t *device ); … … 101 102 void *arg ); 102 103 104 int pci_get_my_registers(device_t *, uintptr_t *, size_t *, int *); 105 103 106 #endif 104 107 /** -
uspace/drv/usbhid/Makefile
r67a1b78 r4687fcd4 1 1 # 2 # Copyright (c) 2010 Vojtech Horky2 # Copyright (c) 2010-2011 Vojtech Horky 3 3 # All rights reserved. 4 4 # … … 29 29 USPACE_PREFIX = ../.. 30 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include 32 BINARY = usbkbd 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I. 32 BINARY = usbhid 33 34 STOLEN_LAYOUT_SOURCES = \ 35 layout/us_qwerty.c \ 36 layout/us_dvorak.c \ 37 layout/cz.c 33 38 34 39 SOURCES = \ 35 40 main.c \ 36 41 descparser.c \ 37 descdump.c 42 descdump.c \ 43 conv.c \ 44 $(STOLEN_LAYOUT_SOURCES) 45 46 EXTRA_CLEAN = $(STOLEN_LAYOUT_SOURCES) 47 48 SRV_KBD = $(USPACE_PREFIX)/srv/hid/kbd 38 49 39 50 include $(USPACE_PREFIX)/Makefile.common 51 52 layout/%.c: $(SRV_KBD)/layout/%.c 53 ln -sfn ../$< $@ -
uspace/drv/usbhid/descdump.c
r67a1b78 r4687fcd4 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup drvusbhid 29 30 * @{ 31 */ 32 /** @file 33 * Descriptor dumping. 30 34 */ 31 35 -
uspace/drv/usbhid/descdump.h
r67a1b78 r4687fcd4 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup drvusbhid 29 30 * @{ 30 31 */ 32 /** @file 33 * Descriptor dumping. 34 */ 35 31 36 #ifndef USBHID_DESCDUMP_H_ 32 37 #define USBHID_DESCDUMP_H_ -
uspace/drv/usbhid/descparser.c
r67a1b78 r4687fcd4 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup drvusbhid 29 30 * @{ 31 */ 32 /** @file 33 * Descriptor parser. 30 34 */ 31 35 -
uspace/drv/usbhid/descparser.h
r67a1b78 r4687fcd4 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 /** @addtogroup drvusbhid 29 30 * @{ 31 */ 32 /** @file 33 * Descriptor parser. 30 34 */ 31 35 -
uspace/drv/usbhid/main.c
r67a1b78 r4687fcd4 1 1 /* 2 2 * Copyright (c) 2010 Vojtech Horky 3 * Copyright (c) 2011 Lubos Slovak 3 4 * All rights reserved. 4 5 * … … 26 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28 */ 29 28 30 /** @addtogroup drvusbhid 29 31 * @{ 30 32 */ 33 /** 34 * @file 35 * Main routines of USB HID driver. 36 */ 37 31 38 #include <usb/usbdrv.h> 32 39 #include <driver.h> … … 41 48 #include <usb/devreq.h> 42 49 #include <usb/descriptor.h> 50 #include <io/console.h> 43 51 #include "descparser.h" 44 52 #include "descdump.h" 53 #include "conv.h" 54 #include "layout.h" 45 55 46 56 #define BUFFER_SIZE 32 47 #define NAME "usb kbd"57 #define NAME "usbhid" 48 58 49 59 #define GUESSED_POLL_ENDPOINT 1 … … 91 101 92 102 /* 103 * TODO: Move somewhere else 104 */ 105 /* 106 #define BYTES_PER_LINE 12 107 108 static void dump_buffer(const char *msg, const uint8_t *buffer, size_t length) 109 { 110 printf("%s\n", msg); 111 112 size_t i; 113 for (i = 0; i < length; i++) { 114 printf(" 0x%02X", buffer[i]); 115 if (((i > 0) && (((i+1) % BYTES_PER_LINE) == 0)) 116 || (i + 1 == length)) { 117 printf("\n"); 118 } 119 } 120 } 121 */ 122 /* 123 * Copy-paste from srv/hid/kbd/generic/kbd.c 124 */ 125 126 /** Currently active modifiers. 127 * 128 * TODO: put to device? 129 */ 130 static unsigned mods = KM_NUM_LOCK; 131 132 /** Currently pressed lock keys. We track these to tackle autorepeat. 133 * 134 * TODO: put to device? 135 */ 136 static unsigned lock_keys; 137 138 #define NUM_LAYOUTS 3 139 140 static layout_op_t *layout[NUM_LAYOUTS] = { 141 &us_qwerty_op, 142 &us_dvorak_op, 143 &cz_op 144 }; 145 146 static int active_layout = 0; 147 148 static void kbd_push_ev(int type, unsigned int key) 149 { 150 console_event_t ev; 151 unsigned mod_mask; 152 153 // TODO: replace by our own parsing?? or are the key codes identical?? 154 switch (key) { 155 case KC_LCTRL: mod_mask = KM_LCTRL; break; 156 case KC_RCTRL: mod_mask = KM_RCTRL; break; 157 case KC_LSHIFT: mod_mask = KM_LSHIFT; break; 158 case KC_RSHIFT: mod_mask = KM_RSHIFT; break; 159 case KC_LALT: mod_mask = KM_LALT; break; 160 case KC_RALT: mod_mask = KM_RALT; break; 161 default: mod_mask = 0; break; 162 } 163 164 if (mod_mask != 0) { 165 if (type == KEY_PRESS) 166 mods = mods | mod_mask; 167 else 168 mods = mods & ~mod_mask; 169 } 170 171 switch (key) { 172 case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break; 173 case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; break; 174 case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break; 175 default: mod_mask = 0; break; 176 } 177 178 if (mod_mask != 0) { 179 if (type == KEY_PRESS) { 180 /* 181 * Only change lock state on transition from released 182 * to pressed. This prevents autorepeat from messing 183 * up the lock state. 184 */ 185 mods = mods ^ (mod_mask & ~lock_keys); 186 lock_keys = lock_keys | mod_mask; 187 188 /* Update keyboard lock indicator lights. */ 189 // TODO 190 //kbd_ctl_set_ind(mods); 191 } else { 192 lock_keys = lock_keys & ~mod_mask; 193 } 194 } 195 /* 196 printf("type: %d\n", type); 197 printf("mods: 0x%x\n", mods); 198 printf("keycode: %u\n", key); 199 */ 200 201 if (type == KEY_PRESS && (mods & KM_LCTRL) && 202 key == KC_F1) { 203 active_layout = 0; 204 layout[active_layout]->reset(); 205 return; 206 } 207 208 if (type == KEY_PRESS && (mods & KM_LCTRL) && 209 key == KC_F2) { 210 active_layout = 1; 211 layout[active_layout]->reset(); 212 return; 213 } 214 215 if (type == KEY_PRESS && (mods & KM_LCTRL) && 216 key == KC_F3) { 217 active_layout = 2; 218 layout[active_layout]->reset(); 219 return; 220 } 221 222 ev.type = type; 223 ev.key = key; 224 ev.mods = mods; 225 226 ev.c = layout[active_layout]->parse_ev(&ev); 227 228 printf("Sending key %d to the console\n", ev.key); 229 assert(console_callback_phone != -1); 230 async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); 231 } 232 /* 233 * End of copy-paste 234 */ 235 236 /* 237 * TODO: 238 * 1) key press / key release - how does the keyboard notify about release? 239 * 2) layouts (use the already defined), not important now 240 * 3) 241 */ 242 243 /* 93 244 * Callbacks for parser 94 245 */ 95 246 static void usbkbd_process_keycodes(const uint8_t *key_codes, size_t count, 96 uint8_t modifiers, void *arg)247 uint8_t modifiers, void *arg) 97 248 { 98 249 printf("Got keys: "); … … 100 251 for (i = 0; i < count; ++i) { 101 252 printf("%d ", key_codes[i]); 253 // TODO: Key press / release 254 255 // TODO: NOT WORKING 256 unsigned int key = usbkbd_parse_scancode(key_codes[i]); 257 kbd_push_ev(KEY_PRESS, key); 102 258 } 103 259 printf("\n"); … … 267 423 //usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, 268 424 // NULL); 269 printf("Calling usb_hid_boot_keyboard_input_report()...\n)"); 270 usb_hid_boot_keyboard_input_report(buffer, actual_size, callbacks, NULL); 425 printf("Calling usb_hid_boot_keyboard_input_report() with size %zu\n", 426 actual_size); 427 //dump_buffer("bufffer: ", buffer, actual_size); 428 int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, callbacks, 429 NULL); 430 if (rc != EOK) { 431 printf("Error in usb_hid_boot_keyboard_input_report(): %d\n", rc); 432 } 271 433 } 272 434 273 435 static void usbkbd_poll_keyboard(usb_hid_dev_kbd_t *kbd_dev) 274 436 { 275 return;276 277 437 int rc; 278 438 usb_handle_t handle; … … 292 452 }; 293 453 454 printf("Polling keyboard...\n"); 455 294 456 while (true) { 295 async_usleep(1000 * 1000 );457 async_usleep(1000 * 1000 * 2); 296 458 rc = usb_drv_async_interrupt_in(kbd_dev->device->parent_phone, 297 459 poll_target, buffer, BUFFER_SIZE, &actual_size, &handle); 298 460 299 461 if (rc != EOK) { 462 printf("Error in usb_drv_async_interrupt_in(): %d\n", rc); 300 463 continue; 301 464 } … … 303 466 rc = usb_drv_async_wait_for(handle); 304 467 if (rc != EOK) { 468 printf("Error in usb_drv_async_wait_for(): %d\n", rc); 305 469 continue; 306 470 } … … 311 475 */ 312 476 if (actual_size == 0) { 477 printf("Keyboard returned NAK\n"); 313 478 continue; 314 479 } … … 317 482 * TODO: Process pressed keys. 318 483 */ 484 printf("Calling usbkbd_process_interrupt_in()\n"); 319 485 usbkbd_process_interrupt_in(kbd_dev, buffer, actual_size); 320 486 } … … 337 503 // initialize device (get and process descriptors, get address, etc.) 338 504 usb_hid_dev_kbd_t *kbd_dev = usbkbd_init_device(dev); 505 if (kbd_dev == NULL) { 506 printf("Error while initializing device.\n"); 507 return -1; 508 } 339 509 340 510 usbkbd_poll_keyboard(kbd_dev); -
uspace/drv/usbhub/main.c
r67a1b78 r4687fcd4 42 42 43 43 usb_general_list_t usb_hub_list; 44 f utex_t usb_hub_list_lock;44 fibril_mutex_t usb_hub_list_lock; 45 45 46 46 static driver_ops_t hub_driver_ops = { … … 65 65 { 66 66 usb_dprintf_enable(NAME, 0); 67 68 futex_initialize(&usb_hub_list_lock, 0); 67 68 fibril_mutex_initialize(&usb_hub_list_lock); 69 fibril_mutex_lock(&usb_hub_list_lock); 69 70 usb_lst_init(&usb_hub_list); 70 f utex_up(&usb_hub_list_lock);71 fibril_mutex_unlock(&usb_hub_list_lock); 71 72 72 73 fid_t fid = fibril_create(usb_hub_control_loop, NULL); -
uspace/drv/usbhub/usbhub.c
r67a1b78 r4687fcd4 203 203 204 204 //add the hub to list 205 f utex_down(&usb_hub_list_lock);205 fibril_mutex_lock(&usb_hub_list_lock); 206 206 usb_lst_append(&usb_hub_list, hub_info); 207 f utex_up(&usb_hub_list_lock);207 fibril_mutex_unlock(&usb_hub_list_lock); 208 208 209 209 dprintf(1, "hub info added to list"); … … 445 445 */ 446 446 usb_general_list_t * lst_item; 447 f utex_down(&usb_hub_list_lock);447 fibril_mutex_lock(&usb_hub_list_lock); 448 448 for (lst_item = usb_hub_list.next; 449 449 lst_item != &usb_hub_list; 450 450 lst_item = lst_item->next) { 451 f utex_up(&usb_hub_list_lock);451 fibril_mutex_unlock(&usb_hub_list_lock); 452 452 usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data); 453 453 /* … … 488 488 489 489 if (opResult != EOK) { 490 free(change_bitmap); 490 491 dprintf(1, "something went wrong while getting status of hub"); 491 492 continue; … … 503 504 504 505 ipc_hangup(hc); 505 f utex_down(&usb_hub_list_lock);506 } 507 f utex_up(&usb_hub_list_lock);506 fibril_mutex_lock(&usb_hub_list_lock); 507 } 508 fibril_mutex_unlock(&usb_hub_list_lock); 508 509 } 509 510 -
uspace/drv/usbhub/usbhub_private.h
r67a1b78 r4687fcd4 43 43 #include <bool.h> 44 44 #include <driver.h> 45 #include <f utex.h>45 #include <fibril_synch.h> 46 46 47 47 #include <usb/usb.h> … … 82 82 83 83 /** Lock for hub list*/ 84 extern f utex_t usb_hub_list_lock;84 extern fibril_mutex_t usb_hub_list_lock; 85 85 86 86 -
uspace/drv/vhc/hub.c
r67a1b78 r4687fcd4 63 63 = fibril_create(hub_register_in_devman_fibril, hc_dev); 64 64 if (root_hub_registration == 0) { 65 printf(NAME ": failed to register root hub\n");65 printf(NAME ": failed to create hub registration fibril\n"); 66 66 return; 67 67 } … … 79 79 device_t *hc_dev = (device_t *) arg; 80 80 81 int hc = usb_drv_hc_connect(hc_dev, hc_dev->handle, IPC_FLAG_BLOCKING);82 if (hc < 0){83 printf(NAME ": failed to register root hub\n");84 return hc;85 } 81 int hc; 82 do { 83 hc = usb_drv_hc_connect(hc_dev, hc_dev->handle, 84 IPC_FLAG_BLOCKING); 85 } while (hc < 0); 86 86 87 87 usb_drv_reserve_default_address(hc); -
uspace/drv/vhc/hub/hub.h
r67a1b78 r4687fcd4 38 38 #include <fibril_synch.h> 39 39 40 #ifndef HUB_PORT_COUNT 40 41 #define HUB_PORT_COUNT 2 42 #endif 41 43 #define BITS2BYTES(bits) (bits ? ((((bits)-1)>>3)+1) : 0) 42 44 -
uspace/drv/vhc/hub/virthub.c
r67a1b78 r4687fcd4 164 164 dev->device_data = hub; 165 165 166 usbvirt_connect_local(dev); 167 168 return EOK; 166 int rc; 167 #ifdef STANDALONE_HUB 168 dev->name = "hub"; 169 rc = usbvirt_connect(dev); 170 #else 171 rc = usbvirt_connect_local(dev); 172 #endif 173 174 return rc; 169 175 } 170 176 -
uspace/drv/vhc/hub/virthub.h
r67a1b78 r4687fcd4 37 37 38 38 #include <usbvirt/device.h> 39 #include "hub.h" 40 41 #ifdef STANDALONE_HUB 42 #define virtdev_connection_t int 43 #else 39 44 #include "../devices.h" 40 # include "hub.h"45 #endif 41 46 42 47 /** Endpoint number for status change pipe. */
Note:
See TracChangeset
for help on using the changeset viewer.
