Changeset 357a302 in mainline for uspace/lib
- Timestamp:
- 2011-02-20T14:17:40Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b68b279
- Parents:
- 3ae93a8
- Location:
- uspace/lib
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usb.c
r3ae93a8 r357a302 41 41 42 42 static void remote_usb_get_hc_handle(device_t *, void *, ipc_callid_t, ipc_call_t *); 43 static void remote_usb_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 43 44 //static void remote_usb(device_t *, void *, ipc_callid_t, ipc_call_t *); 44 45 45 46 /** Remote USB interface operations. */ 46 47 static remote_iface_func_ptr_t remote_usb_iface_ops [] = { 48 remote_usb_get_address, 47 49 remote_usb_get_hc_handle 48 50 }; … … 55 57 .methods = remote_usb_iface_ops 56 58 }; 59 60 61 void remote_usb_get_address(device_t *device, void *iface, 62 ipc_callid_t callid, ipc_call_t *call) 63 { 64 usb_iface_t *usb_iface = (usb_iface_t *) iface; 65 66 if (usb_iface->get_address == NULL) { 67 async_answer_0(callid, ENOTSUP); 68 return; 69 } 70 71 devman_handle_t handle = DEV_IPC_GET_ARG1(*call); 72 73 usb_address_t address; 74 int rc = usb_iface->get_address(device, handle, &address); 75 if (rc != EOK) { 76 async_answer_0(callid, rc); 77 } else { 78 async_answer_1(callid, EOK, address); 79 } 80 } 57 81 58 82 -
uspace/lib/drv/generic/remote_usbhc.c
r3ae93a8 r357a302 43 43 #define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4 44 44 45 static void remote_usbhc_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *);46 45 static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *); 47 46 static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 59 58 /** Remote USB host controller interface operations. */ 60 59 static remote_iface_func_ptr_t remote_usbhc_iface_ops [] = { 61 remote_usbhc_get_address,62 63 60 remote_usbhc_reserve_default_address, 64 61 remote_usbhc_release_default_address, … … 124 121 125 122 return trans; 126 }127 128 void remote_usbhc_get_address(device_t *device, void *iface,129 ipc_callid_t callid, ipc_call_t *call)130 {131 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;132 133 if (!usb_iface->tell_address) {134 async_answer_0(callid, ENOTSUP);135 return;136 }137 138 devman_handle_t handle = DEV_IPC_GET_ARG1(*call);139 140 usb_address_t address;141 int rc = usb_iface->tell_address(device, handle, &address);142 if (rc != EOK) {143 async_answer_0(callid, rc);144 } else {145 async_answer_1(callid, EOK, address);146 }147 123 } 148 124 -
uspace/lib/drv/include/usb_iface.h
r3ae93a8 r357a302 41 41 #include <usb/usb.h> 42 42 typedef enum { 43 /** Tell USB address assigned to device. 44 * Parameters: 45 * - devman handle id 46 * Answer: 47 * - EINVAL - unknown handle or handle not managed by this driver 48 * - ENOTSUP - operation not supported (shall not happen) 49 * - arbitrary error code if returned by remote implementation 50 * - EOK - handle found, first parameter contains the USB address 51 */ 52 IPC_M_USB_GET_ADDRESS, 53 43 54 /** Tell devman handle of device host controller. 44 55 * Parameters: … … 55 66 /** USB device communication interface. */ 56 67 typedef struct { 68 int (*get_address)(device_t *, devman_handle_t, usb_address_t *); 57 69 int (*get_hc_handle)(device_t *, devman_handle_t *); 58 70 } usb_iface_t; -
uspace/lib/drv/include/usbhc_iface.h
r3ae93a8 r357a302 85 85 */ 86 86 typedef enum { 87 /** Tell USB address assigned to device.88 * Parameters:89 * - devman handle id90 * Answer:91 * - EINVAL - unknown handle or handle not managed by this driver92 * - ENOTSUP - operation not supported by HC (shall not happen)93 * - arbitrary error code if returned by remote implementation94 * - EOK - handle found, first parameter contains the USB address95 */96 IPC_M_USBHC_GET_ADDRESS,97 98 99 87 /** Reserve usage of default address. 100 88 * This call informs the host controller that the caller will be … … 206 194 /** USB host controller communication interface. */ 207 195 typedef struct { 208 int (*tell_address)(device_t *, devman_handle_t, usb_address_t *);209 210 196 int (*reserve_default_address)(device_t *, usb_speed_t); 211 197 int (*release_default_address)(device_t *); -
uspace/lib/usb/Makefile
r3ae93a8 r357a302 35 35 src/addrkeep.c \ 36 36 src/class.c \ 37 src/ddfiface.c \ 37 38 src/debug.c \ 38 39 src/dp.c \ -
uspace/lib/usb/src/hub.c
r3ae93a8 r357a302 301 301 } 302 302 303 304 303 /** 305 304 * @} -
uspace/lib/usb/src/pipes.c
r3ae93a8 r357a302 36 36 #include <usb/pipes.h> 37 37 #include <usbhc_iface.h> 38 #include <usb_iface.h> 38 39 #include <errno.h> 39 40 #include <assert.h> … … 41 42 /** Tell USB address assigned to given device. 42 43 * 43 * @param phone Phone to my HC.44 * @param phone Phone to parent device. 44 45 * @param dev Device in question. 45 46 * @return USB address or error code. … … 48 49 { 49 50 sysarg_t address; 50 int rc = async_req_2_1(phone, DEV_IFACE_ID(USB HC_DEV_IFACE),51 IPC_M_USB HC_GET_ADDRESS,51 int rc = async_req_2_1(phone, DEV_IFACE_ID(USB_DEV_IFACE), 52 IPC_M_USB_GET_ADDRESS, 52 53 dev->handle, &address); 53 54 … … 80 81 } 81 82 82 int hc_phone = devman_device_connect(hc_handle, 0); 83 if (hc_phone < 0) { 84 return hc_phone; 85 } 86 87 my_address = get_my_address(hc_phone, device); 83 int parent_phone = devman_parent_device_connect(device->handle, 84 IPC_FLAG_BLOCKING); 85 if (parent_phone < 0) { 86 return parent_phone; 87 } 88 89 my_address = get_my_address(parent_phone, device); 88 90 if (my_address < 0) { 89 91 rc = my_address; … … 95 97 96 98 leave: 97 async_hangup( hc_phone);99 async_hangup(parent_phone); 98 100 return rc; 99 101 } -
uspace/lib/usb/src/recognise.c
r3ae93a8 r357a302 34 34 */ 35 35 #include <sys/types.h> 36 #include <usb_iface.h>37 36 #include <usb/usbdrv.h> 38 37 #include <usb/pipes.h> 39 38 #include <usb/recognise.h> 39 #include <usb/ddfiface.h> 40 40 #include <usb/request.h> 41 41 #include <usb/classes/classes.h> … … 46 46 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex); 47 47 48 /** Callback for getting host controller handle.49 *50 * @param dev Device in question.51 * @param[out] handle Devman handle of the host controller.52 * @return Error code.53 */54 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)55 {56 assert(dev);57 assert(dev->parent != NULL);58 59 device_t *parent = dev->parent;60 61 if (parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {62 usb_iface_t *usb_iface63 = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];64 assert(usb_iface != NULL);65 if (usb_iface->get_hc_handle) {66 int rc = usb_iface->get_hc_handle(parent, handle);67 return rc;68 }69 }70 71 return ENOTSUP;72 }73 74 static usb_iface_t usb_iface = {75 .get_hc_handle = usb_iface_get_hc_handle76 };77 78 48 device_ops_t child_ops = { 79 .interfaces[USB_DEV_IFACE] = &usb_iface 49 .interfaces[USB_DEV_IFACE] = &usb_iface_hub_child_impl 80 50 }; 81 51
Note:
See TracChangeset
for help on using the changeset viewer.