1 | /* $Id: cout.h,v 1.1 1999-09-06 02:19:57 bird Exp $
|
---|
2 | *
|
---|
3 | * cout - cout replacement.
|
---|
4 | *
|
---|
5 | * Copyright (c) 1998-1999 knut st. osmundsen
|
---|
6 | *
|
---|
7 | */
|
---|
8 |
|
---|
9 | #ifndef _cout_h_
|
---|
10 | #define _cout_h_
|
---|
11 | #ifndef __cplusplus
|
---|
12 | void coutInit(USHORT usCom);
|
---|
13 | #else
|
---|
14 | extern "C" {void coutInit(USHORT usCom);}
|
---|
15 |
|
---|
16 | #ifndef OUTPUT_COM1
|
---|
17 | #define OUTPUT_COM1 0x3f8
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #ifndef OUTPUT_COM2
|
---|
21 | #define OUTPUT_COM2 0x2f8
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * @prop Provide easy Ring0 logging thru a COM port.
|
---|
26 | * @desc Provide easy Ring0 logging thru a COM port for C++ code.
|
---|
27 | * WARNING: It Yields CPU! using Yield();
|
---|
28 | * @purpose Ring0 replacement for cout.
|
---|
29 | * @author knut st. osmundsen
|
---|
30 | */
|
---|
31 | class kLog
|
---|
32 | {
|
---|
33 | private:
|
---|
34 | /** @cat Datamembers */
|
---|
35 | /** */
|
---|
36 | /** flags - hex or decimal */
|
---|
37 | int fHex;
|
---|
38 |
|
---|
39 | /** buffer to make sprintfs into */
|
---|
40 | char szBuffer[32];
|
---|
41 |
|
---|
42 | /** port-address */
|
---|
43 | unsigned long ulPort;
|
---|
44 |
|
---|
45 | /** @cat Methods */
|
---|
46 | void putch(char ch);
|
---|
47 | void putstr(const char *pszStr);
|
---|
48 |
|
---|
49 | public:
|
---|
50 | /** @cat Constructors/Destructor */
|
---|
51 | kLog();
|
---|
52 | ~kLog();
|
---|
53 |
|
---|
54 | /* @cat Methods */
|
---|
55 | void constructor(ULONG ulPort = OUTPUT_COM2);
|
---|
56 | void setf(int, int);
|
---|
57 |
|
---|
58 | /** @cat Operators */
|
---|
59 | kLog& operator<<(char);
|
---|
60 | kLog& operator<<(const char*);
|
---|
61 | kLog& operator<<(const signed char*);
|
---|
62 | kLog& operator<<(const unsigned char*);
|
---|
63 | kLog& operator<<(int);
|
---|
64 | kLog& operator<<(long); /**/
|
---|
65 | kLog& operator<<(unsigned int);
|
---|
66 | kLog& operator<<(unsigned long); /**/
|
---|
67 | kLog& operator<<(const void*); /**/
|
---|
68 | kLog& operator<<(short);
|
---|
69 | kLog& operator<<(unsigned short);
|
---|
70 |
|
---|
71 | /** @cat Enums */
|
---|
72 | enum {dec=0, hex=1, basefield=2};
|
---|
73 | };
|
---|
74 |
|
---|
75 |
|
---|
76 | /*******************/
|
---|
77 | /* debug / release */
|
---|
78 | /*******************/
|
---|
79 | #ifndef RELEASE
|
---|
80 | extern kLog _log_;
|
---|
81 | #define cout _log_
|
---|
82 | #define ios kLog
|
---|
83 | #define endl "\n"
|
---|
84 | #else
|
---|
85 | #define cout Yield();//
|
---|
86 | #define ios {}//
|
---|
87 | #define endl {}//
|
---|
88 | #endif
|
---|
89 |
|
---|
90 | #endif
|
---|
91 | #endif
|
---|
92 |
|
---|
93 |
|
---|