Changeset b9d910f in mainline
- Timestamp:
- 2011-02-19T23:02:49Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fb78ae72
- Parents:
- 6edc69a
- Location:
- uspace/drv/uhci-hcd
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/main.c
r6edc69a rb9d910f 80 80 }; 81 81 /*----------------------------------------------------------------------------*/ 82 static irq_cmd_t uhci_cmds[] = {83 {84 .cmd = CMD_PIO_READ_16,85 .addr = (void*)0xc022,86 .dstarg = 187 },88 {89 .cmd = CMD_PIO_WRITE_16,90 .addr = (void*)0xc022,91 .value = 0x1f92 },93 {94 .cmd = CMD_ACCEPT95 }96 };97 /*----------------------------------------------------------------------------*/98 static irq_code_t uhci_code = {99 sizeof(uhci_cmds) / sizeof(irq_cmd_t),100 uhci_cmds101 };102 /*----------------------------------------------------------------------------*/103 82 static void irq_handler(device_t *device, ipc_callid_t iid, ipc_call_t *call) 104 83 { … … 111 90 } 112 91 /*----------------------------------------------------------------------------*/ 92 #define CHECK_RET_RETURN(ret, message...) \ 93 if (ret != EOK) { \ 94 usb_log_error(message); \ 95 return ret; \ 96 } 97 113 98 static int uhci_add_device(device_t *device) 114 99 { … … 125 110 pci_get_my_registers(device, &io_reg_base, &io_reg_size, &irq); 126 111 127 if (ret != EOK) { 128 usb_log_error( 129 "Failed(%d) to get I/O registers addresses for device:.\n", 130 ret, device->handle); 131 return ret; 132 } 133 112 CHECK_RET_RETURN(ret, 113 "Failed(%d) to get I/O registers addresses for device:.\n", 114 ret, device->handle); 134 115 usb_log_info("I/O regs at 0x%X (size %zu), IRQ %d.\n", 135 116 io_reg_base, io_reg_size, irq); … … 158 139 async_hangup(irc_phone); 159 140 160 ret = register_interrupt_handler(device, irq, irq_handler, &uhci_code);161 usb_log_debug("Registered interrupt handler %d.\n", ret);162 141 163 142 uhci_t *uhci_hc = malloc(sizeof(uhci_t)); 164 if (!uhci_hc) { 165 usb_log_error("Failed to allocate memory for uhci hcd driver.\n"); 166 return ENOMEM; 167 } 143 ret = (uhci_hc != NULL) ? EOK : ENOMEM; 144 CHECK_RET_RETURN(ret, "Failed to allocate memory for uhci hcd driver.\n"); 168 145 169 146 ret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size); 170 147 if (ret != EOK) { 171 148 usb_log_error("Failed to init uhci-hcd.\n"); 149 free(uhci_hc); 172 150 return ret; 173 151 } 152 153 ret = register_interrupt_handler(device, irq, irq_handler, 154 &uhci_hc->interrupt_code); 155 if (ret != EOK) { 156 usb_log_error("Failed to register interrupt handler.\n"); 157 uhci_fini(uhci_hc); 158 free(uhci_hc); 159 return ret; 160 } 161 174 162 device_t *rh; 175 163 ret = setup_root_hub(&rh, device); 176 164 if (ret != EOK) { 177 165 usb_log_error("Failed to setup uhci root hub.\n"); 178 /* TODO: destroy uhci here */ 166 uhci_fini(uhci_hc); 167 free(uhci_hc); 179 168 return ret; 180 169 } … … 183 172 if (ret != EOK) { 184 173 usb_log_error("Failed to register root hub.\n"); 185 /* TODO: destroy uhci here */ 174 uhci_fini(uhci_hc); 175 free(uhci_hc); 176 free(rh); 186 177 return ret; 187 178 } 188 179 189 180 device->driver_data = uhci_hc; 190 191 181 return EOK; 192 182 } -
uspace/drv/uhci-hcd/uhci.c
r6edc69a rb9d910f 39 39 40 40 #include "uhci.h" 41 static irq_cmd_t uhci_cmds[] = { 42 { 43 .cmd = CMD_PIO_READ_16, 44 .addr = (void*)0xc022, 45 .dstarg = 1 46 }, 47 { 48 .cmd = CMD_PIO_WRITE_16, 49 .addr = (void*)0xc022, 50 .value = 0x1f 51 }, 52 { 53 .cmd = CMD_ACCEPT 54 } 55 }; 41 56 42 57 static int uhci_init_transfer_lists(uhci_t *instance); … … 101 116 { 102 117 assert(instance); 118 119 /* init interrupt code */ 120 irq_cmd_t *interrupt_commands = malloc(sizeof(uhci_cmds)); 121 if (interrupt_commands == NULL) { 122 return ENOMEM; 123 } 124 memcpy(interrupt_commands, uhci_cmds, sizeof(uhci_cmds)); 125 interrupt_commands[0].addr = (void*)&instance->registers->usbsts; 126 interrupt_commands[1].addr = (void*)&instance->registers->usbsts; 127 instance->interrupt_code.cmds = interrupt_commands; 128 instance->interrupt_code.cmdcount = 129 sizeof(uhci_cmds) / sizeof(irq_cmd_t); 130 103 131 /* init transfer lists */ 104 132 int ret = uhci_init_transfer_lists(instance); -
uspace/drv/uhci-hcd/uhci.h
r6edc69a rb9d910f 93 93 transfer_list_t *transfers[2][4]; 94 94 95 irq_code_t interrupt_code; 96 95 97 fid_t cleaner; 96 98 fid_t debug_checker; … … 100 102 int uhci_init(uhci_t *instance, void *regs, size_t reg_size); 101 103 102 int uhci_fini(uhci_t *device);104 static inline void uhci_fini(uhci_t *instance) {}; 103 105 104 106 int uhci_transfer( … … 122 124 { return (uhci_t*)dev->driver_data; } 123 125 126 124 127 #endif 125 128 /**
Note:
See TracChangeset
for help on using the changeset viewer.