Changeset 5944244 in mainline for uspace/drv/uhci-hcd/uhci.c
- Timestamp:
- 2011-02-01T23:25:48Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f5c1e61
- Parents:
- c56dbe0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/uhci.c
rc56dbe0 r5944244 37 37 #include <usb/usb.h> 38 38 39 #include "utils/malloc32.h"40 39 #include "uhci.h" 41 40 … … 44 43 static int uhci_debug_checker(void *arg); 45 44 46 int uhci_init(device_t *device, void *regs, size_t reg_size) 47 { 48 assert(device); 49 usb_log_info("Initializing device at address %p.\n", device); 50 51 #define CHECK_RET_FREE_INSTANCE(message...) \ 45 int uhci_init(uhci_t *instance, void *regs, size_t reg_size) 46 { 47 #define CHECK_RET_RETURN(message...) \ 52 48 if (ret != EOK) { \ 53 49 usb_log_error(message); \ 54 if (instance) { \55 free(instance); \56 } \57 50 return ret; \ 58 51 } else (void) 0 59 60 /* create instance */61 uhci_t *instance = malloc(sizeof(uhci_t));62 int ret = instance ? EOK : ENOMEM;63 CHECK_RET_FREE_INSTANCE("Failed to allocate uhci driver instance.\n");64 65 bzero(instance, sizeof(uhci_t));66 52 67 53 /* init address keeper(libusb) */ … … 72 58 regs_t *io; 73 59 assert(reg_size >= sizeof(regs_t)); 74 ret = pio_enable(regs, reg_size, (void**)&io);75 CHECK_RET_ FREE_INSTANCE("Failed to gain access to registers at %p.\n", io);60 int ret = pio_enable(regs, reg_size, (void**)&io); 61 CHECK_RET_RETURN("Failed to gain access to registers at %p.\n", io); 76 62 instance->registers = io; 77 63 usb_log_debug("Device registers accessible.\n"); … … 79 65 /* init transfer lists */ 80 66 ret = uhci_init_transfer_lists(instance->transfers); 81 CHECK_RET_ FREE_INSTANCE("Failed to initialize transfer lists.\n");67 CHECK_RET_RETURN("Failed to initialize transfer lists.\n"); 82 68 usb_log_debug("Transfer lists initialized.\n"); 83 69 … … 86 72 instance->frame_list = get_page(); 87 73 ret = instance ? EOK : ENOMEM; 88 CHECK_RET_ FREE_INSTANCE("Failed to get frame list page.\n");74 CHECK_RET_RETURN("Failed to get frame list page.\n"); 89 75 90 76 /* initialize all frames to point to the first queue head */ 91 unsigned i = 0;92 77 const uint32_t queue = 93 78 instance->transfers[USB_TRANSFER_INTERRUPT].queue_head_pa 94 79 | LINK_POINTER_QUEUE_HEAD_FLAG; 80 unsigned i = 0; 95 81 for(; i < UHCI_FRAME_LIST_COUNT; ++i) { 96 82 instance->frame_list[i] = queue; … … 107 93 fibril_add_ready(instance->debug_checker); 108 94 109 usb_log_debug("Starting UHCI HC.\n"); 110 pio_write_16(&instance->registers->usbcmd, UHCI_CMD_RUN_STOP); 95 /* Start the hc with large(64b) packet FSBR */ 96 pio_write_16(&instance->registers->usbcmd, 97 UHCI_CMD_RUN_STOP | UHCI_CMD_MAX_PACKET); 98 usb_log_debug("Started UHCI HC.\n"); 111 99 /* 112 100 uint16_t cmd = pio_read_16(&instance->registers->usbcmd); … … 114 102 pio_write_16(&instance->registers->usbcmd, cmd); 115 103 */ 116 device->driver_data = instance;117 104 return EOK; 118 105 } … … 152 139 /*----------------------------------------------------------------------------*/ 153 140 int uhci_transfer( 141 uhci_t *instance, 154 142 device_t *dev, 155 143 usb_target_t target, … … 172 160 callback_t *job = NULL; 173 161 int ret = EOK; 162 assert(dev); 174 163 175 164 #define CHECK_RET_TRANS_FREE_JOB_TD(message) \ … … 183 172 } else (void) 0 184 173 185 186 174 job = callback_get(dev, buffer, size, callback_in, callback_out, arg); 187 175 ret = job ? EOK : ENOMEM; … … 193 181 194 182 td->callback = job; 195 196 assert(dev);197 uhci_t *instance = (uhci_t*)dev->driver_data;198 assert(instance);199 183 200 184 usb_log_debug("Appending a new transfer to queue.\n");
Note:
See TracChangeset
for help on using the changeset viewer.