Changeset 76fbd9a in mainline for uspace/drv/bus/usb/uhci
- Timestamp:
- 2012-02-24T19:07:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a76b01b4
- Parents:
- 5837c7a
- Location:
- uspace/drv/bus/usb/uhci
- Files:
-
- 11 edited
-
hc.c (modified) (11 diffs)
-
hw_struct/queue_head.h (modified) (3 diffs)
-
hw_struct/transfer_descriptor.c (modified) (2 diffs)
-
hw_struct/transfer_descriptor.h (modified) (6 diffs)
-
main.c (modified) (2 diffs)
-
pci.c (modified) (2 diffs)
-
transfer_list.c (modified) (6 diffs)
-
uhci.c (modified) (6 diffs)
-
uhci_batch.c (modified) (7 diffs)
-
uhci_batch.h (modified) (3 diffs)
-
utils/malloc32.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/hc.c
r5837c7a r76fbd9a 72 72 static int hc_debug_checker(void *arg); 73 73 74 /*----------------------------------------------------------------------------*/ 74 75 75 /** Get number of PIO ranges used in IRQ code. 76 76 * @return Number of ranges. … … 80 80 return sizeof(uhci_irq_pio_ranges) / sizeof(irq_pio_range_t); 81 81 } 82 /*----------------------------------------------------------------------------*/ 82 83 83 /** Get number of commands used in IRQ code. 84 84 * @return Number of commands. … … 88 88 return sizeof(uhci_irq_commands) / sizeof(irq_cmd_t); 89 89 } 90 /*----------------------------------------------------------------------------*/ 90 91 91 /** Generate IRQ code. 92 92 * @param[out] ranges PIO ranges buffer. … … 118 118 return EOK; 119 119 } 120 /*----------------------------------------------------------------------------*/ 120 121 121 /** Take action based on the interrupt cause. 122 122 * … … 175 175 } 176 176 } 177 /*----------------------------------------------------------------------------*/ 177 178 178 /** Initialize UHCI hc driver structure 179 179 * … … 235 235 return EOK; 236 236 } 237 /*----------------------------------------------------------------------------*/ 237 238 238 /** Initialize UHCI hc hw resources. 239 239 * … … 277 277 UHCI_CMD_RUN_STOP | UHCI_CMD_MAX_PACKET | UHCI_CMD_CONFIGURE); 278 278 } 279 /*----------------------------------------------------------------------------*/ 279 280 280 /** Initialize UHCI hc memory structures. 281 281 * … … 319 319 return EOK; 320 320 } 321 /*----------------------------------------------------------------------------*/ 321 322 322 /** Initialize UHCI hc transfer lists. 323 323 * … … 381 381 #undef CHECK_RET_CLEAR_RETURN 382 382 } 383 /*----------------------------------------------------------------------------*/ 383 384 384 /** Schedule batch for execution. 385 385 * … … 409 409 return EOK; 410 410 } 411 /*----------------------------------------------------------------------------*/ 411 412 412 /** Polling function, emulates interrupts. 413 413 * … … 432 432 return EOK; 433 433 } 434 /*----------------------------------------------------------------------------*/ 434 435 435 /** Debug function, checks consistency of memory structures. 436 436 * -
uspace/drv/bus/usb/uhci/hw_struct/queue_head.h
r5837c7a r76fbd9a 47 47 volatile link_pointer_t element; 48 48 } __attribute__((packed)) qh_t; 49 /*----------------------------------------------------------------------------*/ 49 50 50 /** Initialize queue head structure 51 51 * … … 61 61 instance->next = LINK_POINTER_TERM; 62 62 } 63 /*----------------------------------------------------------------------------*/ 63 64 64 /** Set queue head next pointer 65 65 * … … 81 81 } 82 82 } 83 /*----------------------------------------------------------------------------*/ 83 84 84 /** Set queue head element pointer 85 85 * -
uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c
r5837c7a r76fbd9a 107 107 } 108 108 } 109 /*----------------------------------------------------------------------------*/ 109 110 110 /** Convert TD status into standard error code 111 111 * … … 145 145 return EOK; 146 146 } 147 /*----------------------------------------------------------------------------*/ 147 148 148 /** Print values in status field (dw1) in a human readable way. 149 149 * -
uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h
r5837c7a r76fbd9a 100 100 101 101 void td_print_status(const td_t *instance); 102 /*----------------------------------------------------------------------------*/ 102 103 103 /** Helper function for parsing actual size out of TD. 104 104 * … … 113 113 return ((s >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK; 114 114 } 115 /*----------------------------------------------------------------------------*/ 115 116 116 /** Check whether less than max data were received on SPD marked transfer. 117 117 * … … 129 129 (instance->status | TD_STATUS_SPD_FLAG) && act_size < max_size; 130 130 } 131 /*----------------------------------------------------------------------------*/ 131 132 132 /** Helper function for parsing value of toggle bit. 133 133 * … … 140 140 return (instance->device & TD_DEVICE_DATA_TOGGLE_ONE_FLAG) ? 1 : 0; 141 141 } 142 /*----------------------------------------------------------------------------*/ 142 143 143 /** Helper function for parsing value of active bit 144 144 * … … 151 151 return (instance->status & TD_STATUS_ERROR_ACTIVE) != 0; 152 152 } 153 /*----------------------------------------------------------------------------*/ 153 154 154 /** Helper function for setting IOC bit. 155 155 * … … 161 161 instance->status |= TD_STATUS_IOC_FLAG; 162 162 } 163 /*----------------------------------------------------------------------------*/ 163 164 164 #endif 165 165 /** -
uspace/drv/bus/usb/uhci/main.c
r5837c7a r76fbd9a 44 44 45 45 static int uhci_dev_add(ddf_dev_t *device); 46 /*----------------------------------------------------------------------------*/ 46 47 47 static driver_ops_t uhci_driver_ops = { 48 48 .dev_add = uhci_dev_add, 49 49 }; 50 /*----------------------------------------------------------------------------*/ 50 51 51 static driver_t uhci_driver = { 52 52 .name = NAME, 53 53 .driver_ops = &uhci_driver_ops 54 54 }; 55 /*----------------------------------------------------------------------------*/ 55 56 56 /** Initialize a new ddf driver instance for uhci hc and hub. 57 57 * … … 75 75 return ret; 76 76 } 77 /*----------------------------------------------------------------------------*/ 77 78 78 /** Initialize global driver structures (NONE). 79 79 * -
uspace/drv/bus/usb/uhci/pci.c
r5837c7a r76fbd9a 91 91 return EOK; 92 92 } 93 /*----------------------------------------------------------------------------*/ 93 94 94 /** Call the PCI driver with a request to enable interrupts 95 95 * … … 110 110 return enabled ? EOK : EIO; 111 111 } 112 /*----------------------------------------------------------------------------*/ 112 113 113 /** Call the PCI driver with a request to clear legacy support register 114 114 * -
uspace/drv/bus/usb/uhci/transfer_list.c
r5837c7a r76fbd9a 42 42 static void transfer_list_remove_batch( 43 43 transfer_list_t *instance, uhci_transfer_batch_t *uhci_batch); 44 /*----------------------------------------------------------------------------*/ 44 45 45 /** Initialize transfer list structures. 46 46 * … … 69 69 return EOK; 70 70 } 71 /*----------------------------------------------------------------------------*/ 71 72 72 /** Dispose transfer list structures. 73 73 * … … 97 97 qh_set_next_qh(instance->queue_head, next->queue_head); 98 98 } 99 /*----------------------------------------------------------------------------*/ 99 100 100 /** Add transfer batch to the list and queue. 101 101 * … … 144 144 fibril_mutex_unlock(&instance->guard); 145 145 } 146 /*----------------------------------------------------------------------------*/ 146 147 147 /** Add completed batches to the provided list. 148 148 * … … 171 171 fibril_mutex_unlock(&instance->guard); 172 172 } 173 /*----------------------------------------------------------------------------*/ 173 174 174 /** Walk the list and finish all batches with EINTR. 175 175 * … … 188 188 fibril_mutex_unlock(&instance->guard); 189 189 } 190 /*----------------------------------------------------------------------------*/ 190 191 191 /** Remove a transfer batch from the list and queue. 192 192 * -
uspace/drv/bus/usb/uhci/uhci.c
r5837c7a r76fbd9a 65 65 return dev->driver_data; 66 66 } 67 /*----------------------------------------------------------------------------*/ 67 68 68 /** IRQ handling callback, forward status from call to diver structure. 69 69 * … … 83 83 hc_interrupt(&uhci->hc, status); 84 84 } 85 /*----------------------------------------------------------------------------*/ 85 86 86 /** Operations supported by the HC driver */ 87 87 static ddf_dev_ops_t hc_ops = { 88 88 .interfaces[USBHC_DEV_IFACE] = &hcd_iface, /* see iface.h/c */ 89 89 }; 90 /*----------------------------------------------------------------------------*/ 90 91 91 /** Gets handle of the respective hc. 92 92 * … … 105 105 return EOK; 106 106 } 107 /*----------------------------------------------------------------------------*/ 107 108 108 /** USB interface implementation used by RH */ 109 109 static usb_iface_t usb_iface = { 110 110 .get_hc_handle = usb_iface_get_hc_handle, 111 111 }; 112 /*----------------------------------------------------------------------------*/ 112 113 113 /** Get root hub hw resources (I/O registers). 114 114 * … … 123 123 return &rh->resource_list; 124 124 } 125 /*----------------------------------------------------------------------------*/ 125 126 126 /** Interface to provide the root hub driver with hw info */ 127 127 static hw_res_ops_t hw_res_iface = { … … 129 129 .enable_interrupt = NULL, 130 130 }; 131 /*----------------------------------------------------------------------------*/ 131 132 132 /** RH function support for uhci_rhd */ 133 133 static ddf_dev_ops_t rh_ops = { … … 135 135 .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface 136 136 }; 137 /*----------------------------------------------------------------------------*/ 137 138 138 /** Initialize hc and rh DDF structures and their respective drivers. 139 139 * -
uspace/drv/bus/usb/uhci/uhci_batch.c
r5837c7a r76fbd9a 58 58 } 59 59 } 60 /*----------------------------------------------------------------------------*/ 60 61 61 /** Finishes usb_transfer_batch and destroys the structure. 62 62 * … … 71 71 uhci_transfer_batch_dispose(uhci_batch); 72 72 } 73 /*----------------------------------------------------------------------------*/ 73 74 74 /** Transfer batch setup table. */ 75 75 static void (*const batch_setup[])(uhci_transfer_batch_t*, usb_direction_t); 76 /*----------------------------------------------------------------------------*/ 76 77 77 /** Allocate memory and initialize internal data structure. 78 78 * … … 143 143 return uhci_batch; 144 144 } 145 /*----------------------------------------------------------------------------*/ 145 146 146 /** Check batch TDs for activity. 147 147 * … … 196 196 return true; 197 197 } 198 /*----------------------------------------------------------------------------*/ 198 199 199 /** Direction to pid conversion table */ 200 200 static const usb_packet_id direction_pids[] = { … … 202 202 [USB_DIRECTION_OUT] = USB_PID_OUT, 203 203 }; 204 /*----------------------------------------------------------------------------*/ 204 205 205 /** Prepare generic data transfer 206 206 * … … 259 259 USB_TRANSFER_BATCH_ARGS(*uhci_batch->usb_batch)); 260 260 } 261 /*----------------------------------------------------------------------------*/ 261 262 262 /** Prepare generic control transfer 263 263 * … … 331 331 uhci_batch->tds[td].status); 332 332 } 333 /*----------------------------------------------------------------------------*/ 333 334 334 static void (*const batch_setup[])(uhci_transfer_batch_t*, usb_direction_t) = 335 335 { -
uspace/drv/bus/usb/uhci/uhci_batch.h
r5837c7a r76fbd9a 76 76 uhci_batch->td_count * sizeof(td_t); 77 77 } 78 /*----------------------------------------------------------------------------*/ 78 79 79 /** Get offset to data buffer accessible to the HC hw. 80 80 * @param uhci_batch UHCI batch structure. … … 89 89 uhci_batch->usb_batch->setup_size; 90 90 } 91 /*----------------------------------------------------------------------------*/ 91 92 92 /** Aborts the batch. 93 93 * Sets error to EINTR and size off transferd data to 0, before finishing the … … 103 103 uhci_transfer_batch_finish_dispose(uhci_batch); 104 104 } 105 /*----------------------------------------------------------------------------*/ 105 106 106 /** Linked list conversion wrapper. 107 107 * @param l Linked list link. -
uspace/drv/bus/usb/uhci/utils/malloc32.h
r5837c7a r76fbd9a 62 62 return result; 63 63 } 64 /*----------------------------------------------------------------------------*/ 64 65 65 /** DMA malloc simulator 66 66 * … … 84 84 return memalign(alignment, size); 85 85 } 86 /*----------------------------------------------------------------------------*/ 86 87 87 /** DMA malloc simulator 88 88 * … … 91 91 static inline void free32(void *addr) 92 92 { free(addr); } 93 /*----------------------------------------------------------------------------*/ 93 94 94 /** Create 4KB page mapping 95 95 * … … 105 105 return address; 106 106 } 107 /*----------------------------------------------------------------------------*/ 107 108 108 static inline void return_page(void *page) 109 109 {
Note:
See TracChangeset
for help on using the changeset viewer.
