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.


updated test vm to current palacios version and fixed pci scan
[palacios.git] / misc / test_vm / src / geekos / vm_cons.c
1 #include <geekos/fmtout.h>
2 #include <geekos/string.h>
3 #include <geekos/idt.h>
4 #include <geekos/vm_cons.h>
5
6 #define CONS_PORT 0xc0c0
7
8 void VMConsPutChar(unsigned char c) {
9   /* send char */
10   Out_Byte(CONS_PORT, c);
11 }
12
13
14
15
16 void VMConsPutLineN(char * line, int len) {
17   int i;
18   for (i = 0; i < len && line[i] != 0; i++) { 
19     VMConsPutChar(line[i]); 
20   }
21 }
22
23
24 void VMConsPutLine(char * line) {
25   int i;
26   for (i = 0; line[i]!= 0; i++) { 
27     VMConsPutChar(line[i]); 
28   }
29 }
30
31
32 void VMConsPrintHex(unsigned char x)
33 {
34   unsigned char z;
35   
36   z = (x >> 4) & 0xf ;
37   VMConsPrint("%x", z);
38   z = x & 0xf;
39   VMConsPrint("%x", z);
40 }
41
42 void VMConsMemDump(unsigned char *start, int n)
43 {
44   int i, j;
45
46   for (i=0;i<n;i+=16) {
47     VMConsPrint("%8x", (unsigned)(start+i));
48     for (j=i; j<i+16 && j<n; j+=2) {
49       VMConsPrint(" ");
50       VMConsPrintHex(*((unsigned char *)(start+j)));
51       if ((j+1)<n) { 
52         VMConsPrintHex(*((unsigned char *)(start+j+1)));
53       }
54     }
55     VMConsPrint(" ");
56     for (j=i; j<i+16 && j<n;j++) {
57       VMConsPrint("%c", ((start[j]>=32) && (start[j]<=126)) ? start[j] : '.');
58     }
59     VMConsPrint("\n");
60   }
61 }
62
63
64 static struct Output_Sink vm_cons_output_sink;
65 static void VMCons_Emit(struct Output_Sink * o, int ch) { 
66   VMConsPutChar((unsigned char)ch); 
67 }
68 static void VMCons_Finish(struct Output_Sink * o) { return; }
69
70
71 static void __inline__ VMConsPrintInternal(const char * format, va_list ap) {
72   Format_Output(&vm_cons_output_sink, format, ap);
73 }
74
75
76 void VMConsPrint(const char * format, ...) {
77   va_list args;
78   bool iflag = Begin_Int_Atomic();
79
80   va_start(args, format);
81   VMConsPrintInternal(format, args);
82   va_end(args);
83
84   End_Int_Atomic(iflag);
85 }
86
87 void VMConsPrintList(const char * format, va_list ap) {
88   bool iflag = Begin_Int_Atomic();
89   VMConsPrintInternal(format, ap);
90   End_Int_Atomic(iflag);
91
92 }
93
94
95
96
97 void VMConsPrintLevel(int level, const char * format, ...) {
98     va_list args;
99     bool iflag = Begin_Int_Atomic();
100     
101     va_start(args, format);
102     VMConsPrintInternal(format, args);
103     va_end(args);
104     
105     End_Int_Atomic(iflag);   
106 }
107
108 void Init_VMCons() {
109
110     vm_cons_output_sink.Emit = &VMCons_Emit;
111     vm_cons_output_sink.Finish = &VMCons_Finish;
112
113     VMConsPrint("Initializing VM Console\n");
114
115     return;
116 }