From e0024d9ea688ee91a77abc0e28c5ea24b13ca67d Mon Sep 17 00:00:00 2001 From: Amlal Date: Mon, 28 Oct 2024 07:01:58 +0100 Subject: IMP: Refactor whole source code to make it even. - That is because previously the source was both in lowercase and lettercase. Signed-off-by: Amlal --- dev/ZKAKit/ArchKit/ArchKit.h | 85 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 dev/ZKAKit/ArchKit/ArchKit.h (limited to 'dev/ZKAKit/ArchKit/ArchKit.h') diff --git a/dev/ZKAKit/ArchKit/ArchKit.h b/dev/ZKAKit/ArchKit/ArchKit.h new file mode 100644 index 00000000..681dbab1 --- /dev/null +++ b/dev/ZKAKit/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