Changeset 1f1fa64 in mainline for uspace/drv
- Timestamp:
- 2014-07-28T21:53:11Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c3b25985, f2f4c00
- Parents:
- cbfece7 (diff), 7eb6c96 (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:
-
- 15 edited
-
bus/usb/ohci/hc.c (modified) (6 diffs)
-
bus/usb/ohci/hc.h (modified) (3 diffs)
-
bus/usb/ohci/ohci.c (modified) (3 diffs)
-
bus/usb/uhci/hc.c (modified) (3 diffs)
-
bus/usb/uhci/hc.h (modified) (3 diffs)
-
bus/usb/uhci/uhci.c (modified) (6 diffs)
-
bus/usb/uhcirh/port.c (modified) (1 diff)
-
bus/usb/usbhid/usbhid.c (modified) (1 diff)
-
bus/usb/usbhub/port.c (modified) (2 diffs)
-
bus/usb/usbmid/explore.c (modified) (5 diffs)
-
bus/usb/usbmid/usbmid.c (modified) (5 diffs)
-
bus/usb/usbmid/usbmid.h (modified) (1 diff)
-
bus/usb/vhc/hub.c (modified) (2 diffs)
-
nic/e1k/e1k.c (modified) (1 diff)
-
nic/rtl8169/driver.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
rcbfece7 r1f1fa64 193 193 instance->rh.address = 1; 194 194 rc = usb_device_manager_request_address( 195 &instance->generic .dev_manager, &instance->rh.address, false,195 &instance->generic->dev_manager, &instance->rh.address, false, 196 196 USB_SPEED_FULL); 197 197 if (rc != EOK) { … … 204 204 205 205 rc = usb_endpoint_manager_add_ep( 206 &instance->generic .ep_manager, instance->rh.address, 0,206 &instance->generic->ep_manager, instance->rh.address, 0, 207 207 USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64, 208 208 0, NULL, NULL); … … 231 231 fun_bound = true; 232 232 233 rc = usb_device_manager_bind_address(&instance->generic .dev_manager,233 rc = usb_device_manager_bind_address(&instance->generic->dev_manager, 234 234 instance->rh.address, ddf_fun_get_handle(hub_fun)); 235 235 if (rc != EOK) { … … 244 244 if (ep_added) { 245 245 usb_endpoint_manager_remove_ep( 246 &instance->generic .ep_manager, instance->rh.address, 0,246 &instance->generic->ep_manager, instance->rh.address, 0, 247 247 USB_DIRECTION_BOTH, NULL, NULL); 248 248 } 249 249 if (addr_reqd) { 250 250 usb_device_manager_release_address( 251 &instance->generic .dev_manager, instance->rh.address);251 &instance->generic->dev_manager, instance->rh.address); 252 252 } 253 253 return rc; … … 257 257 * 258 258 * @param[in] instance Memory place for the structure. 259 * @param[in] HC function node 259 260 * @param[in] regs Device's I/O registers range. 260 261 * @param[in] interrupts True if w interrupts should be used 261 262 * @return Error code 262 263 */ 263 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)264 int hc_init(hc_t *instance, ddf_fun_t *fun, addr_range_t *regs, bool interrupts) 264 265 { 265 266 assert(instance); … … 274 275 list_initialize(&instance->pending_batches); 275 276 276 hcd_init(&instance->generic, USB_SPEED_FULL, 277 instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t)); 278 if (instance->generic == NULL) { 279 usb_log_error("Out of memory.\n"); 280 return ENOMEM; 281 } 282 283 hcd_init(instance->generic, USB_SPEED_FULL, 277 284 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 278 instance->generic .private_data = instance;279 instance->generic .schedule = hc_schedule;280 instance->generic .ep_add_hook = ohci_endpoint_init;281 instance->generic .ep_remove_hook = ohci_endpoint_fini;285 instance->generic->private_data = instance; 286 instance->generic->schedule = hc_schedule; 287 instance->generic->ep_add_hook = ohci_endpoint_init; 288 instance->generic->ep_remove_hook = ohci_endpoint_fini; 282 289 283 290 rc = hc_init_memory(instance); -
uspace/drv/bus/usb/ohci/hc.h
rcbfece7 r1f1fa64 35 35 #define DRV_OHCI_HC_H 36 36 37 #include <ddf/driver.h> 37 38 #include <ddf/interrupt.h> 38 39 #include <fibril.h> … … 53 54 typedef struct hc { 54 55 /** Generic USB hc driver */ 55 hcd_t generic;56 hcd_t *generic; 56 57 57 58 /** Memory mapped I/O registers area */ … … 79 80 int hc_register_irq_handler(ddf_dev_t *, addr_range_t *, int, 80 81 interrupt_handler_t); 81 int hc_register_hub(hc_t * instance, ddf_fun_t *hub_fun);82 int hc_init(hc_t * instance, addr_range_t *regs, bool interrupts);82 int hc_register_hub(hc_t *, ddf_fun_t *); 83 int hc_init(hc_t *, ddf_fun_t *, addr_range_t *, bool); 83 84 84 85 /** Safely dispose host controller internal structures -
uspace/drv/bus/usb/ohci/ohci.c
rcbfece7 r1f1fa64 34 34 */ 35 35 36 /* XXX Fix this */37 #define _DDF_DATA_IMPLANT38 39 36 #include <errno.h> 40 37 #include <str_error.h> … … 165 162 166 163 ddf_fun_set_ops(instance->hc_fun, &hc_ops); 167 ddf_fun_data_implant(instance->hc_fun, &instance->hc);168 164 169 165 instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh"); … … 214 210 } 215 211 216 rc = hc_init(&instance->hc, ®s, interrupts);212 rc = hc_init(&instance->hc, instance->hc_fun, ®s, interrupts); 217 213 if (rc != EOK) { 218 214 usb_log_error("Failed to init ohci_hcd: %s.\n", str_error(rc)); -
uspace/drv/bus/usb/uhci/hc.c
rcbfece7 r1f1fa64 230 230 * 231 231 * @param[in] instance Memory place to initialize. 232 * @param[in] HC function node 232 233 * @param[in] regs Range of device's I/O control registers. 233 234 * @param[in] interrupts True if hw interrupts should be used. … … 238 239 * interrupt fibrils. 239 240 */ 240 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)241 int hc_init(hc_t *instance, ddf_fun_t *fun, addr_range_t *regs, bool interrupts) 241 242 { 242 243 assert(regs->size >= sizeof(uhci_regs_t)); … … 266 267 } 267 268 268 hcd_init(&instance->generic, USB_SPEED_FULL, 269 instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t)); 270 if (instance->generic == NULL) { 271 usb_log_error("Out of memory.\n"); 272 return ENOMEM; 273 } 274 275 hcd_init(instance->generic, USB_SPEED_FULL, 269 276 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 270 277 271 instance->generic .private_data = instance;272 instance->generic .schedule = hc_schedule;273 instance->generic .ep_add_hook = NULL;278 instance->generic->private_data = instance; 279 instance->generic->schedule = hc_schedule; 280 instance->generic->ep_add_hook = NULL; 274 281 275 282 hc_init_hw(instance); -
uspace/drv/bus/usb/uhci/hc.h
rcbfece7 r1f1fa64 36 36 #define DRV_UHCI_HC_H 37 37 38 #include <ddf/driver.h> 38 39 #include <ddf/interrupt.h> 39 40 #include <device/hw_res_parsed.h> … … 93 94 typedef struct hc { 94 95 /** Generic HCD driver structure */ 95 hcd_t generic;96 hcd_t *generic; 96 97 97 98 /** Addresses of I/O registers */ … … 126 127 addr_range_t *); 127 128 void hc_interrupt(hc_t *instance, uint16_t status); 128 int hc_init(hc_t * instance, addr_range_t *regs, bool interupts);129 int hc_init(hc_t *, ddf_fun_t *, addr_range_t *, bool); 129 130 130 131 /** Safely dispose host controller internal structures -
uspace/drv/bus/usb/uhci/uhci.c
rcbfece7 r1f1fa64 34 34 */ 35 35 36 /* XXX Fix this */37 #define _DDF_DATA_IMPLANT38 39 36 #include <errno.h> 40 37 #include <stdbool.h> … … 62 59 hc_t hc; 63 60 /** Internal driver's representation of UHCI root hub */ 64 rh_t rh;61 rh_t *rh; 65 62 } uhci_t; 66 63 … … 186 183 187 184 ddf_fun_set_ops(instance->hc_fun, &hc_ops); 188 ddf_fun_data_implant(instance->hc_fun, &instance->hc.generic);189 185 190 186 instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh"); … … 196 192 197 193 ddf_fun_set_ops(instance->rh_fun, &rh_ops); 198 ddf_fun_data_implant(instance->rh_fun, &instance->rh);194 instance->rh = ddf_fun_data_alloc(instance->rh_fun, sizeof(rh_t)); 199 195 200 196 addr_range_t regs; … … 236 232 } 237 233 238 rc = hc_init(&instance->hc, ®s, interrupts);234 rc = hc_init(&instance->hc, instance->hc_fun, ®s, interrupts); 239 235 if (rc != EOK) { 240 236 usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(rc)); … … 260 256 } 261 257 262 rc = rh_init( &instance->rh, instance->rh_fun, ®s, 0x10, 4);258 rc = rh_init(instance->rh, instance->rh_fun, ®s, 0x10, 4); 263 259 if (rc != EOK) { 264 260 usb_log_error("Failed to setup UHCI root hub: %s.\n", -
uspace/drv/bus/usb/uhcirh/port.c
rcbfece7 r1f1fa64 269 269 int ret, count = MAX_ERROR_COUNT; 270 270 do { 271 ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection, 271 port->attached_device.fun = ddf_fun_create(port->rh, fun_inner, 272 NULL); 273 if (port->attached_device.fun == NULL) { 274 ret = ENOMEM; 275 continue; 276 } 277 278 ret = usb_hc_new_device_wrapper(port->rh, 279 port->attached_device.fun, 280 &port->hc_connection, 272 281 speed, uhci_port_reset_enable, port, 273 &port->attached_device.address, NULL, NULL, 274 &port->attached_device.fun); 282 &port->attached_device.address, NULL); 283 284 if (ret != EOK) { 285 ddf_fun_destroy(port->attached_device.fun); 286 port->attached_device.fun = NULL; 287 } 288 275 289 } while (ret != EOK && count-- > 0); 276 290 -
uspace/drv/bus/usb/usbhid/usbhid.c
rcbfece7 r1f1fa64 415 415 } 416 416 417 /* 418 * 1) subdriver vytvori vlastnu ddf_fun, vlastne ddf_dev_ops, ktore da 419 * do nej. 420 * 2) do tych ops do .interfaces[DEV_IFACE_USBHID (asi)] priradi 421 * vyplnenu strukturu usbhid_iface_t. 422 * 3) klientska aplikacia - musi si rucne vytvorit telefon 423 * (devman_device_connect() - cesta k zariadeniu (/hw/pci0/...) az 424 * k tej fcii. 425 * pouzit usb/classes/hid/iface.h - prvy int je telefon 426 */ 417 /* Initialize subdrivers */ 427 418 bool ok = false; 428 419 for (unsigned i = 0; i < hid_dev->subdriver_count; ++i) { -
uspace/drv/bus/usb/usbhub/port.c
rcbfece7 r1f1fa64 424 424 ddf_fun_t *child_fun; 425 425 426 child_fun = ddf_fun_create(data->hub->usb_device->ddf_dev, 427 fun_inner, NULL); 428 if (child_fun == NULL) 429 return ENOMEM; 430 426 431 const int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev, 427 &data->hub->usb_device->hc_conn, data->speed, enable_port_callback,428 data->port, &new_address, NULL, NULL, &child_fun);432 child_fun, &data->hub->usb_device->hc_conn, data->speed, 433 enable_port_callback, data->port, &new_address, NULL); 429 434 430 435 if (rc == EOK) { … … 440 445 ddf_fun_get_handle(child_fun)); 441 446 } else { 447 ddf_fun_destroy(child_fun); 442 448 usb_log_error("Failed registering device on port %zu: %s.\n", 443 449 data->port->port_number, str_error(rc)); -
uspace/drv/bus/usb/usbmid/explore.c
rcbfece7 r1f1fa64 34 34 * Exploration of available interfaces in the USB device. 35 35 */ 36 #include <ddf/driver.h> 36 37 #include <errno.h> 37 38 #include <str_error.h> … … 70 71 * @param config_descriptor_size Size of configuration descriptor in bytes. 71 72 * @param list List where to add the interfaces. 72 */ 73 static void create_interfaces(const uint8_t *config_descriptor, 74 size_t config_descriptor_size, list_t *list) 73 * @return EOK on success, ENOMEM if out of memory. 74 */ 75 static int create_interfaces(usb_mid_t *mid, const uint8_t *config_descriptor, 76 size_t config_descriptor_size) 75 77 { 76 78 const usb_dp_parser_data_t data = { … … 101 103 102 104 /* Skip alternate interfaces. */ 103 if (interface_in_list(list, interface->interface_number)) { 105 if (interface_in_list(&mid->interface_list, 106 interface->interface_number)) { 104 107 /* TODO: add the alternatives and create match ids 105 108 * for them. */ 106 109 continue; 107 110 } 108 usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t)); 109 if (iface == NULL) { 110 //TODO: Do something about that failure. 111 break; 112 } 111 112 /* Create the function */ 113 ddf_fun_t *fun = ddf_fun_create(mid->dev, fun_inner, NULL); 114 if (fun == NULL) 115 goto error; 116 117 usbmid_interface_t *iface = ddf_fun_data_alloc(fun, 118 sizeof(usbmid_interface_t)); 119 if (iface == NULL) 120 goto error; 113 121 114 122 link_initialize(&iface->link); 115 iface->fun = NULL;123 iface->fun = fun; 116 124 iface->interface_no = interface->interface_number; 117 125 iface->interface = interface; 118 126 119 list_append(&iface->link, list); 120 } 127 list_append(&iface->link, &mid->interface_list); 128 } 129 130 return EOK; 131 error: 132 while (!list_empty(&mid->interface_list)) { 133 link_t *link = list_first(&mid->interface_list); 134 usbmid_interface_t *iface = list_get_instance(link, 135 usbmid_interface_t, link); 136 137 ddf_fun_destroy(iface->fun); 138 } 139 140 return ENOMEM; 121 141 } 122 142 … … 165 185 } 166 186 187 usb_mid->dev = dev->ddf_dev; 188 167 189 /* Create control function. */ 168 190 usb_mid->ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl"); … … 182 204 } 183 205 184 185 206 /* Create interface children. */ 186 207 list_initialize(&usb_mid->interface_list); 187 create_interfaces(config_descriptor_raw, config_descriptor_size, 188 &usb_mid->interface_list); 208 create_interfaces(usb_mid, config_descriptor_raw, config_descriptor_size); 189 209 190 210 /* Start child function for every interface. */ -
uspace/drv/bus/usb/usbmid/usbmid.c
rcbfece7 r1f1fa64 30 30 * @{ 31 31 */ 32 33 /* XXX Fix this */34 #define _DDF_DATA_IMPLANT35 32 36 33 /** … … 102 99 const usb_standard_interface_descriptor_t *interface_descriptor) 103 100 { 104 ddf_fun_t *child = NULL;105 101 char *child_name = NULL; 106 102 int rc; … … 114 110 usb_str_class(interface_descriptor->interface_class), 115 111 interface_descriptor->interface_number); 116 if (rc < 0) {112 if (rc < 0) 117 113 return ENOMEM; 118 }119 114 120 /* Create the device. */ 121 child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name); 115 rc = ddf_fun_set_name(iface->fun, child_name); 122 116 free(child_name); 123 if ( child == NULL) {117 if (rc != EOK) 124 118 return ENOMEM; 125 }126 119 127 120 match_id_list_t match_ids; … … 130 123 rc = usb_device_create_match_ids_from_interface(device_descriptor, 131 124 interface_descriptor, &match_ids); 132 if (rc != EOK) { 133 ddf_fun_destroy(child); 125 if (rc != EOK) 134 126 return rc; 135 }136 127 137 128 list_foreach(match_ids.ids, link, match_id_t, match_id) { 138 rc = ddf_fun_add_match_id( child, match_id->id, match_id->score);129 rc = ddf_fun_add_match_id(iface->fun, match_id->id, match_id->score); 139 130 if (rc != EOK) { 140 131 clean_match_ids(&match_ids); 141 ddf_fun_destroy(child);142 132 return rc; 143 133 } … … 145 135 clean_match_ids(&match_ids); 146 136 147 rc = ddf_fun_bind(child);148 if (rc != EOK) { 149 /* This takes care of match_id deallocation as well. */150 ddf_fun_destroy(child);137 ddf_fun_set_ops(iface->fun, &child_device_ops); 138 139 rc = ddf_fun_bind(iface->fun); 140 if (rc != EOK) 151 141 return rc; 152 }153 154 iface->fun = child;155 ddf_fun_data_implant(child, iface);156 ddf_fun_set_ops(child, &child_device_ops);157 142 158 143 return EOK; -
uspace/drv/bus/usb/usbmid/usbmid.h
rcbfece7 r1f1fa64 60 60 /** Container to hold all the function pointers */ 61 61 typedef struct usb_mid { 62 ddf_dev_t *dev; 62 63 ddf_fun_t *ctl_fun; 63 64 list_t interface_list; -
uspace/drv/bus/usb/vhc/hub.c
rcbfece7 r1f1fa64 94 94 { 95 95 ddf_fun_t *hc_dev = (ddf_fun_t *) arg; 96 97 /*98 * Wait until parent device is properly initialized.99 */100 async_sess_t *sess;101 do {102 sess = devman_device_connect(EXCHANGE_SERIALIZE,103 ddf_fun_get_handle(hc_dev), 0);104 } while (!sess);105 async_hangup(sess);106 107 96 int rc; 108 97 … … 114 103 115 104 ddf_fun_t *hub_dev; 116 rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), &hc_conn, USB_SPEED_FULL, 117 pretend_port_rest, NULL, NULL, &rh_ops, hc_dev, &hub_dev); 105 106 hub_dev = ddf_fun_create(ddf_fun_get_dev(hc_dev), fun_inner, NULL); 107 if (hub_dev == NULL) { 108 rc = ENOMEM; 109 usb_log_fatal("Failed to create root hub: %s.\n", 110 str_error(rc)); 111 return rc; 112 } 113 114 rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), hub_dev, 115 &hc_conn, USB_SPEED_FULL, pretend_port_rest, NULL, NULL, &rh_ops); 118 116 if (rc != EOK) { 119 117 usb_log_fatal("Failed to create root hub: %s.\n", 120 118 str_error(rc)); 119 ddf_fun_destroy(hub_dev); 121 120 } 122 121 -
uspace/drv/nic/e1k/e1k.c
rcbfece7 r1f1fa64 71 71 /** ddf_fun_t * -> nic_driver_data_t* cast */ 72 72 #define NIC_DATA_FUN(fun) \ 73 ((nic_t *) ddf_ fun_data_get(fun))73 ((nic_t *) ddf_dev_data_get(ddf_fun_get_dev(fun))) 74 74 75 75 /** ddf_dev_t * -> nic_driver_data_t* cast */ -
uspace/drv/nic/rtl8169/driver.c
rcbfece7 r1f1fa64 439 439 nic_set_ddf_fun(nic_data, fun); 440 440 ddf_fun_set_ops(fun, &rtl8169_dev_ops); 441 ddf_fun_data_implant(fun, nic_data);441 // ddf_fun_data_implant(fun, nic_data); 442 442 443 443 rc = ddf_fun_bind(fun);
Note:
See TracChangeset
for help on using the changeset viewer.
