Changeset 00aece0 in mainline for uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c
- Timestamp:
- 2012-02-18T16:47:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c
rbd5f3b7 r00aece0 34 34 #include "endpoint_descriptor.h" 35 35 36 static unsigned direc[3] = 37 { ED_STATUS_D_IN, ED_STATUS_D_OUT, ED_STATUS_D_TRANSFER }; 36 /** USB direction to OHCI values translation table. */ 37 static const uint32_t dir[] = { 38 [USB_DIRECTION_IN] = ED_STATUS_D_IN, 39 [USB_DIRECTION_OUT] = ED_STATUS_D_OUT, 40 [USB_DIRECTION_BOTH] = ED_STATUS_D_TD, 41 }; 38 42 39 void ed_init(ed_t *instance, endpoint_t *ep) 43 /** 44 * Initialize ED. 45 * 46 * @param instance ED structure to initialize. 47 * @param ep Driver endpoint to use. 48 * @param td TD to put in the list. 49 * 50 * If @param ep is NULL, dummy ED is initalized with only skip flag set. 51 */ 52 void ed_init(ed_t *instance, const endpoint_t *ep, const td_t *td) 40 53 { 41 54 assert(instance); 42 55 bzero(instance, sizeof(ed_t)); 56 43 57 if (ep == NULL) { 58 /* Mark as dead, used for dummy EDs at the beginning of 59 * endpoint lists. */ 44 60 instance->status = ED_STATUS_K_FLAG; 45 61 return; 46 62 } 47 assert(ep); 63 /* Non-dummy ED must have TD assigned */ 64 assert(td); 65 66 /* Status: address, endpoint nr, direction mask and max packet size. */ 48 67 instance->status = 0 49 68 | ((ep->address & ED_STATUS_FA_MASK) << ED_STATUS_FA_SHIFT) 50 69 | ((ep->endpoint & ED_STATUS_EN_MASK) << ED_STATUS_EN_SHIFT) 51 | ((dir ec[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT)70 | ((dir[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT) 52 71 | ((ep->max_packet_size & ED_STATUS_MPS_MASK) 53 72 << ED_STATUS_MPS_SHIFT); 54 73 55 74 /* Low speed flag */ 56 75 if (ep->speed == USB_SPEED_LOW) 57 76 instance->status |= ED_STATUS_S_FLAG; 77 78 /* Isochronous format flag */ 58 79 if (ep->transfer_type == USB_TRANSFER_ISOCHRONOUS) 59 80 instance->status |= ED_STATUS_F_FLAG; 60 81 82 /* Set TD to the list */ 83 const uintptr_t pa = addr_to_phys(td); 84 instance->td_head = pa & ED_TDHEAD_PTR_MASK; 85 instance->td_tail = pa & ED_TDTAIL_PTR_MASK; 86 87 /* Set toggle bit */ 61 88 if (ep->toggle) 62 89 instance->td_head |= ED_TDHEAD_TOGGLE_CARRY; 90 63 91 } 64 92 /**
Note:
See TracChangeset
for help on using the changeset viewer.