Changeset 3f03199 in mainline for uspace/drv/bus/usb/uhci/hc.c
- Timestamp:
- 2013-09-15T06:33:53Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9348862
- Parents:
- dd7078c (diff), 1c0cef0 (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/bus/usb/uhci/hc.c
rdd7078c r3f03199 111 111 * @param[out] cmds Commands buffer. 112 112 * @param[in] cmds_size Size of the commands buffer (bytes). 113 * @param[in] regs Physical address of device's registers. 114 * @param[in] reg_size Size of the register area (bytes). 113 * @param[in] regs Device's register range. 115 114 * 116 115 * @return Error code. … … 118 117 int 119 118 hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[], 120 size_t cmds_size, uintptr_t regs, size_t reg_size)119 size_t cmds_size, addr_range_t *regs) 121 120 { 122 121 if ((ranges_size < sizeof(uhci_irq_pio_ranges)) || 123 122 (cmds_size < sizeof(uhci_irq_commands)) || 124 ( reg_size< sizeof(uhci_regs_t)))123 (RNGSZ(*regs) < sizeof(uhci_regs_t))) 125 124 return EOVERFLOW; 126 125 127 126 memcpy(ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges)); 128 ranges[0].base = regs;127 ranges[0].base = RNGABS(*regs); 129 128 130 129 memcpy(cmds, uhci_irq_commands, sizeof(uhci_irq_commands)); 131 uhci_regs_t *registers = (uhci_regs_t *) regs;130 uhci_regs_t *registers = (uhci_regs_t *) RNGABSPTR(*regs); 132 131 cmds[0].addr = (void*)®isters->usbsts; 133 132 cmds[3].addr = (void*)®isters->usbsts; 133 134 return EOK; 135 } 136 137 /** Register interrupt handler. 138 * 139 * @param[in] device Host controller DDF device 140 * @param[in] regs Register range 141 * @param[in] irq Interrupt number 142 * @paran[in] handler Interrupt handler 143 * 144 * @return EOK on success or negative error code 145 */ 146 int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq, 147 interrupt_handler_t handler) 148 { 149 assert(device); 150 irq_pio_range_t irq_ranges[hc_irq_pio_range_count()]; 151 irq_cmd_t irq_cmds[hc_irq_cmd_count()]; 152 153 int ret = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds, 154 sizeof(irq_cmds), regs); 155 if (ret != EOK) { 156 usb_log_error("Failed to generate IRQ commands: %s.\n", 157 str_error(ret)); 158 return ret; 159 } 160 161 irq_code_t irq_code = { 162 .rangecount = hc_irq_pio_range_count(), 163 .ranges = irq_ranges, 164 .cmdcount = hc_irq_cmd_count(), 165 .cmds = irq_cmds 166 }; 167 168 /* Register handler to avoid interrupt lockup */ 169 ret = register_interrupt_handler(device, irq, handler, &irq_code); 170 if (ret != EOK) { 171 usb_log_error("Failed to register interrupt handler: %s.\n", 172 str_error(ret)); 173 return ret; 174 } 134 175 135 176 return EOK; … … 196 237 * 197 238 * @param[in] instance Memory place to initialize. 198 * @param[in] regs Address of I/O control registers. 199 * @param[in] reg_size Size of I/O control registers. 239 * @param[in] regs Range of device's I/O control registers. 200 240 * @param[in] interrupts True if hw interrupts should be used. 201 241 * @return Error code. … … 205 245 * interrupt fibrils. 206 246 */ 207 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interrupts) 208 { 209 assert(reg_size >= sizeof(uhci_regs_t)); 247 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts) 248 { 249 assert(instance); 250 assert(regs); 251 assert(regs->size >= sizeof(uhci_regs_t)); 210 252 211 253 instance->hw_interrupts = interrupts; … … 214 256 /* allow access to hc control registers */ 215 257 uhci_regs_t *io; 216 int ret = pio_enable (regs, reg_size, (void **)&io);258 int ret = pio_enable_range(regs, (void **) &io); 217 259 if (ret != EOK) { 218 260 usb_log_error("Failed to gain access to registers at %p: %s.\n", … … 223 265 224 266 usb_log_debug( 225 "Device registers at %p (%zuB) accessible.\n", io, reg _size);267 "Device registers at %p (%zuB) accessible.\n", io, regs->size); 226 268 227 269 ret = hc_init_mem_structures(instance);
Note:
See TracChangeset
for help on using the changeset viewer.