X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fos_debug.c;h=954c38ac58da57e7c8c591d2db6297c257042d48;hp=f821415696780efb494578813dc93f9d10ef3d14;hb=460ac979ecba88a7526afb10733b24ff2f27d57b;hpb=88648ddca6003a438826e7d86e28a2ba7b5bfcac diff --git a/palacios/src/devices/os_debug.c b/palacios/src/devices/os_debug.c index f821415..954c38a 100644 --- a/palacios/src/devices/os_debug.c +++ b/palacios/src/devices/os_debug.c @@ -26,6 +26,7 @@ #define BUF_SIZE 1024 #define DEBUG_PORT1 0xc0c0 +#define HEARTBEAT_PORT 0x99 struct debug_state { char debug_buf[BUF_SIZE]; @@ -48,6 +49,22 @@ static int handle_gen_write(struct guest_info * core, ushort_t port, void * src, return length; } +static int handle_hb_write(struct guest_info * core, ushort_t port, void * src, uint_t length, void * priv_data) { + uint32_t val = 0; + + if (length == 1) { + val = *(uint8_t *)src; + } else if (length == 2) { + val = *(uint16_t *)src; + } else { + val = *(uint32_t *)src; + } + + V3_Print("HEARTBEAT> %x (%d)\n", val, val); + + return length; +} + static int handle_hcall(struct guest_info * info, uint_t hcall_id, void * priv_data) { struct debug_state * state = (struct debug_state *)priv_data; @@ -146,6 +163,13 @@ static int debug_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { return -1; } + + if (v3_dev_hook_io(dev, HEARTBEAT_PORT, NULL, &handle_hb_write) == -1) { + PrintError("error hooking OS heartbeat port\n"); + v3_remove_device(dev); + return -1; + } + v3_register_hypercall(vm, OS_DEBUG_HCALL, handle_hcall, state); state->debug_offset = 0;