From 800977c96cd64b3beeccaa7d373daed3987b1c2a Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 2 Feb 2024 14:26:01 +0100 Subject: Kernel: Improvements and fixes regarding the VMMers and assembly code. Signed-off-by: Amlal El Mahrouss --- Private/ArchKit/Arch.hpp | 86 -------------------------------------- Private/ArchKit/ArchKit.hpp | 91 +++++++++++++++++++++++++++++++++++++++++ Private/ArchKit/SyscallImpl.hpp | 3 +- 3 files changed, 93 insertions(+), 87 deletions(-) delete mode 100644 Private/ArchKit/Arch.hpp create mode 100644 Private/ArchKit/ArchKit.hpp (limited to 'Private/ArchKit') diff --git a/Private/ArchKit/Arch.hpp b/Private/ArchKit/Arch.hpp deleted file mode 100644 index 4216f9b3..00000000 --- a/Private/ArchKit/Arch.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#pragma once - -#include -#include -#include - -#ifdef __x86_64__ -# include -# include -# include -#elif defined(__powerpc64__) -# include -#else -# error Unknown architecture -#endif - -namespace HCore -{ - class SystemCallDefaultImpl final - { - public: - static Int32 Exec() { return 0; } - - }; - - template - class SystemCall - { - public: - explicit SystemCall() - { - kcout << "SystemCall::SystemCall"; - } - - virtual ~SystemCall() - { - kcout << "SystemCall::~SystemCall"; - } - - SystemCall &operator=(const SystemCall &) = default; - SystemCall(const SystemCall &) = default; - - // Should not be called alone! - virtual bool Exec() const - { - kcout << "SystemCall->Exec()"; - return false; - } - - }; - - constexpr static inline SSizeT syscall_hash(const char *seed, int mul) - { - SSizeT hash = 0; - - for (SSizeT idx = 0; seed[idx] != 0; ++idx) - { - hash += seed[idx]; - hash ^= mul; - } - - return hash; - } - - bool ke_init_hal(); -} // namespace HCore - -#define kMaxSyscalls 0x100 -#define kSyscallGate 0x21 - -extern HCore::Array kSyscalls; - -extern "C" void rt_wait_for_io(); -extern "C" void rt_syscall_handle(HCore::HAL::StackFrame* stackFrame); -extern "C" HCore::HAL::StackFrame* rt_get_current_context(); -extern "C" int rt_do_context_switch(HCore::HAL::StackFrame* stackFrame); - diff --git a/Private/ArchKit/ArchKit.hpp b/Private/ArchKit/ArchKit.hpp new file mode 100644 index 00000000..eefd6f5f --- /dev/null +++ b/Private/ArchKit/ArchKit.hpp @@ -0,0 +1,91 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include +#include +#include + +#ifdef __x86_64__ +# include +# include +# include +#elif defined(__powerpc64__) +# include +#else +# error Unknown architecture +#endif + +namespace HCore +{ + class SystemCallDefaultImpl final + { + public: + static Int32 Exec() { return 0; } + + }; + + template + class SystemCall + { + public: + explicit SystemCall() + { + kcout << "SystemCall::SystemCall"; + } + + virtual ~SystemCall() + { + kcout << "SystemCall::~SystemCall"; + } + + SystemCall &operator=(const SystemCall &) = default; + SystemCall(const SystemCall &) = default; + + // Should not be called alone! + virtual bool Exec() const + { + kcout << "SystemCall->Exec()"; + return false; + } + + }; + + constexpr static inline SSizeT syscall_hash(const char *seed, int mul) + { + SSizeT hash = 0; + + for (SSizeT idx = 0; seed[idx] != 0; ++idx) + { + hash += seed[idx]; + hash ^= mul; + } + + return hash; + } + + bool ke_init_hal(); +} // namespace HCore + +#define kMaxSyscalls 0x100 +#define kSyscallGate 0x21 + +extern HCore::Array kSyscalls; + +extern "C" void rt_wait_for_io(); +extern "C" void rt_syscall_handle(HCore::HAL::StackFrame* stackFrame); +extern "C" HCore::HAL::StackFrame* rt_get_current_context(); +extern "C" int rt_do_context_switch(HCore::HAL::StackFrame* stackFrame); + +inline HCore::VoidPtr kKernelVirtualStart; +inline HCore::UIntPtr kKernelVirtualSize; + +inline HCore::VoidPtr kKernelPhysicalStart; +inline HCore::UIntPtr kKernelPhysicalSize; diff --git a/Private/ArchKit/SyscallImpl.hpp b/Private/ArchKit/SyscallImpl.hpp index 7d379197..26acdd38 100644 --- a/Private/ArchKit/SyscallImpl.hpp +++ b/Private/ArchKit/SyscallImpl.hpp @@ -9,4 +9,5 @@ #pragma once -#include \ No newline at end of file +#include + -- cgit v1.2.3