Changeset d93b3e3 in mainline
- Timestamp:
- 2011-03-25T17:02:08Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1585c7e
- Parents:
- 30718cc2
- Location:
- uspace/lib/usb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/host/device_keeper.h
r30718cc2 rd93b3e3 51 51 usb_speed_t speed; 52 52 bool occupied; 53 bool control_used; 53 54 uint16_t toggle_status[2]; 54 55 devman_handle_t handle; … … 61 62 struct usb_device_info devices[USB_ADDRESS_COUNT]; 62 63 fibril_mutex_t guard; 63 fibril_condvar_t default_address_occupied;64 fibril_condvar_t change; 64 65 usb_address_t last_address; 65 66 } usb_device_keeper_t; … … 97 98 usb_address_t address); 98 99 100 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 101 usb_address_t address); 102 103 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 104 usb_address_t address); 105 99 106 #endif 100 107 /** -
uspace/lib/usb/src/host/device_keeper.c
r30718cc2 rd93b3e3 49 49 assert(instance); 50 50 fibril_mutex_initialize(&instance->guard); 51 fibril_condvar_initialize(&instance-> default_address_occupied);51 fibril_condvar_initialize(&instance->change); 52 52 instance->last_address = 0; 53 53 unsigned i = 0; 54 54 for (; i < USB_ADDRESS_COUNT; ++i) { 55 55 instance->devices[i].occupied = false; 56 instance->devices[i].control_used = false; 56 57 instance->devices[i].handle = 0; 57 58 instance->devices[i].toggle_status[0] = 0; … … 71 72 fibril_mutex_lock(&instance->guard); 72 73 while (instance->devices[USB_ADDRESS_DEFAULT].occupied) { 73 fibril_condvar_wait(&instance->default_address_occupied, 74 &instance->guard); 74 fibril_condvar_wait(&instance->change, &instance->guard); 75 75 } 76 76 instance->devices[USB_ADDRESS_DEFAULT].occupied = true; … … 90 90 instance->devices[USB_ADDRESS_DEFAULT].occupied = false; 91 91 fibril_mutex_unlock(&instance->guard); 92 fibril_condvar_signal(&instance-> default_address_occupied);92 fibril_condvar_signal(&instance->change); 93 93 } 94 94 /*----------------------------------------------------------------------------*/ … … 309 309 return instance->devices[address].speed; 310 310 } 311 311 /*----------------------------------------------------------------------------*/ 312 void usb_device_keeper_use_control(usb_device_keeper_t *instance, 313 usb_address_t address) 314 { 315 assert(instance); 316 fibril_mutex_lock(&instance->guard); 317 while (instance->devices[address].control_used) { 318 fibril_condvar_wait(&instance->change, &instance->guard); 319 } 320 instance->devices[address].control_used = true; 321 fibril_mutex_unlock(&instance->guard); 322 } 323 /*----------------------------------------------------------------------------*/ 324 void usb_device_keeper_release_control(usb_device_keeper_t *instance, 325 usb_address_t address) 326 { 327 assert(instance); 328 fibril_mutex_lock(&instance->guard); 329 instance->devices[address].control_used = false; 330 fibril_mutex_unlock(&instance->guard); 331 fibril_condvar_signal(&instance->change); 332 } 312 333 /** 313 334 * @}
Note:
See TracChangeset
for help on using the changeset viewer.