#include "linux-exts.h"
#include "vm.h"
-#include <linux/vmalloc.h>
/*
*/
+static struct list_head global_gcons;
struct palacios_graphics_console {
// descriptor for the data in the shared frame buffer
void *priv_data);
void *render_data;
- int (*update_inquire)(v3_graphics_console_t cons,
- void *priv_data);
-
- void *update_data;
+ int (*update_inquire)(v3_graphics_console_t cons,
+ void *priv_data);
+
+ void *update_data;
+
+ struct list_head gcons_node;
};
DEBUG("palacios: allocating %u bytes for %u by %u by %u buffer\n",
mem, desired_spec->width, desired_spec->height, desired_spec->bytes_per_pixel);
- gc->data = vmalloc(mem);
+ gc->data = palacios_valloc(mem);
if (!(gc->data)) {
ERROR("palacios: unable to allocate memory for frame buffer\n");
return;
}
if (gc->data) {
- kfree(gc->data);
+ palacios_vfree(gc->data);
gc->data=0;
}
}
struct palacios_graphics_console *cons,
uint8_t scancode)
{
- struct v3_keyboard_event e;
+ struct v3_keyboard_event e;
e.status = 0;
e.scan_code = scancode;
static int palacios_graphics_console_mouse(struct v3_guest * guest,
struct palacios_graphics_console *cons,
- uint8_t x, uint8_t y, uint8_t buttons)
+ uint8_t sx, uint8_t dx,
+ uint8_t sy, uint8_t dy,
+ uint8_t buttons)
{
+
struct v3_mouse_event e;
- e.data[0]=x;
- e.data[1]=y;
- e.data[2]=buttons; // These three are completely wrong, of course - ignoring mouse for now
- // mouse delivery is broken, so don't do it.
- // v3_deliver_mouse_event(guest->v3_ctx,&e);
+ e.sx=sx;
+ e.dx=dx;
+ e.sy=sy;
+ e.dy=dy;
+ e.buttons=buttons;
+
+ v3_deliver_mouse_event(guest->v3_ctx,&e);
return 0;
}
static int graphics_console_init( void ) {
+ INIT_LIST_HEAD(&(global_gcons));
+
V3_Init_Graphics_Console(&palacios_graphics_console_hooks);
return 0;
}
+static int graphics_console_deinit( void ) {
+ struct palacios_graphics_console * gc = NULL;
+ struct palacios_graphics_console * tmp = NULL;
+
+ list_for_each_entry_safe(gc, tmp, &(global_gcons), gcons_node) {
+ list_del(&(gc->gcons_node));
+
+ if (gc->data)
+ palacios_vfree(gc->data);
+
+ palacios_free(gc);
+ }
+
+ return 0;
+}
+
static int fb_query(struct v3_guest * guest, unsigned int cmd, unsigned long arg,
void * priv_data) {
}
if ((inp.data_type == V3_FB_MOUSE) || (inp.data_type == V3_FB_BOTH)) {
- rc |= palacios_graphics_console_mouse(guest, cons, inp.mouse_data[0],
- inp.mouse_data[1], inp.mouse_data[2]);
+ rc |= palacios_graphics_console_mouse(guest, cons, inp.sx, inp.dx, inp.sy, inp.dy, inp.buttons);
//DEBUG("palacios: mouse delivered to palacios\n");
}
static int graphics_console_guest_init(struct v3_guest * guest, void ** vm_data) {
- struct palacios_graphics_console * graphics_cons = kmalloc(sizeof(struct palacios_graphics_console), GFP_KERNEL);
+ struct palacios_graphics_console * graphics_cons = palacios_alloc(sizeof(struct palacios_graphics_console));
if (!graphics_cons) {
ERROR("palacios: filed to do guest_init for graphics console\n");
add_guest_ctrl(guest, V3_VM_FB_INPUT, fb_input, graphics_cons);
add_guest_ctrl(guest, V3_VM_FB_QUERY, fb_query, graphics_cons);
+ list_add(&(graphics_cons->gcons_node),&global_gcons);
+
return 0;
}
+static int graphics_console_guest_deinit(struct v3_guest * guest, void * vm_data) {
+ struct palacios_graphics_console * graphics_cons = (struct palacios_graphics_console *)vm_data;
+
+ list_del(&(graphics_cons->gcons_node));
+
+ remove_guest_ctrl(guest, V3_VM_FB_INPUT);
+ remove_guest_ctrl(guest, V3_VM_FB_QUERY);
+
+ if (graphics_cons->data) {
+ palacios_vfree(graphics_cons->data);
+ }
+
+
+ palacios_free(graphics_cons);
+
+ return 0;
+}
+
+
static struct linux_ext graphics_cons_ext = {
.name = "GRAPHICS_CONSOLE_INTERFACE",
.init = graphics_console_init,
- .deinit = NULL,
+ .deinit = graphics_console_deinit,
.guest_init = graphics_console_guest_init,
- .guest_deinit = NULL
+ .guest_deinit = graphics_console_guest_deinit,
};