Changeset 9a884ed in mainline
- Timestamp:
- 2011-05-06T10:12:25Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 42d47f8
- Parents:
- 30f9f8f
- Location:
- uspace/app/vuhid
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vuhid/device.c
r30f9f8f r9a884ed 77 77 { 78 78 vuhid_interface_t *iface = arg; 79 vuhid_data_t *hid_data = iface->vuhid_data; 79 80 80 81 if (iface->live != NULL) { 81 82 iface->live(iface); 82 83 } 84 85 fibril_mutex_lock(&hid_data->iface_count_mutex); 86 hid_data->iface_died_count++; 87 fibril_condvar_broadcast(&hid_data->iface_count_cv); 88 fibril_mutex_unlock(&hid_data->iface_count_mutex); 83 89 84 90 return EOK; … … 110 116 if ((iface->in_data_size == 0) && (iface->out_data_size == 0)) { 111 117 return EEMPTY; 118 } 119 120 // FIXME - we shall set vuhid_data to NULL in the main() rather 121 // than to depend on individual interfaces 122 /* Already used interface. */ 123 if (iface->vuhid_data != NULL) { 124 return EEXISTS; 112 125 } 113 126 … … 252 265 253 266 /* Launch the "life" fibril. */ 267 iface->vuhid_data = hid_data; 254 268 fid_t life_fibril = fibril_create(interface_life_fibril, iface); 255 269 if (life_fibril == 0) { … … 310 324 += total_descr_size; 311 325 326 hid_data->iface_count++; 312 327 fibril_add_ready(life_fibril); 313 328 … … 331 346 } 332 347 348 void wait_for_interfaces_death(usbvirt_device_t *dev) 349 { 350 vuhid_data_t *hid_data = dev->device_data; 351 352 fibril_mutex_lock(&hid_data->iface_count_mutex); 353 while (hid_data->iface_died_count < hid_data->iface_count) { 354 fibril_condvar_wait(&hid_data->iface_count_cv, 355 &hid_data->iface_count_mutex); 356 } 357 fibril_mutex_unlock(&hid_data->iface_count_mutex); 358 } 333 359 334 360 /** @} -
uspace/app/vuhid/hids/bootkbd.c
r30f9f8f r9a884ed 169 169 .on_data_out = on_data_out, 170 170 171 .live = live 171 .live = live, 172 173 .vuhid_data = NULL 172 174 }; 173 175 -
uspace/app/vuhid/main.c
r30f9f8f r9a884ed 132 132 .in_endpoint_first_free = 1, 133 133 .out_endpoints_mapping = { NULL }, 134 .out_endpoint_first_free = 1 135 }; 134 .out_endpoint_first_free = 1, 135 136 .iface_count = 0, 137 .iface_died_count = 0 138 // mutex and CV must be initialized elsewhere 139 }; 140 136 141 137 142 /** Keyboard device. … … 151 156 152 157 usb_log_enable(USB_LOG_LEVEL_DEBUG2, "vusbhid"); 158 159 fibril_mutex_initialize(&vuhid_data.iface_count_mutex); 160 fibril_condvar_initialize(&vuhid_data.iface_count_cv); 153 161 154 162 /* Determine which interfaces to initialize. */ … … 182 190 printf("Connected to VHCD...\n"); 183 191 184 while (true) { 185 async_usleep(10 * 1000 * 1000); 186 } 192 wait_for_interfaces_death(&hid_dev); 187 193 188 194 printf("Terminating...\n"); -
uspace/app/vuhid/virthid.h
r30f9f8f r9a884ed 38 38 #include <usb/usb.h> 39 39 #include <usbvirt/device.h> 40 #include <fibril_synch.h> 40 41 41 42 #define VUHID_ENDPOINT_MAX USB11_ENDPOINT_MAX … … 43 44 44 45 typedef struct vuhid_interface vuhid_interface_t; 46 47 typedef struct { 48 vuhid_interface_t *in_endpoints_mapping[VUHID_ENDPOINT_MAX]; 49 size_t in_endpoint_first_free; 50 vuhid_interface_t *out_endpoints_mapping[VUHID_ENDPOINT_MAX]; 51 size_t out_endpoint_first_free; 52 vuhid_interface_t *interface_mapping[VUHID_INTERFACE_MAX]; 53 54 fibril_mutex_t iface_count_mutex; 55 fibril_condvar_t iface_count_cv; 56 size_t iface_count; 57 size_t iface_died_count; 58 } vuhid_data_t; 45 59 46 60 struct vuhid_interface { … … 63 77 64 78 void *interface_data; 79 80 vuhid_data_t *vuhid_data; 65 81 }; 66 67 typedef struct {68 vuhid_interface_t *in_endpoints_mapping[VUHID_ENDPOINT_MAX];69 size_t in_endpoint_first_free;70 vuhid_interface_t *out_endpoints_mapping[VUHID_ENDPOINT_MAX];71 size_t out_endpoint_first_free;72 vuhid_interface_t *interface_mapping[VUHID_INTERFACE_MAX];73 } vuhid_data_t;74 82 75 83 typedef struct { … … 84 92 85 93 int add_interface_by_id(vuhid_interface_t **, const char *, usbvirt_device_t *); 94 void wait_for_interfaces_death(usbvirt_device_t *); 86 95 87 96 #endif
Note:
See TracChangeset
for help on using the changeset viewer.