diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-02 19:38:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-02 19:38:46 +0200 |
| commit | 997be16e5ac9a68d54882ab69529815860d62955 (patch) | |
| tree | 19d6129c2d776bb1edc5d4a7325e39ca176c3403 /dev/kernel/HALKit/ARM64/HalKernelMain.cc | |
| parent | 618104e74c195d7508a18450524f8ed7f9af8cc6 (diff) | |
| parent | b3b4b1ebdcd6adeac914869017c86d892b7a8ced (diff) | |
Merge pull request #28 from nekernel-org/dev
0.0.2
Diffstat (limited to 'dev/kernel/HALKit/ARM64/HalKernelMain.cc')
| -rw-r--r-- | dev/kernel/HALKit/ARM64/HalKernelMain.cc | 75 |
1 files changed, 46 insertions, 29 deletions
diff --git a/dev/kernel/HALKit/ARM64/HalKernelMain.cc b/dev/kernel/HALKit/ARM64/HalKernelMain.cc index d9f3eb85..3e6701ea 100644 --- a/dev/kernel/HALKit/ARM64/HalKernelMain.cc +++ b/dev/kernel/HALKit/ARM64/HalKernelMain.cc @@ -1,54 +1,71 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ #include <ArchKit/ArchKit.h> -#include <modules/CoreGfx/CoreGfx.h> +#include <CFKit/Property.h> #include <FirmwareKit/Handover.h> +#include <HALKit/ARM64/Processor.h> +#include <KernelKit/CodeMgr.h> #include <KernelKit/FileMgr.h> #include <KernelKit/MemoryMgr.h> #include <KernelKit/PEFCodeMgr.h> #include <KernelKit/ProcessScheduler.h> +#include <NetworkKit/IPC.h> #include <NewKit/Json.h> -#include <KernelKit/CodeMgr.h> #include <modules/ACPI/ACPIFactoryInterface.h> -#include <NetworkKit/IPC.h> -#include <HALKit/ARM64/Processor.h> -#include <CFKit/Property.h> +#include <modules/CoreGfx/CoreGfx.h> #include <HALKit/ARM64/ApplicationProcessor.h> -EXTERN_C void hal_init_platform( - Kernel::HEL::BootInfoHeader* handover_hdr) -{ +EXTERN_C void hal_init_platform(Kernel::HEL::BootInfoHeader* handover_hdr) { + /************************************************** */ + /* INITIALIZE AND VALIDATE HEADER. */ + /************************************************** */ + + kHandoverHeader = handover_hdr; + + if (kHandoverHeader->f_Magic != kHandoverMagic && + kHandoverHeader->f_Version != kHandoverVersion) { + return; + } + + /************************************** */ + /* INITIALIZE BIT MAP. */ + /************************************** */ + + kKernelBitMpSize = kHandoverHeader->f_BitMapSize; + kKernelBitMpStart = reinterpret_cast<Kernel::VoidPtr>( + reinterpret_cast<Kernel::UIntPtr>(kHandoverHeader->f_BitMapStart)); + + /// @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. - /************************************************** */ - /* INITIALIZE AND VALIDATE HEADER. */ - /************************************************** */ + auto constexpr kSchedTeamSwitchMS = 5U; /// @brief Team switch time in milliseconds. - kHandoverHeader = handover_hdr; + Kernel::HardwareTimer timer(rtl_milliseconds(kSchedTeamSwitchMS)); - if (kHandoverHeader->f_Magic != kHandoverMagic && - kHandoverHeader->f_Version != kHandoverVersion) - { - return; - } + STATIC Kernel::Array<UserProcessTeam, kSchedTeamCount> kTeams; - /************************************** */ - /* INITIALIZE BIT MAP. */ - /************************************** */ + SizeT team_index = 0U; - kKernelBitMpSize = kHandoverHeader->f_BitMapSize; - kKernelBitMpStart = reinterpret_cast<Kernel::VoidPtr>( - reinterpret_cast<Kernel::UIntPtr>(kHandoverHeader->f_BitMapStart)); + /// @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; + } - /// @note do initialize the interrupts after it. + while (!UserProcessScheduler::The().SwitchTeam(kTeams[team_index])); - Kernel::mp_initialize_gic(); + timer.Wait(); - while (YES) - { - } + ++team_index; + } } |
