diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-01-02 21:10:13 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-01-02 21:10:13 +0100 |
| commit | cbfa3f14674713910077f024958d96fd31b4f36f (patch) | |
| tree | 23a603a8ac25b8d7ff1305f80087222a9233aee2 /dev/Kernel/HALKit | |
| parent | e154cbf9a2a9eedd4c122d6619f25d29e04610ef (diff) | |
FIX: Fix scheduler for the task switch, separate desktop and mobile
targets.
- Giving priority to aarch64 support.
- The scheduler needed those fixes before proceeding to aarch64
support.
- We use the register approach, which is correct here, the
platform code will just take those records and execute them.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/HALKit')
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc | 18 | ||||
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc | 9 | ||||
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm | 54 | ||||
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/HalKernelMain.cc | 19 | ||||
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/HalKernelPanic.cc | 3 |
5 files changed, 30 insertions, 73 deletions
diff --git a/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc b/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc index 32be8dee..ca3f2353 100644 --- a/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc +++ b/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc @@ -17,9 +17,6 @@ EXTERN_C void idt_handle_gpf(Kernel::UIntPtr rsp) { auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); - if (!process) - Kernel::ke_panic(RUNTIME_CHECK_PAGE); - if (process.Leak().Status != Kernel::ProcessStatusKind::kRunning) return; @@ -44,9 +41,6 @@ EXTERN_C void idt_handle_pf(Kernel::UIntPtr rsp) { auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); - if (!process) - Kernel::ke_panic(RUNTIME_CHECK_PAGE); - if (process.Leak().Status != Kernel::ProcessStatusKind::kRunning) return; @@ -96,9 +90,6 @@ EXTERN_C void idt_handle_math(Kernel::UIntPtr rsp) { auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); - if (!process) - Kernel::ke_panic(RUNTIME_CHECK_PAGE); - if (process.Leak().Status != Kernel::ProcessStatusKind::kRunning) return; @@ -125,9 +116,6 @@ EXTERN_C void idt_handle_generic(Kernel::UIntPtr rsp) { auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); - if (!process) - Kernel::ke_panic(RUNTIME_CHECK_PAGE); - if (process.Leak().Status != Kernel::ProcessStatusKind::kRunning) return; @@ -152,9 +140,6 @@ EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip) { auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); - if (!process) - Kernel::ke_panic(RUNTIME_CHECK_PAGE); - if (process.Leak().Status != Kernel::ProcessStatusKind::kRunning) return; @@ -179,9 +164,6 @@ EXTERN_C void idt_handle_ud(Kernel::UIntPtr rsp) { auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); - if (!process) - Kernel::ke_panic(RUNTIME_CHECK_PAGE); - if (process.Leak().Status != Kernel::ProcessStatusKind::kRunning) return; diff --git a/dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc b/dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc index c8556ddc..298dfe06 100644 --- a/dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc +++ b/dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc @@ -146,7 +146,7 @@ namespace Kernel::HAL return kProcessBlocks[process_index].f_Frame; } - EXTERN_C Bool mp_register_process(VoidPtr image, UInt8* stack_ptr, HAL::StackFramePtr stack_frame, ProcessID pid) + EXTERN_C BOOL mp_register_process(VoidPtr image, UInt8* stack_ptr, HAL::StackFramePtr stack_frame, ProcessID pid) { MUST_PASS(image && stack_ptr && stack_frame); @@ -156,12 +156,7 @@ namespace Kernel::HAL kProcessBlocks[process_index].f_Stack = stack_ptr; kProcessBlocks[process_index].f_Image = image; - if (!mp_is_smp()) - { - /// TODO: Switch from process_index in hash list. - } - - return Yes; + return NO; } /***********************************************************************************/ diff --git a/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm b/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm index fbc7cda8..02031c4c 100644 --- a/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm +++ b/dev/Kernel/HALKit/AMD64/HalInterruptAPI.asm @@ -11,7 +11,7 @@ [bits 64] -%define kInterruptId 0x21 +%define kInterruptId 50 %macro IntExp 1 global __ZKA_INT_%1 @@ -26,9 +26,8 @@ __ZKA_INT_%1: call idt_handle_generic pop rcx - - std + o64 iret %endmacro @@ -42,6 +41,7 @@ __ZKA_INT_%1: out 0x20, al std + o64 iret %endmacro @@ -67,6 +67,7 @@ __ZKA_INT_0: out 0x20, al std + o64 iret __ZKA_INT_1: @@ -79,9 +80,8 @@ __ZKA_INT_1: call idt_handle_generic pop rcx - - std + o64 iret __ZKA_INT_2: @@ -94,9 +94,8 @@ __ZKA_INT_2: call idt_handle_generic pop rcx - - std + o64 iret ;; @brief Triggers a breakpoint and freeze the process. RIP is also fetched. @@ -110,9 +109,8 @@ __ZKA_INT_3: call idt_handle_generic pop rcx - - std + o64 iret __ZKA_INT_4: @@ -126,10 +124,8 @@ __ZKA_INT_4: call idt_handle_generic pop rcx - - - std + o64 iret __ZKA_INT_5: @@ -138,9 +134,8 @@ __ZKA_INT_5: mov al, 0x20 out 0x20, al - - std + o64 iret ;; Invalid opcode interrupt @@ -154,9 +149,8 @@ __ZKA_INT_6: call idt_handle_generic pop rcx - - std + o64 iret __ZKA_INT_7: @@ -169,9 +163,8 @@ __ZKA_INT_7: call idt_handle_generic pop rcx - - std + o64 iret ;; Invalid opcode interrupt @@ -187,6 +180,7 @@ __ZKA_INT_8: pop rcx std + o64 iret IntNormal 9 @@ -206,9 +200,8 @@ __ZKA_INT_13: call idt_handle_gpf pop rcx - add qword [rsp + 4], 2 - std + o64 iret __ZKA_INT_14: @@ -222,9 +215,8 @@ __ZKA_INT_14: call idt_handle_pf pop rcx - add qword [rsp + 4], 2 - std + o64 iret IntNormal 15 @@ -262,6 +254,7 @@ __ZKA_INT_32: pop rax std + o64 iret IntNormal 33 @@ -371,23 +364,6 @@ extern hal_real_init hal_reload_segments: std - ;; Write address of syscall handler. - mov rdx, [mp_system_call_handler] - shr rdx, 32 - mov rcx, 0xC0000082 - wrmsr - - ;; Set segments of syscall handler. - - xor rax, rax - mov rdx, 0x230008 - mov rcx, 0xC0000081 - wrmsr - - mov ecx, 0xC0000080 - rdmsr - or eax, 1 - wrmsr jmp hal_real_init ret diff --git a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc index 25bb1de3..e5449649 100644 --- a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc @@ -70,10 +70,10 @@ EXTERN_C void hal_init_platform( /* GDT, mostly descriptors for user and kernel segments. */ STATIC Kernel::HAL::Detail::ZKA_GDT_ENTRY ALIGN(0x08) kGDTArray[kGDTEntriesCount] = { {.fLimitLow = 0, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x00, .fFlags = 0x00, .fBaseHigh = 0}, // Null entry - {.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x9A, .fFlags = 0xAF, .fBaseHigh = 0}, // Kernel code - {.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x92, .fFlags = 0xCF, .fBaseHigh = 0}, // Kernel data - {.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0xF2, .fFlags = 0xCF, .fBaseHigh = 0}, // User data - {.fLimitLow = 0xFFFF, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0xFA, .fFlags = 0xAF, .fBaseHigh = 0}, // User code + {.fLimitLow = 0x0, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x9A, .fFlags = 0xAF, .fBaseHigh = 0}, // Kernel code + {.fLimitLow = 0x0, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0x92, .fFlags = 0xCF, .fBaseHigh = 0}, // Kernel data + {.fLimitLow = 0x0, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0xFA, .fFlags = 0xAF, .fBaseHigh = 0}, // User code + {.fLimitLow = 0x0, .fBaseLow = 0, .fBaseMid = 0, .fAccessByte = 0xF2, .fFlags = 0xCF, .fBaseHigh = 0}, // User data }; // Load memory descriptors. @@ -91,9 +91,16 @@ EXTERN_C void hal_init_platform( EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept { - auto str_proc = Kernel::rt_alloc_string("System"); + //rtl_kernel_main(0, nullptr, nullptr, 0); - auto pid = Kernel::rtl_create_process(rtl_kernel_main, str_proc); + auto str_proc = Kernel::rt_alloc_string("User Program"); + + auto pid = Kernel::rtl_create_process([](const Kernel::SizeT argc, Kernel::Char** argv, Kernel::Char** envp, const Kernel::SizeT envp_len) -> void { + while (YES) + { + kcout << "what\r"; + } + }, str_proc); Kernel::UserProcessScheduler::The().CurrentTeam().AsArray()[pid].PTime = 0; Kernel::UserProcessScheduler::The().CurrentTeam().AsArray()[pid].Status = Kernel::ProcessStatusKind::kRunning; diff --git a/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc b/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc index ac41f7fa..6f8b292a 100644 --- a/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc +++ b/dev/Kernel/HALKit/AMD64/HalKernelPanic.cc @@ -62,9 +62,6 @@ namespace Kernel fb_render_string(message_cr2, y, x, panic_text); - kcout << message_apicid; - kcout << message_cr2; - y += 10; fb_clear(); |
