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.


created a test directory to hold test guest OSes
[palacios.git] / test / geekos_test_vm / src / geekos / vm_cons.c
diff --git a/test/geekos_test_vm/src/geekos/vm_cons.c b/test/geekos_test_vm/src/geekos/vm_cons.c
new file mode 100644 (file)
index 0000000..9c2e5a4
--- /dev/null
@@ -0,0 +1,116 @@
+#include <geekos/fmtout.h>
+#include <geekos/string.h>
+#include <geekos/idt.h>
+#include <geekos/vm_cons.h>
+
+#define CONS_PORT 0xc0c0
+
+void VMConsPutChar(unsigned char c) {
+  /* send char */
+  Out_Byte(CONS_PORT, c);
+}
+
+
+
+
+void VMConsPutLineN(char * line, int len) {
+  int i;
+  for (i = 0; i < len && line[i] != 0; i++) { 
+    VMConsPutChar(line[i]); 
+  }
+}
+
+
+void VMConsPutLine(char * line) {
+  int i;
+  for (i = 0; line[i]!= 0; i++) { 
+    VMConsPutChar(line[i]); 
+  }
+}
+
+
+void VMConsPrintHex(unsigned char x)
+{
+  unsigned char z;
+  
+  z = (x >> 4) & 0xf ;
+  VMConsPrint("%x", z);
+  z = x & 0xf;
+  VMConsPrint("%x", z);
+}
+
+void VMConsMemDump(unsigned char *start, int n)
+{
+  int i, j;
+
+  for (i=0;i<n;i+=16) {
+    VMConsPrint("%8x", (unsigned)(start+i));
+    for (j=i; j<i+16 && j<n; j+=2) {
+      VMConsPrint(" ");
+      VMConsPrintHex(*((unsigned char *)(start+j)));
+      if ((j+1)<n) { 
+       VMConsPrintHex(*((unsigned char *)(start+j+1)));
+      }
+    }
+    VMConsPrint(" ");
+    for (j=i; j<i+16 && j<n;j++) {
+      VMConsPrint("%c", ((start[j]>=32) && (start[j]<=126)) ? start[j] : '.');
+    }
+    VMConsPrint("\n");
+  }
+}
+
+
+static struct Output_Sink vm_cons_output_sink;
+static void VMCons_Emit(struct Output_Sink * o, int ch) { 
+  VMConsPutChar((unsigned char)ch); 
+}
+static void VMCons_Finish(struct Output_Sink * o) { return; }
+
+
+static void __inline__ VMConsPrintInternal(const char * format, va_list ap) {
+  Format_Output(&vm_cons_output_sink, format, ap);
+}
+
+
+void VMConsPrint(const char * format, ...) {
+  va_list args;
+  bool iflag = Begin_Int_Atomic();
+
+  va_start(args, format);
+  VMConsPrintInternal(format, args);
+  va_end(args);
+
+  End_Int_Atomic(iflag);
+}
+
+void VMConsPrintList(const char * format, va_list ap) {
+  bool iflag = Begin_Int_Atomic();
+  VMConsPrintInternal(format, ap);
+  End_Int_Atomic(iflag);
+
+}
+
+
+
+
+void VMConsPrintLevel(int level, const char * format, ...) {
+    va_list args;
+    bool iflag = Begin_Int_Atomic();
+    
+    va_start(args, format);
+    VMConsPrintInternal(format, args);
+    va_end(args);
+    
+    End_Int_Atomic(iflag);   
+}
+
+void Init_VMCons() {
+
+    vm_cons_output_sink.Emit = &VMCons_Emit;
+    vm_cons_output_sink.Finish = &VMCons_Finish;
+
+    VMConsPrint("Initializing VM Console\n");
+
+    return;
+}