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