1 #include <geekos/fmtout.h>
2 #include <geekos/string.h>
3 #include <geekos/idt.h>
4 #include <geekos/vm_cons.h>
6 #define CONS_PORT 0xc0c0
8 void VMConsPutChar(unsigned char c) {
10 Out_Byte(CONS_PORT, c);
16 void VMConsPutLineN(char * line, int len) {
18 for (i = 0; i < len && line[i] != 0; i++) {
19 VMConsPutChar(line[i]);
24 void VMConsPutLine(char * line) {
26 for (i = 0; line[i]!= 0; i++) {
27 VMConsPutChar(line[i]);
32 void VMConsPrintHex(unsigned char x)
42 void VMConsMemDump(unsigned char *start, int n)
47 VMConsPrint("%8x", (unsigned)(start+i));
48 for (j=i; j<i+16 && j<n; j+=2) {
50 VMConsPrintHex(*((unsigned char *)(start+j)));
52 VMConsPrintHex(*((unsigned char *)(start+j+1)));
56 for (j=i; j<i+16 && j<n;j++) {
57 VMConsPrint("%c", ((start[j]>=32) && (start[j]<=126)) ? start[j] : '.');
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);
68 static void VMCons_Finish(struct Output_Sink * o) { return; }
71 static void __inline__ VMConsPrintInternal(const char * format, va_list ap) {
72 Format_Output(&vm_cons_output_sink, format, ap);
76 void VMConsPrint(const char * format, ...) {
78 bool iflag = Begin_Int_Atomic();
80 va_start(args, format);
81 VMConsPrintInternal(format, args);
84 End_Int_Atomic(iflag);
87 void VMConsPrintList(const char * format, va_list ap) {
88 bool iflag = Begin_Int_Atomic();
89 VMConsPrintInternal(format, ap);
90 End_Int_Atomic(iflag);
97 void VMConsPrintLevel(int level, const char * format, ...) {
99 bool iflag = Begin_Int_Atomic();
101 va_start(args, format);
102 VMConsPrintInternal(format, args);
105 End_Int_Atomic(iflag);
110 vm_cons_output_sink.Emit = &VMCons_Emit;
111 vm_cons_output_sink.Finish = &VMCons_Finish;
113 VMConsPrint("Initializing VM Console\n");