From 0402a1c2feb8e8036c56dfc51d13e63ef3133208 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 10 Jul 2024 14:25:37 +0200 Subject: [MHR-36] Giving priority to NVMe module suport. Signed-off-by: Amlal El Mahrouss --- .../HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx | 9 +- Kernel/HALKit/AMD64/HalKernelMain.cxx | 4 +- Kernel/HALKit/ARM64/HalKernelMain.cxx | 4 +- Kernel/KernelKit/ProcessHeap.hpp | 44 -------- Kernel/KernelKit/ProcessHeap.hxx | 44 ++++++++ Kernel/KernelKit/ProcessScheduler.hxx | 2 +- Kernel/Modules/ACPI/ACPIFactoryInterface.hxx | 4 + Kernel/NewKit/Json.hpp | 118 --------------------- Kernel/NewKit/Json.hxx | 118 +++++++++++++++++++++ Kernel/NewKit/NewKit.hpp | 4 +- Kernel/Sources/Json.cxx | 2 +- Kernel/Sources/KeMain.cxx | 4 +- Kernel/Sources/ProcessHeap.cxx | 2 +- 13 files changed, 184 insertions(+), 175 deletions(-) delete mode 100644 Kernel/KernelKit/ProcessHeap.hpp create mode 100644 Kernel/KernelKit/ProcessHeap.hxx delete mode 100644 Kernel/NewKit/Json.hpp create mode 100644 Kernel/NewKit/Json.hxx (limited to 'Kernel') diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx index 86bf635c..76e447be 100644 --- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx +++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx @@ -24,7 +24,7 @@ /// @brief assembly routine. internal use only. EXTERN_C void _hal_enable_smp(void); -/// @note: _hal_switch_context +/// @note: _hal_switch_context is internal /////////////////////////////////////////////////////////////////////////////////////// @@ -169,10 +169,13 @@ namespace Kernel::HAL return cFramePtr; } + /// @internal EXTERN_C Void hal_apic_acknowledge(Void) { + kcout << "newoskrnl: acknowledge APIC.\r"; } + /// @internal EXTERN_C Void _hal_switch_context(HAL::StackFramePtr stackFrame) { hal_switch_context(stackFrame); @@ -182,7 +185,9 @@ namespace Kernel::HAL { Semaphore sem; - HardwareTimer timer(Seconds(5)); + constexpr auto cSeconds = 1U; + + HardwareTimer timer(Seconds(cSeconds)); sem.LockOrWait(&ProcessScheduler::The().Leak().TheCurrent().Leak(), &timer); cFramePtr = stackFrame; diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx index a279b776..dc3ae4d0 100644 --- a/Kernel/HALKit/AMD64/HalKernelMain.cxx +++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx @@ -12,8 +12,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/Kernel/HALKit/ARM64/HalKernelMain.cxx b/Kernel/HALKit/ARM64/HalKernelMain.cxx index 3fb18737..1d82aeba 100644 --- a/Kernel/HALKit/ARM64/HalKernelMain.cxx +++ b/Kernel/HALKit/ARM64/HalKernelMain.cxx @@ -12,8 +12,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/Kernel/KernelKit/ProcessHeap.hpp b/Kernel/KernelKit/ProcessHeap.hpp deleted file mode 100644 index 0682d969..00000000 --- a/Kernel/KernelKit/ProcessHeap.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -/// @version 5/11/23 -/// @file ProcessHeap.hpp -/// @brief memory heap for user processes. - -#define kUserHeapMaxSz (4096) -#define kUserHeapMag (0xFAF0FEF0) - -namespace Kernel -{ - typedef enum - { - /// @brief Shared heap. - kUserHeapShared = 0x4, - /// @brief User and private heap. - kUserHeapUser = 0x6, - /// @brief Read and Write heap. - kUserHeapRw = 0x8, - } kUserHeapFlags; - - /// @brief Allocate a process heap, no zero out is done here. - /// @param flags - /// @return The process's heap. - VoidPtr rt_new_heap(Int32 flags); - - /// @brief Frees the process heap. - /// @param pointer The process heap pointer. - /// @return - Int32 rt_free_heap(voidPtr pointer); -} // namespace Kernel diff --git a/Kernel/KernelKit/ProcessHeap.hxx b/Kernel/KernelKit/ProcessHeap.hxx new file mode 100644 index 00000000..6fa397b3 --- /dev/null +++ b/Kernel/KernelKit/ProcessHeap.hxx @@ -0,0 +1,44 @@ +/* ------------------------------------------- + + Copyright Zeta Electronics Corporation + +------------------------------------------- */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +/// @version 5/11/23 +/// @file ProcessHeap.hxx +/// @brief memory heap for user processes. + +#define kUserHeapMaxSz (4096) +#define kUserHeapMag (0xFAF0FEF0) + +namespace Kernel +{ + typedef enum + { + /// @brief Shared heap. + kUserHeapShared = 0x4, + /// @brief User and private heap. + kUserHeapUser = 0x6, + /// @brief Read and Write heap. + kUserHeapRw = 0x8, + } kUserHeapFlags; + + /// @brief Allocate a process heap, no zero out is done here. + /// @param flags + /// @return The process's heap. + VoidPtr rt_new_heap(Int32 flags); + + /// @brief Frees the process heap. + /// @param pointer The process heap pointer. + /// @return + Int32 rt_free_heap(voidPtr pointer); +} // namespace Kernel diff --git a/Kernel/KernelKit/ProcessScheduler.hxx b/Kernel/KernelKit/ProcessScheduler.hxx index 578dc163..5e7a6e55 100644 --- a/Kernel/KernelKit/ProcessScheduler.hxx +++ b/Kernel/KernelKit/ProcessScheduler.hxx @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #define kSchedMinMicroTime (AffinityKind::kHartStandard) diff --git a/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx b/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx index e5def104..fc49c2b9 100644 --- a/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx +++ b/Kernel/Modules/ACPI/ACPIFactoryInterface.hxx @@ -14,6 +14,10 @@ namespace Kernel { + class ACPIFactoryInterface; + + typedef ACPIFactoryInterface PowerFactoryInterface; + class ACPIFactoryInterface final { public: diff --git a/Kernel/NewKit/Json.hpp b/Kernel/NewKit/Json.hpp deleted file mode 100644 index b2a0d872..00000000 --- a/Kernel/NewKit/Json.hpp +++ /dev/null @@ -1,118 +0,0 @@ - -/* ------------------------------------------- - - Copyright Zeta Electronics Corporation - -------------------------------------------- */ - -#pragma once - -// last-rev: 30/01/24 - -#include -#include -#include -#include -#include - -namespace Kernel -{ - /// @brief Json value class - class JsonType final - { - public: - explicit JsonType() - : Kernel::JsonType(1, 1) - { - } - - explicit JsonType(SizeT lhsLen, SizeT rhsLen) - : fKey(lhsLen), fValue(rhsLen) - { - } - - ~JsonType() = default; - - NEWOS_COPY_DEFAULT(JsonType); - - private: - StringView fKey; - StringView fValue; - - public: - /// @brief returns the key of the json - /// @return the key as string view. - StringView& AsKey() - { - return fKey; - } - - /// @brief returns the value of the json. - /// @return the key as string view. - StringView& AsValue() - { - return fValue; - } - - static JsonType kUndefined; - }; - - /// @brief Json stream helper class. - struct JsonStreamTrait final - { - JsonType In(const char* full_array) - { - SizeT len = rt_string_len(full_array); - - if (full_array[0] == '\"' && full_array[len - 1] == ',' || - full_array[len - 1] == '\"') - { - Boolean probe_key = true; - - SizeT key_len = 0; - SizeT value_len = 0; - - for (SizeT i = 1; i < len; i++) - { - if (full_array[i] == ' ') - continue; - - JsonType type(kPathLen, kPathLen); - - if (probe_key) - { - type.AsKey().Data()[key_len] = full_array[i]; - ++key_len; - - if (full_array[i] == '\"') - { - probe_key = false; - type.AsKey().Data()[key_len] = 0; - - ++i; - } - } - else - { - type.AsValue().Data()[value_len] = full_array[i]; - ++value_len; - - if (full_array[i] == '\"') - { - type.AsValue().Data()[value_len] = 0; - } - } - } - } - - return JsonType::kUndefined; - } - - JsonType Out(JsonType& out) - { - return out; - } - }; - - using JsonStream = Stream; -} // namespace Kernel diff --git a/Kernel/NewKit/Json.hxx b/Kernel/NewKit/Json.hxx new file mode 100644 index 00000000..b2a0d872 --- /dev/null +++ b/Kernel/NewKit/Json.hxx @@ -0,0 +1,118 @@ + +/* ------------------------------------------- + + Copyright Zeta Electronics Corporation + +------------------------------------------- */ + +#pragma once + +// last-rev: 30/01/24 + +#include +#include +#include +#include +#include + +namespace Kernel +{ + /// @brief Json value class + class JsonType final + { + public: + explicit JsonType() + : Kernel::JsonType(1, 1) + { + } + + explicit JsonType(SizeT lhsLen, SizeT rhsLen) + : fKey(lhsLen), fValue(rhsLen) + { + } + + ~JsonType() = default; + + NEWOS_COPY_DEFAULT(JsonType); + + private: + StringView fKey; + StringView fValue; + + public: + /// @brief returns the key of the json + /// @return the key as string view. + StringView& AsKey() + { + return fKey; + } + + /// @brief returns the value of the json. + /// @return the key as string view. + StringView& AsValue() + { + return fValue; + } + + static JsonType kUndefined; + }; + + /// @brief Json stream helper class. + struct JsonStreamTrait final + { + JsonType In(const char* full_array) + { + SizeT len = rt_string_len(full_array); + + if (full_array[0] == '\"' && full_array[len - 1] == ',' || + full_array[len - 1] == '\"') + { + Boolean probe_key = true; + + SizeT key_len = 0; + SizeT value_len = 0; + + for (SizeT i = 1; i < len; i++) + { + if (full_array[i] == ' ') + continue; + + JsonType type(kPathLen, kPathLen); + + if (probe_key) + { + type.AsKey().Data()[key_len] = full_array[i]; + ++key_len; + + if (full_array[i] == '\"') + { + probe_key = false; + type.AsKey().Data()[key_len] = 0; + + ++i; + } + } + else + { + type.AsValue().Data()[value_len] = full_array[i]; + ++value_len; + + if (full_array[i] == '\"') + { + type.AsValue().Data()[value_len] = 0; + } + } + } + } + + return JsonType::kUndefined; + } + + JsonType Out(JsonType& out) + { + return out; + } + }; + + using JsonStream = Stream; +} // namespace Kernel diff --git a/Kernel/NewKit/NewKit.hpp b/Kernel/NewKit/NewKit.hpp index 8ca19ec8..90c0cf6e 100644 --- a/Kernel/NewKit/NewKit.hpp +++ b/Kernel/NewKit/NewKit.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -18,5 +18,5 @@ #include #include #include -#include +#include #include diff --git a/Kernel/Sources/Json.cxx b/Kernel/Sources/Json.cxx index 16a74765..f27c1486 100644 --- a/Kernel/Sources/Json.cxx +++ b/Kernel/Sources/Json.cxx @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include +#include using namespace Kernel; diff --git a/Kernel/Sources/KeMain.cxx b/Kernel/Sources/KeMain.cxx index 011e59a4..ddcdb6f9 100644 --- a/Kernel/Sources/KeMain.cxx +++ b/Kernel/Sources/KeMain.cxx @@ -17,8 +17,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/Kernel/Sources/ProcessHeap.cxx b/Kernel/Sources/ProcessHeap.cxx index b5988c5f..5efe8fd4 100644 --- a/Kernel/Sources/ProcessHeap.cxx +++ b/Kernel/Sources/ProcessHeap.cxx @@ -5,7 +5,7 @@ ------------------------------------------- */ #include -#include +#include #include #define kHeapHeaderPaddingSz (16U) -- cgit v1.2.3