diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 09:04:13 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-18 09:04:13 +0100 |
| commit | ed6d2f6007b572b907e3cb11b4303c13d1572c9c (patch) | |
| tree | 47f177336db980a138a91a2fb109db8f1a65086c /src | |
| parent | 3a5c7473910156051951f8ec98488a6c91a3eabd (diff) | |
chore: specification updates and patches on the DDK, new source `ddk_c++.cc`.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/boot/src/BootThread.cc | 11 | ||||
| -rw-r--r-- | src/kernel/NeKit/Atom.h | 24 | ||||
| -rw-r--r-- | src/kernel/NeKit/InitializerList.h | 25 | ||||
| -rw-r--r-- | src/libDDK/DriverKit/c++/driver_base.h | 15 | ||||
| -rw-r--r-- | src/libDDK/src/ddk_c++.cc | 9 |
5 files changed, 53 insertions, 31 deletions
diff --git a/src/boot/src/BootThread.cc b/src/boot/src/BootThread.cc index 336c5f9e..7d3beba8 100644 --- a/src/boot/src/BootThread.cc +++ b/src/boot/src/BootThread.cc @@ -15,6 +15,7 @@ #include <KernelKit/PEF.h> #include <modules/CoreGfx/TextGfx.h> +// \brief This macro defines the maximum size of a image's stack. #define kBootThreadSz mib_cast(16) /// @brief External boot services symbol. @@ -26,9 +27,8 @@ namespace Boot { EXTERN_C Int32 rt_jump_to_address(VoidPtr code, HEL::BootInfoHeader* handover, UInt8* stack); BootThread::BootThread(VoidPtr blob) : fStartAddress(nullptr), fBlob(blob) { - // detect the format. - const Char* blob_bytes = reinterpret_cast<char*>(fBlob); - + // detect the image format (PEF, PE32, etc.) + const Char* blob_bytes = static_cast<Char*>(fBlob); BootTextWriter writer; if (!blob_bytes) { @@ -151,11 +151,12 @@ BootThread::BootThread(VoidPtr blob) : fStartAddress(nullptr), fBlob(blob) { blob_bytes[2] == kPefMagic[2] && blob_bytes[3] == kPefMagic[3]) { // ========================================= // // PEF executable has been detected. + // This is stricly firmware level, by convention we only accept PE32+ here. // ========================================= // fStartAddress = nullptr; - writer.Write("BootZ: PEF executable detected, won't load it.\r"); + writer.Write("BootZ: PEF executable detected, BootZ won't load it.\r"); writer.Write("BootZ: note: PEF executables aren't supported for now.\r"); } else { writer.Write("BootZ: Invalid Executable.\r"); @@ -215,4 +216,4 @@ Void BootThread::SetName(const Char* name) { bool BootThread::IsValid() { return fStartAddress != nullptr; } -} // namespace Boot
\ No newline at end of file +} // namespace Boot diff --git a/src/kernel/NeKit/Atom.h b/src/kernel/NeKit/Atom.h index 7c4ebb5b..7deff14e 100644 --- a/src/kernel/NeKit/Atom.h +++ b/src/kernel/NeKit/Atom.h @@ -3,12 +3,14 @@ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once + +#ifndef __NE_KIT_ATOM_H__ +#define __NE_KIT_ATOM_H__ #include <NeKit/Config.h> namespace Kernel { -template <typename T> +template <class TypeAtomic> class Atom final { public: explicit Atom() = default; @@ -19,15 +21,19 @@ class Atom final { Atom(const Atom&) = delete; public: - T operator[](Size bit) { return (fArrayOfAtoms & (1 << bit)); } - - void operator|(Size bit) { fArrayOfAtoms |= (1 << bit); } + using Type = TypeAtomic; + + const TypeAtomic& operator[](const SizeT& bit) { return (fArrayOfAtoms & (1 << bit)); } - friend Boolean operator==(Atom<T>& atomic, const T& idx) { return atomic[idx] == idx; } - - friend Boolean operator!=(Atom<T>& atomic, const T& idx) { return atomic[idx] != idx; } + void operator|(const SizeT& bit) { fArrayOfAtoms |= (1 << bit); } + Atom& operator|=(const SizeT& bit) { this->operator|(bit); return *this; } + + friend bool operator==(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) { return atomic[idx] == idx; } + friend bool operator!=(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) { return atomic[idx] != idx; } private: - T fArrayOfAtoms; + TypeAtomic fArrayOfAtoms; }; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/InitializerList.h b/src/kernel/NeKit/InitializerList.h index d918ba85..46639d4d 100644 --- a/src/kernel/NeKit/InitializerList.h +++ b/src/kernel/NeKit/InitializerList.h @@ -1,19 +1,23 @@ /* ======================================== - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once +#ifndef __NE_KIT_INIT_LIST_H__ +#define __NE_KIT_INIT_LIST_H__ #include <NeKit/Config.h> #include <NeKit/ErrorOr.h> namespace Kernel { -template <class T, SizeT N> + // \brief Initalizer List object for containers. +template <class Type, SizeT N> class InitializerList final { public: - explicit InitializerList(const T* list) { + InitializerList() = delete; + + explicit InitializerList(const Type* list) { if constexpr (N > 0) { for (auto i = 0UL; i < N; ++i) { fList[i] = list[i]; @@ -26,17 +30,20 @@ class InitializerList final { InitializerList& operator=(const InitializerList&) = delete; InitializerList(const InitializerList&) = delete; - T* begin() { return fList; } - T* end() { return fList + N; } + Type* begin() { return fList; } + Type* end() { return fList + N; } + constexpr SizeT size() const { return N; } - T* operator->() { return fList; } - T* operator*() { return fList; } + Type* operator->() { return this->begin(); } + Type* operator*() { return this->begin(); } private: - T fList[N]; + Type fList[N]; }; template <class T, SizeT N> using ErrorOrList = ErrorOr<InitializerList<T, N>>; } // namespace Kernel + +#endif diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h index f43ae0bf..683969f3 100644 --- a/src/libDDK/DriverKit/c++/driver_base.h +++ b/src/libDDK/DriverKit/c++/driver_base.h @@ -3,13 +3,12 @@ Copyright Amlal El Mahrouss 2025, licensed under the Apache 2.0 license. FILE: driver_base.h - PURPOSE: IDriverBase and friends. + PURPOSE: C++ Driver Wrapper. ======================================== */ #pragma once -#include <CompilerKit/CompilerKit.h> #include <libDDK/DriverKit/macros.h> #define DDK_DRIVER_IMPL \ @@ -30,12 +29,12 @@ class IDriverBase { NE_COPY_DELETE(IDriverBase); NE_MOVE_DEFAULT(IDriverBase); - using PtrType = VoidPtr; + using PtrType = void*; - virtual constexpr BOOL IsCastable() { return NO; } - virtual constexpr BOOL IsActive() { return NO; } + virtual constexpr bool IsCastable() { return false; } + virtual constexpr bool IsActive() { return false; } virtual PtrType Leak() { return nullptr; } - virtual constexpr Int32 Type() { return kInvalidType; } + virtual constexpr int32_t Type() { return kInvalidType; } }; /// @brief This concept requires the Driver to be IDriverBase compliant. @@ -46,6 +45,6 @@ concept IsValidDriver = requires(Driver driver_base) { /// @brief Consteval helper to detect whether a template is truly based on IDriverBase. /// @note This helper is consteval only. -template <IsValidDriver T> -consteval void ce_ddk_is_valid(T) {} +template <class Driver> +inline bool ce_ddk_is_valid(Driver drv) { return IsValidDriver<Driver>(drv); } } // namespace Kernel::DDK diff --git a/src/libDDK/src/ddk_c++.cc b/src/libDDK/src/ddk_c++.cc new file mode 100644 index 00000000..920697ac --- /dev/null +++ b/src/libDDK/src/ddk_c++.cc @@ -0,0 +1,9 @@ +/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + +#include <libDDK/DriverKit/c++/driver_base.h> + + |
