Changeset 4603b35 in mainline
- Timestamp:
- 2018-01-16T20:23:54Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 51a51be
- Parents:
- eeca8a6
- Location:
- uspace/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
reeca8a6 r4603b35 45 45 46 46 typedef enum { 47 IPC_M_USB_RESERVE_DEFAULT_ADDRESS, 48 IPC_M_USB_RELEASE_DEFAULT_ADDRESS, 47 IPC_M_USB_DEFAULT_ADDRESS_RESERVATION, 49 48 IPC_M_USB_DEVICE_ENUMERATE, 50 49 IPC_M_USB_DEVICE_REMOVE, … … 63 62 if (!exch) 64 63 return EBADMEM; 65 return async_req_ 1_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_RESERVE_DEFAULT_ADDRESS);64 return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_DEFAULT_ADDRESS_RESERVATION, true); 66 65 } 67 66 … … 76 75 if (!exch) 77 76 return EBADMEM; 78 return async_req_ 1_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_RELEASE_DEFAULT_ADDRESS);77 return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_DEFAULT_ADDRESS_RESERVATION, false); 79 78 } 80 79 … … 263 262 } 264 263 265 static void remote_usbhc_reserve_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 266 static void remote_usbhc_release_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 264 static void remote_usbhc_default_address_reservation(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 267 265 static void remote_usbhc_device_enumerate(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 268 266 static void remote_usbhc_device_remove(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 274 272 /** Remote USB interface operations. */ 275 273 static const remote_iface_func_ptr_t remote_usbhc_iface_ops [] = { 276 [IPC_M_USB_RESERVE_DEFAULT_ADDRESS] = remote_usbhc_reserve_default_address, 277 [IPC_M_USB_RELEASE_DEFAULT_ADDRESS] = remote_usbhc_release_default_address, 274 [IPC_M_USB_DEFAULT_ADDRESS_RESERVATION] = remote_usbhc_default_address_reservation, 278 275 [IPC_M_USB_DEVICE_ENUMERATE] = remote_usbhc_device_enumerate, 279 276 [IPC_M_USB_DEVICE_REMOVE] = remote_usbhc_device_remove, … … 297 294 } async_transaction_t; 298 295 299 void remote_usbhc_ reserve_default_address(ddf_fun_t *fun, void *iface,296 void remote_usbhc_default_address_reservation(ddf_fun_t *fun, void *iface, 300 297 ipc_callid_t callid, ipc_call_t *call) 301 298 { 302 299 const usbhc_iface_t *usbhc_iface = (usbhc_iface_t *) iface; 303 300 304 if (usbhc_iface->reserve_default_address == NULL) { 305 async_answer_0(callid, ENOTSUP); 306 return; 307 } 308 309 const int ret = usbhc_iface->reserve_default_address(fun); 301 if (usbhc_iface->default_address_reservation == NULL) { 302 async_answer_0(callid, ENOTSUP); 303 return; 304 } 305 306 const bool reserve = IPC_GET_ARG2(*call); 307 const int ret = usbhc_iface->default_address_reservation(fun, reserve); 310 308 async_answer_0(callid, ret); 311 309 } 312 310 313 void remote_usbhc_release_default_address(ddf_fun_t *fun, void *iface,314 ipc_callid_t callid, ipc_call_t *call)315 {316 const usbhc_iface_t *usbhc_iface = (usbhc_iface_t *) iface;317 318 if (usbhc_iface->release_default_address == NULL) {319 async_answer_0(callid, ENOTSUP);320 return;321 }322 323 const int ret = usbhc_iface->release_default_address(fun);324 async_answer_0(callid, ret);325 }326 311 327 312 static void remote_usbhc_device_enumerate(ddf_fun_t *fun, void *iface, -
uspace/lib/drv/include/usbhc_iface.h
reeca8a6 r4603b35 99 99 /** USB device communication interface. */ 100 100 typedef struct { 101 int (*reserve_default_address)(ddf_fun_t *); 102 int (*release_default_address)(ddf_fun_t *); 101 int (*default_address_reservation)(ddf_fun_t *, bool); 103 102 104 103 int (*device_enumerate)(ddf_fun_t *, unsigned, usb_speed_t); -
uspace/lib/usbhost/src/bus.c
reeca8a6 r4603b35 519 519 fibril_mutex_lock(&bus->guard); 520 520 if (bus->default_address_owner != dev) { 521 usb_log_error("Device %d tried to release address, which is not reserved for it.", dev->address); 521 usb_log_error("Device %d tried to release default address, " 522 "which is not reserved for it.", dev->address); 522 523 } else { 523 524 bus->default_address_owner = NULL; -
uspace/lib/usbhost/src/ddf_helpers.c
reeca8a6 r4603b35 114 114 115 115 /** 116 * DDF usbhc_iface callback. Calls the bus operation directly.116 * DDF usbhc_iface callback. Calls the respective bus operation directly. 117 117 * 118 118 * @param fun DDF function of the device (hub) requesting the address. 119 119 */ 120 static int reserve_default_address(ddf_fun_t *fun)120 static int default_address_reservation(ddf_fun_t *fun, bool reserve) 121 121 { 122 122 assert(fun); … … 127 127 assert(dev); 128 128 129 usb_log_debug("Device %d requested default address", dev->address); 130 return bus_reserve_default_address(hcd->bus, dev); 131 } 132 133 /** 134 * DDF usbhc_iface callback. Calls the bus operation directly. 135 * 136 * @param fun DDF function of the device (hub) releasing the address. 137 */ 138 static int release_default_address(ddf_fun_t *fun) 139 { 140 assert(fun); 141 hc_device_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun)); 142 device_t *dev = ddf_fun_data_get(fun); 143 assert(hcd); 144 assert(hcd->bus); 145 assert(dev); 146 147 usb_log_debug("Device %d released default address", dev->address); 148 bus_release_default_address(hcd->bus, dev); 149 150 return EOK; 129 usb_log_debug("Device %d %s default address", dev->address, reserve ? "requested" : "releasing"); 130 if (reserve) { 131 return bus_reserve_default_address(hcd->bus, dev); 132 } else { 133 bus_release_default_address(hcd->bus, dev); 134 return EOK; 135 } 151 136 } 152 137 … … 169 154 int err; 170 155 171 usb_log_debug("Hub %d reported a new %s device on port: %u",156 usb_log_debug("Hub %d reported a new %s speed device on port: %u", 172 157 hub->address, usb_str_speed(speed), port); 173 158 … … 310 295 /** USB host controller interface */ 311 296 static usbhc_iface_t usbhc_iface = { 312 .reserve_default_address = reserve_default_address, 313 .release_default_address = release_default_address, 297 .default_address_reservation = default_address_reservation, 314 298 315 299 .device_enumerate = device_enumerate,
Note:
See TracChangeset
for help on using the changeset viewer.