From 30ba1aab88bd8138a6b3b3e1dbb464e4e67af698 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 3 Feb 2026 19:06:45 +0100 Subject: chore: {DDK, KernelKit}: Improvements and release schedule. Signed-off-by: Amlal El Mahrouss --- src/libDDK/DriverKit/ObjectKit/checksum.h | 39 ++++++++++++++++++++++ src/libDDK/DriverKit/ObjectKit/ddk.h | 11 +++++++ src/libDDK/DriverKit/ObjectKit/driver_base.h | 48 ++++++++++++++++++++++++++++ src/libDDK/DriverKit/c++/checksum.h | 38 ---------------------- src/libDDK/DriverKit/c++/ddk.h | 11 ------- src/libDDK/DriverKit/c++/driver_base.h | 46 -------------------------- src/libDDK/src/ddk_c++.cc | 5 --- src/libDDK/src/ddk_kernel_call.c | 2 +- src/libDDK/src/ddk_objectkit.cc | 5 +++ 9 files changed, 104 insertions(+), 101 deletions(-) create mode 100644 src/libDDK/DriverKit/ObjectKit/checksum.h create mode 100644 src/libDDK/DriverKit/ObjectKit/ddk.h create mode 100644 src/libDDK/DriverKit/ObjectKit/driver_base.h delete mode 100644 src/libDDK/DriverKit/c++/checksum.h delete mode 100644 src/libDDK/DriverKit/c++/ddk.h delete mode 100644 src/libDDK/DriverKit/c++/driver_base.h delete mode 100644 src/libDDK/src/ddk_c++.cc create mode 100644 src/libDDK/src/ddk_objectkit.cc (limited to 'src/libDDK') diff --git a/src/libDDK/DriverKit/ObjectKit/checksum.h b/src/libDDK/DriverKit/ObjectKit/checksum.h new file mode 100644 index 00000000..5f9859e2 --- /dev/null +++ b/src/libDDK/DriverKit/ObjectKit/checksum.h @@ -0,0 +1,39 @@ +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/nekernel-org/nekernel + +#ifndef DRIVERKIT_CHECKSUM_H +#define DRIVERKIT_CHECKSUM_H + +#include + +namespace Kernel::DDK { + +using IndexableBlob = char*; +using Indexable = char; + +/// @note This uses the FNV 64-bit variant. +/// @brief Performs a checksum computation for a memory region. +inline uintptr_t rtl_checksum(const IndexableBlob path) { + if (!path || *path == 0) return 0; + + const uintptr_t kFNVSeed = 0xcbf29ce484222325ULL; + const uintptr_t kFNVPrime = 0x100000001b3ULL; + + uintptr_t hash = kFNVSeed; + + IndexableBlob path_ = path; + + while (*path_) { + hash ^= (Indexable) (*path_++); + hash *= kFNVPrime; + } + + return hash; +} + +using Blob = void*; + +} // namespace Kernel::DDK + +#endif diff --git a/src/libDDK/DriverKit/ObjectKit/ddk.h b/src/libDDK/DriverKit/ObjectKit/ddk.h new file mode 100644 index 00000000..2d6dec75 --- /dev/null +++ b/src/libDDK/DriverKit/ObjectKit/ddk.h @@ -0,0 +1,11 @@ +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/nekernel-org/nekernel + +#ifndef DRIVERKIT_DDK_H +#define DRIVERKIT_DDK_H + +#include +#include + +#endif diff --git a/src/libDDK/DriverKit/ObjectKit/driver_base.h b/src/libDDK/DriverKit/ObjectKit/driver_base.h new file mode 100644 index 00000000..909bfe7b --- /dev/null +++ b/src/libDDK/DriverKit/ObjectKit/driver_base.h @@ -0,0 +1,48 @@ +// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/nekernel-org/nekernel + +#ifndef DRIVERKIT_DRIVER_BASE_H +#define DRIVERKIT_DRIVER_BASE_H + +#include + +#define DDK_DRIVER_IMPL \ + final: \ + public \ + ::Kernel::DDK::IDriverBase + +/// @author Amlal El Mahrouss +/// @brief The DDK C++ API. + +namespace Kernel::DDK { + +inline constexpr auto kInvalidType = 0; + +/// @brief Driver interface type. +class IDriverBase { + public: + IDriverBase() = default; + virtual ~IDriverBase() = default; + + IDriverBase& operator=(const IDriverBase&) = delete; + IDriverBase(const IDriverBase&) = delete; + + using PtrType = void*; + + virtual constexpr bool IsCastable() { return false; } + virtual constexpr bool IsActive() { return false; } + virtual PtrType Leak() { return nullptr; } + virtual constexpr int32_t Type() { return kInvalidType; } +}; + +/// @brief This concept requires the Driver to be IDriverBase compliant. +/// @author @amlel-el-mahrouss +template +concept IsValidDriver = requires(Driver drv) { + { drv.IsActive() && drv.Type() > kInvalidType }; +}; + +} // namespace Kernel::DDK + +#endif diff --git a/src/libDDK/DriverKit/c++/checksum.h b/src/libDDK/DriverKit/c++/checksum.h deleted file mode 100644 index 55d3d58f..00000000 --- a/src/libDDK/DriverKit/c++/checksum.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/nekernel-org/nekernel - -#ifndef DRIVERKIT_CHECKSUM_H -#define DRIVERKIT_CHECKSUM_H - -#include - -namespace Kernel::DDK { - -using IndexableBlob = Char*; - -/// @note This uses the FNV 64-bit variant. -/// @brief Performs a checksum computation for a memory region. -inline UInt64 rtl_checksum(const IndexableBlob path) { - if (!path || *path == 0) return 0; - - const UInt64 kFNVSeed = 0xcbf29ce484222325ULL; - const UInt64 kFNVPrime = 0x100000001b3ULL; - - UInt64 hash = kFNVSeed; - - IndexableBlob path_ = path; - - while (*path_) { - hash ^= (Char) (*path_++); - hash *= kFNVPrime; - } - - return hash; -} - -using Blob = VoidPtr; - -} // namespace Kernel::DDK - -#endif diff --git a/src/libDDK/DriverKit/c++/ddk.h b/src/libDDK/DriverKit/c++/ddk.h deleted file mode 100644 index f05b86bc..00000000 --- a/src/libDDK/DriverKit/c++/ddk.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/nekernel-org/nekernel - -#ifndef DRIVERKIT_DDK_H -#define DRIVERKIT_DDK_H - -#include -#include - -#endif diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h deleted file mode 100644 index 1d6057b3..00000000 --- a/src/libDDK/DriverKit/c++/driver_base.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/nekernel-org/nekernel - -#ifndef DRIVERKIT_DRIVER_BASE_H -#define DRIVERKIT_DRIVER_BASE_H - -#include - -#define DDK_DRIVER_IMPL \ - final: \ - public \ - ::Kernel::DDK::IDriverBase - -/// @author Amlal El Mahrouss -/// @brief The DDK C++ API. - -namespace Kernel::DDK { -inline constexpr auto kInvalidType = 0; - -/// @brief Driver interface type. -class IDriverBase { - public: - IDriverBase() = default; - virtual ~IDriverBase() = default; - - IDriverBase& operator=(const IDriverBase&) = delete; - IDriverBase(const IDriverBase&) = delete; - - using PtrType = void*; - - virtual constexpr bool IsCastable() { return false; } - virtual constexpr bool IsActive() { return false; } - virtual PtrType Leak() { return nullptr; } - virtual constexpr int32_t Type() { return kInvalidType; } -}; - -/// @brief This concept requires the Driver to be IDriverBase compliant. -/// @author @amlel-el-mahrouss -template -concept IsValidDriver = requires(Driver drv) { - {drv.IsActive() && drv.Type() > kInvalidType}; -}; -} // namespace Kernel::DDK - -#endif diff --git a/src/libDDK/src/ddk_c++.cc b/src/libDDK/src/ddk_c++.cc deleted file mode 100644 index 65aa181c..00000000 --- a/src/libDDK/src/ddk_c++.cc +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) -// Licensed under the Apache License, Version 2.0 (see LICENSE file) -// Official repository: https://github.com/nekernel-org/nekernel - -#include diff --git a/src/libDDK/src/ddk_kernel_call.c b/src/libDDK/src/ddk_kernel_call.c index 53eb7f35..32ae3a42 100644 --- a/src/libDDK/src/ddk_kernel_call.c +++ b/src/libDDK/src/ddk_kernel_call.c @@ -13,7 +13,7 @@ /// @brief this is an internal call, do not use it. DDK_EXTERN ATTRIBUTE(naked) /* */ - ptr_t __ke_call_dispatch(const int32_t name, int32_t cnt, void* data, size_t sz); +ptr_t __ke_call_dispatch(const int32_t name, int32_t cnt, void* data, size_t sz); /// @brief This function hashes the path into a FNV symbol. /// @param path the path to hash. diff --git a/src/libDDK/src/ddk_objectkit.cc b/src/libDDK/src/ddk_objectkit.cc new file mode 100644 index 00000000..5aad76d2 --- /dev/null +++ b/src/libDDK/src/ddk_objectkit.cc @@ -0,0 +1,5 @@ +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (see LICENSE file) +// Official repository: https://github.com/nekernel-org/nekernel + +#include -- cgit v1.2.3