Changeset e6edc8d1 in mainline for uspace/drv/bus/usb/uhci/hc.c
- Timestamp:
- 2013-07-11T19:13:37Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 67632f7
- Parents:
- 52ff62d3 (diff), 2b3e8840 (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
r52ff62d3 re6edc8d1 90 90 static int hc_debug_checker(void *arg); 91 91 92 93 /** Get number of PIO ranges used in IRQ code. 94 * @return Number of ranges. 95 */ 96 size_t hc_irq_pio_range_count(void) 97 { 98 return sizeof(uhci_irq_pio_ranges) / sizeof(irq_pio_range_t); 99 } 100 101 /** Get number of commands used in IRQ code. 102 * @return Number of commands. 103 */ 104 size_t hc_irq_cmd_count(void) 105 { 106 return sizeof(uhci_irq_commands) / sizeof(irq_cmd_t); 107 } 92 enum { 93 /** Number of PIO ranges used in IRQ code */ 94 hc_irq_pio_range_count = 95 sizeof(uhci_irq_pio_ranges) / sizeof(irq_pio_range_t), 96 97 /* Number of commands used in IRQ code */ 98 hc_irq_cmd_count = 99 sizeof(uhci_irq_commands) / sizeof(irq_cmd_t) 100 }; 108 101 109 102 /** Generate IRQ code. … … 133 126 cmds[0].addr = ®isters->usbsts; 134 127 cmds[3].addr = ®isters->usbsts; 128 129 return EOK; 130 } 131 132 /** Register interrupt handler. 133 * 134 * @param[in] device Host controller DDF device 135 * @param[in] reg_base Register range base 136 * @param[in] reg_size Register range size 137 * @param[in] irq Interrupt number 138 * @paran[in] handler Interrupt handler 139 * 140 * @return EOK on success or negative error code 141 */ 142 int hc_register_irq_handler(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size, 143 int irq, interrupt_handler_t handler) 144 { 145 int rc; 146 irq_pio_range_t irq_ranges[hc_irq_pio_range_count]; 147 irq_cmd_t irq_cmds[hc_irq_cmd_count]; 148 rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds, 149 sizeof(irq_cmds), reg_base, reg_size); 150 if (rc != EOK) { 151 usb_log_error("Failed to generate IRQ commands: %s.\n", 152 str_error(rc)); 153 return rc; 154 } 155 156 irq_code_t irq_code = { 157 .rangecount = hc_irq_pio_range_count, 158 .ranges = irq_ranges, 159 .cmdcount = hc_irq_cmd_count, 160 .cmds = irq_cmds 161 }; 162 163 /* Register handler to avoid interrupt lockup */ 164 rc = register_interrupt_handler(device, irq, handler, &irq_code); 165 if (rc != EOK) { 166 usb_log_error("Failed to register interrupt handler: %s.\n", 167 str_error(rc)); 168 return rc; 169 } 135 170 136 171 return EOK; … … 209 244 { 210 245 assert(reg_size >= sizeof(uhci_regs_t)); 211 int ret; 212 213 #define CHECK_RET_RETURN(ret, message...) \ 214 if (ret != EOK) { \ 215 usb_log_error(message); \ 216 return ret; \ 217 } else (void) 0 246 int rc; 218 247 219 248 instance->hw_interrupts = interrupts; … … 222 251 /* allow access to hc control registers */ 223 252 uhci_regs_t *io; 224 ret = pio_enable(regs, reg_size, (void **)&io); 225 CHECK_RET_RETURN(ret, "Failed to gain access to registers at %p: %s.\n", 226 io, str_error(ret)); 253 rc = pio_enable(regs, reg_size, (void **)&io); 254 if (rc != EOK) { 255 usb_log_error("Failed to gain access to registers at %p: %s.\n", 256 io, str_error(rc)); 257 return rc; 258 } 259 227 260 instance->registers = io; 228 261 usb_log_debug( 229 262 "Device registers at %p (%zuB) accessible.\n", io, reg_size); 230 263 231 r et= hc_init_mem_structures(instance);232 CHECK_RET_RETURN(ret,233 234 str_error(ret));235 236 #undef CHECK_RET_RETURN 264 rc = hc_init_mem_structures(instance); 265 if (rc != EOK) { 266 usb_log_error("Failed to initialize UHCI memory structures: %s.\n", 267 str_error(rc)); 268 return rc; 269 } 237 270 238 271 hcd_init(&instance->generic, USB_SPEED_FULL, … … 397 430 398 431 return EOK; 399 #undef CHECK_RET_CLEAR_RETURN400 432 } 401 433
Note:
See TracChangeset
for help on using the changeset viewer.