diff options
Diffstat (limited to 'src/kernel')
| -rw-r--r-- | src/kernel/CFKit/GUIDWizard.h | 4 | ||||
| -rw-r--r-- | src/kernel/HALKit/AMD64/HalKernelMain.cc | 1 | ||||
| -rw-r--r-- | src/kernel/KernelKit/CoreProcessScheduler.h | 50 | ||||
| -rw-r--r-- | src/kernel/KernelKit/UserProcessScheduler.h | 22 | ||||
| -rw-r--r-- | src/kernel/NeKit/Array.h | 11 | ||||
| -rw-r--r-- | src/kernel/NeKit/ArrayList.h | 44 | ||||
| -rw-r--r-- | src/kernel/NeKit/Atom.h | 2 | ||||
| -rw-r--r-- | src/kernel/NeKit/InitializerList.h | 42 | ||||
| -rw-r--r-- | src/kernel/NeKit/NeKit.h | 2 | ||||
| -rw-r--r-- | src/kernel/src/GUIDWizard.cc | 2 | ||||
| -rw-r--r-- | src/kernel/src/InitializerList.cc (renamed from src/kernel/src/ArrayList.cc) | 2 |
11 files changed, 78 insertions, 104 deletions
diff --git a/src/kernel/CFKit/GUIDWizard.h b/src/kernel/CFKit/GUIDWizard.h index 8d8f6e54..901bd261 100644 --- a/src/kernel/CFKit/GUIDWizard.h +++ b/src/kernel/CFKit/GUIDWizard.h @@ -8,14 +8,14 @@ #include <CFKit/GUIDWrapper.h> #include <NeKit/Array.h> -#include <NeKit/ArrayList.h> #include <NeKit/Config.h> #include <NeKit/ErrorOr.h> +#include <NeKit/InitializerList.h> #include <NeKit/KString.h> #include <NeKit/Ref.h> #include <NeKit/Stream.h> namespace Kernel::CF::XRN::Version1 { -Ref<GUIDSequence*> cf_make_sequence(const ArrayList<UInt32>& seq); +Ref<GUIDSequence*> cf_make_sequence(const Array<UInt32, 10>& seq); ErrorOr<Ref<KString>> cf_try_guid_to_string(Ref<GUIDSequence*>& guid); } // namespace Kernel::CF::XRN::Version1 diff --git a/src/kernel/HALKit/AMD64/HalKernelMain.cc b/src/kernel/HALKit/AMD64/HalKernelMain.cc index 5f1d2430..831c3636 100644 --- a/src/kernel/HALKit/AMD64/HalKernelMain.cc +++ b/src/kernel/HALKit/AMD64/HalKernelMain.cc @@ -17,6 +17,7 @@ #include <misc/BenchKit/HWChronometer.h> #include <modules/ACPI/ACPIFactoryInterface.h> #include <modules/CoreGfx/TextGfx.h> +#include "NeKit/InitializerList.h" #ifndef __NE_MODULAR_KERNEL_COMPONENTS__ EXTERN_C Kernel::VoidPtr kInterruptVectorTable[]; diff --git a/src/kernel/KernelKit/CoreProcessScheduler.h b/src/kernel/KernelKit/CoreProcessScheduler.h index 5071f85d..e3cfc12c 100644 --- a/src/kernel/KernelKit/CoreProcessScheduler.h +++ b/src/kernel/KernelKit/CoreProcessScheduler.h @@ -60,19 +60,11 @@ struct ProcessHeapTree { TreeKind Color{TreeKind::kBlackTreeKind}; - struct ProcessHeapTree<T>* Parent { - nullptr - }; - struct ProcessHeapTree<T>* Child { - nullptr - }; - - struct ProcessHeapTree<T>* Prev { - nullptr - }; - struct ProcessHeapTree<T>* Next { - nullptr - }; + struct ProcessHeapTree<T>* Parent{nullptr}; + struct ProcessHeapTree<T>* Child{nullptr}; + + struct ProcessHeapTree<T>* Prev{nullptr}; + struct ProcessHeapTree<T>* Next{nullptr}; }; template <typename T> @@ -87,21 +79,13 @@ struct ProcessFileTree { TreeKind Color{TreeKind::kBlackTreeKind}; - struct ProcessFileTree<T>* Parent { - nullptr - }; + struct ProcessFileTree<T>* Parent{nullptr}; - struct ProcessFileTree<T>* Child { - nullptr - }; + struct ProcessFileTree<T>* Child{nullptr}; - struct ProcessFileTree<T>* Prev { - nullptr - }; + struct ProcessFileTree<T>* Prev{nullptr}; - struct ProcessFileTree<T>* Next { - nullptr - }; + struct ProcessFileTree<T>* Next{nullptr}; }; using ProcessCtx = UInt32; @@ -121,21 +105,13 @@ struct ProcessSpecialTree { TreeKind Color{TreeKind::kBlackTreeKind}; - struct ProcessSpecialTree<T>* Parent { - nullptr - }; + struct ProcessSpecialTree<T>* Parent{nullptr}; - struct ProcessSpecialTree<T>* Child { - nullptr - }; + struct ProcessSpecialTree<T>* Child{nullptr}; - struct ProcessSpecialTree<T>* Prev { - nullptr - }; + struct ProcessSpecialTree<T>* Prev{nullptr}; - struct ProcessSpecialTree<T>* Next { - nullptr - }; + struct ProcessSpecialTree<T>* Next{nullptr}; }; /***********************************************************************************/ diff --git a/src/kernel/KernelKit/UserProcessScheduler.h b/src/kernel/KernelKit/UserProcessScheduler.h index 9d483ef4..859dd9e5 100644 --- a/src/kernel/KernelKit/UserProcessScheduler.h +++ b/src/kernel/KernelKit/UserProcessScheduler.h @@ -63,10 +63,10 @@ class UserProcess final NE_VETTABLE { UIntPtr SignalID{0}; }; - USER_PROCESS_SIGNAL Signal; + USER_PROCESS_SIGNAL Signal; ProcessFileTree<VoidPtr>* FileTree{nullptr}; ProcessHeapTree<VoidPtr>* HeapTree{nullptr}; - UserProcessTeam* ParentTeam; + UserProcessTeam* ParentTeam; VoidPtr VMRegister{0UL}; @@ -158,8 +158,8 @@ class UserProcess final NE_VETTABLE { friend UserProcessHelper; }; -typedef Array<UserProcess, kSchedProcessLimitPerTeam> USER_PROCESS_ARRAY; -typedef Ref<UserProcess> USER_PROCESS_REF; +typedef Array<UserProcess, kSchedProcessLimitPerTeam> UserProcessArray; +typedef Ref<UserProcess> UserProcessRef; /// \brief Processs Team (contains multiple processes inside it.) /// Equivalent to a process batch @@ -172,13 +172,13 @@ class UserProcessTeam final { Array<UserProcess, kSchedProcessLimitPerTeam>& AsArray(); Ref<UserProcess>& AsRef(); - ProcessID& Id(); + ProcessID& Id(); public: - USER_PROCESS_ARRAY mProcessList; - USER_PROCESS_REF mCurrentProcess; - ProcessID mTeamId{0}; - ProcessID mProcessCur{0}; + UserProcessArray mProcessList; + UserProcessRef mCurrentProcess; + ProcessID mTeamId{0}; + ProcessID mProcessCur{0}; }; /***********************************************************************************/ @@ -212,8 +212,8 @@ class UserProcessScheduler final : public ISchedulable { Bool HasMP() override; public: - USER_PROCESS_REF& TheCurrentProcess(); - SizeT Run(); + UserProcessRef& TheCurrentProcess(); + SizeT Run(); public: STATIC UserProcessScheduler& The(); diff --git a/src/kernel/NeKit/Array.h b/src/kernel/NeKit/Array.h index f4673b68..179b8e4e 100644 --- a/src/kernel/NeKit/Array.h +++ b/src/kernel/NeKit/Array.h @@ -20,26 +20,25 @@ class Array final { Array& operator=(const Array&) = default; Array(const Array&) = default; - T& operator[](SizeT at) { return fArray[at]; } + T& operator[](const SizeT& at) { return fArray[at]; } + const T& operator[](const SizeT& at) const { return fArray[at]; } Boolean Empty() { return this->Count() > 0; } SizeT Capacity() { return N; } - SizeT Count() { - return N; // avoid constexpr error. - } + SizeT Count() { return N; } const T* CData() { return fArray; } - operator bool() { return !Empty(); } + explicit operator bool() { return !this->Empty(); } private: T fArray[N]; }; template <typename ValueType> -auto make_list(ValueType val) { +inline auto make_array(ValueType& val) -> auto { return Array<ValueType, ARRAY_SIZE(val)>{val}; } } // namespace Kernel diff --git a/src/kernel/NeKit/ArrayList.h b/src/kernel/NeKit/ArrayList.h deleted file mode 100644 index 5787fe98..00000000 --- a/src/kernel/NeKit/ArrayList.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ======================================== - - Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -======================================== */ - -#pragma once - -#include <NeKit/Config.h> - -namespace Kernel { -template <typename T> -class ArrayList final { - public: - explicit ArrayList(T* list, SizeT length) : fList(reinterpret_cast<T>(list)), fLen(length) {} - - ~ArrayList() = default; - - ArrayList& operator=(const ArrayList&) = default; - ArrayList(const ArrayList&) = default; - - T* Data() { return fList; } - - const T* CData() { return fList; } - - T& operator[](SizeT index) const { - MUST_PASS(index < this->Count()); - return fList[index]; - } - - explicit operator bool() { return fList; } - - SizeT Count() const { return fLen; } - - private: - T* fList{nullptr}; - SizeT fLen{0}; -}; - -template <typename ValueType> -ArrayList<ValueType> make_list(ValueType val) { - return ArrayList<ValueType>{val}; -} -} // namespace Kernel diff --git a/src/kernel/NeKit/Atom.h b/src/kernel/NeKit/Atom.h index 51808a0a..7c4ebb5b 100644 --- a/src/kernel/NeKit/Atom.h +++ b/src/kernel/NeKit/Atom.h @@ -25,7 +25,7 @@ class Atom final { friend Boolean operator==(Atom<T>& atomic, const T& idx) { return atomic[idx] == idx; } - friend Boolean operator!=(Atom<T>& atomic, const T& idx) { return atomic[idx] == idx; } + friend Boolean operator!=(Atom<T>& atomic, const T& idx) { return atomic[idx] != idx; } private: T fArrayOfAtoms; diff --git a/src/kernel/NeKit/InitializerList.h b/src/kernel/NeKit/InitializerList.h new file mode 100644 index 00000000..158b88ed --- /dev/null +++ b/src/kernel/NeKit/InitializerList.h @@ -0,0 +1,42 @@ +/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + +#pragma once + +#include <NeKit/Config.h> + +namespace Kernel { +template <typename T, SizeT N> +class InitializerList final { + public: + explicit InitializerList(const T* list) { + if constexpr (N > 0) { + for (auto i = 0UL; i < N; ++i) { + fList[i] = list[i]; + } + } + } + + ~InitializerList() = default; + + InitializerList& operator=(const InitializerList&) = default; + InitializerList(const InitializerList&) = default; + + T* begin() { return fList; } + T* operator->() { return fList; } + T* operator*() { return fList; } + T* end() { return fList + N; } + constexpr SizeT size() const { return N; } + + private: + T fList[N]; +}; + +template <typename ValueType, SizeT N> +inline InitializerList<ValueType, N> make_list(ValueType& val) { + return InitializerList<ValueType, N>{val}; +} +} // namespace Kernel diff --git a/src/kernel/NeKit/NeKit.h b/src/kernel/NeKit/NeKit.h index 4b1e64ca..9bf74e57 100644 --- a/src/kernel/NeKit/NeKit.h +++ b/src/kernel/NeKit/NeKit.h @@ -8,8 +8,8 @@ #pragma once #include <NeKit/Array.h> -#include <NeKit/ArrayList.h> #include <NeKit/ErrorOr.h> +#include <NeKit/InitializerList.h> #include <NeKit/Json.h> #include <NeKit/KernelPanic.h> #include <NeKit/MutableArray.h> diff --git a/src/kernel/src/GUIDWizard.cc b/src/kernel/src/GUIDWizard.cc index 2d1218ed..87f19e21 100644 --- a/src/kernel/src/GUIDWizard.cc +++ b/src/kernel/src/GUIDWizard.cc @@ -18,7 +18,7 @@ #define kGUIDSize 37 namespace Kernel::CF::XRN::Version1 { -auto cf_make_sequence(const ArrayList<UInt32>& uuidSeq) -> Ref<GUIDSequence*> { +auto cf_make_sequence(const Array<UInt32, 10>& uuidSeq) -> Ref<GUIDSequence*> { GUIDSequence* seq = new GUIDSequence(); MUST_PASS(seq); diff --git a/src/kernel/src/ArrayList.cc b/src/kernel/src/InitializerList.cc index 37042320..da9e8f14 100644 --- a/src/kernel/src/ArrayList.cc +++ b/src/kernel/src/InitializerList.cc @@ -4,4 +4,4 @@ ======================================== */ -#include <NeKit/ArrayList.h> +#include <NeKit/InitializerList.h> |
