Changeset f97717d9 in mainline for uspace/drv/uhci-hcd/iface.c
- Timestamp:
- 2011-03-25T16:22:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- da3dafc, e6223239
- Parents:
- d8421c4 (diff), f08c560 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/iface.c
rd8421c4 rf97717d9 33 33 */ 34 34 #include <ddf/driver.h> 35 #include < remote_usbhc.h>35 #include <errno.h> 36 36 37 37 #include <usb/debug.h> 38 38 39 #include <errno.h>40 41 39 #include "iface.h" 42 #include " uhci_hc.h"40 #include "hc.h" 43 41 44 42 /** Reserve default address interface function … … 48 46 * @return Error code. 49 47 */ 50 /*----------------------------------------------------------------------------*/51 48 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 52 49 { 53 50 assert(fun); 54 uhci_hc_t *hc = fun_to_uhci_hc(fun);51 hc_t *hc = fun_to_hc(fun); 55 52 assert(hc); 56 53 usb_log_debug("Default address request with speed %d.\n", speed); 57 usb_device_keeper_reserve_default_address(&hc-> device_manager, speed);54 usb_device_keeper_reserve_default_address(&hc->manager, speed); 58 55 return EOK; 59 56 } … … 67 64 { 68 65 assert(fun); 69 uhci_hc_t *hc = fun_to_uhci_hc(fun);66 hc_t *hc = fun_to_hc(fun); 70 67 assert(hc); 71 68 usb_log_debug("Default address release.\n"); 72 usb_device_keeper_release_default_address(&hc-> device_manager);69 usb_device_keeper_release_default_address(&hc->manager); 73 70 return EOK; 74 71 } … … 81 78 * @return Error code. 82 79 */ 83 static int request_address( ddf_fun_t *fun, usb_speed_t speed,84 usb_address_t *address)85 { 86 assert(fun); 87 uhci_hc_t *hc = fun_to_uhci_hc(fun);80 static int request_address( 81 ddf_fun_t *fun, usb_speed_t speed, usb_address_t *address) 82 { 83 assert(fun); 84 hc_t *hc = fun_to_hc(fun); 88 85 assert(hc); 89 86 assert(address); 90 87 91 88 usb_log_debug("Address request with speed %d.\n", speed); 92 *address = device_keeper_get_free_address(&hc-> device_manager, speed);89 *address = device_keeper_get_free_address(&hc->manager, speed); 93 90 usb_log_debug("Address request with result: %d.\n", *address); 94 91 if (*address <= 0) 95 92 return *address; 96 93 return EOK; 97 94 } … … 108 105 { 109 106 assert(fun); 110 uhci_hc_t *hc = fun_to_uhci_hc(fun);107 hc_t *hc = fun_to_hc(fun); 111 108 assert(hc); 112 109 usb_log_debug("Address bind %d-%d.\n", address, handle); 113 usb_device_keeper_bind(&hc-> device_manager, address, handle);110 usb_device_keeper_bind(&hc->manager, address, handle); 114 111 return EOK; 115 112 } … … 124 121 { 125 122 assert(fun); 126 uhci_hc_t *hc = fun_to_uhci_hc(fun);123 hc_t *hc = fun_to_hc(fun); 127 124 assert(hc); 128 125 usb_log_debug("Address release %d.\n", address); 129 usb_device_keeper_release(&hc-> device_manager, address);126 usb_device_keeper_release(&hc->manager, address); 130 127 return EOK; 131 128 } … … 142 139 * @return Error code. 143 140 */ 144 static int interrupt_out(ddf_fun_t *fun, usb_target_t target, 145 size_t max_packet_size, void *data, size_t size, 146 usbhc_iface_transfer_out_callback_t callback, void *arg) 147 { 148 assert(fun); 149 uhci_hc_t *hc = fun_to_uhci_hc(fun); 150 assert(hc); 151 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 141 static int interrupt_out( 142 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 143 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 144 { 145 assert(fun); 146 hc_t *hc = fun_to_hc(fun); 147 assert(hc); 148 usb_speed_t speed = 149 usb_device_keeper_get_speed(&hc->manager, target.address); 152 150 153 151 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 154 152 target.address, target.endpoint, size, max_packet_size); 155 153 156 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,157 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,158 &hc->device_manager);154 usb_transfer_batch_t *batch = 155 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 156 speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager); 159 157 if (!batch) 160 158 return ENOMEM; 161 159 batch_interrupt_out(batch); 162 const int ret = uhci_hc_schedule(hc, batch); 163 if (ret != EOK) { 164 batch_dispose(batch); 165 return ret; 166 } 167 return EOK; 160 const int ret = hc_schedule(hc, batch); 161 if (ret != EOK) { 162 batch_dispose(batch); 163 } 164 return ret; 168 165 } 169 166 /*----------------------------------------------------------------------------*/ … … 179 176 * @return Error code. 180 177 */ 181 static int interrupt_in(ddf_fun_t *fun, usb_target_t target, 182 size_t max_packet_size, void *data, size_t size, 183 usbhc_iface_transfer_in_callback_t callback, void *arg) 184 { 185 assert(fun); 186 uhci_hc_t *hc = fun_to_uhci_hc(fun); 187 assert(hc); 188 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 178 static int interrupt_in( 179 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 180 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 181 { 182 assert(fun); 183 hc_t *hc = fun_to_hc(fun); 184 assert(hc); 185 usb_speed_t speed = 186 usb_device_keeper_get_speed(&hc->manager, target.address); 189 187 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 190 188 target.address, target.endpoint, size, max_packet_size); 191 189 192 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,193 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,194 &hc->device_manager);190 usb_transfer_batch_t *batch = 191 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 192 speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager); 195 193 if (!batch) 196 194 return ENOMEM; 197 195 batch_interrupt_in(batch); 198 const int ret = uhci_hc_schedule(hc, batch); 199 if (ret != EOK) { 200 batch_dispose(batch); 201 return ret; 202 } 203 return EOK; 196 const int ret = hc_schedule(hc, batch); 197 if (ret != EOK) { 198 batch_dispose(batch); 199 } 200 return ret; 204 201 } 205 202 /*----------------------------------------------------------------------------*/ … … 215 212 * @return Error code. 216 213 */ 217 static int bulk_out(ddf_fun_t *fun, usb_target_t target, 218 size_t max_packet_size, void *data, size_t size, 219 usbhc_iface_transfer_out_callback_t callback, void *arg) 220 { 221 assert(fun); 222 uhci_hc_t *hc = fun_to_uhci_hc(fun); 223 assert(hc); 224 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 214 static int bulk_out( 215 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 216 size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg) 217 { 218 assert(fun); 219 hc_t *hc = fun_to_hc(fun); 220 assert(hc); 221 usb_speed_t speed = 222 usb_device_keeper_get_speed(&hc->manager, target.address); 225 223 226 224 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 227 225 target.address, target.endpoint, size, max_packet_size); 228 226 229 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,230 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,231 &hc->device_manager);227 usb_transfer_batch_t *batch = 228 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 229 data, size, NULL, 0, NULL, callback, arg, &hc->manager); 232 230 if (!batch) 233 231 return ENOMEM; 234 232 batch_bulk_out(batch); 235 const int ret = uhci_hc_schedule(hc, batch); 236 if (ret != EOK) { 237 batch_dispose(batch); 238 return ret; 239 } 240 return EOK; 233 const int ret = hc_schedule(hc, batch); 234 if (ret != EOK) { 235 batch_dispose(batch); 236 } 237 return ret; 241 238 } 242 239 /*----------------------------------------------------------------------------*/ … … 252 249 * @return Error code. 253 250 */ 254 static int bulk_in(ddf_fun_t *fun, usb_target_t target, 255 size_t max_packet_size, void *data, size_t size, 256 usbhc_iface_transfer_in_callback_t callback, void *arg) 257 { 258 assert(fun); 259 uhci_hc_t *hc = fun_to_uhci_hc(fun); 260 assert(hc); 261 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 251 static int bulk_in( 252 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, void *data, 253 size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg) 254 { 255 assert(fun); 256 hc_t *hc = fun_to_hc(fun); 257 assert(hc); 258 usb_speed_t speed = 259 usb_device_keeper_get_speed(&hc->manager, target.address); 262 260 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 263 261 target.address, target.endpoint, size, max_packet_size); 264 262 265 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,266 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,267 &hc->device_manager);263 usb_transfer_batch_t *batch = 264 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 265 data, size, NULL, 0, callback, NULL, arg, &hc->manager); 268 266 if (!batch) 269 267 return ENOMEM; 270 268 batch_bulk_in(batch); 271 const int ret = uhci_hc_schedule(hc, batch); 272 if (ret != EOK) { 273 batch_dispose(batch); 274 return ret; 275 } 276 return EOK; 269 const int ret = hc_schedule(hc, batch); 270 if (ret != EOK) { 271 batch_dispose(batch); 272 } 273 return ret; 277 274 } 278 275 /*----------------------------------------------------------------------------*/ … … 282 279 * @param[in] target USB device to write to. 283 280 * @param[in] max_packet_size maximum size of data packet the device accepts. 284 * @param[in] setup_data Data to send with SETUP packet.285 * @param[in] setup_size Size of data to send with SETUP packet (should be8B).281 * @param[in] setup_data Data to send with SETUP transfer. 282 * @param[in] setup_size Size of data to send with SETUP transfer (always 8B). 286 283 * @param[in] data Source of data. 287 284 * @param[in] size Size of data source. … … 290 287 * @return Error code. 291 288 */ 292 static int control_write( ddf_fun_t *fun, usb_target_t target,293 size_t max_packet_size,289 static int control_write( 290 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 294 291 void *setup_data, size_t setup_size, void *data, size_t size, 295 292 usbhc_iface_transfer_out_callback_t callback, void *arg) 296 293 { 297 294 assert(fun); 298 uhci_hc_t *hc = fun_to_uhci_hc(fun); 299 assert(hc); 300 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 295 hc_t *hc = fun_to_hc(fun); 296 assert(hc); 297 usb_speed_t speed = 298 usb_device_keeper_get_speed(&hc->manager, target.address); 301 299 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 302 300 speed, target.address, target.endpoint, size, max_packet_size); … … 305 303 return EINVAL; 306 304 307 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 308 max_packet_size, speed, data, size, setup_data, setup_size, 309 NULL, callback, arg, &hc->device_manager); 310 if (!batch) 311 return ENOMEM; 312 usb_device_keeper_reset_if_need(&hc->device_manager, target, setup_data); 305 usb_transfer_batch_t *batch = 306 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 307 data, size, setup_data, setup_size, NULL, callback, arg, 308 &hc->manager); 309 if (!batch) 310 return ENOMEM; 311 usb_device_keeper_reset_if_need(&hc->manager, target, setup_data); 313 312 batch_control_write(batch); 314 const int ret = uhci_hc_schedule(hc, batch); 315 if (ret != EOK) { 316 batch_dispose(batch); 317 return ret; 318 } 319 return EOK; 313 const int ret = hc_schedule(hc, batch); 314 if (ret != EOK) { 315 batch_dispose(batch); 316 } 317 return ret; 320 318 } 321 319 /*----------------------------------------------------------------------------*/ … … 333 331 * @return Error code. 334 332 */ 335 static int control_read( ddf_fun_t *fun, usb_target_t target,336 size_t max_packet_size,333 static int control_read( 334 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 337 335 void *setup_data, size_t setup_size, void *data, size_t size, 338 336 usbhc_iface_transfer_in_callback_t callback, void *arg) 339 337 { 340 338 assert(fun); 341 uhci_hc_t *hc = fun_to_uhci_hc(fun); 342 assert(hc); 343 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); 339 hc_t *hc = fun_to_hc(fun); 340 assert(hc); 341 usb_speed_t speed = 342 usb_device_keeper_get_speed(&hc->manager, target.address); 344 343 345 344 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 346 345 speed, target.address, target.endpoint, size, max_packet_size); 347 usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 348 max_packet_size, speed, data, size, setup_data, setup_size, callback, 349 NULL, arg, &hc->device_manager); 346 usb_transfer_batch_t *batch = 347 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 348 data, size, setup_data, setup_size, callback, NULL, arg, 349 &hc->manager); 350 350 if (!batch) 351 351 return ENOMEM; 352 352 batch_control_read(batch); 353 const int ret = uhci_hc_schedule(hc, batch); 354 if (ret != EOK) { 355 batch_dispose(batch); 356 return ret; 357 } 358 return EOK; 359 } 360 /*----------------------------------------------------------------------------*/ 361 usbhc_iface_t uhci_hc_iface = { 353 const int ret = hc_schedule(hc, batch); 354 if (ret != EOK) { 355 batch_dispose(batch); 356 } 357 return ret; 358 } 359 /*----------------------------------------------------------------------------*/ 360 usbhc_iface_t hc_iface = { 362 361 .reserve_default_address = reserve_default_address, 363 362 .release_default_address = release_default_address, … … 369 368 .interrupt_in = interrupt_in, 370 369 370 .bulk_out = bulk_out, 371 371 .bulk_in = bulk_in, 372 .bulk_out = bulk_out, 373 372 373 .control_write = control_write, 374 374 .control_read = control_read, 375 .control_write = control_write,376 375 }; 377 376 /**
Note:
See TracChangeset
for help on using the changeset viewer.