Changeset e099f26 in mainline for uspace/lib/usb/src/host/device_keeper.c
- Timestamp:
- 2011-03-21T20:22:50Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c56c5b5b
- Parents:
- 4fb6d9ee (diff), 31b568e (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
r4fb6d9ee re099f26 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 |=182 (1 << target.endpoint);192 instance->devices[target.address].toggle_status[direction] 193 |= (1 << target.endpoint); 183 194 } else { 184 instance->devices[target.address].toggle_status &=185 ~(1 << target.endpoint);195 instance->devices[target.address].toggle_status[direction] 196 &= ~(1 << target.endpoint); 186 197 } 187 198 ret = EOK; … … 197 208 * @return Free address, or error code. 198 209 */ 199 usb_address_t device_keeper_ request(200 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) 201 212 { 202 213 assert(instance); … … 218 229 instance->devices[new_address].occupied = true; 219 230 instance->devices[new_address].speed = speed; 220 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; 221 233 instance->last_address = new_address; 222 234 fibril_mutex_unlock(&instance->guard); … … 230 242 * @param[in] handle Devman handle of the device. 231 243 */ 232 void device_keeper_bind(233 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) 234 246 { 235 247 assert(instance); … … 247 259 * @param[in] address Device address 248 260 */ 249 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) 250 263 { 251 264 assert(instance); … … 265 278 * @return USB Address, or error code. 266 279 */ 267 usb_address_t device_keeper_find(268 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) 269 282 { 270 283 assert(instance); … … 288 301 * @return USB speed. 289 302 */ 290 usb_speed_t device_keeper_speed(291 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) 292 305 { 293 306 assert(instance); … … 296 309 return instance->devices[address].speed; 297 310 } 311 298 312 /** 299 313 * @}
Note:
See TracChangeset
for help on using the changeset viewer.