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.


added new debugging directives
Jack Lange [Mon, 21 Jul 2008 22:54:44 +0000 (22:54 +0000)]
palacios/build/Makefile
palacios/include/palacios/vmm_decoder.h
palacios/src/devices/8254.c
palacios/src/devices/8259a.c
palacios/src/devices/keyboard.c
palacios/src/devices/nvram.c
palacios/src/palacios/svm.c
palacios/src/palacios/svm_handler.c
palacios/src/palacios/vm_guest_mem.c
palacios/src/palacios/vmm_ctrl_regs.c
palacios/src/palacios/vmm_io.c

index 3ced5a9..79f3d7d 100644 (file)
@@ -1,6 +1,6 @@
 # Makefile for GeekOS kernel, userspace, and tools
 # Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
-# $Revision: 1.47 $
+# $Revision: 1.48 $
 
 # This is free software.  You are permitted to use,
 # redistribute, and modify it as specified in the file "COPYING".
@@ -46,6 +46,34 @@ VPATH := $(PROJECT_ROOT)/src
 # as are SERIAL_PRINT_DEBUG
 # 
 DEBUG=1
+DEBUG_SECTIONS= 
+
+ifeq ($(DEBUG_SHADOW_PAGING),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_SHADOW_PAGING
+endif
+ifeq ($(DEBUG_CTRL_REGS),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_CTRL_REGS
+endif
+ifeq ($(DEBUG_INTERRUPTS),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_INTERRUPTS
+endif
+ifeq ($(DEBUG_IO),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_IO
+endif
+ifeq ($(DEBUG_KEYBOARD),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_KEYBOARD
+endif
+ifeq ($(DEBUG_PIC),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIC
+endif
+ifeq ($(DEBUG_DEBUG_PIT),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_PIT
+endif
+ifeq ($(DEBUG_NVRAM),1)
+DEBUG_SECTIONS := $(DEBUG_SECTIONS) -DDEBUG_NVRAM
+endif
+
+
 
 #
 # XED=1 means that libxed will be included
@@ -57,8 +85,8 @@ DEBUG=1
 XED=0
 
 ifeq ($(DEBUG),1)
-  JRLDEBUG= -DSERIAL_PRINT_DEBUG=1 -DSERIAL_PRINT_DEBUG_LEVEL=10 -DSERIAL_PRINT=1 -DVMM_DEBUG=1 -DVMM_INFO=1 -DVMM_TRACE=1 
-#-DDEBUG_SHADOW_PAGING -DDEBUG_CTRL_REGS -DDEBUG_INTERRUPTS -DDEBUG_IO
+  JRLDEBUG= -DSERIAL_PRINT_DEBUG=1 -DSERIAL_PRINT_DEBUG_LEVEL=10 -DSERIAL_PRINT=1 -DVMM_DEBUG=1 -DVMM_INFO=1 -DVMM_TRACE=1 $(DEBUG_SECTIONS)
+
 else
   JRLDEBUG= -DSERIAL_PRINT_DEBUG=0 -DSERIAL_PRINT_DEBUG_LEVEL=999999 -DSERIAL_PRINT=0 -DVMM_DEBUG=0 -DVMM_INFO=0 -DVMM_TRACE=0
 endif
index aeb758d..ef08031 100644 (file)
@@ -257,14 +257,14 @@ static inline operand_type_t decode_operands16(struct v3_gprs * gprs, // input/o
   operand_type_t addr_type = INVALID_OPERAND;
   char * instr_cursor = modrm_instr;
 
-  PrintDebug("ModRM mod=%d\n", modrm->mod);
+  //  PrintDebug("ModRM mod=%d\n", modrm->mod);
 
   instr_cursor += 1;
 
   if (modrm->mod == 3) {
     mod_mode = REG;
     addr_type = REG_OPERAND;
-    PrintDebug("first operand = Register (RM=%d)\n",modrm->rm);
+    //PrintDebug("first operand = Register (RM=%d)\n",modrm->rm);
 
     *first_operand = decode_register(gprs, modrm->rm, reg_size);
 
@@ -355,7 +355,7 @@ static inline operand_type_t decode_operands32(struct v3_gprs * gprs, // input/o
     mod_mode = REG;
     addr_type = REG_OPERAND;
     
-    PrintDebug("first operand = Register (RM=%d)\n",modrm->rm);
+    //    PrintDebug("first operand = Register (RM=%d)\n",modrm->rm);
 
     *first_operand = decode_register(gprs, modrm->rm, reg_size);
 
index 7c0de12..df0c169 100644 (file)
@@ -6,7 +6,10 @@
 
 
 
-
+#ifndef DEBUG_PIT
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
 
 
 
@@ -402,7 +405,7 @@ static int pit_read_channel(ushort_t port, void * dst, uint_t length, struct vm_
   char * val = (char *)dst;
 
   if (length != 1) {
-    PrintDebug("8254 PIT: Invalid Read Write length \n");
+    PrintError("8254 PIT: Invalid Read Write length \n");
     return -1;
   }
 
@@ -425,7 +428,7 @@ static int pit_read_channel(ushort_t port, void * dst, uint_t length, struct vm_
     }
     break;
   default:
-    PrintDebug("8254 PIT: Read from invalid port (%d)\n", port);
+    PrintError("8254 PIT: Read from invalid port (%d)\n", port);
     return -1;
   }
 
@@ -439,7 +442,7 @@ static int pit_write_channel(ushort_t port, void * src, uint_t length, struct vm
   char val = *(char *)src;
 
   if (length != 1) {
-    PrintDebug("8254 PIT: Invalid Write Length\n");
+    PrintError("8254 PIT: Invalid Write Length\n");
     return -1;
   }
 
@@ -463,7 +466,7 @@ static int pit_write_channel(ushort_t port, void * src, uint_t length, struct vm
     }
     break;
   default:
-    PrintDebug("8254 PIT: Write to invalid port (%d)\n", port);
+    PrintError("8254 PIT: Write to invalid port (%d)\n", port);
     return -1;
   }
 
@@ -480,7 +483,7 @@ static int pit_write_command(ushort_t port, void * src, uint_t length, struct vm
   PrintDebug("8254 PIT: Write to PIT Command port\n");
   PrintDebug("8254 PIT: Writing to channel %d (access_mode = %d, op_mode = %d)\n", cmd->channel, cmd->access_mode, cmd->op_mode);
   if (length != 1) {
-    PrintDebug("8254 PIT: Write of Invalid length to command port\n");
+    PrintError("8254 PIT: Write of Invalid length to command port\n");
     return -1;
   }
 
@@ -549,10 +552,11 @@ static int pit_init(struct vm_device * dev) {
   dev_hook_io(dev, CHANNEL2_PORT, &pit_read_channel, &pit_write_channel);
   dev_hook_io(dev, COMMAND_PORT, NULL, &pit_write_command);
 
+#ifdef DEBUG_PIT
   PrintDebug("8254 PIT: OSC_HZ=%d, reload_val=", OSC_HZ);
   PrintTraceLL(reload_val);
   PrintDebug("\n");
-
+#endif
 
   v3_add_timer(dev->vm, &timer_ops, dev);
 
@@ -568,9 +572,11 @@ static int pit_init(struct vm_device * dev) {
   init_channel(&(state->ch_1));
   init_channel(&(state->ch_2));
 
+#ifdef DEBUG_PIT
   PrintDebug("8254 PIT: CPU MHZ=%d -- pit count=", cpu_khz / 1000);
   PrintTraceLL(state->pit_counter);
   PrintDebug("\n");
+#endif
 
   return 0;
 }
index 2851946..deabacd 100644 (file)
@@ -3,6 +3,10 @@
 #include <palacios/vmm_types.h>
 #include <palacios/vmm.h>
 
+#ifndef DEBUG_PIC
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
 
 typedef enum {RESET, ICW1, ICW2, ICW3, ICW4,  READY} pic_state_t;
 
@@ -170,7 +174,7 @@ static int pic_raise_intr(void * private_data, int irq) {
   } else if ((irq > 7) && (irq < 16)) {
     state->slave_irr |= 0x01 << (irq - 8);  // PAD if -7 then irq 15=no irq
   } else {
-    PrintDebug("8259 PIC: Invalid IRQ raised (%d)\n", irq);
+    PrintError("8259 PIC: Invalid IRQ raised (%d)\n", irq);
     return -1;
   }
 
@@ -240,7 +244,7 @@ static int pic_begin_irq(void * private_data, int irq) {
     irq &= 0x7;
     irq += 8;
   } else {
-    PrintDebug("8259 PIC: Could not find IRQ (0x%x) to Begin\n",irq);
+    PrintError("8259 PIC: Could not find IRQ (0x%x) to Begin\n",irq);
     return -1;
   }
 
@@ -278,7 +282,7 @@ int read_master_port1(ushort_t port, void * dst, uint_t length, struct vm_device
   struct pic_internal * state = (struct pic_internal*)dev->private_data;
 
   if (length != 1) {
-    PrintDebug("8259 PIC: Invalid Read length (rd_Master1)\n");
+    PrintError("8259 PIC: Invalid Read length (rd_Master1)\n");
     return -1;
   }
   
@@ -297,7 +301,7 @@ int read_master_port2(ushort_t port, void * dst, uint_t length, struct vm_device
   struct pic_internal * state = (struct pic_internal*)dev->private_data;
 
   if (length != 1) {
-    PrintDebug("8259 PIC: Invalid Read length (rd_Master2)\n");
+    PrintError("8259 PIC: Invalid Read length (rd_Master2)\n");
     return -1;
   }
 
@@ -311,7 +315,7 @@ int read_slave_port1(ushort_t port, void * dst, uint_t length, struct vm_device
   struct pic_internal * state = (struct pic_internal*)dev->private_data;
 
   if (length != 1) {
-    PrintDebug("8259 PIC: Invalid Read length (rd_Slave1)\n");
+    PrintError("8259 PIC: Invalid Read length (rd_Slave1)\n");
     return -1;
   }
   
@@ -330,7 +334,7 @@ int read_slave_port2(ushort_t port, void * dst, uint_t length, struct vm_device
   struct pic_internal * state = (struct pic_internal*)dev->private_data;
 
   if (length != 1) {
-    PrintDebug("8259 PIC: Invalid Read length  (rd_Slave2)\n");
+    PrintError("8259 PIC: Invalid Read length  (rd_Slave2)\n");
     return -1;
   }
 
@@ -345,7 +349,7 @@ int write_master_port1(ushort_t port, void * src, uint_t length, struct vm_devic
   uchar_t cw = *(uchar_t *)src;
 
   if (length != 1) {
-    PrintDebug("8259 PIC: Invalid Write length (wr_Master1)\n");
+    PrintError("8259 PIC: Invalid Write length (wr_Master1)\n");
     return -1;
   }
   
@@ -374,7 +378,7 @@ int write_master_port1(ushort_t port, void * src, uint_t length, struct vm_devic
        }       
                PrintDebug("8259 PIC: Post ISR = %x (wr_Master1)\n", state->master_isr);
       } else {
-       PrintDebug("8259 PIC: Command not handled, or in error (wr_Master1)\n");
+       PrintError("8259 PIC: Command not handled, or in error (wr_Master1)\n");
        return -1;
       }
 
@@ -382,13 +386,13 @@ int write_master_port1(ushort_t port, void * src, uint_t length, struct vm_devic
     } else if (IS_OCW3(cw)) {
       state->master_ocw3 = cw;
     } else {
-      PrintDebug("8259 PIC: Invalid OCW to PIC (wr_Master1)\n");
-      PrintDebug("8259 PIC: CW=%x\n", cw);
+      PrintError("8259 PIC: Invalid OCW to PIC (wr_Master1)\n");
+      PrintError("8259 PIC: CW=%x\n", cw);
       return -1;
     }
   } else {
-    PrintDebug("8259 PIC: Invalid PIC State (wr_Master1)\n");
-    PrintDebug("8259 PIC: CW=%x\n", cw);
+    PrintError("8259 PIC: Invalid PIC State (wr_Master1)\n");
+    PrintError("8259 PIC: CW=%x\n", cw);
     return -1;
   }
 
@@ -400,7 +404,7 @@ int write_master_port2(ushort_t port, void * src, uint_t length, struct vm_devic
     uchar_t cw = *(uchar_t *)src;    
 
     if (length != 1) {
-      PrintDebug("8259 PIC: Invalid Write length (wr_Master2)\n");
+      PrintError("8259 PIC: Invalid Write length (wr_Master2)\n");
       return -1;
     }
     
@@ -436,7 +440,7 @@ int write_master_port2(ushort_t port, void * src, uint_t length, struct vm_devic
       state->master_imr = cw;
     } else {
       // error
-      PrintDebug("8259 PIC: Invalid master PIC State (wr_Master2)\n");
+      PrintError("8259 PIC: Invalid master PIC State (wr_Master2)\n");
       return -1;
     }
 
@@ -449,7 +453,7 @@ int write_slave_port1(ushort_t port, void * src, uint_t length, struct vm_device
 
   if (length != 1) {
     // error
-    PrintDebug("8259 PIC: Invalid Write length (wr_Slave1)\n");
+    PrintError("8259 PIC: Invalid Write length (wr_Slave1)\n");
     return -1;
   }
 
@@ -476,7 +480,7 @@ int write_slave_port1(ushort_t port, void * src, uint_t length, struct vm_device
        }       
                PrintDebug("8259 PIC: Post ISR = %x (wr_Slave1)\n", state->slave_isr);
       } else {
-       PrintDebug("8259 PIC: Command not handled or invalid  (wr_Slave1)\n");
+       PrintError("8259 PIC: Command not handled or invalid  (wr_Slave1)\n");
        return -1;
       }
 
@@ -485,11 +489,11 @@ int write_slave_port1(ushort_t port, void * src, uint_t length, struct vm_device
       // Basically sets the IRR/ISR read flag
       state->slave_ocw3 = cw;
     } else {
-      PrintDebug("8259 PIC: Invalid command work (wr_Slave1)\n");
+      PrintError("8259 PIC: Invalid command work (wr_Slave1)\n");
       return -1;
     }
   } else {
-    PrintDebug("8259 PIC: Invalid State writing (wr_Slave1)\n");
+    PrintError("8259 PIC: Invalid State writing (wr_Slave1)\n");
     return -1;
   }
 
@@ -501,7 +505,7 @@ int write_slave_port2(ushort_t port, void * src, uint_t length, struct vm_device
     uchar_t cw = *(uchar_t *)src;    
 
     if (length != 1) {
-      PrintDebug("8259 PIC: Invalid write length (wr_Slave2)\n");
+      PrintError("8259 PIC: Invalid write length (wr_Slave2)\n");
       return -1;
     }
 
@@ -535,7 +539,7 @@ int write_slave_port2(ushort_t port, void * src, uint_t length, struct vm_device
     } else if (state->slave_state == READY) {
       state->slave_imr = cw;
     } else {
-      PrintDebug("8259 PIC: Invalid State at write (wr_Slave2)\n");
+      PrintError("8259 PIC: Invalid State at write (wr_Slave2)\n");
       return -1;
     }
 
index 4173bda..fe4e443 100644 (file)
@@ -3,15 +3,14 @@
 #include <palacios/vmm.h>
 #include <palacios/vmm_types.h>
 
-#define KEYBOARD_DEBUG 1
+
+#ifndef DEBUG_KEYBOARD
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
 
 #define KEYBOARD_DEBUG_80H   0
 
-#if KEYBOARD_DEBUG
-#define KEYBOARD_DEBUG_PRINT(first, rest...) PrintDebug(first, ##rest)
-#else
-#define KEYBOARD_DEBUG_PRINT(first, rest...)
-#endif
 
 
 #define KEYBOARD_60H          0x60  // keyboard microcontroller
@@ -223,7 +222,7 @@ static int PushToOutputQueue(struct vm_device *dev, uchar_t value, uchar_t overw
     return 0;
 
   } else {
-    KEYBOARD_DEBUG_PRINT("keyboard: PushToOutputQueue Failed - Queue Full\n");
+    PrintError("keyboard: PushToOutputQueue Failed - Queue Full\n");
     return -1;
   }
 }
@@ -257,7 +256,7 @@ static int PullFromOutputQueue(struct vm_device *dev, uchar_t *value)
     
     return 0;
   } else {
-    KEYBOARD_DEBUG_PRINT("keyboard: PullFromOutputQueue Failed - Queue Empty\n");
+    PrintError("keyboard: PullFromOutputQueue Failed - Queue Empty\n");
     return -1;
   }
 }
@@ -280,7 +279,7 @@ static int PushToInputQueue(struct vm_device *dev, uchar_t value, uchar_t overwr
 
     return 0;
   } else {
-    KEYBOARD_DEBUG_PRINT("keyboard: PushToOutputQueue Failed - Queue Full\n");
+    PrintError("keyboard: PushToOutputQueue Failed - Queue Full\n");
     return -1;
   }
 }
@@ -301,8 +300,7 @@ static int PullFromInputQueue(struct vm_device *dev, uchar_t *value)
 
     return 0;
   } else {
-    KEYBOARD_DEBUG_PRINT("keyboard: PullFromInputQueue Failed - Queue Empty\n");
-
+    PrintError("keyboard: PullFromInputQueue Failed - Queue Empty\n");
     return -1;
   }
 }
@@ -328,7 +326,7 @@ void deliver_key_to_vmm(uchar_t status, uchar_t scancode)
   struct vm_device *dev = demultiplex_injected_key(status, scancode);
   struct keyboard_internal *state = (struct keyboard_internal *)(dev->private_data);
 
-  KEYBOARD_DEBUG_PRINT("keyboard: injected status 0x%x, and scancode 0x%x\n", status, scancode);
+  PrintDebug("keyboard: injected status 0x%x, and scancode 0x%x\n", status, scancode);
   
   if ( (state->status_byte & STATUS_ENABLED)      // onboard is enabled
        && (!(state->cmd_byte & CMD_DISABLE)) )  {   // keyboard is enabled
@@ -348,7 +346,7 @@ void deliver_mouse_to_vmm(uchar_t data[3])
   struct vm_device *dev = demultiplex_injected_mouse(data);
   struct keyboard_internal *state = (struct keyboard_internal *)(dev->private_data);
 
-  KEYBOARD_DEBUG_PRINT("keyboard: injected mouse packet 0x %x %x %x\n",data[0],data[1],data[2]);
+  PrintDebug("keyboard: injected mouse packet 0x %x %x %x\n",data[0],data[1],data[2]);
   
   memcpy(state->mouse_packet,data,3);
   
@@ -398,7 +396,7 @@ int keyboard_reset_device(struct vm_device * dev)
 
   
 
-  KEYBOARD_DEBUG_PRINT("keyboard: reset device\n");
+  PrintDebug("keyboard: reset device\n");
  
   return 0;
 
@@ -408,14 +406,14 @@ int keyboard_reset_device(struct vm_device * dev)
 
 int keyboard_start_device(struct vm_device *dev)
 {
-  KEYBOARD_DEBUG_PRINT("keyboard: start device\n");
+  PrintDebug("keyboard: start device\n");
   return 0;
 }
 
 
 int keyboard_stop_device(struct vm_device *dev)
 {
-  KEYBOARD_DEBUG_PRINT("keyboard: stop device\n");
+  PrintDebug("keyboard: stop device\n");
   return 0;
 }
 
@@ -437,78 +435,78 @@ int mouse_read_input(struct vm_device *dev)
   switch (state->mouse_state) { 
   case RESET1: // requesting the BAT code
     PushToOutputQueue(dev,0xaa,OVERWRITE,DATA,MOUSE) ;  // BAT successful
-    KEYBOARD_DEBUG_PRINT(" mouse sent BAT code (sucesssful) ");
+    PrintDebug(" mouse sent BAT code (sucesssful) ");
     state->mouse_state=RESET2;
     return 0;  // not done with mouse processing yet
     break;
   case RESET2: // requesting the device id
     PushToOutputQueue(dev,0x00,OVERWRITE,DATA,MOUSE) ;  // normal mouse type
-    KEYBOARD_DEBUG_PRINT(" mouse sent device id ");
+    PrintDebug(" mouse sent device id ");
     state->mouse_state=STREAM1;
     return 1;  // done with mouse processing 
     break;
   case STREAM1: // send data
     PushToOutputQueue(dev,state->mouse_packet[0],OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent stream data1 ");
+    PrintDebug(" mouse sent stream data1 ");
     state->mouse_state=STREAM2;
     return 0;
     break;
   case STREAM2: // send data
     PushToOutputQueue(dev,state->mouse_packet[1],OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent stream data2 ");
+    PrintDebug(" mouse sent stream data2 ");
     state->mouse_state=STREAM3;
     return 0;
     break;
   case STREAM3: // send data
     PushToOutputQueue(dev,state->mouse_packet[2],OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent stream data3 ");
+    PrintDebug(" mouse sent stream data3 ");
     state->mouse_state=STREAM1;
     return 1; // now done
     break;
   case REMOTE1: // send data
     PushToOutputQueue(dev,state->mouse_packet[0],OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent remote data1 ");
+    PrintDebug(" mouse sent remote data1 ");
     state->mouse_state=REMOTE2;
     return 0;
     break;
   case REMOTE2: // send data
     PushToOutputQueue(dev,state->mouse_packet[1],OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent remote data2 ");
+    PrintDebug(" mouse sent remote data2 ");
     state->mouse_state=REMOTE3;
     return 0;
     break;
   case REMOTE3: // send data
     PushToOutputQueue(dev,state->mouse_packet[2],OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent remote data3 ");
+    PrintDebug(" mouse sent remote data3 ");
     state->mouse_state=REMOTE1;
     return 1; // now done
     break;
   case STATUS1: // send data
     PushToOutputQueue(dev,0x0,OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent status data1 ");
+    PrintDebug(" mouse sent status data1 ");
     state->mouse_state=STATUS2;
     return 0;
     break;
   case STATUS2: // send data
     PushToOutputQueue(dev,0x0,OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent status data2 ");
+    PrintDebug(" mouse sent status data2 ");
     state->mouse_state=STATUS3;
     return 0;
     break;
   case STATUS3: // send data
     PushToOutputQueue(dev,0x0,OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent status data3 ");
+    PrintDebug(" mouse sent status data3 ");
     state->mouse_state=STREAM1;
     return 1; // now done
     break;
   case DEVICE1: // send device id
     PushToOutputQueue(dev,0x0,OVERWRITE,DATA,MOUSE); 
-    KEYBOARD_DEBUG_PRINT(" mouse sent device id ");
+    PrintDebug(" mouse sent device id ");
     state->mouse_state=STREAM1;
     return 1; // now done
     break;
   default:
-    KEYBOARD_DEBUG_PRINT(" mouse has no data ");
+    PrintDebug(" mouse has no data ");
     return 1; // done
     break;
   }
@@ -529,14 +527,14 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
 
     case 0xff: //reset
       PushToOutputQueue(dev,0xfe,OVERWRITE,DATA,MOUSE) ;   // no mouse!
-      KEYBOARD_DEBUG_PRINT(" mouse reset begins (no mouse) ");
+      PrintDebug(" mouse reset begins (no mouse) ");
       return 1;  // not done;
       break;
 
       /*
     case 0xff: //reset
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
-      KEYBOARD_DEBUG_PRINT(" mouse reset begins ");
+      PrintDebug(" mouse reset begins ");
       state->mouse_done_after_ack=0;
       state->mouse_needs_ack=1;
       state->mouse_state=RESET1;
@@ -545,7 +543,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       */
     case 0xfe: //resend
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
-      KEYBOARD_DEBUG_PRINT(" mouse resend begins ");
+      PrintDebug(" mouse resend begins ");
       state->mouse_done_after_ack=0;
       state->mouse_needs_ack=0;
       state->mouse_state=STREAM1;
@@ -554,7 +552,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       
     case 0xf6: // set defaults
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
-      KEYBOARD_DEBUG_PRINT(" mouse set defaults ");
+      PrintDebug(" mouse set defaults ");
       state->mouse_done_after_ack=1;
       state->mouse_needs_ack=1;
       state->mouse_state=STREAM1;
@@ -565,7 +563,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=1;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse disable data reporting ");
+      PrintDebug(" mouse disable data reporting ");
       state->mouse_state=STREAM1;
       return 0; // not done
       break;
@@ -574,7 +572,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=1;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse enable data reporting ");
+      PrintDebug(" mouse enable data reporting ");
       state->mouse_state=STREAM1;
       return 0; // not done
       break;
@@ -583,7 +581,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=0;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse set sample rate begins ");
+      PrintDebug(" mouse set sample rate begins ");
       state->mouse_state=SAMPLE1;
       return 0; // not done
       break;
@@ -592,7 +590,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=0;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse get device id begins ");
+      PrintDebug(" mouse get device id begins ");
       state->mouse_state=DEVICE1;
       return 0; // not done
       break;
@@ -601,7 +599,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=1;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse set remote mode  ");
+      PrintDebug(" mouse set remote mode  ");
       state->mouse_state=REMOTE1;
       return 0; // not done
       break;
@@ -610,7 +608,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=1;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse set wrap mode (ignored)  ");
+      PrintDebug(" mouse set wrap mode (ignored)  ");
       state->mouse_state=STREAM1;
       return 0; // not done
       break;
@@ -619,7 +617,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=1;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse reset wrap mode (ignored)  ");
+      PrintDebug(" mouse reset wrap mode (ignored)  ");
       state->mouse_state=STREAM1;
       return 0; // done
       break;
@@ -628,7 +626,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=0;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse switch to wrap mode (ignored)  ");
+      PrintDebug(" mouse switch to wrap mode (ignored)  ");
       state->mouse_state=REMOTE1;
       return 0; // not done
       break;
@@ -637,7 +635,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=1;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse set stream mode  ");
+      PrintDebug(" mouse set stream mode  ");
       state->mouse_state=STREAM1;
       return 0; // not done
       break;
@@ -646,7 +644,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=0;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse status request begins  ");
+      PrintDebug(" mouse status request begins  ");
       state->mouse_state=STATUS1;
       return 0; // notdone
       break;
@@ -655,7 +653,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=0;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse set resolution begins  ");
+      PrintDebug(" mouse set resolution begins  ");
       state->mouse_state=SETRES1;
       return 0; // notdone
       break;
@@ -664,7 +662,7 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=1;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse set scaling 2:1 ");
+      PrintDebug(" mouse set scaling 2:1 ");
       state->mouse_state=STREAM1;
       return 0; // not done
       break;
@@ -673,26 +671,26 @@ int mouse_write_output(struct vm_device *dev, uchar_t data)
       PushToOutputQueue(dev,0xfa,OVERWRITE,DATA,MOUSE) ; 
       state->mouse_done_after_ack=1;
       state->mouse_needs_ack=1;
-      KEYBOARD_DEBUG_PRINT(" mouse set scaling 1:1 ");
+      PrintDebug(" mouse set scaling 1:1 ");
       state->mouse_state=STREAM1;
       return 0; // done
       break;
       
     default:
-      KEYBOARD_DEBUG_PRINT(" receiving unknown mouse command (0x%x) in acceptable state ",data);
+      PrintDebug(" receiving unknown mouse command (0x%x) in acceptable state ",data);
       return 1; // done
       break;
 
     }
     
   default:
-    KEYBOARD_DEBUG_PRINT(" receiving mouse output in unhandled state (0x%x) ",state->mouse_state);
+    PrintDebug(" receiving mouse output in unhandled state (0x%x) ",state->mouse_state);
     break;
     return 1; // done?
     break;
   }
 
-  KEYBOARD_DEBUG_PRINT(" HUH? ");
+  PrintDebug(" HUH? ");
   return 1; // done
 }
 
@@ -706,11 +704,11 @@ int keyboard_write_delay(ushort_t port,
 {
 
   if (length == 1) { 
-    KEYBOARD_DEBUG_PRINT("keyboard: write of 0x%x to 80h\n", *((uchar_t*)src));
+    PrintDebug("keyboard: write of 0x%x to 80h\n", *((uchar_t*)src));
 
     return 1;
   } else {
-    KEYBOARD_DEBUG_PRINT("keyboard: write of >1 byte to 80h\n", *((uchar_t*)src));
+    PrintDebug("keyboard: write of >1 byte to 80h\n", *((uchar_t*)src));
 
     return length;
   }
@@ -725,11 +723,11 @@ int keyboard_read_delay(ushort_t port,
   if (length == 1) { 
     *((uchar_t*)dest) = In_Byte(port);
 
-    KEYBOARD_DEBUG_PRINT("keyboard: read of 0x%x from 80h\n", *((uchar_t*)dest));
+    PrintDebug("keyboard: read of 0x%x from 80h\n", *((uchar_t*)dest));
 
     return 1;
   } else {
-    KEYBOARD_DEBUG_PRINT("keyboard: read of >1 byte from 80h\n");
+    PrintDebug("keyboard: read of >1 byte from 80h\n");
 
     return length;
   }
@@ -751,29 +749,29 @@ int keyboard_write_command(ushort_t port,
   // Should always be single byte write
 
   if (length != 1) { 
-    KEYBOARD_DEBUG_PRINT("keyboard: write of >1 bytes (%d) to 64h\n", length);
+    PrintError("keyboard: write of >1 bytes (%d) to 64h\n", length);
     return -1;
   }
 
   cmd = *((uchar_t*)src); 
 
   if (state->state != NORMAL) { 
-    KEYBOARD_DEBUG_PRINT("keyboard: warning - receiving command on 64h but state != NORMAL\n");
+    PrintDebug("keyboard: warning - receiving command on 64h but state != NORMAL\n");
   }
   
-  KEYBOARD_DEBUG_PRINT("keyboard: command 0x%x on 64h\n", cmd);
+  PrintDebug("keyboard: command 0x%x on 64h\n", cmd);
 
   switch (cmd) { 
 
   case 0x20:  // READ COMMAND BYTE (returned in 60h)
     PushToOutputQueue(dev, state->cmd_byte, OVERWRITE, COMMAND,KEYBOARD);
     state->state = NORMAL;  // the next read on 0x60 will get the right data
-    KEYBOARD_DEBUG_PRINT("keyboard: command byte 0x%x returned\n",state->cmd_byte);
+    PrintDebug("keyboard: command byte 0x%x returned\n",state->cmd_byte);
     break;
 
   case 0x60:  // WRITE COMMAND BYTE (read from 60h)
     state->state = WRITING_CMD_BYTE; // we need to make sure we send the next 0x60 byte appropriately
-    KEYBOARD_DEBUG_PRINT("keyboard: prepare to write command byte\n");
+    PrintDebug("keyboard: prepare to write command byte\n");
     break;
 
   // case 0x90-9f - write to output port  (?)
@@ -781,19 +779,19 @@ int keyboard_write_command(ushort_t port,
   case 0xa1: // Get version number
     PushToOutputQueue(dev, 0, OVERWRITE, COMMAND,KEYBOARD);
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: version number 0x0 returned\n");
+    PrintDebug("keyboard: version number 0x0 returned\n");
     break;
 
   case 0xa4:  // is password installed?  send result to 0x60
     // we don't support passwords
     PushToOutputQueue(dev, 0xf1, OVERWRITE, COMMAND,KEYBOARD);
-    KEYBOARD_DEBUG_PRINT("keyboard: password not installed\n");
+    PrintDebug("keyboard: password not installed\n");
     state->state = NORMAL;
     break;
 
   case 0xa5:  // new password will arrive on 0x60
     state->state = TRANSMIT_PASSWD;
-    KEYBOARD_DEBUG_PRINT("keyboard: pepare to transmit password\n");
+    PrintDebug("keyboard: pepare to transmit password\n");
     break;
 
   case 0xa6:  // check passwd;
@@ -801,107 +799,107 @@ int keyboard_write_command(ushort_t port,
     // the implication is that any password check immediately succeeds 
     // with a blank password
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: password check succeeded\n");
+    PrintDebug("keyboard: password check succeeded\n");
     break;
 
   case 0xa7:  // disable mouse
     state->cmd_byte |= CMD_MOUSE_DISABLE;
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: mouse disabled\n");
+    PrintDebug("keyboard: mouse disabled\n");
     break;
 
   case 0xa8:  // enable mouse
     state->cmd_byte &= ~CMD_MOUSE_DISABLE;
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: mouse enabled\n");
+    PrintDebug("keyboard: mouse enabled\n");
     break;
 
   case 0xa9:  // mouse interface test  (always succeeds)
     PushToOutputQueue(dev, 0, OVERWRITE,COMMAND,KEYBOARD);
-    KEYBOARD_DEBUG_PRINT("keyboard: mouse interface test succeeded\n");
+    PrintDebug("keyboard: mouse interface test succeeded\n");
     state->state = NORMAL;
     break;
 
   case 0xaa:  // controller self test (always succeeds)
     PushToOutputQueue(dev, 0x55, OVERWRITE, COMMAND,KEYBOARD);
-    KEYBOARD_DEBUG_PRINT("keyboard: controller self test succeeded\n");
+    PrintDebug("keyboard: controller self test succeeded\n");
     state->state = NORMAL;
     break;
 
   case 0xab:  // keyboard interface test (always succeeds)
     PushToOutputQueue(dev, 0, OVERWRITE, COMMAND,KEYBOARD);
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: keyboard interface test succeeded\n");
+    PrintDebug("keyboard: keyboard interface test succeeded\n");
     break;
 
   case 0xad:  // disable keyboard
     state->cmd_byte |= CMD_DISABLE;
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: keyboard disabled\n");
+    PrintDebug("keyboard: keyboard disabled\n");
     break;
 
   case 0xae:  // enable keyboard
     state->cmd_byte &= ~CMD_DISABLE;
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: keyboard enabled\n");
+    PrintDebug("keyboard: keyboard enabled\n");
     break;
 
   case 0xaf:  // get version
     PushToOutputQueue(dev, 0x00, OVERWRITE, COMMAND,KEYBOARD);
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: version 0 returned \n");
+    PrintDebug("keyboard: version 0 returned \n");
     break;
 
   case 0xd0: // return microcontroller output on 60h
     PushToOutputQueue(dev,state->output_byte,OVERWRITE,COMMAND,KEYBOARD);
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: output byte 0x%x returned\n",state->output_byte);
+    PrintDebug("keyboard: output byte 0x%x returned\n",state->output_byte);
     break;
 
   case 0xd1: // request to write next byte on 60h to the microcontroller output port
     state->state = WRITING_OUTPUT_PORT;
-    KEYBOARD_DEBUG_PRINT("keyboard: prepare to write output byte\n");
+    PrintDebug("keyboard: prepare to write output byte\n");
     break;
 
   case 0xd2:  //  write keyboard buffer (inject key)
     state->state = INJECTING_KEY;
-    KEYBOARD_DEBUG_PRINT("keyboard: prepare to inject key\n");
+    PrintDebug("keyboard: prepare to inject key\n");
     break;
 
   case 0xd3: //  write mouse buffer (inject mouse)
     state->state = INJECTING_MOUSE;
-    KEYBOARD_DEBUG_PRINT("keyboard: prepare to inject mouse\n");
+    PrintDebug("keyboard: prepare to inject mouse\n");
     break;
 
   case 0xd4: // write mouse device (command to mouse?)
     state->state = IN_MOUSE;
-    KEYBOARD_DEBUG_PRINT("keyboard: prepare to inject mouse command\n");
+    PrintDebug("keyboard: prepare to inject mouse command\n");
     break;
 
   case 0xc0: //  read input port 
     PushToOutputQueue(dev,state->input_byte,OVERWRITE,COMMAND,KEYBOARD);
     state->state=NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: input byte 0x%x returned\n",state->input_byte);
+    PrintDebug("keyboard: input byte 0x%x returned\n",state->input_byte);
     break;
 
   case 0xc1:  //copy input port lsn to status msn
     state->status_byte &= 0x0f;
     state->status_byte |= (state->input_byte & 0xf)<<4;
     state->state=NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: copied input byte lsn to status msn\n");
+    PrintDebug("keyboard: copied input byte lsn to status msn\n");
     break;
 
   case 0xc2: // copy input port msn to status msn
     state->status_byte &= 0x0f;
     state->status_byte |= (state->input_byte & 0xf0);
     state->state=NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: copied input byte msn to status msn\n");
+    PrintDebug("keyboard: copied input byte msn to status msn\n");
     break;
     
   case 0xe0: // read test port
     PushToOutputQueue(dev,state->output_byte>>6,OVERWRITE,COMMAND,KEYBOARD);
     state->state=NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: read 0x%x from test port\n",state->output_byte>>6);
+    PrintDebug("keyboard: read 0x%x from test port\n",state->output_byte>>6);
     break;
 
    
@@ -922,14 +920,14 @@ int keyboard_write_command(ushort_t port,
   case 0xfe:
   case 0xff:
   
-    KEYBOARD_DEBUG_PRINT("keyboard: ignoring pulse of 0x%x (low=pulsed) on output port\n",cmd&0xf);
+    PrintDebug("keyboard: ignoring pulse of 0x%x (low=pulsed) on output port\n",cmd&0xf);
     state->state=NORMAL;
     break;
    
 
   // case ac  diagonstic - returns 16 bytes from keyboard microcontroler on 60h
   default:
-    KEYBOARD_DEBUG_PRINT("keyboard: ignoring command (unimplemented)\n");
+    PrintDebug("keyboard: ignoring command (unimplemented)\n");
     state->state = NORMAL;
     break;
   }
@@ -947,15 +945,15 @@ int keyboard_read_status(ushort_t port,
 
   if (length == 1) { 
 
-    KEYBOARD_DEBUG_PRINT("keyboard: read status (64h): ");
+    PrintDebug("keyboard: read status (64h): ");
 
     *((uchar_t*)dest) = state->status_byte;
 
-    KEYBOARD_DEBUG_PRINT("0x%x\n", *((uchar_t*)dest));
+    PrintDebug("0x%x\n", *((uchar_t*)dest));
 
     return 1;
   } else {
-    KEYBOARD_DEBUG_PRINT("keyboard: >1 byte read for status (64h)\n");
+    PrintError("keyboard: >1 byte read for status (64h)\n");
     return -1;
   }
 }
@@ -968,49 +966,49 @@ int keyboard_write_output(ushort_t port,
   struct keyboard_internal *state = (struct keyboard_internal *)(dev->private_data);
 
   if (length != 1) { 
-    KEYBOARD_DEBUG_PRINT("keyboard: write of 60h with >1 byte\n");
+    PrintError("keyboard: write of 60h with >1 byte\n");
     return -1;
   }
 
   uchar_t data = *((uchar_t*)src);
   
-  KEYBOARD_DEBUG_PRINT("keyboard: output 0x%x on 60h\n", data);
+  PrintDebug("keyboard: output 0x%x on 60h\n", data);
 
   switch (state->state) {
   case WRITING_CMD_BYTE:
     state->cmd_byte = data;
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: wrote new command byte 0x%x\n",state->cmd_byte);
+    PrintDebug("keyboard: wrote new command byte 0x%x\n",state->cmd_byte);
     break;
   case WRITING_OUTPUT_PORT:
     state->output_byte = data;
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: wrote new output byte 0x%x\n",state->output_byte);
+    PrintDebug("keyboard: wrote new output byte 0x%x\n",state->output_byte);
     break;
   case INJECTING_KEY:
     PushToOutputQueue(dev,data,OVERWRITE,COMMAND,KEYBOARD);  // probably should be a call to deliver_key_to_vmm()
     state->state = NORMAL;
-    KEYBOARD_DEBUG_PRINT("keyboard: injected key 0x%x\n",data);
+    PrintDebug("keyboard: injected key 0x%x\n",data);
     break;
   case INJECTING_MOUSE:
-    KEYBOARD_DEBUG_PRINT("keyboard: ignoring injected mouse event 0x%x\n",data);
+    PrintDebug("keyboard: ignoring injected mouse event 0x%x\n",data);
     state->state = NORMAL;
     break;
   case IN_MOUSE:
-    KEYBOARD_DEBUG_PRINT("keyboard: mouse action: ");
+    PrintDebug("keyboard: mouse action: ");
     if (mouse_write_output(dev,data)) { 
       state->state=NORMAL;
     }
-    KEYBOARD_DEBUG_PRINT("\n");
+    PrintDebug("\n");
     break;
   case TRANSMIT_PASSWD:
     if (data) {
       //ignore passwd
-      KEYBOARD_DEBUG_PRINT("keyboard: ignoring password character 0x%x\n",data);
+      PrintDebug("keyboard: ignoring password character 0x%x\n",data);
     } else {
       // end of password
       state->state = NORMAL;
-      KEYBOARD_DEBUG_PRINT("keyboard: done with password\n");
+      PrintDebug("keyboard: done with password\n");
     }
     break;
   case NORMAL:
@@ -1020,7 +1018,7 @@ int keyboard_write_output(ushort_t port,
       case 0xff: // reset
        PushToOutputQueue(dev, 0xfa, OVERWRITE, COMMAND,KEYBOARD); // ack
        state->state = RESET;
-       KEYBOARD_DEBUG_PRINT("keyboard: reset complete and acked\n",data);
+       PrintDebug("keyboard: reset complete and acked\n",data);
        break;
       case 0xf5: // disable scanning
       case 0xf4: // enable scanning
@@ -1028,7 +1026,7 @@ int keyboard_write_output(ushort_t port,
        PushToOutputQueue(dev, 0xfa, OVERWRITE, COMMAND,KEYBOARD);
        // should do something here... PAD
        state->state = NORMAL;
-       KEYBOARD_DEBUG_PRINT("keyboard: %s scanning done and acked\n",data==0xf5 ? "disable" : "enable", data);
+       PrintDebug("keyboard: %s scanning done and acked\n",data==0xf5 ? "disable" : "enable", data);
        break;
       case 0xfe: // resend
       case 0xfd: // set key type make
@@ -1040,17 +1038,17 @@ int keyboard_write_output(ushort_t port,
       case 0xf7: // set all typemaktic
       case 0xf6: // set defaults
       case 0xf3: // set typematic delay/rate
-       KEYBOARD_DEBUG_PRINT("keyboard: unhandled known command 0x%x on output buffer (60h)\n", data);
+       PrintDebug("keyboard: unhandled known command 0x%x on output buffer (60h)\n", data);
        break;
       default:
-       KEYBOARD_DEBUG_PRINT("keyboard: unhandled unknown command 0x%x on output buffer (60h)\n", data);
+       PrintDebug("keyboard: unhandled unknown command 0x%x on output buffer (60h)\n", data);
        state->status_byte |= 0x1;
        break;
       }
       break;
     }
   default:
-    KEYBOARD_DEBUG_PRINT("keyboard: unknown state %x on command 0x%x on output buffer (60h)\n", state->state, data);
+    PrintDebug("keyboard: unknown state %x on command 0x%x on output buffer (60h)\n", state->state, data);
   }
   
   return 1;
@@ -1067,7 +1065,7 @@ int keyboard_read_input(ushort_t port,
     uchar_t data;
     int done_mouse;
 
-    KEYBOARD_DEBUG_PRINT("keyboard: read from input (60h): ");
+    PrintDebug("keyboard: read from input (60h): ");
 
     if (state->state==IN_MOUSE) { 
       done_mouse=mouse_read_input(dev);
@@ -1083,16 +1081,16 @@ int keyboard_read_input(ushort_t port,
       // now we will ready ourselves to deliver the BAT code (success)
       PushToOutputQueue(dev, 0xaa, OVERWRITE,COMMAND,KEYBOARD);
       state->state = NORMAL;
-      KEYBOARD_DEBUG_PRINT(" (in reset, pushing BAT test code 0xaa) ");
+      PrintDebug(" (in reset, pushing BAT test code 0xaa) ");
     }
       
-    KEYBOARD_DEBUG_PRINT("0x%x\n", data);
+    PrintDebug("0x%x\n", data);
 
     *((uchar_t*)dest) = data;
     
     return 1;
   } else {
-    KEYBOARD_DEBUG_PRINT("keyboard: unknown size read from input (60h)\n");
+    PrintError("keyboard: unknown size read from input (60h)\n");
     return -1;
   }
 }
@@ -1100,7 +1098,7 @@ int keyboard_read_input(ushort_t port,
 
 int keyboard_interrupt(uint_t irq, struct vm_device * dev) 
 {
-  KEYBOARD_DEBUG_PRINT("keyboard: interrupt 0x%x\n",irq);
+  PrintDebug("keyboard: interrupt 0x%x\n",irq);
 
   dev->vm->vm_ops.raise_irq(dev->vm, irq);
 
@@ -1114,7 +1112,7 @@ int keyboard_init_device(struct vm_device * dev)
  
   //  struct keyboard_internal *data = (struct keyboard_internal *) dev->private_data;
 
-  KEYBOARD_DEBUG_PRINT("keyboard: init_device\n");
+  PrintDebug("keyboard: init_device\n");
 
   // Would read state here
 
@@ -1167,7 +1165,7 @@ static struct vm_device_ops dev_ops = {
 struct vm_device *create_keyboard() {
   
   if (thekeyboard != NULL) { 
-    KEYBOARD_DEBUG_PRINT("keyboard: creating >1 keyboard device.  This will probably fail!\n");
+    PrintDebug("keyboard: creating >1 keyboard device.  This will probably fail!\n");
   }
   
   struct keyboard_internal * keyboard_state = (struct keyboard_internal *)V3_Malloc(sizeof(struct keyboard_internal));
index 624179f..ef37366 100644 (file)
@@ -2,9 +2,15 @@
 #include <palacios/vmm.h>
 #include <palacios/vmm_types.h>
 
-extern struct vmm_os_hooks *os_hooks;
 
-extern void SerialPrint(const char *format, ...);
+#ifndef DEBUG_NVRAM
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
+
+
+
+
 
 #define NVRAM_REG_PORT  0x70
 #define NVRAM_DATA_PORT 0x71
@@ -153,7 +159,7 @@ int nvram_reset_device(struct vm_device * dev)
 {
   struct nvram_internal *data = (struct nvram_internal *) dev->private_data;
   
-  SerialPrint("nvram: reset device\n");
+  PrintDebug("nvram: reset device\n");
 
  
 
@@ -171,14 +177,14 @@ int nvram_reset_device(struct vm_device * dev)
 
 int nvram_start_device(struct vm_device *dev)
 {
-  SerialPrint("nvram: start device\n");
+  PrintDebug("nvram: start device\n");
   return 0;
 }
 
 
 int nvram_stop_device(struct vm_device *dev)
 {
-  SerialPrint("nvram: stop device\n");
+  PrintDebug("nvram: stop device\n");
   return 0;
 }
 
@@ -241,7 +247,7 @@ int nvram_init_device(struct vm_device * dev) {
  
   struct nvram_internal *data = (struct nvram_internal *) dev->private_data;
 
-  SerialPrint("nvram: init_device\n");
+  PrintDebug("nvram: init_device\n");
 
   memset(data->mem_state, 0, NVRAM_REG_MAX);
 
@@ -284,9 +290,9 @@ static struct vm_device_ops dev_ops = {
 
 
 struct vm_device *create_nvram() {
-  struct nvram_internal * nvram_state = os_hooks->malloc(sizeof(struct nvram_internal)+1000);
+  struct nvram_internal * nvram_state = (struct nvram_internal *)V3_Malloc(sizeof(struct nvram_internal)+1000);
 
-  SerialPrint("internal at %x\n",nvram_state);
+  PrintDebug("internal at %x\n",nvram_state);
 
   struct vm_device *device = create_device("NVRAM", &dev_ops, nvram_state);
 
index 55bda95..28967fb 100644 (file)
@@ -72,19 +72,22 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) {
   // guest_state->cr0 = 0x00000001;    // PE 
   ctrl_area->guest_ASID = 1;
 
-  ctrl_area->exceptions.de = 1;
-  ctrl_area->exceptions.df = 1;
-
-  ctrl_area->exceptions.ts = 1;
-  ctrl_area->exceptions.ss = 1;
-  ctrl_area->exceptions.ac = 1;
-  ctrl_area->exceptions.mc = 1;
-  ctrl_area->exceptions.gp = 1;
-  ctrl_area->exceptions.ud = 1;
-  ctrl_area->exceptions.np = 1;
-  ctrl_area->exceptions.of = 1;
-  ctrl_area->exceptions.nmi = 1;
-
+  
+  /*
+    ctrl_area->exceptions.de = 1;
+    ctrl_area->exceptions.df = 1;
+    
+    ctrl_area->exceptions.ts = 1;
+    ctrl_area->exceptions.ss = 1;
+    ctrl_area->exceptions.ac = 1;
+    ctrl_area->exceptions.mc = 1;
+    ctrl_area->exceptions.gp = 1;
+    ctrl_area->exceptions.ud = 1;
+    ctrl_area->exceptions.np = 1;
+    ctrl_area->exceptions.of = 1;
+  
+    ctrl_area->exceptions.nmi = 1;
+  */
   // Debug of boot on physical machines - 7/14/08
   ctrl_area->instrs.NMI=1;
   ctrl_area->instrs.SMI=1;
@@ -272,7 +275,7 @@ static int start_svm_guest(struct guest_info *info) {
     EnableInts();
     CLGI();
 
-    PrintDebug("SVM Entry to rip=%x...\n", info->rip);
+    //    PrintDebug("SVM Entry to rip=%x...\n", info->rip);
 
     rdtscll(info->time_state.cached_host_tsc);
     guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc;
index 1545cad..18ea2e3 100644 (file)
@@ -230,17 +230,22 @@ int handle_svm_exit(struct guest_info * info) {
 
     PrintError("Host Address of rip = 0x%x\n", host_addr);
 
-    memset(buf, 0, 15);
+    memset(buf, 0, 32);
     
-    PrintError("Reading from 0x%x in guest\n", rip_addr);
+    PrintError("Reading instruction stream in guest\n", rip_addr);
     
     if (info->mem_mode == PHYSICAL_MEM) {
-      read_guest_pa_memory(info, rip_addr, 15, buf);
+      read_guest_pa_memory(info, rip_addr-16, 32, buf);
     } else {
-      read_guest_va_memory(info, rip_addr, 15, buf);
+      read_guest_va_memory(info, rip_addr-16, 32, buf);
     }
 
-    PrintTraceMemDump(buf, 15);
+    PrintDebug("16 bytes before Rip\n");
+    PrintTraceMemDump(buf, 16);
+    PrintDebug("Rip onward\n");
+    PrintTraceMemDump(buf+16, 16);
+
+
 
     return -1;
 
index 21c1b54..e2ca0bf 100644 (file)
@@ -15,11 +15,11 @@ int host_va_to_host_pa(addr_t host_va, addr_t * host_pa) {
     *host_pa = (addr_t)(os_hooks)->vaddr_to_paddr((void *)host_va);
   
     if (*host_pa == 0) {
-      PrintDebug("In HVA->HPA: Invalid HVA(%x)->HPA lookup\n", host_va);
+      PrintError("In HVA->HPA: Invalid HVA(%x)->HPA lookup\n", host_va);
       return -1;
     }
   } else {
-    PrintDebug("In HVA->HPA: os_hooks not defined\n");
+    PrintError("In HVA->HPA: os_hooks not defined\n");
     return -1;
   }
   return 0;
@@ -32,11 +32,11 @@ int host_pa_to_host_va(addr_t host_pa, addr_t * host_va) {
     *host_va = (addr_t)(os_hooks)->paddr_to_vaddr((void *)host_pa);
     
     if (*host_va == 0) {
-      PrintDebug("In HPA->HVA: Invalid HPA(%x)->HVA lookup\n", host_pa);
+      PrintError("In HPA->HVA: Invalid HPA(%x)->HVA lookup\n", host_pa);
       return -1;
     }
   } else {
-    PrintDebug("In HPA->HVA: os_hooks not defined\n");
+    PrintError("In HPA->HVA: os_hooks not defined\n");
     return -1;
   }
   return 0;
@@ -47,7 +47,7 @@ int host_pa_to_host_va(addr_t host_pa, addr_t * host_va) {
 int guest_pa_to_host_pa(struct guest_info * guest_info, addr_t guest_pa, addr_t * host_pa) {
   // we use the shadow map here...
   if (lookup_shadow_map_addr(&(guest_info->mem_map), guest_pa, host_pa) != HOST_REGION_PHYSICAL_MEMORY) {
-    PrintDebug("In GPA->HPA: Could not find address in shadow map (addr=%x)\n", guest_pa);
+    PrintError("In GPA->HPA: Could not find address in shadow map (addr=%x)\n", guest_pa);
     return -1;
   }
 
@@ -61,7 +61,7 @@ int guest_pa_to_host_pa(struct guest_info * guest_info, addr_t guest_pa, addr_t
 // 
 int host_pa_to_guest_pa(struct guest_info * guest_info, addr_t host_pa, addr_t * guest_pa) {
   *guest_pa = 0;
-  PrintDebug("ERROR!!! HPA->GPA currently not implemented!!!\n");
+  PrintError("ERROR!!! HPA->GPA currently not implemented!!!\n");
 
   return -1;
 }
@@ -80,12 +80,12 @@ int host_va_to_guest_pa(struct guest_info * guest_info, addr_t host_va, addr_t *
   *guest_pa = 0;
 
   if (host_va_to_host_pa(host_va, &host_pa) != 0) {
-    PrintDebug("In HVA->GPA: Invalid HVA(%x)->HPA lookup\n", host_va);
+    PrintError("In HVA->GPA: Invalid HVA(%x)->HPA lookup\n", host_va);
     return -1;
   }
 
   if (host_pa_to_guest_pa(guest_info, host_pa, guest_pa) != 0) {
-    PrintDebug("In HVA->GPA: Invalid HPA(%x)->GPA lookup\n", host_pa);
+    PrintError("In HVA->GPA: Invalid HPA(%x)->GPA lookup\n", host_pa);
     return -1;
   }
 
@@ -101,12 +101,12 @@ int guest_pa_to_host_va(struct guest_info * guest_info, addr_t guest_pa, addr_t
   *host_va = 0;
 
   if (guest_pa_to_host_pa(guest_info, guest_pa, &host_pa) != 0) {
-    PrintDebug("In GPA->HVA: Invalid GPA(%x)->HPA lookup\n", guest_pa);
+    PrintError("In GPA->HVA: Invalid GPA(%x)->HPA lookup\n", guest_pa);
     return -1;
   }
   
   if (host_pa_to_host_va(host_pa, host_va) != 0) {
-    PrintDebug("In GPA->HVA: Invalid HPA(%x)->HVA lookup\n", host_pa);
+    PrintError("In GPA->HVA: Invalid HPA(%x)->HVA lookup\n", host_pa);
     return -1;
   }
 
@@ -138,7 +138,7 @@ int guest_va_to_guest_pa(struct guest_info * guest_info, addr_t guest_va, addr_t
       }
       
       if (guest_pa_to_host_va(guest_info, guest_pde, (addr_t *)&pde) == -1) {
-       PrintDebug("In GVA->GPA: Invalid GPA(%x)->HVA PDE32 lookup\n", guest_pde);
+       PrintError("In GVA->GPA: Invalid GPA(%x)->HVA PDE32 lookup\n", guest_pde);
        return -1;
       }
       
@@ -156,14 +156,14 @@ int guest_va_to_guest_pa(struct guest_info * guest_info, addr_t guest_va, addr_t
          
          
          if (guest_pa_to_host_va(guest_info, tmp_pa, (addr_t*)&pte) == -1) {
-           PrintDebug("In GVA->GPA: Invalid GPA(%x)->HVA PTE32 lookup\n", guest_pa);
+           PrintError("In GVA->GPA: Invalid GPA(%x)->HVA PTE32 lookup\n", guest_pa);
            return -1;
          }
          
-         PrintDebug("PTE host addr=%x, GVA=%x, GPA=%x(should be 0)\n", pte, guest_va, *guest_pa);
-         
+         //PrintDebug("PTE host addr=%x, GVA=%x, GPA=%x(should be 0)\n", pte, guest_va, *guest_pa);
+        
          if (pte32_lookup(pte, guest_va, guest_pa) != 0) {
-           PrintDebug("In GVA->GPA: PTE32 Lookup failure GVA=%x; PTE=%x\n", guest_va, pte);
+           PrintError("In GVA->GPA: PTE32 Lookup failure GVA=%x; PTE=%x\n", guest_va, pte);
            //        PrintPT32(PDE32_INDEX(guest_va) << 22, pte);
            return -1;
          }
@@ -200,7 +200,7 @@ int guest_va_to_guest_pa(struct guest_info * guest_info, addr_t guest_va, addr_t
  */
 int guest_pa_to_guest_va(struct guest_info * guest_info, addr_t guest_pa, addr_t * guest_va) {
   *guest_va = 0;
-  PrintDebug("ERROR!!: GPA->GVA Not Implemented!!\n");
+  PrintError("ERROR!!: GPA->GVA Not Implemented!!\n");
   return -1;
 }
 
@@ -216,12 +216,12 @@ int guest_va_to_host_pa(struct guest_info * guest_info, addr_t guest_va, addr_t
   *host_pa = 0;
 
   if (guest_va_to_guest_pa(guest_info, guest_va, &guest_pa) != 0) {
-    PrintDebug("In GVA->HPA: Invalid GVA(%x)->GPA lookup\n", guest_va);
+    PrintError("In GVA->HPA: Invalid GVA(%x)->GPA lookup\n", guest_va);
     return -1;
   }
   
   if (guest_pa_to_host_pa(guest_info, guest_pa, host_pa) != 0) {
-    PrintDebug("In GVA->HPA: Invalid GPA(%x)->HPA lookup\n", guest_pa);
+    PrintError("In GVA->HPA: Invalid GPA(%x)->HPA lookup\n", guest_pa);
     return -1;
   }
 
@@ -235,12 +235,12 @@ int host_pa_to_guest_va(struct guest_info * guest_info, addr_t host_pa, addr_t *
   *guest_va = 0;
 
   if (host_pa_to_guest_pa(guest_info, host_pa, &guest_pa) != 0) {
-    PrintDebug("In HPA->GVA: Invalid HPA(%x)->GPA lookup\n", host_pa);
+    PrintError("In HPA->GVA: Invalid HPA(%x)->GPA lookup\n", host_pa);
     return -1;
   }
 
   if (guest_pa_to_guest_va(guest_info, guest_pa, guest_va) != 0) {
-    PrintDebug("In HPA->GVA: Invalid GPA(%x)->GVA lookup\n", guest_pa);
+    PrintError("In HPA->GVA: Invalid GPA(%x)->GVA lookup\n", guest_pa);
     return -1;
   }
 
@@ -257,17 +257,17 @@ int guest_va_to_host_va(struct guest_info * guest_info, addr_t guest_va, addr_t
   *host_va = 0;
 
   if (guest_va_to_guest_pa(guest_info, guest_va, &guest_pa) != 0) {
-    PrintDebug("In GVA->HVA: Invalid GVA(%x)->GPA lookup\n", guest_va);
+    PrintError("In GVA->HVA: Invalid GVA(%x)->GPA lookup\n", guest_va);
     return -1;
   }
 
   if (guest_pa_to_host_pa(guest_info, guest_pa, &host_pa) != 0) {
-    PrintDebug("In GVA->HVA: Invalid GPA(%x)->HPA lookup\n", guest_pa);
+    PrintError("In GVA->HVA: Invalid GPA(%x)->HPA lookup\n", guest_pa);
     return -1;
   }
 
   if (host_pa_to_host_va(host_pa, host_va) != 0) {
-    PrintDebug("In GVA->HVA: Invalid HPA(%x)->HVA lookup\n", host_pa);
+    PrintError("In GVA->HVA: Invalid HPA(%x)->HVA lookup\n", host_pa);
     return -1;
   }
 
@@ -283,17 +283,17 @@ int host_va_to_guest_va(struct guest_info * guest_info, addr_t host_va, addr_t *
   *guest_va = 0;
 
   if (host_va_to_host_pa(host_va, &host_pa) != 0) {
-    PrintDebug("In HVA->GVA: Invalid HVA(%x)->HPA lookup\n", host_va);
+    PrintError("In HVA->GVA: Invalid HVA(%x)->HPA lookup\n", host_va);
     return -1;
   }
 
   if (host_pa_to_guest_pa(guest_info, host_pa, &guest_pa) != 0) {
-    PrintDebug("In HVA->GVA: Invalid HPA(%x)->GPA lookup\n", host_va);
+    PrintError("In HVA->GVA: Invalid HPA(%x)->GPA lookup\n", host_va);
     return -1;
   }
 
   if (guest_pa_to_guest_va(guest_info, guest_pa, guest_va) != 0) {
-    PrintDebug("In HVA->GVA: Invalid GPA(%x)->GVA lookup\n", guest_pa);
+    PrintError("In HVA->GVA: Invalid GPA(%x)->GVA lookup\n", guest_pa);
     return -1;
   }
 
@@ -319,36 +319,6 @@ int read_guest_va_memory(struct guest_info * guest_info, addr_t guest_va, int co
     int bytes_to_copy = (dist_to_pg_edge > count) ? count : dist_to_pg_edge;
     addr_t host_addr = 0;
 
-
-
-    /* JRL FIXME:
-     * This should be somewhere else....
-     */
-    /*  
-  addr_t tmp_addr;
-      
-    addr_t shadow_pde = CR3_TO_PDE32(guest_info->shdw_pg_state.shadow_cr3);
-    
-    // Check the Shadow Page Tables first (Virtual TLB)
-    if (pt32_lookup((pde32_t *)shadow_pde, cursor, &tmp_addr) == 0) {
-      host_addr = tmp_addr;
-
-      if (host_pa_to_host_va(tmp_addr, &host_addr) != 0) {
-       return bytes_read;
-      }
-    } else {
-    
-      // No entry in the VTLB, do a guest page table walk
-   
-      if (guest_va_to_host_va(guest_info, cursor, &host_addr) != 0) {
-       PrintDebug("Invalid GVA(%x)->HVA lookup\n", cursor);
-       return bytes_read;
-      }
-    }
-*/
-    /* JRL: END GRUESOME HACK */
-
-
     
     if (guest_va_to_host_va(guest_info, cursor, &host_addr) != 0) {
       PrintDebug("Invalid GVA(%x)->HVA lookup\n", cursor);
index 3615671..b21dc85 100644 (file)
@@ -17,6 +17,11 @@ extern void SerialMemDump(unsigned char *start, int n);
  */
 
 
+#ifndef VMM_CTRL_REGS
+#undef PrintDebug
+#define PrintDebug(fmt, args...)
+#endif
+
 int handle_cr0_write(struct guest_info * info) {
   char instr[15];
   
index 420085a..81febc7 100644 (file)
@@ -2,7 +2,7 @@
 #include <palacios/vmm_string.h>
 #include <palacios/vmm.h>
 
-extern struct vmm_os_hooks * os_hooks;
+
 
 
 #ifndef DEBUG_IO
@@ -132,7 +132,7 @@ int hook_io_port(vmm_io_map_t * io_map, uint_t port,
                 int (*read)(ushort_t port, void * dst, uint_t length, void * priv_data),
                 int (*write)(ushort_t port, void * src, uint_t length, void * priv_data), 
                 void * priv_data) {
-  vmm_io_hook_t * io_hook = os_hooks->malloc(sizeof(vmm_io_hook_t));
+  vmm_io_hook_t * io_hook = (vmm_io_hook_t *)V3_Malloc(sizeof(vmm_io_hook_t));
 
   io_hook->port = port;