From 38cddd5dc02f886e5cb3a0e386f0f7a1e6c8da86 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 1 Mar 2026 05:48:35 +0100 Subject: feat: ddk!: Breaking changes, the DDK has been reworked in C++ instead. chore: public, kernel: fixes and important patches. Signed-off-by: Amlal El Mahrouss --- src/libDDK/DriverKit/ObjectKit/Base.h | 48 ++++++++++++++++++++++++++++ src/libDDK/DriverKit/ObjectKit/Checksum.h | 39 ++++++++++++++++++++++ src/libDDK/DriverKit/ObjectKit/DriverKit.h | 11 +++++++ src/libDDK/DriverKit/ObjectKit/checksum.h | 39 ---------------------- src/libDDK/DriverKit/ObjectKit/ddk.h | 11 ------- src/libDDK/DriverKit/ObjectKit/driver_base.h | 48 ---------------------------- 6 files changed, 98 insertions(+), 98 deletions(-) create mode 100644 src/libDDK/DriverKit/ObjectKit/Base.h create mode 100644 src/libDDK/DriverKit/ObjectKit/Checksum.h create mode 100644 src/libDDK/DriverKit/ObjectKit/DriverKit.h delete mode 100644 src/libDDK/DriverKit/ObjectKit/checksum.h delete mode 100644 src/libDDK/DriverKit/ObjectKit/ddk.h delete mode 100644 src/libDDK/DriverKit/ObjectKit/driver_base.h (limited to 'src/libDDK/DriverKit/ObjectKit') diff --git a/src/libDDK/DriverKit/ObjectKit/Base.h b/src/libDDK/DriverKit/ObjectKit/Base.h new file mode 100644 index 00000000..4d2f6072 --- /dev/null +++ b/src/libDDK/DriverKit/ObjectKit/Base.h @@ -0,0 +1,48 @@ +// 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_OBJECTKIT_DRIVER_BASE_H +#define DRIVERKIT_OBJECTKIT_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&) = default; + IDriverBase(const IDriverBase&) = default; + + 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/ObjectKit/Checksum.h b/src/libDDK/DriverKit/ObjectKit/Checksum.h new file mode 100644 index 00000000..e925f9ca --- /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/DriverKit.h b/src/libDDK/DriverKit/ObjectKit/DriverKit.h new file mode 100644 index 00000000..490e7d03 --- /dev/null +++ b/src/libDDK/DriverKit/ObjectKit/DriverKit.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/checksum.h b/src/libDDK/DriverKit/ObjectKit/checksum.h deleted file mode 100644 index 92c63603..00000000 --- a/src/libDDK/DriverKit/ObjectKit/checksum.h +++ /dev/null @@ -1,39 +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*; -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 deleted file mode 100644 index 2d6dec75..00000000 --- a/src/libDDK/DriverKit/ObjectKit/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/ObjectKit/driver_base.h b/src/libDDK/DriverKit/ObjectKit/driver_base.h deleted file mode 100644 index f5811fb2..00000000 --- a/src/libDDK/DriverKit/ObjectKit/driver_base.h +++ /dev/null @@ -1,48 +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_OBJECTKIT_DRIVER_BASE_H -#define DRIVERKIT_OBJECTKIT_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&) = default; - IDriverBase(const IDriverBase&) = default; - - 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 -- cgit v1.2.3