summaryrefslogtreecommitdiffhomepage
path: root/Kernel/ArchKit/ArchKit.hpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-06-01 09:29:31 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-06-01 09:29:31 +0200
commitfc0d38259fd6670966b916b1f28a11f3cb2a4c45 (patch)
tree2a54c64137eae7ffacfcb1842a92335b0e41b39b /Kernel/ArchKit/ArchKit.hpp
parentc8b9625efaeae241d57cc8a40c3234807206e386 (diff)
MHR-23: SMP: Add hal_send_start_ipi and hal_send_end_ipi, as well as
DMA utilities. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Kernel/ArchKit/ArchKit.hpp')
-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)