summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-03 22:37:17 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-03 22:37:17 +0200
commitcc9ce57cac59bd443e2319e3b8f427172b93f7da (patch)
tree524ac4109ba00c887765f243e07e3d8c25cddffa
parent2a20797f83b5184cd569bacefbe68efb731a1135 (diff)
[ KERNEL ] REFACTORINGS AND IMPROVEMENTS OVER KERNEL AND DRIVERS.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
-rw-r--r--dev/ZBA/Modules/SysChk/Boot.S7
-rw-r--r--dev/ZBA/Modules/SysChk/Module.cxx8
-rw-r--r--dev/ZBA/Modules/SysChk/build.json2
-rw-r--r--dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx2
-rw-r--r--dev/ZKA/HALKit/AMD64/HalKernelMain.cxx20
-rw-r--r--dev/ZKA/HALKit/AMD64/HalProcessor.cxx8
-rw-r--r--dev/ZKA/HALKit/AMD64/HalSchedulerCore.cxx3
-rw-r--r--dev/ZKA/HALKit/AMD64/Processor.hxx2
-rw-r--r--dev/ZKA/NewKit/Defines.hxx4
-rw-r--r--dev/ZKA/Sources/MP.cxx7
-rw-r--r--dev/ZKA/Sources/PEFCodeManager.cxx6
11 files changed, 21 insertions, 48 deletions
diff --git a/dev/ZBA/Modules/SysChk/Boot.S b/dev/ZBA/Modules/SysChk/Boot.S
index ce9f36b1..a8622ae3 100644
--- a/dev/ZBA/Modules/SysChk/Boot.S
+++ b/dev/ZBA/Modules/SysChk/Boot.S
@@ -19,10 +19,3 @@
.quad kHandoverMagic
.word kTypeDriver
-.text
-
-.extern main
-.global __main
-
-__main:
- ret
diff --git a/dev/ZBA/Modules/SysChk/Module.cxx b/dev/ZBA/Modules/SysChk/Module.cxx
index fa564324..9bc3425c 100644
--- a/dev/ZBA/Modules/SysChk/Module.cxx
+++ b/dev/ZBA/Modules/SysChk/Module.cxx
@@ -9,12 +9,14 @@
#include <BootKit/BootKit.hxx>
-EXTERN_C Int32 main(Kernel::HEL::HandoverInformationHeader* Handover)
+EXTERN_C Int32 ModuleMain(Kernel::HEL::HandoverInformationHeader* Handover)
{
EfiSystemTable* cST = (EfiSystemTable*)Handover->f_FirmwareCustomTables[1];
+
cST->ConOut->ClearScreen(cST->ConOut);
- cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: CHECKING FOR VALID NEWFS OR EXT4 PARTITIONS...\r");
- cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: WE ARE GOOD TO GO!\r");
+
+ cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: CHECKING FOR VALID NEWFS OR EXT4 PARTITIONS...\r\n");
+ cST->ConOut->OutputString(cST->ConOut, L"SYSCHK: GOOD TO GO!\r\n");
return kEfiOk;
}
diff --git a/dev/ZBA/Modules/SysChk/build.json b/dev/ZBA/Modules/SysChk/build.json
index b2071a2e..67e22955 100644
--- a/dev/ZBA/Modules/SysChk/build.json
+++ b/dev/ZBA/Modules/SysChk/build.json
@@ -11,7 +11,7 @@
"-fPIC",
"-fno-rtti",
"-fno-exceptions",
- "-Wl,--subsystem=17,--image-base,0x10000000"
+ "-Wl,--subsystem=17,--image-base,0x10000000,-e,ModuleMain"
],
"cpp_macros": [
"__NEWOSKRNL__",
diff --git a/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx b/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx
index 9a0914f8..4474295f 100644
--- a/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx
@@ -64,7 +64,7 @@ namespace Kernel::HAL
{
MUST_PASS(ptr_ivt[idt_indx]);
- Detail::kInterruptVectorTable[idt_indx].Selector = (idt_indx == kSyscallRoute) ? kGdtUserCodeSelector : kGdtKernelCodeSelector;
+ Detail::kInterruptVectorTable[idt_indx].Selector = kGdtKernelCodeSelector;
Detail::kInterruptVectorTable[idt_indx].Ist = 0;
Detail::kInterruptVectorTable[idt_indx].TypeAttributes = kInterruptGate;
Detail::kInterruptVectorTable[idt_indx].OffsetLow = ((UIntPtr)ptr_ivt[idt_indx] & __INT16_MAX__);
diff --git a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
index 2cdeb7f0..34398871 100644
--- a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
@@ -64,26 +64,6 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept;
EXTERN_C void hal_user_code_start(void);
EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void);
-/* @brief TSS */
-
-Kernel::HAL::Detail::ZKA_TSS cTSS = {
- .fReserved1 = 0x0,
- .fRsp0 = 0x0,
- .fRsp1 = 0x0,
- .fRsp2 = 0x0,
- .fReserved2 = 0x0,
- .fIst1 = 0x0,
- .fIst2 = 0x0,
- .fIst3 = 0x0,
- .fIst4 = 0x0,
- .fIst5 = 0x0,
- .fIst6 = 0x0,
- .fIst7 = 0x0,
- .fReserved3 = 0x0,
- .fReserved4 = 0x0,
- .fIopb = 0x0,
-};
-
/* GDT, mostly descriptors for user and kernel segments. */
STATIC Kernel::HAL::Detail::ZKA_GDT_ENTRY cGdt[6] = {
{.fLimitLow = 0, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x00, .fFlags = 0x00, .fBaseHigh = 0}, // Null entry
diff --git a/dev/ZKA/HALKit/AMD64/HalProcessor.cxx b/dev/ZKA/HALKit/AMD64/HalProcessor.cxx
index 169c02f5..407b7e51 100644
--- a/dev/ZKA/HALKit/AMD64/HalProcessor.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalProcessor.cxx
@@ -26,17 +26,17 @@ namespace Kernel::HAL
UIntPtr pte_idx = ((UIntPtr)virt_addr >> 12) & 0x1FFF;
// Access PML4 entry
- volatile UInt64* pml4_entry = (volatile UInt64*)(pml4_base + pml4_idx * sizeof(UIntPtr));
+ volatile UInt64* pml4_entry = (volatile UInt64*)(((UInt64)pml4_base) + pml4_idx * sizeof(UIntPtr));
UInt64 pdpt_base = *pml4_entry & ~0xFFF; // Remove flags (assuming 4KB pages)
// Access PDPT entry
- volatile UInt64* pdpt_entry = (volatile UInt64*)(pdpt_base + pdpt_idx * sizeof(UIntPtr));
+ volatile UInt64* pdpt_entry = (volatile UInt64*)(((UInt64)pdpt_base) + pdpt_idx * sizeof(UIntPtr));
UInt64 pd_base = *pdpt_entry & ~0xFFF; // Remove flags
- volatile UInt64* pd_entry = (volatile UInt64*)(pd_base + pd_idx * sizeof(UIntPtr));
+ volatile UInt64* pd_entry = (volatile UInt64*)(((UInt64)pd_base) + pd_idx * sizeof(UIntPtr));
UInt64 pt_base = *pd_entry & ~0xFFF; // Remove flags
- volatile UInt64* page_addr = (volatile UInt64*)((UIntPtr)pt_base + (pte_idx * sizeof(UIntPtr)));
+ volatile UInt64* page_addr = (volatile UInt64*)(((UInt64)pt_base) + (pte_idx * sizeof(UIntPtr)));
if (page_addr)
{
diff --git a/dev/ZKA/HALKit/AMD64/HalSchedulerCore.cxx b/dev/ZKA/HALKit/AMD64/HalSchedulerCore.cxx
index bf98d01d..cef5d368 100644
--- a/dev/ZKA/HALKit/AMD64/HalSchedulerCore.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalSchedulerCore.cxx
@@ -14,7 +14,8 @@ Void UserProcess::SetImageStart(VoidPtr imageStart) noexcept
if (imageStart == nullptr)
this->Crash();
- HAL::mm_update_pte(imageStart, HAL::eFlagsPresent | HAL::eFlagsUser);
+ HAL::mm_update_pte(imageStart, HAL::eFlagsPresent);
+ HAL::mm_update_pte(imageStart, HAL::eFlagsUser);
this->Image = imageStart;
}
diff --git a/dev/ZKA/HALKit/AMD64/Processor.hxx b/dev/ZKA/HALKit/AMD64/Processor.hxx
index 0f24a2be..a80e13cb 100644
--- a/dev/ZKA/HALKit/AMD64/Processor.hxx
+++ b/dev/ZKA/HALKit/AMD64/Processor.hxx
@@ -24,8 +24,6 @@ EXTERN_C
#include <cpuid.h>
}
-#define kSyscallRoute (0x29)
-
#define IsActiveLow(FLG) (FLG & 2)
#define IsLevelTriggered(FLG) (FLG & 8)
diff --git a/dev/ZKA/NewKit/Defines.hxx b/dev/ZKA/NewKit/Defines.hxx
index 0be72aaf..77d400df 100644
--- a/dev/ZKA/NewKit/Defines.hxx
+++ b/dev/ZKA/NewKit/Defines.hxx
@@ -67,8 +67,8 @@ namespace Kernel
using WideChar = wchar_t;
using Utf32Char = char32_t;
- typedef UInt64 PhysicalAddress;
- typedef UInt64 VirtualAddress;
+ typedef UInt32 PhysicalAddressKind;
+ typedef UIntPtr VirtualAddressKind;
using Void = void;
diff --git a/dev/ZKA/Sources/MP.cxx b/dev/ZKA/Sources/MP.cxx
index fcf555cb..b3b62609 100644
--- a/dev/ZKA/Sources/MP.cxx
+++ b/dev/ZKA/Sources/MP.cxx
@@ -15,10 +15,6 @@
///! @brief This file handles multi processing in the Kernel.
///! @brief Multi processing is needed for multi-tasking operations.
-#ifdef __ZKA_AMD64__
-EXTERN Kernel::HAL::Detail::ZKA_TSS cTSS;
-#endif // ifdef __ZKA_AMD64__
-
namespace Kernel
{
/***********************************************************************************/
@@ -104,9 +100,6 @@ namespace Kernel
if (kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled)
{
-#ifdef __ZKA_AMD64__
- cTSS.fRsp0 = (UIntPtr)stack_ptr;
-#endif // ifdef __ZKA_AMD64__
return mp_register_process(fStack);
}
diff --git a/dev/ZKA/Sources/PEFCodeManager.cxx b/dev/ZKA/Sources/PEFCodeManager.cxx
index a797fd50..526312e0 100644
--- a/dev/ZKA/Sources/PEFCodeManager.cxx
+++ b/dev/ZKA/Sources/PEFCodeManager.cxx
@@ -164,6 +164,12 @@ namespace Kernel
Char* blobRet = new Char[container_header->Size];
+ HAL::mm_update_pte(blobRet, HAL::eFlagsPresent);
+ HAL::mm_update_pte(blobRet, HAL::eFlagsUser);
+
+ if (container_header->Kind != kPefCode)
+ HAL::mm_update_pte(blobRet, HAL::eFlagsRw);
+
rt_copy_memory((VoidPtr)((Char*)blob + sizeof(PEFCommandHeader)), blobRet, container_header->Size);
mm_delete_ke_heap(blob);