From d48cbe75ef29a9c67c9d176bf58e56ea6448fb9e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 21 Oct 2024 20:23:36 +0200 Subject: IMP: Major refactor of header and source files extensions. Signed-off-by: Amlal El Mahrouss --- dev/zka/ArchKit/ArchKit.h | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 dev/zka/ArchKit/ArchKit.h (limited to 'dev/zka/ArchKit/ArchKit.h') diff --git a/dev/zka/ArchKit/ArchKit.h b/dev/zka/ArchKit/ArchKit.h new file mode 100644 index 00000000..681dbab1 --- /dev/null +++ b/dev/zka/ArchKit/ArchKit.h @@ -0,0 +1,85 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#pragma once + +#include +#include +#include + +#include + +#ifdef __ZKA_AMD64__ +#include +#include +#include +#elif defined(__ZKA_POWER64__) +#include +#elif defined(__ZKA_ARM64__) +#include +#else +#error !!! unknown architecture !!! +#endif + +namespace Kernel +{ + inline SSizeT rt_hash_seed(const Char* seed, int mul) + { + SSizeT hash = 0; + + for (SSizeT idx = 0; seed[idx] != 0; ++idx) + { + hash += seed[idx]; + hash ^= mul; + } + + 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); + } +} // namespace Kernel + +#define kKernelMaxSystemCalls (256) + +typedef Kernel::Void (*rt_syscall_proc)(Kernel::VoidPtr); + +struct HAL_SYSCALL_RECORD final +{ + Kernel::Int64 fHash; + Kernel::Bool fHooked; + rt_syscall_proc fProc; + + operator bool() + { + return fHooked; + } +}; + +inline Kernel::Array + kSyscalls; + +inline Kernel::Array + kKerncalls; + +EXTERN_C Kernel::HAL::StackFramePtr mp_get_current_context(); -- cgit v1.2.3