summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKAKit/HALKit
diff options
context:
space:
mode:
authorAmlal <amlal.elmahrouss@icloud.com>2024-10-30 06:55:35 +0100
committerAmlal <amlal.elmahrouss@icloud.com>2024-10-30 06:55:35 +0100
commit8600ffcc1ddfc861e761baf2682490061a55cca8 (patch)
treec51f0b4ce9fa8565c683be7209890c21ab09a99a /dev/ZKAKit/HALKit
parent708400a70921055b06013f9b149449be64a7d585 (diff)
FIX: Scheduler should always check for a valid image, even for DLLs.
FIX: Fix ZBA modules btb files. FIX: Don't put while statement on page allocation. Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKAKit/HALKit')
-rw-r--r--dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc5
-rw-r--r--dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc2
-rw-r--r--dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc14
-rw-r--r--dev/ZKAKit/HALKit/AMD64/HalPagingMgrAMD64.cc28
-rw-r--r--dev/ZKAKit/HALKit/ARM64/HalKernelMain.cc2
-rw-r--r--dev/ZKAKit/HALKit/ARM64/HalPagingMgrARM64.cc (renamed from dev/ZKAKit/HALKit/ARM64/HalPagingMgr.cc)0
6 files changed, 33 insertions, 18 deletions
diff --git a/dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc b/dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc
index cb323ed8..ded862dd 100644
--- a/dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc
+++ b/dev/ZKAKit/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc
@@ -8,11 +8,6 @@
#include <KernelKit/UserProcessScheduler.h>
#include <NewKit/KString.h>
-namespace Kernel
-{
- EXTERN UserProcessScheduler* kProcessScheduler;
-}
-
/// @brief Handle GPF fault.
/// @param rsp
EXTERN_C void idt_handle_gpf(Kernel::UIntPtr rsp)
diff --git a/dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc b/dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc
index b04fb0b0..f28d23a5 100644
--- a/dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc
+++ b/dev/ZKAKit/HALKit/AMD64/HalDescriptorLoader.cc
@@ -7,7 +7,7 @@
#include <ArchKit/ArchKit.h>
#include <HALKit/AMD64/Processor.h>
-#define kPITDefaultTicks (1000U)
+#define kPITDefaultTicks (100U)
namespace Kernel::HAL
{
diff --git a/dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc b/dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc
index 58b7acbf..14cf4dae 100644
--- a/dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc
+++ b/dev/ZKAKit/HALKit/AMD64/HalKernelMain.cc
@@ -17,6 +17,18 @@ EXTERN_C Kernel::VoidPtr kInterruptVectorTable[];
EXTERN_C Kernel::VoidPtr mp_user_switch_proc;
EXTERN_C Kernel::Char mp_user_switch_proc_stack_begin[];
+EXTERN_C Kernel::MainKind __CTOR_LIST__[];
+EXTERN_C Kernel::MainKind __DTOR_LIST__[];
+
+STATIC Kernel::Void hal_init_cxx_ctors()
+{
+ for (Kernel::SizeT index = 0UL; __CTOR_LIST__[index] != __DTOR_LIST__[0]; ++index)
+ {
+ Kernel::MainKind ctor = (Kernel::MainKind)__CTOR_LIST__[index];
+ ctor();
+ }
+}
+
/// @brief Kernel init procedure.
EXTERN_C void hal_init_platform(
Kernel::HEL::HANDOVER_INFO_HEADER* HandoverHeader)
@@ -29,6 +41,8 @@ EXTERN_C void hal_init_platform(
return;
}
+ hal_init_cxx_ctors();
+
/************************************** */
/* INITIALIZE BIT MAP. */
/************************************** */
diff --git a/dev/ZKAKit/HALKit/AMD64/HalPagingMgrAMD64.cc b/dev/ZKAKit/HALKit/AMD64/HalPagingMgrAMD64.cc
index a94fe442..53553a13 100644
--- a/dev/ZKAKit/HALKit/AMD64/HalPagingMgrAMD64.cc
+++ b/dev/ZKAKit/HALKit/AMD64/HalPagingMgrAMD64.cc
@@ -14,7 +14,9 @@ namespace Kernel::HAL
{
typedef UInt32 PageTableIndex;
+ /***********************************************************************************/
/// \brief Page store type.
+ /***********************************************************************************/
struct ZKA_PAGE_STORE final
{
struct
@@ -24,7 +26,7 @@ namespace Kernel::HAL
VoidPtr fVAddr{nullptr};
} fInternalStore;
- Bool fStoreOp{No}; // Store operation in progress.
+ Bool fStoreOp{No}; // Store operation is in progress.
bool IsValidPage(PTE* pte)
{
@@ -48,7 +50,10 @@ namespace Kernel::HAL
}
};
+ /***********************************************************************************/
/// \brief Retrieve the page status of a PTE.
+ /// \param pte Page Table Entry pointer.
+ /***********************************************************************************/
STATIC Void mmi_page_status(PTE* pte)
{
kcout << (pte->Present ? "Present" : "Not Present") << endl;
@@ -57,13 +62,15 @@ namespace Kernel::HAL
kcout << (pte->User ? "User" : "Not User") << endl;
}
- STATIC Int32 mmi_map_page_table_entry(VoidPtr virtual_address, UInt32 flags, PTE* pt_entry);
+ STATIC Int32 mmi_map_page_table_entry(VoidPtr virtual_address, UInt32 flags, ZKA_PTE* pt_entry, ZKA_PDE* pd_entry);
+ /***********************************************************************************/
/// @brief Maps or allocates a page from virtual_address.
/// @param virtual_address a valid virtual address.
/// @param phys_addr point to physical address.
/// @param flags the flags to put on the page.
/// @return Status code of page manipulation process.
+ /***********************************************************************************/
EXTERN_C Int32 mm_map_page(VoidPtr virtual_address, UInt32 flags)
{
if (!virtual_address ||
@@ -84,15 +91,12 @@ namespace Kernel::HAL
UInt64 pd_index = ((UIntPtr)virtual_address >> 21) & cPmlIndexMask;
UInt64 pt_index = ((UIntPtr)virtual_address >> 12) & cPmlIndexMask;
- while (page_store.fStoreOp)
- ;
-
page_store.fStoreOp = Yes;
if (page_store.fInternalStore.fVAddr == virtual_address)
{
page_store.fStoreOp = No;
- return mmi_map_page_table_entry(page_store.fInternalStore.fVAddr, flags, page_store.fInternalStore.fPte);
+ return mmi_map_page_table_entry(page_store.fInternalStore.fVAddr, flags, page_store.fInternalStore.fPte, page_store.fInternalStore.fPde);
}
const auto cPmlEntrySize = 8;
@@ -114,15 +118,19 @@ namespace Kernel::HAL
UInt64 pt_entry = (pt_base + pt_index * cPmlEntrySize);
// Lastly, grab the pte entry.
- ZKA_PDE* pte_struct = reinterpret_cast<ZKA_PDE*>(pt_base);
+ ZKA_PDE* pde_struct = reinterpret_cast<ZKA_PDE*>(pt_base);
- return mmi_map_page_table_entry(virtual_address, flags, pte_struct->fEntries[pt_entry]);
+ return mmi_map_page_table_entry(virtual_address, flags, pde_struct->fEntries[pt_entry], pde_struct);
}
+ /***********************************************************************************/
/// @brief Maps flags for a specific pte.
/// @internal Internal function.
- STATIC Int32 mmi_map_page_table_entry(VoidPtr virtual_address, UInt32 flags, PTE* pt_entry)
+ /***********************************************************************************/
+ STATIC Int32 mmi_map_page_table_entry(VoidPtr virtual_address, UInt32 flags, ZKA_PTE* pt_entry, ZKA_PDE* pd_entry)
{
+ if (!pt_entry) return -1;
+
pt_entry->Present = true;
if (flags & kMMFlagsWr)
@@ -148,7 +156,7 @@ namespace Kernel::HAL
// Update Internal store.
- page_store.fInternalStore.fPde = nullptr;
+ page_store.fInternalStore.fPde = pd_entry;
page_store.fInternalStore.fPte = pt_entry;
page_store.fInternalStore.fVAddr = virtual_address;
diff --git a/dev/ZKAKit/HALKit/ARM64/HalKernelMain.cc b/dev/ZKAKit/HALKit/ARM64/HalKernelMain.cc
index 6039791e..81e14bf6 100644
--- a/dev/ZKAKit/HALKit/ARM64/HalKernelMain.cc
+++ b/dev/ZKAKit/HALKit/ARM64/HalKernelMain.cc
@@ -46,7 +46,5 @@ EXTERN_C void hal_init_platform(
Kernel::NeFileSystemMgr::Mount(new Kernel::NeFileSystemMgr());
-
-
while (Yes);
}
diff --git a/dev/ZKAKit/HALKit/ARM64/HalPagingMgr.cc b/dev/ZKAKit/HALKit/ARM64/HalPagingMgrARM64.cc
index 5b262cf9..5b262cf9 100644
--- a/dev/ZKAKit/HALKit/ARM64/HalPagingMgr.cc
+++ b/dev/ZKAKit/HALKit/ARM64/HalPagingMgrARM64.cc