From 77a1bd038f4288a7c24cfe52ad9824ca947c6671 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 24 Mar 2025 05:08:21 +0100 Subject: kernel(feat): Add basic wide system bug check (memory check), other changes have been made too, see commit details for more information. Signed-off-by: Amlal El Mahrouss --- dev/kernel/KernelKit/DriveMgr.h | 2 +- dev/kernel/KernelKit/FileMgr.h | 2 +- dev/kernel/KernelKit/KPC.h | 67 ++++++++++++++++++++++++++++++++++++++ dev/kernel/KernelKit/LPC.h | 70 ---------------------------------------- dev/kernel/KernelKit/MemoryMgr.h | 2 +- dev/kernel/KernelKit/Timer.h | 2 +- dev/kernel/KernelKit/User.h | 2 +- 7 files changed, 72 insertions(+), 75 deletions(-) create mode 100644 dev/kernel/KernelKit/KPC.h delete mode 100644 dev/kernel/KernelKit/LPC.h (limited to 'dev/kernel/KernelKit') diff --git a/dev/kernel/KernelKit/DriveMgr.h b/dev/kernel/KernelKit/DriveMgr.h index 87bd2714..fd972ab7 100644 --- a/dev/kernel/KernelKit/DriveMgr.h +++ b/dev/kernel/KernelKit/DriveMgr.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/dev/kernel/KernelKit/FileMgr.h b/dev/kernel/KernelKit/FileMgr.h index 7374df9d..59203998 100644 --- a/dev/kernel/KernelKit/FileMgr.h +++ b/dev/kernel/KernelKit/FileMgr.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include diff --git a/dev/kernel/KernelKit/KPC.h b/dev/kernel/KernelKit/KPC.h new file mode 100644 index 00000000..9b62c14e --- /dev/null +++ b/dev/kernel/KernelKit/KPC.h @@ -0,0 +1,67 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include + +/// @file KPC.h +/// @brief Kernel Procedure Code. + +#define err_local_ok() (NeOS::UserProcessScheduler::The().CurrentProcess().Leak().GetLocalCode() == NeOS::kErrorSuccess) +#define err_local_fail() (NeOS::UserProcessScheduler::The().CurrentProcess().Leak().GetLocalCode() != NeOS::kErrorSuccess) +#define err_local_get() (NeOS::UserProcessScheduler::The().CurrentProcess().Leak().GetLocalCode()) + +#define err_global_ok() (NeOS::kErrorLocalNumber == NeOS::kErrorSuccess) +#define err_global_fail() (NeOS::kErrorLocalNumber != NeOS::kErrorSuccess) +#define err_global_get() (NeOS::kErrorLocalNumber) + +namespace NeOS +{ + typedef Int32 HError; + + inline HError kErrorLocalNumber = 0UL; + + inline constexpr HError kErrorSuccess = 0; + inline constexpr HError kErrorExecutable = 33; + inline constexpr HError kErrorExecutableLib = 34; + inline constexpr HError kErrorFileNotFound = 35; + inline constexpr HError kErrorDirectoryNotFound = 36; + inline constexpr HError kErrorDiskReadOnly = 37; + inline constexpr HError kErrorDiskIsFull = 38; + inline constexpr HError kErrorProcessFault = 39; + inline constexpr HError kErrorSocketHangUp = 40; + inline constexpr HError kErrorThreadLocalStorage = 41; + inline constexpr HError kErrorMath = 42; + inline constexpr HError kErrorNoNetwork = 43; + inline constexpr HError kErrorHeapOutOfMemory = 44; + inline constexpr HError kErrorNoSuchDisk = 45; + inline constexpr HError kErrorFileExists = 46; + inline constexpr HError kErrorFormatFailed = 47; + inline constexpr HError kErrorNetworkTimeout = 48; + inline constexpr HError kErrorInternal = 49; + inline constexpr HError kErrorForkAlreadyExists = 50; + inline constexpr HError kErrorOutOfTeamSlot = 51; + inline constexpr HError kErrorHeapNotPresent = 52; + inline constexpr HError kErrorNoEntrypoint = 53; + inline constexpr HError kErrorDiskIsCorrupted = 54; + inline constexpr HError kErrorDisk = 55; + inline constexpr HError kErrorInvalidData = 56; + inline constexpr HError kErrorAsync = 57; + inline constexpr HError kErrorNonBlocking = 58; + inline constexpr HError kErrorIPC = 59; + inline constexpr HError kErrorSign = 60; + inline constexpr HError kErrorInvalidCreds = 61; + inline constexpr HError kErrorCDTrayBroken = 62; + inline constexpr HError kErrorUnrecoverableDisk = 63; + inline constexpr HError kErrorFileLocked = 64; + inline constexpr HError kErrorUnimplemented = -1; + + /// @brief Does a system wide bug check. + /// @param void no params are needed. + /// @return if error-free: false, otherwise true. + Boolean err_bug_check_raise(Void) noexcept; +} // namespace NeOS diff --git a/dev/kernel/KernelKit/LPC.h b/dev/kernel/KernelKit/LPC.h deleted file mode 100644 index d76eeff1..00000000 --- a/dev/kernel/KernelKit/LPC.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. - -------------------------------------------- */ - -#pragma once - -#include - -/// @file LPC.h -/// @brief Local Process Codes. - -#define err_local_ok() (NeOS::UserProcessScheduler::The().CurrentProcess().Leak().GetLocalCode() == NeOS::kErrorSuccess) -#define err_local_fail() (NeOS::UserProcessScheduler::The().CurrentProcess().Leak().GetLocalCode() != NeOS::kErrorSuccess) -#define err_local_get() (NeOS::UserProcessScheduler::The().CurrentProcess().Leak().GetLocalCode()) - -#define err_global_ok() (NeOS::kErrorLocalNumber == NeOS::kErrorSuccess) -#define err_global_fail() (NeOS::kErrorLocalNumber != NeOS::kErrorSuccess) -#define err_global_get() (NeOS::kErrorLocalNumber) - -namespace NeOS -{ - typedef Int32 HError; - - inline HError kErrorLocalNumber = 0UL; - - inline constexpr HError kErrorSuccess = 0; - inline constexpr HError kErrorExecutable = 33; - inline constexpr HError kErrorExecutableLib = 34; - inline constexpr HError kErrorFileNotFound = 35; - inline constexpr HError kErrorDirectoryNotFound = 36; - inline constexpr HError kErrorDiskReadOnly = 37; - inline constexpr HError kErrorDiskIsFull = 38; - inline constexpr HError kErrorProcessFault = 39; - inline constexpr HError kErrorSocketHangUp = 40; - inline constexpr HError kErrorThreadLocalStorage = 41; - inline constexpr HError kErrorMath = 42; - inline constexpr HError kErrorNoNetwork = 43; - inline constexpr HError kErrorHeapOutOfMemory = 44; - inline constexpr HError kErrorNoSuchDisk = 45; - inline constexpr HError kErrorFileExists = 46; - inline constexpr HError kErrorFormatFailed = 47; - inline constexpr HError kErrorNetworkTimeout = 48; - inline constexpr HError kErrorInternal = 49; - inline constexpr HError kErrorForkAlreadyExists = 50; - inline constexpr HError kErrorOutOfTeamSlot = 51; - inline constexpr HError kErrorHeapNotPresent = 52; - inline constexpr HError kErrorNoEntrypoint = 53; - inline constexpr HError kErrorDiskIsCorrupted = 54; - inline constexpr HError kErrorDisk = 55; - inline constexpr HError kErrorInvalidData = 56; - inline constexpr HError kErrorAsync = 57; - inline constexpr HError kErrorNonBlocking = 58; - inline constexpr HError kErrorIPC = 59; - inline constexpr HError kErrorSign = 60; - inline constexpr HError kErrorInvalidCreds = 61; - inline constexpr HError kErrorCDTrayBroken = 62; - inline constexpr HError kErrorUnrecoverableDisk = 63; - inline constexpr HError kErrorFileLocked = 64; - inline constexpr HError kErrorUnimplemented = -1; - - /// @brief Raises a bug check stop code. - Void err_bug_check_raise(Void) noexcept; - - /// @brief Does a system wide bug check. - /// @param void no params are needed. - /// @return if error-free: false, otherwise true. - Boolean err_bug_check(Void) noexcept; -} // namespace NeOS diff --git a/dev/kernel/KernelKit/MemoryMgr.h b/dev/kernel/KernelKit/MemoryMgr.h index 93718493..139ae7aa 100644 --- a/dev/kernel/KernelKit/MemoryMgr.h +++ b/dev/kernel/KernelKit/MemoryMgr.h @@ -12,7 +12,7 @@ /// @brief: heap allocation support. #include -#include +#include #include namespace NeOS diff --git a/dev/kernel/KernelKit/Timer.h b/dev/kernel/KernelKit/Timer.h index abca5352..e52f91e7 100644 --- a/dev/kernel/KernelKit/Timer.h +++ b/dev/kernel/KernelKit/Timer.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include namespace NeOS { diff --git a/dev/kernel/KernelKit/User.h b/dev/kernel/KernelKit/User.h index 9ab2b02e..620b9bc9 100644 --- a/dev/kernel/KernelKit/User.h +++ b/dev/kernel/KernelKit/User.h @@ -16,7 +16,7 @@ ------------------------------------------- */ #include -#include +#include #include #include -- cgit v1.2.3