uint_t cons_offset;
};
-static int handle_info_write(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
+static int handle_info_write(struct guest_info * core, ushort_t port, void * src, uint_t length, struct vm_device * dev) {
struct debug_state * state = (struct debug_state *)dev->private_data;
state->info_buf[state->info_offset++] = *(char*)src;
}
-static int handle_debug_write(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
+static int handle_debug_write(struct guest_info * core, ushort_t port, void * src, uint_t length, struct vm_device * dev) {
struct debug_state * state = (struct debug_state *)dev->private_data;
state->debug_buf[state->debug_offset++] = *(char*)src;
}
-static int handle_console_write(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
+static int handle_console_write(struct guest_info * core, ushort_t port, void * src, uint_t length, struct vm_device * dev) {
struct debug_state * state = (struct debug_state *)dev->private_data;
- state->cons_buf[state->cons_offset++] = *(char*)src;
+ state->cons_buf[state->cons_offset++] = *(char *)src;
- if ((*(char*)src == 0xa) || (state->cons_offset == (BUF_SIZE - 1))) {
- PrintDebug("BOCHSCONSOLE>%s", state->cons_buf);
+ if ((*(char *)src == 0xa) || (state->cons_offset == (BUF_SIZE - 1))) {
+ V3_Print("BOCHSCONSOLE>%s", state->cons_buf);
memset(state->cons_buf, 0, BUF_SIZE);
state->cons_offset = 0;
}
}
-static int handle_gen_write(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
+static int handle_gen_write(struct guest_info * core, ushort_t port, void * src, uint_t length, struct vm_device * dev) {
switch (length) {
case 1:
-static int debug_init(struct guest_info * vm, void * cfg_data) {
- struct debug_state * state = NULL;
+static int debug_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
+ struct debug_state * state = NULL;
+ char * dev_id = v3_cfg_val(cfg, "ID");
state = (struct debug_state *)V3_Malloc(sizeof(struct debug_state));
V3_ASSERT(state != NULL);
PrintDebug("Creating Bochs Debug Device\n");
- struct vm_device * dev = v3_allocate_device("BOCHS_DEBUG", &dev_ops, state);
+ struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state);
if (v3_attach_device(vm, dev) == -1) {
- PrintError("Could not attach device %s\n", "BOCHS_DEBUG");
+ PrintError("Could not attach device %s\n", dev_id);
return -1;
}
state->debug_offset = 0;
state->info_offset = 0;
+ state->cons_offset = 0;
memset(state->debug_buf, 0, BUF_SIZE);
memset(state->info_buf, 0, BUF_SIZE);
+ memset(state->cons_buf, 0, BUF_SIZE);
v3_dev_hook_io(dev, BOCHS_PORT1, NULL, &handle_gen_write);