summaryrefslogtreecommitdiffhomepage
path: root/Kernel/Sources
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-06-29 23:52:17 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-06-29 23:52:17 +0200
commit397b03fd02a851abc70e750daf340966914e4239 (patch)
tree20c597eccfe7c390431938a58cdfacff9c68400a /Kernel/Sources
parent0558e8040c0d9628858ddd85ce573b9c80941a1f (diff)
New err_ kernel API (with err_bug_check)
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/Sources')
-rw-r--r--Kernel/Sources/CxxAbi.cxx8
-rw-r--r--Kernel/Sources/HError.cxx17
-rw-r--r--Kernel/Sources/KernelHeap.cxx38
3 files changed, 38 insertions, 25 deletions
diff --git a/Kernel/Sources/CxxAbi.cxx b/Kernel/Sources/CxxAbi.cxx
index e358caca..efc908d7 100644
--- a/Kernel/Sources/CxxAbi.cxx
+++ b/Kernel/Sources/CxxAbi.cxx
@@ -6,7 +6,7 @@
#include <KernelKit/DebugOutput.hpp>
#include <NewKit/CxxAbi.hpp>
-#include <NewKit/KernelCheck.hpp>
+#include <KernelKit/HError.hpp>
atexit_func_entry_t __atexit_funcs[kDSOMaxObjects];
@@ -22,12 +22,12 @@ EXTERN_C void __cxa_pure_virtual()
EXTERN_C void ___chkstk_ms()
{
- while (true)
- {
- }
+ NewOS::err_bug_check_raise();
+ NewOS::err_bug_check();
}
#ifdef __NEWOS_ARM64__
+// AEABI specific.
#define atexit __aeabi_atexit
#endif
diff --git a/Kernel/Sources/HError.cxx b/Kernel/Sources/HError.cxx
index d38f2e07..39915f65 100644
--- a/Kernel/Sources/HError.cxx
+++ b/Kernel/Sources/HError.cxx
@@ -5,15 +5,28 @@
------------------------------------------- */
#include <KernelKit/HError.hpp>
+#include <NewKit/KernelCheck.hpp>
namespace NewOS
{
- /// @brief Doea a system wide bug check.
+ STATIC Bool cRaise = false;
+
+ /// @brief Does a system wide bug check.
/// @param void no params.
/// @return if error-free: true, otherwise false.
Boolean err_bug_check(void) noexcept
{
- /// TODO:
+ if (cRaise)
+ {
+ ke_stop(RUNTIME_CHECK_BAD_BEHAVIOR);
+ }
+
return false;
}
+
+ Void err_bug_check_raise(void) noexcept
+ {
+ if (!cRaise)
+ cRaise = true;
+ }
} // namespace NewOS
diff --git a/Kernel/Sources/KernelHeap.cxx b/Kernel/Sources/KernelHeap.cxx
index 875e00fb..770e11da 100644
--- a/Kernel/Sources/KernelHeap.cxx
+++ b/Kernel/Sources/KernelHeap.cxx
@@ -87,11 +87,11 @@ namespace NewOS
if (((IntPtr)heapPtr - kBadPtr) < 0)
return -kErrorInternal;
- Detail::HeapInformationBlockPtr virtualAddress =
+ Detail::HeapInformationBlockPtr heapInfoBlk =
reinterpret_cast<Detail::HeapInformationBlockPtr>(
(UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock));
- virtualAddress->fPagePtr = 1;
+ heapInfoBlk->fPagePtr = 1;
return 0;
}
@@ -108,34 +108,34 @@ namespace NewOS
if (((IntPtr)heapPtr - kBadPtr) < 0)
return -kErrorInternal;
- Detail::HeapInformationBlockPtr virtualAddress =
+ Detail::HeapInformationBlockPtr heapInfoBlk =
reinterpret_cast<Detail::HeapInformationBlockPtr>(
(UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock));
- if (virtualAddress && virtualAddress->fMagic == kKernelHeapMagic)
+ if (heapInfoBlk && heapInfoBlk->fMagic == kKernelHeapMagic)
{
- if (!virtualAddress->fPresent)
+ if (!heapInfoBlk->fPresent)
{
return -kErrorHeapNotPresent;
}
- if (virtualAddress->fCRC32 != 0)
+ if (heapInfoBlk->fCRC32 != 0)
{
- if (virtualAddress->fCRC32 !=
- ke_calculate_crc32((Char*)virtualAddress->fTargetPtr,
- virtualAddress->fTargetPtrSize))
+ if (heapInfoBlk->fCRC32 !=
+ ke_calculate_crc32((Char*)heapInfoBlk->fTargetPtr,
+ heapInfoBlk->fTargetPtrSize))
{
ke_stop(RUNTIME_CHECK_POINTER);
}
}
- virtualAddress->fTargetPtrSize = 0UL;
- virtualAddress->fPresent = false;
- virtualAddress->fTargetPtr = 0;
- virtualAddress->fCRC32 = 0;
- virtualAddress->fMagic = 0;
+ heapInfoBlk->fTargetPtrSize = 0UL;
+ heapInfoBlk->fPresent = false;
+ heapInfoBlk->fTargetPtr = 0;
+ heapInfoBlk->fCRC32 = 0;
+ heapInfoBlk->fMagic = 0;
- PTEWrapper pageWrapper(false, false, false, (UIntPtr)virtualAddress);
+ PTEWrapper pageWrapper(false, false, false, reinterpret_cast<UIntPtr>(heapInfoBlk));
Ref<PTEWrapper*> pteAddress{&pageWrapper};
kHeapPageManager.Free(pteAddress);
@@ -177,14 +177,14 @@ namespace NewOS
{
if (heapPtr)
{
- Detail::HeapInformationBlockPtr virtualAddress =
+ Detail::HeapInformationBlockPtr heapInfoBlk =
reinterpret_cast<Detail::HeapInformationBlockPtr>(
(UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock));
- if (virtualAddress->fPresent && kKernelHeapMagic == virtualAddress->fMagic)
+ if (heapInfoBlk->fPresent && kKernelHeapMagic == heapInfoBlk->fMagic)
{
- virtualAddress->fCRC32 =
- ke_calculate_crc32((Char*)virtualAddress->fTargetPtr, virtualAddress->fTargetPtrSize);
+ heapInfoBlk->fCRC32 =
+ ke_calculate_crc32((Char*)heapInfoBlk->fTargetPtr, heapInfoBlk->fTargetPtrSize);
return true;
}