Changes in / [54b141a:e28d228] in mainline
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/utils.c
r54b141a re28d228 186 186 */ 187 187 188 /* 189 * WARNING: sample code, will not work out of the box. 190 * And does not contain code for checking for errors. 191 */ 192 #if 0 193 /* 194 * Before opening the port, we must acquire the default 195 * address. 196 */ 197 usb_drv_reserve_default_address(hc); 198 199 usb_address_t new_device_address = usb_drv_request_address(hc); 200 201 // TODO: open the port 202 203 // TODO: send request for setting address to new_device_address 204 205 /* 206 * Once new address is set, we can release the default 207 * address. 208 */ 209 usb_drv_release_default_address(hc); 210 211 /* 212 * Obtain descriptors and create match ids for devman. 213 */ 214 215 // TODO: get device descriptors 216 217 // TODO: create match ids 218 219 // TODO: add child device 220 221 // child_device_register sets the device handle 222 // TODO: store it here 223 devman_handle_t new_device_handle = 0; 224 225 /* 226 * Inform the HC that the new device has devman handle 227 * assigned. 228 */ 229 usb_drv_bind_address(hc, new_device_address, new_device_handle); 230 231 /* 232 * That's all. 233 */ 234 #endif 235 188 236 189 237 /* -
uspace/drv/vhc/addrmgm.c
r54b141a re28d228 49 49 typedef struct { 50 50 usb_address_t address; 51 devman_handle_t devman_handle; 51 52 bool available; 52 53 } address_info_t; … … 69 70 dev_address[i].address = i + 1; 70 71 dev_address[i].available = true; 72 dev_address[i].devman_handle = 0; 71 73 } 72 74 … … 120 122 } 121 123 124 int bind_address(device_t *dev, usb_address_t address, devman_handle_t handle) 125 { 126 if (address == DEFAULT_ADDRESS) { 127 return EPERM; 128 } 129 130 int rc = EPERM; 131 132 fibril_mutex_lock(&address_guard); 133 usb_address_t i; 134 for (i = 0; i < ADDRESS_COUNT; i++) { 135 if (dev_address[i].address == address) { 136 if (dev_address[i].available) { 137 rc = ENOENT; 138 break; 139 } 140 141 dev_address[i].devman_handle = handle; 142 rc = EOK; 143 break; 144 } 145 } 146 fibril_mutex_unlock(&address_guard); 147 148 return rc; 149 } 150 151 int tell_address(device_t *dev, devman_handle_t handle, usb_address_t *address) 152 { 153 int rc = ENOENT; 154 155 fibril_mutex_lock(&address_guard); 156 usb_address_t i; 157 for (i = 0; i < ADDRESS_COUNT; i++) { 158 if (dev_address[i].devman_handle == handle) { 159 *address = dev_address[i].address; 160 rc = EOK; 161 break; 162 } 163 } 164 fibril_mutex_unlock(&address_guard); 165 166 return rc; 167 } 168 122 169 int release_address(device_t *dev, usb_address_t address) 123 170 { … … 138 185 139 186 dev_address[i].available = true; 187 dev_address[i].devman_handle = 0; 140 188 rc = EOK; 141 189 break; -
uspace/drv/vhc/conn.h
r54b141a re28d228 52 52 int request_address(device_t *, usb_address_t *); 53 53 int release_address(device_t *, usb_address_t); 54 int bind_address(device_t *, usb_address_t, devman_handle_t); 54 55 56 int tell_address(device_t *, devman_handle_t, usb_address_t *); 55 57 56 58 void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *); -
uspace/drv/vhc/connhost.c
r54b141a re28d228 148 148 149 149 150 static int get_address(device_t *dev, devman_handle_t handle,151 usb_address_t *address)152 {153 return ENOTSUP;154 }155 156 150 static int interrupt_out(device_t *dev, usb_target_t target, 157 151 void *data, size_t size, … … 226 220 227 221 usbhc_iface_t vhc_iface = { 228 .tell_address = get_address,222 .tell_address = tell_address, 229 223 230 224 .reserve_default_address = reserve_default_address, 231 225 .release_default_address = release_default_address, 232 226 .request_address = request_address, 227 .bind_address = bind_address, 233 228 .release_address = release_address, 234 229 -
uspace/lib/drv/generic/remote_usbhc.c
r54b141a re28d228 55 55 static void remote_usbhc_release_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 56 56 static void remote_usbhc_request_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 57 static void remote_usbhc_bind_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 57 58 static void remote_usbhc_release_address(device_t *, void *, ipc_callid_t, ipc_call_t *); 58 59 //static void remote_usbhc(device_t *, void *, ipc_callid_t, ipc_call_t *); … … 68 69 69 70 remote_usbhc_request_address, 71 remote_usbhc_bind_address, 70 72 remote_usbhc_release_address, 71 73 … … 197 199 ipc_answer_1(callid, EOK, (ipcarg_t) address); 198 200 } 201 } 202 203 void remote_usbhc_bind_address(device_t *device, void *iface, 204 ipc_callid_t callid, ipc_call_t *call) 205 { 206 usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface; 207 208 if (!usb_iface->bind_address) { 209 ipc_answer_0(callid, ENOTSUP); 210 return; 211 } 212 213 usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call); 214 devman_handle_t handle = (devman_handle_t) IPC_GET_ARG2(*call); 215 216 int rc = usb_iface->bind_address(device, address, handle); 217 218 ipc_answer_0(callid, rc); 199 219 } 200 220 -
uspace/lib/drv/include/usbhc_iface.h
r54b141a re28d228 137 137 IPC_M_USBHC_REQUEST_ADDRESS, 138 138 139 /** Bind USB address with devman handle. 140 * Parameters: 141 * - USB address 142 * - devman handle 143 * Answer: 144 * - EOK - address binded 145 * - ENOENT - address is not in use 146 */ 147 IPC_M_USBHC_BIND_ADDRESS, 148 139 149 /** Release address in use. 140 150 * Arguments: … … 223 233 int (*release_default_address)(device_t *); 224 234 int (*request_address)(device_t *, usb_address_t *); 235 int (*bind_address)(device_t *, usb_address_t, devman_handle_t); 225 236 int (*release_address)(device_t *, usb_address_t); 226 237 -
uspace/lib/usb/include/usb/usbdrv.h
r54b141a re28d228 44 44 int usb_drv_release_default_address(int); 45 45 usb_address_t usb_drv_request_address(int); 46 int usb_drv_bind_address(int, usb_address_t, devman_handle_t); 46 47 int usb_drv_release_address(int, usb_address_t); 47 48 -
uspace/lib/usb/src/usbdrv.c
r54b141a re28d228 136 136 } 137 137 138 /** Inform HC about binding address with devman handle. 139 * 140 * @param phone Open phone to host controller driver. 141 * @param address Address to be binded. 142 * @param handle Devman handle of the device. 143 * @return Error code. 144 */ 145 int usb_drv_bind_address(int phone, usb_address_t address, 146 devman_handle_t handle) 147 { 148 int rc = async_req_2_0(phone, IPC_M_USBHC_BIND_ADDRESS, 149 address, handle); 150 151 return rc; 152 } 153 138 154 /** Inform HC about address release. 139 155 *
Note:
See TracChangeset
for help on using the changeset viewer.