Changeset 62f4212 in mainline for uspace/drv/uhci-hcd/iface.c
- Timestamp:
- 2011-03-22T10:07:53Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f8e4cb6
- Parents:
- 18b3cfd (diff), b01995b (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
r18b3cfd r62f4212 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" 43 #include "utils/device_keeper.h" 40 #include "hc.h" 44 41 45 42 /** Reserve default address interface function … … 49 46 * @return Error code. 50 47 */ 51 /*----------------------------------------------------------------------------*/52 48 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 53 49 { 54 50 assert(fun); 55 uhci_hc_t *hc = fun_to_uhci_hc(fun);51 hc_t *hc = fun_to_hc(fun); 56 52 assert(hc); 57 53 usb_log_debug("Default address request with speed %d.\n", speed); 58 device_keeper_reserve_default(&hc->device_manager, speed);54 usb_device_keeper_reserve_default_address(&hc->manager, speed); 59 55 return EOK; 60 56 } … … 68 64 { 69 65 assert(fun); 70 uhci_hc_t *hc = fun_to_uhci_hc(fun);66 hc_t *hc = fun_to_hc(fun); 71 67 assert(hc); 72 68 usb_log_debug("Default address release.\n"); 73 device_keeper_release_default(&hc->device_manager);69 usb_device_keeper_release_default_address(&hc->manager); 74 70 return EOK; 75 71 } … … 82 78 * @return Error code. 83 79 */ 84 static int request_address( ddf_fun_t *fun, usb_speed_t speed,85 usb_address_t *address)86 { 87 assert(fun); 88 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); 89 85 assert(hc); 90 86 assert(address); 91 87 92 88 usb_log_debug("Address request with speed %d.\n", speed); 93 *address = device_keeper_ request(&hc->device_manager, speed);89 *address = device_keeper_get_free_address(&hc->manager, speed); 94 90 usb_log_debug("Address request with result: %d.\n", *address); 95 91 if (*address <= 0) 96 92 return *address; 97 93 return EOK; 98 94 } … … 109 105 { 110 106 assert(fun); 111 uhci_hc_t *hc = fun_to_uhci_hc(fun);107 hc_t *hc = fun_to_hc(fun); 112 108 assert(hc); 113 109 usb_log_debug("Address bind %d-%d.\n", address, handle); 114 device_keeper_bind(&hc->device_manager, address, handle);110 usb_device_keeper_bind(&hc->manager, address, handle); 115 111 return EOK; 116 112 } … … 125 121 { 126 122 assert(fun); 127 uhci_hc_t *hc = fun_to_uhci_hc(fun);123 hc_t *hc = fun_to_hc(fun); 128 124 assert(hc); 129 125 usb_log_debug("Address release %d.\n", address); 130 device_keeper_release(&hc->device_manager, address);126 usb_device_keeper_release(&hc->manager, address); 131 127 return EOK; 132 128 } … … 143 139 * @return Error code. 144 140 */ 145 static int interrupt_out(ddf_fun_t *fun, usb_target_t target, 146 size_t max_packet_size, void *data, size_t size, 147 usbhc_iface_transfer_out_callback_t callback, void *arg) 148 { 149 assert(fun); 150 uhci_hc_t *hc = fun_to_uhci_hc(fun); 151 assert(hc); 152 usb_speed_t speed = device_keeper_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); 153 150 154 151 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 155 152 target.address, target.endpoint, size, max_packet_size); 156 153 157 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,158 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,159 &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); 160 157 if (!batch) 161 158 return ENOMEM; 162 159 batch_interrupt_out(batch); 163 const int ret = uhci_hc_schedule(hc, batch); 164 if (ret != EOK) { 165 batch_dispose(batch); 166 return ret; 167 } 168 return EOK; 160 const int ret = hc_schedule(hc, batch); 161 if (ret != EOK) { 162 batch_dispose(batch); 163 } 164 return ret; 169 165 } 170 166 /*----------------------------------------------------------------------------*/ … … 180 176 * @return Error code. 181 177 */ 182 static int interrupt_in(ddf_fun_t *fun, usb_target_t target, 183 size_t max_packet_size, void *data, size_t size, 184 usbhc_iface_transfer_in_callback_t callback, void *arg) 185 { 186 assert(fun); 187 uhci_hc_t *hc = fun_to_uhci_hc(fun); 188 assert(hc); 189 usb_speed_t speed = device_keeper_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); 190 187 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 191 188 target.address, target.endpoint, size, max_packet_size); 192 189 193 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,194 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,195 &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); 196 193 if (!batch) 197 194 return ENOMEM; 198 195 batch_interrupt_in(batch); 199 const int ret = uhci_hc_schedule(hc, batch); 200 if (ret != EOK) { 201 batch_dispose(batch); 202 return ret; 203 } 204 return EOK; 196 const int ret = hc_schedule(hc, batch); 197 if (ret != EOK) { 198 batch_dispose(batch); 199 } 200 return ret; 205 201 } 206 202 /*----------------------------------------------------------------------------*/ … … 216 212 * @return Error code. 217 213 */ 218 static int bulk_out(ddf_fun_t *fun, usb_target_t target, 219 size_t max_packet_size, void *data, size_t size, 220 usbhc_iface_transfer_out_callback_t callback, void *arg) 221 { 222 assert(fun); 223 uhci_hc_t *hc = fun_to_uhci_hc(fun); 224 assert(hc); 225 usb_speed_t speed = device_keeper_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); 226 223 227 224 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 228 225 target.address, target.endpoint, size, max_packet_size); 229 226 230 batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,231 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,232 &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); 233 230 if (!batch) 234 231 return ENOMEM; 235 232 batch_bulk_out(batch); 236 const int ret = uhci_hc_schedule(hc, batch); 237 if (ret != EOK) { 238 batch_dispose(batch); 239 return ret; 240 } 241 return EOK; 233 const int ret = hc_schedule(hc, batch); 234 if (ret != EOK) { 235 batch_dispose(batch); 236 } 237 return ret; 242 238 } 243 239 /*----------------------------------------------------------------------------*/ … … 253 249 * @return Error code. 254 250 */ 255 static int bulk_in(ddf_fun_t *fun, usb_target_t target, 256 size_t max_packet_size, void *data, size_t size, 257 usbhc_iface_transfer_in_callback_t callback, void *arg) 258 { 259 assert(fun); 260 uhci_hc_t *hc = fun_to_uhci_hc(fun); 261 assert(hc); 262 usb_speed_t speed = device_keeper_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); 263 260 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 264 261 target.address, target.endpoint, size, max_packet_size); 265 262 266 batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,267 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,268 &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); 269 266 if (!batch) 270 267 return ENOMEM; 271 268 batch_bulk_in(batch); 272 const int ret = uhci_hc_schedule(hc, batch); 273 if (ret != EOK) { 274 batch_dispose(batch); 275 return ret; 276 } 277 return EOK; 269 const int ret = hc_schedule(hc, batch); 270 if (ret != EOK) { 271 batch_dispose(batch); 272 } 273 return ret; 278 274 } 279 275 /*----------------------------------------------------------------------------*/ … … 291 287 * @return Error code. 292 288 */ 293 static int control_write( ddf_fun_t *fun, usb_target_t target,294 size_t max_packet_size,289 static int control_write( 290 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 295 291 void *setup_data, size_t setup_size, void *data, size_t size, 296 292 usbhc_iface_transfer_out_callback_t callback, void *arg) 297 293 { 298 294 assert(fun); 299 uhci_hc_t *hc = fun_to_uhci_hc(fun); 300 assert(hc); 301 usb_speed_t speed = device_keeper_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); 302 299 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 303 300 speed, target.address, target.endpoint, size, max_packet_size); … … 306 303 return EINVAL; 307 304 308 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 309 max_packet_size, speed, data, size, setup_data, setup_size, 310 NULL, callback, arg, &hc->device_manager); 311 if (!batch) 312 return ENOMEM; 313 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); 314 312 batch_control_write(batch); 315 const int ret = uhci_hc_schedule(hc, batch); 316 if (ret != EOK) { 317 batch_dispose(batch); 318 return ret; 319 } 320 return EOK; 313 const int ret = hc_schedule(hc, batch); 314 if (ret != EOK) { 315 batch_dispose(batch); 316 } 317 return ret; 321 318 } 322 319 /*----------------------------------------------------------------------------*/ … … 334 331 * @return Error code. 335 332 */ 336 static int control_read( ddf_fun_t *fun, usb_target_t target,337 size_t max_packet_size,333 static int control_read( 334 ddf_fun_t *fun, usb_target_t target, size_t max_packet_size, 338 335 void *setup_data, size_t setup_size, void *data, size_t size, 339 336 usbhc_iface_transfer_in_callback_t callback, void *arg) 340 337 { 341 338 assert(fun); 342 uhci_hc_t *hc = fun_to_uhci_hc(fun); 343 assert(hc); 344 usb_speed_t speed = device_keeper_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); 345 343 346 344 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 347 345 speed, target.address, target.endpoint, size, max_packet_size); 348 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL, 349 max_packet_size, speed, data, size, setup_data, setup_size, callback, 350 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); 351 350 if (!batch) 352 351 return ENOMEM; 353 352 batch_control_read(batch); 354 const int ret = uhci_hc_schedule(hc, batch); 355 if (ret != EOK) { 356 batch_dispose(batch); 357 return ret; 358 } 359 return EOK; 360 } 361 /*----------------------------------------------------------------------------*/ 362 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 = { 363 361 .reserve_default_address = reserve_default_address, 364 362 .release_default_address = release_default_address, … … 370 368 .interrupt_in = interrupt_in, 371 369 370 .bulk_out = bulk_out, 372 371 .bulk_in = bulk_in, 373 .bulk_out = bulk_out, 374 372 373 .control_write = control_write, 375 374 .control_read = control_read, 376 .control_write = control_write,377 375 }; 378 376 /**
Note:
See TracChangeset
for help on using the changeset viewer.