#define DEVICE_NAME "virtio-hwkey"
#define MAX_BUF_COUNT 64
-static int vqidx = 0;
-
+static int vqidx;
/*
* HW key event queue
*/
{
HwKeyEventEntry *entry = NULL;
+ if (!vhk) {
+ INFO("Hwkey device can not be used.\n");
+ return;
+ }
+
if (unlikely(event_queue_cnt >= MAX_HWKEY_EVENT_CNT)) {
INFO("full hwkey event queue, lose event\n", event_queue_cnt);
event_ringbuf_cnt++;
- entry->index = ++event_queue_cnt; // 1 ~
+ /* 1 ~ */
+ entry->index = ++event_queue_cnt;
QTAILQ_INSERT_TAIL(&events_queue, entry, node);
event_queue_cnt, vqidx);
/* copy event into virtio buffer */
- memcpy(elem_vhk.in_sg[vqidx++].iov_base, &(event_entry->hwkey), sizeof(EmulHWKeyEvent));
+ memcpy(elem_vhk.in_sg[vqidx++].iov_base, &(event_entry->hwkey),
+ sizeof(EmulHWKeyEvent));
if (vqidx == MAX_BUF_COUNT) {
vqidx = 0;
}
static uint32_t virtio_hwkey_get_features(
VirtIODevice *vdev, uint32_t request_features)
{
- // TODO:
return request_features;
}