Changeset 41ef5b9 in mainline for uspace/lib/usb/src/host/device_keeper.c
- Timestamp:
- 2011-03-21T17:16:10Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4d0c40b
- Parents:
- fd9f6e4c (diff), 434ef65 (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/host/device_keeper.c
rfd9f6e4c r41ef5b9 27 27 */ 28 28 29 /** @addtogroup drvusbuhcihc29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief UHCI driver33 * Device keeper structure and functions (implementation). 34 34 */ 35 35 #include <assert.h> 36 36 #include <errno.h> 37 37 #include <usb/debug.h> 38 39 #include "device_keeper.h" 38 #include <usb/host/device_keeper.h> 40 39 41 40 /*----------------------------------------------------------------------------*/ … … 46 45 * Set all values to false/0. 47 46 */ 48 void device_keeper_init(device_keeper_t *instance)47 void usb_device_keeper_init(usb_device_keeper_t *instance) 49 48 { 50 49 assert(instance); … … 56 55 instance->devices[i].occupied = false; 57 56 instance->devices[i].handle = 0; 58 instance->devices[i].toggle_status = 0; 57 instance->devices[i].toggle_status[0] = 0; 58 instance->devices[i].toggle_status[1] = 0; 59 59 } 60 60 } … … 65 65 * @param[in] speed Speed of the device requesting default address. 66 66 */ 67 void device_keeper_reserve_default(device_keeper_t *instance, usb_speed_t speed) 67 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance, 68 usb_speed_t speed) 68 69 { 69 70 assert(instance); … … 83 84 * @param[in] speed Speed of the device requesting default address. 84 85 */ 85 void device_keeper_release_default(device_keeper_t *instance)86 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance) 86 87 { 87 88 assert(instance); … … 100 101 * Really ugly one. 101 102 */ 102 void device_keeper_reset_if_need(103 device_keeper_t *instance, usb_target_t target, const unsigned char*data)103 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance, 104 usb_target_t target, const uint8_t *data) 104 105 { 105 106 assert(instance); … … 119 120 if (((data[0] & 0xf) == 1) && ((data[2] | data[3]) == 0)) { 120 121 /* endpoint number is < 16, thus first byte is enough */ 121 instance->devices[target.address].toggle_status &= 122 instance->devices[target.address].toggle_status[0] &= 123 ~(1 << data[4]); 124 instance->devices[target.address].toggle_status[1] &= 122 125 ~(1 << data[4]); 123 126 } … … 128 131 /* target must be device */ 129 132 if ((data[0] & 0xf) == 0) { 130 instance->devices[target.address].toggle_status = 0; 133 instance->devices[target.address].toggle_status[0] = 0; 134 instance->devices[target.address].toggle_status[1] = 0; 131 135 } 132 136 break; … … 141 145 * @return Error code 142 146 */ 143 int device_keeper_get_toggle(device_keeper_t *instance, usb_target_t target) 144 { 145 assert(instance); 147 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance, 148 usb_target_t target, usb_direction_t direction) 149 { 150 assert(instance); 151 /* only control pipes are bi-directional and those do not need toggle */ 152 if (direction == USB_DIRECTION_BOTH) 153 return ENOENT; 146 154 int ret; 147 155 fibril_mutex_lock(&instance->guard); … … 152 160 ret = EINVAL; 153 161 } else { 154 ret = (instance->devices[target.address].toggle_status 162 ret = (instance->devices[target.address].toggle_status[direction] 155 163 >> target.endpoint) & 1; 156 164 } … … 166 174 * @return Error code. 167 175 */ 168 int device_keeper_set_toggle( 169 device_keeper_t *instance, usb_target_t target, bool toggle) 170 { 171 assert(instance); 176 int usb_device_keeper_set_toggle(usb_device_keeper_t *instance, 177 usb_target_t target, usb_direction_t direction, bool toggle) 178 { 179 assert(instance); 180 /* only control pipes are bi-directional and those do not need toggle */ 181 if (direction == USB_DIRECTION_BOTH) 182 return ENOENT; 172 183 int ret; 173 184 fibril_mutex_lock(&instance->guard); … … 179 190 } else { 180 191 if (toggle) { 181 instance->devices[target.address].toggle_status |= (1 << target.endpoint); 192 instance->devices[target.address].toggle_status[direction] 193 |= (1 << target.endpoint); 182 194 } else { 183 instance->devices[target.address].toggle_status &= ~(1 << target.endpoint); 195 instance->devices[target.address].toggle_status[direction] 196 &= ~(1 << target.endpoint); 184 197 } 185 198 ret = EOK; … … 195 208 * @return Free address, or error code. 196 209 */ 197 usb_address_t device_keeper_ request(198 device_keeper_t *instance,usb_speed_t speed)210 usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance, 211 usb_speed_t speed) 199 212 { 200 213 assert(instance); … … 216 229 instance->devices[new_address].occupied = true; 217 230 instance->devices[new_address].speed = speed; 218 instance->devices[new_address].toggle_status = 0; 231 instance->devices[new_address].toggle_status[0] = 0; 232 instance->devices[new_address].toggle_status[1] = 0; 219 233 instance->last_address = new_address; 220 234 fibril_mutex_unlock(&instance->guard); … … 228 242 * @param[in] handle Devman handle of the device. 229 243 */ 230 void device_keeper_bind(231 device_keeper_t *instance,usb_address_t address, devman_handle_t handle)244 void usb_device_keeper_bind(usb_device_keeper_t *instance, 245 usb_address_t address, devman_handle_t handle) 232 246 { 233 247 assert(instance); … … 245 259 * @param[in] address Device address 246 260 */ 247 void device_keeper_release(device_keeper_t *instance, usb_address_t address) 261 void usb_device_keeper_release(usb_device_keeper_t *instance, 262 usb_address_t address) 248 263 { 249 264 assert(instance); … … 263 278 * @return USB Address, or error code. 264 279 */ 265 usb_address_t device_keeper_find(266 dev ice_keeper_t *instance, devman_handle_t handle)280 usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance, 281 devman_handle_t handle) 267 282 { 268 283 assert(instance); … … 286 301 * @return USB speed. 287 302 */ 288 usb_speed_t device_keeper_speed(289 device_keeper_t *instance,usb_address_t address)303 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance, 304 usb_address_t address) 290 305 { 291 306 assert(instance); … … 294 309 return instance->devices[address].speed; 295 310 } 311 296 312 /** 297 313 * @}
Note:
See TracChangeset
for help on using the changeset viewer.