Changeset b828907 in mainline for uspace/lib
- Timestamp:
- 2012-07-20T20:29:54Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 34bc2fe
- Parents:
- 4cdac68 (diff), 6de2d766 (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/lib
- Files:
-
- 5 added
- 24 edited
-
c/Makefile (modified) (1 diff)
-
c/generic/device/ahci.c (added)
-
c/include/device/ahci.h (added)
-
c/include/ipc/dev_iface.h (modified) (1 diff)
-
drv/Makefile (modified) (1 diff)
-
drv/generic/dev_iface.c (modified) (2 diffs)
-
drv/generic/remote_ahci.c (added)
-
drv/generic/remote_usb.c (modified) (8 diffs)
-
drv/generic/remote_usbhc.c (modified) (15 diffs)
-
drv/include/ahci_iface.h (added)
-
drv/include/remote_ahci.h (added)
-
usbdev/include/usb/dev/usb_device_connection.h (modified) (6 diffs)
-
usbdev/src/devdrv.c (modified) (6 diffs)
-
usbdev/src/pipes.c (modified) (10 diffs)
-
usbdev/src/pipesinit.c (modified) (4 diffs)
-
usbdev/src/request.c (modified) (8 diffs)
-
usbhid/include/usb/hid/hid_report_items.h (modified) (7 diffs)
-
usbhid/include/usb/hid/hidpath.h (modified) (4 diffs)
-
usbhid/include/usb/hid/hidtypes.h (modified) (8 diffs)
-
usbhid/include/usb/hid/request.h (modified) (2 diffs)
-
usbhid/src/hiddescriptor.c (modified) (13 diffs)
-
usbhid/src/hidparser.c (modified) (11 diffs)
-
usbhid/src/hidpath.c (modified) (11 diffs)
-
usbhid/src/hidreport.c (modified) (6 diffs)
-
usbhid/src/hidreq.c (modified) (7 diffs)
-
usbhost/src/endpoint.c (modified) (7 diffs)
-
usbhost/src/usb_device_manager.c (modified) (6 diffs)
-
usbhost/src/usb_endpoint_manager.c (modified) (11 diffs)
-
usbhost/src/usb_transfer_batch.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r4cdac68 rb828907 71 71 generic/device/nic.c \ 72 72 generic/device/pci.c \ 73 generic/device/ahci.c \ 73 74 generic/elf/elf_load.c \ 74 75 generic/event.c \ -
uspace/lib/c/include/ipc/dev_iface.h
r4cdac68 rb828907 51 51 /** Interface provided by USB HID devices. */ 52 52 USBHID_DEV_IFACE, 53 /** Interface provided by AHCI devices. */ 54 AHCI_DEV_IFACE, 53 55 54 56 DEV_IFACE_MAX -
uspace/lib/drv/Makefile
r4cdac68 rb828907 44 44 generic/remote_pci.c \ 45 45 generic/remote_usbhc.c \ 46 generic/remote_usbhid.c 46 generic/remote_usbhid.c \ 47 generic/remote_ahci.c 47 48 48 49 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/drv/generic/dev_iface.c
r4cdac68 rb828907 46 46 #include "remote_usbhid.h" 47 47 #include "remote_pci.h" 48 #include "remote_ahci.h" 48 49 49 50 static iface_dipatch_table_t remote_ifaces = { … … 55 56 &remote_usb_iface, 56 57 &remote_usbhc_iface, 57 &remote_usbhid_iface 58 &remote_usbhid_iface, 59 &remote_ahci_iface 58 60 } 59 61 }; -
uspace/lib/drv/generic/remote_usb.c
r4cdac68 rb828907 56 56 { 57 57 if (!exch) 58 return E INVAL;58 return EBADMEM; 59 59 sysarg_t addr; 60 60 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), … … 65 65 return ret; 66 66 } 67 /*----------------------------------------------------------------------------*/ 67 68 68 /** Tell interface number given device can use. 69 69 * @param[in] exch IPC communication exchange … … 75 75 { 76 76 if (!exch) 77 return E INVAL;77 return EBADMEM; 78 78 sysarg_t iface_no; 79 79 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), … … 83 83 return ret; 84 84 } 85 /*----------------------------------------------------------------------------*/ 85 86 86 /** Tell devman handle of device host controller. 87 87 * @param[in] exch IPC communication exchange … … 92 92 { 93 93 if (!exch) 94 return E INVAL;94 return EBADMEM; 95 95 devman_handle_t h; 96 96 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), … … 121 121 }; 122 122 123 /*----------------------------------------------------------------------------*/ 123 124 124 void remote_usb_get_my_address(ddf_fun_t *fun, void *iface, 125 125 ipc_callid_t callid, ipc_call_t *call) … … 140 140 } 141 141 } 142 /*----------------------------------------------------------------------------*/ 142 143 143 void remote_usb_get_my_interface(ddf_fun_t *fun, void *iface, 144 144 ipc_callid_t callid, ipc_call_t *call) … … 159 159 } 160 160 } 161 /*----------------------------------------------------------------------------*/ 161 162 162 void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface, 163 163 ipc_callid_t callid, ipc_call_t *call) -
uspace/lib/drv/generic/remote_usbhc.c
r4cdac68 rb828907 165 165 { 166 166 if (!exch || !address) 167 return E INVAL;167 return EBADMEM; 168 168 sysarg_t new_address; 169 169 const int ret = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), … … 173 173 return ret; 174 174 } 175 /*----------------------------------------------------------------------------*/ 175 176 176 int usbhc_bind_address(async_exch_t *exch, usb_address_t address, 177 177 devman_handle_t handle) 178 178 { 179 179 if (!exch) 180 return E INVAL;180 return EBADMEM; 181 181 return async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 182 182 IPC_M_USBHC_BIND_ADDRESS, address, handle); 183 183 } 184 /*----------------------------------------------------------------------------*/ 184 185 185 int usbhc_get_handle(async_exch_t *exch, usb_address_t address, 186 186 devman_handle_t *handle) 187 187 { 188 188 if (!exch) 189 return E INVAL;189 return EBADMEM; 190 190 sysarg_t h; 191 191 const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), … … 195 195 return ret; 196 196 } 197 /*----------------------------------------------------------------------------*/ 197 198 198 int usbhc_release_address(async_exch_t *exch, usb_address_t address) 199 199 { 200 200 if (!exch) 201 return E INVAL;201 return EBADMEM; 202 202 return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 203 203 IPC_M_USBHC_RELEASE_ADDRESS, address); 204 204 } 205 /*----------------------------------------------------------------------------*/ 205 206 206 int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address, 207 207 usb_endpoint_t endpoint, usb_transfer_type_t type, … … 209 209 { 210 210 if (!exch) 211 return E INVAL;211 return EBADMEM; 212 212 const usb_target_t target = 213 213 {{ .address = address, .endpoint = endpoint }}; … … 220 220 #undef _PACK2 221 221 } 222 /*----------------------------------------------------------------------------*/ 222 223 223 int usbhc_unregister_endpoint(async_exch_t *exch, usb_address_t address, 224 224 usb_endpoint_t endpoint, usb_direction_t direction) 225 225 { 226 226 if (!exch) 227 return E INVAL;227 return EBADMEM; 228 228 return async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 229 229 IPC_M_USBHC_UNREGISTER_ENDPOINT, address, endpoint, direction); 230 230 } 231 /*----------------------------------------------------------------------------*/ 231 232 232 int usbhc_read(async_exch_t *exch, usb_address_t address, 233 233 usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size, 234 234 size_t *rec_size) 235 235 { 236 if (!exch) 237 return EBADMEM; 238 236 239 if (size == 0 && setup == 0) 237 240 return EOK; 238 241 239 if (!exch)240 return EINVAL;241 242 const usb_target_t target = 242 243 {{ .address = address, .endpoint = endpoint }}; … … 284 285 return EOK; 285 286 } 286 /*----------------------------------------------------------------------------*/ 287 287 288 int usbhc_write(async_exch_t *exch, usb_address_t address, 288 289 usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size) 289 290 { 291 if (!exch) 292 return EBADMEM; 293 290 294 if (size == 0 && setup == 0) 291 295 return EOK; 292 296 293 if (!exch)294 return EINVAL;295 297 const usb_target_t target = 296 298 {{ .address = address, .endpoint = endpoint }}; … … 319 321 return (int) opening_request_rc; 320 322 } 321 /*----------------------------------------------------------------------------*/ 323 322 324 323 325 static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 384 386 return trans; 385 387 } 386 /*----------------------------------------------------------------------------*/ 388 387 389 void remote_usbhc_request_address(ddf_fun_t *fun, void *iface, 388 390 ipc_callid_t callid, ipc_call_t *call) … … 406 408 } 407 409 } 408 /*----------------------------------------------------------------------------*/ 410 409 411 void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface, 410 412 ipc_callid_t callid, ipc_call_t *call) … … 423 425 async_answer_0(callid, ret); 424 426 } 425 /*----------------------------------------------------------------------------*/ 427 426 428 void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface, 427 429 ipc_callid_t callid, ipc_call_t *call) … … 444 446 } 445 447 } 446 /*----------------------------------------------------------------------------*/ 448 447 449 void remote_usbhc_release_address(ddf_fun_t *fun, void *iface, 448 450 ipc_callid_t callid, ipc_call_t *call) … … 460 462 async_answer_0(callid, ret); 461 463 } 462 /*----------------------------------------------------------------------------*/ 464 463 465 static void callback_out(ddf_fun_t *fun, 464 466 int outcome, void *arg) … … 470 472 async_transaction_destroy(trans); 471 473 } 472 /*----------------------------------------------------------------------------*/ 474 473 475 static void callback_in(ddf_fun_t *fun, 474 476 int outcome, size_t actual_size, void *arg) … … 494 496 async_transaction_destroy(trans); 495 497 } 496 /*----------------------------------------------------------------------------*/ 498 497 499 void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface, 498 500 ipc_callid_t callid, ipc_call_t *call) … … 594 596 } 595 597 } 596 /*----------------------------------------------------------------------------*/ 598 597 599 void remote_usbhc_write( 598 600 ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) -
uspace/lib/usbdev/include/usb/dev/usb_device_connection.h
r4cdac68 rb828907 72 72 return EOK; 73 73 } 74 /*----------------------------------------------------------------------------*/ 74 75 75 /** Register endpoint on the device. 76 76 * @param instance device connection structure to use. … … 91 91 instance->address, ep, type, direction, packet_size, interval); 92 92 } 93 /*----------------------------------------------------------------------------*/ 93 94 94 /** Unregister endpoint on the device. 95 95 * @param instance device connection structure … … 105 105 instance->address, ep, dir); 106 106 } 107 /*----------------------------------------------------------------------------*/ 107 108 108 /** Get data from the device. 109 109 * @param[in] instance device connection structure to use. … … 122 122 instance->address, ep, setup, data, size, rsize); 123 123 } 124 /*----------------------------------------------------------------------------*/ 124 125 125 /** Send data to the device. 126 126 * @param instance device connection structure to use. … … 138 138 instance->address, ep, setup, data, size); 139 139 } 140 /*----------------------------------------------------------------------------*/ 140 141 141 /** Wrapper for read calls with no setup stage. 142 142 * @param[in] instance device connection structure. … … 153 153 return usb_device_control_read(instance, ep, 0, data, size, real_size); 154 154 } 155 /*----------------------------------------------------------------------------*/ 155 156 156 /** Wrapper for write calls with no setup stage. 157 157 * @param instance device connection structure. -
uspace/lib/usbdev/src/devdrv.c
r4cdac68 rb828907 74 74 return ddf_driver_main(&generic_driver); 75 75 } 76 /*----------------------------------------------------------------------------*/ 76 77 77 /** Count number of pipes the driver expects. 78 78 * … … 87 87 return count; 88 88 } 89 /*----------------------------------------------------------------------------*/ 89 90 90 /** Callback when a new device is supposed to be controlled by this driver. 91 91 * … … 124 124 return rc; 125 125 } 126 /*----------------------------------------------------------------------------*/ 126 127 127 /** Callback when a device is supposed to be removed from the system. 128 128 * … … 146 146 return EOK; 147 147 } 148 /*----------------------------------------------------------------------------*/ 148 149 149 /** Callback when a device was removed from the system. 150 150 * … … 167 167 return ret; 168 168 } 169 /*----------------------------------------------------------------------------*/ 169 170 170 /** Destroy existing pipes of a USB device. 171 171 * … … 178 178 dev->pipes_count = 0; 179 179 } 180 /*----------------------------------------------------------------------------*/ 180 181 181 /** Change interface setting of a device. 182 182 * This function selects new alternate setting of an interface by issuing -
uspace/lib/usbdev/src/pipes.c
r4cdac68 rb828907 54 54 return usb_hc_connection_open(pipe->wire->hc_connection); 55 55 } 56 /*----------------------------------------------------------------------------*/ 56 57 57 /** Terminate a long transfer on a pipe. 58 58 * @param pipe Pipe where to end the long transfer. … … 67 67 return usb_hc_connection_close(pipe->wire->hc_connection); 68 68 } 69 /*----------------------------------------------------------------------------*/ 69 70 70 /** Try to clear endpoint halt of default control pipe. 71 71 * … … 85 85 pipe->auto_reset_halt = true; 86 86 } 87 /*----------------------------------------------------------------------------*/ 87 88 88 /** Request a control read transfer on an endpoint pipe. 89 89 * … … 135 135 return rc; 136 136 } 137 /*----------------------------------------------------------------------------*/ 137 138 138 /** Request a control write transfer on an endpoint pipe. 139 139 * … … 182 182 return rc; 183 183 } 184 /*----------------------------------------------------------------------------*/ 184 185 185 /** Request a read (in) transfer on an endpoint pipe. 186 186 * … … 227 227 return rc; 228 228 } 229 /*----------------------------------------------------------------------------*/ 229 230 230 /** Request a write (out) transfer on an endpoint pipe. 231 231 * … … 259 259 pipe->endpoint_no, buffer, size); 260 260 } 261 /*----------------------------------------------------------------------------*/ 261 262 262 /** Initialize USB endpoint pipe. 263 263 * … … 287 287 return EOK; 288 288 } 289 /*----------------------------------------------------------------------------*/ 289 290 290 /** Initialize USB endpoint pipe as the default zero control pipe. 291 291 * … … 307 307 return rc; 308 308 } 309 /*----------------------------------------------------------------------------*/ 309 310 310 /** Register endpoint with the host controller. 311 311 * … … 323 323 pipe->direction, pipe->max_packet_size, interval); 324 324 } 325 /*----------------------------------------------------------------------------*/ 325 326 326 /** Revert endpoint registration with the host controller. 327 327 * -
uspace/lib/usbdev/src/pipesinit.c
r4cdac68 rb828907 154 154 usb_endpoint_mapping_t *mapping, size_t mapping_count, 155 155 usb_standard_interface_descriptor_t *interface, 156 usb_standard_endpoint_descriptor_t *endpoint ,156 usb_standard_endpoint_descriptor_t *endpoint_desc, 157 157 usb_device_connection_t *wire) 158 158 { … … 163 163 164 164 /* Actual endpoint number is in bits 0..3 */ 165 const usb_endpoint_t ep_no = endpoint ->endpoint_address & 0x0F;165 const usb_endpoint_t ep_no = endpoint_desc->endpoint_address & 0x0F; 166 166 167 167 const usb_endpoint_description_t description = { 168 168 /* Endpoint direction is set by bit 7 */ 169 .direction = (endpoint ->endpoint_address & 128)169 .direction = (endpoint_desc->endpoint_address & 128) 170 170 ? USB_DIRECTION_IN : USB_DIRECTION_OUT, 171 171 /* Transfer type is in bits 0..2 and 172 172 * the enum values corresponds 1:1 */ 173 .transfer_type = endpoint ->attributes & 3,173 .transfer_type = endpoint_desc->attributes & 3, 174 174 175 175 /* Get interface characteristics. */ … … 194 194 195 195 int rc = usb_pipe_initialize(&ep_mapping->pipe, wire, 196 ep_no, description.transfer_type, endpoint->max_packet_size, 196 ep_no, description.transfer_type, 197 uint16_usb2host(endpoint_desc->max_packet_size), 197 198 description.direction); 198 199 if (rc != EOK) { … … 201 202 202 203 ep_mapping->present = true; 203 ep_mapping->descriptor = endpoint ;204 ep_mapping->descriptor = endpoint_desc; 204 205 ep_mapping->interface = interface; 205 206 -
uspace/lib/usbdev/src/request.c
r4cdac68 rb828907 114 114 * (in native endianness). 115 115 * @param actual_data_size Actual size of transfered data 116 * (in native endianness).116 * (in native endianness). 117 117 * @return Error code. 118 118 * @retval EBADMEM @p pipe is NULL. … … 147 147 | (request_type << 5) | recipient, 148 148 .request = request, 149 .value = value,150 .index = index,151 .length = (uint16_t) data_size,149 .value = uint16_host2usb(value), 150 .index = uint16_host2usb(index), 151 .length = uint16_host2usb(data_size), 152 152 }; 153 153 … … 375 375 usb_standard_device_descriptor_t descriptor_tmp; 376 376 int rc = usb_request_get_descriptor(pipe, 377 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 377 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 378 378 USB_DESCTYPE_DEVICE, 0, 0, 379 379 &descriptor_tmp, sizeof(descriptor_tmp), … … 435 435 /* Everything is okay, copy the descriptor. */ 436 436 memcpy(descriptor, &descriptor_tmp, sizeof(descriptor_tmp)); 437 438 437 return EOK; 439 438 } … … 495 494 return ENOENT; 496 495 } 497 if (bare_config.total_length < sizeof(bare_config)) { 496 497 const size_t total_length = uint16_usb2host(bare_config.total_length); 498 if (total_length < sizeof(bare_config)) { 498 499 return ELIMIT; 499 500 } 500 501 501 void *buffer = malloc( bare_config.total_length);502 void *buffer = malloc(total_length); 502 503 if (buffer == NULL) { 503 504 return ENOMEM; … … 506 507 size_t transferred = 0; 507 508 rc = usb_request_get_full_configuration_descriptor(pipe, index, 508 buffer, bare_config.total_length, &transferred);509 buffer, total_length, &transferred); 509 510 if (rc != EOK) { 510 511 free(buffer); … … 512 513 } 513 514 514 if (transferred != bare_config.total_length) {515 if (transferred != total_length) { 515 516 free(buffer); 516 517 return ELIMIT; … … 522 523 523 524 if (descriptor_size != NULL) { 524 *descriptor_size = bare_config.total_length;525 *descriptor_size = total_length; 525 526 } 526 527 -
uspace/lib/usbhid/include/usb/hid/hid_report_items.h
r4cdac68 rb828907 38 38 #include <stdint.h> 39 39 40 /*---------------------------------------------------------------------------*/ 40 41 41 /* 42 42 * Item prefix … … 56 56 #define USB_HID_ITEM_IS_LONG(data) (data == 0xFE) 57 57 58 /*---------------------------------------------------------------------------*/ 58 59 59 /* 60 60 * Extended usage macros … … 70 70 #define USB_HID_EXTENDED_USAGE(usage) (usage & 0xFFFF) 71 71 72 /*---------------------------------------------------------------------------*/ 72 73 73 /* 74 74 * Input/Output/Feature Item flags … … 142 142 #define USB_HID_ITEM_FLAG_BUFFERED(flags) ((flags & 0x100) == 0x100) 143 143 144 /*---------------------------------------------------------------------------*/ 144 145 145 146 146 /* MAIN ITEMS */ … … 185 185 #define USB_HID_REPORT_TAG_END_COLLECTION 0xC 186 186 187 /*---------------------------------------------------------------------------*/ 187 188 188 189 189 /* GLOBAL ITEMS */ … … 272 272 #define USB_HID_REPORT_TAG_POP 0xB 273 273 274 /*---------------------------------------------------------------------------*/ 274 275 275 276 276 /* LOCAL ITEMS */ … … 347 347 #define USB_HID_REPORT_TAG_DELIMITER 0xA 348 348 349 /*---------------------------------------------------------------------------*/ 349 350 350 351 351 #endif -
uspace/lib/usbhid/include/usb/hid/hidpath.h
r4cdac68 rb828907 41 41 42 42 43 /*---------------------------------------------------------------------------*/ 43 44 44 /* 45 45 * Flags of usage paths comparison modes. … … 73 73 #define USB_HID_PATH_COMPARE_ANYWHERE 8 74 74 75 /*----------------------------------------------------------------------------*/ 75 76 76 /** 77 77 * Item of usage path structure. Last item of linked list describes one item … … 93 93 94 94 95 /*---------------------------------------------------------------------------*/ 95 96 96 /** 97 97 * USB HID usage path structure. … … 112 112 } usb_hid_report_path_t; 113 113 114 /*---------------------------------------------------------------------------*/ 114 115 115 usb_hid_report_path_t *usb_hid_report_path(void); 116 116 -
uspace/lib/usbhid/include/usb/hid/hidtypes.h
r4cdac68 rb828907 39 39 #include <adt/list.h> 40 40 41 /*---------------------------------------------------------------------------*/ 41 42 42 43 43 /** … … 69 69 (((x) < 0 ) ? ((1 << (size)) + (x)) : (x)) 70 70 71 /*---------------------------------------------------------------------------*/ 71 72 72 73 73 /** … … 86 86 } usb_hid_report_type_t; 87 87 88 /*---------------------------------------------------------------------------*/ 88 89 89 90 90 /** … … 111 111 112 112 } usb_hid_report_t; 113 /*---------------------------------------------------------------------------*/ 113 114 114 115 115 /** … … 135 135 link_t reports_link; 136 136 } usb_hid_report_description_t; 137 /*---------------------------------------------------------------------------*/ 137 138 138 139 139 /** … … 202 202 } usb_hid_report_field_t; 203 203 204 /*---------------------------------------------------------------------------*/ 204 205 205 206 206 /** … … 287 287 int in_delimiter; 288 288 } usb_hid_report_item_t; 289 /*---------------------------------------------------------------------------*/ 289 290 290 /** 291 291 * Enum of the keyboard modifiers … … 314 314 USB_HID_MOD_RGUI 315 315 }; 316 /*---------------------------------------------------------------------------*/ 316 317 317 318 318 -
uspace/lib/usbhid/include/usb/hid/request.h
r4cdac68 rb828907 42 42 #include <usb/dev/pipes.h> 43 43 44 /*----------------------------------------------------------------------------*/ 44 45 45 46 46 int usbhid_req_set_report(usb_pipe_t *ctrl_pipe, int iface_no, … … 61 61 int usbhid_req_get_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t *duration); 62 62 63 /*----------------------------------------------------------------------------*/ 63 64 64 65 65 #endif /* USB_KBD_HIDREQ_H_ */ -
uspace/lib/usbhid/src/hiddescriptor.c
r4cdac68 rb828907 41 41 #include <assert.h> 42 42 43 /*---------------------------------------------------------------------------*/ 43 44 44 /* 45 45 * Constants defining current parsing mode for correct parsing of the set of … … 61 61 #define INSIDE_DELIMITER_SET 2 62 62 63 /*---------------------------------------------------------------------------*/ 63 64 64 65 65 /** The new report item flag. Used to determine when the item is completly … … 78 78 #define USB_HID_UNKNOWN_TAG -99 79 79 80 /*---------------------------------------------------------------------------*/ 80 81 81 /** 82 82 * Checks if given collection path is already present in report structure and … … 124 124 } 125 125 126 /*---------------------------------------------------------------------------*/ 126 127 127 /** 128 128 * Initialize the report descriptor parser structure … … 147 147 } 148 148 149 /*---------------------------------------------------------------------------*/ 149 150 150 151 151 /** … … 314 314 return EOK; 315 315 } 316 /*---------------------------------------------------------------------------*/ 316 317 317 /** 318 318 * Finds description of report with given report_id and of given type in … … 348 348 return NULL; 349 349 } 350 /*---------------------------------------------------------------------------*/ 350 351 351 352 352 /** Parse HID report descriptor. … … 536 536 } 537 537 538 /*---------------------------------------------------------------------------*/ 538 539 539 540 540 /** … … 871 871 return EOK; 872 872 } 873 /*---------------------------------------------------------------------------*/ 873 874 874 875 875 /** … … 892 892 return result; 893 893 } 894 /*---------------------------------------------------------------------------*/ 894 895 895 896 896 /** … … 941 941 942 942 } 943 /*---------------------------------------------------------------------------*/ 943 944 944 945 945 /** … … 972 972 } 973 973 } 974 /*---------------------------------------------------------------------------*/ 974 975 975 976 976 … … 1022 1022 return; 1023 1023 } 1024 /*---------------------------------------------------------------------------*/ 1024 1025 1025 1026 1026 /** -
uspace/lib/usbhid/src/hidparser.c
r4cdac68 rb828907 41 41 #include <assert.h> 42 42 43 /*---------------------------------------------------------------------------*/ 43 44 44 /* 45 45 * Data translation private functions … … 52 52 int32_t value); 53 53 54 /*---------------------------------------------------------------------------*/ 54 55 55 56 56 static int usb_pow(int a, int b) … … 68 68 } 69 69 } 70 /*---------------------------------------------------------------------------*/ 70 71 71 72 72 /** Returns size of report of specified report id and type in items … … 117 117 } 118 118 } 119 /*---------------------------------------------------------------------------*/ 119 120 120 121 121 /** Parse and act upon a HID report. … … 192 192 } 193 193 194 /*---------------------------------------------------------------------------*/ 194 195 195 /** 196 196 * Translate data from the report as specified in report descriptor item … … 274 274 } 275 275 276 /*---------------------------------------------------------------------------*/ 276 277 277 /* OUTPUT API */ 278 278 … … 431 431 } 432 432 433 /*---------------------------------------------------------------------------*/ 433 434 434 /** 435 435 * Translate given data for putting them into the outoput report … … 476 476 } 477 477 478 /*---------------------------------------------------------------------------*/ 478 479 479 /** 480 480 * Clones given state table … … 497 497 } 498 498 499 /*---------------------------------------------------------------------------*/ 499 500 500 /** 501 501 * Function for sequence walking through the report. Returns next field in the … … 552 552 } 553 553 554 /*---------------------------------------------------------------------------*/ 554 555 555 /** 556 556 * Returns next report_id of report of specified type. If zero is given than … … 600 600 } 601 601 602 /*---------------------------------------------------------------------------*/ 602 603 603 /** 604 604 * Reset all local items in given state table -
uspace/lib/usbhid/src/hidpath.c
r4cdac68 rb828907 41 41 #include <assert.h> 42 42 43 /*---------------------------------------------------------------------------*/ 43 44 44 /** 45 45 * Compares two usages if they are same or not or one of the usages is not … … 63 63 ((page1 == page2) || (page1 == 0) || (page2 == 0)) 64 64 65 /*---------------------------------------------------------------------------*/ 65 66 66 /** 67 67 * Appends one item (couple of usage_path and usage) into the usage path … … 93 93 } 94 94 95 /*---------------------------------------------------------------------------*/ 95 96 96 /** 97 97 * Removes last item from the usage path structure … … 114 114 } 115 115 116 /*---------------------------------------------------------------------------*/ 116 117 117 /** 118 118 * Nulls last item of the usage path structure. … … 133 133 } 134 134 135 /*---------------------------------------------------------------------------*/ 135 136 136 /** 137 137 * Modifies last item of usage path structure by given usage page or usage … … 164 164 } 165 165 166 /*---------------------------------------------------------------------------*/ 166 167 167 /** 168 168 * … … 188 188 } 189 189 190 /*---------------------------------------------------------------------------*/ 190 191 191 /** 192 192 * Compares two usage paths structures … … 354 354 } 355 355 356 /*---------------------------------------------------------------------------*/ 356 357 357 /** 358 358 * Allocates and initializes new usage path structure. … … 376 376 } 377 377 378 /*---------------------------------------------------------------------------*/ 378 379 379 /** 380 380 * Releases given usage path structure. … … 395 395 } 396 396 397 /*---------------------------------------------------------------------------*/ 397 398 398 /** 399 399 * Clone content of given usage path to the new one … … 441 441 } 442 442 443 /*---------------------------------------------------------------------------*/ 443 444 444 /** 445 445 * Sets report id in usage path structure -
uspace/lib/usbhid/src/hidreport.c
r4cdac68 rb828907 50 50 #include <usb/hid/hidreport.h> 51 51 52 static int usb_hid_get_report_descriptor(usb_device_t *dev, 52 static int usb_hid_get_report_descriptor(usb_device_t *dev, 53 53 uint8_t **report_desc, size_t *size) 54 54 { … … 69 69 * First nested descriptor of the configuration descriptor. 70 70 */ 71 const uint8_t *d = 72 usb_dp_get_nested_descriptor(&parser, &parser_data, 71 const uint8_t *d = 72 usb_dp_get_nested_descriptor(&parser, &parser_data, 73 73 dev->descriptors.configuration); 74 74 … … 78 78 int i = 0; 79 79 while (d != NULL && i < dev->interface_no) { 80 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 80 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 81 81 dev->descriptors.configuration, d); 82 82 ++i; … … 99 99 */ 100 100 while (d != NULL && *(d + 1) != USB_DESCTYPE_HID) { 101 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 101 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 102 102 iface_desc, d); 103 103 } … … 114 114 } 115 115 116 usb_standard_hid_descriptor_t *hid_desc = 116 usb_standard_hid_descriptor_t *hid_desc = 117 117 (usb_standard_hid_descriptor_t *)d; 118 118 119 uint16_t length = hid_desc->report_desc_info.length;119 uint16_t length = uint16_usb2host(hid_desc->report_desc_info.length); 120 120 size_t actual_size = 0; 121 121 … … 161 161 } 162 162 163 /*----------------------------------------------------------------------------*/ 163 164 164 165 165 int usb_hid_process_report_descriptor(usb_device_t *dev, -
uspace/lib/usbhid/src/hidreq.c
r4cdac68 rb828907 45 45 #include <usb/hid/request.h> 46 46 47 /*----------------------------------------------------------------------------*/ 47 48 48 /** 49 49 * Send Set Report request to the HID device. … … 97 97 } 98 98 99 /*----------------------------------------------------------------------------*/ 99 100 100 /** 101 101 * Send Set Protocol request to the HID device. … … 145 145 } 146 146 147 /*----------------------------------------------------------------------------*/ 147 148 148 /** 149 149 * Send Set Idle request to the HID device. … … 195 195 } 196 196 197 /*----------------------------------------------------------------------------*/ 197 198 198 /** 199 199 * Send Get Report request to the HID device. … … 251 251 } 252 252 253 /*----------------------------------------------------------------------------*/ 253 254 254 /** 255 255 * Send Get Protocol request to the HID device. … … 310 310 } 311 311 312 /*----------------------------------------------------------------------------*/ 312 313 313 /** 314 314 * Send Get Idle request to the HID device. … … 373 373 } 374 374 375 /*----------------------------------------------------------------------------*/ 375 376 376 377 377 /** -
uspace/lib/usbhost/src/endpoint.c
r4cdac68 rb828907 72 72 return instance; 73 73 } 74 /*----------------------------------------------------------------------------*/ 74 75 75 /** Properly dispose of endpoint_t structure. 76 76 * @param instance endpoint_t structure. … … 84 84 free(instance); 85 85 } 86 /*----------------------------------------------------------------------------*/ 86 87 87 /** Set device specific data and hooks. 88 88 * @param instance endpoint_t structure. … … 101 101 fibril_mutex_unlock(&instance->guard); 102 102 } 103 /*----------------------------------------------------------------------------*/ 103 104 104 /** Clear device specific data and hooks. 105 105 * @param instance endpoint_t structure. … … 115 115 fibril_mutex_unlock(&instance->guard); 116 116 } 117 /*----------------------------------------------------------------------------*/ 117 118 118 /** Mark the endpoint as active and block access for further fibrils. 119 119 * @param instance endpoint_t structure. … … 128 128 fibril_mutex_unlock(&instance->guard); 129 129 } 130 /*----------------------------------------------------------------------------*/ 130 131 131 /** Mark the endpoint as inactive and allow access for further fibrils. 132 132 * @param instance endpoint_t structure. … … 140 140 fibril_condvar_signal(&instance->avail); 141 141 } 142 /*----------------------------------------------------------------------------*/ 142 143 143 /** Get the value of toggle bit. 144 144 * @param instance endpoint_t structure. … … 156 156 return ret; 157 157 } 158 /*----------------------------------------------------------------------------*/ 158 159 159 /** Set the value of toggle bit. 160 160 * @param instance endpoint_t structure. -
uspace/lib/usbhost/src/usb_device_manager.c
r4cdac68 rb828907 61 61 return new_address; 62 62 } 63 /*----------------------------------------------------------------------------*/ 63 64 64 /** Initialize device manager structure. 65 65 * … … 82 82 fibril_mutex_initialize(&instance->guard); 83 83 } 84 /*----------------------------------------------------------------------------*/ 84 85 85 /** Request USB address. 86 86 * @param instance usb_device_manager … … 124 124 return EOK; 125 125 } 126 /*----------------------------------------------------------------------------*/ 126 127 127 /** Bind USB address to devman handle. 128 128 * … … 156 156 return EOK; 157 157 } 158 /*----------------------------------------------------------------------------*/ 158 159 159 /** Release used USB address. 160 160 * … … 182 182 return EOK; 183 183 } 184 /*----------------------------------------------------------------------------*/ 184 185 185 /** Find USB address associated with the device. 186 186 * … … 205 205 return ENOENT; 206 206 } 207 /*----------------------------------------------------------------------------*/ 207 208 208 /** Find devman handle and speed assigned to USB address. 209 209 * -
uspace/lib/usbhost/src/usb_endpoint_manager.c
r4cdac68 rb828907 61 61 && (address == ep->address); 62 62 } 63 /*----------------------------------------------------------------------------*/ 63 64 64 /** Get list that holds endpoints for given address. 65 65 * @param instance usb_endpoint_manager structure, non-null. … … 73 73 return &instance->endpoint_lists[addr % ENDPOINT_LIST_COUNT]; 74 74 } 75 /*----------------------------------------------------------------------------*/ 75 76 76 /** Internal search function, works on locked structure. 77 77 * @param instance usb_endpoint_manager structure, non-null. … … 97 97 return NULL; 98 98 } 99 /*----------------------------------------------------------------------------*/ 99 100 100 /** Calculate bandwidth that needs to be reserved for communication with EP. 101 101 * Calculation follows USB 1.1 specification. … … 145 145 } 146 146 } 147 /*----------------------------------------------------------------------------*/ 147 148 148 /** Initialize to default state. 149 149 * You need to provide valid bw_count function if you plan to use … … 168 168 return EOK; 169 169 } 170 /*----------------------------------------------------------------------------*/ 170 171 171 /** Check setup packet data for signs of toggle reset. 172 172 * … … 227 227 } 228 228 } 229 /*----------------------------------------------------------------------------*/ 229 230 230 /** Register endpoint structure. 231 231 * Checks for duplicates. … … 262 262 return EOK; 263 263 } 264 /*----------------------------------------------------------------------------*/ 264 265 265 /** Unregister endpoint structure. 266 266 * Checks for duplicates. … … 286 286 return EOK; 287 287 } 288 /*----------------------------------------------------------------------------*/ 288 289 289 /** Find endpoint_t representing the given communication route. 290 290 * @param instance usb_endpoint_manager, non-null. … … 301 301 return ep; 302 302 } 303 /*----------------------------------------------------------------------------*/ 303 304 304 /** Create and register new endpoint_t structure. 305 305 * @param instance usb_endpoint_manager structure, non-null. … … 364 364 return EOK; 365 365 } 366 /*----------------------------------------------------------------------------*/ 366 367 367 /** Unregister and destroy endpoint_t structure representing given route. 368 368 * @param instance usb_endpoint_manager structure, non-null. … … 395 395 return EOK; 396 396 } 397 /*----------------------------------------------------------------------------*/ 397 398 398 /** Unregister and destroy all endpoints using given address. 399 399 * @param instance usb_endpoint_manager structure, non-null. -
uspace/lib/usbhost/src/usb_transfer_batch.c
r4cdac68 rb828907 96 96 return instance; 97 97 } 98 /*----------------------------------------------------------------------------*/ 98 99 99 /** Correctly dispose all used data structures. 100 100 * … … 116 116 free(instance); 117 117 } 118 /*----------------------------------------------------------------------------*/ 118 119 119 /** Prepare data and call the right callback. 120 120 *
Note:
See TracChangeset
for help on using the changeset viewer.
