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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/* -------------------------------------------
Copyright ZKA Technologies
------------------------------------------- */
#include <ArchKit/ArchKit.hxx>
#include <KernelKit/DebugOutput.hxx>
#include <NewKit/KernelCheck.hxx>
#include <NewKit/String.hxx>
#include <FirmwareKit/Handover.hxx>
#include <Modules/ACPI/ACPIFactoryInterface.hxx>
#include <Modules/CoreCG/Accessibility.hxx>
#include <Modules/CoreCG/FbRenderer.hxx>
#include <Modules/CoreCG/TextRenderer.hxx>
EXTERN_C Kernel::Void ke_wait_for_debugger()
{
}
/* Each error code is attributed with an ID, which will prompt a string onto the
* screen. Wait for debugger... */
namespace Kernel
{
void ke_stop(const Kernel::Int& id)
{
CGInit();
auto panicBack = RGB(0xDC, 0xF5, 0xF5);
auto panicTxt = RGB(0, 0, 0);
CGDrawInRegion(panicBack, UIAccessibilty::The().Height(), UIAccessibilty::The().Width(), 0, 0);
auto start_y = 10;
auto x = 10;
cg_write_text("*** Kernel panic! ***\rnewoskrnl.dll stopped working properly so we had to shut it down.", start_y, x, panicTxt);
CGFini();
// ******* //
// shows in debug only.
// ******* //
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;
}
}
};
RecoveryFactory::Recover();
}
Void RecoveryFactory::Recover() noexcept
{
#ifdef __DEBUG__
ke_wait_for_debugger();
#endif // ifdef __DEBUG__
PowerFactoryInterface powerInterface(kHandoverHeader->f_HardwareTables.f_VendorPtr);
powerInterface.Shutdown();
}
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__
ke_stop(RUNTIME_CHECK_FAILED); // Runtime Check failed
}
}
} // namespace Kernel
|