diff options
Diffstat (limited to 'src/kernel')
37 files changed, 151 insertions, 231 deletions
diff --git a/src/kernel/FSKit/Ext2+IFS.h b/src/kernel/FSKit/Ext2+IFS.h index 51767677..8c904710 100644 --- a/src/kernel/FSKit/Ext2+IFS.h +++ b/src/kernel/FSKit/Ext2+IFS.h @@ -32,7 +32,7 @@ class Ext2Context final { } } - Ext2Context(const Ext2Context&) = delete; + Ext2Context(const Ext2Context&) = delete; Ext2Context& operator=(const Ext2Context&) = delete; Ext2Context(Ext2Context&& other) : drive(other.drive), superblock(other.superblock) { diff --git a/src/kernel/FSKit/OpenHeFS.h b/src/kernel/FSKit/OpenHeFS.h index 9983f6ff..a642c299 100644 --- a/src/kernel/FSKit/OpenHeFS.h +++ b/src/kernel/FSKit/OpenHeFS.h @@ -267,7 +267,7 @@ inline UInt32 hefs_hour_get(ATime raw_atime) { /// @return the minute value. /// @note The minute is stored in the lower 8 bits of the ATime value. inline UInt32 hefs_minute_get(ATime raw_atime) { - return (raw_atime) &0xFF; + return (raw_atime) & 0xFF; } inline constexpr UInt32 kOpenHeFSBaseYear = 1970; @@ -387,10 +387,10 @@ class HeFileSystemParser final { ~HeFileSystemParser() = default; public: - HeFileSystemParser(const HeFileSystemParser&) = delete; + HeFileSystemParser(const HeFileSystemParser&) = delete; HeFileSystemParser& operator=(const HeFileSystemParser&) = delete; - HeFileSystemParser(HeFileSystemParser&&) = delete; + HeFileSystemParser(HeFileSystemParser&&) = delete; HeFileSystemParser& operator=(HeFileSystemParser&&) = delete; public: diff --git a/src/kernel/FirmwareKit/EFI/EFI.h b/src/kernel/FirmwareKit/EFI/EFI.h index e472a0f5..4e256403 100644 --- a/src/kernel/FirmwareKit/EFI/EFI.h +++ b/src/kernel/FirmwareKit/EFI/EFI.h @@ -56,7 +56,7 @@ typedef Char16 EfiChar16Type; /// @brief Core Handle Kind /// Self is like NT's Win32 HANDLE type. typedef struct EfiHandle { -} * EfiHandlePtr; +}* EfiHandlePtr; /* UEFI uses wide characters by default. */ typedef WideChar EfiCharType; @@ -238,64 +238,42 @@ typedef struct EfiTableHeader { UInt32 Reserved; } EfiTableHeader; -#define EFI_ACPI_TABLE_PROTOCOL_GUID \ - { \ - 0xffe06bdd, 0x6107, 0x46a6, { 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c } \ - } +#define EFI_ACPI_TABLE_PROTOCOL_GUID \ + {0xffe06bdd, 0x6107, 0x46a6, {0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c}} -#define EFI_LOAD_FILE_PROTOCOL_GUID \ - { \ - 0x56EC3091, 0x954C, 0x11d2, { 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_LOAD_FILE_PROTOCOL_GUID \ + {0x56EC3091, 0x954C, 0x11d2, {0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} -#define EFI_LOAD_FILE2_PROTOCOL_GUID \ - { \ - 0x4006c0c1, 0xfcb3, 0x403e, { 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d } \ - } +#define EFI_LOAD_FILE2_PROTOCOL_GUID \ + {0x4006c0c1, 0xfcb3, 0x403e, {0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d}} -#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ - { \ - 0x5B1B31A1, 0x9562, 0x11d2, { 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \ - } +#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ + {0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B}} -#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ - { \ - 0x9042a9de, 0x23dc, 0x4a38, { 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a } \ - } +#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ + {0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a}} -#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \ - { \ - 0xA19832B9, 0xAC25, 0x11D3, { 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ - } +#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \ + {0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d}} #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 -#define EFI_IP4_PROTOCOL_GUID \ - { \ - 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } \ - } +#define EFI_IP4_PROTOCOL_GUID \ + {0x41d94cd2, 0x35b6, 0x455a, {0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd}} #define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000 -#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ - { \ - 0x0964e5b22, 0x6459, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ + {0x0964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} -#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ - { \ - 0xbc62157e, 0x3e33, 0x4fec, { 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf } \ - } +#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ + {0xbc62157e, 0x3e33, 0x4fec, {0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf}} -#define EFI_DEVICE_PATH_PROTOCOL_GUID \ - { \ - 0x9576e91, 0x6d3f, 0x11d2, { 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_DEVICE_PATH_PROTOCOL_GUID \ + {0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} -#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ - { \ - 0x0964e5b22, 0x6459, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ + {0x0964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} typedef UInt64(EfiImageUnload)(EfiHandlePtr ImageHandle); @@ -350,17 +328,17 @@ typedef struct { typedef EFI_STATUS(EFIAPI* EFI_SIMPLE_NETWORK_TRANSMIT)(IN EFI_SIMPLE_NETWORK_PROTOCOL* This, IN UInt32 HeaderSize, IN UInt32 BufferSize, - IN Void* Buffer, - IN EfiMacAddress* SrcAddr OPTIONAL, + IN Void* Buffer, + IN EfiMacAddress* SrcAddr OPTIONAL, IN EfiMacAddress* DestAddr OPTIONAL, - IN UInt16* Protocol OPTIONAL); + IN UInt16* Protocol OPTIONAL); typedef EFI_STATUS(EFIAPI* EFI_SIMPLE_NETWORK_RECEIVE)(IN EFI_SIMPLE_NETWORK_PROTOCOL* This, - OUT UInt32* HeaderSize OPTIONAL, + OUT UInt32* HeaderSize OPTIONAL, IN OUT UInt32* BufferSize, OUT Void* Buffer, - OUT EfiMacAddress* SrcAddr OPTIONAL, + OUT EfiMacAddress* SrcAddr OPTIONAL, OUT EfiMacAddress* DestAddr OPTIONAL, - OUT UInt16* Protocol OPTIONAL); + OUT UInt16* Protocol OPTIONAL); typedef struct EFI_SIMPLE_NETWORK_PROTOCOL { UInt64 Revision; @@ -505,10 +483,8 @@ typedef struct EFI_GUID EFI_FINAL { * Protocol stuff... */ -#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \ - { \ - 0x387477c1, 0x69c7, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \ + {0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} /** some helpers */ #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 @@ -606,7 +582,7 @@ typedef struct { } EfiInputKey; typedef EfiStatusType(EFI_API* EfiInputReadKey)(IN EfiSimpleTextInputProtocol* This, - OUT EfiInputKey* Key); + OUT EfiInputKey* Key); typedef EfiStatusType(EFI_API* EfiInputReset)(IN EfiSimpleTextInputProtocol* This, IN Boolean ExtendedChk); @@ -664,7 +640,7 @@ typedef struct EfiSystemTable { struct { EFI_GUID VendorGUID; VoidPtr VendorTable; - } * ConfigurationTable; + }* ConfigurationTable; } EfiSystemTable; #define kEfiOk 0 @@ -725,10 +701,8 @@ enum { #define EFI_EXTRA_DESCRIPTOR_SIZE 8 -#define EFI_MP_SERVICES_PROTOCOL_GUID \ - { \ - 0x3fdda605, 0xa76e, 0x4f46, { 0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08 } \ - } +#define EFI_MP_SERVICES_PROTOCOL_GUID \ + {0x3fdda605, 0xa76e, 0x4f46, {0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08}} #define PROCESSOR_AS_BSP_BIT 0x00000001 #define PROCESSOR_ENABLED_BIT 0x00000002 @@ -824,10 +798,8 @@ typedef struct EfiTime { UInt8 Pad2; } EfiTime; -#define EFI_FILE_INFO_GUID \ - { \ - 0x09576e92, 0x6d3f, 0x11d2, { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ - } +#define EFI_FILE_INFO_GUID \ + {0x09576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}} struct EfiFileInfo EFI_FINAL { /// @brief Structure size. @@ -895,8 +867,8 @@ typedef EfiStatusType EFI_API (*EfiMpServicesStartupThisAP)( IN Void* ProcedureArgument OPTIONAL, OUT Boolean* Finished OPTIONAL); typedef EfiStatusType EFI_API (*EfiMpServicesDisableThisAP)(IN struct _EfiMpServicesProtocol* Self, - IN UInt32 ProcessorNumber, - IN Boolean EnableAP, + IN UInt32 ProcessorNumber, + IN Boolean EnableAP, IN UInt32* HealthFlag OPTIONAL); typedef EfiStatusType EFI_API (*EfiMpServicesWhoAmI)(IN struct _EfiMpServicesProtocol* Self, diff --git a/src/kernel/HALKit/AMD64/CxxAbi.cpp b/src/kernel/HALKit/AMD64/CxxAbi.cpp index 50b6ccf2..c2487f85 100644 --- a/src/kernel/HALKit/AMD64/CxxAbi.cpp +++ b/src/kernel/HALKit/AMD64/CxxAbi.cpp @@ -11,7 +11,7 @@ #define kAtExitMaxDestructors (128U) atexit_func_entry_t __atexit_funcs[kAtExitMaxDestructors]; -uarch_t __atexit_func_count; +uarch_t __atexit_func_count; /// @brief dynamic shared object Handle. Kernel::UIntPtr __dso_handle; diff --git a/src/kernel/HALKit/AMD64/HalKernelMain.cpp b/src/kernel/HALKit/AMD64/HalKernelMain.cpp index 57f980c6..fabeb077 100644 --- a/src/kernel/HALKit/AMD64/HalKernelMain.cpp +++ b/src/kernel/HALKit/AMD64/HalKernelMain.cpp @@ -158,9 +158,11 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) { PEFLoader ldr("/system/init.out"); - if (ldr.IsLoaded()) rtl_create_user_process(ldr, UserProcess::ExecutableKind::kExecutableKind); - else ke_panic(RUNTIME_CHECK_PROCESS, "RuntimeCheck: Invalid Process Data!"); - + if (ldr.IsLoaded()) + rtl_create_user_process(ldr, UserProcess::ExecutableKind::kExecutableKind); + else + ke_panic(RUNTIME_CHECK_PROCESS, "RuntimeCheck: Invalid Process Data!"); + UserProcessScheduler::The().SwitchTeam(kMidUserTeam); #ifdef __HALKIT_INCLUDES_BNID__ diff --git a/src/kernel/HALKit/AMD64/HalKernelPanic.cpp b/src/kernel/HALKit/AMD64/HalKernelPanic.cpp index d9afa204..a5f0b8bc 100644 --- a/src/kernel/HALKit/AMD64/HalKernelPanic.cpp +++ b/src/kernel/HALKit/AMD64/HalKernelPanic.cpp @@ -45,19 +45,18 @@ Void RecoveryFactory::Recover() { HAL::rt_cli(); HAL::rt_halt(); } - + alreadyDumped = YES; - - HeFileSystemMgr mgr; - auto node = mgr.Open("/system/dump.dmp", "wb"); + HeFileSystemMgr mgr; + auto node = mgr.Open("/system/dump.dmp", "wb"); if (node && hal_read_cr2()) mgr.Write(node, hal_read_cr2(), 0, 0x100); if (node) mm_free_ptr(node); - + node = nullptr; #endif - + while (YES) { HAL::rt_cli(); HAL::rt_halt(); diff --git a/src/kernel/HALKit/AMD64/Paging.h b/src/kernel/HALKit/AMD64/Paging.h index f6ec0bf4..7b64835a 100644 --- a/src/kernel/HALKit/AMD64/Paging.h +++ b/src/kernel/HALKit/AMD64/Paging.h @@ -57,7 +57,9 @@ namespace Detail { kPageEnable = 31, }; - inline UInt8 control_register_cast(ControlRegisterBits reg) { return static_cast<UInt8>(reg); } + inline UInt8 control_register_cast(ControlRegisterBits reg) { + return static_cast<UInt8>(reg); + } } // namespace Detail auto mm_alloc_bitmap(Boolean wr, Boolean user, SizeT size, Bool is_page, SizeT pad = 0) -> VoidPtr; diff --git a/src/kernel/HALKit/ARM64/CxxAbi.cpp b/src/kernel/HALKit/ARM64/CxxAbi.cpp index 3c7c7952..7f8c8245 100644 --- a/src/kernel/HALKit/ARM64/CxxAbi.cpp +++ b/src/kernel/HALKit/ARM64/CxxAbi.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <KernelKit/DebugOutput.h> #include <KernelKit/KPC.h> #include <NeKit/CxxAbi.h> diff --git a/src/kernel/HALKit/ARM64/Paging.h b/src/kernel/HALKit/ARM64/Paging.h index 71e663ae..fd04c2da 100644 --- a/src/kernel/HALKit/ARM64/Paging.h +++ b/src/kernel/HALKit/ARM64/Paging.h @@ -41,14 +41,10 @@ /// Long format address range -#define cPageMAll \ - { 0b000, 0b000 } -#define cPageMToMax(M) \ - { M, 0b000 } -#define cPageMaxToM(M) \ - { 0b000, M } -#define cPageMToN(M, N) \ - { M, N } +#define cPageMAll {0b000, 0b000} +#define cPageMToMax(M) {M, 0b000} +#define cPageMaxToM(M) {0b000, M} +#define cPageMToN(M, N) {M, N} namespace Kernel::HAL { struct PACKED PTE_4KB final { @@ -86,7 +82,9 @@ namespace Detail { PageEnable = 31, }; - inline UInt8 control_register_cast(ControlRegisterBits reg) { return static_cast<UInt8>(reg); } + inline UInt8 control_register_cast(ControlRegisterBits reg) { + return static_cast<UInt8>(reg); + } } // namespace Detail struct PDE_4KB final { diff --git a/src/kernel/KernelKit/CoreProcessScheduler.h b/src/kernel/KernelKit/CoreProcessScheduler.h index 7ed23a92..71a75e1a 100644 --- a/src/kernel/KernelKit/CoreProcessScheduler.h +++ b/src/kernel/KernelKit/CoreProcessScheduler.h @@ -59,19 +59,11 @@ struct ProcessHeapTree final { 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> @@ -86,21 +78,13 @@ struct ProcessFileTree final { 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}; }; template <typename T> @@ -121,21 +105,13 @@ struct ProcessSpecialTree final { 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/DriveMgr.h b/src/kernel/KernelKit/DriveMgr.h index 082ffc95..76ee5dcf 100644 --- a/src/kernel/KernelKit/DriveMgr.h +++ b/src/kernel/KernelKit/DriveMgr.h @@ -73,7 +73,7 @@ struct DriveTrait final { Void (*fOutput)(DrivePacket& packet){nullptr}; Void (*fVerify)(DrivePacket& packet){nullptr}; Void (*fInit)(DrivePacket& packet){nullptr}; - const Char* (*fProtocol)(Void){nullptr}; + const Char* (*fProtocol)(Void) {nullptr}; }; namespace Probe { diff --git a/src/kernel/KernelKit/HardwareThreadScheduler.h b/src/kernel/KernelKit/HardwareThreadScheduler.h index 53a971e5..a9183cd2 100644 --- a/src/kernel/KernelKit/HardwareThreadScheduler.h +++ b/src/kernel/KernelKit/HardwareThreadScheduler.h @@ -64,10 +64,10 @@ class HardwareThread final { BOOL IsWakeup(); public: - HAL::StackFramePtr StackFrame(); + HAL::StackFramePtr StackFrame(); _Output const ThreadKind& Kind(); BOOL IsBusy(); - _Output const ThreadID& ID(); + _Output const ThreadID& ID(); private: HAL::StackFramePtr fStack{}; @@ -102,7 +102,7 @@ class HardwareThreadScheduler final : public ISchedulable { public: Ref<HardwareThread*> operator[](SizeT idx); bool operator!(); - operator bool(); + operator bool(); Bool IsUser() override { return Yes; } diff --git a/src/kernel/KernelKit/ILoader.h b/src/kernel/KernelKit/ILoader.h index f6e13023..9291340f 100644 --- a/src/kernel/KernelKit/ILoader.h +++ b/src/kernel/KernelKit/ILoader.h @@ -26,9 +26,9 @@ class ILoader { public: virtual _Output ErrorOr<VoidPtr> GetBlob() { return ErrorOr<VoidPtr>{}; } - virtual _Output const Char* AsString() { return "(null)"; } - virtual _Output const Char* MIME() { return "*/*"; } - virtual _Output const Char* Path() { return "(null)"; } + virtual _Output const Char* AsString() { return "(null)"; } + virtual _Output const Char* MIME() { return "*/*"; } + virtual _Output const Char* Path() { return "(null)"; } virtual _Output ErrorOr<VoidPtr> FindStart() { return ErrorOr<VoidPtr>{}; } virtual _Output ErrorOr<VoidPtr> FindSymbol(_Input const Char*, _Input Int32) { return ErrorOr<VoidPtr>{}; diff --git a/src/kernel/KernelKit/PCI/DMA.h b/src/kernel/KernelKit/PCI/DMA.h index 63b284cb..f27681de 100644 --- a/src/kernel/KernelKit/PCI/DMA.h +++ b/src/kernel/KernelKit/PCI/DMA.h @@ -47,7 +47,7 @@ class DMAWrapper final { T* Get(UIntPtr off = 0); public: - operator bool(); + operator bool(); bool operator!(); public: diff --git a/src/kernel/KernelKit/UserProcessScheduler.h b/src/kernel/KernelKit/UserProcessScheduler.h index ab3c713e..5018f1f6 100644 --- a/src/kernel/KernelKit/UserProcessScheduler.h +++ b/src/kernel/KernelKit/UserProcessScheduler.h @@ -63,10 +63,10 @@ class UserProcess final { IDylibObject* DylibDelegate{nullptr}; SizeT MemoryCursor{0UL}; SizeT MemoryLimit{kCPSMaxMemoryLimit}; - SizeT UsedMemory{0UL}; /// AMLALE: This should be thread-safe as well. - SizeT UsedFiles{0UL}; /// AMLALE: This is a thread-safe counter to track file allocation count. - UserProcessSignal Signal; - ProcessImage Image; + SizeT UsedMemory{0UL}; /// AMLALE: This should be thread-safe as well. + SizeT UsedFiles{0UL}; /// AMLALE: This is a thread-safe counter to track file allocation count. + UserProcessSignal Signal; + ProcessImage Image; private: ProcessFileTree<Any>* FileTree{nullptr}; @@ -207,8 +207,8 @@ class UserProcessTeam final { NE_COPY_DEFAULT(UserProcessTeam) Array<UserProcess, kCPSProcessLimitPerTeam>& AsArray(); - Ref<UserProcess>& AsRef(); - ProcessID& Id(); + Ref<UserProcess>& AsRef(); + ProcessID& Id(); public: UserProcessArray mProcessList; diff --git a/src/kernel/NeKit/Config.h b/src/kernel/NeKit/Config.h index caf17ebd..a855bf2a 100644 --- a/src/kernel/NeKit/Config.h +++ b/src/kernel/NeKit/Config.h @@ -17,7 +17,7 @@ #define NE_ICODEC \ final: \ - public \ + public \ ::Kernel::ICodec /// @brief The **NeKernel** namespace. @@ -113,12 +113,12 @@ inline Args&& move(Args&& arg) { template <class Type> concept IsSerializable = requires() { - {Type::kValue}; + { Type::kValue }; }; template <class Type> concept IsNotSerializable = requires() { - {!Type::kValue}; + { !Type::kValue }; }; /// @brief Encoding interface, used as a proxy to convert T to Char* diff --git a/src/kernel/NeKit/Macros.h b/src/kernel/NeKit/Macros.h index 4fb3a736..361afbda 100644 --- a/src/kernel/NeKit/Macros.h +++ b/src/kernel/NeKit/Macros.h @@ -16,7 +16,7 @@ #endif #ifndef kib_cast -#define kib_cast(X) (Kernel::UInt64)((X) *1024) +#define kib_cast(X) (Kernel::UInt64)((X) * 1024) #endif #ifndef MIB @@ -117,7 +117,7 @@ #define NE_UNUSED(X) ((Kernel::Void) X) #ifndef RGB -#define RGB(R, G, B) ((Kernel::UInt32)((0xFF << 24) | ((R) << 16) | ((G) << 8) | (B))) +#define RGB(R, G, B) ((Kernel::UInt32) ((0xFF << 24) | ((R) << 16) | ((G) << 8) | (B))) #endif // !RGB #ifdef __NE_AMD64__ diff --git a/src/kernel/NeKit/Utils.h b/src/kernel/NeKit/Utils.h index 0ac5acc5..3f387c33 100644 --- a/src/kernel/NeKit/Utils.h +++ b/src/kernel/NeKit/Utils.h @@ -55,9 +55,9 @@ inline constexpr SizeT oe_string_len(const CharType* str) { if (!str) return 0; #if __cplusplus == 202302L - if - consteval { return ARRAY_SIZE(str); } - else { + if consteval { + return ARRAY_SIZE(str); + } else { SizeT len{0}; while (str[len] != 0) ++len; return len; diff --git a/src/kernel/NeKit/Vettable.h b/src/kernel/NeKit/Vettable.h index 4cb1682d..a33a3ab3 100644 --- a/src/kernel/NeKit/Vettable.h +++ b/src/kernel/NeKit/Vettable.h @@ -16,14 +16,10 @@ namespace Kernel { template <class Type> -concept IsVettable = requires(Type) { - (Type::kVettable); -}; +concept IsVettable = requires(Type) { (Type::kVettable); }; template <class Type> -concept IsUnVettable = requires(Type) { - (Type::kUnvettable); -}; +concept IsUnVettable = requires(Type) { (Type::kUnvettable); }; } // namespace Kernel #endif // !__NE_KIT_VETTABLE_H__ diff --git a/src/kernel/src/ACPIFactoryInterface.cpp b/src/kernel/src/ACPIFactoryInterface.cpp index 53f7b9e0..9aa4e26e 100644 --- a/src/kernel/src/ACPIFactoryInterface.cpp +++ b/src/kernel/src/ACPIFactoryInterface.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <ArchKit/ArchKit.h> #include <KernelKit/HeapMgr.h> #include <NeKit/KString.h> diff --git a/src/kernel/src/AsciiUtils.cpp b/src/kernel/src/AsciiUtils.cpp index 83caa058..10b4c756 100644 --- a/src/kernel/src/AsciiUtils.cpp +++ b/src/kernel/src/AsciiUtils.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <NeKit/Utils.h> namespace Kernel { @@ -105,9 +104,7 @@ Int32 rt_to_lower(Int ch) { } Int32 rt_is_alnum(Int ch) { - return (ch >= 'a' && ch <= 'z') || - (ch >= 'A' && ch <= 'Z') || - (ch >= '0' && ch <= '9'); + return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'); } Boolean rt_is_space(Int ch) { diff --git a/src/kernel/src/CodeMgr.cpp b/src/kernel/src/CodeMgr.cpp index 8344fefc..e9eab8bd 100644 --- a/src/kernel/src/CodeMgr.cpp +++ b/src/kernel/src/CodeMgr.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <KernelKit/CodeMgr.h> #include <KernelKit/ProcessScheduler.h> #include <NeKit/Utils.h> diff --git a/src/kernel/src/FS/Ext2+IFS.cpp b/src/kernel/src/FS/Ext2+IFS.cpp index 30fb2f0d..4816119e 100644 --- a/src/kernel/src/FS/Ext2+IFS.cpp +++ b/src/kernel/src/FS/Ext2+IFS.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #ifndef __NE_MINIMAL_OS__ #ifdef __FSKIT_INCLUDES_EXT2__ @@ -18,17 +17,18 @@ #include <NeKit/Utils.h> /// @note There's no current maintainer of Ext2, the position is vacant. -/// @note AMLALE: @0xf00sec has written this driver, and I @amlel-el-mahrouss is currently working on adding triple indirect indices. +/// @note AMLALE: @0xf00sec has written this driver, and I @amlel-el-mahrouss is currently working +/// on adding triple indirect indices. /// @note AMLALE: This driver is too verbose, we need a complete overhaul of it. -constexpr static UInt32 EXT2_DIRECT_BLOCKS = 12; -constexpr static UInt32 EXT2_SINGLE_INDIRECT_INDEX = 12; -constexpr static UInt32 EXT2_DOUBLE_INDIRECT_INDEX = 13; -constexpr static UInt32 EXT2_TRIPLE_INDIRECT_INDEX = 14; -constexpr static UInt32 EXT2_ROOT_INODE = 2; -constexpr ATTRIBUTE(unused) static UInt32 EXT2_SUPERBLOCK_BLOCK = 1; -constexpr static UInt32 EXT2_GROUP_DESC_BLOCK_SMALL = 2; -constexpr static UInt32 EXT2_GROUP_DESC_BLOCK_LARGE = 1; +constexpr static UInt32 EXT2_DIRECT_BLOCKS = 12; +constexpr static UInt32 EXT2_SINGLE_INDIRECT_INDEX = 12; +constexpr static UInt32 EXT2_DOUBLE_INDIRECT_INDEX = 13; +constexpr static UInt32 EXT2_TRIPLE_INDIRECT_INDEX = 14; +constexpr static UInt32 EXT2_ROOT_INODE = 2; +constexpr ATTRIBUTE(unused) static UInt32 EXT2_SUPERBLOCK_BLOCK = 1; +constexpr static UInt32 EXT2_GROUP_DESC_BLOCK_SMALL = 2; +constexpr static UInt32 EXT2_GROUP_DESC_BLOCK_LARGE = 1; namespace Detail { static inline SizeT ext2_min(SizeT a, SizeT b) { @@ -521,8 +521,8 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node, mm_free_ptr(singlePtr); return ErrorOr<Void*>(nullptr); } else if (logicalBlockIndex < doubleStart + tripleSpan) { - UInt32 tripleLba = ext2_block_to_lba(ctx, node->inode.fBlock[EXT2_TRIPLE_INDIRECT_INDEX]); - auto triplePtrRef = ext2_read_block_ptr(ctx, node->inode.fBlock[EXT2_TRIPLE_INDIRECT_INDEX]); + UInt32 tripleLba = ext2_block_to_lba(ctx, node->inode.fBlock[EXT2_TRIPLE_INDIRECT_INDEX]); + auto triplePtrRef = ext2_read_block_ptr(ctx, node->inode.fBlock[EXT2_TRIPLE_INDIRECT_INDEX]); if (triplePtrRef.HasError()) { return ErrorOr<Void*>(kErrorDisk); @@ -536,7 +536,6 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node, mm_free_ptr(triplePtrRef.Leak().Leak()); } - return ErrorOr<Void*>(kErrorDisk); } diff --git a/src/kernel/src/FS/NeFS+FileMgr.cpp b/src/kernel/src/FS/NeFS+FileMgr.cpp index e42bd519..a0cf4ad0 100644 --- a/src/kernel/src/FS/NeFS+FileMgr.cpp +++ b/src/kernel/src/FS/NeFS+FileMgr.cpp @@ -50,7 +50,7 @@ NodePtr NeFileSystemMgr::Create(_Input const Char* path) { kout << "NeFS: Create called with null or empty path\n"; return nullptr; } - + return rtl_node_cast(mParser->CreateCatalog(path)); } @@ -62,7 +62,7 @@ NodePtr NeFileSystemMgr::CreateDirectory(const Char* path) { kout << "NeFS: CreateDirectory called with null or empty path\n"; return nullptr; } - + return rtl_node_cast(mParser->CreateCatalog(path, 0, kNeFSCatalogKindDir)); } @@ -74,7 +74,7 @@ NodePtr NeFileSystemMgr::CreateAlias(const Char* path) { kout << "NeFS: CreateAlias called with null or empty path\n"; return nullptr; } - + return rtl_node_cast(mParser->CreateCatalog(path, 0, kNeFSCatalogKindAlias)); } @@ -119,12 +119,12 @@ _Output NodePtr NeFileSystemMgr::Open(_Input const Char* path, _Input const Char kout << "NeFS: Open called with null or empty path\n"; return nullptr; } - + if (!r || *r == 0) { kout << "NeFS: Open called with null or empty mode string\n"; return nullptr; } - + auto catalog = mParser->GetCatalog(path); if (!catalog) { kout << "NeFS: Open could not find catalog for path\n"; diff --git a/src/kernel/src/FS/OpenHeFS+FileMgr.cpp b/src/kernel/src/FS/OpenHeFS+FileMgr.cpp index 551d69d1..a0a649eb 100644 --- a/src/kernel/src/FS/OpenHeFS+FileMgr.cpp +++ b/src/kernel/src/FS/OpenHeFS+FileMgr.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #ifndef __NE_MINIMAL_OS__ #ifdef __FSKIT_INCLUDES_OPENHEFS__ @@ -74,9 +73,7 @@ NodePtr HeFileSystemMgr::Create(_Input const Char* path) { err_local_get() = kErrorSuccess; - if (auto node = mParser->CreateINode(&mDriveTrait, 0, nullptr, out, 0); - node) - return nullptr; + if (auto node = mParser->CreateINode(&mDriveTrait, 0, nullptr, out, 0); node) return nullptr; kout << "OpenHeFS: ERROR: Check KPC.\r"; @@ -107,14 +104,12 @@ NodePtr HeFileSystemMgr::CreateDirectory(const Char* path) { err_local_get() = kErrorSuccess; - if (auto node = mParser->CreateINodeDirectory(&mDriveTrait, 0, out); - node) - return nullptr; + if (auto node = mParser->CreateINodeDirectory(&mDriveTrait, 0, out); node) return nullptr; kout << "OpenHeFS: ERROR: Check KPC.\r"; - err_local_get() = kErrorDiskIsFull; - + err_local_get() = kErrorDiskIsFull; + return nullptr; } @@ -126,7 +121,7 @@ NodePtr HeFileSystemMgr::CreateAlias(const Char* path) { kout << "OpenHeFS: CreateAlias called with null or empty path\r"; return nullptr; } - + // TODO: It needs its own helper! SizeT len = oe_string_len<Char>(path); @@ -140,14 +135,15 @@ NodePtr HeFileSystemMgr::CreateAlias(const Char* path) { err_local_get() = kErrorSuccess; - if (auto node = mParser->CreateINode(&mDriveTrait, kOpenHeFSFileKindSymbolicLink, nullptr, out, 0); - node) + if (auto node = + mParser->CreateINode(&mDriveTrait, kOpenHeFSFileKindSymbolicLink, nullptr, out, 0); + node) return nullptr; kout << "OpenHeFS: ERROR: Check KPC.\r"; - err_local_get() = kErrorDiskIsFull; - + err_local_get() = kErrorDiskIsFull; + return nullptr; } @@ -221,14 +217,14 @@ _Output VoidPtr HeFileSystemMgr::Read(_Input NodePtr node, _Input Int32 flags, _ return nullptr; } - /// @note name is not used in OpenHeFS to mark data offsets. That's an NeFS-ism. +/// @note name is not used in OpenHeFS to mark data offsets. That's an NeFS-ism. Void HeFileSystemMgr::Write(_Input const Char* name, _Input NodePtr node, _Input VoidPtr data, _Input Int32 flags, _Input SizeT size) { NE_UNUSED(node); - //NE_UNUSED(flags); - //NE_UNUSED(size); - //NE_UNUSED(name); - //NE_UNUSED(data); + // NE_UNUSED(flags); + // NE_UNUSED(size); + // NE_UNUSED(name); + // NE_UNUSED(data); if (!flags) return; if (!size) return; @@ -237,8 +233,8 @@ Void HeFileSystemMgr::Write(_Input const Char* name, _Input NodePtr node, _Input static IMountpoint mnt; io_construct_main_drive(mnt.A()); - - mParser->INodeManip(&mnt.A(), (VoidPtr)data, size, u8"/", (Char8*)name, 0, NO); + + mParser->INodeManip(&mnt.A(), (VoidPtr) data, size, u8"/", (Char8*) name, 0, NO); } _Output VoidPtr HeFileSystemMgr::Read(_Input const Char* name, _Input NodePtr node, @@ -257,8 +253,8 @@ _Output VoidPtr HeFileSystemMgr::Read(_Input const Char* name, _Input NodePtr no static IMountpoint mnt; io_construct_main_drive(mnt.A()); - mParser->INodeManip(&mnt.A(), (VoidPtr)retBlob, sz, u8"/", (Char8*)name, 0, YES); - + mParser->INodeManip(&mnt.A(), (VoidPtr) retBlob, sz, u8"/", (Char8*) name, 0, YES); + return retBlob; } @@ -273,7 +269,7 @@ _Output Bool HeFileSystemMgr::Seek(NodePtr node, SizeT off) { _Output SizeT HeFileSystemMgr::Tell(NodePtr node) { if (!node) return kFileMgrNPos; SizeT pos = 0ULL; - + return pos; } diff --git a/src/kernel/src/FS/OpenHeFS+FileSystemParser.cpp b/src/kernel/src/FS/OpenHeFS+FileSystemParser.cpp index e03657f7..b923d13f 100644 --- a/src/kernel/src/FS/OpenHeFS+FileSystemParser.cpp +++ b/src/kernel/src/FS/OpenHeFS+FileSystemParser.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #ifdef __FSKIT_INCLUDES_OPENHEFS__ #include <FSKit/OpenHeFS.h> diff --git a/src/kernel/src/FileMgr.cpp b/src/kernel/src/FileMgr.cpp index 4d109bf3..4dadf288 100644 --- a/src/kernel/src/FileMgr.cpp +++ b/src/kernel/src/FileMgr.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <KernelKit/FileMgr.h> #include <NeKit/Utils.h> diff --git a/src/kernel/src/GUIDWizard.cpp b/src/kernel/src/GUIDWizard.cpp index ad54d4bd..fd43d861 100644 --- a/src/kernel/src/GUIDWizard.cpp +++ b/src/kernel/src/GUIDWizard.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <CFKit/GUIDWizard.h> #include <NeKit/Ref.h> diff --git a/src/kernel/src/Gfx/FBDeviceInterface.cpp b/src/kernel/src/Gfx/FBDeviceInterface.cpp index 35688966..48bc1abd 100644 --- a/src/kernel/src/Gfx/FBDeviceInterface.cpp +++ b/src/kernel/src/Gfx/FBDeviceInterface.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <GfxKit/FB.h> using namespace Kernel; diff --git a/src/kernel/src/HeapMgr.cpp b/src/kernel/src/HeapMgr.cpp index c22d6cdd..a7430824 100644 --- a/src/kernel/src/HeapMgr.cpp +++ b/src/kernel/src/HeapMgr.cpp @@ -3,15 +3,14 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <ArchKit/ArchKit.h> #include <KernelKit/DebugOutput.h> #include <KernelKit/HeapMgr.h> #include <KernelKit/KPC.h> +#include <KernelKit/LockDelegate.h> #include <NeKit/Crc32.h> #include <NeKit/PageMgr.h> #include <NeKit/Utils.h> -#include <KernelKit/LockDelegate.h> /* ======================================== @@ -85,7 +84,7 @@ STATIC PageMgr kPageMgr; /// @param user User enable bit. /// @return The newly allocated pointer. _Output VoidPtr mm_alloc_ptr(SizeT sz, Bool wr, Bool user, SizeT pad_amount) { - static Bool locked = false; + static Bool locked = false; LockDelegate<255> lock{&locked}; auto sz_fix = sz; @@ -134,7 +133,7 @@ _Output VoidPtr mm_alloc_ptr(SizeT sz, Bool wr, Bool user, SizeT pad_amount) { /// @brief Controls the page's heap. /// @param heap_ptr the pointer to make a page heap. /// @return kErrorSuccess if successful, otherwise an error code. - _Output Int32 mm_ctl_page(VoidPtr heap_ptr, const Bool enable) { +_Output Int32 mm_ctl_page(VoidPtr heap_ptr, const Bool enable) { if (Detail::mm_check_ptr_address(heap_ptr) == No) return kErrorHeapNotPresent; Detail::MM_INFORMATION_BLOCK_PTR heap_info_ptr = diff --git a/src/kernel/src/InitializerList.cpp b/src/kernel/src/InitializerList.cpp index 42e3db6a..fada5851 100644 --- a/src/kernel/src/InitializerList.cpp +++ b/src/kernel/src/InitializerList.cpp @@ -3,5 +3,4 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <NeKit/InitializerList.h> diff --git a/src/kernel/src/KernelTask.cpp b/src/kernel/src/KernelTask.cpp index e733d64a..e73dce21 100644 --- a/src/kernel/src/KernelTask.cpp +++ b/src/kernel/src/KernelTask.cpp @@ -3,9 +3,8 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - -#include <KernelKit/KernelTask.h> #include <KernelKit/CodeMgr.h> +#include <KernelKit/KernelTask.h> /***********************************************************************************/ /// @file KernelTaskScheduler.cc @@ -14,15 +13,15 @@ /***********************************************************************************/ namespace Kernel { - + /// @internal @brief Calls the DDK stub to initialize the stack_frame of the driver. EXTERN_C Int32 kt_kernel_task_start(HAL::StackFramePtr stack_frame, VoidPtr code) { MUST_PASS(stack_frame && code); - ((rtl_kstart_kind)(code))(stack_frame); + ((rtl_kstart_kind) (code))(stack_frame); return stack_frame->R8; } - + Bool KernelTaskHelper::Start(KernelTask& task_ptr, const KID& kid) { if (!kid) return NO; diff --git a/src/kernel/src/Semaphore.cpp b/src/kernel/src/Semaphore.cpp index c353c223..8516e462 100644 --- a/src/kernel/src/Semaphore.cpp +++ b/src/kernel/src/Semaphore.cpp @@ -3,6 +3,4 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <KernelKit/Semaphore.h> - diff --git a/src/kernel/src/Storage/AHCIDeviceInterface.cpp b/src/kernel/src/Storage/AHCIDeviceInterface.cpp index 3e47ef45..3a48cadc 100644 --- a/src/kernel/src/Storage/AHCIDeviceInterface.cpp +++ b/src/kernel/src/Storage/AHCIDeviceInterface.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <StorageKit/AHCI.h> namespace Kernel { diff --git a/src/kernel/src/Swap/DiskSwap.cpp b/src/kernel/src/Swap/DiskSwap.cpp index 94991d20..b7733870 100644 --- a/src/kernel/src/Swap/DiskSwap.cpp +++ b/src/kernel/src/Swap/DiskSwap.cpp @@ -3,7 +3,6 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <KernelKit/FileMgr.h> #include <SwapKit/DiskSwap.h> diff --git a/src/kernel/src/UserMgr.cpp b/src/kernel/src/UserMgr.cpp index cceda53d..358a96c2 100644 --- a/src/kernel/src/UserMgr.cpp +++ b/src/kernel/src/UserMgr.cpp @@ -16,8 +16,8 @@ /// @brief Multi-user support. namespace Kernel { - namespace Detail { - struct UserPermissionControl; - struct UserPermissionElevator; - } -} +namespace Detail { + struct UserPermissionControl; + struct UserPermissionElevator; +} // namespace Detail +} // namespace Kernel diff --git a/src/kernel/src/ZXDCodeMgr.cpp b/src/kernel/src/ZXDCodeMgr.cpp index 59abc3c3..29599b1e 100644 --- a/src/kernel/src/ZXDCodeMgr.cpp +++ b/src/kernel/src/ZXDCodeMgr.cpp @@ -3,8 +3,5 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/ne-foss-org/nekernel - #include <KernelKit/CodeMgr.h> #include <KernelKit/ZXD.h> - - |
