summaryrefslogtreecommitdiffhomepage
path: root/Kernel/ArchKit
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-06-06 10:27:55 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-06-06 10:27:55 +0000
commit4e75e05a20ddd0dbca982e8f3bc2ea8043ed3a3f (patch)
tree95409c0e32b644578b94a5c230417da684d79dc9 /Kernel/ArchKit
parentf5081a8f9a8537ad5be5d639955cd1d0e68a9e1d (diff)
parent9994b8f3f88131f41be1061fb0947177e66dc7b0 (diff)
Merged in MHR-23 (pull request #14)
Draft: MHR-23
Diffstat (limited to 'Kernel/ArchKit')
-rw-r--r--Kernel/ArchKit/ArchKit.hpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/Kernel/ArchKit/ArchKit.hpp b/Kernel/ArchKit/ArchKit.hpp
index 83770272..fa899984 100644
--- a/Kernel/ArchKit/ArchKit.hpp
+++ b/Kernel/ArchKit/ArchKit.hpp
@@ -34,6 +34,47 @@ namespace NewOS
return hash;
}
+
+ /// @brief write to mapped memory register
+ /// @param base the base address.
+ /// @param reg the register.
+ /// @param value the write to write on it.
+ inline void ke_dma_write(UInt32 base, UInt32 reg, UInt32 value) noexcept
+ {
+ *(volatile UInt32*)((UInt64)base + reg) = value;
+ }
+
+ /// @brief read from mapped memory register.
+ /// @param base base address
+ /// @param reg the register.
+ /// @return the value inside the register.
+ inline UInt32 ke_dma_read(UInt32 base, UInt32 reg) noexcept
+ {
+ return *(volatile UInt32*)((UInt64)base + reg);
+ }
+
+ /// @brief Print a region of memory.
+ /// @param start
+ /// @param length
+ inline void ke_print_raw_memory(const void* start, Size length)
+ {
+ const UInt8* ptr = (const UInt8*)start;
+ for (Size i = 0; i < length; i++)
+ {
+ if (i % 16 == 0)
+ {
+ kcout << hex_number((UIntPtr)ptr + i);
+ }
+ else
+ {
+ kcout << hex_number(ptr[i]);
+ }
+
+ kcout << " ";
+ }
+
+ kcout << "\r";
+ }
} // namespace NewOS
#define kKernelMaxSystemCalls (256)