blob: e0e61ab27ba6d042037afa7101e2e58b7c102d45 (
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/* -------------------------------------------
Copyright Zeta Electronics Corporation
------------------------------------------- */
#include <ArchKit/ArchKit.hpp>
#include <KernelKit/DebugOutput.hpp>
#include <NewKit/KernelCheck.hpp>
#include <NewKit/String.hpp>
EXTERN_C [[noreturn]] void ke_wait_for_debugger()
{
while (true)
{
#ifdef __NEWOS_AMD64__
NewOS::HAL::rt_cli();
NewOS::HAL::rt_halt();
#endif
}
}
/* Each error code is attributed with an ID, which will prompt a string onto the
* screen. Wait for debugger... */
namespace NewOS
{
void ke_stop(const NewOS::Int& id)
{
kcout << "*** STOP *** \r";
kcout << "*** Kernel has trigerred a runtime stop. *** \r";
switch (id)
{
case RUNTIME_CHECK_PROCESS: {
kcout << "*** CAUSE: RUNTIME_CHECK_PROCESS *** \r";
kcout << "*** WHAT: BAD DRIVER. *** \r";
break;
}
case RUNTIME_CHECK_ACPI: {
kcout << "*** CAUSE: RUNTIME_CHECK_ACPI *** \r";
kcout << "*** WHAT: ACPI ERROR, UNSTABLE STATE. *** \r";
break;
}
case RUNTIME_CHECK_POINTER: {
kcout << "*** CAUSE: RUNTIME_CHECK_POINTER *** \r";
kcout << "*** WHAT: HEAP CRC32 ERROR, UNSTABLE STATE. *** \r";
break;
}
case RUNTIME_CHECK_BAD_BEHAVIOR: {
kcout << "*** CAUSE: RUNTIME_CHECK_BAD_BEHAVIOR *** \r";
kcout << "*** WHAT: KERNEL BECAME UNSTABLE. *** \r";
break;
}
case RUNTIME_CHECK_BOOTSTRAP: {
kcout << "*** CAUSE: RUNTIME_CHECK_BOOTSTRAP *** \r";
kcout << "*** WHAT: END OF CODE. *** \r";
break;
}
case RUNTIME_CHECK_HANDSHAKE: {
kcout << "*** CAUSE: RUNTIME_CHECK_HANDSHAKE *** \r";
kcout << "*** WHAT: BAD HANDSHAKE. *** \r";
break;
}
case RUNTIME_CHECK_IPC: {
kcout << "*** CAUSE: RUNTIME_CHECK_IPC *** \r";
kcout << "*** WHAT: RICH CALL VIOLATION. *** \r";
break;
}
case RUNTIME_CHECK_INVALID_PRIVILEGE: {
kcout << "*** CAUSE: RUNTIME_CHECK_INVALID_PRIVILEGE *** \r";
kcout << "*** WHAT: HYPERVISOR POLICY VIOLATION. *** \r";
break;
case RUNTIME_CHECK_UNEXCPECTED: {
kcout << "*** CAUSE: RUNTIME_CHECK_UNEXCPECTED *** \r";
kcout << "*** WHAT: CATASROPHIC FAILURE! *** \r";
break;
}
case RUNTIME_CHECK_FAILED: {
kcout << "*** CAUSE: RUNTIME_CHECK_FAILED *** \r";
kcout << "*** WHAT: ASSERTION FAILED! *** \r";
break;
}
default: {
kcout << "*** CAUSE: RUNTIME_CHECK_GENERIC *** \r";
break;
}
}
};
DumpManager::Dump();
#ifdef __DEBUG__
ke_wait_for_debugger();
#endif // ifdef __DEBUG__
}
void ke_runtime_check(bool expr, const char* file, const char* line)
{
if (!expr)
{
#ifdef __DEBUG__
kcout << "newoskrnl: File: " << file << "\r";
kcout << "newoskrnl: Line: " << line << "\r";
#endif // __DEBUG__
NewOS::ke_stop(RUNTIME_CHECK_FAILED); // Runtime Check failed
}
}
} // namespace NewOS
|