Changeset ba038f4 in mainline for uspace/lib/usb/src/host/device_keeper.c
- Timestamp:
- 2011-04-09T22:03:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a19a2d7
- Parents:
- 501e5df
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/host/device_keeper.c
r501e5df rba038f4 54 54 for (; i < USB_ADDRESS_COUNT; ++i) { 55 55 instance->devices[i].occupied = false; 56 instance->devices[i].control_used = 0;57 56 instance->devices[i].handle = 0; 58 57 instance->devices[i].speed = USB_SPEED_MAX; 59 list_initialize(&instance->devices[i].endpoints);60 58 } 61 59 // TODO: is this hack enough? 62 60 // (it is needed to allow smooth registration at default address) 63 61 instance->devices[0].occupied = true; 64 }65 /*----------------------------------------------------------------------------*/66 void usb_device_keeper_add_ep(67 usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep)68 {69 assert(instance);70 fibril_mutex_lock(&instance->guard);71 assert(instance->devices[address].occupied);72 list_append(&ep->same_device_eps, &instance->devices[address].endpoints);73 fibril_mutex_unlock(&instance->guard);74 }75 /*----------------------------------------------------------------------------*/76 void usb_device_keeper_del_ep(77 usb_device_keeper_t *instance, usb_address_t address, endpoint_t *ep)78 {79 assert(instance);80 fibril_mutex_lock(&instance->guard);81 assert(instance->devices[address].occupied);82 list_remove(&ep->same_device_eps);83 list_initialize(&ep->same_device_eps);84 fibril_mutex_unlock(&instance->guard);85 62 } 86 63 /*----------------------------------------------------------------------------*/ … … 117 94 } 118 95 /*----------------------------------------------------------------------------*/ 119 /** Check setup packet data for signs of toggle reset.120 *121 * @param[in] instance Device keeper structure to use.122 * @param[in] target Device to receive setup packet.123 * @param[in] data Setup packet data.124 *125 * Really ugly one.126 */127 void usb_device_keeper_reset_if_need(128 usb_device_keeper_t *instance, usb_target_t target, const uint8_t *data)129 {130 assert(instance);131 fibril_mutex_lock(&instance->guard);132 if (target.endpoint > 15 || target.endpoint < 0133 || target.address >= USB_ADDRESS_COUNT || target.address < 0134 || !instance->devices[target.address].occupied) {135 fibril_mutex_unlock(&instance->guard);136 usb_log_error("Invalid data when checking for toggle reset.\n");137 return;138 }139 140 switch (data[1])141 {142 case 0x01: /*clear feature*/143 /* recipient is endpoint, value is zero (ENDPOINT_STALL) */144 if (((data[0] & 0xf) == 1) && ((data[2] | data[3]) == 0)) {145 link_t *current =146 instance->devices[target.address].endpoints.next;147 while (current !=148 &instance->devices[target.address].endpoints)149 {150 /* endpoint number is < 16, thus first byte is enough */151 endpoint_toggle_reset_filtered(152 current, data[4]);153 current = current->next;154 }155 }156 break;157 158 case 0x9: /* set configuration */159 case 0x11: /* set interface */160 /* target must be device */161 if ((data[0] & 0xf) == 0) {162 link_t *current =163 instance->devices[target.address].endpoints.next;164 while (current !=165 &instance->devices[target.address].endpoints)166 {167 endpoint_toggle_reset(current);168 current = current->next;169 }170 }171 break;172 }173 fibril_mutex_unlock(&instance->guard);174 }175 96 /*----------------------------------------------------------------------------*/ 176 97 /** Get a free USB address
Note:
See TracChangeset
for help on using the changeset viewer.