Changeset 77d10f0 in mainline
- Timestamp:
- 2011-04-22T21:29:57Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- af81980
- Parents:
- 6f122df
- Location:
- uspace/drv/uhci-hcd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/hc.c
r6f122df r77d10f0 44 44 #include "hc.h" 45 45 46 static irq_cmd_t uhci_cmds[] = {47 {48 .cmd = CMD_PIO_READ_16,49 .addr = NULL, /* patched for every instance */50 .dstarg = 151 },52 {53 .cmd = CMD_PIO_WRITE_16,54 .addr = NULL, /* pathed for every instance */55 .value = 0x1f56 },57 {58 .cmd = CMD_ACCEPT59 }60 };61 /*----------------------------------------------------------------------------*/62 46 static int hc_init_transfer_lists(hc_t *instance); 63 47 static int hc_init_mem_structures(hc_t *instance); … … 177 161 { 178 162 assert(instance); 179 #define CHECK_RET_ DEST_CMDS_RETURN(ret, message...) \163 #define CHECK_RET_RETURN(ret, message...) \ 180 164 if (ret != EOK) { \ 181 165 usb_log_error(message); \ 182 if (instance->interrupt_code.cmds != NULL) \183 free(instance->interrupt_code.cmds); \184 166 return ret; \ 185 167 } else (void) 0 186 168 187 169 /* Init interrupt code */ 188 instance->interrupt_code.cmds = malloc(sizeof(uhci_cmds)); 189 int ret = (instance->interrupt_code.cmds == NULL) ? ENOMEM : EOK; 190 CHECK_RET_DEST_CMDS_RETURN(ret, 191 "Failed to allocate interrupt cmds space.\n"); 192 170 instance->interrupt_code.cmds = instance->interrupt_commands; 193 171 { 194 irq_cmd_t *interrupt_commands = instance->interrupt_code.cmds; 195 memcpy(interrupt_commands, uhci_cmds, sizeof(uhci_cmds)); 196 interrupt_commands[0].addr = 197 (void*)&instance->registers->usbsts; 198 interrupt_commands[1].addr = 199 (void*)&instance->registers->usbsts; 200 instance->interrupt_code.cmdcount = 201 sizeof(uhci_cmds) / sizeof(irq_cmd_t); 172 instance->interrupt_commands[0].cmd = CMD_PIO_READ_16; 173 instance->interrupt_commands[0].dstarg = 1; 174 instance->interrupt_commands[0].addr = 175 &instance->registers->usbsts; 176 177 instance->interrupt_commands[1].cmd = CMD_PIO_WRITE_16; 178 instance->interrupt_commands[1].value = 0x1f; 179 instance->interrupt_commands[1].addr = 180 &instance->registers->usbsts; 181 182 instance->interrupt_commands[2].cmd = CMD_ACCEPT; 183 instance->interrupt_code.cmdcount = UHCI_NEEDED_IRQ_COMMANDS; 202 184 } 203 185 204 186 /* Init transfer lists */ 205 ret = hc_init_transfer_lists(instance);206 CHECK_RET_ DEST_CMDS_RETURN(ret, "Failed to init transfer lists.\n");187 int ret = hc_init_transfer_lists(instance); 188 CHECK_RET_RETURN(ret, "Failed to init transfer lists.\n"); 207 189 usb_log_debug("Initialized transfer lists.\n"); 208 190 … … 210 192 instance->frame_list = get_page(); 211 193 ret = instance ? EOK : ENOMEM; 212 CHECK_RET_ DEST_CMDS_RETURN(ret, "Failed to get frame list page.\n");194 CHECK_RET_RETURN(ret, "Failed to get frame list page.\n"); 213 195 usb_log_debug("Initialized frame list at %p.\n", instance->frame_list); 214 196 … … 229 211 ret = usb_endpoint_manager_init(&instance->ep_manager, 230 212 BANDWIDTH_AVAILABLE_USB11); 231 assert(ret == EOK); 232 233 return EOK; 234 #undef CHECK_RET_DEST_CMDS_RETURN 213 CHECK_RET_RETURN(ret, "Failed to initialize endpoint manager: %s.\n", 214 str_error(ret)); 215 216 return EOK; 217 #undef CHECK_RET_RETURN 235 218 } 236 219 /*----------------------------------------------------------------------------*/ -
uspace/drv/uhci-hcd/hc.h
r6f122df r77d10f0 91 91 #define UHCI_DEBUGER_TIMEOUT 5000000 92 92 #define UHCI_ALLOWED_HW_FAIL 5 93 #define UHCI_NEEDED_IRQ_COMMANDS 3 93 94 94 95 /* Main HC driver structure */ … … 119 120 /** Code to be executed in kernel interrupt handler */ 120 121 irq_code_t interrupt_code; 122 123 /** Commands that form interrupt code */ 124 irq_cmd_t interrupt_commands[UHCI_NEEDED_IRQ_COMMANDS]; 121 125 122 126 /** Fibril periodically checking status register*/
Note:
See TracChangeset
for help on using the changeset viewer.