diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-11-20 08:42:45 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-11-20 08:42:45 +0100 |
| commit | e718262c5e5163378ef92469db9b94908dccf12b (patch) | |
| tree | 98da3dbd414c14ff86e1d1c0f459285b78f63ec8 /dev/ZKAKit/KernelKit | |
| parent | ade3a2578ca8d6836b8e73160455df80d49cf045 (diff) | |
ADD: Add CoreBoot header, need to add missing fields for specific platforms.
Diffstat (limited to 'dev/ZKAKit/KernelKit')
| -rw-r--r-- | dev/ZKAKit/KernelKit/DebugOutput.h | 6 | ||||
| -rw-r--r-- | dev/ZKAKit/KernelKit/Heap.h | 27 | ||||
| -rw-r--r-- | dev/ZKAKit/KernelKit/LPC.h | 6 |
3 files changed, 27 insertions, 12 deletions
diff --git a/dev/ZKAKit/KernelKit/DebugOutput.h b/dev/ZKAKit/KernelKit/DebugOutput.h index c00df2e0..b268d874 100644 --- a/dev/ZKAKit/KernelKit/DebugOutput.h +++ b/dev/ZKAKit/KernelKit/DebugOutput.h @@ -11,7 +11,7 @@ #include <NewKit/OwnPtr.h> #include <NewKit/Stream.h> -#define kDebugMaxPorts 16 +#define kDebugMaxPorts 56 #define kDebugUnboundPort 0x0FEED @@ -35,7 +35,7 @@ namespace Kernel inline TerminalDevice hex_number(const Long& x); // @brief Emulates a VT100 terminal. - class TerminalDevice final : public DeviceInterface<const Char*> + class TerminalDevice final ZKA_DEVICE<const Char*> { public: TerminalDevice(void (*print)(const Char*), void (*get)(const Char*)) @@ -43,7 +43,7 @@ namespace Kernel { } - virtual ~TerminalDevice() = default; + ~TerminalDevice() override; /// @brief returns device name (terminal name) /// @return string type (const Char*) diff --git a/dev/ZKAKit/KernelKit/Heap.h b/dev/ZKAKit/KernelKit/Heap.h index 2bcda412..c0a646d9 100644 --- a/dev/ZKAKit/KernelKit/Heap.h +++ b/dev/ZKAKit/KernelKit/Heap.h @@ -9,10 +9,11 @@ // last-rev 30/01/24 // file: Heap.h -// description: heap allocation for the Kernel. +// description: heap allocation support. -#include <NewKit/Defines.h> #include <NewKit/Stop.h> +#include <KernelKit/LPC.h> +#include <HintKit/CompilerHint.h> namespace Kernel { @@ -58,19 +59,27 @@ namespace Kernel UInt64 mm_get_flags(VoidPtr heap_ptr); /// @brief Allocate C++ class. + /// @param cls The class to allocate. + /// @param args The args to pass. template <typename T, typename... Args> - inline T* mm_new_class(Args&&... args) + inline Void mm_new_class(_Input _Output T** cls, _Input Args&&... args) { - T* cls = new T(move(args)...); - return cls; + if (*cls) + { + ErrGlobal() = Kernel::kErrorInvalidData; + return; + } + + *cls = new T(move(args)...); } - /// @brief Free C++ class. + /// @brief Delete and nullify C++ class. + /// @param cls The class to delete. template <typename T> - inline Void mm_delete_class(T* cls) + inline Void mm_delete_class(_Input _Output T** cls) { - delete cls; - cls = nullptr; + delete *cls; + *cls = nullptr; } } // namespace Kernel diff --git a/dev/ZKAKit/KernelKit/LPC.h b/dev/ZKAKit/KernelKit/LPC.h index bbb14c05..ff19ec8a 100644 --- a/dev/ZKAKit/KernelKit/LPC.h +++ b/dev/ZKAKit/KernelKit/LPC.h @@ -15,10 +15,16 @@ #define ErrLocalFailed() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode() != Kernel::kErrorSuccess) #define ErrLocal() (Kernel::UserProcessScheduler::The().GetCurrentProcess().Leak().GetLocalCode()) +#define ErrGlobalIsOk() (Kernel::kErrorLocalNumber == Kernel::kErrorSuccess) +#define ErrGlobalFailed() (Kernel::kErrorLocalNumber != Kernel::kErrorSuccess) +#define ErrGlobal() (Kernel::kErrorLocalNumber) + namespace Kernel { typedef Int32 HError; + inline HError kErrorLocalNumber = 0UL; + inline constexpr HError kErrorSuccess = 0; inline constexpr HError kErrorExecutable = 33; inline constexpr HError kErrorExecutableLib = 34; |
