2 Interface to Nautilus screen and keyboard
5 #include <nautilus/nautilus.h>
6 #include <nautilus/vc.h>
10 #include <palacios/vmm.h>
12 #include <interfaces/vmm_console.h>
13 #include <palacios/vmm_host_events.h>
17 static void kbd_callback(nk_scancode_t scancode, void *priv)
19 struct nk_vm_state *n = (struct nk_vm_state *) priv;
21 struct v3_keyboard_event event = {0,scancode};
24 v3_deliver_keyboard_event(n->vm, &event);
26 ERROR("Missing target for event... n=%p, n->vm=%p\n", n, n?n->vm:0);
31 static void * palacios_tty_open(void * private_data, unsigned int width, unsigned int height)
33 struct nk_vm_state *n = palacios_get_selected_vm();
36 ERROR("Cannot create console without selected VM\n");
39 if (width!=80 || height!=25) {
40 ERROR("Console is wrong size\n");
45 ERROR("Cannot open multiple consoles per selected VM\n");
50 n->vc = nk_create_vc(n->name,
57 ERROR("Failed to create vc\n");
61 nk_vc_clear_specific(n->vc,0x5f);
68 static int palacios_tty_cursor_set(void * console, int x, int y)
70 struct nk_vm_state *n = (struct nk_vm_state *) console;
73 nk_vc_setpos_specific(n->vc,x,y);
80 static int palacios_tty_character_set(void * console, int x, int y, char c, unsigned char style)
82 struct nk_vm_state *n = (struct nk_vm_state *) console;
85 nk_vc_display_char_specific(n->vc,c,style,x,y);
86 nk_vc_setattr_specific(n->vc,style);
93 static int palacios_tty_scroll(void * console, int lines)
95 struct nk_vm_state *n = (struct nk_vm_state *) console;
99 for (i=0;i<lines;i++) {
100 nk_vc_scrollup_specific(n->vc);
109 static int palacios_set_text_resolution(void * console, int cols, int rows)
112 if (cols!=80 || rows!=25) {
113 ERROR("Cannot change resolution\n");
123 static int palacios_tty_update(void * console)
129 static void palacios_tty_close(void * console)
131 struct nk_vm_state *n = (struct nk_vm_state *) console;
134 nk_destroy_vc(n->vc);
140 static struct v3_console_hooks palacios_console_hooks = {
141 .open = palacios_tty_open,
142 .set_cursor = palacios_tty_cursor_set,
143 .set_character = palacios_tty_character_set,
144 .scroll = palacios_tty_scroll,
145 .set_text_resolution = palacios_set_text_resolution,
146 .update = palacios_tty_update,
147 .close = palacios_tty_close,
152 int nautilus_console_init(void)
154 INFO("Palacios Console\n");
156 V3_Init_Console(&palacios_console_hooks);
161 int nautilus_console_deinit(void)