From 4ed658c633ce5d7c5bde4acdbe322e5f51592369 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 25 Dec 2024 14:04:14 +0100 Subject: IMPL: Important refactors and improvements of ZkaOS. Signed-off-by: Amlal El Mahrouss --- .../HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc | 22 ++++---- dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc | 4 +- dev/Kernel/HALKit/AMD64/HalDebugOutput.cc | 2 +- dev/Kernel/HALKit/AMD64/HalKernelMain.cc | 8 +-- dev/Kernel/HALKit/ARM64/HalKernelMain.cc | 6 +- dev/Kernel/HALKit/ARM64/Storage/.gitkeep | 0 dev/Kernel/HALKit/ARM64/Storage/HalFlash.cc | 66 ---------------------- dev/Kernel/HALKit/ARM64/Storage/HalFlashMemory.cc | 66 ++++++++++++++++++++++ 8 files changed, 87 insertions(+), 87 deletions(-) delete mode 100644 dev/Kernel/HALKit/ARM64/Storage/.gitkeep delete mode 100644 dev/Kernel/HALKit/ARM64/Storage/HalFlash.cc create mode 100644 dev/Kernel/HALKit/ARM64/Storage/HalFlashMemory.cc (limited to 'dev/Kernel/HALKit') diff --git a/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc b/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc index 036593e5..aa1d66d7 100644 --- a/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc +++ b/dev/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc @@ -18,7 +18,7 @@ EXTERN_C void idt_handle_gpf(Kernel::UIntPtr rsp) auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); if (!process) - Kernel::ke_stop(RUNTIME_CHECK_PAGE); + Kernel::ke_panic(RUNTIME_CHECK_PAGE); process.Leak().ProcessSignal.SignalIP = 0UL; process.Leak().ProcessSignal.SignalID = SIGKILL; @@ -30,7 +30,7 @@ EXTERN_C void idt_handle_gpf(Kernel::UIntPtr rsp) process.Leak().Crash(); - Kernel::ke_stop(RUNTIME_CHECK_POINTER); + Kernel::ke_panic(RUNTIME_CHECK_POINTER); } /// @brief Handle page fault. @@ -43,7 +43,7 @@ EXTERN_C void idt_handle_pf(Kernel::UIntPtr rsp) auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); if (!process) - Kernel::ke_stop(RUNTIME_CHECK_PAGE); + Kernel::ke_panic(RUNTIME_CHECK_PAGE); process.Leak().ProcessSignal.SignalIP = 0UL; process.Leak().ProcessSignal.SignalID = SIGKILL; @@ -55,7 +55,7 @@ EXTERN_C void idt_handle_pf(Kernel::UIntPtr rsp) process.Leak().Crash(); - Kernel::ke_stop(RUNTIME_CHECK_PAGE); + Kernel::ke_panic(RUNTIME_CHECK_PAGE); } /// @brief Handle scheduler interrupt. @@ -90,7 +90,7 @@ EXTERN_C void idt_handle_math(Kernel::UIntPtr rsp) auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); if (!process) - Kernel::ke_stop(RUNTIME_CHECK_PAGE); + Kernel::ke_panic(RUNTIME_CHECK_PAGE); process.Leak().ProcessSignal.SignalIP = 0UL; process.Leak().ProcessSignal.SignalID = SIGKILL; @@ -102,7 +102,7 @@ EXTERN_C void idt_handle_math(Kernel::UIntPtr rsp) process.Leak().Crash(); - Kernel::ke_stop(RUNTIME_CHECK_UNEXCPECTED); + Kernel::ke_panic(RUNTIME_CHECK_UNEXCPECTED); } /// @brief Handle any generic fault. @@ -114,7 +114,7 @@ EXTERN_C void idt_handle_generic(Kernel::UIntPtr rsp) auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); if (!process) - Kernel::ke_stop(RUNTIME_CHECK_PAGE); + Kernel::ke_panic(RUNTIME_CHECK_PAGE); process.Leak().ProcessSignal.SignalIP = 0UL; process.Leak().ProcessSignal.SignalID = SIGKILL; @@ -126,7 +126,7 @@ EXTERN_C void idt_handle_generic(Kernel::UIntPtr rsp) process.Leak().Crash(); - Kernel::ke_stop(RUNTIME_CHECK_UNEXCPECTED); + Kernel::ke_panic(RUNTIME_CHECK_UNEXCPECTED); } EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip) @@ -134,7 +134,7 @@ EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip) auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); if (!process) - Kernel::ke_stop(RUNTIME_CHECK_PAGE); + Kernel::ke_panic(RUNTIME_CHECK_PAGE); kcout << "Kernel: Process RIP: " << Kernel::hex_number(rip) << endl; kcout << "Kernel: SIGTRAP set.\r"; @@ -158,7 +158,7 @@ EXTERN_C void idt_handle_ud(Kernel::UIntPtr rsp) auto process = Kernel::UserProcessScheduler::The().GetCurrentProcess(); if (!process) - Kernel::ke_stop(RUNTIME_CHECK_PAGE); + Kernel::ke_panic(RUNTIME_CHECK_PAGE); process.Leak().ProcessSignal.SignalIP = 0UL; process.Leak().ProcessSignal.SignalID = SIGKILL; @@ -170,7 +170,7 @@ EXTERN_C void idt_handle_ud(Kernel::UIntPtr rsp) process.Leak().Crash(); - Kernel::ke_stop(RUNTIME_CHECK_UNEXCPECTED); + Kernel::ke_panic(RUNTIME_CHECK_UNEXCPECTED); } /// @brief Enter syscall from assembly. diff --git a/dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc b/dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc index 02150f6e..ac103d0d 100644 --- a/dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc +++ b/dev/Kernel/HALKit/AMD64/HalCoreScheduler.cc @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include // Needed for SMP. #include diff --git a/dev/Kernel/HALKit/AMD64/HalDebugOutput.cc b/dev/Kernel/HALKit/AMD64/HalDebugOutput.cc index 6ae5859d..ce3690b3 100644 --- a/dev/Kernel/HALKit/AMD64/HalDebugOutput.cc +++ b/dev/Kernel/HALKit/AMD64/HalDebugOutput.cc @@ -47,7 +47,7 @@ namespace Kernel // Check if serial is faulty (i.e: not same byte as sent) if (HAL::rt_in8(PORT) != 0xAE) { - ke_stop(RUNTIME_CHECK_HANDSHAKE); + ke_panic(RUNTIME_CHECK_HANDSHAKE); } kState = kStateReady; diff --git a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc index bf297d6a..75c41433 100644 --- a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include EXTERN_C Kernel::VoidPtr kInterruptVectorTable[]; EXTERN_C Kernel::VoidPtr mp_user_switch_proc; @@ -79,12 +79,12 @@ EXTERN_C void hal_init_platform( Kernel::HAL::GDTLoader gdt_loader; gdt_loader.Load(gdt_reg); - Kernel::ke_stop(RUNTIME_CHECK_BOOTSTRAP); + Kernel::ke_panic(RUNTIME_CHECK_BOOTSTRAP); } EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept { - CG::ui_draw_background(); + UI::ui_draw_background(); auto str_proc = Kernel::rt_alloc_string("System"); Kernel::rtl_create_process(rtl_kernel_main, str_proc); diff --git a/dev/Kernel/HALKit/ARM64/HalKernelMain.cc b/dev/Kernel/HALKit/ARM64/HalKernelMain.cc index 3892e31b..ff4676e4 100644 --- a/dev/Kernel/HALKit/ARM64/HalKernelMain.cc +++ b/dev/Kernel/HALKit/ARM64/HalKernelMain.cc @@ -5,7 +5,7 @@ ------------------------------------------- */ #include -#include +#include #include #include #include @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include Kernel::Void hal_real_init(Kernel::Void) noexcept; @@ -47,7 +47,7 @@ EXTERN_C void hal_init_platform( /// @note do initialize the interrupts after it. - CG::ui_draw_background(); + UI::ui_draw_background(); auto str_proc = Kernel::rt_alloc_string("System"); Kernel::rtl_create_process(rtl_kernel_main, str_proc); diff --git a/dev/Kernel/HALKit/ARM64/Storage/.gitkeep b/dev/Kernel/HALKit/ARM64/Storage/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/dev/Kernel/HALKit/ARM64/Storage/HalFlash.cc b/dev/Kernel/HALKit/ARM64/Storage/HalFlash.cc deleted file mode 100644 index 9bd71b57..00000000 --- a/dev/Kernel/HALKit/ARM64/Storage/HalFlash.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024, Theater Quality Inc, all rights reserved. - -------------------------------------------- */ - -#include -#include - -/// @file Flash.cc -/// @brief Flash memory builtin. - -#ifdef __USE_MBCI_FLASH__ - -#define kMaxFlash (4U) - -namespace Kernel -{ - /// /:/BRIDGE/FLSH/1 - constexpr auto kFlashBridgeMagic = "FLSH"; - constexpr auto kFlashBridgeRevision = 1; - - STATIC const Boolean kFlashEnabled = No; - STATIC SizeT kFlashSize[kMaxFlash] = {}; - STATIC SizeT kFlashSectorSz[kMaxFlash] = {}; - - /// @brief Enable flash memory builtin. - STATIC Void drv_enable_flash(Int32 slot); - - /// @brief Disable flash memory builtin. - STATIC Void drv_disable_flash(Int32 slot); - - /// @brief get sector count. - /// @return drive sector count. - SizeT drv_get_sector_count(Int32 slot) - { - if (slot > kMaxFlash) - return 0; - - return kFlashSectorSz[slot]; - } - - /// @brief get device size. - /// @return drive size - SizeT drv_get_size(Int32 slot) - { - if (slot > kMaxFlash) - return 0; - - return kFlashSize[slot]; - } - - /// @brief Enable flash memory at slot. - STATIC Void drv_enable_flash(Int32 arg) - { - kcout << "Enabled FLSH hardware.\r"; - } - - /// @brief Disable flash memory at slot. - STATIC Void drv_disable_flash(Int32 arg) - { - kcout << "Disabled FLSH hardware.\r"; - } -} // namespace Kernel - -#endif // if __USE_MBCI_FLASH__ (Bridge) diff --git a/dev/Kernel/HALKit/ARM64/Storage/HalFlashMemory.cc b/dev/Kernel/HALKit/ARM64/Storage/HalFlashMemory.cc new file mode 100644 index 00000000..d5a9ecf4 --- /dev/null +++ b/dev/Kernel/HALKit/ARM64/Storage/HalFlashMemory.cc @@ -0,0 +1,66 @@ +/* ------------------------------------------- + + Copyright (C) 2024, Theater Quality Inc, all rights reserved. + +------------------------------------------- */ + +#include +#include + +/// @file Flash.cc +/// @brief Flash memory builtin. + +#ifdef ZKA_USE_MBCI_FLASH + +#define kMaxFlash (4U) + +namespace Kernel +{ + /// /Mount/Flash/n + constexpr auto kFlashBridgeMagic = "FLSH"; + constexpr auto kFlashBridgeRevision = 1; + + STATIC const Boolean kFlashEnabled = No; + STATIC SizeT kFlashSize[kMaxFlash] = {}; + STATIC SizeT kFlashSectorSz[kMaxFlash] = {}; + + /// @brief Enable flash memory builtin. + STATIC Void drv_enable_flash(Int32 slot); + + /// @brief Disable flash memory builtin. + STATIC Void drv_disable_flash(Int32 slot); + + /// @brief get sector count. + /// @return drive sector count. + SizeT drv_get_sector_count(Int32 slot) + { + if (slot > kMaxFlash) + return 0; + + return kFlashSectorSz[slot]; + } + + /// @brief get device size. + /// @return drive size + SizeT drv_get_size(Int32 slot) + { + if (slot > kMaxFlash) + return 0; + + return kFlashSize[slot]; + } + + /// @brief Enable flash memory at slot. + STATIC Void drv_enable_flash(Int32 arg) + { + kcout << "Enabled FLSH hardware.\r"; + } + + /// @brief Disable flash memory at slot. + STATIC Void drv_disable_flash(Int32 arg) + { + kcout << "Disabled FLSH hardware.\r"; + } +} // namespace Kernel + +#endif // if ZKA_USE_MBCI_FLASH (Bridge) -- cgit v1.2.3