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.


Release 1.0
[palacios.git] / misc / test_vm / include / geekos / serial.h
1 #ifndef SERIAL_H
2 #define SERIAL_H
3
4 #include <geekos/irq.h>
5 #include <geekos/string.h>
6 #include <geekos/io.h>
7 #include <geekos/screen.h>
8
9 #define COM1_IRQ 4
10 #define DEFAULT_SERIAL_ADDR 0x3F8
11
12
13 #ifndef SERIAL_PRINT
14 #define SERIAL_PRINT              1
15 #endif
16 #ifndef SERIAL_PRINT_DEBUG
17 #define SERIAL_PRINT_DEBUG        1 
18 #endif
19 #ifndef SERIAL_PRINT_DEBUG_LEVEL
20 #define SERIAL_PRINT_DEBUG_LEVEL  10
21 #endif
22
23 #define SERIAL_PRINT_MAXBUF       256
24  
25
26 #if SERIAL_PRINT                                                 
27 #define SerialPrint(format, args...)                             \
28 do {                                                             \
29   char buf[SERIAL_PRINT_MAXBUF];                                                 \
30   snprintf( buf, SERIAL_PRINT_MAXBUF, format, ## args ) ;                        \
31   SerialPutLineN(buf, SERIAL_PRINT_MAXBUF);                                      \
32 } while (0)  
33 #else
34 #define SerialPrint(format, args...) do {} while (0)
35 #endif
36
37
38 #define PrintBoth(format, args...) \
39 do {  \
40   Print(format, ## args); \
41   SerialPrint(format, ##args); \
42  } while (0)
43
44
45 #if SERIAL_PRINT_DEBUG
46 #define SerialPrintLevel(level, format, args...)                 \
47 do {                                                             \
48   char buf[SERIAL_PRINT_MAXBUF];                                                 \
49   if (level >= SERIAL_PRINT_DEBUG_LEVEL  ) {                                     \
50     snprintf( buf, SERIAL_PRINT_MAXBUF, format, ## args ) ;             \
51     SerialPutLineN(buf, SERIAL_PRINT_MAXBUF);                           \
52   }                                                                     \
53 } while (0)  
54 #else
55 #define SerialPrintLevel(level, format, args...) do {} while (0)
56 #endif
57
58
59 void SerialPutLine(char * line); 
60 void SerialPutLineN(char * line, int len);
61
62
63 void SerialPrintHex(unsigned char x);
64 void SerialMemDump(unsigned char *start, int n);
65
66 void InitSerial();
67 void InitSerialAddr(unsigned short io_addr);
68
69 #endif