Changeset 9ee87f6 in mainline
- Timestamp:
- 2011-01-25T22:51:08Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7fc092a
- Parents:
- d03ade7
- Location:
- uspace/drv/uhci
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci/uhci.c
rd03ade7 r9ee87f6 9 9 #include "uhci.h" 10 10 11 static int uhci_init_tran fer_lists(transfer_list_t list[]);12 11 static int uhci_init_transfer_lists(transfer_list_t list[]); 12 static int uhci_clean_finished(void *arg); 13 13 static inline int uhci_add_transfer( 14 14 device_t *dev, … … 23 23 int uhci_init(device_t *device, void *regs) 24 24 { 25 assert( device ); 26 uhci_print_info( "Initializing device at address %p\n", device); 25 assert(device); 26 uhci_print_info("Initializing device at address %p.\n", device); 27 28 #define CHECK_RET_FREE_INSTANCE(message...) \ 29 if (ret != EOK) { \ 30 uhci_print_error(message); \ 31 if (instance) { \ 32 free(instance); \ 33 } \ 34 return ret; \ 35 } else (void) 0 27 36 28 37 /* create instance */ 29 38 uhci_t *instance = malloc( sizeof(uhci_t) ); 30 if (!instance) 31 { return ENOMEM; } 32 bzero( instance, sizeof(uhci_t) ); 39 int ret = instance ? EOK : ENOMEM; 40 CHECK_RET_FREE_INSTANCE("Failed to allocate uhci driver instance.\n"); 41 42 bzero(instance, sizeof(uhci_t)); 33 43 34 44 /* init address keeper(libusb) */ 35 usb_address_keeping_init( &instance->address_manager, USB11_ADDRESS_MAX);45 usb_address_keeping_init(&instance->address_manager, USB11_ADDRESS_MAX); 36 46 37 47 /* allow access to hc control registers */ 38 48 regs_t *io; 39 int ret = pio_enable( regs, sizeof(regs_t), (void**)&io); 40 if (ret < 0) { 41 free( instance ); 42 uhci_print_error("Failed to gain access to registers at %p\n", io); 43 return ret; 44 } 49 ret = pio_enable(regs, sizeof(regs_t), (void**)&io); 50 CHECK_RET_FREE_INSTANCE("Failed to gain access to registers at %p.\n", io); 45 51 instance->registers = io; 52 53 /* init transfer lists */ 54 ret = uhci_init_transfer_lists(instance->transfers); 55 CHECK_RET_FREE_INSTANCE("Failed to initialize transfer lists.\n"); 46 56 47 57 /* init root hub */ 48 58 ret = uhci_root_hub_init(&instance->root_hub, device, 49 59 (char*)regs + UHCI_ROOT_HUB_PORT_REGISTERS_OFFSET); 50 if (ret < 0) { 51 free(instance); 52 uhci_print_error("Failed to initialize root hub driver.\n"); 53 return ret; 54 } 55 56 instance->frame_list = trans_malloc(sizeof(frame_list_t)); 60 CHECK_RET_FREE_INSTANCE("Failed to initialize root hub driver.\n"); 61 62 instance->frame_list = 63 trans_malloc(sizeof(link_pointer_t) * UHCI_FRAME_LIST_COUNT); 57 64 if (instance->frame_list == NULL) { 58 65 uhci_print_error("Failed to allocate frame list pointer.\n"); … … 62 69 } 63 70 71 /* initialize all frames to point to the first queue head */ 72 unsigned i = 0; 73 const uint32_t queue = 74 instance->transfers[USB_TRANSFER_INTERRUPT].queue_head_pa 75 | LINK_POINTER_QUEUE_HEAD_FLAG; 76 for(; i < UHCI_FRAME_LIST_COUNT; ++i) { 77 instance->frame_list[i] = queue; 78 } 79 64 80 const uintptr_t pa = (uintptr_t)addr_to_phys(instance->frame_list); 65 81 66 82 pio_write_32(&instance->registers->flbaseadd, (uint32_t)pa); 67 83 68 ret = uhci_init_tranfer_lists(instance->transfers); 69 if (ret != EOK) { 70 uhci_print_error("Transfer list initialization failed.\n"); 71 uhci_root_hub_fini(&instance->root_hub); 72 free(instance); 73 return ret; 74 } 84 instance->cleaner = fibril_create(uhci_clean_finished, instance); 85 fibril_add_ready(instance->cleaner); 75 86 76 87 device->driver_data = instance; … … 129 140 } 130 141 /*----------------------------------------------------------------------------*/ 131 int uhci_init_tran fer_lists(transfer_list_t transfers[])142 int uhci_init_transfer_lists(transfer_list_t transfers[]) 132 143 { 133 144 //TODO:refactor … … 220 231 return EOK; 221 232 } 233 /*----------------------------------------------------------------------------*/ 234 int uhci_clean_finished(void* arg) 235 { 236 uhci_print_verbose("Started cleaning fibril.\n"); 237 uhci_t *instance = (uhci_t*)arg; 238 assert(instance); 239 while(1) { 240 uhci_print_verbose("Running cleaning fibril on %p.\n", instance); 241 242 async_usleep(1000000); 243 } 244 return EOK; 245 } -
uspace/drv/uhci/uhci.h
rd03ade7 r9ee87f6 42 42 43 43 #include "root_hub/root_hub.h" 44 #include "uhci_struct/frame_list.h"45 44 #include "transfer_list.h" 46 47 45 48 46 typedef struct uhci_regs { … … 56 54 57 55 #define TRANSFER_QUEUES 4 56 #define UHCI_FRAME_LIST_COUNT 1024 58 57 59 58 typedef struct uhci { … … 62 61 volatile regs_t *registers; 63 62 64 frame_list_t *frame_list;63 link_pointer_t *frame_list; 65 64 66 65 transfer_list_t transfers[TRANSFER_QUEUES]; 66 fid_t cleaner; 67 67 } uhci_t; 68 68
Note:
See TracChangeset
for help on using the changeset viewer.