Changeset 75732da in mainline for uspace/lib
- Timestamp:
- 2010-12-13T07:20:20Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 309dea52
- Parents:
- 84439d7 (diff), 37f7cfe (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:
-
- 10 added
- 22 edited
-
c/generic/adt/char_map.c (modified) (4 diffs)
-
c/generic/devman.c (modified) (1 diff)
-
c/include/adt/generic_field.h (modified) (2 diffs)
-
c/include/errno.h (modified) (1 diff)
-
c/include/ipc/dev_iface.h (modified) (1 diff)
-
c/include/ipc/vfs.h (modified) (2 diffs)
-
drv/generic/driver.c (modified) (1 diff)
-
drv/generic/remote_usbhc.c (modified) (8 diffs)
-
drv/include/driver.h (modified) (1 diff)
-
usb/Makefile (modified) (1 diff)
-
usb/include/usb/classes/classes.h (modified) (1 diff)
-
usb/include/usb/classes/hid.h (modified) (2 diffs)
-
usb/include/usb/classes/hidparser.h (added)
-
usb/include/usb/classes/hub.h (modified) (2 diffs)
-
usb/include/usb/debug.h (added)
-
usb/include/usb/devreq.h (modified) (2 diffs)
-
usb/include/usb/hcd.h (added)
-
usb/include/usb/hcdhubd.h (modified) (1 diff)
-
usb/include/usb/usb.h (modified) (1 diff)
-
usb/include/usb/usbdrv.h (modified) (4 diffs)
-
usb/src/addrkeep.c (added)
-
usb/src/class.c (added)
-
usb/src/debug.c (added)
-
usb/src/drvpsync.c (added)
-
usb/src/hidparser.c (added)
-
usb/src/recognise.c (added)
-
usb/src/remotedrv.c (modified) (1 diff)
-
usb/src/usbdrv.c (modified) (8 diffs)
-
usb/src/usbdrvreq.c (added)
-
usbvirt/src/callback.c (modified) (1 diff)
-
usbvirt/src/main.c (modified) (2 diffs)
-
usbvirt/src/transaction.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/char_map.c
r84439d7 r75732da 90 90 } 91 91 92 map->items[map->next]->c = * identifier;93 ++ identifier;94 ++ map->next;95 if ((length > 1) || ((length == 0) && (*identifier))) {92 map->items[map->next]->c = *identifier; 93 identifier++; 94 map->next++; 95 if ((length > 1) || ((length == 0) && *identifier)) { 96 96 map->items[map->next - 1]->value = CHAR_MAP_NULL; 97 97 return char_map_add_item(map->items[map->next - 1], identifier, … … 142 142 const int value) 143 143 { 144 if (char_map_is_valid(map) && (identifier) && 145 ((length) || (*identifier))) { 144 if (char_map_is_valid(map) && identifier && (length || *identifier)) { 146 145 int index; 147 146 148 for (index = 0; index < map->next; ++ index) {147 for (index = 0; index < map->next; index++) { 149 148 if (map->items[index]->c != *identifier) 150 149 continue; 151 150 152 ++ identifier;153 if((length > 1) || ((length == 0) && (*identifier))) {151 identifier++; 152 if((length > 1) || ((length == 0) && *identifier)) { 154 153 return char_map_add(map->items[index], 155 154 identifier, length ? length - 1 : 0, value); … … 178 177 179 178 map->magic = 0; 180 for (index = 0; index < map->next; ++index)179 for (index = 0; index < map->next; index++) 181 180 char_map_destroy(map->items[index]); 182 181 … … 207 206 return NULL; 208 207 209 if (length || (*identifier)) {208 if (length || *identifier) { 210 209 int index; 211 210 212 for (index = 0; index < map->next; ++index) {211 for (index = 0; index < map->next; index++) { 213 212 if (map->items[index]->c == *identifier) { 214 ++identifier;213 identifier++; 215 214 if (length == 1) 216 215 return map->items[index]; -
uspace/lib/c/generic/devman.c
r84439d7 r75732da 116 116 { 117 117 ipc_call_t answer; 118 a sync_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer);118 aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer); 119 119 int retval = async_data_write_start(phone, match_id->id, str_size(match_id->id)); 120 return retval; 120 async_wait_for(req, NULL); 121 return retval; 121 122 } 122 123 -
uspace/lib/c/include/adt/generic_field.h
r84439d7 r75732da 91 91 } \ 92 92 field->items[field->next] = value; \ 93 ++field->next; \93 field->next++; \ 94 94 field->items[field->next] = NULL; \ 95 95 return field->next - 1; \ … … 108 108 int index; \ 109 109 field->magic = 0; \ 110 for (index = 0; index < field->next; ++ index) { \110 for (index = 0; index < field->next; index++) { \ 111 111 if (field->items[index]) \ 112 112 free(field->items[index]); \ -
uspace/lib/c/include/errno.h
r84439d7 r75732da 83 83 #define ENOTCONN (-10057) 84 84 85 /** The requested operation was not performed. 86 * Try again later. 87 */ 88 #define TRY_AGAIN (-11002) 85 /** The requested operation was not performed. Try again later. */ 86 #define EAGAIN (-11002) 89 87 90 88 /** No data. -
uspace/lib/c/include/ipc/dev_iface.h
r84439d7 r75732da 54 54 DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX) 55 55 56 /* 57 * The first argument is actually method (as the "real" method is used 58 * for indexing into interfaces. 59 */ 60 61 #define DEV_IPC_GET_ARG1(call) IPC_GET_ARG2((call)) 62 #define DEV_IPC_GET_ARG2(call) IPC_GET_ARG3((call)) 63 #define DEV_IPC_GET_ARG3(call) IPC_GET_ARG4((call)) 64 #define DEV_IPC_GET_ARG4(call) IPC_GET_ARG5((call)) 65 56 66 57 67 #endif -
uspace/lib/c/include/ipc/vfs.h
r84439d7 r75732da 36 36 #define LIBC_IPC_VFS_H_ 37 37 38 #include <ipc/ipc.h> 38 39 #include <sys/types.h> 39 #include < ipc/ipc.h>40 #include <bool.h> 40 41 41 42 #define FS_NAME_MAXLEN 20 … … 55 56 /** Unique identifier of the fs. */ 56 57 char name[FS_NAME_MAXLEN + 1]; 58 bool concurrent_read_write; 59 bool write_retains_size; 57 60 } vfs_info_t; 58 61 -
uspace/lib/drv/generic/driver.c
r84439d7 r75732da 381 381 } 382 382 383 /** Wrapper for child_device_register for devices with single match id. 384 * 385 * @param parent Parent device. 386 * @param child_name Child device name. 387 * @param child_match_id Child device match id. 388 * @param child_match_score Child device match score. 389 * @return Error code. 390 */ 391 int child_device_register_wrapper(device_t *parent, const char *child_name, 392 const char *child_match_id, int child_match_score, 393 devman_handle_t *child_handle) 394 { 395 device_t *child = NULL; 396 match_id_t *match_id = NULL; 397 int rc; 398 399 child = create_device(); 400 if (child == NULL) { 401 rc = ENOMEM; 402 goto failure; 403 } 404 405 child->name = child_name; 406 407 match_id = create_match_id(); 408 if (match_id == NULL) { 409 rc = ENOMEM; 410 goto failure; 411 } 412 413 match_id->id = child_match_id; 414 match_id->score = child_match_score; 415 add_match_id(&child->match_ids, match_id); 416 417 rc = child_device_register(child, parent); 418 if (EOK != rc) 419 goto failure; 420 421 if (child_handle != NULL) { 422 *child_handle = child->handle; 423 } 424 return EOK; 425 426 failure: 427 if (match_id != NULL) { 428 match_id->id = NULL; 429 delete_match_id(match_id); 430 } 431 432 if (child != NULL) { 433 child->name = NULL; 434 delete_device(child); 435 } 436 437 return rc; 438 } 439 383 440 int driver_main(driver_t *drv) 384 441 { -
uspace/lib/drv/generic/remote_usbhc.c
r84439d7 r75732da 108 108 } 109 109 110 devman_handle_t handle = IPC_GET_ARG1(*call);110 devman_handle_t handle = DEV_IPC_GET_ARG1(*call); 111 111 112 112 usb_address_t address; … … 122 122 ipc_callid_t callid, ipc_call_t *call) 123 123 { 124 ipcarg_t buffer_hash = IPC_GET_ARG1(*call);124 ipcarg_t buffer_hash = DEV_IPC_GET_ARG1(*call); 125 125 async_transaction_t * trans = (async_transaction_t *)buffer_hash; 126 126 if (trans == NULL) { … … 144 144 accepted_size = trans->size; 145 145 } 146 async_data_read_finalize(c allid, trans->buffer, accepted_size);146 async_data_read_finalize(cid, trans->buffer, accepted_size); 147 147 148 148 ipc_answer_1(callid, EOK, accepted_size); … … 211 211 } 212 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);213 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 214 devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call); 215 215 216 216 int rc = usb_iface->bind_address(device, address, handle); … … 229 229 } 230 230 231 usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call);231 usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call); 232 232 233 233 int rc = usb_iface->release_address(device, address); … … 275 275 } 276 276 277 size_t expected_len = IPC_GET_ARG3(*call);277 size_t expected_len = DEV_IPC_GET_ARG3(*call); 278 278 usb_target_t target = { 279 .address = IPC_GET_ARG1(*call),280 .endpoint = IPC_GET_ARG2(*call)279 .address = DEV_IPC_GET_ARG1(*call), 280 .endpoint = DEV_IPC_GET_ARG2(*call) 281 281 }; 282 282 … … 327 327 } 328 328 329 size_t len = IPC_GET_ARG3(*call);329 size_t len = DEV_IPC_GET_ARG3(*call); 330 330 usb_target_t target = { 331 .address = IPC_GET_ARG1(*call),332 .endpoint = IPC_GET_ARG2(*call)331 .address = DEV_IPC_GET_ARG1(*call), 332 .endpoint = DEV_IPC_GET_ARG2(*call) 333 333 }; 334 334 … … 384 384 385 385 usb_target_t target = { 386 .address = IPC_GET_ARG1(*call),387 .endpoint = IPC_GET_ARG2(*call)386 .address = DEV_IPC_GET_ARG1(*call), 387 .endpoint = DEV_IPC_GET_ARG2(*call) 388 388 }; 389 389 -
uspace/lib/drv/include/driver.h
r84439d7 r75732da 199 199 200 200 int child_device_register(device_t *, device_t *); 201 int child_device_register_wrapper(device_t *, const char *, const char *, int, 202 devman_handle_t *); 201 203 202 204 -
uspace/lib/usb/Makefile
r84439d7 r75732da 33 33 34 34 SOURCES = \ 35 src/addrkeep.c \ 36 src/class.c \ 37 src/debug.c \ 38 src/drvpsync.c \ 35 39 src/hcdhubd.c \ 36 40 src/hcdrv.c \ 41 src/hidparser.c \ 37 42 src/localdrv.c \ 43 src/recognise.c \ 38 44 src/remotedrv.c \ 39 45 src/usb.c \ 46 src/usbdrvreq.c \ 40 47 src/usbdrv.c 41 48 -
uspace/lib/usb/include/usb/classes/classes.h
r84439d7 r75732da 60 60 } usb_class_t; 61 61 62 const char *usb_str_class(usb_class_t); 62 63 63 64 #endif -
uspace/lib/usb/include/usb/classes/hid.h
r84439d7 r75732da 36 36 #define LIBUSB_HID_H_ 37 37 38 #include <usb/usb.h> 39 #include <driver.h> 40 #include <usb/classes/hidparser.h> 41 38 42 /** USB/HID device requests. */ 39 43 typedef enum { … … 54 58 } usb_hid_protocol_t; 55 59 60 /** Part of standard USB HID descriptor specifying one class descriptor. 61 * 62 * (See HID Specification, p.22) 63 */ 64 typedef struct { 65 /** Type of class descriptor (Report or Physical). */ 66 uint8_t class_descriptor_type; 67 /** Length of class descriptor. */ 68 uint16_t class_descriptor_length; 69 } __attribute__ ((packed)) usb_standard_hid_descriptor_class_item_t; 70 71 /** Standard USB HID descriptor. 72 * 73 * (See HID Specification, p.22) 74 * 75 * It is actually only the "header" of the descriptor, as it may have arbitrary 76 * length if more than one class descritor is provided. 77 */ 78 typedef struct { 79 /** Size of this descriptor in bytes. */ 80 uint8_t length; 81 /** Descriptor type (USB_DESCTYPE_HID). */ 82 uint8_t descriptor_type; 83 /** HID Class Specification release. */ 84 uint16_t spec_release; 85 /** Country code of localized hardware. */ 86 uint8_t country_code; 87 /** Total number of class (i.e. Report and Physical) descriptors. */ 88 uint8_t class_count; 89 /** First mandatory class descriptor info. */ 90 usb_standard_hid_descriptor_class_item_t class_descriptor; 91 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 92 93 94 /** 95 * @brief USB/HID keyboard device type. 96 * 97 * Quite dummy right now. 98 */ 99 typedef struct { 100 device_t *device; 101 usb_address_t address; 102 usb_endpoint_t poll_endpoint; 103 usb_hid_report_parser_t *parser; 104 } usb_hid_dev_kbd_t; 105 56 106 #endif 57 107 /** -
uspace/lib/usb/include/usb/classes/hub.h
r84439d7 r75732da 177 177 178 178 /** @brief hub class request codes*/ 179 /// \TODO these are duplicit to standart descriptors 179 180 typedef enum { 180 181 /** */ … … 213 214 usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor); 214 215 215 /**216 * @brief create hub structure instance217 *218 * @param device219 * @return220 */221 usb_hcd_hub_info_t * usb_create_hub_info(device_t * device);222 216 223 217 -
uspace/lib/usb/include/usb/devreq.h
r84439d7 r75732da 38 38 #include <ipc/ipc.h> 39 39 #include <async.h> 40 #include <usb/usb.h> 41 #include <usb/descriptor.h> 40 42 41 43 /** Standard device request. */ … … 83 85 } __attribute__ ((packed)) usb_device_request_setup_packet_t; 84 86 87 int usb_drv_req_set_address(int, usb_address_t, usb_address_t); 88 int usb_drv_req_get_device_descriptor(int, usb_address_t, 89 usb_standard_device_descriptor_t *); 90 int usb_drv_req_get_bare_configuration_descriptor(int, usb_address_t, int, 91 usb_standard_configuration_descriptor_t *); 92 int usb_drv_req_get_full_configuration_descriptor(int, usb_address_t, int, 93 void *, size_t, size_t *); 94 95 85 96 #endif 86 97 /** -
uspace/lib/usb/include/usb/hcdhubd.h
r84439d7 r75732da 65 65 } usb_hcd_attached_device_info_t; 66 66 67 /** Information about attached hub. */68 typedef struct {69 /** Number of ports. */70 size_t port_count;71 /** General device info. */72 usb_hcd_attached_device_info_t *device;73 /** Link to other hubs. */74 link_t link;75 } usb_hcd_hub_info_t;76 67 77 68 /** Host controller device. */ -
uspace/lib/usb/include/usb/usb.h
r84439d7 r75732da 69 69 typedef int usb_address_t; 70 70 71 /** Default USB address. */ 72 #define USB_ADDRESS_DEFAULT 0 73 /** Maximum address number in USB 1.1. */ 74 #define USB11_ADDRESS_MAX 128 75 71 76 /** USB endpoint number type. 72 77 * Negative values could be used to indicate error. -
uspace/lib/usb/include/usb/usbdrv.h
r84439d7 r75732da 36 36 #define LIBUSB_USBDRV_H_ 37 37 38 #include "usb.h"38 #include <usb/usb.h> 39 39 #include <driver.h> 40 #include <usb/devreq.h> 41 #include <usb/descriptor.h> 40 42 41 43 int usb_drv_hc_connect(device_t *, unsigned int); … … 54 56 void *, size_t, size_t *, usb_handle_t *); 55 57 58 int usb_drv_psync_interrupt_out(int, usb_target_t, void *, size_t); 59 int usb_drv_psync_interrupt_in(int, usb_target_t, void *, size_t, size_t *); 60 61 62 56 63 int usb_drv_async_control_write_setup(int, usb_target_t, 57 64 void *, size_t, usb_handle_t *); … … 60 67 int usb_drv_async_control_write_status(int, usb_target_t, 61 68 usb_handle_t *); 69 70 int usb_drv_psync_control_write_setup(int, usb_target_t, void *, size_t); 71 int usb_drv_psync_control_write_data(int, usb_target_t, void *, size_t); 72 int usb_drv_psync_control_write_status(int, usb_target_t); 73 74 int usb_drv_psync_control_write(int, usb_target_t, 75 void *, size_t, void *, size_t); 76 62 77 63 78 int usb_drv_async_control_read_setup(int, usb_target_t, … … 68 83 usb_handle_t *); 69 84 85 int usb_drv_psync_control_read_setup(int, usb_target_t, void *, size_t); 86 int usb_drv_psync_control_read_data(int, usb_target_t, void *, size_t, size_t *); 87 int usb_drv_psync_control_read_status(int, usb_target_t); 88 89 int usb_drv_psync_control_read(int, usb_target_t, 90 void *, size_t, void *, size_t, size_t *); 91 92 93 70 94 int usb_drv_async_wait_for(usb_handle_t); 95 96 int usb_drv_create_device_match_ids(int, match_id_list_t *, usb_address_t); 97 int usb_drv_register_child_in_devman(int, device_t *, usb_address_t, 98 devman_handle_t *); 99 71 100 72 101 #endif -
uspace/lib/usb/src/remotedrv.c
r84439d7 r75732da 300 300 */ 301 301 static void remote_in_callback(usb_hc_device_t *hc, 302 usb_transaction_outcome_t outcome, size_t actual_size, void *arg)302 size_t actual_size, usb_transaction_outcome_t outcome, void *arg) 303 303 { 304 304 transfer_info_t *transfer = (transfer_info_t *) arg; -
uspace/lib/usb/src/usbdrv.c
r84439d7 r75732da 36 36 #include <usbhc_iface.h> 37 37 #include <errno.h> 38 #include <str_error.h> 38 39 39 40 /** Information about pending transaction on HC. */ … … 71 72 devman_handle_t handle; 72 73 73 rc = devman_device_get_handle("/v hc", &handle, 0);74 rc = devman_device_get_handle("/virt/usbhc", &handle, 0); 74 75 if (rc != EOK) { 75 76 return rc; … … 90 91 { 91 92 ipcarg_t address; 92 int rc = async_req_1_1(phone, IPC_M_USBHC_GET_ADDRESS, 93 int rc = async_req_2_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE), 94 IPC_M_USBHC_GET_ADDRESS, 93 95 dev->handle, &address); 94 96 95 97 if (rc != EOK) { 98 printf("usb_drv_get_my_address over %d failed: %s\n", phone, str_error(rc)); 96 99 return rc; 97 100 } … … 107 110 int usb_drv_reserve_default_address(int phone) 108 111 { 109 return async_req_0_0(phone, IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS); 112 return async_req_1_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE), 113 IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS); 110 114 } 111 115 … … 117 121 int usb_drv_release_default_address(int phone) 118 122 { 119 return async_req_0_0(phone, IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS); 123 return async_req_1_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE), 124 IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS); 120 125 } 121 126 … … 128 133 { 129 134 ipcarg_t address; 130 int rc = async_req_0_1(phone, IPC_M_USBHC_REQUEST_ADDRESS, &address); 135 int rc = async_req_1_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE), 136 IPC_M_USBHC_REQUEST_ADDRESS, &address); 131 137 if (rc != EOK) { 132 138 return rc; … … 146 152 devman_handle_t handle) 147 153 { 148 int rc = async_req_2_0(phone, IPC_M_USBHC_BIND_ADDRESS, 154 int rc = async_req_3_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE), 155 IPC_M_USBHC_BIND_ADDRESS, 149 156 address, handle); 150 157 … … 160 167 int usb_drv_release_address(int phone, usb_address_t address) 161 168 { 162 return async_req_1_0(phone, IPC_M_USBHC_RELEASE_ADDRESS, address); 169 return async_req_2_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE), 170 IPC_M_USBHC_RELEASE_ADDRESS, address); 163 171 } 164 172 -
uspace/lib/usbvirt/src/callback.c
r84439d7 r75732da 153 153 * If the request was processed, we will send data back. 154 154 */ 155 if ( rc == EOK) {155 if ((rc == EOK) && (expected_len > 0)) { 156 156 size_t receive_len; 157 157 ipc_callid_t callid; -
uspace/lib/usbvirt/src/main.c
r84439d7 r75732da 183 183 /** Create necessary phones for communication with virtual HCD. 184 184 * This function wraps following calls: 185 * -# open <code>/dev/devices/\\v hc</code>for reading185 * -# open <code>/dev/devices/\\virt\\usbhc for reading 186 186 * -# access phone of file opened in previous step 187 187 * -# create callback through just opened phone … … 203 203 } 204 204 205 const char *vhc_path = "/v hc";205 const char *vhc_path = "/virt/usbhc"; 206 206 int rc; 207 207 devman_handle_t handle; -
uspace/lib/usbvirt/src/transaction.c
r84439d7 r75732da 183 183 actual_size = size; 184 184 } 185 device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION, 186 "in transaction: will copy %zu bytes", actual_size); 185 187 if (actual_size > 0) { 186 188 memcpy(buffer, transfer->data, actual_size);
Note:
See TracChangeset
for help on using the changeset viewer.
