summaryrefslogtreecommitdiffhomepage
path: root/src/libDDK/DriverKit
diff options
context:
space:
mode:
Diffstat (limited to 'src/libDDK/DriverKit')
-rw-r--r--src/libDDK/DriverKit/c++/checksum.h33
-rw-r--r--src/libDDK/DriverKit/c++/ddk.h4
-rw-r--r--src/libDDK/DriverKit/c++/driver_base.h5
-rw-r--r--src/libDDK/DriverKit/ddk.h16
4 files changed, 44 insertions, 14 deletions
diff --git a/src/libDDK/DriverKit/c++/checksum.h b/src/libDDK/DriverKit/c++/checksum.h
index 34a49675..4cc87423 100644
--- a/src/libDDK/DriverKit/c++/checksum.h
+++ b/src/libDDK/DriverKit/c++/checksum.h
@@ -1,10 +1,39 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
+// 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
-/// @todo Driver checksum
+#include <DriverKit/c++/driver_base.h>
+
+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;
+
+}
+
#endif
diff --git a/src/libDDK/DriverKit/c++/ddk.h b/src/libDDK/DriverKit/c++/ddk.h
index f9b6b8d1..857a65a7 100644
--- a/src/libDDK/DriverKit/c++/ddk.h
+++ b/src/libDDK/DriverKit/c++/ddk.h
@@ -1,11 +1,11 @@
-// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
+// 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 <DriverKit/c++/checksum.h>
#include <DriverKit/c++/driver_base.h>
+#include <DriverKit/c++/checksum.h>
#endif
diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h
index e5147b77..82e5bd44 100644
--- a/src/libDDK/DriverKit/c++/driver_base.h
+++ b/src/libDDK/DriverKit/c++/driver_base.h
@@ -5,11 +5,12 @@
#ifndef DRIVERKIT_DRIVER_BASE_H
#define DRIVERKIT_DRIVER_BASE_H
+#include <CompilerKit/CompilerKit.h>
#include <libDDK/DriverKit/macros.h>
#define DDK_DRIVER_IMPL \
final: \
- public \
+ public \
::Kernel::DDK::IDriverBase
/// @author Amlal El Mahrouss
@@ -38,7 +39,7 @@ class IDriverBase {
/// @author @amlel-el-mahrouss
template <typename Driver>
concept IsValidDriver = requires(Driver drv) {
- {drv.IsActive() && drv.Type() > kInvalidType};
+ { drv.IsActive() && drv.Type() > kInvalidType };
};
} // namespace Kernel::DDK
diff --git a/src/libDDK/DriverKit/ddk.h b/src/libDDK/DriverKit/ddk.h
index fa6a90ed..2ff2db9e 100644
--- a/src/libDDK/DriverKit/ddk.h
+++ b/src/libDDK/DriverKit/ddk.h
@@ -10,11 +10,18 @@
struct DDK_STATUS_STRUCT;
struct DDK_OBJECT_MANIFEST;
+typedef void* ptr_t;
+
+typedef ptr_t addr_t;
+
+typedef ptr_t vaddr_t;
+typedef ptr_t paddr_t;
+
/// \brief Object handle manifest.
struct DDK_OBJECT_MANIFEST DDK_FINAL {
char* p_name;
int32_t p_kind;
- void* p_object;
+ ptr_t p_object;
};
/// \brief DDK status ping structure.
@@ -25,13 +32,6 @@ struct DDK_STATUS_STRUCT DDK_FINAL {
struct DDK_OBJECT_MANIFEST* s_object;
};
-typedef void* ptr_t;
-
-typedef ptr_t addr_t;
-
-typedef ptr_t vaddr_t;
-typedef ptr_t paddr_t;
-
/// @brief Call Kernel procedure.
/// @param name the procedure name.
/// @param cnt number of elements in **dat**