diff options
Diffstat (limited to 'Kernel/ArchKit/ArchKit.hpp')
| -rw-r--r-- | Kernel/ArchKit/ArchKit.hpp | 41 |
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) |
