Changes in uspace/drv/ohci/hc.c [1387692:53f1c87] in mainline
- File:
-
- 1 edited
-
uspace/drv/ohci/hc.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/hc.c
r1387692 r53f1c87 39 39 #include <usb/debug.h> 40 40 #include <usb/usb.h> 41 #include <usb/hub.h>42 41 #include <usb/ddfiface.h> 43 42 #include <usb/usbdevice.h> … … 45 44 #include "hc.h" 46 45 47 static int dummy_reset(int foo, void *arg) 46 static int interrupt_emulator(hc_t *instance); 47 /*----------------------------------------------------------------------------*/ 48 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun) 48 49 { 49 hc_t *hc = (hc_t*)arg; 50 assert(hc); 51 hc->rh.address = 0; 52 return EOK; 50 assert(instance); 51 assert(hub_fun); 52 53 usb_address_t hub_address = 54 device_keeper_get_free_address(&instance->manager, USB_SPEED_FULL); 55 instance->rh.address = hub_address; 56 usb_device_keeper_bind( 57 &instance->manager, hub_address, hub_fun->handle); 58 59 char *match_str = NULL; 60 int ret = asprintf(&match_str, "usb&mid"); 61 ret = (match_str == NULL) ? ret : EOK; 62 if (ret < 0) { 63 usb_log_error("Failed to create root hub match-id string.\n"); 64 return ret; 65 } 66 67 ret = ddf_fun_add_match_id(hub_fun, match_str, 100); 68 if (ret != EOK) { 69 usb_log_error("Failed add create root hub match-id.\n"); 70 } 71 return ret; 53 72 } 54 73 /*----------------------------------------------------------------------------*/ … … 67 86 usb_device_keeper_init(&instance->manager); 68 87 88 if (!interrupts) { 89 instance->interrupt_emulator = 90 fibril_create((int(*)(void*))interrupt_emulator, instance); 91 fibril_add_ready(instance->interrupt_emulator); 92 } 69 93 70 94 rh_init(&instance->rh, dev, instance->registers); 95 71 96 /* TODO: implement */ 72 return EOK;73 }74 /*----------------------------------------------------------------------------*/75 int hc_register_hub(hc_t *instance)76 {77 async_usleep(1000000);78 #define CHECK_RET_RETURN(ret, msg...) \79 if (ret != EOK) { \80 usb_log_error(msg); \81 return ret; \82 } else (void)083 assert(instance);84 assert(instance->ddf_instance);85 assert(instance->ddf_instance->handle);86 ddf_dev_t *dev = instance->rh.device;87 int ret = EOK;88 89 usb_hc_connection_t conn;90 ret =91 usb_hc_connection_initialize(&conn, instance->ddf_instance->handle);92 CHECK_RET_RETURN(ret, "Failed to initialize hc connection.\n");93 94 ret = usb_hc_connection_open(&conn);95 CHECK_RET_RETURN(ret, "Failed to open hc connection.\n");96 97 usb_address_t address;98 devman_handle_t handle;99 ret = usb_hc_new_device_wrapper(dev, &conn, USB_SPEED_FULL, dummy_reset,100 0, instance, &address, &handle, NULL, NULL, NULL);101 CHECK_RET_RETURN(ret, "Failed to add rh device.\n");102 103 ret = usb_hc_connection_close(&conn);104 CHECK_RET_RETURN(ret, "Failed to close hc connection.\n");105 97 return EOK; 106 98 } … … 117 109 } 118 110 /*----------------------------------------------------------------------------*/ 119 void hc_interrupt(hc_t *instance, uint 16_t status)111 void hc_interrupt(hc_t *instance, uint32_t status) 120 112 { 121 113 assert(instance); 122 /* TODO: Check for interrupt cause */ 123 rh_interrupt(&instance->rh); 114 if (status == 0) 115 return; 116 if (status & IS_RHSC) 117 rh_interrupt(&instance->rh); 118 119 /* TODO: Check for further interrupt causes */ 124 120 /* TODO: implement */ 121 } 122 /*----------------------------------------------------------------------------*/ 123 int interrupt_emulator(hc_t *instance) 124 { 125 assert(instance); 126 usb_log_info("Started interrupt emulator.\n"); 127 while (1) { 128 uint32_t status = instance->registers->interrupt_status; 129 instance->registers->interrupt_status = status; 130 hc_interrupt(instance, status); 131 async_usleep(1000); 132 } 133 return EOK; 125 134 } 126 135 /**
Note:
See TracChangeset
for help on using the changeset viewer.
