summaryrefslogtreecommitdiffhomepage
path: root/ArchKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-06 09:14:11 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-06 09:14:11 +0100
commit5339d016c07bf717ee388f4feb73544087324af0 (patch)
tree94be6f67ed626091f24aee24ec3b3be03d01e4e7 /ArchKit
git: port from mercurial repo.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'ArchKit')
-rw-r--r--ArchKit/Arch.hpp86
-rw-r--r--ArchKit/SyscallImpl.hpp12
-rw-r--r--ArchKit/compile_flags.txt5
3 files changed, 103 insertions, 0 deletions
diff --git a/ArchKit/Arch.hpp b/ArchKit/Arch.hpp
new file mode 100644
index 00000000..3d7f0f6c
--- /dev/null
+++ b/ArchKit/Arch.hpp
@@ -0,0 +1,86 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+#include <NewKit/Defines.hpp>
+#include <NewKit/Function.hpp>
+#include <NewKit/Array.hpp>
+
+#ifdef __x86_64__
+# include <HALKit/AMD64/Hypervisor.hpp>
+# include <HALKit/AMD64/Processor.hpp>
+# include <HALKit/AMD64/HalPageAlloc.hpp>
+#elif defined(__powerpc64__)
+# include <HALKit/PowerPC/Processor.hpp>
+#else
+# error Unknown architecture
+#endif
+
+namespace hCore
+{
+ class SystemCallDefaultImpl final
+ {
+ public:
+ static Int32 Exec() { return 0; }
+
+ };
+
+ template <SSizeT ID>
+ 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<RET>()";
+ 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 initialize_hardware_components();
+} // namespace hCore
+
+#define kMaxSyscalls 0x100
+#define kSyscallGate 0x21
+
+extern hCore::Array<void (*)(hCore::Int32 id, hCore::HAL::StackFrame *), kMaxSyscalls> kSyscalls;
+
+extern "C" void rt_wait_for_io();
+extern "C" void rt_syscall_handle(hCore::HAL::StackFrame *stack);
+extern "C" hCore::HAL::StackFrame* rt_get_current_context();
+extern "C" int rt_do_context_switch(hCore::HAL::StackFrame* stackLeft, hCore::HAL::StackFrame* stackRight);
+
diff --git a/ArchKit/SyscallImpl.hpp b/ArchKit/SyscallImpl.hpp
new file mode 100644
index 00000000..4ba472e6
--- /dev/null
+++ b/ArchKit/SyscallImpl.hpp
@@ -0,0 +1,12 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+#include <ArchKit/Arch.hpp> \ No newline at end of file
diff --git a/ArchKit/compile_flags.txt b/ArchKit/compile_flags.txt
new file mode 100644
index 00000000..a37ae6bf
--- /dev/null
+++ b/ArchKit/compile_flags.txt
@@ -0,0 +1,5 @@
+-nostdlib
+-ffreestanding
+-std=c++20
+-I./
+-I../