Changeset 9600516 in mainline
- Timestamp:
- 2011-01-21T16:49:47Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 643b983
- Parents:
- 1062c8d
- Location:
- uspace/drv/uhci
- Files:
-
- 3 added
- 2 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci/callback.h
r1062c8d r9600516 1 2 1 /* 3 2 * Copyright (c) 2010 Jan Vesely … … 33 32 * @brief UHCI driver 34 33 */ 35 #ifndef DRV_UHCI_ QH_H36 #define DRV_UHCI_ QH_H34 #ifndef DRV_UHCI_CALLBACK_H 35 #define DRV_UHCI_CALLBACK_H 37 36 38 #include "link_ptr.h"37 #include <usbhc_iface.h> 39 38 40 typedef struct qh { 41 link_ptr_t 42 } __attribute__(("packed")) link_ptr_t; 39 typedef struct callback 40 { 41 union { 42 usbhc_iface_transfer_in_callback_t callback_in; 43 usbhc_iface_transfer_out_callback_t callback_out; 44 }; 45 void* buffer; 46 } callback_t; 43 47 44 48 #endif -
uspace/drv/uhci/uhci.c
r1062c8d r9600516 3 3 #include <usb/usb.h> 4 4 5 #include "translating_malloc.h" 6 5 7 #include "debug.h" 6 8 #include "name.h" 7 9 #include "uhci.h" 10 11 static int init_tranfer_lists(transfer_list_t list[]); 8 12 9 13 int uhci_init(device_t *device, void *regs) … … 26 30 if (ret < 0) { 27 31 free( instance ); 28 printf(NAME":Failed to gain access to registers at %p\n", io);32 uhci_print_error("Failed to gain access to registers at %p\n", io); 29 33 return ret; 30 34 } … … 32 36 33 37 /* init root hub */ 34 ret = uhci_root_hub_init( 35 (char*)regs + UHCI_ROOT_HUB_PORT_REGISTERS_OFFSET 38 ret = uhci_root_hub_init(&instance->root_hub, device, 39 (char*)regs + UHCI_ROOT_HUB_PORT_REGISTERS_OFFSET); 36 40 if (ret < 0) { 37 free( instance ); 38 printf(NAME": Failed to initialize root hub driver.\n"); 41 free(instance); 42 uhci_print_error("Failed to initialize root hub driver.\n"); 43 return ret; 44 } 45 46 instance->frame_list = trans_malloc(sizeof(frame_list_t)); 47 if (instance->frame_list == NULL) { 48 uhci_print_error("Failed to allocate frame list pointer.\n"); 49 uhci_root_hub_fini(&instance->root_hub); 50 free(instance); 51 return ENOMEM; 52 } 53 54 const uintptr_t pa = (uintptr_t)addr_to_phys(instance->frame_list); 55 56 pio_write_32(&instance->registers->flbaseadd, (uint32_t)pa); 57 58 ret = init_tranfer_lists(instance->transfers); 59 if (ret != EOK) { 60 uhci_print_error("Transfer list initialization failed.\n"); 61 uhci_root_hub_fini(&instance->root_hub); 62 free(instance); 39 63 return ret; 40 64 } 41 65 42 66 device->driver_data = instance; 67 return EOK; 68 } 69 /*----------------------------------------------------------------------------*/ 70 int init_tranfer_lists(transfer_list_t transfers[]) 71 { 72 //TODO:refactor 73 int ret; 74 ret = transfer_list_init(&transfers[USB_TRANSFER_BULK], NULL); 75 if (ret != EOK) { 76 uhci_print_error("Failed to inititalize bulk queue.\n"); 77 return ret; 78 } 79 80 ret = transfer_list_init( 81 &transfers[USB_TRANSFER_CONTROL], &transfers[USB_TRANSFER_BULK]); 82 if (ret != EOK) { 83 uhci_print_error("Failed to inititalize control queue.\n"); 84 transfer_list_fini(&transfers[USB_TRANSFER_BULK]); 85 return ret; 86 } 87 88 ret = transfer_list_init( 89 &transfers[USB_TRANSFER_INTERRUPT], &transfers[USB_TRANSFER_CONTROL]); 90 if (ret != EOK) { 91 uhci_print_error("Failed to interrupt control queue.\n"); 92 transfer_list_fini(&transfers[USB_TRANSFER_CONTROL]); 93 transfer_list_fini(&transfers[USB_TRANSFER_BULK]); 94 return ret; 95 } 96 43 97 return EOK; 44 98 } -
uspace/drv/uhci/uhci.h
r1062c8d r9600516 42 42 43 43 #include "root_hub/root_hub.h" 44 #include "uhci_struct/frame_list.h" 45 #include "transfer_list.h" 46 44 47 45 48 typedef struct uhci_regs { … … 52 55 } regs_t; 53 56 57 #define TRANSFER_QUEUES 4 58 54 59 typedef struct uhci { 55 60 usb_address_keeping_t address_manager; 56 61 uhci_root_hub_t root_hub; 57 volatile regs_t* registers; 58 } uhci_t ; 62 volatile regs_t *registers; 63 64 frame_list_t *frame_list; 65 66 transfer_list_t transfers[TRANSFER_QUEUES]; 67 } uhci_t; 59 68 60 69 /* init uhci specifics in device.driver_data */ -
uspace/drv/uhci/uhci_struct/frame_list.h
r1062c8d r9600516 32 32 * @brief UHCI driver 33 33 */ 34 #ifndef DRV_UHCI_ LINK_PTR_H35 #define DRV_UHCI_ LINK_PTR_H34 #ifndef DRV_UHCI_FRAME_LIST_H 35 #define DRV_UHCI_FRAME_LIST_H 36 36 37 #include " td_ptr.h"37 #include "link_pointer.h" 38 38 39 /** Links in Frame List */ 40 typedef td_ptr_t link_ptr_t; 39 #define UHCI_FRAME_LIST_COUNT 1024 41 40 41 typedef link_pointer_t frame_list_t[UHCI_FRAME_LIST_COUNT]; 42 42 #endif 43 43 /** -
uspace/drv/uhci/uhci_struct/link_pointer.h
r1062c8d r9600516 32 32 * @brief UHCI driver 33 33 */ 34 #ifndef DRV_UHCI_ TD_PTR_H35 #define DRV_UHCI_ TD_PTR_H34 #ifndef DRV_UHCI_LINK_POINTER_H 35 #define DRV_UHCI_LINK_POINTER_H 36 36 37 /** UHCI Transfer Descriptor pointer */ 38 typedef struct td_ptr { 39 uint32_t fpl:28; 40 char :2; 37 /* UHCI link pointer, used by many data structures */ 38 typedef struct link_pointer { 39 uint32_t addr:28; 40 uint8_t zero:1; 41 uint8_t reserved:1; 41 42 uint8_t qh:1; 42 43 uint8_t terminate:1; 43 } __attribute__(( "packed")) td_ptr_t;44 } __attribute__((packed)) link_pointer_t; 44 45 45 46 #endif … … 47 48 * @} 48 49 */ 50 -
uspace/drv/uhci/uhci_struct/transfer_descriptor.h
r1062c8d r9600516 32 32 * @brief UHCI driver 33 33 */ 34 #ifndef DRV_UHCI_TRANSFER_H 35 #define DRV_UHCI_TRANSFER_H 34 #ifndef DRV_UHCI_TRANSFER_DESCRIPTOR_H 35 #define DRV_UHCI_TRANSFER_DESCRIPTOR_H 36 37 #include "callback.h" 36 38 37 39 /** Status field in UHCI Transfer Descriptor (TD) */ … … 45 47 uint8_t bitstuff:1; 46 48 uint8_t :1; /* reserved */ 47 } status_t 49 } status_t; 48 50 49 51 /** UHCI Transfer Descriptor */ 50 typedef struct t d{52 typedef struct transfer_descriptor { 51 53 uint32_t fpl:28; 52 54 char :1; /* reserved */ … … 73 75 74 76 uint32_t buffer_ptr; 75 } __attribute__(("packed")) td_t;76 77 78 /* there is 16 byte of data available here 79 * those are used to store callback pointer 80 * and next pointer. Thus there is some free space 81 * on 32bits systems. 82 */ 83 struct transfer_descriptor *next; 84 callback_t *callback; 85 } __attribute__((packed)) transfer_descriptor_t; 77 86 78 87 #endif
Note:
See TracChangeset
for help on using the changeset viewer.