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 /src/kernel | |
| parent | 731758b271233b9c11052001ffc20a5a2ca1f365 (diff) | |
feat! breaking API changes, use header guards and libSystem fixes.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/kernel')
82 files changed, 776 insertions, 526 deletions
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 |
