Changes in / [fa2f79d:47c573a] in mainline
- Location:
- uspace
- Files:
-
- 4 deleted
- 16 edited
-
drv/uhci-rhd/port.c (modified) (10 diffs)
-
drv/uhci-rhd/port.h (modified) (2 diffs)
-
drv/vhc/connhost.c (modified) (4 diffs)
-
drv/vhc/devices.c (modified) (4 diffs)
-
drv/vhc/devices.h (modified) (1 diff)
-
drv/vhc/hc.c (modified) (2 diffs)
-
drv/vhc/hc.h (modified) (1 diff)
-
lib/c/generic/str_error.c (modified) (2 diffs)
-
lib/c/include/errno.h (modified) (1 diff)
-
lib/drv/generic/remote_usbhc.c (modified) (3 diffs)
-
lib/drv/include/usbhc_iface.h (modified) (1 diff)
-
lib/usb/Makefile (modified) (2 diffs)
-
lib/usb/include/usb/hub.h (deleted)
-
lib/usb/include/usb/pipes.h (modified) (3 diffs)
-
lib/usb/include/usb/usb.h (modified) (1 diff)
-
lib/usb/include/usb/usbdevice.h (deleted)
-
lib/usb/src/hub.c (deleted)
-
lib/usb/src/pipes.c (modified) (1 diff)
-
lib/usb/src/usb.c (modified) (1 diff)
-
lib/usb/src/usbdevice.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-rhd/port.c
rfa2f79d r47c573a 36 36 37 37 #include <usb/usb.h> /* usb_address_t */ 38 #include <usb/usbdevice.h> 39 #include <usb/hub.h> 40 #include <usb/request.h> 38 #include <usb/usbdrv.h> /* usb_drv_* */ 41 39 #include <usb/debug.h> 42 40 #include <usb/recognise.h> … … 60 58 port->attached_device = 0; 61 59 port->rh = rh; 62 int rc = usb_hc_connection_initialize_from_device( 63 &port->hc_connection, rh); 64 if (rc != EOK) { 65 usb_log_error("Failed to initialize connection to HC."); 66 return rc; 67 } 60 port->hc_phone = parent_phone; 68 61 69 62 port->checker = fibril_create(uhci_port_check, port); … … 105 98 106 99 if (port_status & STATUS_CONNECTED_CHANGED) { 107 int rc = usb_hc_connection_open(108 &port_instance->hc_connection);109 if (rc != EOK) {110 usb_log_error("Failed to connect to HC.");111 goto next;112 }113 114 100 if (port_status & STATUS_CONNECTED) { 115 101 /* new device */ … … 118 104 uhci_port_remove_device(port_instance); 119 105 } 120 121 rc = usb_hc_connection_close(122 &port_instance->hc_connection);123 if (rc != EOK) {124 usb_log_error("Failed to disconnect from HC.");125 goto next;126 }127 106 } 128 next:129 107 async_usleep(port_instance->wait_period_usec); 130 108 } … … 135 113 { 136 114 assert(port); 137 assert( usb_hc_connection_is_opened(&port->hc_connection));115 assert(port->hc_phone); 138 116 139 117 usb_log_info("Adding new device on port %d.\n", port->number); 140 118 141 119 /* get address of the future device */ 142 const usb_address_t usb_address = usb_ hc_request_address(&port->hc_connection);120 const usb_address_t usb_address = usb_drv_request_address(port->hc_phone); 143 121 144 122 if (usb_address <= 0) { … … 150 128 151 129 /* get default address */ 152 int ret = usb_ hc_reserve_default_address(&port->hc_connection);130 int ret = usb_drv_reserve_default_address(port->hc_phone); 153 131 if (ret != EOK) { 154 132 usb_log_error("Failed to reserve default address on port %d.\n", 155 133 port->number); 156 int ret2 = usb_hc_unregister_device(&port->hc_connection,157 usb_address);134 int ret2 = 135 usb_drv_release_address(port->hc_phone, usb_address); 158 136 if (ret2 != EOK) { 159 137 usb_log_fatal("Failed to return requested address on port %d.\n", … … 196 174 } 197 175 198 /* 199 * Initialize connection to the device. 200 */ 201 /* FIXME: check for errors. */ 202 usb_device_connection_t new_dev_connection; 203 usb_endpoint_pipe_t new_dev_ctrl_pipe; 204 usb_device_connection_initialize_on_default_address( 205 &new_dev_connection, &port->hc_connection); 206 usb_endpoint_pipe_initialize_default_control(&new_dev_ctrl_pipe, 207 &new_dev_connection); 208 209 /* 210 * Assign new address to the device. This function updates 211 * the backing connection to still point to the same device. 212 */ 213 /* FIXME: check for errors. */ 214 usb_endpoint_pipe_start_session(&new_dev_ctrl_pipe); 215 ret = usb_request_set_address(&new_dev_ctrl_pipe, usb_address); 216 usb_endpoint_pipe_end_session(&new_dev_ctrl_pipe); 176 /* assign address to device */ 177 ret = usb_drv_req_set_address(port->hc_phone, 0, usb_address); 217 178 218 179 if (ret != EOK) { /* address assigning went wrong */ 219 180 usb_log_error("Failed(%d) to assign address to the device.\n", ret); 220 181 uhci_port_set_enabled(port, false); 221 int release = usb_ hc_release_default_address(&port->hc_connection);182 int release = usb_drv_release_default_address(port->hc_phone); 222 183 if (release != EOK) { 223 184 usb_log_error("Failed to release default address on port %d.\n", … … 233 194 234 195 /* release default address */ 235 ret = usb_ hc_release_default_address(&port->hc_connection);196 ret = usb_drv_release_default_address(port->hc_phone); 236 197 if (ret != EOK) { 237 198 usb_log_error("Failed to release default address on port %d.\n", … … 245 206 assert(port->attached_device == 0); 246 207 247 ret = usb_device_register_child_in_devman(new_dev_connection.address, 248 new_dev_connection.hc_handle, port->rh, &port->attached_device); 249 208 devman_handle_t hc_handle; 209 ret = usb_drv_find_hc(port->rh, &hc_handle); 210 if (ret != EOK) { 211 usb_log_error("Failed to get handle of host controller: %s.\n", 212 str_error(ret)); 213 uhci_port_set_enabled(port, false); 214 return ENOMEM; 215 } 216 217 ret = usb_device_register_child_in_devman(usb_address, hc_handle, 218 port->rh, &port->attached_device); 250 219 if (ret != EOK) { /* something went wrong */ 251 220 usb_log_error("Failed(%d) in usb_drv_register_child.\n", ret); … … 256 225 port->number, usb_address, port->attached_device); 257 226 258 /* 259 * Register the device in the host controller. 260 */ 261 usb_hc_attached_device_t new_device = { 262 .address = new_dev_connection.address, 263 .handle = port->attached_device 264 }; 265 266 ret = usb_hc_register_device(&port->hc_connection, &new_device); 227 ret = 228 usb_drv_bind_address(port->hc_phone, usb_address, port->attached_device); 267 229 // TODO: proper error check here 268 230 assert(ret == EOK); -
uspace/drv/uhci-rhd/port.h
rfa2f79d r47c573a 38 38 #include <driver.h> /* device_t */ 39 39 #include <stdint.h> 40 #include <usb/usbdevice.h>41 40 42 41 #include "port_status.h" … … 47 46 unsigned number; 48 47 unsigned wait_period_usec; 49 usb_hc_connection_t hc_connection;48 int hc_phone; 50 49 device_t *rh; 51 50 devman_handle_t attached_device; -
uspace/drv/vhc/connhost.c
rfa2f79d r47c573a 64 64 65 65 static void universal_callback(void *buffer, size_t size, 66 int outcome, void *arg)66 usb_transaction_outcome_t outcome, void *arg) 67 67 { 68 68 transfer_info_t *transfer = (transfer_info_t *) arg; … … 107 107 108 108 static void control_abort_prematurely(control_transfer_info_t *transfer, 109 size_t size, int outcome)109 size_t size, usb_transaction_outcome_t outcome) 110 110 { 111 111 switch (transfer->direction) { … … 127 127 128 128 static void control_callback_two(void *buffer, size_t size, 129 int outcome, void *arg)129 usb_transaction_outcome_t outcome, void *arg) 130 130 { 131 131 control_transfer_info_t *ctrl_transfer = (control_transfer_info_t *) arg; 132 132 133 if (outcome != EOK) {133 if (outcome != USB_OUTCOME_OK) { 134 134 control_abort_prematurely(ctrl_transfer, outcome, size); 135 135 free(ctrl_transfer); … … 165 165 166 166 static void control_callback_one(void *buffer, size_t size, 167 int outcome, void *arg)167 usb_transaction_outcome_t outcome, void *arg) 168 168 { 169 169 control_transfer_info_t *transfer = (control_transfer_info_t *) arg; 170 170 171 if (outcome != EOK) {171 if (outcome != USB_OUTCOME_OK) { 172 172 control_abort_prematurely(transfer, outcome, size); 173 173 free(transfer); -
uspace/drv/vhc/devices.c
rfa2f79d r47c573a 112 112 * @param transaction Transaction to be sent over the bus. 113 113 */ 114 int virtdev_send_to_all(transaction_t *transaction)114 usb_transaction_outcome_t virtdev_send_to_all(transaction_t *transaction) 115 115 { 116 116 /* For easier debugging. */ … … 126 126 assert(false && "unreachable branch in switch()"); 127 127 } 128 int outcome = EBADCHECKSUM;128 usb_transaction_outcome_t outcome = USB_OUTCOME_BABBLE; 129 129 130 130 link_t *pos; … … 185 185 */ 186 186 if (rc == EOK) { 187 outcome = EOK;187 outcome = USB_OUTCOME_OK; 188 188 } 189 189 } … … 221 221 break; 222 222 } 223 outcome = EOK;223 outcome = USB_OUTCOME_OK; 224 224 } 225 225 -
uspace/drv/vhc/devices.h
rfa2f79d r47c573a 54 54 virtdev_connection_t *virtdev_find(sysarg_t); 55 55 void virtdev_destroy_device(virtdev_connection_t *); 56 int virtdev_send_to_all(transaction_t *);56 usb_transaction_outcome_t virtdev_send_to_all(transaction_t *); 57 57 58 58 #endif -
uspace/drv/vhc/hc.c
rfa2f79d r47c573a 89 89 */ 90 90 static void process_transaction_with_outcome(transaction_t * transaction, 91 int outcome)91 usb_transaction_outcome_t outcome) 92 92 { 93 93 usb_log_debug2("Transaction " TRANSACTION_FORMAT " done: %s.\n", 94 94 TRANSACTION_PRINTF(*transaction), 95 str_error(outcome));95 usb_str_transaction_outcome(outcome)); 96 96 97 97 transaction->callback(transaction->buffer, transaction->actual_len, … … 127 127 TRANSACTION_PRINTF(*transaction), ports); 128 128 129 int outcome;129 usb_transaction_outcome_t outcome; 130 130 outcome = virtdev_send_to_all(transaction); 131 131 -
uspace/drv/vhc/hc.h
rfa2f79d r47c573a 47 47 */ 48 48 typedef void (*hc_transaction_done_callback_t)(void *buffer, size_t size, 49 int outcome, void *arg);49 usb_transaction_outcome_t outcome, void *arg); 50 50 51 51 /** Pending transaction details. */ -
uspace/lib/c/generic/str_error.c
rfa2f79d r47c573a 33 33 */ 34 34 35 #include <errno.h>36 35 #include <str_error.h> 37 36 #include <stdio.h> … … 64 63 static fibril_local char noerr[NOERR_LEN]; 65 64 66 const char *str_error(const int e )65 const char *str_error(const int errno) 67 66 { 68 if ((e <= 0) && (e>= MIN_ERRNO))69 return err_desc[-e ];67 if ((errno <= 0) && (errno >= MIN_ERRNO)) 68 return err_desc[-errno]; 70 69 71 /* Ad hoc descriptions of error codes interesting for USB. */ 72 switch (e) { 73 case EBADCHECKSUM: 74 return "Bad checksum"; 75 case EAGAIN: 76 return "Resource temporarily unavailable"; 77 default: 78 break; 79 } 80 81 snprintf(noerr, NOERR_LEN, "Unkown error code %d", e); 70 snprintf(noerr, NOERR_LEN, "Unkown error code %d", errno); 82 71 return noerr; 83 72 } -
uspace/lib/c/include/errno.h
rfa2f79d r47c573a 56 56 #define EMLINK (-266) 57 57 58 /** Bad checksum. */59 #define EBADCHECKSUM (-300)60 61 58 /** An API function is called while another blocking function is in progress. */ 62 59 #define EINPROGRESS (-10036) -
uspace/lib/drv/generic/remote_usbhc.c
rfa2f79d r47c573a 240 240 241 241 static void callback_out(device_t *device, 242 int outcome, void *arg)242 usb_transaction_outcome_t outcome, void *arg) 243 243 { 244 244 async_transaction_t *trans = (async_transaction_t *)arg; … … 250 250 251 251 static void callback_in(device_t *device, 252 int outcome, size_t actual_size, void *arg)252 usb_transaction_outcome_t outcome, size_t actual_size, void *arg) 253 253 { 254 254 async_transaction_t *trans = (async_transaction_t *)arg; 255 255 256 if (outcome != EOK) {256 if (outcome != USB_OUTCOME_OK) { 257 257 async_answer_0(trans->caller, outcome); 258 258 if (trans->data_caller) { … … 270 270 } 271 271 272 async_answer_0(trans->caller, EOK);272 async_answer_0(trans->caller, USB_OUTCOME_OK); 273 273 274 274 async_transaction_destroy(trans); -
uspace/lib/drv/include/usbhc_iface.h
rfa2f79d r47c573a 207 207 /** Callback for outgoing transfer. */ 208 208 typedef void (*usbhc_iface_transfer_out_callback_t)(device_t *, 209 int, void *);209 usb_transaction_outcome_t, void *); 210 210 211 211 /** Callback for incoming transfer. */ 212 212 typedef void (*usbhc_iface_transfer_in_callback_t)(device_t *, 213 int, size_t, void *);213 usb_transaction_outcome_t, size_t, void *); 214 214 215 215 -
uspace/lib/usb/Makefile
rfa2f79d r47c573a 40 40 src/dump.c \ 41 41 src/hidparser.c \ 42 src/hub.c \43 42 src/pipes.c \ 44 43 src/pipesinit.c \ … … 47 46 src/request.c \ 48 47 src/usb.c \ 49 src/usbdevice.c \50 48 src/usbdrvreq.c \ 51 49 src/usbdrv.c \ -
uspace/lib/usb/include/usb/pipes.h
rfa2f79d r47c573a 31 31 */ 32 32 /** @file 33 * USB pipes representation.33 * Communication between device drivers and host controller driver. 34 34 */ 35 35 #ifndef LIBUSB_PIPES_H_ … … 38 38 #include <sys/types.h> 39 39 #include <usb/usb.h> 40 #include <usb/usbdevice.h>41 40 #include <usb/descriptor.h> 42 41 #include <ipc/devman.h> … … 115 114 } usb_endpoint_mapping_t; 116 115 117 int usb_device_connection_initialize_on_default_address(118 usb_device_connection_t *, usb_hc_connection_t *);119 116 int usb_device_connection_initialize_from_device(usb_device_connection_t *, 120 117 device_t *); -
uspace/lib/usb/include/usb/usb.h
rfa2f79d r47c573a 83 83 } usb_request_recipient_t; 84 84 85 /** USB transaction outcome. */ 86 typedef enum { 87 USB_OUTCOME_OK, 88 USB_OUTCOME_CRCERROR, 89 USB_OUTCOME_BABBLE 90 } usb_transaction_outcome_t; 91 92 const char * usb_str_transaction_outcome(usb_transaction_outcome_t o); 93 85 94 /** USB address type. 86 95 * Negative values could be used to indicate error. -
uspace/lib/usb/src/pipes.c
rfa2f79d r47c573a 102 102 } 103 103 104 /** Initialize connection to USB device on default address.105 *106 * @param dev_connection Device connection structure to be initialized.107 * @param hc_connection Initialized connection to host controller.108 * @return Error code.109 */110 int usb_device_connection_initialize_on_default_address(111 usb_device_connection_t *dev_connection,112 usb_hc_connection_t *hc_connection)113 {114 assert(dev_connection);115 116 if (hc_connection == NULL) {117 return EBADMEM;118 }119 120 return usb_device_connection_initialize(dev_connection,121 hc_connection->hc_handle, (usb_address_t) 0);122 }123 124 104 125 105 /** Start a session on the endpoint pipe. -
uspace/lib/usb/src/usb.c
rfa2f79d r47c573a 54 54 } 55 55 56 /** String representation of USB transaction outcome. */ 57 const char * usb_str_transaction_outcome(usb_transaction_outcome_t o) 58 { 59 switch (o) { 60 case USB_OUTCOME_OK: 61 return "ok"; 62 case USB_OUTCOME_CRCERROR: 63 return "CRC error"; 64 case USB_OUTCOME_BABBLE: 65 return "babble"; 66 default: 67 return "unknown"; 68 } 69 } 70 71 56 72 /** 57 73 * @}
Note:
See TracChangeset
for help on using the changeset viewer.
