diff options
| author | Amlal <amlal@nekernel.org> | 2025-04-25 13:08:33 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-04-25 13:08:33 +0200 |
| commit | fb790b07aeba8e22e4190cf3e1834d11ecde6c96 (patch) | |
| tree | 4cec7d1b321307b1d5935577631dae116a658a37 /public/frameworks | |
| parent | 63a2d92c5dfe976175cda024ec01905d11b43738 (diff) | |
dev: better .clang-format, ran format command.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'public/frameworks')
12 files changed, 353 insertions, 449 deletions
diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Array.h b/public/frameworks/CoreFoundation.fwrk/headers/Array.h index e9a36ac4..0b4a8dbf 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Array.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Array.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ @@ -8,64 +8,45 @@ #include <user/SystemCalls.h> -namespace CF -{ - template <typename T, SizeT N> - class CFArray final - { - public: - explicit CFArray() = default; - ~CFArray() = default; - - CFArray& operator=(const CFArray&) = default; - CFArray(const CFArray&) = default; - - T& operator[](SizeT at) - { - MUST_PASS(at < this->Count()); - return fArray[at]; - } - - Bool Empty() - { - return this->Count() > 0; - } - - SizeT Capacity() - { - return N; - } - - SizeT Count() - { - auto cnt = 0UL; - - for (auto i = 0UL; i < N; ++i) - { - if (fArray[i]) - ++cnt; - } - - return cnt; - } - - const T* CData() - { - return fArray; - } - - operator bool() - { - return !Empty(); - } - - private: - T fArray[N] = {nullptr}; - }; - - template <typename ValueType> - auto make_array(ValueType val) - { - return CFArray<ValueType, ARRAY_SIZE(val)>{val}; - } -} // namespace CF +namespace CF { +template <typename T, SizeT N> +class CFArray final { + public: + explicit CFArray() = default; + ~CFArray() = default; + + CFArray& operator=(const CFArray&) = default; + CFArray(const CFArray&) = default; + + T& operator[](SizeT at) { + MUST_PASS(at < this->Count()); + return fArray[at]; + } + + Bool Empty() { return this->Count() > 0; } + + SizeT Capacity() { return N; } + + SizeT Count() { + auto cnt = 0UL; + + for (auto i = 0UL; i < N; ++i) { + if (fArray[i]) ++cnt; + } + + return cnt; + } + + const T* CData() { return fArray; } + + operator bool() { return !Empty(); } + + private: + T fArray[N] = {nullptr}; +}; + +template <typename ValueType> +auto make_array(ValueType val) { + return CFArray<ValueType, ARRAY_SIZE(val)>{val}; +} +} // namespace CF diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Atom.h b/public/frameworks/CoreFoundation.fwrk/headers/Atom.h index 923d6bce..f279f0b1 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Atom.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Atom.h @@ -1,47 +1,33 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ #pragma once #include <CoreFoundation.fwrk/headers/Foundation.h> -namespace CF -{ - template <typename T> - class CFAtom final - { - public: - explicit CFAtom() = default; - ~CFAtom() = default; - - public: - CFAtom& operator=(const CFAtom&) = delete; - CFAtom(const CFAtom&) = delete; - - public: - T operator[](SizeT bit) - { - return (fArrayOfAtoms & (1 << bit)); - } - - void operator|(SizeT bit) - { - fArrayOfAtoms |= (1 << bit); - } - - friend Boolean operator==(CFAtom<T>& atomic, const T& idx) - { - return atomic[idx] == idx; - } - - friend Boolean operator!=(CFAtom<T>& atomic, const T& idx) - { - return atomic[idx] == idx; - } - - private: - T fArrayOfAtoms; - }; -} // namespace CF +namespace CF { +template <typename T> +class CFAtom final { + public: + explicit CFAtom() = default; + ~CFAtom() = default; + + public: + CFAtom& operator=(const CFAtom&) = delete; + CFAtom(const CFAtom&) = delete; + + public: + T operator[](SizeT bit) { return (fArrayOfAtoms & (1 << bit)); } + + void operator|(SizeT bit) { fArrayOfAtoms |= (1 << bit); } + + friend Boolean operator==(CFAtom<T>& atomic, const T& idx) { return atomic[idx] == idx; } + + friend Boolean operator!=(CFAtom<T>& atomic, const T& idx) { return atomic[idx] == idx; } + + private: + T fArrayOfAtoms; +}; +} // namespace CF diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h index b1c37635..194b7bb7 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h @@ -1,10 +1,10 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - FILE: Foundation.h - PURPOSE: Foundation header of the CF framework. + FILE: Foundation.h + PURPOSE: Foundation header of the CF framework. ------------------------------------------- */ @@ -12,68 +12,64 @@ #include <user/SystemCalls.h> -namespace CF -{ - class CFString; - class CFGUID; - class CFProperty; - class CFObject; +namespace CF { +class CFString; +class CFGUID; +class CFProperty; +class CFObject; - template <typename T> - class CFRef; - class CFFont; - struct CFPoint; - struct CFRect; - struct CFColor; +template <typename T> +class CFRef; +class CFFont; +struct CFPoint; +struct CFRect; +struct CFColor; #ifndef __LP64__ - typedef SInt32 CFInteger; - typedef float CFReal; +typedef SInt32 CFInteger; +typedef float CFReal; #else - typedef SInt64 CFInteger; - typedef double CFReal; +typedef SInt64 CFInteger; +typedef double CFReal; #endif - typedef SInt32 CFInteger32; - typedef SInt64 CFInteger64; +typedef SInt32 CFInteger32; +typedef SInt64 CFInteger64; - typedef Char CFChar8; - typedef char16_t CFChar16; +typedef Char CFChar8; +typedef char16_t CFChar16; - struct CFPoint - { - CFInteger64 x_1{0UL}; - CFInteger64 y_1{0UL}; +struct CFPoint { + CFInteger64 x_1{0UL}; + CFInteger64 y_1{0UL}; - CFInteger64 x_2{0UL}; - CFInteger64 y_2{0UL}; - CFReal ang{0UL}; + CFInteger64 x_2{0UL}; + CFInteger64 y_2{0UL}; + CFReal ang{0UL}; - operator bool(); + operator bool(); - /// @brief Check if point is within the current CFPoint. - /// @param point the current point to check. - /// @retval true if point is within this point. - /// @retval validations failed. - bool IsWithin(CFPoint& point); - }; + /// @brief Check if point is within the current CFPoint. + /// @param point the current point to check. + /// @retval true if point is within this point. + /// @retval validations failed. + bool IsWithin(CFPoint& point); +}; - struct CFColor final - { - CFInteger64 r, g, b, a{0}; - }; +struct CFColor final { + CFInteger64 r, g, b, a{0}; +}; - struct CFRect final - { - CFInteger64 x{0UL}; - CFInteger64 y{0UL}; +struct CFRect final { + CFInteger64 x{0UL}; + CFInteger64 y{0UL}; - CFInteger64 width{0UL}; - CFInteger64 height{0UL}; + CFInteger64 width{0UL}; + CFInteger64 height{0UL}; - operator bool(); + operator bool(); - BOOL SizeMatches(CFRect& rect) noexcept; - BOOL PositionMatches(CFRect& rect) noexcept; - }; -} // namespace CF
\ No newline at end of file + BOOL SizeMatches(CFRect& rect) noexcept; + BOOL PositionMatches(CFRect& rect) noexcept; +}; +} // namespace CF
\ No newline at end of file diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Object.h b/public/frameworks/CoreFoundation.fwrk/headers/Object.h index 733512b1..1692f20e 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Object.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Object.h @@ -1,7 +1,7 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ @@ -11,16 +11,14 @@ #define CF_OBJECT : public CF::CFObject -namespace CF -{ - class CFObject; +namespace CF { +class CFObject; - class CFObject - { - public: - explicit CFObject() = default; - virtual ~CFObject() = default; +class CFObject { + public: + explicit CFObject() = default; + virtual ~CFObject() = default; - SCI_COPY_DEFAULT(CFObject); - }; -} // namespace CF
\ No newline at end of file + SCI_COPY_DEFAULT(CFObject); +}; +} // namespace CF
\ No newline at end of file diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Property.h b/public/frameworks/CoreFoundation.fwrk/headers/Property.h index b999c54e..58e881e5 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Property.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Property.h @@ -1,53 +1,51 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ #ifndef _PROPS_H #define _PROPS_H -#include <user/SystemCalls.h> #include <CoreFoundation.fwrk/headers/Ref.h> +#include <user/SystemCalls.h> #define kMaxPropLen (256U) -namespace CF -{ - class CFString; - class CFProperty; - class CFGUID; - - template <typename Cls, SizeT N> - class CFArray; - - /// @brief handle to anything (number, ptr, string...) - using CFPropertyId = UIntPtr; - - /// @brief User property class. - /// @example /prop/foo or /prop/bar - class CFProperty final CF_OBJECT - { - public: - CFProperty(); - virtual ~CFProperty(); - - public: - CFProperty& operator=(const CFProperty&) = default; - CFProperty(const CFProperty&) = default; - - Bool StringEquals(CFString& name); - CFPropertyId& GetValue(); - CFString& GetKey(); - - private: - CFString* fName{nullptr}; - CFPropertyId fValue{0UL}; - Ref<CFGUID> fGUID{}; - }; - - template <SizeT N> - using CFPropertyArray = CFArray<CFProperty, N>; -} // namespace CF - -#endif // !CFKIT_PROPS_H +namespace CF { +class CFString; +class CFProperty; +class CFGUID; + +template <typename Cls, SizeT N> +class CFArray; + +/// @brief handle to anything (number, ptr, string...) +using CFPropertyId = UIntPtr; + +/// @brief User property class. +/// @example /prop/foo or /prop/bar +class CFProperty final CF_OBJECT { + public: + CFProperty(); + virtual ~CFProperty(); + + public: + CFProperty& operator=(const CFProperty&) = default; + CFProperty(const CFProperty&) = default; + + Bool StringEquals(CFString& name); + CFPropertyId& GetValue(); + CFString& GetKey(); + + private: + CFString* fName{nullptr}; + CFPropertyId fValue{0UL}; + Ref<CFGUID> fGUID{}; +}; + +template <SizeT N> +using CFPropertyArray = CFArray<CFProperty, N>; +} // namespace CF + +#endif // !CFKIT_PROPS_H diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h index 2a4ec452..c18c6161 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h @@ -1,110 +1,81 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ #ifndef _REF_H_ #define _REF_H_ -#include <user/SystemCalls.h> #include <CoreFoundation.fwrk/headers/Object.h> +#include <user/SystemCalls.h> + +namespace CF { +template <typename T> +class CFRef; + +template <typename T> +class CFRef final CF_OBJECT { + public: + CFRef() = default; + + ~CFRef() { + if (MmGetHeapFlags(fClass) != -1) delete fClass; + } + + public: + CFRef(T* cls) : fClass(cls) {} + + CFRef(T cls) : fClass(&cls) {} + + CFRef& operator=(T ref) { + if (!fClass) return *this; + + fClass = &ref; + return *this; + } + + public: + T operator->() const { + MUST_PASS(*fClass); + return *fClass; + } + + T& Leak() noexcept { return *fClass; } + + T& TryLeak() const noexcept { + MUST_PASS(*fClass); + return *fClass; + } + + T operator*() { return *fClass; } + + operator bool() noexcept { return fClass; } + + private: + T* fClass{nullptr}; +}; + +template <typename T> +class CFNonNullRef final { + public: + CFNonNullRef() = delete; + CFNonNullRef(nullPtr) = delete; + + CFNonNullRef(T* ref) : fRef(ref) { MUST_PASS(ref); } + + CFRef<T>& operator->() { + MUST_PASS(fRef); + return fRef; + } + + CFNonNullRef& operator=(const CFNonNullRef<T>& ref) = delete; + CFNonNullRef(const CFNonNullRef<T>& ref) = default; + + private: + CFRef<T> fRef{nullptr}; +}; +} // namespace CF -namespace CF -{ - template <typename T> - class CFRef; - - template <typename T> - class CFRef final CF_OBJECT - { - public: - CFRef() = default; - - ~CFRef() - { - if (MmGetHeapFlags(fClass) != -1) - delete fClass; - } - - public: - CFRef(T* cls) - : fClass(cls) - { - } - - CFRef(T cls) - : fClass(&cls) - { - } - - CFRef& operator=(T ref) - { - if (!fClass) - return *this; - - fClass = &ref; - return *this; - } - - public: - T operator->() const - { - MUST_PASS(*fClass); - return *fClass; - } - - T& Leak() noexcept - { - return *fClass; - } - - T& TryLeak() const noexcept - { - MUST_PASS(*fClass); - return *fClass; - } - - T operator*() - { - return *fClass; - } - - operator bool() noexcept - { - return fClass; - } - - private: - T* fClass{nullptr}; - }; - - template <typename T> - class CFNonNullRef final - { - public: - CFNonNullRef() = delete; - CFNonNullRef(nullPtr) = delete; - - CFNonNullRef(T* ref) - : fRef(ref) - { - MUST_PASS(ref); - } - - CFRef<T>& operator->() - { - MUST_PASS(fRef); - return fRef; - } - - CFNonNullRef& operator=(const CFNonNullRef<T>& ref) = delete; - CFNonNullRef(const CFNonNullRef<T>& ref) = default; - - private: - CFRef<T> fRef{nullptr}; - }; -} // namespace CF - -#endif // ifndef _NEWKIT_REF_H_ +#endif // ifndef _NEWKIT_REF_H_ diff --git a/public/frameworks/CoreFoundation.fwrk/headers/String.h b/public/frameworks/CoreFoundation.fwrk/headers/String.h index e420ac91..c28c05cd 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/String.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/String.h @@ -1,7 +1,7 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ @@ -9,12 +9,10 @@ #include <CoreFoundation.fwrk/headers/Object.h> -namespace CF -{ - class CFString; +namespace CF { +class CFString; - class CFString final CF_OBJECT - { - public: - }; -} // namespace CF
\ No newline at end of file +class CFString final CF_OBJECT { + public: +}; +} // namespace CF
\ No newline at end of file diff --git a/public/frameworks/CoreFoundation.fwrk/src/Foundation.cc b/public/frameworks/CoreFoundation.fwrk/src/Foundation.cc index 89adf665..a4b84abf 100644 --- a/public/frameworks/CoreFoundation.fwrk/src/Foundation.cc +++ b/public/frameworks/CoreFoundation.fwrk/src/Foundation.cc @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024 Amlal El Mahrouss, all rights reserved + Copyright (C) 2024 Amlal El Mahrouss, all rights reserved ------------------------------------------- */ @@ -9,25 +9,22 @@ /***********************************************************************************/ /// @brief returns true if the proportions are valid. /***********************************************************************************/ -CF::CFRect::operator bool() -{ - return width > 0 && height > 0; +CF::CFRect::operator bool() { + return width > 0 && height > 0; } /***********************************************************************************/ /// @brief returns true if size matches. /***********************************************************************************/ -BOOL CF::CFRect::SizeMatches(CF::CFRect& rect) noexcept -{ - return rect.height == height && rect.width == width; +BOOL CF::CFRect::SizeMatches(CF::CFRect& rect) noexcept { + return rect.height == height && rect.width == width; } /***********************************************************************************/ /// @brief returns true if position matches. /***********************************************************************************/ -BOOL CF::CFRect::PositionMatches(CF::CFRect& rect) noexcept -{ - return rect.y == y && rect.x == x; +BOOL CF::CFRect::PositionMatches(CF::CFRect& rect) noexcept { + return rect.y == y && rect.x == x; } /***********************************************************************************/ @@ -36,16 +33,14 @@ BOOL CF::CFRect::PositionMatches(CF::CFRect& rect) noexcept /// @retval true if point is within this point. /// @retval the validations have failed, false otherwise true. /***********************************************************************************/ -BOOL CF::CFPoint::IsWithin(CF::CFPoint& withinOf) -{ - return x_1 >= withinOf.x_1 && x_2 <= (withinOf.x_2) && - y_1 >= withinOf.y_1 && y_2 <= (withinOf.y_2); +BOOL CF::CFPoint::IsWithin(CF::CFPoint& withinOf) { + return x_1 >= withinOf.x_1 && x_2 <= (withinOf.x_2) && y_1 >= withinOf.y_1 && + y_2 <= (withinOf.y_2); } /***********************************************************************************/ /// @brief if Point object is correctly set up. /***********************************************************************************/ -CF::CFPoint::operator bool() -{ - return x_1 > x_2 && y_1 > y_2; +CF::CFPoint::operator bool() { + return x_1 > x_2 && y_1 > y_2; }
\ No newline at end of file diff --git a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h index c0566485..78b39bf8 100644 --- a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h +++ b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h @@ -1,51 +1,49 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + + FILE: DiskImage.h + PURPOSE: Disk Imaging framework. - FILE: DiskImage.h - PURPOSE: Disk Imaging framework. - ------------------------------------------- */ #pragma once #include <user/SystemCalls.h> -#define kDISectorSz (512) -#define kDIMinDiskSz mib_cast(1) +#define kDISectorSz (512) +#define kDIMinDiskSz mib_cast(1) #define kDIDefaultOutputName "disk.eimg" -#define kDIDefaultDiskName "Disk" -#define kDISuccessStatus (0) -#define kDIFailureStatus (1) +#define kDIDefaultDiskName "Disk" +#define kDISuccessStatus (0) +#define kDIFailureStatus (1) #define kDIDiskNameLen (16) -#define kDIOutNameLen (256) - -namespace DI -{ - /// @brief Disk Image file structure. - /// @param disk_name Disk partition name. - /// @param sector_sz Disk sector_sz. - /// @param block_cnt Disk block count. - /// @param disk_sz Disk size. - /// @param out_name Output file name. - struct DI_DISK_IMAGE - { - Char disk_name[kDIDiskNameLen] = kDIDefaultDiskName; - SInt32 sector_sz = kDISectorSz; - SInt32 block_cnt = 0; - SizeT disk_sz = kDIMinDiskSz; - Char out_name[kDIOutNameLen] = kDIDefaultOutputName; - }; - - /// @brief Format with an EPM partition. - /// @param img disk image structure. - /// @return Status code upon completion. - SInt32 DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) noexcept; - - /// @brief NeFS format over EPM. - /// @param img disk image structure. - /// @return Status code upon completion. - SInt32 DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept; - -} // namespace DI +#define kDIOutNameLen (256) + +namespace DI { +/// @brief Disk Image file structure. +/// @param disk_name Disk partition name. +/// @param sector_sz Disk sector_sz. +/// @param block_cnt Disk block count. +/// @param disk_sz Disk size. +/// @param out_name Output file name. +struct DI_DISK_IMAGE { + Char disk_name[kDIDiskNameLen] = kDIDefaultDiskName; + SInt32 sector_sz = kDISectorSz; + SInt32 block_cnt = 0; + SizeT disk_sz = kDIMinDiskSz; + Char out_name[kDIOutNameLen] = kDIDefaultOutputName; +}; + +/// @brief Format with an EPM partition. +/// @param img disk image structure. +/// @return Status code upon completion. +SInt32 DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) noexcept; + +/// @brief NeFS format over EPM. +/// @param img disk image structure. +/// @return Status code upon completion. +SInt32 DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept; + +} // namespace DI diff --git a/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc b/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc index 4d2a6694..a1182e64 100644 --- a/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc +++ b/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc @@ -1,53 +1,46 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - FILE: DiskImage+EPM.cc - PURPOSE: Disk Imaging framework. + FILE: DiskImage+EPM.cc + PURPOSE: Disk Imaging framework. ------------------------------------------- */ #include <DiskImage.fwrk/headers/DiskImage.h> -#include <FirmwareKit/EPM.h> #include <FSKit/NeFS.h> +#include <FirmwareKit/EPM.h> /// @brief EPM format disk /// @param img disk image structure. /// @return Status code upon completion. -SInt32 DI::DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) noexcept -{ - if (!img.sector_sz || (img.sector_sz % 512 != 0)) - return kDIFailureStatus; +SInt32 DI::DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) noexcept { + if (!img.sector_sz || (img.sector_sz % 512 != 0)) return kDIFailureStatus; - if (*img.out_name == 0 || - *img.disk_name == 0) - return kDIFailureStatus; + if (*img.out_name == 0 || *img.disk_name == 0) return kDIFailureStatus; - struct ::EPM_PART_BLOCK block - { - }; + struct ::EPM_PART_BLOCK block {}; - block.NumBlocks = img.block_cnt; - block.SectorSz = img.sector_sz; - block.Version = kEPMRevisionBcd; - block.LbaStart = sizeof(struct ::EPM_PART_BLOCK); - block.LbaEnd = img.disk_sz - block.LbaStart; - block.FsVersion = kNeFSVersionInteger; + block.NumBlocks = img.block_cnt; + block.SectorSz = img.sector_sz; + block.Version = kEPMRevisionBcd; + block.LbaStart = sizeof(struct ::EPM_PART_BLOCK); + block.LbaEnd = img.disk_sz - block.LbaStart; + block.FsVersion = kNeFSVersionInteger; - ::MmCopyMemory(block.Name, (VoidPtr)img.disk_name, ::MmStrLen(img.disk_name)); - ::MmCopyMemory(block.Magic, (VoidPtr)kEPMMagic86, ::MmStrLen(kEPMMagic86)); + ::MmCopyMemory(block.Name, (VoidPtr) img.disk_name, ::MmStrLen(img.disk_name)); + ::MmCopyMemory(block.Magic, (VoidPtr) kEPMMagic86, ::MmStrLen(kEPMMagic86)); - IORef handle = IoOpenFile(img.out_name, nullptr); + IORef handle = IoOpenFile(img.out_name, nullptr); - if (!handle) - return kDIFailureStatus; + if (!handle) return kDIFailureStatus; - ::IoWriteFile(handle, (Char*)&block, sizeof(struct ::EPM_PART_BLOCK)); + ::IoWriteFile(handle, (Char*) &block, sizeof(struct ::EPM_PART_BLOCK)); - ::IoCloseFile(handle); + ::IoCloseFile(handle); - handle = nullptr; + handle = nullptr; - return kDISuccessStatus; + return kDISuccessStatus; } diff --git a/public/frameworks/DiskImage.fwrk/src/DiskImage+NeFS.cc b/public/frameworks/DiskImage.fwrk/src/DiskImage+NeFS.cc index 4928c878..bee84cca 100644 --- a/public/frameworks/DiskImage.fwrk/src/DiskImage+NeFS.cc +++ b/public/frameworks/DiskImage.fwrk/src/DiskImage+NeFS.cc @@ -1,64 +1,57 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - FILE: DiskImage+NeFS.cc - PURPOSE: Disk Imaging framework. + FILE: DiskImage+NeFS.cc + PURPOSE: Disk Imaging framework. ------------------------------------------- */ #include <DiskImage.fwrk/headers/DiskImage.h> -#include <FirmwareKit/EPM.h> #include <FSKit/NeFS.h> +#include <FirmwareKit/EPM.h> /// @brief NeFS format over EPM. /// @param img disk image structure. /// @return Status code upon completion. -SInt32 DI::DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept -{ - if (!img.sector_sz || (img.sector_sz % 512 != 0)) - return kDIFailureStatus; +SInt32 DI::DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept { + if (!img.sector_sz || (img.sector_sz % 512 != 0)) return kDIFailureStatus; - if (*img.out_name == 0 || - *img.disk_name == 0) - return kDIFailureStatus; + if (*img.out_name == 0 || *img.disk_name == 0) return kDIFailureStatus; - struct ::NEFS_ROOT_PARTITION_BLOCK rpb - { - }; + struct ::NEFS_ROOT_PARTITION_BLOCK rpb {}; - ::MmCopyMemory(rpb.PartitionName, (VoidPtr)img.disk_name, ::MmStrLen(img.disk_name)); - ::MmCopyMemory(rpb.Ident, (VoidPtr)kNeFSIdent, ::MmStrLen(kNeFSIdent)); + ::MmCopyMemory(rpb.PartitionName, (VoidPtr) img.disk_name, ::MmStrLen(img.disk_name)); + ::MmCopyMemory(rpb.Ident, (VoidPtr) kNeFSIdent, ::MmStrLen(kNeFSIdent)); - rpb.Version = kNeFSVersionInteger; - rpb.EpmBlock = kEPMBootBlockLba; + rpb.Version = kNeFSVersionInteger; + rpb.EpmBlock = kEPMBootBlockLba; - rpb.StartCatalog = kNeFSCatalogStartAddress; - rpb.CatalogCount = 0; + rpb.StartCatalog = kNeFSCatalogStartAddress; + rpb.CatalogCount = 0; - rpb.DiskSize = img.disk_sz; + rpb.DiskSize = img.disk_sz; - rpb.SectorSize = img.sector_sz; - rpb.SectorCount = rpb.DiskSize / rpb.SectorSize; + rpb.SectorSize = img.sector_sz; + rpb.SectorCount = rpb.DiskSize / rpb.SectorSize; - rpb.FreeSectors = rpb.SectorCount; - rpb.FreeCatalog = rpb.DiskSize / sizeof(NEFS_CATALOG_STRUCT); + rpb.FreeSectors = rpb.SectorCount; + rpb.FreeCatalog = rpb.DiskSize / sizeof(NEFS_CATALOG_STRUCT); - IORef handle = IoOpenFile(img.out_name, nullptr); + IORef handle = IoOpenFile(img.out_name, nullptr); - if (!handle) - return kDIFailureStatus; + if (!handle) return kDIFailureStatus; - UInt64 p_prev = ::IoTellFile(handle); + UInt64 p_prev = ::IoTellFile(handle); - ::IoWriteFile(handle, (Char*)&rpb, sizeof(struct ::NEFS_ROOT_PARTITION_BLOCK)); + ::IoWriteFile(handle, (Char*) &rpb, sizeof(struct ::NEFS_ROOT_PARTITION_BLOCK)); - ::IoSeekFile(handle, p_prev); + ::IoSeekFile(handle, p_prev); - ::IoCloseFile(handle); + ::IoCloseFile(handle); - handle = nullptr; + handle = nullptr; - return kDISuccessStatus; + return kDISuccessStatus; }
\ No newline at end of file diff --git a/public/frameworks/KernelTest.fwrk/headers/KernelTest.h b/public/frameworks/KernelTest.fwrk/headers/KernelTest.h index e3200032..808d127e 100644 --- a/public/frameworks/KernelTest.fwrk/headers/KernelTest.h +++ b/public/frameworks/KernelTest.fwrk/headers/KernelTest.h @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ @@ -12,27 +12,24 @@ /// @file KernelTest.h #define KT_TEST_VERSION_BCD (0x0001) -#define KT_TEST_VERSION "0.0.1" +#define KT_TEST_VERSION "0.0.1" #define KT_TEST_FAILURE (1) #define KT_TEST_SUCCESS (0) #define KT_DECL_TEST(NAME, FN) \ - class KT_##NAME final \ - { \ - public: \ - void Run(); \ - const char* ToString(); \ - }; \ - inline void KT_##NAME::Run() \ - { \ - MUST_PASS(FN() == true); \ - } \ - inline const char* KT_##NAME::ToString() \ - { \ - return #FN; \ - } + class KT_##NAME final { \ + public: \ + void Run(); \ + const char* ToString(); \ + }; \ + inline void KT_##NAME::Run() { \ + MUST_PASS(FN() == true); \ + } \ + inline const char* KT_##NAME::ToString() { \ + return #FN; \ + } KT_DECL_TEST(ALWAYS_BREAK, []() -> bool { return false; }); KT_DECL_TEST(ALWAYS_GOOD, []() -> bool { return true; });
\ No newline at end of file |
