blob: bbeecb74ef3e4bd0c65790ae4c55ebc97a33902e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*
* ========================================================
*
* HCore
* Copyright Mahrouss Logic, all rights reserved.
*
* ========================================================
*/
#include <ArchKit/Arch.hpp>
#include <KernelKit/DebugOutput.hpp>
#include <NewKit/RuntimeCheck.hpp>
#include <NewKit/String.hpp>
extern "C" [[noreturn]] void wait_for_debugger() {
while (true) {
HCore::HAL::rt_cli();
HCore::HAL::rt_halt();
}
}
/* Each error code is attributed with an ID, which will prompt a string onto the
* screen. Wait for debugger... */
namespace HCore {
void ke_stop(const HCore::Int &id) {
kcout << "*** STOP *** \r\n";
kcout << "*** HCoreKrnl.exe has trigerred a runtime breakpoint. *** \r\n";
switch (id) {
case RUNTIME_CHECK_PROCESS: {
kcout << "*** CAUSE: RUNTIME_CHECK_PROCESS *** \r\n";
break;
}
case RUNTIME_CHECK_ACPI: {
kcout << "*** CAUSE: RUNTIME_CHECK_ACPI *** \r\n";
break;
}
case RUNTIME_CHECK_POINTER: {
kcout << "*** CAUSE: RUNTIME_CHECK_POINTER *** \r\n";
break;
}
case RUNTIME_CHECK_BAD_BEHAVIOR: {
kcout << "*** CAUSE: RUNTIME_CHECK_BAD_BEHAVIOR *** \r\n";
break;
}
case RUNTIME_CHECK_BOOTSTRAP: {
kcout << "*** CAUSE: RUNTIME_CHECK_BOOTSTRAP *** \r\n";
break;
}
case RUNTIME_CHECK_HANDSHAKE: {
kcout << "*** CAUSE: RUNTIME_CHECK_HANDSHAKE *** \r\n";
break;
}
case RUNTIME_CHECK_LD: {
kcout << "*** CAUSE: RUNTIME_CHECK_LD *** \r\n";
break;
}
case RUNTIME_CHECK_INVALID_PRIVILEGE: {
kcout << "*** CAUSE: RUNTIME_CHECK_INVALID_PRIVILEGE *** \r\n";
break;
}
};
DumpManager::Dump();
wait_for_debugger();
}
void runtime_check(bool expr, const char *file, const char *line) {
if (!expr) {
#ifdef __DEBUG__
kcout << "[KERNEL] Check Failed!\n";
kcout << "[KERNEL] File: " << file << "\n";
kcout << "[KERNEL] Where: " << line << "\n";
#endif // __DEBUG__
HCore::ke_stop(RUNTIME_CHECK_FAILED); // Runtime Check failed
}
}
} // namespace HCore
|