diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-26 10:08:33 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-26 10:08:33 +0100 |
| commit | 9e746d42d2e3faa526f12ba222f5ee6924dd30f9 (patch) | |
| tree | 7f1a83f69562a2725bb9cda27c31d120640d2c1c | |
| parent | 731758b271233b9c11052001ffc20a5a2ca1f365 (diff) | |
feat! breaking API changes, use header guards and libSystem fixes.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
135 files changed, 1215 insertions, 812 deletions
diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Array.h b/public/frameworks/CoreFoundation.fwrk/headers/Array.h index 1b3e4818..dab81fc3 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Array.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Array.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_ARRAY_H +#define HEADERS_ARRAY_H #include <libSystem/SystemKit/System.h> @@ -50,3 +51,5 @@ inline auto make_array(ValueType val) { return CFArray<ValueType, ARRAY_SIZE(val)>{val}; } } // namespace CF + +#endif diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Atom.h b/public/frameworks/CoreFoundation.fwrk/headers/Atom.h index 5b398d1e..f9fdf1d6 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Atom.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Atom.h @@ -3,7 +3,8 @@ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once +#ifndef HEADERS_ATOM_H +#define HEADERS_ATOM_H #include <CoreFoundation.fwrk/headers/Foundation.h> @@ -31,3 +32,5 @@ class CFAtom final { T fArrayOfAtoms; }; } // namespace CF + +#endif diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Dictionary.h b/public/frameworks/CoreFoundation.fwrk/headers/Dictionary.h index fef51f21..e00260ec 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Dictionary.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Dictionary.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_DICTIONARY_H +#define HEADERS_DICTIONARY_H #include <libSystem/SystemKit/System.h> @@ -38,3 +39,5 @@ inline auto make_dict() { return CFDictionary<KeyType, ValueType>{}; } } // namespace CF + +#endif diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h index d11697db..d3340e1b 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Foundation.h @@ -8,7 +8,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_FOUNDATION_H +#define HEADERS_FOUNDATION_H #include <libSystem/SystemKit/System.h> @@ -86,4 +87,6 @@ union CFGuid final { UInt8 fMs4[8]; } fUuid; }; -} // namespace CF
\ No newline at end of file +} // namespace CF + +#endif diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Object.h b/public/frameworks/CoreFoundation.fwrk/headers/Object.h index 0bf02e1c..c13ed383 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Object.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Object.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_OBJECT_H +#define HEADERS_OBJECT_H #include <CoreFoundation.fwrk/headers/Foundation.h> @@ -24,3 +25,5 @@ class CFObject { virtual const Char* Name() { return "[\"CFObject\"];"; } }; } // namespace CF + +#endif diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Property.h b/public/frameworks/CoreFoundation.fwrk/headers/Property.h index 28315938..3e9bc3ed 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Property.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Property.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_PROPERTY_H +#define HEADERS_PROPERTY_H #include <CoreFoundation.fwrk/headers/Foundation.h> #include <CoreFoundation.fwrk/headers/Ref.h> @@ -50,3 +51,5 @@ class CFProperty final CF_OBJECT { template <SizeT N> using CFPropertyArray = CFArray<CFProperty, N>; } // namespace CF + +#endif diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h index 0bc728ce..13226d3e 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_REF_H +#define HEADERS_REF_H #include <CoreFoundation.fwrk/headers/Object.h> #include <libSystem/SystemKit/System.h> @@ -83,3 +84,5 @@ class CFNonNullRef final { CFRef<T> fRef{nullptr}; }; } // namespace CF + +#endif diff --git a/public/frameworks/CoreFoundation.fwrk/headers/String.h b/public/frameworks/CoreFoundation.fwrk/headers/String.h index 2a44d1cb..55c70cac 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/String.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/String.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_STRING_H +#define HEADERS_STRING_H #include <CoreFoundation.fwrk/headers/Object.h> #include <CoreFoundation.fwrk/headers/Ref.h> @@ -45,4 +46,6 @@ class CFStringBuilder final { static BOOL Equals(const Char, const Char*); static BOOL Equals(const Char*, const Char*); }; -} // namespace CF
\ No newline at end of file +} // namespace CF + +#endif diff --git a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h index 2ed66345..796cd545 100644 --- a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h +++ b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h @@ -7,7 +7,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_DISKIMAGE_H +#define HEADERS_DISKIMAGE_H #include <libSystem/SystemKit/System.h> @@ -58,3 +59,5 @@ SInt32 DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img); SInt32 DIFormatFilesystemOpenHeFS(struct DI_DISK_IMAGE& img); } // namespace DI + +#endif diff --git a/public/frameworks/KernelTest.fwrk/headers/Foundation.h b/public/frameworks/KernelTest.fwrk/headers/Foundation.h index 3bc7225d..7737e584 100644 --- a/public/frameworks/KernelTest.fwrk/headers/Foundation.h +++ b/public/frameworks/KernelTest.fwrk/headers/Foundation.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_FOUNDATION_H +#define HEADERS_FOUNDATION_H #include <libSystem/SystemKit/Err.h> #include <libSystem/SystemKit/System.h> @@ -17,3 +18,5 @@ #define KT_TEST_SUCCESS (kErrorSuccess) #define KT_TEST_FAILURE (kErrorSuccess + 1) + +#endif diff --git a/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h b/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h index 39fdafbb..eb6b8648 100644 --- a/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h +++ b/public/frameworks/KernelTest.fwrk/headers/SourceLocation.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_SOURCELOCATION_H +#define HEADERS_SOURCELOCATION_H #include <KernelTest.fwrk/headers/Foundation.h> @@ -31,4 +32,6 @@ class KTSourceLocation final CF_OBJECT { private: CF::CFString mFile{4096}; SInt32 mLine{0U}; -};
\ No newline at end of file +}; + +#endif diff --git a/public/frameworks/KernelTest.fwrk/headers/TestCase.h b/public/frameworks/KernelTest.fwrk/headers/TestCase.h index 077fb960..54a8e8fd 100644 --- a/public/frameworks/KernelTest.fwrk/headers/TestCase.h +++ b/public/frameworks/KernelTest.fwrk/headers/TestCase.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_TESTCASE_H +#define HEADERS_TESTCASE_H #include <KernelTest.fwrk/headers/SourceLocation.h> @@ -51,4 +52,6 @@ KT_DECL_TEST(AlwaysBreak, []() -> bool { KT_DECL_TEST(AlwaysPass, []() -> bool { KT_MUST_PASS("AlwaysPass", YES, YES); return YES; -});
\ No newline at end of file +}); + +#endif diff --git a/public/frameworks/LaunchHelpers.fwrk/headers/Foundation.h b/public/frameworks/LaunchHelpers.fwrk/headers/Foundation.h index e0cdcc64..421bb0cc 100644 --- a/public/frameworks/LaunchHelpers.fwrk/headers/Foundation.h +++ b/public/frameworks/LaunchHelpers.fwrk/headers/Foundation.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HEADERS_FOUNDATION_H +#define HEADERS_FOUNDATION_H #include <CoreFoundation.fwrk/headers/Foundation.h> #include <CoreFoundation.fwrk/headers/String.h> @@ -43,4 +44,6 @@ using LHLaunchInfoPtr = LHLaunchInfo*; /// @brief Get launch information. /// @return the launch information structure. CF::CFRef<LHLaunchInfo> LHGetLaunchInfo(Void); -} // namespace LaunchHelpers
\ No newline at end of file +} // namespace LaunchHelpers + +#endif diff --git a/public/tools/diutil/vendor/Dialogs.h b/public/tools/diutil/vendor/Dialogs.h index e5e6d83a..d1bbd7a2 100644 --- a/public/tools/diutil/vendor/Dialogs.h +++ b/public/tools/diutil/vendor/Dialogs.h @@ -10,7 +10,8 @@ // See http://www.wtfpl.net/ for more details. // -#pragma once +#ifndef VENDOR_DIALOGS_H +#define VENDOR_DIALOGS_H #if _WIN32 #ifndef WIN32_LEAN_AND_MEAN @@ -1735,4 +1736,6 @@ inline std::string select_folder::result() { #endif // PFD_SKIP_IMPLEMENTATION -} // namespace pfd
\ No newline at end of file +} // namespace pfd + +#endif diff --git a/src/boot/BootKit/BootThread.h b/src/boot/BootKit/BootThread.h index abe4d653..cde4e65e 100644 --- a/src/boot/BootKit/BootThread.h +++ b/src/boot/BootKit/BootThread.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef BOOTKIT_BOOTTHREAD_H +#define BOOTKIT_BOOTTHREAD_H #include <FirmwareKit/Handover.h> #include <KernelKit/MSDOS.h> @@ -39,3 +40,5 @@ class BootThread final { HEL::BootInfoHeader* fHandover{nullptr}; }; } // namespace Boot + +#endif diff --git a/src/boot/BootKit/HW/ATA.h b/src/boot/BootKit/HW/ATA.h index 1842300b..db35fa64 100644 --- a/src/boot/BootKit/HW/ATA.h +++ b/src/boot/BootKit/HW/ATA.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef BOOTKIT_ATA_H +#define BOOTKIT_ATA_H #include <BootKit/Device.h> #include <modules/ATA/ATA.h> @@ -44,4 +45,6 @@ class BootDeviceATA final : public Device { private: ATATrait mTrait; }; -} // namespace Boot
\ No newline at end of file +} // namespace Boot + +#endif diff --git a/src/boot/BootKit/HW/SATA.h b/src/boot/BootKit/HW/SATA.h index 442ea399..90f7afbb 100644 --- a/src/boot/BootKit/HW/SATA.h +++ b/src/boot/BootKit/HW/SATA.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef BOOTKIT_SATA_H +#define BOOTKIT_SATA_H #include <BootKit/BootKit.h> #include <CompilerKit/CompilerKit.h> @@ -41,4 +42,6 @@ class BootDeviceSATA final { private: SATATrait mTrait; }; -} // namespace Boot
\ No newline at end of file +} // namespace Boot + +#endif diff --git a/src/boot/BootKit/Platform.h b/src/boot/BootKit/Platform.h index bfc738fc..242716c5 100644 --- a/src/boot/BootKit/Platform.h +++ b/src/boot/BootKit/Platform.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef BOOTKIT_PLATFORM_H +#define BOOTKIT_PLATFORM_H /** @file Platform.h @@ -30,3 +31,5 @@ EXTERN_C void rt_cld(); EXTERN_C void rt_std(); #endif /* ifdef __x86_64__ */ + +#endif diff --git a/src/boot/BootKit/Protocol.h b/src/boot/BootKit/Protocol.h index 0a049b77..6b4544ce 100644 --- a/src/boot/BootKit/Protocol.h +++ b/src/boot/BootKit/Protocol.h @@ -4,7 +4,10 @@ ======================================== */ -#pragma once +#ifndef BOOTKIT_PROTOCOL_H +#define BOOTKIT_PROTOCOL_H #include <FirmwareKit/EFI.h> #include <FirmwareKit/Handover.h> + +#endif diff --git a/src/boot/BootKit/QrPrelude.h b/src/boot/BootKit/QrPrelude.h index 7b09fdb0..0717db6a 100644 --- a/src/boot/BootKit/QrPrelude.h +++ b/src/boot/BootKit/QrPrelude.h @@ -4,6 +4,9 @@ ======================================== */ -#pragma once +#ifndef BOOTKIT_QRPRELUDE_H +#define BOOTKIT_QRPRELUDE_H -#include <BootKit/BitManip.h>
\ No newline at end of file +#include <BootKit/BitManip.h> + +#endif diff --git a/src/boot/BootKit/Support.h b/src/boot/BootKit/Support.h index 110b220c..b51112ef 100644 --- a/src/boot/BootKit/Support.h +++ b/src/boot/BootKit/Support.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef BOOTKIT_SUPPORT_H +#define BOOTKIT_SUPPORT_H /// @file Support.h /// @brief Purpose of this file is to help port libs into the bootloader. @@ -143,3 +144,5 @@ inline long StringToLong(const char* nptr, char** endptr, int base) { return (long) ((is_neg) ? -n : n); } + +#endif diff --git a/src/boot/modules/BootNet/BootNet.h b/src/boot/modules/BootNet/BootNet.h index 9fe1a186..b8498608 100644 --- a/src/boot/modules/BootNet/BootNet.h +++ b/src/boot/modules/BootNet/BootNet.h @@ -7,6 +7,9 @@ * ======================================================== */ -#pragma once +#ifndef BOOTNET_BOOTNET_H +#define BOOTNET_BOOTNET_H #include <FirmwareKit/NeBoot/BootNet.h> + +#endif diff --git a/src/kernel/ArchKit/ArchKit.h b/src/kernel/ArchKit/ArchKit.h index 375c5b44..b0ebda03 100644 --- a/src/kernel/ArchKit/ArchKit.h +++ b/src/kernel/ArchKit/ArchKit.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef ARCHKIT_ARCHKIT_H +#define ARCHKIT_ARCHKIT_H #include <NeKit/Array.h> #include <NeKit/Config.h> @@ -106,3 +107,5 @@ inline Kernel::VoidPtr kKernelVM = nullptr; #endif // __NE_VIRTUAL_MEMORY_SUPPORT__ inline Kernel::SizeT kBitMapCursor = 0UL; + +#endif diff --git a/src/kernel/CFKit/GUIDWizard.h b/src/kernel/CFKit/GUIDWizard.h index 901bd261..3418a68f 100644 --- a/src/kernel/CFKit/GUIDWizard.h +++ b/src/kernel/CFKit/GUIDWizard.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef CFKIT_GUIDWIZARD_H +#define CFKIT_GUIDWIZARD_H #include <CFKit/GUIDWrapper.h> #include <NeKit/Array.h> @@ -19,3 +20,5 @@ namespace Kernel::CF::XRN::Version1 { 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 + +#endif diff --git a/src/kernel/CFKit/GUIDWrapper.h b/src/kernel/CFKit/GUIDWrapper.h index ffea7fcb..20509ce9 100644 --- a/src/kernel/CFKit/GUIDWrapper.h +++ b/src/kernel/CFKit/GUIDWrapper.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef CFKIT_GUIDWRAPPER_H +#define CFKIT_GUIDWRAPPER_H #include <NeKit/Config.h> #include <NeKit/Ref.h> @@ -46,3 +47,5 @@ class GUID final { GUIDSequence fUUID; }; } // namespace Kernel::CF::XRN + +#endif diff --git a/src/kernel/CFKit/Utils.h b/src/kernel/CFKit/Utils.h index 41dc5a0d..76034e5c 100644 --- a/src/kernel/CFKit/Utils.h +++ b/src/kernel/CFKit/Utils.h @@ -1,3 +1,9 @@ +/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + #ifndef CFKIT_UTILS_H #define CFKIT_UTILS_H diff --git a/src/kernel/CompilerKit/Detail.h b/src/kernel/CompilerKit/Detail.h index 14c23754..b772026a 100644 --- a/src/kernel/CompilerKit/Detail.h +++ b/src/kernel/CompilerKit/Detail.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef COMPILERKIT_DETAIL_H +#define COMPILERKIT_DETAIL_H #ifdef __NEOSKRNL__ #include <NeKit/Config.h> @@ -25,3 +26,5 @@ #define NE_MOVE_DEFAULT(KLASS) \ KLASS& operator=(KLASS&&) = default; \ KLASS(KLASS&&) = default; + +#endif diff --git a/src/kernel/CompilerKit/Version.h b/src/kernel/CompilerKit/Version.h index 4250531a..b74c7402 100644 --- a/src/kernel/CompilerKit/Version.h +++ b/src/kernel/CompilerKit/Version.h @@ -1,9 +1,12 @@ // (c) Amlal El Mahrouss -#pragma once +#ifndef COMPILERKIT_VERSION_H +#define COMPILERKIT_VERSION_H #define BOOTLOADER_VERSION "v0.0.2-bootz" #define KERNEL_VERSION "v0.0.2-krnl" #define BOOTLOADER_VERSION_BCD (0x0002) #define KERNEL_VERSION_BCD (0x0002) + +#endif diff --git a/src/kernel/DmaKit/DmaPool.h b/src/kernel/DmaKit/DmaPool.h index 9b7e6b82..171c5162 100644 --- a/src/kernel/DmaKit/DmaPool.h +++ b/src/kernel/DmaKit/DmaPool.h @@ -7,7 +7,8 @@ ======================================== */ -#pragma once +#ifndef DMAKIT_DMAPOOL_H +#define DMAKIT_DMAPOOL_H #include <KernelKit/DebugOutput.h> @@ -103,3 +104,5 @@ inline Void rtl_dma_flush(VoidPtr ptr, SizeT size_buffer) { } } // namespace Kernel + +#endif diff --git a/src/kernel/FSKit/Config.h b/src/kernel/FSKit/Config.h index 2324633f..b7dfad53 100644 --- a/src/kernel/FSKit/Config.h +++ b/src/kernel/FSKit/Config.h @@ -4,9 +4,12 @@ ======================================== */ -#pragma once +#ifndef FSKIT_CONFIG_H +#define FSKIT_CONFIG_H #include <NeKit/Config.h> #define FSKIT_VERSION "0.0.2" #define FSKIT_VERSION_BCD 0x0002 + +#endif diff --git a/src/kernel/FSKit/Ext2+IFS.h b/src/kernel/FSKit/Ext2+IFS.h index a010f8b1..743e5159 100644 --- a/src/kernel/FSKit/Ext2+IFS.h +++ b/src/kernel/FSKit/Ext2+IFS.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef FSKIT_EXT2_IFS_H +#define FSKIT_EXT2_IFS_H #include <FSKit/Ext2.h> #include <KernelKit/DriveMgr.h> @@ -271,3 +272,5 @@ class Ext2FileSystemParser final { BOOL GetInfo(VoidPtr node, VoidPtr info); }; } // namespace Kernel + +#endif diff --git a/src/kernel/FSKit/Ext2.h b/src/kernel/FSKit/Ext2.h index 35b2bf23..373607be 100644 --- a/src/kernel/FSKit/Ext2.h +++ b/src/kernel/FSKit/Ext2.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef FSKIT_EXT2_H +#define FSKIT_EXT2_H #include <CompilerKit/CompilerKit.h> #include <KernelKit/DriveMgr.h> @@ -146,3 +147,5 @@ struct Ext2Node { EXT2_INODE inode; Kernel::UInt32 cursor{0}; }; + +#endif diff --git a/src/kernel/FSKit/IndexableProperty.h b/src/kernel/FSKit/IndexableProperty.h index 9eb64f81..68196fee 100644 --- a/src/kernel/FSKit/IndexableProperty.h +++ b/src/kernel/FSKit/IndexableProperty.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef FSKIT_INDEXABLEPROPERTY_H +#define FSKIT_INDEXABLEPROPERTY_H #include <CFKit/Property.h> #include <CompilerKit/CompilerKit.h> @@ -56,3 +57,5 @@ namespace Indexer { Void fs_index_file(const Char* filename, SizeT filenameLen, IndexableProperty& indexer); } // namespace Indexer } // namespace Kernel + +#endif diff --git a/src/kernel/FSKit/NeFS.h b/src/kernel/FSKit/NeFS.h index 5e38aaf5..d39de143 100644 --- a/src/kernel/FSKit/NeFS.h +++ b/src/kernel/FSKit/NeFS.h @@ -14,7 +14,8 @@ default. ======================================== */ -#pragma once +#ifndef FSKIT_NEFS_H +#define FSKIT_NEFS_H #include <CompilerKit/CompilerKit.h> #include <KernelKit/DriveMgr.h> @@ -411,3 +412,5 @@ namespace NeFS { Boolean fs_init_nefs(Void); } // namespace NeFS } // namespace Kernel + +#endif diff --git a/src/kernel/FSKit/OpenHeFS.h b/src/kernel/FSKit/OpenHeFS.h index 16647095..cecad2ee 100644 --- a/src/kernel/FSKit/OpenHeFS.h +++ b/src/kernel/FSKit/OpenHeFS.h @@ -1,434 +1,437 @@ -/* ========================================
-
- Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-
-======================================== */
-
-#pragma once
-
-#include <CompilerKit/CompilerKit.h>
-#include <KernelKit/DriveMgr.h>
-#include <KernelKit/UserMgr.h>
-#include <NeKit/Config.h>
-#include <NeKit/Crc32.h>
-#include <NeKit/KString.h>
-#include <hint/CompilerHint.h>
-
-/// @file OpenHeFS.h
-/// @brief OpenHeFS filesystem support.
-
-#define kOpenHeFSVersion (0x0104)
-#define kOpenHeFSMagic "OpenHeFS"
-#define kOpenHeFSMagicLen (9U)
-
-#define kOpenHeFSBlockLen (512U)
-#define kOpenHeFSFileNameLen (256U)
-#define kOpenHeFSPartNameLen (128U)
-
-#define kOpenHeFSMinimumDiskSize (gib_cast(128))
-
-#define kOpenHeFSDefaultVolumeName u8"OpenHeFS Volume"
-
-#define kOpenHeFSINDStartOffset (sizeof(HEFS_BOOT_NODE))
-#define kOpenHeFSINStartOffset (sizeof(HEFS_INDEX_NODE_DIRECTORY))
-
-#define kOpenHeFSRootDirectory "/"
-#define kOpenHeFSRootDirectoryU8 u8"/"
-
-#define kOpenHeFSSeparator '/'
-#define kOpenHeFSUpDir ".."
-
-#define kOpenHeFSRootDirectoryLen (2U)
-
-#define kOpenHeFSSearchAllStr u8"*"
-
-struct HEFS_BOOT_NODE;
-struct HEFS_INDEX_NODE;
-struct HEFS_INDEX_NODE_DIRECTORY;
-struct HEFS_JOURNAL_NODE;
-
-enum : UInt8 {
- kOpenHeFSHardDrive = 0xC0, // Hard Drive
- kOpenHeFSSolidStateDrive = 0xC1, // Solid State Drive
- kOpenHeFSOpticalDrive = 0x0C, // Blu-Ray/DVD
- kOpenHeFSMassStorageDevice = 0xCC, // USB
- kOpenHeFSScsiDrive = 0xC4, // SCSI Hard Drive
- kOpenHeFSFlashDrive = 0xC6,
- kOpenHeFSUnknown = 0xFF, // Unknown device.
- kOpenHeFSDriveCount = 8,
-};
-
-enum : UInt8 {
- kOpenHeFSStatusUnlocked = 0x18,
- kOpenHeFSStatusLocked,
- kOpenHeFSStatusError,
- kOpenHeFSStatusInvalid,
- kOpenHeFSStatusCount,
-};
-
-enum : UInt16 {
- kOpenHeFSEncodingFlagsUTF8 = 0x50,
- kOpenHeFSEncodingFlagsUTF16,
- kOpenHeFSEncodingFlagsUTF32,
- kOpenHeFSEncodingFlagsUTF16BE,
- kOpenHeFSEncodingFlagsUTF16LE,
- kOpenHeFSEncodingFlagsUTF32BE,
- kOpenHeFSEncodingFlagsUTF32LE,
- kOpenHeFSEncodingFlagsUTF8BE,
- kOpenHeFSEncodingFlagsUTF8LE,
- kOpenHeFSEncodingFlagsBinary,
- kOpenHeFSEncodingFlagsCount = 11,
- kOpenHeFSFlagsNone = 0,
- kOpenHeFSFlagsReadOnly = 0x100,
- kOpenHeFSFlagsHidden,
- kOpenHeFSFlagsSystem,
- kOpenHeFSFlagsArchive,
- kOpenHeFSFlagsDevice,
- kOpenHeFSFlagsCount = 7
-};
-
-inline constexpr UInt16 kOpenHeFSFileKindRegular = 0x00;
-inline constexpr UInt16 kOpenHeFSFileKindDirectory = 0x01;
-inline constexpr UInt16 kOpenHeFSFileKindBlock = 0x02;
-inline constexpr UInt16 kOpenHeFSFileKindCharacter = 0x03;
-inline constexpr UInt16 kOpenHeFSFileKindFIFO = 0x04;
-inline constexpr UInt16 kOpenHeFSFileKindSocket = 0x05;
-inline constexpr UInt16 kOpenHeFSFileKindSymbolicLink = 0x06;
-inline constexpr UInt16 kOpenHeFSFileKindUnknown = 0x07;
-inline constexpr UInt16 kOpenHeFSFileKindCount = 0x08;
-
-/// @brief OpenHeFS blocks are array containing sparse blocks of data.
-/// @details The blocks are used to store the data of a file. Each block is a pointer to a block of
-/// data on the disk.
-inline constexpr UInt16 kOpenHeFSSliceCount = 0x10;
-
-inline constexpr UInt16 kOpenHeFSInvalidVID = 0xFFFF;
-
-namespace Kernel {
-/// @brief Access time type.
-/// @details Used to keep track of the INode, INodeDir allocation status.
-typedef UInt64 ATime;
-
-/// @brief OpenHeFS Boot node.
-/// @details Acts like a superblock, it contains the information about the filesystem.
-/// @note The boot node is the first block of the filesystem.
-struct PACKED HEFS_BOOT_NODE final {
- Char fMagic[kOpenHeFSMagicLen]; /// @brief Magic number of the filesystem.
- Utf8Char fVolName[kOpenHeFSPartNameLen]; /// @brief Volume name.
- UInt32 fVersion; /// @brief Version of the filesystem.
- UInt64 fBadSectors; /// @brief Number of bad sectors in the filesystem.
- UInt64 fSectorCount; /// @brief Number of sectors in the filesystem.
- UInt64 fSectorSize; /// @brief Size of the sector.
- UInt32 fChecksum; /// @brief Checksum of the boot node.
- UInt8 fDiskKind; /// @brief Kind of the drive. (Hard Drive, Solid State Drive, Optical
- /// Drive, etc).
- UInt8 fEncoding; /// @brief Encoding of the filesystem. (UTF-8, UTF-16, etc).
- UInt64 fStartIND; /// @brief Start of the INode directory tree.
- UInt64 fEndIND; /// @brief End of the INode directory tree.
- UInt64 fINDCount; /// @brief Number of leafs in the INode tree.
- UInt64 fDiskSize; /// @brief Size of the disk. (Could be a virtual size, that is not the
- /// real size of the disk.)
- UInt16 fDiskStatus; /// @brief Status of the disk. (locked, unlocked, error, invalid).
- UInt16 fDiskFlags; /// @brief Flags of the disk. (read-only, read-write, etc).
- UInt16 fVID; /// @brief Virtual Identification Number within an EPM disk. (0xFFFF if not used).
- UInt64 fStartIN; /// @brief Start INodes range
- UInt64 fEndIN; /// @brief End INodes range
- UInt64 fStartBlock; /// @brief Start Blocks range
- UInt64 fEndBlock; /// @brief End Blocks range
- UInt64 fJournalLBA; /// @brief Boot Node's COW journal LBA.
- Char fPad[264];
-};
-
-inline constexpr ATime kOpenHeFSTimeInvalid = 0x0000000000000000;
-inline constexpr ATime kOpenHeFSTimeMax = 0xFFFFFFFFFFFFFFFF - 1;
-
-/// @brief Journal Node structure
-/// @param fHashPath target hash path
-/// @param fStatus target status
-/// @param fCopyElem copy of element
-/// @param fCopyKind kind of element
-struct PACKED HEFS_JOURNAL_NODE {
- UInt64 fHashPath;
- UInt64 fStatus;
- UInt64 fCopyElem;
- UInt8 fCopyKind;
- UInt8 fPad[487];
-};
-
-/// @brief This enum defines the opcode of the journal, here mentioned as 'kinds'
-enum HeFSJournalKind : UInt8 {
- kJournalKindInvalid = 0x00,
- kJournalKindWrite = 0x01,
- kJournalKindRename = 0x02,
- kJournalKindDelete = 0x03,
- kJournalKindFlagEdit = 0x04,
- kJournalKindCreate = 0x05,
- kJournalKindCount,
-};
-
-/// @brief OpenHeFS index node.
-/// @details This structure is used to store the file information of a file.
-/// @note The index node is a special type of INode that contains the file information.
-/// @note The index node is used to store the file information of a file.
-struct PACKED HEFS_INDEX_NODE final {
- UInt64 fHashPath; /// @brief File name.
- UInt32 fFlags; /// @brief File flags.
- UInt16 fKind; /// @brief File kind. (Regular, Directory, Block, Character, FIFO, Socket,
- /// Symbolic Link, Unknown).
- UInt32 fSize; /// @brief File size.
- UInt32 fChecksum; /// @brief Checksum.
-
- Boolean fSymLink; /// @brief Is this a symbolic link? (if yes, the fName is the path to
- /// the file and blocklinkstart and end contains it's inodes.)
-
- ATime fCreated, fAccessed, fModified, fDeleted; /// @brief File timestamps.
- UInt32 fUID, fGID; /// @brief User ID and Group ID of the file.
- UInt32 fMode; /// @brief File mode. (read, write, execute, etc).
-
- /// @brief Extents system by using blocks
- /// @details Using an offset to ask fBase, and fLength to compute each slice's length.
- UInt32 fOffsetSliceLow;
- UInt32 fOffsetSliceHigh;
-
- Char fPad[437];
-};
-
-enum {
- kOpenHeFSInvalidColor = 0,
- kOpenHeFSRed = 100,
- kOpenHeFSBlack,
- kOpenHeFSColorCount,
-};
-
-/// @brief OpenHeFS directory node.
-/// @details This structure is used to store the directory information of a file.
-/// @note The directory node is a special type of INode that contains the directory entries.
-struct PACKED HEFS_INDEX_NODE_DIRECTORY final {
- UInt64 fHashPath; /// @brief Directory path as FNV hash.
-
- UInt32 fFlags; /// @brief File flags.
- UInt16 fReserved; /// @note Reserved for future use.
- UInt32 fEntryCount; /// @brief Entry Count of this directory inode.
- UInt32 fChecksum; /// @brief Checksum of the file, index node checksum.
-
- ATime fCreated, fAccessed, fModified,
- fDeleted; /// @brief File timestamps and allocation status.
- UInt32 fUID, fGID; /// @brief User ID and Group ID of the file.
- UInt32 fMode; /// @brief File mode. (read, write, execute, etc).
-
- /// @note These slices are organized as:
- /// [0] = OFFSET
- /// [1] = SIZE
- /// @note Thus the += 2 when iterating over them.
- UInt64 fINSlices[kOpenHeFSSliceCount]; /// @brief Start of the index node.
-
- UInt8 fColor; /// @brief Color of the node. (Red or Black).
- Lba fNext, fPrev, fChild, fParent; /// @brief Red-black tree pointers.
-
- Char fPad[285];
-};
-} // namespace Kernel
-
-namespace Kernel::Detail {
-/// @brief OpenHeFS get year from ATime.
-/// @param raw_atime the raw ATime value.
-/// @return the year value.
-/// @note The year is stored in the upper 32 bits of the ATime value.
-inline UInt32 hefs_year_get(ATime raw_atime) {
- return (raw_atime) >> 32;
-}
-
-/// @brief OpenHeFS get month from ATime.
-/// @param raw_atime the raw ATime value.
-/// @return the month value.
-/// @note The month is stored in the upper 24 bits of the ATime value.
-inline UInt32 hefs_month_get(ATime raw_atime) {
- return (raw_atime) >> 24;
-}
-
-/// @brief OpenHeFS get day from ATime.
-/// @param raw_atime the raw ATime value.
-/// @return the day value.
-/// @note The day is stored in the upper 16 bits of the ATime value.
-inline UInt32 hefs_day_get(ATime raw_atime) {
- return (raw_atime) >> 16;
-}
-
-/// @brief OpenHeFS get hour from ATime.
-/// @param raw_atime the raw ATime value.
-/// @return the hour value.
-/// @note The hour is stored in the upper 8 bits of the ATime value.
-inline UInt32 hefs_hour_get(ATime raw_atime) {
- return (raw_atime) >> 8;
-}
-
-/// @brief OpenHeFS get minute from ATime.
-/// @param raw_atime the raw ATime value.
-/// @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;
-}
-
-inline constexpr UInt32 kOpenHeFSBaseYear = 1970;
-inline constexpr UInt32 kOpenHeFSBaseMonth = 1;
-inline constexpr UInt32 kOpenHeFSBaseDay = 1;
-inline constexpr UInt32 kOpenHeFSBaseHour = 0;
-inline constexpr UInt32 kOpenHeFSBaseMinute = 0;
-
-inline const Char* hefs_status_to_string(UInt16 status) {
- switch (status) {
- case kOpenHeFSStatusUnlocked:
- return "Unlocked";
- case kOpenHeFSStatusLocked:
- return "Locked";
- case kOpenHeFSStatusError:
- return "Error";
- case kOpenHeFSStatusInvalid:
- return "Invalid";
- default:
- return "Unknown";
- }
-}
-
-inline const Char* hefs_drive_kind_to_string(UInt8 kind) {
- switch (kind) {
- case kOpenHeFSHardDrive:
- return "Hard Drive";
- case kOpenHeFSSolidStateDrive:
- return "Solid State Drive";
- case kOpenHeFSOpticalDrive:
- return "Optical Drive";
- case kOpenHeFSMassStorageDevice:
- return "Mass Storage Device";
- case kOpenHeFSScsiDrive:
- return "SCSI/SAS Drive";
- case kOpenHeFSFlashDrive:
- return "Flash Drive";
- case kOpenHeFSUnknown:
- default:
- return "Unknown";
- }
-}
-
-inline const Char* hefs_encoding_to_string(UInt8 encoding) {
- switch (encoding) {
- case kOpenHeFSEncodingFlagsUTF8:
- return "UTF-8";
- case kOpenHeFSEncodingFlagsUTF16:
- return "UTF-16";
- case kOpenHeFSEncodingFlagsUTF32:
- return "UTF-32";
- case kOpenHeFSEncodingFlagsUTF16BE:
- return "UTF-16BE";
- case kOpenHeFSEncodingFlagsUTF16LE:
- return "UTF-16LE";
- case kOpenHeFSEncodingFlagsUTF32BE:
- return "UTF-32BE";
- case kOpenHeFSEncodingFlagsUTF32LE:
- return "UTF-32LE";
- case kOpenHeFSEncodingFlagsUTF8BE:
- return "UTF-8BE";
- case kOpenHeFSEncodingFlagsUTF8LE:
- return "UTF-8LE";
- default:
- return "Unknown";
- }
-}
-
-inline const Char* hefs_file_kind_to_string(UInt16 kind) {
- switch (kind) {
- case kOpenHeFSFileKindRegular:
- return "Regular File";
- case kOpenHeFSFileKindDirectory:
- return "Directory";
- case kOpenHeFSFileKindBlock:
- return "Block Device";
- case kOpenHeFSFileKindCharacter:
- return "Character Device";
- case kOpenHeFSFileKindFIFO:
- return "FIFO";
- case kOpenHeFSFileKindSocket:
- return "Socket";
- case kOpenHeFSFileKindSymbolicLink:
- return "Symbolic Link";
- case kOpenHeFSFileKindUnknown:
- default:
- return "Unknown";
- }
-}
-
-inline const Char* hefs_file_flags_to_string(UInt32 flags) {
- switch (flags) {
- case kOpenHeFSFlagsNone:
- return "No Flags";
- case kOpenHeFSFlagsReadOnly:
- return "Read Only";
- case kOpenHeFSFlagsHidden:
- return "Hidden";
- case kOpenHeFSFlagsSystem:
- return "System";
- case kOpenHeFSFlagsArchive:
- return "Archive";
- case kOpenHeFSFlagsDevice:
- return "Device";
- default:
- return "Unknown";
- }
-}
-} // namespace Kernel::Detail
-
-namespace Kernel {
-/// @brief OpenHeFS filesystem parser class.
-/// @details This class is used to parse the OpenHeFS filesystem.
-class HeFileSystemParser final {
- public:
- HeFileSystemParser() = default;
- ~HeFileSystemParser() = default;
-
- public:
- HeFileSystemParser(const HeFileSystemParser&) = delete;
- HeFileSystemParser& operator=(const HeFileSystemParser&) = delete;
-
- HeFileSystemParser(HeFileSystemParser&&) = delete;
- HeFileSystemParser& operator=(HeFileSystemParser&&) = delete;
-
- public:
- /// @brief Make a EPM+OpenHeFS drive out of the disk.
- /// @param drive The drive to write on.
- /// @return If it was sucessful, see err_local_get().
- _Output Bool Format(_Input _Output DriveTrait* drive, _Input const Int32 flags,
- const Utf8Char* part_name);
-
- _Output Bool CreateINodeDirectory(_Input DriveTrait* drive, _Input const Int32 flags,
- const Utf8Char* dir);
-
- _Output Bool RemoveINodeDirectory(_Input DriveTrait* drive, _Input const Int32 flags,
- const Utf8Char* dir);
-
- _Output Bool CreateINode(_Input DriveTrait* drive, _Input const Int32 flags, const Utf8Char* dir,
- const Utf8Char* name, const UInt8 kind);
-
- _Output Bool DeleteINode(_Input DriveTrait* drive, _Input const Int32 flags, const Utf8Char* dir,
- const Utf8Char* name, const UInt8 kind);
-
- _Output Bool INodeManip(_Input DriveTrait* drive, VoidPtr block, SizeT block_sz,
- const Utf8Char* dir, const Utf8Char* name, const UInt8 kind,
- const BOOL input);
-
- private:
- _Output Bool INodeCtlManip(_Input DriveTrait* drive, _Input const Int32 flags,
- const Utf8Char* dir, const Utf8Char* name, const BOOL delete_or_create,
- const UInt8 kind);
-
- _Output Bool INodeDirectoryCtlManip(_Input DriveTrait* drive, _Input const Int32 flags,
- const Utf8Char* dir, const BOOL delete_or_create);
-};
-
-namespace OpenHeFS {
-
- /// @brief Initialize OpenHeFS inside the main disk.
- /// @return Whether it successfuly formated it or not.
- Boolean fs_init_openhefs(Void);
-} // namespace OpenHeFS
-} // namespace Kernel
+/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + +#ifndef FSKIT_OPENHEFS_H +#define FSKIT_OPENHEFS_H + +#include <CompilerKit/CompilerKit.h> +#include <KernelKit/DriveMgr.h> +#include <KernelKit/UserMgr.h> +#include <NeKit/Config.h> +#include <NeKit/Crc32.h> +#include <NeKit/KString.h> +#include <hint/CompilerHint.h> + +/// @file OpenHeFS.h +/// @brief OpenHeFS filesystem support. + +#define kOpenHeFSVersion (0x0104) +#define kOpenHeFSMagic "OpenHeFS" +#define kOpenHeFSMagicLen (9U) + +#define kOpenHeFSBlockLen (512U) +#define kOpenHeFSFileNameLen (256U) +#define kOpenHeFSPartNameLen (128U) + +#define kOpenHeFSMinimumDiskSize (gib_cast(128)) + +#define kOpenHeFSDefaultVolumeName u8"OpenHeFS Volume" + +#define kOpenHeFSINDStartOffset (sizeof(HEFS_BOOT_NODE)) +#define kOpenHeFSINStartOffset (sizeof(HEFS_INDEX_NODE_DIRECTORY)) + +#define kOpenHeFSRootDirectory "/" +#define kOpenHeFSRootDirectoryU8 u8"/" + +#define kOpenHeFSSeparator '/' +#define kOpenHeFSUpDir ".." + +#define kOpenHeFSRootDirectoryLen (2U) + +#define kOpenHeFSSearchAllStr u8"*" + +struct HEFS_BOOT_NODE; +struct HEFS_INDEX_NODE; +struct HEFS_INDEX_NODE_DIRECTORY; +struct HEFS_JOURNAL_NODE; + +enum : UInt8 { + kOpenHeFSHardDrive = 0xC0, // Hard Drive + kOpenHeFSSolidStateDrive = 0xC1, // Solid State Drive + kOpenHeFSOpticalDrive = 0x0C, // Blu-Ray/DVD + kOpenHeFSMassStorageDevice = 0xCC, // USB + kOpenHeFSScsiDrive = 0xC4, // SCSI Hard Drive + kOpenHeFSFlashDrive = 0xC6, + kOpenHeFSUnknown = 0xFF, // Unknown device. + kOpenHeFSDriveCount = 8, +}; + +enum : UInt8 { + kOpenHeFSStatusUnlocked = 0x18, + kOpenHeFSStatusLocked, + kOpenHeFSStatusError, + kOpenHeFSStatusInvalid, + kOpenHeFSStatusCount, +}; + +enum : UInt16 { + kOpenHeFSEncodingFlagsUTF8 = 0x50, + kOpenHeFSEncodingFlagsUTF16, + kOpenHeFSEncodingFlagsUTF32, + kOpenHeFSEncodingFlagsUTF16BE, + kOpenHeFSEncodingFlagsUTF16LE, + kOpenHeFSEncodingFlagsUTF32BE, + kOpenHeFSEncodingFlagsUTF32LE, + kOpenHeFSEncodingFlagsUTF8BE, + kOpenHeFSEncodingFlagsUTF8LE, + kOpenHeFSEncodingFlagsBinary, + kOpenHeFSEncodingFlagsCount = 11, + kOpenHeFSFlagsNone = 0, + kOpenHeFSFlagsReadOnly = 0x100, + kOpenHeFSFlagsHidden, + kOpenHeFSFlagsSystem, + kOpenHeFSFlagsArchive, + kOpenHeFSFlagsDevice, + kOpenHeFSFlagsCount = 7 +}; + +inline constexpr UInt16 kOpenHeFSFileKindRegular = 0x00; +inline constexpr UInt16 kOpenHeFSFileKindDirectory = 0x01; +inline constexpr UInt16 kOpenHeFSFileKindBlock = 0x02; +inline constexpr UInt16 kOpenHeFSFileKindCharacter = 0x03; +inline constexpr UInt16 kOpenHeFSFileKindFIFO = 0x04; +inline constexpr UInt16 kOpenHeFSFileKindSocket = 0x05; +inline constexpr UInt16 kOpenHeFSFileKindSymbolicLink = 0x06; +inline constexpr UInt16 kOpenHeFSFileKindUnknown = 0x07; +inline constexpr UInt16 kOpenHeFSFileKindCount = 0x08; + +/// @brief OpenHeFS blocks are array containing sparse blocks of data. +/// @details The blocks are used to store the data of a file. Each block is a pointer to a block of +/// data on the disk. +inline constexpr UInt16 kOpenHeFSSliceCount = 0x10; + +inline constexpr UInt16 kOpenHeFSInvalidVID = 0xFFFF; + +namespace Kernel { +/// @brief Access time type. +/// @details Used to keep track of the INode, INodeDir allocation status. +typedef UInt64 ATime; + +/// @brief OpenHeFS Boot node. +/// @details Acts like a superblock, it contains the information about the filesystem. +/// @note The boot node is the first block of the filesystem. +struct PACKED HEFS_BOOT_NODE final { + Char fMagic[kOpenHeFSMagicLen]; /// @brief Magic number of the filesystem. + Utf8Char fVolName[kOpenHeFSPartNameLen]; /// @brief Volume name. + UInt32 fVersion; /// @brief Version of the filesystem. + UInt64 fBadSectors; /// @brief Number of bad sectors in the filesystem. + UInt64 fSectorCount; /// @brief Number of sectors in the filesystem. + UInt64 fSectorSize; /// @brief Size of the sector. + UInt32 fChecksum; /// @brief Checksum of the boot node. + UInt8 fDiskKind; /// @brief Kind of the drive. (Hard Drive, Solid State Drive, Optical + /// Drive, etc). + UInt8 fEncoding; /// @brief Encoding of the filesystem. (UTF-8, UTF-16, etc). + UInt64 fStartIND; /// @brief Start of the INode directory tree. + UInt64 fEndIND; /// @brief End of the INode directory tree. + UInt64 fINDCount; /// @brief Number of leafs in the INode tree. + UInt64 fDiskSize; /// @brief Size of the disk. (Could be a virtual size, that is not the + /// real size of the disk.) + UInt16 fDiskStatus; /// @brief Status of the disk. (locked, unlocked, error, invalid). + UInt16 fDiskFlags; /// @brief Flags of the disk. (read-only, read-write, etc). + UInt16 fVID; /// @brief Virtual Identification Number within an EPM disk. (0xFFFF if not used). + UInt64 fStartIN; /// @brief Start INodes range + UInt64 fEndIN; /// @brief End INodes range + UInt64 fStartBlock; /// @brief Start Blocks range + UInt64 fEndBlock; /// @brief End Blocks range + UInt64 fJournalLBA; /// @brief Boot Node's COW journal LBA. + Char fPad[264]; +}; + +inline constexpr ATime kOpenHeFSTimeInvalid = 0x0000000000000000; +inline constexpr ATime kOpenHeFSTimeMax = 0xFFFFFFFFFFFFFFFF - 1; + +/// @brief Journal Node structure +/// @param fHashPath target hash path +/// @param fStatus target status +/// @param fCopyElem copy of element +/// @param fCopyKind kind of element +struct PACKED HEFS_JOURNAL_NODE { + UInt64 fHashPath; + UInt64 fStatus; + UInt64 fCopyElem; + UInt8 fCopyKind; + UInt8 fPad[487]; +}; + +/// @brief This enum defines the opcode of the journal, here mentioned as 'kinds' +enum HeFSJournalKind : UInt8 { + kJournalKindInvalid = 0x00, + kJournalKindWrite = 0x01, + kJournalKindRename = 0x02, + kJournalKindDelete = 0x03, + kJournalKindFlagEdit = 0x04, + kJournalKindCreate = 0x05, + kJournalKindCount, +}; + +/// @brief OpenHeFS index node. +/// @details This structure is used to store the file information of a file. +/// @note The index node is a special type of INode that contains the file information. +/// @note The index node is used to store the file information of a file. +struct PACKED HEFS_INDEX_NODE final { + UInt64 fHashPath; /// @brief File name. + UInt32 fFlags; /// @brief File flags. + UInt16 fKind; /// @brief File kind. (Regular, Directory, Block, Character, FIFO, Socket, + /// Symbolic Link, Unknown). + UInt32 fSize; /// @brief File size. + UInt32 fChecksum; /// @brief Checksum. + + Boolean fSymLink; /// @brief Is this a symbolic link? (if yes, the fName is the path to + /// the file and blocklinkstart and end contains it's inodes.) + + ATime fCreated, fAccessed, fModified, fDeleted; /// @brief File timestamps. + UInt32 fUID, fGID; /// @brief User ID and Group ID of the file. + UInt32 fMode; /// @brief File mode. (read, write, execute, etc). + + /// @brief Extents system by using blocks + /// @details Using an offset to ask fBase, and fLength to compute each slice's length. + UInt32 fOffsetSliceLow; + UInt32 fOffsetSliceHigh; + + Char fPad[437]; +}; + +enum { + kOpenHeFSInvalidColor = 0, + kOpenHeFSRed = 100, + kOpenHeFSBlack, + kOpenHeFSColorCount, +}; + +/// @brief OpenHeFS directory node. +/// @details This structure is used to store the directory information of a file. +/// @note The directory node is a special type of INode that contains the directory entries. +struct PACKED HEFS_INDEX_NODE_DIRECTORY final { + UInt64 fHashPath; /// @brief Directory path as FNV hash. + + UInt32 fFlags; /// @brief File flags. + UInt16 fReserved; /// @note Reserved for future use. + UInt32 fEntryCount; /// @brief Entry Count of this directory inode. + UInt32 fChecksum; /// @brief Checksum of the file, index node checksum. + + ATime fCreated, fAccessed, fModified, + fDeleted; /// @brief File timestamps and allocation status. + UInt32 fUID, fGID; /// @brief User ID and Group ID of the file. + UInt32 fMode; /// @brief File mode. (read, write, execute, etc). + + /// @note These slices are organized as: + /// [0] = OFFSET + /// [1] = SIZE + /// @note Thus the += 2 when iterating over them. + UInt64 fINSlices[kOpenHeFSSliceCount]; /// @brief Start of the index node. + + UInt8 fColor; /// @brief Color of the node. (Red or Black). + Lba fNext, fPrev, fChild, fParent; /// @brief Red-black tree pointers. + + Char fPad[285]; +}; +} // namespace Kernel + +namespace Kernel::Detail { +/// @brief OpenHeFS get year from ATime. +/// @param raw_atime the raw ATime value. +/// @return the year value. +/// @note The year is stored in the upper 32 bits of the ATime value. +inline UInt32 hefs_year_get(ATime raw_atime) { + return (raw_atime) >> 32; +} + +/// @brief OpenHeFS get month from ATime. +/// @param raw_atime the raw ATime value. +/// @return the month value. +/// @note The month is stored in the upper 24 bits of the ATime value. +inline UInt32 hefs_month_get(ATime raw_atime) { + return (raw_atime) >> 24; +} + +/// @brief OpenHeFS get day from ATime. +/// @param raw_atime the raw ATime value. +/// @return the day value. +/// @note The day is stored in the upper 16 bits of the ATime value. +inline UInt32 hefs_day_get(ATime raw_atime) { + return (raw_atime) >> 16; +} + +/// @brief OpenHeFS get hour from ATime. +/// @param raw_atime the raw ATime value. +/// @return the hour value. +/// @note The hour is stored in the upper 8 bits of the ATime value. +inline UInt32 hefs_hour_get(ATime raw_atime) { + return (raw_atime) >> 8; +} + +/// @brief OpenHeFS get minute from ATime. +/// @param raw_atime the raw ATime value. +/// @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; +} + +inline constexpr UInt32 kOpenHeFSBaseYear = 1970; +inline constexpr UInt32 kOpenHeFSBaseMonth = 1; +inline constexpr UInt32 kOpenHeFSBaseDay = 1; +inline constexpr UInt32 kOpenHeFSBaseHour = 0; +inline constexpr UInt32 kOpenHeFSBaseMinute = 0; + +inline const Char* hefs_status_to_string(UInt16 status) { + switch (status) { + case kOpenHeFSStatusUnlocked: + return "Unlocked"; + case kOpenHeFSStatusLocked: + return "Locked"; + case kOpenHeFSStatusError: + return "Error"; + case kOpenHeFSStatusInvalid: + return "Invalid"; + default: + return "Unknown"; + } +} + +inline const Char* hefs_drive_kind_to_string(UInt8 kind) { + switch (kind) { + case kOpenHeFSHardDrive: + return "Hard Drive"; + case kOpenHeFSSolidStateDrive: + return "Solid State Drive"; + case kOpenHeFSOpticalDrive: + return "Optical Drive"; + case kOpenHeFSMassStorageDevice: + return "Mass Storage Device"; + case kOpenHeFSScsiDrive: + return "SCSI/SAS Drive"; + case kOpenHeFSFlashDrive: + return "Flash Drive"; + case kOpenHeFSUnknown: + default: + return "Unknown"; + } +} + +inline const Char* hefs_encoding_to_string(UInt8 encoding) { + switch (encoding) { + case kOpenHeFSEncodingFlagsUTF8: + return "UTF-8"; + case kOpenHeFSEncodingFlagsUTF16: + return "UTF-16"; + case kOpenHeFSEncodingFlagsUTF32: + return "UTF-32"; + case kOpenHeFSEncodingFlagsUTF16BE: + return "UTF-16BE"; + case kOpenHeFSEncodingFlagsUTF16LE: + return "UTF-16LE"; + case kOpenHeFSEncodingFlagsUTF32BE: + return "UTF-32BE"; + case kOpenHeFSEncodingFlagsUTF32LE: + return "UTF-32LE"; + case kOpenHeFSEncodingFlagsUTF8BE: + return "UTF-8BE"; + case kOpenHeFSEncodingFlagsUTF8LE: + return "UTF-8LE"; + default: + return "Unknown"; + } +} + +inline const Char* hefs_file_kind_to_string(UInt16 kind) { + switch (kind) { + case kOpenHeFSFileKindRegular: + return "Regular File"; + case kOpenHeFSFileKindDirectory: + return "Directory"; + case kOpenHeFSFileKindBlock: + return "Block Device"; + case kOpenHeFSFileKindCharacter: + return "Character Device"; + case kOpenHeFSFileKindFIFO: + return "FIFO"; + case kOpenHeFSFileKindSocket: + return "Socket"; + case kOpenHeFSFileKindSymbolicLink: + return "Symbolic Link"; + case kOpenHeFSFileKindUnknown: + default: + return "Unknown"; + } +} + +inline const Char* hefs_file_flags_to_string(UInt32 flags) { + switch (flags) { + case kOpenHeFSFlagsNone: + return "No Flags"; + case kOpenHeFSFlagsReadOnly: + return "Read Only"; + case kOpenHeFSFlagsHidden: + return "Hidden"; + case kOpenHeFSFlagsSystem: + return "System"; + case kOpenHeFSFlagsArchive: + return "Archive"; + case kOpenHeFSFlagsDevice: + return "Device"; + default: + return "Unknown"; + } +} +} // namespace Kernel::Detail + +namespace Kernel { +/// @brief OpenHeFS filesystem parser class. +/// @details This class is used to parse the OpenHeFS filesystem. +class HeFileSystemParser final { + public: + HeFileSystemParser() = default; + ~HeFileSystemParser() = default; + + public: + HeFileSystemParser(const HeFileSystemParser&) = delete; + HeFileSystemParser& operator=(const HeFileSystemParser&) = delete; + + HeFileSystemParser(HeFileSystemParser&&) = delete; + HeFileSystemParser& operator=(HeFileSystemParser&&) = delete; + + public: + /// @brief Make a EPM+OpenHeFS drive out of the disk. + /// @param drive The drive to write on. + /// @return If it was sucessful, see err_local_get(). + _Output Bool Format(_Input _Output DriveTrait* drive, _Input const Int32 flags, + const Utf8Char* part_name); + + _Output Bool CreateINodeDirectory(_Input DriveTrait* drive, _Input const Int32 flags, + const Utf8Char* dir); + + _Output Bool RemoveINodeDirectory(_Input DriveTrait* drive, _Input const Int32 flags, + const Utf8Char* dir); + + _Output Bool CreateINode(_Input DriveTrait* drive, _Input const Int32 flags, const Utf8Char* dir, + const Utf8Char* name, const UInt8 kind); + + _Output Bool DeleteINode(_Input DriveTrait* drive, _Input const Int32 flags, const Utf8Char* dir, + const Utf8Char* name, const UInt8 kind); + + _Output Bool INodeManip(_Input DriveTrait* drive, VoidPtr block, SizeT block_sz, + const Utf8Char* dir, const Utf8Char* name, const UInt8 kind, + const BOOL input); + + private: + _Output Bool INodeCtlManip(_Input DriveTrait* drive, _Input const Int32 flags, + const Utf8Char* dir, const Utf8Char* name, const BOOL delete_or_create, + const UInt8 kind); + + _Output Bool INodeDirectoryCtlManip(_Input DriveTrait* drive, _Input const Int32 flags, + const Utf8Char* dir, const BOOL delete_or_create); +}; + +namespace OpenHeFS { + + /// @brief Initialize OpenHeFS inside the main disk. + /// @return Whether it successfuly formated it or not. + Boolean fs_init_openhefs(Void); +} // namespace OpenHeFS +} // namespace Kernel + +#endif diff --git a/src/kernel/FirmwareKit/EFI.h b/src/kernel/FirmwareKit/EFI.h index f75f0fbe..f9d0802d 100644 --- a/src/kernel/FirmwareKit/EFI.h +++ b/src/kernel/FirmwareKit/EFI.h @@ -4,9 +4,12 @@ ======================================== */ -#pragma once +#ifndef FIRMWAREKIT_EFI_H +#define FIRMWAREKIT_EFI_H #include <FirmwareKit/EFI/EFI.h> #include <FirmwareKit/GPT.h> /// @note this header is used to reference the EFI/EFI.h + +#endif diff --git a/src/kernel/FirmwareKit/EFI/NS.h b/src/kernel/FirmwareKit/EFI/NS.h index 1314e872..5a4cfeec 100644 --- a/src/kernel/FirmwareKit/EFI/NS.h +++ b/src/kernel/FirmwareKit/EFI/NS.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef FIRMWAREKIT_NS_H +#define FIRMWAREKIT_NS_H #include <NeKit/Config.h> @@ -16,3 +17,5 @@ EXTERN_C { } } // namespace Firmware::Detail::EFI + +#endif diff --git a/src/kernel/FirmwareKit/GPT.h b/src/kernel/FirmwareKit/GPT.h index 6264bf30..c8c46cc9 100644 --- a/src/kernel/FirmwareKit/GPT.h +++ b/src/kernel/FirmwareKit/GPT.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef FIRMWAREKIT_GPT_H +#define FIRMWAREKIT_GPT_H #include <FirmwareKit/EFI/EFI.h> #include <NeKit/Config.h> @@ -46,3 +47,5 @@ struct PACKED GPT_PARTITION_ENTRY { UInt8 Name[kSectorAlignGPT_PartEntry]; }; } // namespace Kernel + +#endif diff --git a/src/kernel/FirmwareKit/Handover.h b/src/kernel/FirmwareKit/Handover.h index 380691de..9bee9ed8 100644 --- a/src/kernel/FirmwareKit/Handover.h +++ b/src/kernel/FirmwareKit/Handover.h @@ -15,7 +15,8 @@ * */ -#pragma once +#ifndef FIRMWAREKIT_HANDOVER_H +#define FIRMWAREKIT_HANDOVER_H #include <FirmwareKit/EFI/EFI.h> #include <NeKit/Config.h> @@ -106,3 +107,5 @@ typedef Int32 (*HandoverProc)(BootInfoHeader* boot_info); /// @brief Bootloader information header global variable. inline Kernel::HEL::BootInfoHeader* kHandoverHeader = nullptr; + +#endif diff --git a/src/kernel/FirmwareKit/NeBoot/BootNet.h b/src/kernel/FirmwareKit/NeBoot/BootNet.h index dca655b7..73ef9e2d 100644 --- a/src/kernel/FirmwareKit/NeBoot/BootNet.h +++ b/src/kernel/FirmwareKit/NeBoot/BootNet.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef FIRMWAREKIT_BOOTNET_H +#define FIRMWAREKIT_BOOTNET_H #include <NeKit/Config.h> @@ -39,3 +40,5 @@ typedef struct _BOOTNET_INTERNET_HEADER { } PACKED BOOTNET_INTERNET_HEADER; using BOOTNET_INTERNET_HEADER_PTR = BOOTNET_INTERNET_HEADER*; + +#endif diff --git a/src/kernel/FirmwareKit/NeBoot/NS.h b/src/kernel/FirmwareKit/NeBoot/NS.h index 3a6bed6d..f8ef00e5 100644 --- a/src/kernel/FirmwareKit/NeBoot/NS.h +++ b/src/kernel/FirmwareKit/NeBoot/NS.h @@ -4,7 +4,10 @@ ======================================== */ -#pragma once +#ifndef FIRMWAREKIT_NS_H +#define FIRMWAREKIT_NS_H #include <FirmwareKit/NeBoot/BootNet.h> -#include <FirmwareKit/NeBoot/NeBoot.h>
\ No newline at end of file +#include <FirmwareKit/NeBoot/NeBoot.h> + +#endif diff --git a/src/kernel/FirmwareKit/NeBoot/NeBoot.h b/src/kernel/FirmwareKit/NeBoot/NeBoot.h index 1ca3b13c..0f377b1d 100644 --- a/src/kernel/FirmwareKit/NeBoot/NeBoot.h +++ b/src/kernel/FirmwareKit/NeBoot/NeBoot.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef FIRMWAREKIT_NEBOOT_H +#define FIRMWAREKIT_NEBOOT_H #include <NeKit/Config.h> @@ -32,3 +33,5 @@ struct ATTRIBUTE(aligned(4)) NEBOOT_LINEAR_EXEC { #endif }; } // namespace Firmware::Detail::NeBoot + +#endif diff --git a/src/kernel/GfxKit/FB.h b/src/kernel/GfxKit/FB.h index a5e866a6..734fa94e 100644 --- a/src/kernel/GfxKit/FB.h +++ b/src/kernel/GfxKit/FB.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef GFXKIT_FB_H +#define GFXKIT_FB_H #include <KernelKit/DeviceMgr.h> @@ -50,3 +51,5 @@ class FBDeviceInterface NE_DEVICE<FBDevicePacket*> { FBDeviceInterface& operator>>(FBDevicePacket* dat) override; }; } // namespace Kernel + +#endif diff --git a/src/kernel/HALKit/AMD64/CPUID.h b/src/kernel/HALKit/AMD64/CPUID.h index 90d2c268..c8d26a2f 100644 --- a/src/kernel/HALKit/AMD64/CPUID.h +++ b/src/kernel/HALKit/AMD64/CPUID.h @@ -11,7 +11,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_CPUID_H +#define HALKIT_CPUID_H #include <NeKit/Config.h> @@ -87,3 +88,5 @@ enum { typedef Int64 CPUID; } // namespace Kernel + +#endif diff --git a/src/kernel/HALKit/AMD64/Hypervisor.h b/src/kernel/HALKit/AMD64/Hypervisor.h index 5a96c657..70b2111a 100644 --- a/src/kernel/HALKit/AMD64/Hypervisor.h +++ b/src/kernel/HALKit/AMD64/Hypervisor.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_HYPERVISOR_H +#define HALKIT_HYPERVISOR_H #include <NeKit/Config.h> @@ -22,3 +23,5 @@ ENUM_STRING(Bhyve, "bhyve bhyve "); ENUM_STRING(Qnx, " QNXQVMBSQG "); END_STRING_ENUM() } // namespace Kernel + +#endif diff --git a/src/kernel/HALKit/AMD64/Paging.h b/src/kernel/HALKit/AMD64/Paging.h index 77ea6f37..162e5fd3 100644 --- a/src/kernel/HALKit/AMD64/Paging.h +++ b/src/kernel/HALKit/AMD64/Paging.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_PAGING_H +#define HALKIT_PAGING_H #ifdef __NE_AMD64__ @@ -90,4 +91,6 @@ struct PDE { }; } // namespace Kernel -#endif // __NE_AMD64__
\ No newline at end of file +#endif // __NE_AMD64__ + +#endif diff --git a/src/kernel/HALKit/AMD64/Processor.h b/src/kernel/HALKit/AMD64/Processor.h index f5dee661..352af95f 100644 --- a/src/kernel/HALKit/AMD64/Processor.h +++ b/src/kernel/HALKit/AMD64/Processor.h @@ -11,7 +11,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_PROCESSOR_H +#define HALKIT_PROCESSOR_H #ifdef __NE_AMD64__ @@ -280,4 +281,6 @@ EXTERN_C ATTRIBUTE(naked) Kernel::Void hal_load_gdt(Kernel::HAL::Register64 ptr) inline Kernel::VoidPtr kKernelBitMpStart = nullptr; inline Kernel::UIntPtr kKernelBitMpSize = 0UL; -#endif // __NE_AMD64__ */
\ No newline at end of file +#endif // __NE_AMD64__ */ + +#endif diff --git a/src/kernel/HALKit/ARM64/ApplicationProcessor.h b/src/kernel/HALKit/ARM64/ApplicationProcessor.h index 71f8b68a..2ce60dd1 100644 --- a/src/kernel/HALKit/ARM64/ApplicationProcessor.h +++ b/src/kernel/HALKit/ARM64/ApplicationProcessor.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_APPLICATIONPROCESSOR_H +#define HALKIT_APPLICATIONPROCESSOR_H #include <HALKit/ARM64/Processor.h> #include <NeKit/Config.h> @@ -16,4 +17,6 @@ namespace Kernel { Void mp_init_cores(Void); -}
\ No newline at end of file +} + +#endif diff --git a/src/kernel/HALKit/ARM64/Paging.h b/src/kernel/HALKit/ARM64/Paging.h index 34cf4213..7526b640 100644 --- a/src/kernel/HALKit/ARM64/Paging.h +++ b/src/kernel/HALKit/ARM64/Paging.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_PAGING_H +#define HALKIT_PAGING_H /** --------------------------------------------------- @@ -102,4 +103,6 @@ typedef HAL::PDE_4KB PDE; EXTERN_C void hal_flush_tlb(); -#endif // __NE_ARM64__
\ No newline at end of file +#endif // __NE_ARM64__ + +#endif diff --git a/src/kernel/HALKit/ARM64/Processor.h b/src/kernel/HALKit/ARM64/Processor.h index 3ef21957..f4df9a92 100644 --- a/src/kernel/HALKit/ARM64/Processor.h +++ b/src/kernel/HALKit/ARM64/Processor.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_PROCESSOR_H +#define HALKIT_PROCESSOR_H #ifdef __NE_ARM64__ @@ -75,4 +76,6 @@ inline Kernel::UIntPtr kKernelBitMpSize = 0UL; #include <HALKit/ARM64/Paging.h> -#endif // __NE_ARM64__
\ No newline at end of file +#endif // __NE_ARM64__ + +#endif diff --git a/src/kernel/HALKit/POWER/AP.h b/src/kernel/HALKit/POWER/AP.h index b0a89138..2699d9f0 100644 --- a/src/kernel/HALKit/POWER/AP.h +++ b/src/kernel/HALKit/POWER/AP.h @@ -11,7 +11,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_AP_H +#define HALKIT_AP_H #include <NeKit/Config.h> @@ -37,3 +38,5 @@ typedef struct HAL_HARDWARE_THREAD { /// @return EXTERN_C Kernel::Void hal_set_pc_to_hart(HAL_HARDWARE_THREAD* hart, Kernel::VoidPtr epc); } // namespace Kernel + +#endif diff --git a/src/kernel/HALKit/POWER/Processor.h b/src/kernel/HALKit/POWER/Processor.h index 74352a00..decdfc38 100644 --- a/src/kernel/HALKit/POWER/Processor.h +++ b/src/kernel/HALKit/POWER/Processor.h @@ -6,7 +6,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_PROCESSOR_H +#define HALKIT_PROCESSOR_H #include <NeKit/Config.h> #include <NeKit/Utils.h> @@ -58,3 +59,5 @@ Kernel::Void hal_write_tlb(Kernel::UInt32 mas0, Kernel::UInt32 mas1, Kernel::UIn /// @brief Flush TLB. EXTERN_C Kernel::Void hal_flush_tlb(); + +#endif diff --git a/src/kernel/HALKit/RISCV/AP.h b/src/kernel/HALKit/RISCV/AP.h index b699d50f..0d8fbd94 100644 --- a/src/kernel/HALKit/RISCV/AP.h +++ b/src/kernel/HALKit/RISCV/AP.h @@ -11,7 +11,8 @@ ======================================== */ -#pragma once +#ifndef HALKIT_AP_H +#define HALKIT_AP_H #include <NeKit/Config.h> @@ -33,3 +34,5 @@ typedef struct HAL_HARDWARE_THREAD { /// @return EXTERN_C Kernel::Void hal_set_pc_to_hart(HAL_HARDWARE_THREAD* hart, Kernel::VoidPtr epc); } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/BinaryMutex.h b/src/kernel/KernelKit/BinaryMutex.h index 0609ca9c..48dc6e50 100644 --- a/src/kernel/KernelKit/BinaryMutex.h +++ b/src/kernel/KernelKit/BinaryMutex.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_BINARYMUTEX_H +#define KERNELKIT_BINARYMUTEX_H #include <CompilerKit/CompilerKit.h> #include <KernelKit/Timer.h> @@ -39,3 +40,5 @@ class BinaryMutex final { LockedPtr fLockingProcess{nullptr}; }; } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/CodeMgr.h b/src/kernel/KernelKit/CodeMgr.h index dc08fc99..8d8bce25 100644 --- a/src/kernel/KernelKit/CodeMgr.h +++ b/src/kernel/KernelKit/CodeMgr.h @@ -12,7 +12,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_CODEMGR_H +#define KERNELKIT_CODEMGR_H #include <KernelKit/CoreProcessScheduler.h> #include <KernelKit/IPEFDylibObject.h> @@ -47,3 +48,5 @@ BOOL rtl_create_kernel_task(HAL::StackFramePtr main, const KID kid); /// @return The team's process id. ProcessID rtl_create_user_process(rtl_start_kind main, const Char* process_name); } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/Config.h b/src/kernel/KernelKit/Config.h index f0d1e106..3b185a35 100644 --- a/src/kernel/KernelKit/Config.h +++ b/src/kernel/KernelKit/Config.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_CONFIG_H +#define KERNELKIT_CONFIG_H #include <NeKit/Config.h> @@ -16,4 +17,6 @@ class UserProcessScheduler; class IDylibObject; class UserProcess; class KernelTask; -} // namespace Kernel
\ No newline at end of file +} // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/CoreProcessScheduler.h b/src/kernel/KernelKit/CoreProcessScheduler.h index efb879f8..80651905 100644 --- a/src/kernel/KernelKit/CoreProcessScheduler.h +++ b/src/kernel/KernelKit/CoreProcessScheduler.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_COREPROCESSSCHEDULER_H +#define KERNELKIT_COREPROCESSSCHEDULER_H #include <NeKit/Config.h> #include <NeKit/ErrorOr.h> @@ -248,3 +249,5 @@ struct ProcessImage final { } }; } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/DebugOutput.h b/src/kernel/KernelKit/DebugOutput.h index 0818a712..54599e95 100644 --- a/src/kernel/KernelKit/DebugOutput.h +++ b/src/kernel/KernelKit/DebugOutput.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_DEBUGOUTPUT_H +#define KERNELKIT_DEBUGOUTPUT_H #include <CompilerKit/CompilerKit.h> #include <KernelKit/DeviceMgr.h> @@ -204,3 +205,5 @@ inline TerminalDevice& operator<<(TerminalDevice& src, const Long& num) { #endif // ifdef kendl8 #define kendl8 utf_end_line() + +#endif diff --git a/src/kernel/KernelKit/DeviceMgr.h b/src/kernel/KernelKit/DeviceMgr.h index 56208140..45c5e50a 100644 --- a/src/kernel/KernelKit/DeviceMgr.h +++ b/src/kernel/KernelKit/DeviceMgr.h @@ -13,7 +13,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_DEVICEMGR_H +#define KERNELKIT_DEVICEMGR_H /* @note Device Mgr. */ /* @file KernelKit/DeviceMgr.h */ @@ -131,3 +132,5 @@ enum { kDeviceTypeCount, }; } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/IDylibObject.h b/src/kernel/KernelKit/IDylibObject.h index d834b8db..f0cb00c4 100644 --- a/src/kernel/KernelKit/IDylibObject.h +++ b/src/kernel/KernelKit/IDylibObject.h @@ -7,7 +7,8 @@ * ======================================================== */ -#pragma once +#ifndef KERNELKIT_IDYLIBOBJECT_H +#define KERNELKIT_IDYLIBOBJECT_H #include <CompilerKit/CompilerKit.h> #include <NeKit/Config.h> @@ -43,3 +44,5 @@ class IDylibObject { /// @brief Pure implementation, missing method/function handler. EXTERN_C void __ne_pure_call(void); } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/IFS.h b/src/kernel/KernelKit/IFS.h index c885d350..f62718d4 100644 --- a/src/kernel/KernelKit/IFS.h +++ b/src/kernel/KernelKit/IFS.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_IFS_H +#define KERNELKIT_IFS_H #include <KernelKit/DriveMgr.h> @@ -23,3 +24,5 @@ Int32 fs_ifs_read(IMountpoint* mnt, DriveTrait& drvTrait, Int32 drvIndex); /// @return Status code Int32 fs_ifs_write(IMountpoint* mnt, DriveTrait& drvTrait, Int32 drvIndex); } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/ILoader.h b/src/kernel/KernelKit/ILoader.h index 8a6b8bfa..dedff7ad 100644 --- a/src/kernel/KernelKit/ILoader.h +++ b/src/kernel/KernelKit/ILoader.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_ILOADER_H +#define KERNELKIT_ILOADER_H #include <CompilerKit/CompilerKit.h> #include <NeKit/Config.h> @@ -30,3 +31,5 @@ class ILoader { virtual _Output ErrorOr<VoidPtr> FindSymbol(_Input const Char*, _Input Int32) { return ErrorOr<VoidPtr>{}; } }; } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/KPC.h b/src/kernel/KernelKit/KPC.h index 4809f19f..63531f14 100644 --- a/src/kernel/KernelKit/KPC.h +++ b/src/kernel/KernelKit/KPC.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_KPC_H +#define KERNELKIT_KPC_H #include <NeKit/Config.h> @@ -77,3 +78,5 @@ inline constexpr KPCError kErrorUnimplemented = -1; /// @return if error-free: false, otherwise true. Boolean err_bug_check_raise(Void); } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/KernelTaskScheduler.h b/src/kernel/KernelKit/KernelTaskScheduler.h index a3fba2af..8564b043 100644 --- a/src/kernel/KernelKit/KernelTaskScheduler.h +++ b/src/kernel/KernelKit/KernelTaskScheduler.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_KERNELTASKSCHEDULER_H +#define KERNELKIT_KERNELTASKSCHEDULER_H /// @file KernelTaskScheduler.h /// @brief Kernel Task Scheduler backend file. @@ -46,4 +47,6 @@ class KernelTaskHelper final { STATIC ErrorOr<KID> TheCurrentKID(); STATIC SizeT StartScheduling(); }; -} // namespace Kernel
\ No newline at end of file +} // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/LockDelegate.h b/src/kernel/KernelKit/LockDelegate.h index 51f86780..c3778e19 100644 --- a/src/kernel/KernelKit/LockDelegate.h +++ b/src/kernel/KernelKit/LockDelegate.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_LOCKDELEGATE_H +#define KERNELKIT_LOCKDELEGATE_H #include <NeKit/Atom.h> #include <NeKit/Config.h> @@ -56,3 +57,5 @@ class LockDelegate final { Atom<UInt> fLockStatus; }; } // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/PCI/DMA.h b/src/kernel/KernelKit/PCI/DMA.h index d965a3c9..6ca34e0d 100644 --- a/src/kernel/KernelKit/PCI/DMA.h +++ b/src/kernel/KernelKit/PCI/DMA.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_DMA_H +#define KERNELKIT_DMA_H #include <KernelKit/DeviceMgr.h> #include <KernelKit/PCI/Device.h> @@ -73,3 +74,5 @@ class DMAFactory final { } // namespace Kernel #include <KernelKit/PCI/DMA.inl> + +#endif diff --git a/src/kernel/KernelKit/PCI/Database.h b/src/kernel/KernelKit/PCI/Database.h index 35740fdc..adde60b6 100644 --- a/src/kernel/KernelKit/PCI/Database.h +++ b/src/kernel/KernelKit/PCI/Database.h @@ -3,7 +3,8 @@ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once +#ifndef KERNELKIT_DATABASE_H +#define KERNELKIT_DATABASE_H #include <KernelKit/PCI/Device.h> #include <NeKit/Config.h> @@ -48,4 +49,6 @@ inline BOOL operator!=(Kernel::UChar lhs, const Kernel::Types::PciDeviceKind& rh inline BOOL operator==(Kernel::UChar lhs, const Kernel::Types::PciDeviceKind& rhs) { return lhs == (Kernel::UChar) rhs; -}
\ No newline at end of file +} + +#endif diff --git a/src/kernel/KernelKit/PCI/Device.h b/src/kernel/KernelKit/PCI/Device.h index 3e7284de..e585029d 100644 --- a/src/kernel/KernelKit/PCI/Device.h +++ b/src/kernel/KernelKit/PCI/Device.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_DEVICE_H +#define KERNELKIT_DEVICE_H #include <NeKit/Config.h> #include <NeKit/KernelPanic.h> @@ -73,3 +74,5 @@ class Device final { UInt32 fBar; }; } // namespace Kernel::PCI + +#endif diff --git a/src/kernel/KernelKit/PCI/Express.h b/src/kernel/KernelKit/PCI/Express.h index b3411938..e33f9a5d 100644 --- a/src/kernel/KernelKit/PCI/Express.h +++ b/src/kernel/KernelKit/PCI/Express.h @@ -4,9 +4,12 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_EXPRESS_H +#define KERNELKIT_EXPRESS_H #include <KernelKit/PCI/PCI.h> #include <NeKit/Config.h> #define PCI_EXPRESS_BUS_COUNT (4096) + +#endif diff --git a/src/kernel/KernelKit/PCI/IO.h b/src/kernel/KernelKit/PCI/IO.h index dc9f9aa1..65cbf28e 100644 --- a/src/kernel/KernelKit/PCI/IO.h +++ b/src/kernel/KernelKit/PCI/IO.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_IO_H +#define KERNELKIT_IO_H #include <ArchKit/ArchKit.h> #include <NeKit/Array.h> @@ -61,3 +62,5 @@ inline Array<UShort, Sz> make_ports(UShort base) { #else #error Please provide platform specific code for the I/O #endif // ifdef __NE_AMD64__ + +#endif diff --git a/src/kernel/KernelKit/PCI/PCI.h b/src/kernel/KernelKit/PCI/PCI.h index a60145fd..d57478e8 100644 --- a/src/kernel/KernelKit/PCI/PCI.h +++ b/src/kernel/KernelKit/PCI/PCI.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_PCI_H +#define KERNELKIT_PCI_H #include <NeKit/Config.h> @@ -52,3 +53,5 @@ class BAR { Detail::BAR BAR5; }; } // namespace Kernel::PCI + +#endif diff --git a/src/kernel/KernelKit/PE32CodeMgr.h b/src/kernel/KernelKit/PE32CodeMgr.h index 3e359a7c..d5af331c 100644 --- a/src/kernel/KernelKit/PE32CodeMgr.h +++ b/src/kernel/KernelKit/PE32CodeMgr.h @@ -11,7 +11,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_PE32CODEMGR_H +#define KERNELKIT_PE32CODEMGR_H //////////////////////////////////////////////////// @@ -85,4 +86,6 @@ using PE_SECTION_INFO = LDR_SECTION_HEADER; ProcessID rtl_create_user_process(PE32Loader& exec, const UserProcess::ExecutableKind& process_kind); -} // namespace Kernel
\ No newline at end of file +} // namespace Kernel + +#endif diff --git a/src/kernel/KernelKit/ProcessScheduler.h b/src/kernel/KernelKit/ProcessScheduler.h index 74a238f1..d093871b 100644 --- a/src/kernel/KernelKit/ProcessScheduler.h +++ b/src/kernel/KernelKit/ProcessScheduler.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_PROCESSSCHEDULER_H +#define KERNELKIT_PROCESSSCHEDULER_H #include <KernelKit/KernelTaskScheduler.h> #include <KernelKit/UserProcessScheduler.h> @@ -16,4 +17,6 @@ inline UserProcessTeam kHighUserTeam; inline UserProcessTeam kMidUserTeam; inline UserProcessTeam kRTUserTeam; } // namespace Kernel +#endif + #endif
\ No newline at end of file diff --git a/src/kernel/KernelKit/ZXD.h b/src/kernel/KernelKit/ZXD.h index 1ead7b1f..b7d723d6 100644 --- a/src/kernel/KernelKit/ZXD.h +++ b/src/kernel/KernelKit/ZXD.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef KERNELKIT_ZXD_H +#define KERNELKIT_ZXD_H #include <NeKit/Config.h> @@ -57,3 +58,5 @@ inline constexpr auto kProsanName = ".pros"; using ZxdExecPtr = ZxdExec*; using ZxdStubPtr = ZxdStub*; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/Array.h b/src/kernel/NeKit/Array.h index 179b8e4e..1b01760d 100644 --- a/src/kernel/NeKit/Array.h +++ b/src/kernel/NeKit/Array.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_ARRAY_H +#define NEKIT_ARRAY_H #include <KernelKit/DebugOutput.h> #include <NeKit/Config.h> @@ -42,3 +43,5 @@ inline auto make_array(ValueType& val) -> auto { return Array<ValueType, ARRAY_SIZE(val)>{val}; } } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/Config.h b/src/kernel/NeKit/Config.h index 3eceb79e..e7087a18 100644 --- a/src/kernel/NeKit/Config.h +++ b/src/kernel/NeKit/Config.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_CONFIG_H +#define NEKIT_CONFIG_H #include <NeKit/Macros.h> @@ -220,3 +221,5 @@ struct PropertyResult final { static constexpr bool kValue = Type::kValue; }; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/CxxAbi.h b/src/kernel/NeKit/CxxAbi.h index 41956d3f..c9d60739 100644 --- a/src/kernel/NeKit/CxxAbi.h +++ b/src/kernel/NeKit/CxxAbi.h @@ -3,7 +3,8 @@ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once +#ifndef NEKIT_CXXABI_H +#define NEKIT_CXXABI_H #include <NeKit/Config.h> @@ -24,3 +25,5 @@ typedef Kernel::SizeT* __guard; } #endif // !__NECTI__ + +#endif diff --git a/src/kernel/NeKit/ErrorOr.h b/src/kernel/NeKit/ErrorOr.h index 5fa8054b..07d544cb 100644 --- a/src/kernel/NeKit/ErrorOr.h +++ b/src/kernel/NeKit/ErrorOr.h @@ -7,7 +7,8 @@ * ======================================================== */ -#pragma once +#ifndef NEKIT_ERROROR_H +#define NEKIT_ERROROR_H #include <NeKit/Config.h> #include <NeKit/Ref.h> @@ -63,3 +64,5 @@ class ErrorOr final { using ErrorOrAny = ErrorOr<voidPtr>; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/Function.h b/src/kernel/NeKit/Function.h index dfa8608a..fcc3b65c 100644 --- a/src/kernel/NeKit/Function.h +++ b/src/kernel/NeKit/Function.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_FUNCTION_H +#define NEKIT_FUNCTION_H #include <NeKit/Config.h> #include <NeKit/ErrorOr.h> @@ -37,3 +38,5 @@ class Function final { template <typename T, typename... Args> using FunctionOr = ErrorOr<Function<T, Args...>>; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/Json.h b/src/kernel/NeKit/Json.h index 44db52ba..229b8ee6 100644 --- a/src/kernel/NeKit/Json.h +++ b/src/kernel/NeKit/Json.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_JSON_H +#define NEKIT_JSON_H /// @brief Kernel JSON API. @@ -143,3 +144,5 @@ struct AsciiJsonStreamReader final { /// ================================================================================ using AsciiJsonStream = Stream<AsciiJsonStreamReader, JsonObject<Char>>; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/KString.h b/src/kernel/NeKit/KString.h index a27084cb..e195dd62 100644 --- a/src/kernel/NeKit/KString.h +++ b/src/kernel/NeKit/KString.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_KSTRING_H +#define NEKIT_KSTRING_H #include <CompilerKit/CompilerKit.h> #include <NeKit/Config.h> @@ -90,3 +91,5 @@ class KStringBuilder final { } // namespace Kernel #include <NeKit/KString.inl> + +#endif diff --git a/src/kernel/NeKit/KernelPanic.h b/src/kernel/NeKit/KernelPanic.h index 27cbbb6b..d8483d19 100644 --- a/src/kernel/NeKit/KernelPanic.h +++ b/src/kernel/NeKit/KernelPanic.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_KERNELPANIC_H +#define NEKIT_KERNELPANIC_H #include <NeKit/Config.h> @@ -65,3 +66,5 @@ namespace Kernel { void ke_runtime_check(bool expr, const Char* file, const Char* line); void ke_panic(const Int32& id, const Char* message = nullptr); } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/Macros.h b/src/kernel/NeKit/Macros.h index 80a2ff6c..deb91d6a 100644 --- a/src/kernel/NeKit/Macros.h +++ b/src/kernel/NeKit/Macros.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_MACROS_H +#define NEKIT_MACROS_H /***********************************************************************************/ /// @file NeKit/Macros.h @@ -149,3 +150,5 @@ #endif // ifdef RTL_INIT_OBJECT #define RTL_INIT_OBJECT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__) + +#endif diff --git a/src/kernel/NeKit/MutableArray.h b/src/kernel/NeKit/MutableArray.h index 6dafa5b9..caf4fd9f 100644 --- a/src/kernel/NeKit/MutableArray.h +++ b/src/kernel/NeKit/MutableArray.h @@ -3,7 +3,9 @@ Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once + +#ifndef NEKIT_MUTABLEARRAY_H +#define NEKIT_MUTABLEARRAY_H #include <CompilerKit/CompilerKit.h> #include <NeKit/Array.h> @@ -201,3 +203,5 @@ class MutableArray : public NullableMutableArray<voidPtr, nullptr> { Kernel::SizeT fNodeCount{0}; }; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/NeKit.h b/src/kernel/NeKit/NeKit.h index 9bf74e57..4c290016 100644 --- a/src/kernel/NeKit/NeKit.h +++ b/src/kernel/NeKit/NeKit.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_NEKIT_H +#define NEKIT_NEKIT_H #include <NeKit/Array.h> #include <NeKit/ErrorOr.h> @@ -18,3 +19,5 @@ #include <NeKit/Ref.h> #include <NeKit/Stream.h> #include <NeKit/Utils.h> + +#endif diff --git a/src/kernel/NeKit/New.h b/src/kernel/NeKit/New.h index bd986347..203dea24 100644 --- a/src/kernel/NeKit/New.h +++ b/src/kernel/NeKit/New.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_NEW_H +#define NEKIT_NEW_H #include <KernelKit/HeapMgr.h> @@ -18,3 +19,5 @@ void* operator new[](size_t); void operator delete(void*); void operator delete(void*, unsigned long); void operator delete[](void*); + +#endif diff --git a/src/kernel/NeKit/OwnPtr.h b/src/kernel/NeKit/OwnPtr.h index ceb6142d..ea71f06d 100644 --- a/src/kernel/NeKit/OwnPtr.h +++ b/src/kernel/NeKit/OwnPtr.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_OWNPTR_H +#define NEKIT_OWNPTR_H #include <NeKit/Config.h> #include <NeKit/ErrorOr.h> @@ -51,7 +52,7 @@ class OwnPtr final { Ref<T> AsRef() { return Ref<T>(fCls); } explicit operator bool() { return fCls; } - + private: T* fCls{nullptr}; }; @@ -67,3 +68,5 @@ inline OwnPtr<T> make_ptr(Args&&... args) { return ret; } } // namespace Kernel + +#endif
\ No newline at end of file diff --git a/src/kernel/NeKit/PageMgr.h b/src/kernel/NeKit/PageMgr.h index 1bd489af..4c0f03f3 100644 --- a/src/kernel/NeKit/PageMgr.h +++ b/src/kernel/NeKit/PageMgr.h @@ -7,7 +7,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_PAGEMGR_H +#define NEKIT_PAGEMGR_H #include <NeKit/Config.h> #include <NeKit/Ref.h> @@ -74,3 +75,5 @@ struct PageMgr final { friend class Pmm; }; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/Pair.h b/src/kernel/NeKit/Pair.h index 6c67d508..5ede69fa 100644 --- a/src/kernel/NeKit/Pair.h +++ b/src/kernel/NeKit/Pair.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_PAIR_H +#define NEKIT_PAIR_H #include <CompilerKit/CompilerKit.h> #include <NeKit/Config.h> @@ -49,3 +50,5 @@ class PairBuilder final { template <typename T1, typename T2> using PairOr = ErrorOr<Pair<T1, T2>>; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/Pmm.h b/src/kernel/NeKit/Pmm.h index d8d04a0b..bcb43be7 100644 --- a/src/kernel/NeKit/Pmm.h +++ b/src/kernel/NeKit/Pmm.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_PMM_H +#define NEKIT_PMM_H #include <NeKit/Config.h> #include <NeKit/PageMgr.h> @@ -39,3 +40,5 @@ class Pmm final { Ref<PageMgr> fPageMgr; }; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/Stream.h b/src/kernel/NeKit/Stream.h index 44b98e35..7125f573 100644 --- a/src/kernel/NeKit/Stream.h +++ b/src/kernel/NeKit/Stream.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_STREAM_H +#define NEKIT_STREAM_H #include <NeKit/Config.h> #include <NeKit/Ref.h> @@ -43,3 +44,5 @@ class Stream final { Ref<Kind> fKind; }; } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/TOML.h b/src/kernel/NeKit/TOML.h index 9249152b..4293e532 100644 --- a/src/kernel/NeKit/TOML.h +++ b/src/kernel/NeKit/TOML.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_TOML_H +#define NEKIT_TOML_H #include <NeKit/Config.h> #include <NeKit/KString.h> @@ -23,4 +24,6 @@ class TOMLObject final { KString fKey; KString fValue; }; -} // namespace Kernel
\ No newline at end of file +} // namespace Kernel + +#endif
\ No newline at end of file diff --git a/src/kernel/NeKit/Utils.h b/src/kernel/NeKit/Utils.h index 71cae42b..aed3ac48 100644 --- a/src/kernel/NeKit/Utils.h +++ b/src/kernel/NeKit/Utils.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_UTILS_H +#define NEKIT_UTILS_H #include <NeKit/Config.h> @@ -70,3 +71,5 @@ inline constexpr SizeT oe_string_len(const CharType* str) { #endif } } // namespace Kernel + +#endif diff --git a/src/kernel/NeKit/Variant.h b/src/kernel/NeKit/Variant.h index c7aa509c..d26caf0e 100644 --- a/src/kernel/NeKit/Variant.h +++ b/src/kernel/NeKit/Variant.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NEKIT_VARIANT_H +#define NEKIT_VARIANT_H #include <NeKit/Config.h> #include <NeKit/Json.h> @@ -66,3 +67,5 @@ class Variant final { VariantKind fKind{VariantKind::kNull}; }; } // namespace Kernel + +#endif diff --git a/src/kernel/NetworkKit/IP.h b/src/kernel/NetworkKit/IP.h index 625e59e3..59ec97be 100644 --- a/src/kernel/NetworkKit/IP.h +++ b/src/kernel/NetworkKit/IP.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NETWORKKIT_IP_H +#define NETWORKKIT_IP_H #include <KernelKit/DebugOutput.h> #include <NeKit/Config.h> @@ -74,3 +75,5 @@ class IPFactory final { static bool IpCheckVersion4(const Char* ip); }; } // namespace Kernel + +#endif diff --git a/src/kernel/NetworkKit/MAC.h b/src/kernel/NetworkKit/MAC.h index 5291d855..6a2ab5a6 100644 --- a/src/kernel/NetworkKit/MAC.h +++ b/src/kernel/NetworkKit/MAC.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef NETWORKKIT_MAC_H +#define NETWORKKIT_MAC_H #include <NeKit/Array.h> #include <NeKit/Config.h> @@ -32,3 +33,5 @@ class MacAddressGetter final { }; } // namespace Kernel + +#endif diff --git a/src/kernel/SignalKit/Signals.h b/src/kernel/SignalKit/Signals.h index 4369d5a0..1718e42a 100644 --- a/src/kernel/SignalKit/Signals.h +++ b/src/kernel/SignalKit/Signals.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef SIGNALKIT_SIGNALS_H +#define SIGNALKIT_SIGNALS_H #include <NeKit/Config.h> #include <NeKit/KernelPanic.h> @@ -51,3 +52,5 @@ inline BOOL sig_validate_unique(rt_signal_kind sig) { return sig > SIGBAD && sig > SIGDTCH; } } // namespace Kernel + +#endif diff --git a/src/kernel/StorageKit/AHCI.h b/src/kernel/StorageKit/AHCI.h index d29cb0fc..fa74a0f4 100644 --- a/src/kernel/StorageKit/AHCI.h +++ b/src/kernel/StorageKit/AHCI.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef STORAGEKIT_AHCI_H +#define STORAGEKIT_AHCI_H #include <KernelKit/DeviceMgr.h> #include <KernelKit/DriveMgr.h> @@ -45,3 +46,5 @@ class AHCIDeviceInterface NE_DEVICE<IMountpoint*> { UInt16 sk_init_ahci_device(BOOL atapi); ErrorOr<AHCIDeviceInterface> sk_acquire_ahci_device(UInt32 drv_index); } // namespace Kernel + +#endif diff --git a/src/kernel/StorageKit/ATA.h b/src/kernel/StorageKit/ATA.h index 729cf4f7..3b33a97d 100644 --- a/src/kernel/StorageKit/ATA.h +++ b/src/kernel/StorageKit/ATA.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef STORAGEKIT_ATA_H +#define STORAGEKIT_ATA_H #include <KernelKit/DeviceMgr.h> #include <KernelKit/DriveMgr.h> @@ -54,3 +55,5 @@ BOOL sk_init_ata_device(BOOL is_master, UInt16& io, UInt8& master); /// @return A wrapped device interface if successful, or error code. ErrorOr<ATADeviceInterface> sk_acquire_ata_device(Int32 drv_index); } // namespace Kernel + +#endif diff --git a/src/kernel/StorageKit/NVME.h b/src/kernel/StorageKit/NVME.h index 3a4ced1e..80b1630a 100644 --- a/src/kernel/StorageKit/NVME.h +++ b/src/kernel/StorageKit/NVME.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef STORAGEKIT_NVME_H +#define STORAGEKIT_NVME_H #include <KernelKit/DeviceMgr.h> #include <KernelKit/DriveMgr.h> @@ -29,3 +30,5 @@ class NVMEDeviceInterface final NE_DEVICE<IMountpoint*> { Void (*fCleanup)(Void) = {nullptr}; }; } // namespace Kernel + +#endif diff --git a/src/kernel/StorageKit/PRDT.h b/src/kernel/StorageKit/PRDT.h index 44eb11be..0b0ce32e 100644 --- a/src/kernel/StorageKit/PRDT.h +++ b/src/kernel/StorageKit/PRDT.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef STORAGEKIT_PRDT_H +#define STORAGEKIT_PRDT_H #include <KernelKit/PCI/DMA.h> #include <KernelKit/PCI/Iterator.h> @@ -31,3 +32,5 @@ void construct_prdt(Ref<PRDT>& prd); EXTERN_C Int32 kPRDTTransferStatus; } // namespace Kernel + +#endif diff --git a/src/kernel/StorageKit/SCSI.h b/src/kernel/StorageKit/SCSI.h index 3354a678..83395e0e 100644 --- a/src/kernel/StorageKit/SCSI.h +++ b/src/kernel/StorageKit/SCSI.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef STORAGEKIT_SCSI_H +#define STORAGEKIT_SCSI_H #include <KernelKit/DriveMgr.h> #include <NeKit/OwnPtr.h> @@ -27,3 +28,5 @@ class SCSIDeviceInterface final NE_DEVICE<IMountpoint*> { Void (*fCleanup)(Void) = {nullptr}; }; } // namespace Kernel + +#endif diff --git a/src/kernel/StorageKit/StorageKit.h b/src/kernel/StorageKit/StorageKit.h index d7a1b6e9..87dd346e 100644 --- a/src/kernel/StorageKit/StorageKit.h +++ b/src/kernel/StorageKit/StorageKit.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef STORAGEKIT_STORAGEKIT_H +#define STORAGEKIT_STORAGEKIT_H #define kDriveSectorSizeHDD (512U) #define kDriveSectorSizeSSD (512U) @@ -19,3 +20,5 @@ class AHCIDeviceInterface; class ATADeviceInterface; class SCSIDeviceInterface; } // namespace Kernel + +#endif diff --git a/src/kernel/SwapKit/DiskSwap.h b/src/kernel/SwapKit/DiskSwap.h index c3297c66..e1e9b317 100644 --- a/src/kernel/SwapKit/DiskSwap.h +++ b/src/kernel/SwapKit/DiskSwap.h @@ -5,7 +5,8 @@ ======================================== */ -#pragma once +#ifndef SWAPKIT_DISKSWAP_H +#define SWAPKIT_DISKSWAP_H #include <CompilerKit/CompilerKit.h> #include <NeKit/Config.h> @@ -70,3 +71,5 @@ typedef struct SwapDiskHdr { UInt8 fBlob[1]; } PACKED ALIGN(8) SwapDiskHdr; } // namespace Kernel + +#endif diff --git a/src/launch/LaunchKit/Foundation.h b/src/launch/LaunchKit/Foundation.h index 5fb8efea..e14abf6f 100644 --- a/src/launch/LaunchKit/Foundation.h +++ b/src/launch/LaunchKit/Foundation.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef LAUNCHKIT_FOUNDATION_H +#define LAUNCHKIT_FOUNDATION_H #include <CoreFoundation.fwrk/headers/Ref.h> #include <libSystem/SystemKit/System.h> @@ -19,3 +20,5 @@ namespace LaunchKit { using AnyRef = CF::CFRef<VoidPtr>; using StatusRef = CF::CFRef<SInt32>; } // namespace LaunchKit + +#endif diff --git a/src/libDDK/DriverKit/c++/checksum.h b/src/libDDK/DriverKit/c++/checksum.h index 99199f56..f9abf291 100644 --- a/src/libDDK/DriverKit/c++/checksum.h +++ b/src/libDDK/DriverKit/c++/checksum.h @@ -7,6 +7,9 @@ ======================================== */ -#pragma once +#ifndef DRIVERKIT_CHECKSUM_H +#define DRIVERKIT_CHECKSUM_H -/// @todo Driver checksum
\ No newline at end of file +/// @todo Driver checksum + +#endif diff --git a/src/libDDK/DriverKit/c++/ddk.h b/src/libDDK/DriverKit/c++/ddk.h index 65ccb102..f3342352 100644 --- a/src/libDDK/DriverKit/c++/ddk.h +++ b/src/libDDK/DriverKit/c++/ddk.h @@ -7,7 +7,10 @@ ======================================== */ -#pragma once +#ifndef DRIVERKIT_DDK_H +#define DRIVERKIT_DDK_H #include <DriverKit/c++/checksum.h> #include <DriverKit/c++/driver_base.h> + +#endif diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h index 28119f49..db967b43 100644 --- a/src/libDDK/DriverKit/c++/driver_base.h +++ b/src/libDDK/DriverKit/c++/driver_base.h @@ -7,7 +7,8 @@ ======================================== */ -#pragma once +#ifndef DRIVERKIT_DRIVER_BASE_H +#define DRIVERKIT_DRIVER_BASE_H #include <libDDK/DriverKit/macros.h> @@ -45,3 +46,5 @@ concept IsValidDriver = requires(Driver drv) { { drv.IsActive() && drv.Type() > kInvalidType }; }; } // namespace Kernel::DDK + +#endif diff --git a/src/libDDK/DriverKit/ddk.h b/src/libDDK/DriverKit/ddk.h index 45f7d356..19b2869c 100644 --- a/src/libDDK/DriverKit/ddk.h +++ b/src/libDDK/DriverKit/ddk.h @@ -7,7 +7,8 @@ ======================================== */ -#pragma once +#ifndef DRIVERKIT_DDK_H +#define DRIVERKIT_DDK_H #include <DriverKit/macros.h> @@ -74,3 +75,5 @@ DDK_EXTERN uint32_t kApiVersionLowest; /// @brief API version in BCD. DDK_EXTERN uint32_t kApiVersion; + +#endif diff --git a/src/libDDK/DriverKit/dev.h b/src/libDDK/DriverKit/dev.h index 1dda544e..f6574022 100644 --- a/src/libDDK/DriverKit/dev.h +++ b/src/libDDK/DriverKit/dev.h @@ -7,7 +7,8 @@ ======================================== */ -#pragma once +#ifndef DRIVERKIT_DEV_H +#define DRIVERKIT_DEV_H #include <DriverKit/ddk.h> @@ -37,3 +38,5 @@ DDK_EXTERN DDK_DEVICE_PTR kopen_dev(const char* path); /// @brief Close any device. /// @param device valid device. DDK_EXTERN BOOL kclose_dev(DDK_DEVICE_PTR device); + +#endif diff --git a/src/libDDK/DriverKit/io.h b/src/libDDK/DriverKit/io.h index 58b625ac..c867e898 100644 --- a/src/libDDK/DriverKit/io.h +++ b/src/libDDK/DriverKit/io.h @@ -6,7 +6,8 @@ ======================================== */ -#pragma once +#ifndef DRIVERKIT_IO_H +#define DRIVERKIT_IO_H #include <DriverKit/str.h> @@ -16,3 +17,5 @@ DDK_EXTERN void kputc(const char ch); /// @brief print string to UART. /// @param message string to transmit to UART. DDK_EXTERN void kprint(const char* message); + +#endif diff --git a/src/libDDK/DriverKit/macros.h b/src/libDDK/DriverKit/macros.h index 7fd1403b..7e69767d 100644 --- a/src/libDDK/DriverKit/macros.h +++ b/src/libDDK/DriverKit/macros.h @@ -7,7 +7,8 @@ ======================================== */ -#pragma once +#ifndef DRIVERKIT_MACROS_H +#define DRIVERKIT_MACROS_H #include <stddef.h> #include <stdint.h> @@ -45,4 +46,6 @@ #ifndef __NEOSKRNL__ #error !!! Do not include header in EL0/Ring 3 mode !!! -#endif // __NEOSKRNL__
\ No newline at end of file +#endif // __NEOSKRNL__ + +#endif diff --git a/src/libDDK/DriverKit/net.h b/src/libDDK/DriverKit/net.h index 5dfe6374..f7bda9e6 100644 --- a/src/libDDK/DriverKit/net.h +++ b/src/libDDK/DriverKit/net.h @@ -7,10 +7,13 @@ ======================================== */ -#pragma once +#ifndef DRIVERKIT_NET_H +#define DRIVERKIT_NET_H #include <DriverKit/macros.h> struct DDK_NET_MANIFEST; /// @brief IFS hooks to plug into the FileMgr. + +#endif diff --git a/src/libDDK/DriverKit/str.h b/src/libDDK/DriverKit/str.h index 6409b1a7..a8fdf89b 100644 --- a/src/libDDK/DriverKit/str.h +++ b/src/libDDK/DriverKit/str.h @@ -6,7 +6,8 @@ ======================================== */ -#pragma once +#ifndef DRIVERKIT_STR_H +#define DRIVERKIT_STR_H #include <DriverKit/ddk.h> @@ -15,3 +16,5 @@ DDK_EXTERN size_t kstrlen(const char* in); DDK_EXTERN int kstrncpy(char* dst, const char* src, size_t len); + +#endif diff --git a/src/libMsg/MsgKit/Network.h b/src/libMsg/MsgKit/Network.h index ca7cf2d3..7a3ea2d9 100644 --- a/src/libMsg/MsgKit/Network.h +++ b/src/libMsg/MsgKit/Network.h @@ -4,6 +4,9 @@ ======================================== */ -#pragma once +#ifndef MSGKIT_NETWORK_H +#define MSGKIT_NETWORK_H -#include <libMsg/MsgKit/Server.h>
\ No newline at end of file +#include <libMsg/MsgKit/Server.h> + +#endif diff --git a/src/libMsg/MsgKit/Server.h b/src/libMsg/MsgKit/Server.h index b75fb96a..d7325ba9 100644 --- a/src/libMsg/MsgKit/Server.h +++ b/src/libMsg/MsgKit/Server.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef MSGKIT_SERVER_H +#define MSGKIT_SERVER_H #ifdef __cplusplus #include <public/frameworks/CoreFoundation.fwrk/headers/String.h> @@ -39,3 +40,5 @@ typedef Void (*libmsg_func_type)(struct LIBMSG_EXPR* self, VoidPtr arg, SizeT ar IMPORT_C Void libmsg_init_library(libmsg_func_type* funcs, SizeT cnt); IMPORT_C UInt32 libmsg_close_library(Void); IMPORT_C UInt32 libmsg_eval_expr(struct LIBMSG_EXPR* head); + +#endif diff --git a/src/libSystem/SystemKit/Err.h b/src/libSystem/SystemKit/Err.h index ea36abde..7e8dbee4 100644 --- a/src/libSystem/SystemKit/Err.h +++ b/src/libSystem/SystemKit/Err.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef SYSTEMKIT_ERR_H +#define SYSTEMKIT_ERR_H #include <libSystem/SystemKit/Macros.h> @@ -56,3 +57,5 @@ inline constexpr ErrRef kErrorUnimplemented = -1; /// @brief The last error reported by the system to the process. IMPORT_C ErrRef kLastError; + +#endif diff --git a/src/libSystem/SystemKit/Jail.h b/src/libSystem/SystemKit/Jail.h index f28968b4..acf392b4 100644 --- a/src/libSystem/SystemKit/Jail.h +++ b/src/libSystem/SystemKit/Jail.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef SYSTEMKIT_JAIL_H +#define SYSTEMKIT_JAIL_H #include <libSystem/SystemKit/System.h> @@ -34,3 +35,5 @@ struct JAIL { /// @brief Get the current jail /// @return Pointer to the current jail structure, or NULL if not in a jail IMPORT_C struct JAIL* JailGetCurrent(Void); + +#endif diff --git a/src/libSystem/SystemKit/Macros.h b/src/libSystem/SystemKit/Macros.h index b30db701..dab30384 100644 --- a/src/libSystem/SystemKit/Macros.h +++ b/src/libSystem/SystemKit/Macros.h @@ -7,7 +7,8 @@ Purpose: libsci Macros header. ======================================== */ -#pragma once +#ifndef SYSTEMKIT_MACROS_H +#define SYSTEMKIT_MACROS_H /***********************************************************************************/ /// @file libSystem/Macros.h @@ -124,3 +125,5 @@ typedef nullPtr NullPtr; #define LIBSYS_UNUSED(X) ((void) X) IMPORT_C void _rtl_assert(Bool expr, const Char* origin); + +#endif diff --git a/src/libSystem/SystemKit/Syscall.h b/src/libSystem/SystemKit/Syscall.h index 58d7d7f1..1d30782f 100644 --- a/src/libSystem/SystemKit/Syscall.h +++ b/src/libSystem/SystemKit/Syscall.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef SYSTEMKIT_SYSCALL_H +#define SYSTEMKIT_SYSCALL_H #include <libSystem/SystemKit/System.h> #include <cstdarg> @@ -19,3 +20,5 @@ IMPORT_C UInt64 libsys_hash_64(const Char* path); #ifndef SYSCALL_HASH #define SYSCALL_HASH(str) libsys_hash_64(str) #endif // !SYSCALL_HASH + +#endif diff --git a/src/libSystem/SystemKit/Verify.h b/src/libSystem/SystemKit/Verify.h index c584ac82..0bdfd2ca 100644 --- a/src/libSystem/SystemKit/Verify.h +++ b/src/libSystem/SystemKit/Verify.h @@ -7,7 +7,8 @@ ======================================== */ -#pragma once +#ifndef SYSTEMKIT_VERIFY_H +#define SYSTEMKIT_VERIFY_H #include <libSystem/SystemKit/System.h> @@ -15,14 +16,11 @@ namespace LibSystem::Verify { /// @author 0xf00sec, and Amlal El Mahrouss /// @brief safe cast operator. template <class T, class R> -inline R sys_safe_cast(const T* ptr) { +inline R* sys_safe_cast(const T* ptr) { ::_rtl_assert(ptr, "safe cast failed!"); return static_cast<R*>(const_cast<T*>(ptr)); } -template <class T, class R = Void> -inline Void sys_safe_cast(const T* ptr) = delete; - template <class T, class U> struct is_castable { using return_type = U; @@ -45,3 +43,5 @@ constexpr R* sys_constexpr_cast(T* ptr) { return static_cast<R*>(ptr); } } // namespace LibSystem::Verify + +#endif diff --git a/src/libSystem/src/SystemCalls.cc b/src/libSystem/src/SystemCalls.cc index 95545cde..c9dc1c52 100644 --- a/src/libSystem/src/SystemCalls.cc +++ b/src/libSystem/src/SystemCalls.cc @@ -123,7 +123,7 @@ IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input UInt64 len, _Input UIn IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) {
return static_cast<Ref>(libsys_syscall_arg_3(
- SYSCALL_HASH("IoOpenFile"), Verify::sys_safe_cast(path), Verify::sys_safe_cast(drv_letter)));
+ SYSCALL_HASH("IoOpenFile"), Verify::sys_safe_cast<Char, Void>(path), Verify::sys_safe_cast<Char, Void>(drv_letter)));
}
IMPORT_C Void IoCloseFile(_Input Ref desc) {
@@ -159,7 +159,7 @@ IMPORT_C SInt32 PrintOut(_Input IORef desc, const Char* fmt, ...) { // if truncated, `needed` >= kBufferSz; we still send truncated buffer
auto ret_ptr = libsys_syscall_arg_3(SYSCALL_HASH("PrintOut"), static_cast<VoidPtr>(desc),
- Verify::sys_safe_cast(buf));
+ Verify::sys_safe_cast<Char, Void>(buf));
if (!ret_ptr) return -kErrorInvalidData;
diff --git a/src/misc/BenchKit/HWChronometer.h b/src/misc/BenchKit/HWChronometer.h index 331f9a7d..a155d377 100644 --- a/src/misc/BenchKit/HWChronometer.h +++ b/src/misc/BenchKit/HWChronometer.h @@ -4,7 +4,8 @@ Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. ======================================== */ -#pragma once +#ifndef BENCHKIT_HWCHRONOMETER_H +#define BENCHKIT_HWCHRONOMETER_H #include <misc/BenchKit/Chronometer.h> @@ -64,3 +65,5 @@ class HWChrono BENCHKIT_INTERFACE { UInt64 fStop{}; }; } // namespace Kernel + +#endif diff --git a/src/modules/AHCI/AHCI.h b/src/modules/AHCI/AHCI.h index 008c0d6e..8f17f6d8 100644 --- a/src/modules/AHCI/AHCI.h +++ b/src/modules/AHCI/AHCI.h @@ -11,7 +11,8 @@ ======================================== */ -#pragma once +#ifndef AHCI_AHCI_H +#define AHCI_AHCI_H #include <NeKit/Config.h> #include <modules/ACPI/ACPI.h> @@ -358,3 +359,5 @@ Kernel::SizeT drv_std_get_size(); Kernel::Bool drv_is_ready(void); /* EOF */ + +#endif diff --git a/src/modules/APM/APM.h b/src/modules/APM/APM.h index 1c229c82..a7932426 100644 --- a/src/modules/APM/APM.h +++ b/src/modules/APM/APM.h @@ -1,29 +1,32 @@ -/* ========================================
-
- Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-
-======================================== */
-
-#pragma once
-
-#include <NeKit/Config.h>
-
-namespace Kernel {
-typedef Int32 APMPowerCmd;
-
-enum {
- kAPMPowerCommandInvalid = 0x00,
- kAPMPowerCommandStop = 0x01,
- kAPMPowerCommandStart = 0x02,
- kAPMPowerCommandSleep = 0x04,
- kAPMPowerCommandWakeup = 0x06,
- kAPMPowerCommandShutdown = 0x07,
- kAPMPowerCommandReboot = 0x08,
-};
-
-/// @brief Send a APM command into it's controller. (Shutdown, Reboot, Sleep...)
-/// @param base_dma the IO base port.
-/// @param cmd the command.
-/// @return status code of the APM command.
-EXTERN_C Int32 apm_send_io_command(UInt16 cmd);
-} // namespace Kernel
+/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + +#ifndef APM_APM_H +#define APM_APM_H + +#include <NeKit/Config.h> + +namespace Kernel { +typedef Int32 APMPowerCmd; + +enum { + kAPMPowerCommandInvalid = 0x00, + kAPMPowerCommandStop = 0x01, + kAPMPowerCommandStart = 0x02, + kAPMPowerCommandSleep = 0x04, + kAPMPowerCommandWakeup = 0x06, + kAPMPowerCommandShutdown = 0x07, + kAPMPowerCommandReboot = 0x08, +}; + +/// @brief Send a APM command into it's controller. (Shutdown, Reboot, Sleep...) +/// @param base_dma the IO base port. +/// @param cmd the command. +/// @return status code of the APM command. +EXTERN_C Int32 apm_send_io_command(UInt16 cmd); +} // namespace Kernel + +#endif diff --git a/src/modules/ATA/ATA.h b/src/modules/ATA/ATA.h index 09305801..626bb247 100644 --- a/src/modules/ATA/ATA.h +++ b/src/modules/ATA/ATA.h @@ -11,7 +11,8 @@ ======================================== */ -#pragma once +#ifndef ATA_ATA_H +#define ATA_ATA_H #include <CompilerKit/CompilerKit.h> #include <NeKit/Config.h> @@ -154,4 +155,6 @@ Kernel::SizeT drv_std_get_sector_count(); /// @brief get device size. Kernel::SizeT drv_std_get_size(); -#endif // ifdef __NEOSKRNL__
\ No newline at end of file +#endif // ifdef __NEOSKRNL__ + +#endif diff --git a/src/modules/CoreGfx/CoreGfx.h b/src/modules/CoreGfx/CoreGfx.h index 81356452..81d3fc62 100644 --- a/src/modules/CoreGfx/CoreGfx.h +++ b/src/modules/CoreGfx/CoreGfx.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef COREGFX_COREGFX_H +#define COREGFX_COREGFX_H #include <NeKit/Config.h> @@ -115,4 +116,6 @@ inline Void cg_clear_video() { FBDrawInRegion(cg_get_clear_clr(), FB::CGAccessibilty::Height(), FB::CGAccessibilty::Width(), 0, 0); } -} // namespace FB
\ No newline at end of file +} // namespace FB + +#endif diff --git a/src/modules/CoreGfx/MathGfx.h b/src/modules/CoreGfx/MathGfx.h index dbd732d3..218fda51 100644 --- a/src/modules/CoreGfx/MathGfx.h +++ b/src/modules/CoreGfx/MathGfx.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef COREGFX_MATHGFX_H +#define COREGFX_MATHGFX_H /// @file MathMgr.h /// @brief Linear interpolation implementation. @@ -24,4 +25,6 @@ typedef float cg_real_t; inline cg_real_t cg_math_lerp(cg_real_t to, cg_real_t from, cg_real_t stat) { return (from) + (to - from) * stat; } -} // namespace UI
\ No newline at end of file +} // namespace UI + +#endif diff --git a/src/modules/CoreGfx/TextGfx.h b/src/modules/CoreGfx/TextGfx.h index 52eead08..221949c0 100644 --- a/src/modules/CoreGfx/TextGfx.h +++ b/src/modules/CoreGfx/TextGfx.h @@ -1,183 +1,186 @@ -/* ========================================
-
- Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
-
-======================================== */
-
-#pragma once
-
-#include <NeKit/Config.h>
-#include <modules/CoreGfx/CoreGfx.h>
-
-#define kFontSizeX 8
-#define kFontSizeY 8
-#define kFontNOFChars 128
-
-inline const Kernel::UInt8 kFontBitmap[kFontNOFChars][kFontSizeX] = {
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space)
- {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!)
- {0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (")
- {0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#)
- {0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($)
- {0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%)
- {0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&)
- {0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (')
- {0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (()
- {0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ())
- {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*)
- {0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+)
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,)
- {0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-)
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.)
- {0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/)
- {0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0)
- {0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1)
- {0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2)
- {0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3)
- {0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4)
- {0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5)
- {0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6)
- {0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7)
- {0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8)
- {0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9)
- {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:)
- {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;)
- {0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<)
- {0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=)
- {0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>)
- {0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?)
- {0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@)
- {0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A)
- {0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B)
- {0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C)
- {0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D)
- {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E)
- {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F)
- {0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G)
- {0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H)
- {0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I)
- {0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J)
- {0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K)
- {0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L)
- {0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M)
- {0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N)
- {0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O)
- {0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P)
- {0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q)
- {0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R)
- {0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S)
- {0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T)
- {0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U)
- {0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V)
- {0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W)
- {0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X)
- {0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y)
- {0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z)
- {0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([)
- {0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\)
- {0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (])
- {0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^)
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_)
- {0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`)
- {0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a)
- {0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b)
- {0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c)
- {0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d)
- {0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e)
- {0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f)
- {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g)
- {0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h)
- {0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i)
- {0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j)
- {0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k)
- {0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l)
- {0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m)
- {0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n)
- {0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o)
- {0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p)
- {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q)
- {0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r)
- {0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s)
- {0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t)
- {0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u)
- {0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v)
- {0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w)
- {0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x)
- {0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y)
- {0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z)
- {0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({)
- {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|)
- {0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (})
- {0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~)
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F
-
-};
-
-inline Kernel::Void cg_render_string_for_bitmap(const Kernel::UInt8* bitmap,
- const Kernel::SizeT x_sz, const Kernel::SizeT y_sz,
- Kernel::Int32& x_dst, Kernel::Int32& y_dst,
- Kernel::Int32& color) {
- Kernel::SizeT x, y;
- Kernel::SizeT set;
-
- x = 0;
- y = 0;
- set = 0;
-
- for (; y < y_sz; ++y) {
- for (x = 0; x < x_sz; ++x) {
- set = bitmap[x] & (1 << y);
-
- if (set) {
- FBDrawInRegion(color, 1, 1, ((x_dst) + x), ((y_dst) + y));
- }
- }
- }
-}
-
-inline Kernel::Void cg_render_string(const Kernel::Char* text, Kernel::Int32 x_dst,
- Kernel::Int32 y_dst, Kernel::Int32 color) {
-#ifndef __BOOTZ__
- auto len = Kernel::rt_string_len(text);
-#else
- auto len = StrLen(text);
-#endif
-
- for (Kernel::SizeT i = 0; i < len; ++i) {
- cg_render_string_for_bitmap(&kFontBitmap[(Kernel::UInt8) text[i]][0], kFontSizeX, kFontSizeY,
- x_dst, y_dst, color);
- y_dst += kFontSizeY;
- }
-}
+/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + +#ifndef COREGFX_TEXTGFX_H +#define COREGFX_TEXTGFX_H + +#include <NeKit/Config.h> +#include <modules/CoreGfx/CoreGfx.h> + +#define kFontSizeX 8 +#define kFontSizeY 8 +#define kFontNOFChars 128 + +inline const Kernel::UInt8 kFontBitmap[kFontNOFChars][kFontSizeX] = { + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019 + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space) + {0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!) + {0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (") + {0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#) + {0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($) + {0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%) + {0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&) + {0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (') + {0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (() + {0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ()) + {0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*) + {0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,) + {0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.) + {0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/) + {0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0) + {0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1) + {0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2) + {0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3) + {0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4) + {0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5) + {0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6) + {0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7) + {0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8) + {0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9) + {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:) + {0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;) + {0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<) + {0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=) + {0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>) + {0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?) + {0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@) + {0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A) + {0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B) + {0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C) + {0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D) + {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E) + {0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F) + {0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G) + {0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H) + {0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I) + {0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J) + {0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K) + {0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L) + {0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M) + {0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N) + {0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O) + {0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P) + {0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q) + {0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R) + {0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S) + {0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T) + {0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U) + {0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V) + {0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W) + {0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X) + {0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y) + {0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z) + {0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([) + {0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\) + {0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (]) + {0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_) + {0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`) + {0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a) + {0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b) + {0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c) + {0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d) + {0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e) + {0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f) + {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g) + {0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h) + {0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i) + {0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j) + {0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k) + {0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l) + {0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m) + {0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n) + {0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o) + {0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p) + {0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q) + {0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r) + {0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s) + {0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t) + {0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u) + {0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v) + {0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w) + {0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x) + {0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y) + {0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z) + {0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({) + {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|) + {0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (}) + {0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~) + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F + +}; + +inline Kernel::Void cg_render_string_for_bitmap(const Kernel::UInt8* bitmap, + const Kernel::SizeT x_sz, const Kernel::SizeT y_sz, + Kernel::Int32& x_dst, Kernel::Int32& y_dst, + Kernel::Int32& color) { + Kernel::SizeT x, y; + Kernel::SizeT set; + + x = 0; + y = 0; + set = 0; + + for (; y < y_sz; ++y) { + for (x = 0; x < x_sz; ++x) { + set = bitmap[x] & (1 << y); + + if (set) { + FBDrawInRegion(color, 1, 1, ((x_dst) + x), ((y_dst) + y)); + } + } + } +} + +inline Kernel::Void cg_render_string(const Kernel::Char* text, Kernel::Int32 x_dst, + Kernel::Int32 y_dst, Kernel::Int32 color) { +#ifndef __BOOTZ__ + auto len = Kernel::rt_string_len(text); +#else + auto len = StrLen(text); +#endif + + for (Kernel::SizeT i = 0; i < len; ++i) { + cg_render_string_for_bitmap(&kFontBitmap[(Kernel::UInt8) text[i]][0], kFontSizeX, kFontSizeY, + x_dst, y_dst, color); + y_dst += kFontSizeY; + } +} + +#endif diff --git a/src/modules/HPET/Config.h b/src/modules/HPET/Config.h index 9d1d9155..11ccbe96 100644 --- a/src/modules/HPET/Config.h +++ b/src/modules/HPET/Config.h @@ -9,7 +9,8 @@ ======================================== */ -#pragma once +#ifndef HPET_CONFIG_H +#define HPET_CONFIG_H #include <NeKit/Config.h> #include <modules/ACPI/ACPI.h> @@ -37,3 +38,5 @@ struct PACKED HPETHeader final : public SDT { }; } // namespace Kernel + +#endif diff --git a/src/modules/Power/PowerFactory.h b/src/modules/Power/PowerFactory.h index dcc75936..68f568b0 100644 --- a/src/modules/Power/PowerFactory.h +++ b/src/modules/Power/PowerFactory.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef POWER_POWERFACTORY_H +#define POWER_POWERFACTORY_H #include <KernelKit/DebugOutput.h> #include <NeKit/Config.h> @@ -27,4 +28,6 @@ class PowerFactory { virtual Bool Shutdown() { return NO; } // shutdown virtual Void Reboot() {} // soft-reboot }; -} // namespace Kernel
\ No newline at end of file +} // namespace Kernel + +#endif diff --git a/src/modules/SCSI/SCSI.h b/src/modules/SCSI/SCSI.h index b6228e54..4ca79fdc 100644 --- a/src/modules/SCSI/SCSI.h +++ b/src/modules/SCSI/SCSI.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef SCSI_SCSI_H +#define SCSI_SCSI_H #include <NeKit/Config.h> @@ -18,4 +19,6 @@ using scsi_packet_type = Kernel::UInt16[PacketBitLen]; using scsi_packet_type_12 = scsi_packet_type<12>; extern const scsi_packet_type_12 kCDRomPacketTemplate; -} // namespace Kernel
\ No newline at end of file +} // namespace Kernel + +#endif diff --git a/src/modules/XHCI/XHCI.h b/src/modules/XHCI/XHCI.h index 6eb25fac..16abf3f3 100644 --- a/src/modules/XHCI/XHCI.h +++ b/src/modules/XHCI/XHCI.h @@ -12,7 +12,8 @@ ======================================== */ -#pragma once +#ifndef XHCI_XHCI_H +#define XHCI_XHCI_H #include <NeKit/Config.h> @@ -63,4 +64,6 @@ typedef struct USBInterruptEnableRegister final { 32-bit physical adress of Frame List. Remember that first 12 bytes are always 0. The Frame List must contain 1024 entries. */ -} // namespace Kernel
\ No newline at end of file +} // namespace Kernel + +#endif diff --git a/tools/libmkfs/mkfs.h b/tools/libmkfs/mkfs.h index d5efae14..40d63b26 100644 --- a/tools/libmkfs/mkfs.h +++ b/tools/libmkfs/mkfs.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef LIBMKFS_MKFS_H +#define LIBMKFS_MKFS_H #include <tools/rang.h> #include <iostream> @@ -88,3 +89,5 @@ inline auto console_out() -> std::ostream& { return conout; } } // namespace mkfs + +#endif diff --git a/tools/libmkfs/openhefs.h b/tools/libmkfs/openhefs.h index fcfd9d23..b729894c 100644 --- a/tools/libmkfs/openhefs.h +++ b/tools/libmkfs/openhefs.h @@ -4,7 +4,8 @@ ======================================== */ -#pragma once +#ifndef LIBMKFS_OPENHEFS_H +#define LIBMKFS_OPENHEFS_H #include <cstdint> #include <cstring> @@ -114,3 +115,5 @@ struct __attribute__((packed)) BootNode { char pad[272]{}; }; } // namespace mkfs::hefs + +#endif |
