X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fcurses_cons.c;h=9359ecc122a60100450a4c903938c1e4927c148a;hb=11d720fc1423409ceb24e0b970ae6f7199912152;hp=14610368b013da4b0561f098717b122d99601b0b;hpb=1d68e58eef2fbd003616e587ef9a2e5b9a0c9949;p=palacios-OLD.git diff --git a/palacios/src/devices/curses_cons.c b/palacios/src/devices/curses_cons.c index 1461036..9359ecc 100644 --- a/palacios/src/devices/curses_cons.c +++ b/palacios/src/devices/curses_cons.c @@ -51,9 +51,14 @@ static int cursor_update(uint_t x, uint_t y, void *private_data) { struct vm_device *dev = (struct vm_device *) private_data; struct cons_state *state = (struct cons_state *) dev->private_data; - uint_t offset = (x * BYTES_PER_COL) + (y * BYTES_PER_ROW); + uint_t offset; uint_t last_x, last_y; + /* avoid out-of-range coordinates */ + if (x >= NUM_COLS) x = NUM_COLS - 1; + if (y >= NUM_ROWS) y = NUM_ROWS - 1; + offset = (x * BYTES_PER_COL) + (y * BYTES_PER_ROW); + /* unfortunately Palacios sometimes misses some writes, * but if they are accompanied by a cursor move we may be able to * detect this @@ -82,8 +87,8 @@ static int cursor_update(uint_t x, uint_t y, void *private_data) } static int screen_update(uint_t x, uint_t y, uint_t length, void * private_data) { - struct vm_device *dev = (struct vm_device *)private_data; - struct cons_state *state = (struct cons_state *)dev->private_data; + struct vm_device * dev = (struct vm_device *)private_data; + struct cons_state * state = (struct cons_state *)dev->private_data; uint_t offset = (x * BYTES_PER_COL) + (y * BYTES_PER_ROW); uint8_t fb_buf[length]; int i; @@ -156,6 +161,18 @@ static int scroll(int rows, void * private_data) { } +static int cons_free(struct vm_device * dev) { + struct cons_state * state = (struct cons_state *)dev->private_data; + + v3_console_close(state->cons); + + // remove host event + + V3_Free(state); + + return 0; +} + static int console_event_handler(struct v3_vm_info * vm, struct v3_console_event * evt, void * priv_data) { @@ -171,10 +188,7 @@ static struct v3_console_ops cons_ops = { }; static struct v3_device_ops dev_ops = { - .free = NULL, - .reset = NULL, - .start = NULL, - .stop = NULL, + .free = cons_free, }; static int cons_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg)