mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-15 01:09:18 +00:00
.github
.vscode
Architecture
Core
Interrupts
Memory
Video
CPU.cpp
CrashHandler.cpp
Debugger.cpp
Lock.cpp
PeripheralComponentInterconnect.cpp
Power.cpp
README.md
Random.cpp
StackGuard.c
Symbols.cpp
Time.cpp
Timer.cpp
UniversalAsynchronousReceiverTransmitter.cpp
crashhandler.hpp
Library
SystemCalls
Tasking
include
.gitignore
Doxyfile
Fennix Kernel.code-workspace
KConfig.cpp
KThread.cpp
Kernel.cpp
LICENSE
Makefile
README.md
kernel.h
90 lines
2.3 KiB
C++
90 lines
2.3 KiB
C++
#include <debug.h>
|
|
|
|
#include <uart.hpp>
|
|
#include <printf.h>
|
|
#include <lock.hpp>
|
|
|
|
NewLock(DebuggerLock);
|
|
|
|
using namespace UniversalAsynchronousReceiverTransmitter;
|
|
|
|
static inline void uart_wrapper(char c, void *unused)
|
|
{
|
|
UART(COM1).Write(c);
|
|
(void)unused;
|
|
}
|
|
|
|
static inline void WritePrefix(DebugLevel Level, const char *File, int Line, const char *Function)
|
|
{
|
|
const char *DbgLvlString;
|
|
switch (Level)
|
|
{
|
|
case DebugLevelError:
|
|
DbgLvlString = "ERROR";
|
|
break;
|
|
case DebugLevelWarning:
|
|
DbgLvlString = "WARN ";
|
|
break;
|
|
case DebugLevelInfo:
|
|
DbgLvlString = "INFO ";
|
|
break;
|
|
case DebugLevelDebug:
|
|
DbgLvlString = "DEBUG";
|
|
break;
|
|
case DebugLevelTrace:
|
|
DbgLvlString = "TRACE";
|
|
break;
|
|
case DebugLevelFixme:
|
|
DbgLvlString = "FIXME";
|
|
break;
|
|
default:
|
|
DbgLvlString = "UNKNW";
|
|
break;
|
|
}
|
|
fctprintf(uart_wrapper, nullptr, "%s|%s->%s:%d: ", DbgLvlString, File, Function, Line);
|
|
}
|
|
|
|
namespace SysDbg
|
|
{
|
|
void Write(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
|
|
{
|
|
WritePrefix(Level, File, Line, Function);
|
|
va_list args;
|
|
va_start(args, Format);
|
|
vfctprintf(uart_wrapper, nullptr, Format, args);
|
|
va_end(args);
|
|
}
|
|
|
|
void WriteLine(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
|
|
{
|
|
// SmartLock(DebuggerLock);
|
|
WritePrefix(Level, File, Line, Function);
|
|
va_list args;
|
|
va_start(args, Format);
|
|
vfctprintf(uart_wrapper, nullptr, Format, args);
|
|
va_end(args);
|
|
uart_wrapper('\n', nullptr);
|
|
}
|
|
}
|
|
|
|
// C compatibility
|
|
extern "C" void SysDbgWrite(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
|
|
{
|
|
WritePrefix(Level, File, Line, Function);
|
|
va_list args;
|
|
va_start(args, Format);
|
|
vfctprintf(uart_wrapper, nullptr, Format, args);
|
|
va_end(args);
|
|
}
|
|
|
|
// C compatibility
|
|
extern "C" void SysDbgWriteLine(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
|
|
{
|
|
WritePrefix(Level, File, Line, Function);
|
|
va_list args;
|
|
va_start(args, Format);
|
|
vfctprintf(uart_wrapper, nullptr, Format, args);
|
|
va_end(args);
|
|
uart_wrapper('\n', nullptr);
|
|
}
|