| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #include <config.h> |
|---|
| 20 | #include <module.h> |
|---|
| 21 | #include <stdarg.h> |
|---|
| 22 | #include <string.h> |
|---|
| 23 | #include <typedefs.h> |
|---|
| 24 | |
|---|
| 25 | #include <i386/ioports.h> |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | #define CONSOLE_OUT_LEN 256 |
|---|
| 29 | |
|---|
| 30 | static void (*ConsoleOutput)(char* message, int length) = NULL; |
|---|
| 31 | |
|---|
| 32 | void KeSetOutput(void (*newOutput)(char*, int)) |
|---|
| 33 | { |
|---|
| 34 | ConsoleOutput=newOutput; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | SYMBOL_EXPORT(KeSetOutput); |
|---|
| 38 | |
|---|
| 39 | int logLevelUnknown=1; |
|---|
| 40 | int currLogLevel=-1; |
|---|
| 41 | |
|---|
| 42 | void KeVaPrint(const char* message, VaList args) |
|---|
| 43 | { |
|---|
| 44 | char buf[CONSOLE_OUT_LEN]; |
|---|
| 45 | char outputBuf[CONSOLE_OUT_LEN]; |
|---|
| 46 | char* start; |
|---|
| 47 | int length=0; |
|---|
| 48 | |
|---|
| 49 | length = vsnprintf(buf, CONSOLE_OUT_LEN, message, args); |
|---|
| 50 | |
|---|
| 51 | if (!length) |
|---|
| 52 | return; |
|---|
| 53 | |
|---|
| 54 | length = 0; |
|---|
| 55 | |
|---|
| 56 | for (start=buf; *start; start++) |
|---|
| 57 | { |
|---|
| 58 | if (logLevelUnknown) |
|---|
| 59 | { |
|---|
| 60 | |
|---|
| 61 | if (*start == '<') |
|---|
| 62 | { |
|---|
| 63 | currLogLevel=*(start+1)-'0'; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | start+=3; |
|---|
| 67 | }else |
|---|
| 68 | currLogLevel=1; |
|---|
| 69 | |
|---|
| 70 | logLevelUnknown=0; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | if (currLogLevel <= KERN_LOG_LEVEL) |
|---|
| 74 | outputBuf[length++]=*start; |
|---|
| 75 | |
|---|
| 76 | if (*start == '\n') |
|---|
| 77 | logLevelUnknown=1; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | outputBuf[length]='\0'; |
|---|
| 81 | |
|---|
| 82 | ConsoleOutput(outputBuf, length); |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | SYMBOL_EXPORT(KeVaPrint); |
|---|
| 86 | |
|---|
| 87 | void KePrint(const char* message, ...) |
|---|
| 88 | { |
|---|
| 89 | VaList args; |
|---|
| 90 | |
|---|
| 91 | VaStart(args, message); |
|---|
| 92 | KeVaPrint(message, args); |
|---|
| 93 | VaEnd(args); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | SYMBOL_EXPORT(KePrint); |
|---|