summaryrefslogtreecommitdiffhomepage
path: root/src/libDDK
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-26 00:11:43 -0500
committerGitHub <noreply@github.com>2025-11-26 00:11:43 -0500
commit286c9c16a42399716b4ecaa7cab902e5434fa0a6 (patch)
tree5e82555fd3c5bf1e0484e9c6149c192b19708023 /src/libDDK
parent1dc16c306587b4d6410adfcd4dca8f7ba13df78f (diff)
parent2187ed0f67e21c6425b8770ff52ca02269a21a9d (diff)
Merge pull request #83 from nekernel-org/dev
Hotpatches.
Diffstat (limited to 'src/libDDK')
-rw-r--r--src/libDDK/DriverKit/c++/checksum.h10
-rw-r--r--src/libDDK/DriverKit/c++/ddk.h13
-rw-r--r--src/libDDK/DriverKit/c++/driver_base.h48
-rw-r--r--src/libDDK/DriverKit/dev.h3
-rw-r--r--src/libDDK/DriverKit/dki/contract.h34
5 files changed, 74 insertions, 34 deletions
diff --git a/src/libDDK/DriverKit/c++/checksum.h b/src/libDDK/DriverKit/c++/checksum.h
new file mode 100644
index 00000000..0aa206be
--- /dev/null
+++ b/src/libDDK/DriverKit/c++/checksum.h
@@ -0,0 +1,10 @@
+/* ========================================
+
+ Copyright Amlal El Mahrouss 2025, licensed under the Apache 2.0 license.
+
+ FILE: checksum.h
+ PURPOSE: Object DDK checksums.
+
+ ======================================== */
+
+#pragma once \ No newline at end of file
diff --git a/src/libDDK/DriverKit/c++/ddk.h b/src/libDDK/DriverKit/c++/ddk.h
new file mode 100644
index 00000000..2c83f935
--- /dev/null
+++ b/src/libDDK/DriverKit/c++/ddk.h
@@ -0,0 +1,13 @@
+/* ========================================
+
+ Copyright Amlal El Mahrouss 2025, licensed under the Apache 2.0 license.
+
+ FILE: ddk.h
+ PURPOSE: Object DDK header.
+
+ ======================================== */
+
+#pragma once
+
+#include <DriverKit/c++/driver_base.h>
+#include <DriverKit/c++/checksum.h>
diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h
new file mode 100644
index 00000000..89cc04d8
--- /dev/null
+++ b/src/libDDK/DriverKit/c++/driver_base.h
@@ -0,0 +1,48 @@
+/* ========================================
+
+ Copyright Amlal El Mahrouss 2025, licensed under the Apache 2.0 license.
+
+ FILE: driver_base.h
+ PURPOSE: IDriverBase and friends.
+
+ ======================================== */
+
+#pragma once
+
+#include <CompilerKit/CompilerKit.h>
+#include <libDDK/DriverKit/macros.h>
+
+#define DKI_DRIVER_IMPL \
+ final: \
+ public \
+ ::Kernel::DDK::IDriverBase
+
+/// @author Amlal El Mahrouss
+
+namespace Kernel::DDK {
+class IDriverBase {
+ public:
+ explicit IDriverBase() = default;
+ virtual ~IDriverBase() = default;
+
+ NE_COPY_DEFAULT(IDriverBase);
+
+ using PtrType = VoidPtr;
+
+ virtual BOOL IsCastable() { return NO; }
+ virtual constexpr BOOL IsActive() { return NO; }
+ virtual PtrType Leak() { return nullptr; }
+ virtual constexpr Int32 Type() { return 0; }
+};
+
+/// @brief This concept requires the Driver to be IDriverBase compliant.
+template <typename T>
+concept IsValidDriver = requires(T a) {
+ { a.IsActive() && a.Type() > 0 };
+};
+
+/// @brief Consteval helper to detect whether a template is truly based on IDriverBase.
+/// @note This helper is consteval only.
+template<IsValidDriver T>
+inline consteval void ce_ddk_is_valid(T) {}
+} // namespace Kernel::DDK
diff --git a/src/libDDK/DriverKit/dev.h b/src/libDDK/DriverKit/dev.h
index a88a00dd..1dda544e 100644
--- a/src/libDDK/DriverKit/dev.h
+++ b/src/libDDK/DriverKit/dev.h
@@ -27,6 +27,9 @@ typedef struct _DDK_DEVICE DDK_FINAL {
size_t (*d_tell)(struct _DDK_DEVICE* dev);
} DDK_DEVICE, *DDK_DEVICE_PTR;
+#define kopen kopen_dev
+#define kclose kclose_dev
+
/// @brief Open a new device from path.
/// @param path the device's path.
DDK_EXTERN DDK_DEVICE_PTR kopen_dev(const char* path);
diff --git a/src/libDDK/DriverKit/dki/contract.h b/src/libDDK/DriverKit/dki/contract.h
deleted file mode 100644
index 7361d792..00000000
--- a/src/libDDK/DriverKit/dki/contract.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ========================================
-
- Copyright Amlal El Mahrouss 2025, licensed under the Apache 2.0 license.
-
- FILE: ddk.h
- PURPOSE: Driver Kernel Interface Model base header.
-
- ======================================== */
-
-#pragma once
-
-#include <CompilerKit/CompilerKit.h>
-#include <libDDK/DriverKit/macros.h>
-
-#define DKI_CONTRACT_IMPL final : public ::Kernel::DKI::DKIContract
-
-/// @author Amlal El Mahrouss
-
-namespace Kernel::DKI {
-class DKIContract {
- public:
- explicit DKIContract() = default;
- virtual ~DKIContract() = default;
-
- NE_COPY_DEFAULT(DKIContract);
-
- using PtrType = VoidPtr;
-
- virtual BOOL IsCastable() { return NO; }
- virtual BOOL IsActive() { return NO; }
- virtual VoidPtr Leak() { return nullptr; }
- virtual Int32 Type() { return 0; }
-};
-} // namespace Kernel::DKI