diff options
21 files changed, 116 insertions, 128 deletions
diff --git a/docs/tex/core_process_scheduler.tex b/docs/tex/core_process_scheduler.tex index c8a8f97b..71c1db9e 100644 --- a/docs/tex/core_process_scheduler.tex +++ b/docs/tex/core_process_scheduler.tex @@ -58,8 +58,8 @@ class UserProcessTeam final { ProcessID& Id() noexcept; public: - USER_PROCESS_ARRAY mProcessList; - USER_PROCESS_REF mCurrentProcess; + UserProcessArray mProcessList; + UserProcessRef mCurrentProcess; ProcessID mTeamId{0}; ProcessID mProcessCur{0}; }; diff --git a/public/frameworks/LaunchHelpers.fwrk/headers/Foundation.h b/public/frameworks/LaunchHelpers.fwrk/headers/Foundation.h index 846bb344..b20ca17e 100644 --- a/public/frameworks/LaunchHelpers.fwrk/headers/Foundation.h +++ b/public/frameworks/LaunchHelpers.fwrk/headers/Foundation.h @@ -12,15 +12,20 @@ namespace LaunchHelpers { struct LHLaunchInfo; +inline constexpr auto kMaxPath = 4096; +inline constexpr auto kMaxArgs = 256; + /// @brief Launch information structure. /// @note This structure is read-only. Modyfing its members wo't have any effect. struct LHLaunchInfo final { - CF::CFString fExecutablePath; - CF::CFString fWorkingDirectory; - CF::CFString fArguments; - CF::CFString fEnvironment; + CF::CFString fExecutablePath{kMaxPath}; + CF::CFString fWorkingDirectory{kMaxPath}; + CF::CFString fArguments[kMaxArgs]; + CF::CFString fEnvironment{kMaxPath}; CF::CFInteger64 fUID{0}; CF::CFInteger64 fGID{0}; + + explicit operator bool() { return fUID && fGID; } }; using LHLaunchInfoPtr = LHLaunchInfo*; diff --git a/public/frameworks/LaunchHelpers.fwrk/src/.keep b/public/frameworks/LaunchHelpers.fwrk/src/.keep deleted file mode 100644 index e69de29b..00000000 --- a/public/frameworks/LaunchHelpers.fwrk/src/.keep +++ /dev/null diff --git a/public/frameworks/LaunchHelpers.fwrk/src/DylibMain.cc b/public/frameworks/LaunchHelpers.fwrk/src/DylibMain.cc deleted file mode 100644 index 99eebd26..00000000 --- a/public/frameworks/LaunchHelpers.fwrk/src/DylibMain.cc +++ /dev/null @@ -1,5 +0,0 @@ -#include <libSystem/SystemKit/System.h> - -SInt32 _DylibAttach(SInt32 argc, Char* argv[]) { - return EXIT_FAILURE; -}
\ No newline at end of file diff --git a/public/frameworks/LaunchHelpers.fwrk/src/Foundation.cc b/public/frameworks/LaunchHelpers.fwrk/src/Foundation.cc new file mode 100644 index 00000000..6cc3bff3 --- /dev/null +++ b/public/frameworks/LaunchHelpers.fwrk/src/Foundation.cc @@ -0,0 +1,15 @@ +/* ======================================== + + Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + +#include <LaunchHelpers.fwrk/headers/Foundation.h> +#include <libSystem/SystemKit/Syscall.h> + +/// @brief Get launch information. +/// @return the launch information structure. +LaunchHelpers::LHLaunchInfo* LaunchHelpers::LHGetLaunchInfo(Void) { + return static_cast<LaunchHelpers::LHLaunchInfo*>( + libsys_syscall_arg_1(libsys_hash_64("__LHGetLaunchInfo"))); +}
\ No newline at end of file diff --git a/src/boot/BootKit/BootKit.h b/src/boot/BootKit/BootKit.h index b00fd112..c7057d4b 100644 --- a/src/boot/BootKit/BootKit.h +++ b/src/boot/BootKit/BootKit.h @@ -337,4 +337,4 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const Char* part_name) { } } // namespace Boot -#endif // __BOOTKIT_H__
\ No newline at end of file +#endif // __BOOTKIT_H__
\ No newline at end of file diff --git a/src/boot/BootKit/Config.h b/src/boot/BootKit/Config.h index b2641b24..42063d45 100644 --- a/src/boot/BootKit/Config.h +++ b/src/boot/BootKit/Config.h @@ -10,7 +10,7 @@ #include <NeKit/Config.h> namespace Boot { - using namespace Kernel; +using namespace Kernel; } -#endif // ! __BOOTKIT_CONFIG_H__
\ No newline at end of file +#endif // ! __BOOTKIT_CONFIG_H__
\ No newline at end of file diff --git a/src/boot/BootKit/Device.h b/src/boot/BootKit/Device.h index efe27659..e54d0bf1 100644 --- a/src/boot/BootKit/Device.h +++ b/src/boot/BootKit/Device.h @@ -12,7 +12,7 @@ #include <modules/ATA/ATA.h> namespace Boot { -/// @brief Physical/Virtual device type. +/// @brief Physical/Virtual device type. class Device { public: explicit Device() = default; @@ -21,7 +21,7 @@ class Device { NE_MOVE_DEFAULT(Device) struct Trait { - Lba mBase{0}; + Lba mBase{0}; SizeT mSize{0}; }; @@ -31,9 +31,9 @@ class Device { virtual Device& Write(Char* Buf, SizeT SecCount) = 0; }; -using BootDevice = Device; +using BootDevice = Device; using NetworkDevice = Device; -using DiskDevice = Device; +using DiskDevice = Device; } // namespace Boot -#endif
\ No newline at end of file +#endif
\ No newline at end of file diff --git a/src/boot/amd64-desktop.make b/src/boot/amd64-desktop.make index 2ddc4659..88779211 100644 --- a/src/boot/amd64-desktop.make +++ b/src/boot/amd64-desktop.make @@ -48,13 +48,13 @@ ifneq ($(DEBUG_SUPPORT), ) DEBUG_MACRO = -D__DEBUG__ endif -ifeq ($(shell uname), Darwin) +ifeq ($(KVM_SUPPORT),) EMU_FLAGS=-M q35 -smp 4 -m 8G \ -bios $(BIOS) -cdrom $(BOOT) -boot d endif -ifneq ($(shell uname), Darwin) -EMU_FLAGS= -smp 4 -m 8G \ +ifneq ($(KVM_SUPPORT),) +EMU_FLAGS=-M q35 -smp 4 -m 8G \ -bios $(BIOS) -M q35 -cdrom $(BOOT) -boot d -accel kvm endif 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> diff --git a/tools/mkfs.hefs.cc b/tools/mkfs.hefs.cc index 4be6ed04..f4cf77ea 100644 --- a/tools/mkfs.hefs.cc +++ b/tools/mkfs.hefs.cc @@ -32,7 +32,7 @@ int main(int argc, char** argv) { std::string args = mkfs::detail::build_args(argc, argv); auto output_path = mkfs::get_option<char>(args, "o"); - + if (output_path.empty()) { mkfs::console_out() << "hefs: error: Missing -o <output_device> argument.\n"; return EXIT_FAILURE; @@ -199,7 +199,6 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } - output_device.put(0); output_device.flush(); |
