X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fkeyboard.c;h=6d398782c6969b99938403bd99413edc8e0e755c;hb=5d1bbcc86de011e3f0d115b6f10fd8645cdf855e;hp=2aa4bec562987f1a0153370e26fdddcb8dda1573;hpb=6d6988cc9c8bac21d96afd800076afe0915cf2cd;p=palacios.git diff --git a/palacios/src/devices/keyboard.c b/palacios/src/devices/keyboard.c index 2aa4bec..6d39878 100644 --- a/palacios/src/devices/keyboard.c +++ b/palacios/src/devices/keyboard.c @@ -28,7 +28,7 @@ #include -#ifndef CONFIG_DEBUG_KEYBOARD +#ifndef V3_CONFIG_DEBUG_KEYBOARD #undef PrintDebug #define PrintDebug(fmt, args...) #endif @@ -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; @@ -331,7 +335,7 @@ static int pull_from_output_queue(struct keyboard_internal * state, uint8_t * va #include -#ifdef CONFIG_SYMMOD +#ifdef V3_CONFIG_SYMMOD #include #endif @@ -349,7 +353,7 @@ static int key_event_handler(struct v3_vm_info * vm, } // PrintGuestPageTables(info, info->shdw_pg_state.guest_cr3); } -#ifdef CONFIG_SYMCALL +#ifdef V3_CONFIG_SYMCALL else if (evt->scan_code == 0x43) { // F9 Sym test struct guest_info * core = &(vm->cores[0]); PrintDebug("Testing sym call\n"); @@ -381,13 +385,13 @@ static int key_event_handler(struct v3_vm_info * vm, v3_dbg_enable ^= 1; } -#ifdef CONFIG_TELEMETRY +#ifdef V3_CONFIG_TELEMETRY else if (evt->scan_code == 0x41) { // F7 telemetry dump v3_print_telemetry(vm); } #endif -#ifdef CONFIG_SYMMOD +#ifdef V3_CONFIG_SYMMOD else if (evt->scan_code == 0x40) { // F6 Test symmod load v3_load_sym_capsule(vm, "lnx_test"); } @@ -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 @@ -981,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; @@ -1013,9 +1051,27 @@ static int keyboard_reset_device(struct keyboard_internal * kbd) { } +#ifdef V3_CONFIG_CHECKPOINT +static int keyboard_save(struct v3_chkpt_ctx * ctx, void * private_data) { + return 0; +} + + +static int keyboard_load(struct v3_chkpt_ctx * ctx, void * private_data) { + struct keyboard_internal * kbd = (struct keyboard_internal *)private_data; + keyboard_reset_device(kbd); + return 0; +} + +#endif + + static struct v3_device_ops dev_ops = { .free = (int (*)(void *))keyboard_free, - +#ifdef V3_CONFIG_CHECKPOINT + .save = keyboard_save, + .load = keyboard_load +#endif };