summaryrefslogtreecommitdiffhomepage
path: root/Private/HALKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-02 14:26:01 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-02 14:26:01 +0100
commit800977c96cd64b3beeccaa7d373daed3987b1c2a (patch)
treed97b5788f92b416f8f7f386ed9f179ab792b6f72 /Private/HALKit
parente559cf01834340d0a4dfcb45f7bdf081e8994032 (diff)
Kernel: Improvements and fixes regarding the VMMers and assembly code.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/HALKit')
-rw-r--r--Private/HALKit/AMD64/CPUID.hxx1
-rw-r--r--Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp2
-rw-r--r--Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp2
-rw-r--r--Private/HALKit/AMD64/DebugOutput.cxx2
-rw-r--r--Private/HALKit/AMD64/DebugPort.cxx2
-rw-r--r--Private/HALKit/AMD64/HalHardwareAPIC.cpp2
-rw-r--r--Private/HALKit/AMD64/HalHardwareInit.cpp2
-rw-r--r--Private/HALKit/AMD64/HalPageAlloc.cpp9
-rw-r--r--Private/HALKit/AMD64/HalPageAlloc.hpp5
-rw-r--r--Private/HALKit/AMD64/HalPlatformAMD64.cpp2
-rw-r--r--Private/HALKit/AMD64/PCI/Device.cpp2
-rw-r--r--Private/HALKit/AMD64/SMPCoreManager.asm2
-rw-r--r--Private/HALKit/AMD64/StartSequence.asm3
-rw-r--r--Private/HALKit/AXP/CoreSyscallHandlerDEC.cpp2
-rw-r--r--Private/HALKit/PowerPC/CoreSyscallHandlerPowerPC.cpp2
15 files changed, 24 insertions, 16 deletions
diff --git a/Private/HALKit/AMD64/CPUID.hxx b/Private/HALKit/AMD64/CPUID.hxx
index 16e73eb6..85eb4893 100644
--- a/Private/HALKit/AMD64/CPUID.hxx
+++ b/Private/HALKit/AMD64/CPUID.hxx
@@ -76,3 +76,4 @@ typedef enum {
CPU_FEATURE_EDX_IA64 = 1 << 30,
CPU_FEATURE_EDX_PBE = 1 << 31
} CPU_FEATURE;
+
diff --git a/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp
index 8399d9ce..caf891d1 100644
--- a/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp
+++ b/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
#include <KernelKit/ProcessManager.hpp>
#include <NewKit/String.hpp>
diff --git a/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp b/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp
index b41b8285..4f1ed4da 100644
--- a/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp
+++ b/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
#include <HALKit/AMD64/Processor.hpp>
#include <KernelKit/PermissionSelector.hxx>
diff --git a/Private/HALKit/AMD64/DebugOutput.cxx b/Private/HALKit/AMD64/DebugOutput.cxx
index ad9fc8c5..c4e9cc48 100644
--- a/Private/HALKit/AMD64/DebugOutput.cxx
+++ b/Private/HALKit/AMD64/DebugOutput.cxx
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
#include <KernelKit/DebugOutput.hpp>
#include <NewKit/Utils.hpp>
diff --git a/Private/HALKit/AMD64/DebugPort.cxx b/Private/HALKit/AMD64/DebugPort.cxx
index b0f2f6d1..d292f95d 100644
--- a/Private/HALKit/AMD64/DebugPort.cxx
+++ b/Private/HALKit/AMD64/DebugPort.cxx
@@ -10,7 +10,7 @@
//! @file DebuggerPort.cxx
//! @brief UART debug via packets.
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
#define kDebugMaxPorts 16
diff --git a/Private/HALKit/AMD64/HalHardwareAPIC.cpp b/Private/HALKit/AMD64/HalHardwareAPIC.cpp
index c2bcc007..4e985f8e 100644
--- a/Private/HALKit/AMD64/HalHardwareAPIC.cpp
+++ b/Private/HALKit/AMD64/HalHardwareAPIC.cpp
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
// bugs = 0
diff --git a/Private/HALKit/AMD64/HalHardwareInit.cpp b/Private/HALKit/AMD64/HalHardwareInit.cpp
index bc002e3d..adcacce4 100644
--- a/Private/HALKit/AMD64/HalHardwareInit.cpp
+++ b/Private/HALKit/AMD64/HalHardwareInit.cpp
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
// bugs = 0
diff --git a/Private/HALKit/AMD64/HalPageAlloc.cpp b/Private/HALKit/AMD64/HalPageAlloc.cpp
index 86631e57..6d6e4ba5 100644
--- a/Private/HALKit/AMD64/HalPageAlloc.cpp
+++ b/Private/HALKit/AMD64/HalPageAlloc.cpp
@@ -8,12 +8,12 @@
*/
#include <HALKit/AMD64/HalPageAlloc.hpp>
-#include <NewKit/Defines.hpp>
#include <NewKit/RuntimeCheck.hpp>
+#include <NewKit/Defines.hpp>
// this files handles paging.
-static HCore::UIntPtr kPagePtr = kPagePtrAddress;
+static HCore::UIntPtr kPagePtr = 0;
static HCore::SizeT kPageCnt = 0UL;
namespace HCore {
@@ -23,6 +23,7 @@ static auto hal_try_alloc_new_page(SizeT sz, Boolean rw, Boolean user)
char *ptr = &(reinterpret_cast<char *>(kPagePtr))[kPageCnt + 1];
PageTable64 *pte = reinterpret_cast<PageTable64 *>(ptr);
+
pte->Rw = rw;
pte->User = user;
pte->Present = true;
@@ -52,5 +53,9 @@ auto hal_create_page(Boolean rw, Boolean user) -> UIntPtr {
return reinterpret_cast<UIntPtr>(new_pte);
}
+
+UIntPtr& hal_get_page_ptr() noexcept { return kPagePtr; }
+
+void hal_set_page_ptr(const UIntPtr& newPagePtr) noexcept { kPagePtr = newPagePtr; }
} // namespace HAL
} // namespace HCore
diff --git a/Private/HALKit/AMD64/HalPageAlloc.hpp b/Private/HALKit/AMD64/HalPageAlloc.hpp
index 3f9428b9..711dc27d 100644
--- a/Private/HALKit/AMD64/HalPageAlloc.hpp
+++ b/Private/HALKit/AMD64/HalPageAlloc.hpp
@@ -19,8 +19,6 @@
#define PTE_ALIGN (4096)
#endif //! PTE_ALIGN
-#define kPagePtrAddress 0x9000000
-
extern "C" void flush_tlb(HCore::UIntPtr VirtualAddr);
extern "C" void write_cr3(HCore::UIntPtr pde);
extern "C" void write_cr0(HCore::UIntPtr bit);
@@ -44,6 +42,7 @@ struct PageTable64 {
};
PageTable64 *hal_alloc_page(SizeT sz, Boolean rw, Boolean user);
-
+UIntPtr& hal_get_page_ptr() noexcept;
+void hal_set_page_ptr(const UIntPtr& newPagePtr) noexcept;
UIntPtr hal_create_page(Boolean rw, Boolean user);
} // namespace HCore::HAL
diff --git a/Private/HALKit/AMD64/HalPlatformAMD64.cpp b/Private/HALKit/AMD64/HalPlatformAMD64.cpp
index ab03659a..6374d06b 100644
--- a/Private/HALKit/AMD64/HalPlatformAMD64.cpp
+++ b/Private/HALKit/AMD64/HalPlatformAMD64.cpp
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
namespace HCore::HAL {
namespace Detail {
diff --git a/Private/HALKit/AMD64/PCI/Device.cpp b/Private/HALKit/AMD64/PCI/Device.cpp
index 815043c9..b353d2a6 100644
--- a/Private/HALKit/AMD64/PCI/Device.cpp
+++ b/Private/HALKit/AMD64/PCI/Device.cpp
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
#include <KernelKit/PCI/Device.hpp>
HCore::UInt LumiaPCIReadRaw(HCore::UInt bar, HCore::UShort bus,
diff --git a/Private/HALKit/AMD64/SMPCoreManager.asm b/Private/HALKit/AMD64/SMPCoreManager.asm
index 1a994258..9741d092 100644
--- a/Private/HALKit/AMD64/SMPCoreManager.asm
+++ b/Private/HALKit/AMD64/SMPCoreManager.asm
@@ -14,6 +14,8 @@
section .text
rt_do_context_switch:
+ mov rcx, r15
+
mov [r15+0], rax
mov [r15+8], rbx
mov [r15+16], rcx
diff --git a/Private/HALKit/AMD64/StartSequence.asm b/Private/HALKit/AMD64/StartSequence.asm
index 5ef8ed55..c8e0a4e2 100644
--- a/Private/HALKit/AMD64/StartSequence.asm
+++ b/Private/HALKit/AMD64/StartSequence.asm
@@ -15,7 +15,6 @@
;; External symbols needed by this unit.
[extern RuntimeMain]
-[extern __SYSTEM_STACK_END]
%define kTypeKernel 100
%define kArchAmd64 122
@@ -32,7 +31,9 @@ section .text
;; Just a simple setup, we'd also need to tell some before
Main:
+ push rcx
jmp RuntimeMain
+ pop rcx
L0:
cli
hlt
diff --git a/Private/HALKit/AXP/CoreSyscallHandlerDEC.cpp b/Private/HALKit/AXP/CoreSyscallHandlerDEC.cpp
index 11965ff7..5d1c6d2b 100644
--- a/Private/HALKit/AXP/CoreSyscallHandlerDEC.cpp
+++ b/Private/HALKit/AXP/CoreSyscallHandlerDEC.cpp
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
#include <HALKit/Alpha/Processor.hpp>
HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *), kMaxSyscalls> kSyscalls;
diff --git a/Private/HALKit/PowerPC/CoreSyscallHandlerPowerPC.cpp b/Private/HALKit/PowerPC/CoreSyscallHandlerPowerPC.cpp
index 7c7d7683..c1672e68 100644
--- a/Private/HALKit/PowerPC/CoreSyscallHandlerPowerPC.cpp
+++ b/Private/HALKit/PowerPC/CoreSyscallHandlerPowerPC.cpp
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <ArchKit/Arch.hpp>
+#include <ArchKit/ArchKit.hpp>
#include <NewKit/Array.hpp>
HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *), kMaxSyscalls>