Changes in uspace/lib/usb/src/host/device_keeper.c [ba038f4:1998bcd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/host/device_keeper.c
rba038f4 r1998bcd 54 54 for (; i < USB_ADDRESS_COUNT; ++i) { 55 55 instance->devices[i].occupied = false; 56 instance->devices[i].control_used = 0; 56 57 instance->devices[i].handle = 0; 57 58 instance->devices[i].speed = USB_SPEED_MAX; 59 list_initialize(&instance->devices[i].endpoints); 58 60 } 59 61 // TODO: is this hack enough? … … 62 64 } 63 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 } 86 /*----------------------------------------------------------------------------*/ 64 87 /** Attempt to obtain address 0, blocks. 65 88 * … … 94 117 } 95 118 /*----------------------------------------------------------------------------*/ 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 < 0 133 || target.address >= USB_ADDRESS_COUNT || target.address < 0 134 || !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 } 96 175 /*----------------------------------------------------------------------------*/ 97 176 /** Get a free USB address
Note:
See TracChangeset
for help on using the changeset viewer.