Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


add basic heartbeat debug port
[palacios.git] / palacios / src / devices / os_debug.c
index b97da12..954c38a 100644 (file)
@@ -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;
 
@@ -81,16 +98,44 @@ static int handle_hcall(struct guest_info * info, uint_t hcall_id, void * priv_d
 
 
 
-static int debug_free(struct vm_device * dev) {
+static int debug_free(struct debug_state * state) {
+
+    // unregister hypercall
 
+    V3_Free(state);
     return 0;
 };
 
+#ifdef V3_CONFIG_CHECKPOINT
+static int debug_save(struct v3_chkpt_ctx * ctx, void * private_data) {
+    struct debug_state * dbg = (struct debug_state *)private_data;
+    
+    V3_CHKPT_STD_SAVE(ctx, dbg->debug_buf);
+    V3_CHKPT_STD_SAVE(ctx, dbg->debug_offset);
+    
+    return 0;
+}
+
+
+static int debug_load(struct v3_chkpt_ctx * ctx, void * private_data) {
+    struct debug_state * dbg = (struct debug_state *)private_data;
+    
+    V3_CHKPT_STD_LOAD(ctx, dbg->debug_buf);
+    V3_CHKPT_STD_LOAD(ctx, dbg->debug_offset);
+    
+    return 0;
+}
+
+#endif
 
 
 
 static struct v3_device_ops dev_ops = {
-    .free = debug_free,
+    .free = (int (*)(void *))debug_free,
+#ifdef V3_CONFIG_CHECKPOINT
+    .save = debug_save,
+    .load = debug_load
+#endif 
 };
 
 
@@ -118,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;