summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx4
-rw-r--r--dev/ZKA/HALKit/AMD64/HalKernelMain.cxx26
-rw-r--r--dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm2
-rw-r--r--dev/ZKA/HALKit/AMD64/Processor.hxx12
-rw-r--r--dev/ZKA/Sources/DLLMain.cxx26
5 files changed, 22 insertions, 48 deletions
diff --git a/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx b/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx
index 11f9f249..2e61b249 100644
--- a/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalDescriptorLoader.cxx
@@ -41,8 +41,6 @@ namespace Kernel::HAL
/// @return
Void GDTLoader::Load(RegisterGDT& gdt)
{
- MUST_PASS(gdt.Base != 0);
-
Detail::kRegGdt.Base = gdt.Base;
Detail::kRegGdt.Limit = gdt.Limit;
@@ -53,8 +51,6 @@ namespace Kernel::HAL
{
volatile ::Kernel::UIntPtr** baseIdt = (volatile ::Kernel::UIntPtr**)idt.Base;
- MUST_PASS(baseIdt);
-
for (UInt16 i = 0; i < kKernelIdtSize; ++i)
{
MUST_PASS(baseIdt[i]);
diff --git a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
index 12926ee8..820dea97 100644
--- a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
@@ -61,14 +61,18 @@ namespace Kernel::HAL
EXTERN void mp_get_cores(Kernel::voidPtr rsdPtr) noexcept;
} // namespace Kernel::HAL
-/* GDT. */
-STATIC Kernel::HAL::Detail::ZKA_GDT cGdt = {
- .fKernNull = { .fLimit0 = 0, .fBase0 = 0, .fBase1 = 0, .fAccessByte = 0x00, .fLimit1_Flags = 0x00, .fBase2 = 0}, // Null entry
- .fKernCode = { .fLimit0 = 0, .fBase0 = 0, .fBase1 = 00, .fAccessByte = 0x9A, .fLimit1_Flags = 0xA0, .fBase2 = 0}, // Kernel code
- .fKernData = { .fLimit0 = 0, .fBase0 = 0, .fBase1 = 00, .fAccessByte = 0x92, .fLimit1_Flags = 0xA0, .fBase2 = 0}, // Kernel data
- .fUserNull = { .fLimit0 = 0, .fBase0 = 0, .fBase1 = 00, .fAccessByte = 0x00, .fLimit1_Flags = 0x00, .fBase2 = 0}, // Null entry
- .fUserCode = { .fLimit0 = 0, .fBase0 = 0, .fBase1 = 00, .fAccessByte = 0xCF, .fLimit1_Flags = 0xA0, .fBase2 = 0}, // User code
- .fUserData = { .fLimit0 = 0, .fBase0 = 0, .fBase1 = 00, .fAccessByte = 0x92, .fLimit1_Flags = 0xA0, .fBase2 = 0}, // User data
+/* GDT, mostly descriptors for user and kernel segments. */
+STATIC Kernel::HAL::Detail::ZKA_GDT_ENTRY cGdt[9] = {
+ {.fLimit0 = 0, .fBase0 = 0, .fBase1 = 0, .fAccessByte = 0x00, .fGranularity = 0x00, .fBase2 = 0}, // Null entry
+ {.fLimit0 = 0xFFFF, .fBase0 = 0, .fBase1 = 00, .fAccessByte = 0x9A, .fGranularity = 0xA0, .fBase2 = 0}, // Kernel code
+ {.fLimit0 = 0xFFFF, .fBase0 = 0, .fBase1 = 00, .fAccessByte = 0x92, .fGranularity = 0xA0, .fBase2 = 0}, // Kernel data
+ {.fLimit0 = 0xFFFF, .fBase0 = 0, .fBase1 = 00, .fAccessByte = 0xFA, .fGranularity = 0xA0, .fBase2 = 0}, // User code
+ {.fLimit0 = 0xFFFF, .fBase0 = 0, .fBase1 = 00, .fAccessByte = 0xF2, .fGranularity = 0xA0, .fBase2 = 0}, // User data
+ // reserve them for later.
+ {.fLimit0 = 0, .fBase0 = 0, .fBase1 = 0, .fAccessByte = 0x00, .fGranularity = 0x00, .fBase2 = 0}, // Null entry
+ {.fLimit0 = 0, .fBase0 = 0, .fBase1 = 0, .fAccessByte = 0x00, .fGranularity = 0x00, .fBase2 = 0},
+ {.fLimit0 = 0, .fBase0 = 0, .fBase1 = 0, .fAccessByte = 0x00, .fGranularity = 0x00, .fBase2 = 0},
+ {.fLimit0 = 0, .fBase0 = 0, .fBase1 = 0, .fAccessByte = 0x00, .fGranularity = 0x00, .fBase2 = 0},
};
Kernel::Void hal_real_init(Kernel::Void) noexcept;
@@ -81,6 +85,8 @@ EXTERN_C void hal_init_platform(
{
/* Setup globals. */
+ sizeof(Kernel::HAL::Detail::ZKA_GDT_ENTRY);
+
kHandoverHeader = HandoverHeader;
if (kHandoverHeader->f_Magic != kHandoverMagic &&
@@ -113,8 +119,8 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept
// Load memory descriptors.
Kernel::HAL::RegisterGDT gdtBase;
- gdtBase.Base = reinterpret_cast<Kernel::UIntPtr>(&cGdt);
- gdtBase.Limit = sizeof(Kernel::HAL::Detail::ZKA_GDT) - 1;
+ gdtBase.Base = reinterpret_cast<Kernel::UIntPtr>(cGdt);
+ gdtBase.Limit = (sizeof(Kernel::HAL::Detail::ZKA_GDT_ENTRY) * 9);
CONST Kernel::HAL::GDTLoader cGDT;
cGDT.Load(gdtBase);
diff --git a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
index 9ef3122c..b9892d74 100644
--- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
+++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
@@ -22,7 +22,6 @@ section .text
;; rdx: stack ptr.
mp_do_context_switch:
mov r11, 0x0202
- mov rsp, rdx
o64 sysret
;; @brief Gets the current stack frame.
@@ -41,7 +40,6 @@ mp_do_context_switch_pre:
mov rcx, 0xc0000081
rdmsr
mov edx, 0x00180008
-
wrmsr
ret \ No newline at end of file
diff --git a/dev/ZKA/HALKit/AMD64/Processor.hxx b/dev/ZKA/HALKit/AMD64/Processor.hxx
index bb41de54..dba5c625 100644
--- a/dev/ZKA/HALKit/AMD64/Processor.hxx
+++ b/dev/ZKA/HALKit/AMD64/Processor.hxx
@@ -247,19 +247,9 @@ namespace Kernel::HAL
UInt16 fBase0;
UInt8 fBase1;
UInt8 fAccessByte;
- UInt8 fLimit1_Flags;
+ UInt8 fGranularity;
UInt8 fBase2;
};
-
- struct PACKED ALIGN(0x1000) ZKA_GDT final
- {
- ZKA_GDT_ENTRY fKernNull;
- ZKA_GDT_ENTRY fKernCode;
- ZKA_GDT_ENTRY fKernData;
- ZKA_GDT_ENTRY fUserNull;
- ZKA_GDT_ENTRY fUserCode;
- ZKA_GDT_ENTRY fUserData;
- };
} // namespace Detail
class APICController
diff --git a/dev/ZKA/Sources/DLLMain.cxx b/dev/ZKA/Sources/DLLMain.cxx
index 514834d0..6684ed69 100644
--- a/dev/ZKA/Sources/DLLMain.cxx
+++ b/dev/ZKA/Sources/DLLMain.cxx
@@ -192,28 +192,12 @@ EXTERN_C Kernel::Void ke_dll_entrypoint(Kernel::Void)
CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.dll: Starting ZKA System...", 30, 10, RGB(0, 0, 0));
- Kernel::PEFLoader sys_user_drv(kSysDrv);
-
- if (sys_user_drv.IsLoaded())
- {
- auto err_start = sys_user_drv.FindStart();
+ auto main_logger = []() -> void {
+ /// TODO: Write code which calls the login process.
+ while (Yes);
+ };
- if (!err_start.Error())
- {
- auto start = err_start.Leak().Leak();
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.dll: System component successfully loaded...", 20, 10, RGB(0, 0, 0));
- }
- else
- {
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.dll: Missing entrypoint symbol: ", 20, 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, kPefStart, 20, 10 + (FONT_SIZE_X * Kernel::rt_string_len("newoskrnl.dll: Missing entrypoint symbol: ")), RGB(0, 0, 0));
- }
- }
- else
- {
- CG::CGDrawStringToWnd(cKernelWnd, "newoskrnl.dll: Missing catalog: ", 20, 10, RGB(0, 0, 0));
- CG::CGDrawStringToWnd(cKernelWnd, kSysDrv, 20, 10 + (FONT_SIZE_X * Kernel::rt_string_len("newoskrnl.dll: Missing catalog: ")), RGB(0, 0, 0));
- }
+ Kernel::sched_execute_thread(main_logger, "ZKA Init Thread");
Kernel::ProcessHelper::StartScheduling();
Kernel::ke_stop(RUNTIME_CHECK_BOOTSTRAP);