37 lines
744 B
C
37 lines
744 B
C
#include <lcrash/debug/debug.h>
|
|
|
|
#include <lcrash/gdb/gdb.h>
|
|
#include <lcrash/mm/kmalloc.h>
|
|
|
|
struct DebugExtendedDebugInformationBlock {
|
|
/// Kernel panic
|
|
bool Panic;
|
|
|
|
/// Kernel panic error
|
|
const c8* PanicError;
|
|
};
|
|
|
|
struct DebugExtendedDebugInformationBlock* DebugEDIB = 0;
|
|
struct GdbDataBlock* DebugGDB = (struct GdbDataBlock*)0x100000;
|
|
|
|
int DebugInitialize() {
|
|
DebugEDIB = KernelHeapAlloc(sizeof(struct DebugExtendedDebugInformationBlock), 0);
|
|
if (DebugEDIB == 0) return -1;
|
|
|
|
DebugGDB->EDIB = DebugEDIB;
|
|
DebugEDIB->Panic = false;
|
|
DebugEDIB->PanicError = 0;
|
|
|
|
return 0;
|
|
}
|
|
|
|
[[noreturn]]
|
|
void Panic(const c8* Error) {
|
|
DebugEDIB->PanicError = Error;
|
|
DebugEDIB->Panic = true;
|
|
DebugGDB->Update++;
|
|
|
|
asm("cli");
|
|
while (1) asm("hlt");
|
|
}
|