Changeset c01cd32 in mainline
- Timestamp:
- 2011-03-21T22:42:47Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 33fbe95
- Parents:
- c56c5b5b
- Location:
- uspace/drv/uhci-hcd
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/Makefile
rc56c5b5b rc01cd32 37 37 transfer_list.c \ 38 38 uhci.c \ 39 uhci_hc.c \39 hc.c \ 40 40 uhci_rh.c \ 41 41 uhci_struct/transfer_descriptor.c \ -
uspace/drv/uhci-hcd/batch.c
rc56c5b5b rc01cd32 40 40 #include "batch.h" 41 41 #include "transfer_list.h" 42 #include "uhci_hc.h"43 42 #include "utils/malloc32.h" 44 43 #include "uhci_struct/transfer_descriptor.h" -
uspace/drv/uhci-hcd/hc.c
rc56c5b5b rc01cd32 42 42 #include <usb_iface.h> 43 43 44 #include " uhci_hc.h"44 #include "hc.h" 45 45 46 46 static irq_cmd_t uhci_cmds[] = { … … 60 60 }; 61 61 /*----------------------------------------------------------------------------*/ 62 static int uhci_hc_init_transfer_lists(uhci_hc_t *instance);63 static int uhci_hc_init_mem_structures(uhci_hc_t *instance);64 static void uhci_hc_init_hw(uhci_hc_t *instance);65 66 static int uhci_hc_interrupt_emulator(void *arg);67 static int uhci_hc_debug_checker(void *arg);62 static int hc_init_transfer_lists(hc_t *instance); 63 static int hc_init_mem_structures(hc_t *instance); 64 static void hc_init_hw(hc_t *instance); 65 66 static int hc_interrupt_emulator(void *arg); 67 static int hc_debug_checker(void *arg); 68 68 69 69 static bool allowed_usb_packet( … … 82 82 * interrupt fibrils. 83 83 */ 84 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun,84 int hc_init(hc_t *instance, ddf_fun_t *fun, 85 85 void *regs, size_t reg_size, bool interrupts) 86 86 { … … 112 112 io, reg_size); 113 113 114 ret = uhci_hc_init_mem_structures(instance);114 ret = hc_init_mem_structures(instance); 115 115 CHECK_RET_DEST_FUN_RETURN(ret, 116 116 "Failed to initialize UHCI memory structures.\n"); 117 117 118 uhci_hc_init_hw(instance);118 hc_init_hw(instance); 119 119 if (!interrupts) { 120 120 instance->cleaner = 121 fibril_create( uhci_hc_interrupt_emulator, instance);121 fibril_create(hc_interrupt_emulator, instance); 122 122 fibril_add_ready(instance->cleaner); 123 123 } else { … … 126 126 127 127 instance->debug_checker = 128 fibril_create( uhci_hc_debug_checker, instance);128 fibril_create(hc_debug_checker, instance); 129 129 // fibril_add_ready(instance->debug_checker); 130 130 … … 138 138 * For magic values see UHCI Design Guide 139 139 */ 140 void uhci_hc_init_hw(uhci_hc_t *instance)140 void hc_init_hw(hc_t *instance) 141 141 { 142 142 assert(instance); … … 186 186 * - frame list page (needs to be one UHCI hw accessible 4K page) 187 187 */ 188 int uhci_hc_init_mem_structures(uhci_hc_t *instance)188 int hc_init_mem_structures(hc_t *instance) 189 189 { 190 190 assert(instance); … … 215 215 216 216 /* Init transfer lists */ 217 ret = uhci_hc_init_transfer_lists(instance);217 ret = hc_init_transfer_lists(instance); 218 218 CHECK_RET_DEST_CMDS_RETURN(ret, "Failed to init transfer lists.\n"); 219 219 usb_log_debug("Initialized transfer lists.\n"); … … 252 252 * USB scheduling. Sets pointer table for quick access. 253 253 */ 254 int uhci_hc_init_transfer_lists(uhci_hc_t *instance)254 int hc_init_transfer_lists(hc_t *instance) 255 255 { 256 256 assert(instance); … … 318 318 * Checks for bandwidth availability and appends the batch to the proper queue. 319 319 */ 320 int uhci_hc_schedule(uhci_hc_t *instance, usb_transfer_batch_t *batch)320 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch) 321 321 { 322 322 assert(instance); … … 351 351 * - resume from suspend state (not implemented) 352 352 */ 353 void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status)353 void hc_interrupt(hc_t *instance, uint16_t status) 354 354 { 355 355 assert(instance); … … 373 373 if (instance->hw_failures < UHCI_ALLOWED_HW_FAIL) { 374 374 /* reinitialize hw, this triggers virtual disconnect*/ 375 uhci_hc_init_hw(instance);375 hc_init_hw(instance); 376 376 } else { 377 377 usb_log_fatal("Too many UHCI hardware failures!.\n"); 378 uhci_hc_fini(instance);378 hc_fini(instance); 379 379 } 380 380 } … … 386 386 * @return EOK (should never return) 387 387 */ 388 int uhci_hc_interrupt_emulator(void* arg)388 int hc_interrupt_emulator(void* arg) 389 389 { 390 390 usb_log_debug("Started interrupt emulator.\n"); 391 uhci_hc_t *instance = (uhci_hc_t*)arg;391 hc_t *instance = (hc_t*)arg; 392 392 assert(instance); 393 393 … … 398 398 if (status != 0) 399 399 usb_log_debug2("UHCI status: %x.\n", status); 400 uhci_hc_interrupt(instance, status);400 hc_interrupt(instance, status); 401 401 async_usleep(UHCI_CLEANER_TIMEOUT); 402 402 } … … 409 409 * @return EOK (should never return) 410 410 */ 411 int uhci_hc_debug_checker(void *arg)412 { 413 uhci_hc_t *instance = (uhci_hc_t*)arg;411 int hc_debug_checker(void *arg) 412 { 413 hc_t *instance = (hc_t*)arg; 414 414 assert(instance); 415 415 -
uspace/drv/uhci-hcd/hc.h
rc56c5b5b rc01cd32 82 82 #define UHCI_ALLOWED_HW_FAIL 5 83 83 84 typedef struct uhci_hc {84 typedef struct hc { 85 85 usb_device_keeper_t device_manager; 86 86 … … 104 104 105 105 ddf_fun_t *ddf_instance; 106 } uhci_hc_t;106 } hc_t; 107 107 108 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun,108 int hc_init(hc_t *instance, ddf_fun_t *fun, 109 109 void *regs, size_t reg_size, bool interupts); 110 110 111 int uhci_hc_schedule(uhci_hc_t *instance, usb_transfer_batch_t *batch);111 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch); 112 112 113 void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status);113 void hc_interrupt(hc_t *instance, uint16_t status); 114 114 115 115 /** Safely dispose host controller internal structures … … 117 117 * @param[in] instance Host controller structure to use. 118 118 */ 119 static inline void uhci_hc_fini(uhci_hc_t *instance) { /* TODO: implement*/ };119 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ }; 120 120 121 121 /** Get and cast pointer to the driver data … … 124 124 * @return cast pointer to driver_data 125 125 */ 126 static inline uhci_hc_t * fun_to_uhci_hc(ddf_fun_t *fun)127 { return ( uhci_hc_t*)fun->driver_data; }126 static inline hc_t * fun_to_hc(ddf_fun_t *fun) 127 { return (hc_t*)fun->driver_data; } 128 128 #endif 129 129 /** -
uspace/drv/uhci-hcd/iface.c
rc56c5b5b rc01cd32 40 40 41 41 #include "iface.h" 42 #include " uhci_hc.h"42 #include "hc.h" 43 43 44 44 /** Reserve default address interface function … … 52 52 { 53 53 assert(fun); 54 uhci_hc_t *hc = fun_to_uhci_hc(fun);54 hc_t *hc = fun_to_hc(fun); 55 55 assert(hc); 56 56 usb_log_debug("Default address request with speed %d.\n", speed); … … 67 67 { 68 68 assert(fun); 69 uhci_hc_t *hc = fun_to_uhci_hc(fun);69 hc_t *hc = fun_to_hc(fun); 70 70 assert(hc); 71 71 usb_log_debug("Default address release.\n"); … … 85 85 { 86 86 assert(fun); 87 uhci_hc_t *hc = fun_to_uhci_hc(fun);87 hc_t *hc = fun_to_hc(fun); 88 88 assert(hc); 89 89 assert(address); … … 108 108 { 109 109 assert(fun); 110 uhci_hc_t *hc = fun_to_uhci_hc(fun);110 hc_t *hc = fun_to_hc(fun); 111 111 assert(hc); 112 112 usb_log_debug("Address bind %d-%d.\n", address, handle); … … 124 124 { 125 125 assert(fun); 126 uhci_hc_t *hc = fun_to_uhci_hc(fun);126 hc_t *hc = fun_to_hc(fun); 127 127 assert(hc); 128 128 usb_log_debug("Address release %d.\n", address); … … 147 147 { 148 148 assert(fun); 149 uhci_hc_t *hc = fun_to_uhci_hc(fun);149 hc_t *hc = fun_to_hc(fun); 150 150 assert(hc); 151 151 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); … … 160 160 return ENOMEM; 161 161 batch_interrupt_out(batch); 162 const int ret = uhci_hc_schedule(hc, batch);162 const int ret = hc_schedule(hc, batch); 163 163 if (ret != EOK) { 164 164 batch_dispose(batch); … … 184 184 { 185 185 assert(fun); 186 uhci_hc_t *hc = fun_to_uhci_hc(fun);186 hc_t *hc = fun_to_hc(fun); 187 187 assert(hc); 188 188 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); … … 196 196 return ENOMEM; 197 197 batch_interrupt_in(batch); 198 const int ret = uhci_hc_schedule(hc, batch);198 const int ret = hc_schedule(hc, batch); 199 199 if (ret != EOK) { 200 200 batch_dispose(batch); … … 220 220 { 221 221 assert(fun); 222 uhci_hc_t *hc = fun_to_uhci_hc(fun);222 hc_t *hc = fun_to_hc(fun); 223 223 assert(hc); 224 224 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); … … 233 233 return ENOMEM; 234 234 batch_bulk_out(batch); 235 const int ret = uhci_hc_schedule(hc, batch);235 const int ret = hc_schedule(hc, batch); 236 236 if (ret != EOK) { 237 237 batch_dispose(batch); … … 257 257 { 258 258 assert(fun); 259 uhci_hc_t *hc = fun_to_uhci_hc(fun);259 hc_t *hc = fun_to_hc(fun); 260 260 assert(hc); 261 261 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); … … 269 269 return ENOMEM; 270 270 batch_bulk_in(batch); 271 const int ret = uhci_hc_schedule(hc, batch);271 const int ret = hc_schedule(hc, batch); 272 272 if (ret != EOK) { 273 273 batch_dispose(batch); … … 296 296 { 297 297 assert(fun); 298 uhci_hc_t *hc = fun_to_uhci_hc(fun);298 hc_t *hc = fun_to_hc(fun); 299 299 assert(hc); 300 300 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); … … 312 312 usb_device_keeper_reset_if_need(&hc->device_manager, target, setup_data); 313 313 batch_control_write(batch); 314 const int ret = uhci_hc_schedule(hc, batch);314 const int ret = hc_schedule(hc, batch); 315 315 if (ret != EOK) { 316 316 batch_dispose(batch); … … 339 339 { 340 340 assert(fun); 341 uhci_hc_t *hc = fun_to_uhci_hc(fun);341 hc_t *hc = fun_to_hc(fun); 342 342 assert(hc); 343 343 usb_speed_t speed = usb_device_keeper_get_speed(&hc->device_manager, target.address); … … 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 return ret; 357 } 358 return EOK; 359 } 360 /*----------------------------------------------------------------------------*/ 361 usbhc_iface_t hc_iface = { 362 362 .reserve_default_address = reserve_default_address, 363 363 .release_default_address = release_default_address, -
uspace/drv/uhci-hcd/iface.h
rc56c5b5b rc01cd32 38 38 #include <usbhc_iface.h> 39 39 40 extern usbhc_iface_t uhci_hc_iface;40 extern usbhc_iface_t hc_iface; 41 41 42 42 #endif -
uspace/drv/uhci-hcd/uhci.c
rc56c5b5b rc01cd32 54 54 { 55 55 assert(dev); 56 uhci_hc_t *hc = &((uhci_t*)dev->driver_data)->hc;56 hc_t *hc = &((uhci_t*)dev->driver_data)->hc; 57 57 uint16_t status = IPC_GET_ARG1(*call); 58 58 assert(hc); 59 uhci_hc_interrupt(hc, status);59 hc_interrupt(hc, status); 60 60 } 61 61 /*----------------------------------------------------------------------------*/ … … 107 107 }; 108 108 /*----------------------------------------------------------------------------*/ 109 static ddf_dev_ops_t uhci_hc_ops = {109 static ddf_dev_ops_t hc_ops = { 110 110 .interfaces[USB_DEV_IFACE] = &usb_iface, 111 .interfaces[USBHC_DEV_IFACE] = & uhci_hc_iface, /* see iface.h/c */111 .interfaces[USBHC_DEV_IFACE] = &hc_iface, /* see iface.h/c */ 112 112 }; 113 113 /*----------------------------------------------------------------------------*/ … … 190 190 "Failed(%d) to create HC function.\n", ret); 191 191 192 ret = uhci_hc_init(&instance->hc, instance->hc_fun,192 ret = hc_init(&instance->hc, instance->hc_fun, 193 193 (void*)io_reg_base, io_reg_size, interrupts); 194 194 CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to init uhci-hcd.\n", ret); 195 instance->hc_fun->ops = & uhci_hc_ops;195 instance->hc_fun->ops = &hc_ops; 196 196 instance->hc_fun->driver_data = &instance->hc; 197 197 ret = ddf_fun_bind(instance->hc_fun); … … 208 208 if (instance->rh_fun) \ 209 209 ddf_fun_destroy(instance->rh_fun); \ 210 uhci_hc_fini(&instance->hc); \210 hc_fini(&instance->hc); \ 211 211 return ret; \ 212 212 } -
uspace/drv/uhci-hcd/uhci.h
rc56c5b5b rc01cd32 38 38 #include <ddf/driver.h> 39 39 40 #include " uhci_hc.h"40 #include "hc.h" 41 41 #include "uhci_rh.h" 42 42 … … 45 45 ddf_fun_t *rh_fun; 46 46 47 uhci_hc_t hc;47 hc_t hc; 48 48 uhci_rh_t rh; 49 49 } uhci_t; -
uspace/drv/uhci-hcd/uhci_rh.c
rc56c5b5b rc01cd32 40 40 41 41 #include "uhci_rh.h" 42 #include "uhci_hc.h"43 42 44 43 /** Root hub initialization
Note:
See TracChangeset
for help on using the changeset viewer.