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