Changeset 89a0485a in mainline
- Timestamp:
- 2011-01-25T20:44:28Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b00163f
- Parents:
- 7977fa1
- Location:
- uspace/drv/uhci
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci/Makefile
r7977fa1 r89a0485a 33 33 34 34 SOURCES = \ 35 callback.c \ 35 36 iface.c \ 36 37 main.c \ … … 38 39 root_hub/port_status.c \ 39 40 root_hub/root_hub.c \ 41 transfer_list.c \ 40 42 uhci.c 41 43 -
uspace/drv/uhci/callback.h
r7977fa1 r89a0485a 53 53 54 54 55 static inlineint callback_init(callback_t *instance, device_t *dev,55 int callback_init(callback_t *instance, device_t *dev, 56 56 void *buffer, size_t size, usbhc_iface_transfer_in_callback_t func_in, 57 usbhc_iface_transfer_out_callback_t func_out, void *arg) 58 { 59 assert(instance); 60 assert(func_in == NULL || func_out == NULL); 61 instance->new_buffer = trans_malloc(size); 62 if (!instance->new_buffer) { 63 uhci_print_error("Failed to allocate device acessible buffer.\n"); 64 return ENOMEM; 65 } 57 usbhc_iface_transfer_out_callback_t func_out, void *arg); 66 58 67 if (func_out)68 memcpy(instance->new_buffer, buffer, size);69 70 instance->callback_out = func_out;71 instance->callback_in = func_in;72 instance->old_buffer = buffer;73 instance->buffer_size = size;74 instance->dev = dev;75 return EOK;76 }77 59 #define callback_in_init(instance, dev, buffer, size, func, arg) \ 78 60 callback_init(instance, dev, buffer, size, func, NULL, arg) -
uspace/drv/uhci/transfer_list.h
r7977fa1 r89a0485a 48 48 } transfer_list_t; 49 49 50 static inline int transfer_list_init( 51 transfer_list_t *instance, transfer_list_t *next) 52 { 53 assert(instance); 54 instance->first = NULL; 55 instance->last = NULL; 56 instance->queue_head = trans_malloc(sizeof(queue_head_t)); 57 if (!instance->queue_head) { 58 uhci_print_error("Failed to allocate queue head.\n"); 59 return ENOMEM; 60 } 61 instance->queue_head_pa = (uintptr_t)addr_to_phys(instance->queue_head); 62 63 uint32_t next_pa = next ? next->queue_head_pa : 0; 64 queue_head_init(instance->queue_head, next_pa); 65 return EOK; 66 } 50 int transfer_list_init(transfer_list_t *instance, transfer_list_t *next); 67 51 68 52 static inline void transfer_list_fini(transfer_list_t *instance) … … 73 57 } 74 58 59 int transfer_list_append( 60 transfer_list_t *instance, transfer_descriptor_t *transfer); 61 75 62 #endif 76 63 /** -
uspace/drv/uhci/uhci.c
r7977fa1 r89a0485a 22 22 if (!instance) 23 23 { return ENOMEM; } 24 memset( instance, 0, sizeof(uhci_t) );24 bzero( instance, sizeof(uhci_t) ); 25 25 26 26 /* init address keeper(libusb) */ … … 86 86 return ENOTSUP; 87 87 88 callback_t *job = malloc(sizeof(callback_t)); 89 if (job == NULL) { 90 uhci_print_error("Failed to allocate callback structure.\n"); 91 return ENOMEM; 92 } 88 transfer_descriptor_t *td = NULL; 89 callback_t *job = NULL; 90 int ret = EOK; 93 91 94 #define CHECK_RET_ FREE_JOB(r,message) \95 if (r != EOK) { \92 #define CHECK_RET_TRANS_FREE_JOB_TD(message) \ 93 if (ret != EOK) { \ 96 94 uhci_print_error(message); \ 97 callback_fini(job); \ 98 trans_free(job); \ 99 return r; \ 95 if (job) { \ 96 callback_fini(job); \ 97 trans_free(job); \ 98 } \ 99 if (td) { trans_free(td); } \ 100 return ret; \ 100 101 } else (void) 0 101 102 102 int ret = callback_in_init(job, dev, buffer, size, callback, arg);103 CHECK_RET_FREE_JOB(ret, "Failed to initialize callback structure.\n");104 103 105 transfer_descriptor_t *td = trans_malloc(sizeof(transfer_descriptor_t)); 106 ret = (td == NULL) ? ENOMEM : EOK; 107 CHECK_RET_FREE_JOB(ret, "Failed to allocate tranfer descriptor.\n"); 104 job = malloc(sizeof(callback_t)); 105 ret= job ? EOK : ENOMEM; 106 CHECK_RET_TRANS_FREE_JOB_TD("Failed to allocate callback structure.\n"); 107 108 ret = callback_in_init(job, dev, buffer, size, callback, arg); 109 CHECK_RET_TRANS_FREE_JOB_TD("Failed to initialize callback structure.\n"); 110 111 td = trans_malloc(sizeof(transfer_descriptor_t)); 112 ret = td ? ENOMEM : EOK; 113 CHECK_RET_TRANS_FREE_JOB_TD("Failed to allocate tranfer descriptor.\n"); 108 114 109 115 ret = transfer_descriptor_init(td, 3, size, false, target, USB_PID_IN); 110 if (ret != EOK) { 111 uhci_print_error("Failed to initialize transfer descriptor.\n"); 112 trans_free(td); 113 trans_free(job); 114 return ret; 115 } 116 CHECK_RET_TRANS_FREE_JOB_TD("Failed to initialize transfer descriptor.\n"); 117 116 118 td->callback = job; 117 119 120 assert(dev); 121 uhci_t *instance = (uhci_t*)dev->driver_data; 122 assert(instance); 118 123 119 // TODO: add to list120 // callback(dev, USB_OUTCOME_OK, size, arg);124 ret = transfer_list_append(&instance->transfers[transfer_type], td); 125 CHECK_RET_TRANS_FREE_JOB_TD("Failed to append transfer descriptor.\n"); 121 126 122 127 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.