diff options
| -rw-r--r-- | Kernel/KernelKit/HError.hpp | 1 | ||||
| -rw-r--r-- | Kernel/Sources/CxxAbi.cxx | 8 | ||||
| -rw-r--r-- | Kernel/Sources/HError.cxx | 17 | ||||
| -rw-r--r-- | Kernel/Sources/KernelHeap.cxx | 38 |
4 files changed, 39 insertions, 25 deletions
diff --git a/Kernel/KernelKit/HError.hpp b/Kernel/KernelKit/HError.hpp index 468f9a12..528c3542 100644 --- a/Kernel/KernelKit/HError.hpp +++ b/Kernel/KernelKit/HError.hpp @@ -49,6 +49,7 @@ namespace NewOS inline constexpr HError kErrorIPC = 59; inline constexpr HError kErrorUnimplemented = 0; + Void err_bug_check_raise(void) noexcept; Boolean err_bug_check(void) noexcept; } // namespace NewOS 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; } |
