X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fkeyboard.c;h=5eb7d6b490921495e36895d3f3c10b053058c459;hb=03be513c0df4bd0c559a0613943ef580e054bb3f;hp=71bed117139bafe052b138359ac78c4acc60fa68;hpb=72420d58d18ec71d4777d029daaf0c6a1c820b32;p=palacios.git diff --git a/palacios/src/devices/keyboard.c b/palacios/src/devices/keyboard.c index 71bed11..5eb7d6b 100644 --- a/palacios/src/devices/keyboard.c +++ b/palacios/src/devices/keyboard.c @@ -185,6 +185,9 @@ struct keyboard_internal { // After the Keyboard SET_RATE is called // we wait for the output byte on 64? SET_RATE, + // after having a f0 sent to 60 + // we wait for a new output byte on 60 + GETSET_SCANCODES, } state; @@ -209,6 +212,7 @@ struct keyboard_internal { uint8_t wrap; int mouse_enabled; + int scancode_set; struct queue kbd_queue; struct queue mouse_queue; @@ -866,6 +870,34 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * kbd->state = NORMAL; break; + case GETSET_SCANCODES: + switch (data) { + case 0: + PrintDebug("Keyboard: scancode set being read\n"); + push_to_output_queue(kbd, 0x45 - 2 * kbd->scancode_set, COMMAND, KEYBOARD); + break; + case 1: + PrintError("keyboard: unsupported scancode set %d selected\n", data); + return -1; + case 2: + PrintDebug("Keyboard: scancode set being set to %d\n", data); + kbd->scancode_set = data; + push_to_output_queue(kbd, 0xfa, COMMAND, KEYBOARD); + break; + case 3: + /* OpenBSD wants scancode set 3, but falls back to 2 if a + * subsequent read reveals that the request was ignored + */ + PrintError("keyboard: ignoring request for scancode set %d\n", data); + break; + default: + PrintError("keyboard: unknown scancode set %d selected\n", data); + return -1; + + } + kbd->state = NORMAL; + break; + default: case NORMAL: { // command is being sent to keyboard controller @@ -905,6 +937,11 @@ static int keyboard_write_output(struct guest_info * core, ushort_t port, void * push_to_output_queue(kbd, 0xee, COMMAND, KEYBOARD); break; + case 0xf0: // get/set scancode set + push_to_output_queue(kbd, 0xfa, COMMAND, KEYBOARD); + kbd->state = GETSET_SCANCODES; + break; + case 0xfe: // resend case 0xfd: // set key type make case 0xfc: // set key typ make/break @@ -957,8 +994,12 @@ static int keyboard_read_input(struct guest_info * core, ushort_t port, void * d -static int keyboard_free(struct vm_device * dev) { +static int keyboard_free(struct keyboard_internal * kbd) { + + // unhook host events + + V3_Free(kbd); return 0; } @@ -977,6 +1018,7 @@ static int keyboard_reset_device(struct keyboard_internal * kbd) { kbd->kbd_queue.count = 0; kbd->mouse_enabled = 0; + kbd->scancode_set = 2; kbd->state = NORMAL; kbd->mouse_state = STREAM; @@ -1010,7 +1052,7 @@ static int keyboard_reset_device(struct keyboard_internal * kbd) { } static struct v3_device_ops dev_ops = { - .free = keyboard_free, + .free = (int (*)(void *))keyboard_free, };