Changes in uspace/drv/bus/usb/ohci/hc.c [d57122c:0cd8089] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
rd57122c r0cd8089 47 47 (I_SO | I_WDH | I_UE | I_RHSC) 48 48 49 static const irq_pio_range_t ohci_pio_ranges[] = { 50 { 51 .base = 0, /* filled later */ 52 .size = sizeof(ohci_regs_t) 53 } 54 }; 55 56 static const irq_cmd_t ohci_irq_commands[] = { 57 { .cmd = CMD_PIO_READ_32, .dstarg = 1, .addr = NULL /* filled later */ }, 49 static const irq_cmd_t ohci_irq_commands[] = 50 { 51 { .cmd = CMD_MEM_READ_32, .dstarg = 1, .addr = NULL /*filled later*/ }, 58 52 { .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2, .value = OHCI_USED_INTERRUPTS }, 59 53 { .cmd = CMD_PREDICATE, .srcarg = 2, .value = 2 }, 60 { .cmd = CMD_ PIO_WRITE_A_32, .srcarg = 1, .addr = NULL /* filled later*/ },54 { .cmd = CMD_MEM_WRITE_A_32, .srcarg = 1, .addr = NULL /*filled later*/ }, 61 55 { .cmd = CMD_ACCEPT }, 62 56 }; … … 69 63 static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch); 70 64 /*----------------------------------------------------------------------------*/ 71 /** Get number of PIO ranges used in IRQ code.72 * @return Number of ranges.73 */74 size_t hc_irq_pio_range_count(void)75 {76 return sizeof(ohci_pio_ranges) / sizeof(irq_pio_range_t);77 }78 /*----------------------------------------------------------------------------*/79 /*----------------------------------------------------------------------------*/80 65 /** Get number of commands used in IRQ code. 81 66 * @return Number of commands. … … 86 71 } 87 72 /*----------------------------------------------------------------------------*/ 88 /** Generate IRQ code. 89 * @param[out] ranges PIO ranges buffer. 90 * @param[in] ranges_size Size of the ranges buffer (bytes). 91 * @param[out] cmds Commands buffer. 92 * @param[in] cmds_size Size of the commands buffer (bytes). 73 /** Generate IRQ code commands. 74 * @param[out] cmds Place to store the commands. 75 * @param[in] cmd_size Size of the place (bytes). 93 76 * @param[in] regs Physical address of device's registers. 94 77 * @param[in] reg_size Size of the register area (bytes). … … 96 79 * @return Error code. 97 80 */ 98 int 99 hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[], 100 size_t cmds_size, uintptr_t regs, size_t reg_size) 101 { 102 if ((ranges_size < sizeof(ohci_pio_ranges)) || 103 (cmds_size < sizeof(ohci_irq_commands)) || 104 (reg_size < sizeof(ohci_regs_t))) 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)) 105 86 return EOVERFLOW; 106 87 107 memcpy(ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges)); 108 ranges[0].base = regs; 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 if (ret != EOK) 96 return ret; 97 98 /* Some bogus access to force create mapping. DO NOT remove, 99 * unless whole virtual addresses in irq is replaced 100 * NOTE: Compiler won't remove this as ohci_regs_t members 101 * are declared volatile. 102 * 103 * Introducing CMD_MEM set of IRQ code commands broke 104 * assumption that IRQ code does not cause page faults. 105 * If this happens during idling (THREAD == NULL) 106 * it causes kernel panic. 107 */ 108 registers->revision; 109 109 110 110 memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands)); 111 ohci_regs_t *registers = (ohci_regs_t *) regs; 112 cmds[0].addr = (void *)®isters->interrupt_status;113 cmds[ 3].addr = (void *) ®isters->interrupt_status;114 111 112 void *address = (void*)®isters->interrupt_status; 113 cmds[0].addr = address; 114 cmds[3].addr = address; 115 115 return EOK; 116 116 } … … 137 137 return ret; 138 138 } 139 usb_device_manager_bind_address(&instance->generic.dev_manager, 140 instance->rh.address, hub_fun->handle); 139 141 140 142 #define CHECK_RET_UNREG_RETURN(ret, message...) \ … … 148 150 return ret; \ 149 151 } else (void)0 150 151 152 ret = usb_endpoint_manager_add_ep( 152 153 &instance->generic.ep_manager, instance->rh.address, 0, … … 164 165 CHECK_RET_UNREG_RETURN(ret, 165 166 "Failed to bind root hub function: %s.\n", str_error(ret)); 166 167 ret = usb_device_manager_bind_address(&instance->generic.dev_manager,168 instance->rh.address, hub_fun->handle);169 if (ret != EOK)170 usb_log_warning("Failed to bind root hub address: %s.\n",171 str_error(ret));172 167 173 168 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.