Changeset 625f1ba in mainline
- Timestamp:
- 2011-03-21T16:47:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 215b001, 434ef65
- Parents:
- e484f3b
- Location:
- uspace/drv/usbhub
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/main.c
re484f3b r625f1ba 42 42 #include "usbhub_private.h" 43 43 44 45 usb_endpoint_description_t hub_status_change_endpoint_description = { 44 /** Hub status-change endpoint description. 45 * 46 * For more information see section 11.15.1 of USB 1.1 specification. 47 */ 48 static usb_endpoint_description_t hub_status_change_endpoint_description = { 46 49 .transfer_type = USB_TRANSFER_INTERRUPT, 47 50 .direction = USB_DIRECTION_IN, … … 57 60 }; 58 61 62 static usb_endpoint_description_t *usb_hub_endpoints[] = { 63 &hub_status_change_endpoint_description, 64 NULL 65 }; 66 59 67 static usb_driver_t usb_hub_driver = { 60 .name = "usbhub", 61 .ops = &usb_hub_driver_ops 68 .name = NAME, 69 .ops = &usb_hub_driver_ops, 70 .endpoints = usb_hub_endpoints 62 71 }; 63 72 … … 65 74 int main(int argc, char *argv[]) 66 75 { 76 printf(NAME ": HelenOS USB hub driver.\n"); 77 67 78 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 68 usb_log_info("starting hub driver\n");69 70 79 71 usb_hub_driver.endpoints = (usb_endpoint_description_t**)72 malloc(2 * sizeof(usb_endpoint_description_t*));73 usb_hub_driver.endpoints[0] = &hub_status_change_endpoint_description;74 usb_hub_driver.endpoints[1] = NULL;75 76 80 return usb_driver_main(&usb_hub_driver); 77 81 } -
uspace/drv/usbhub/usbhub.c
re484f3b r625f1ba 157 157 static int usb_hub_set_configuration(usb_hub_info_t * hub_info){ 158 158 //device descriptor 159 usb_standard_device_descriptor_t std_descriptor; 160 int opResult = usb_request_get_device_descriptor( 161 &hub_info->usb_device->ctrl_pipe, 162 &std_descriptor); 163 if(opResult!=EOK){ 164 usb_log_error("could not get device descriptor, %d\n",opResult); 165 return opResult; 166 } 159 usb_standard_device_descriptor_t *std_descriptor 160 = &hub_info->usb_device->descriptors.device; 167 161 usb_log_info("hub has %d configurations\n", 168 std_descriptor.configuration_count);169 if(std_descriptor .configuration_count<1){162 std_descriptor->configuration_count); 163 if(std_descriptor->configuration_count<1){ 170 164 usb_log_error("THERE ARE NO CONFIGURATIONS AVAILABLE\n"); 171 165 //shouldn`t I return? 172 } 173 174 /* Retrieve full configuration descriptor. */ 175 uint8_t *descriptors = NULL; 176 size_t descriptors_size = 0; 177 opResult = usb_request_get_full_configuration_descriptor_alloc( 178 &hub_info->usb_device->ctrl_pipe, 0, 179 (void **) &descriptors, &descriptors_size); 180 if (opResult != EOK) { 181 usb_log_error("Could not get configuration descriptor: %s.\n", 182 str_error(opResult)); 183 return opResult; 184 } 166 //definitely 167 return EINVAL; 168 } 169 185 170 usb_standard_configuration_descriptor_t *config_descriptor 186 = (usb_standard_configuration_descriptor_t *) descriptors; 171 = (usb_standard_configuration_descriptor_t *) 172 hub_info->usb_device->descriptors.configuration; 187 173 188 174 /* Set configuration. */ 189 opResult = usb_request_set_configuration(&hub_info->usb_device->ctrl_pipe, 175 int opResult = usb_request_set_configuration( 176 &hub_info->usb_device->ctrl_pipe, 190 177 config_descriptor->configuration_number); 191 178 … … 197 184 usb_log_debug("\tused configuration %d\n", 198 185 config_descriptor->configuration_number); 199 free(descriptors); 186 200 187 return EOK; 201 188 } … … 243 230 244 231 /// \TODO what is this? 245 usb_log_debug(" adding to ddf");232 usb_log_debug("Creating `hub' function.\n"); 246 233 ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev, 247 234 fun_exposed, "hub"); … … 257 244 fid_t fid = fibril_create(usb_hub_control_loop, hub_info); 258 245 if (fid == 0) { 259 usb_log_error("failed to start monitoring fibril for new hub ");246 usb_log_error("failed to start monitoring fibril for new hub.\n"); 260 247 return ENOMEM; 261 248 } 262 249 fibril_add_ready(fid); 263 usb_log_debug("hub fibril created"); 264 usb_log_debug("has %d ports ",hub_info->port_count); 250 usb_log_debug("Hub fibril created.\n"); 251 252 usb_log_info("Controlling hub `%s' (%d ports).\n", 253 hub_info->usb_device->ddf_dev->name, hub_info->port_count); 265 254 return EOK; 266 255 } … … 533 522 //port reset 534 523 if (usb_port_reset_completed(&status)) { 535 usb_log_info("port reset complete ");524 usb_log_info("port reset complete\n"); 536 525 if (usb_port_enabled(&status)) { 537 526 usb_hub_finalize_add_device(hub, port, usb_port_speed(&status)); -
uspace/drv/usbhub/usbhub.h
re484f3b r625f1ba 46 46 #include <usb/pipes.h> 47 47 #include <usb/devdrv.h> 48 49 50 /** Hub status-change endpoint description51 *52 * For more see usb hub specification in 11.15.1 of53 */54 extern usb_endpoint_description_t hub_status_change_endpoint_description;55 56 57 58 /* Hub endpoints. */59 /*typedef struct {60 usb_pipe_t control;61 usb_pipe_t status_change;62 } usb_hub_endpoints_t;63 */64 48 65 49
Note:
See TracChangeset
for help on using the changeset viewer.