Changeset e42dd32 in mainline
- Timestamp:
- 2011-04-08T23:28:52Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1be95c8
- Parents:
- b854e56
- Location:
- uspace/drv/ohci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/batch.c
rb854e56 re42dd32 49 49 } ohci_batch_t; 50 50 51 static void batch_control(usb_transfer_batch_t *instance); 51 static void batch_control(usb_transfer_batch_t *instance, 52 usb_direction_t data_dir, usb_direction_t status_dir); 52 53 static void batch_call_in_and_dispose(usb_transfer_batch_t *instance); 53 54 static void batch_call_out_and_dispose(usb_transfer_batch_t *instance); … … 135 136 instance->buffer_size); 136 137 instance->next_step = batch_call_out_and_dispose; 137 batch_control(instance );138 batch_control(instance, USB_DIRECTION_OUT, USB_DIRECTION_IN); 138 139 usb_log_debug("Batch(%p) CONTROL WRITE initialized.\n", instance); 139 140 } … … 143 144 assert(instance); 144 145 instance->next_step = batch_call_in_and_dispose; 145 batch_control(instance );146 batch_control(instance, USB_DIRECTION_IN, USB_DIRECTION_OUT); 146 147 usb_log_debug("Batch(%p) CONTROL READ initialized.\n", instance); 147 148 } … … 194 195 } 195 196 /*----------------------------------------------------------------------------*/ 196 static void batch_control(usb_transfer_batch_t *instance) 197 void batch_control(usb_transfer_batch_t *instance, 198 usb_direction_t data_dir, usb_direction_t status_dir) 197 199 { 198 200 assert(instance); … … 200 202 assert(data); 201 203 ed_init(data->ed, instance->ep); 204 ed_add_tds(data->ed, &data->tds[0], &data->tds[data->td_count - 1]); 205 usb_log_debug("Created ED: %x:%x:%x:%x.\n", data->ed->status, 206 data->ed->td_tail, data->ed->td_head, data->ed->next); 207 int toggle = 0; 208 /* setup stage */ 209 td_init(&data->tds[0], USB_DIRECTION_BOTH, instance->setup_buffer, 210 instance->setup_size, toggle); 211 td_set_next(&data->tds[0], &data->tds[1]); 212 usb_log_debug("Created SETUP TD: %x:%x:%x:%x.\n", data->tds[0].status, 213 data->tds[0].cbp, data->tds[0].next, data->tds[0].be); 214 215 /* data stage */ 216 size_t td_current = 1; 217 size_t remain_size = instance->buffer_size; 218 char *transfer_buffer = instance->transport_buffer; 219 while (remain_size > 0) { 220 size_t transfer_size = remain_size > OHCI_TD_MAX_TRANSFER ? 221 OHCI_TD_MAX_TRANSFER : remain_size; 222 toggle = 1 - toggle; 223 224 td_init(&data->tds[td_current], data_dir, transfer_buffer, 225 transfer_size, toggle); 226 td_set_next(&data->tds[td_current], &data->tds[td_current + 1]); 227 usb_log_debug("Created DATA TD: %x:%x:%x:%x.\n", 228 data->tds[td_current].status, data->tds[td_current].cbp, 229 data->tds[td_current].next, data->tds[td_current].be); 230 231 transfer_buffer += transfer_size; 232 remain_size -= transfer_size; 233 assert(td_current < data->td_count - 2); 234 ++td_current; 235 } 236 237 /* status stage */ 238 assert(td_current == data->td_count - 2); 239 td_init(&data->tds[td_current], status_dir, NULL, 0, 1); 240 usb_log_debug("Created STATUS TD: %x:%x:%x:%x.\n", 241 data->tds[td_current].status, data->tds[td_current].cbp, 242 data->tds[td_current].next, data->tds[td_current].be); 202 243 } 203 244 /*----------------------------------------------------------------------------*/ -
uspace/drv/ohci/hw_struct/endpoint_descriptor.h
rb854e56 re42dd32 41 41 42 42 #include "utils/malloc32.h" 43 #include "transfer_descriptor.h" 43 44 44 45 #include "completion_codes.h" … … 49 50 #define ED_STATUS_FA_SHIFT (0) 50 51 #define ED_STATUS_EN_MASK (0xf) /* USB endpoint address */ 51 #define ED_STATUS_EN_SHIFT ( 6)52 #define ED_STATUS_EN_SHIFT (7) 52 53 #define ED_STATUS_D_MASK (0x3) /* direction */ 53 #define ED_STATUS_D_SHIFT (1 0)54 #define ED_STATUS_D_SHIFT (11) 54 55 #define ED_STATUS_D_IN (0x1) 55 56 #define ED_STATUS_D_OUT (0x2) … … 80 81 void ed_init(ed_t *instance, endpoint_t *ep); 81 82 82 static inline void ed_add_tds(ed_t *instance, uint32_t head, uint32_ttail)83 static inline void ed_add_tds(ed_t *instance, td_t *head, td_t *tail) 83 84 { 84 85 assert(instance); 85 instance->td_head = head& ED_TDHEAD_PTR_MASK;86 instance->td_tail = tail& ED_TDTAIL_PTR_MASK;86 instance->td_head = addr_to_phys(head) & ED_TDHEAD_PTR_MASK; 87 instance->td_tail = addr_to_phys(tail) & ED_TDTAIL_PTR_MASK; 87 88 } 88 89 -
uspace/drv/ohci/hw_struct/transfer_descriptor.h
rb854e56 re42dd32 36 36 37 37 #include <stdint.h> 38 #include "utils/malloc32.h" 38 39 39 40 #include "completion_codes.h" … … 55 56 #define TD_STATUS_T_MASK (0x3) /* data toggle 1x = use ED toggle carry */ 56 57 #define TD_STATUS_T_SHIFT (24) 57 #define TD_STATUS_T_0 (0x0) 58 #define TD_STATUS_T_1 (0x1) 59 #define TD_STATUS_T_USE_EP (0x1) 58 #define TD_STATUS_T_0 (0x2) 59 #define TD_STATUS_T_1 (0x3) 60 60 #define TD_STATUS_EC_MASK (0x3) /* error count */ 61 61 #define TD_STATUS_EC_SHIFT (26) … … 74 74 td_t *instance, usb_direction_t dir, void *buffer, size_t size, int toggle); 75 75 76 inline static void td_set_next(td_t *instance, uint32_tnext)76 inline static void td_set_next(td_t *instance, td_t *next) 77 77 { 78 78 assert(instance); 79 instance->next = next& TD_NEXT_PTR_MASK;79 instance->next = addr_to_phys(next) & TD_NEXT_PTR_MASK; 80 80 } 81 81 #endif
Note:
See TracChangeset
for help on using the changeset viewer.