From a9653add416fbddc1969a75adb733bc9e9c675d6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 19 May 2025 10:24:52 +0200 Subject: feat(kernel, sched): Architectural improvements, and cleaned up the codebase from previous implementations that didn't work/scale well. Signed-off-by: Amlal El Mahrouss --- dev/kernel/HALKit/ARM64/HalKernelMain.cc | 55 +++++++++++++++++--------------- 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'dev/kernel/HALKit/ARM64/HalKernelMain.cc') diff --git a/dev/kernel/HALKit/ARM64/HalKernelMain.cc b/dev/kernel/HALKit/ARM64/HalKernelMain.cc index bf5849ef..c92b12cd 100644 --- a/dev/kernel/HALKit/ARM64/HalKernelMain.cc +++ b/dev/kernel/HALKit/ARM64/HalKernelMain.cc @@ -7,9 +7,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -18,9 +20,10 @@ #include #include -#include - +#ifndef __NE_MODULAR_KERNEL_COMPONENTS__ EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { + using namespace Kernel; + /************************************************** */ /* INITIALIZE AND VALIDATE HEADER. */ /************************************************** */ @@ -32,6 +35,15 @@ EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { return; } + FB::fb_clear_video(); + +#ifdef __NE_ARM64_EFI__ + fw_init_efi((EfiSystemTable*) handover_hdr->f_FirmwareCustomTables[1]); + + Boot::ExitBootServices(handover_hdr->f_HardwareTables.f_ImageKey, + handover_hdr->f_HardwareTables.f_ImageHandle); +#endif + /************************************** */ /* INITIALIZE BIT MAP. */ /************************************** */ @@ -42,31 +54,24 @@ EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { /// @note do initialize the interrupts after it. - Kernel::mp_initialize_gic(); - - /// after the scheduler runs, we must look over teams, every 5000s in order to schedule every - /// process according to their affinity fairly. - - auto constexpr kSchedTeamSwitchMS = 5U; /// @brief Team switch time in milliseconds. - - Kernel::HardwareTimer timer(rtl_milliseconds(kSchedTeamSwitchMS)); - - STATIC Kernel::Array kTeams; - - SizeT team_index = 0U; + for (SizeT index = 0UL; index < HardwareThreadScheduler::The().Capacity(); ++index) { + HardwareThreadScheduler::The()[index].Leak()->Kind() = ThreadKind::kAPStandard; + HardwareThreadScheduler::The()[index].Leak()->Busy(NO); + } - /// @brief This just loops over the teams and switches between them. - /// @details Not even round-robin, just a simple loop in this boot core we're at. - while (YES) { - if (team_index > (kSchedTeamCount - 1)) { - team_index = 0U; - } + for (SizeT index = 0UL; index < UserProcessScheduler::The().TheCurrentTeam().AsArray().Count(); + ++index) { + UserProcessScheduler::The().TheCurrentTeam().AsArray()[index].Status = + ProcessStatusKind::kInvalid; + } - while (!UserProcessScheduler::The().SwitchTeam(kTeams[team_index])) - ; + rtl_create_user_process(sched_idle_task, "MgmtSrv"); //! Mgmt command server. + rtl_create_user_process(sched_idle_task, "LaunchSrv"); //! launchd + rtl_create_user_process(sched_idle_task, "SecSrv"); //! Login Server - timer.Wait(); + Kernel::mp_init_cores(); - ++team_index; - } + while (YES) + ; } +#endif \ No newline at end of file -- cgit v1.2.3