Changeset 1cb4f05 in mainline
- Timestamp:
- 2011-07-11T08:52:43Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aa81adc
- Parents:
- a00768c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
ra00768c r1cb4f05 56 56 }; 57 57 58 static void hc_gain_control(hc_t *instance); 58 59 static void hc_start(hc_t *instance); 59 static int interrupt_emulator(hc_t *instance);60 static void hc_gain_control(hc_t *instance);61 60 static int hc_init_transfer_lists(hc_t *instance); 62 61 static int hc_init_memory(hc_t *instance); 62 static int interrupt_emulator(hc_t *instance); 63 64 /*----------------------------------------------------------------------------*/ 65 /** Get number of commands used in IRQ code. 66 * @return Number of commands. 67 */ 68 size_t hc_irq_cmd_count(void) 69 { 70 return sizeof(ohci_irq_commands) / sizeof(irq_cmd_t); 71 } 72 /*----------------------------------------------------------------------------*/ 73 /** Generate IRQ code commands. 74 * @param[out] cmds Place to store the commands. 75 * @param[in] cmd_size Size of the place (bytes). 76 * @param[in] regs Physical address of device's registers. 77 * @param[in] reg_size Size of the register area (bytes). 78 * 79 * @return Error code. 80 */ 81 int hc_get_irq_commands( 82 irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size) 83 { 84 if (cmd_size < sizeof(ohci_irq_commands) 85 || reg_size < sizeof(ohci_regs_t)) 86 return EOVERFLOW; 87 88 /* Create register mapping to use in IRQ handler. 89 * This mapping should be present in kernel only. 90 * Remove it from here when kernel knows how to create mappings 91 * and accepts physical addresses in IRQ code. 92 * TODO: remove */ 93 ohci_regs_t *registers; 94 const int ret = pio_enable((void*)regs, reg_size, (void**)®isters); 95 96 /* Some bogus access to force create mapping. DO NOT remove, 97 * unless whole virtual addresses in irq is replaced 98 * NOTE: Compiler won't remove this as ohci_regs_t members 99 * are declared volatile. */ 100 registers->revision; 101 102 if (ret != EOK) 103 return ret; 104 105 memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands)); 106 107 void *address = (void*)®isters->interrupt_status; 108 cmds[0].addr = address; 109 cmds[3].addr = address; 110 return EOK; 111 } 63 112 /*----------------------------------------------------------------------------*/ 64 113 /** Announce OHCI root hub to the DDF … … 94 143 int ret = hc_add_endpoint(instance, hub_address, 0, USB_SPEED_FULL, 95 144 USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH, 64, 0, 0); 96 CHECK_RET_RELEASE(ret, "Failed(%d) to add OHCI rh endpoint 0.\n", ret); 145 CHECK_RET_RELEASE(ret, 146 "Failed to add OHCI root hub endpoint 0: %s.\n", str_error(ret)); 97 147 98 148 char *match_str = NULL; 99 /* DDF needs heap allocated string */149 /* DDF needs heap allocated string. */ 100 150 ret = asprintf(&match_str, "usb&class=hub"); 101 151 ret = ret > 0 ? 0 : ret; 102 CHECK_RET_RELEASE(ret, "Failed(%d) to create match-id string.\n", ret); 152 CHECK_RET_RELEASE(ret, 153 "Failed to create match-id string: %s.\n", str_error(ret)); 103 154 104 155 ret = ddf_fun_add_match_id(hub_fun, match_str, 100); 105 CHECK_RET_RELEASE(ret, "Failed(%d) add root hub match-id.\n", ret); 156 CHECK_RET_RELEASE(ret, 157 "Failed to add root hub match-id: %s.\n", str_error(ret)); 106 158 107 159 ret = ddf_fun_bind(hub_fun); 108 CHECK_RET_RELEASE(ret, "Failed(%d) to bind root hub function.\n", ret); 160 CHECK_RET_RELEASE(ret, 161 "Failed to bind root hub function: %s.\n", str_error(ret)); 109 162 110 163 return EOK; … … 123 176 { 124 177 assert(instance); 125 int ret = EOK; 178 126 179 #define CHECK_RET_RETURN(ret, message...) \ 127 180 if (ret != EOK) { \ … … 130 183 } else (void)0 131 184 132 ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers); 185 int ret = 186 pio_enable((void*)regs, reg_size, (void**)&instance->registers); 133 187 CHECK_RET_RETURN(ret, 134 "Failed(%d) to gain access to device registers: %s.\n", 135 ret, str_error(ret)); 188 "Failed to gain access to device registers: %s.\n", str_error(ret)); 136 189 137 190 list_initialize(&instance->pending_batches); 138 191 usb_device_keeper_init(&instance->manager); 192 139 193 ret = usb_endpoint_manager_init(&instance->ep_manager, 140 194 BANDWIDTH_AVAILABLE_USB11); … … 160 214 hc_start(instance); 161 215 162 return EOK;163 }164 /*----------------------------------------------------------------------------*/165 /** Get number of commands used in IRQ code.166 * @return Number of commands.167 */168 size_t hc_irq_cmd_count(void)169 {170 return sizeof(ohci_irq_commands) / sizeof(irq_cmd_t);171 }172 /*----------------------------------------------------------------------------*/173 /** Generate IRQ code commands.174 * @param[out] cmds Place to store the commands.175 * @param[in] cmd_size Size of the place (bytes).176 * @param[in] regs Physical address of device's registers.177 * @param[in] reg_size Size of the register area (bytes).178 *179 * @return Error code.180 */181 int hc_get_irq_commands(182 irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size)183 {184 if (cmd_size < sizeof(ohci_irq_commands)185 || reg_size < sizeof(ohci_regs_t))186 return EOVERFLOW;187 188 /* Create register mapping to use in IRQ handler.189 * This mapping should be present in kernel only.190 * Remove it from here when kernel knows how to create mappings191 * and accepts physical addresses in IRQ code.192 * TODO: remove */193 ohci_regs_t *registers;194 const int ret = pio_enable((void*)regs, reg_size, (void**)®isters);195 196 /* Some bogus access to force create mapping. DO NOT remove,197 * unless whole virtual addresses in irq is replaced198 * NOTE: Compiler won't remove this as ohci_regs_t members199 * are declared volatile. */200 registers->revision;201 202 if (ret != EOK)203 return ret;204 205 memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands));206 207 void *address = (void*)®isters->interrupt_status;208 cmds[0].addr = address;209 cmds[3].addr = address;210 216 return EOK; 211 217 } … … 606 612 int ret = endpoint_list_init(&instance->lists[type], name); \ 607 613 if (ret != EOK) { \ 608 usb_log_error("Failed (%d) to setup %s endpoint list.\n", \609 ret, name); \614 usb_log_error("Failed to setup %s endpoint list: %s.\n", \ 615 name, str_error(ret)); \ 610 616 endpoint_list_fini(&instance->lists[USB_TRANSFER_ISOCHRONOUS]);\ 611 617 endpoint_list_fini(&instance->lists[USB_TRANSFER_INTERRUPT]); \
Note:
See TracChangeset
for help on using the changeset viewer.