diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-10-26 16:01:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-26 16:01:12 +0100 |
| commit | 36269e57831e560df6a0da9c9d02c00671b0163d (patch) | |
| tree | 69f6a0c6f08ef5ef2f6fcbb7302537dbce222e6e | |
| parent | 2117a9b0f4b84f5bd6c99566bcf5849a64104467 (diff) | |
| parent | b6ce6640afaf6c1cc6ad274f3053b2e218a49554 (diff) | |
Merge pull request #68 from nekernel-org/dev
NeKernel: v0.0.6e1
107 files changed, 891 insertions, 636 deletions
@@ -26,7 +26,7 @@ - **Modular Microkernel Architecture**: Clean separation of kernel, drivers, userland, and frameworks. -- **Custom Filesystems**: (HeFS), catalog/fork model (NeFS), and metadata handling. +- **Custom Filesystems**: (OpenHeFS), catalog/fork model (NeFS), and metadata handling. - **Memory Management**: Custom heap manager, page manager, and safe memory utilities. Kernel heap allocations are protected with metadata and CRCs. Userland and kernel memory separation. @@ -38,7 +38,7 @@ - **Security and Robustness**: kernel and tools (bounds checks, safe memory copy/set, error codes). Kernel panics and error reporting for critical failures. No dynamic code loading in kernel space. -- **Documentation and Specs**: Full LaTeX specifications for HeFS and NeFS, with on-disk structure diagrams and API documentation. Markdown docs for tools and usage. +- **Documentation and Specs**: Full LaTeX specifications for OpenHeFS and NeFS, with on-disk structure diagrams and API documentation. Markdown docs for tools and usage. - **Cross-Platform Boot Support**: Bootloader and platform code for AMD64 and ARM64, with handover and hardware abstraction layers. diff --git a/compile_flags.txt b/compile_flags.txt index 828dc123..384cd84e 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -2,7 +2,7 @@ -Idev/ -Idev/user -Idev/boot --Idev/system_sdk +-Idev/launch -Idev/misc -Idev/ddk -Ipublic/tools @@ -35,4 +35,5 @@ -D__FSKIT_INCLUDES_EXT2__ -D__NE_VIRTUAL_MEMORY_SUPPORT__ -DBOOTZ_GPT_SUPPORT --D__x86_64__
\ No newline at end of file +-D__x86_64__ +-D__NE_USE_PEF__
\ No newline at end of file diff --git a/dev/boot/src/HEL/ARM64/BootCB.S b/dev/boot/src/HEL/ARM64/BootNB.S index d52c1dcf..d52c1dcf 100644 --- a/dev/boot/src/HEL/ARM64/BootCB.S +++ b/dev/boot/src/HEL/ARM64/BootNB.S diff --git a/dev/boot/src/HEL/POWER/BootCB.S b/dev/boot/src/HEL/POWER/BootNB.S index 3887ff10..3887ff10 100644 --- a/dev/boot/src/HEL/POWER/BootCB.S +++ b/dev/boot/src/HEL/POWER/BootNB.S diff --git a/dev/boot/src/docs/MKFS_HEFS.md b/dev/boot/src/docs/MKFS_HEFS.md index c9aa0628..ac84d132 100644 --- a/dev/boot/src/docs/MKFS_HEFS.md +++ b/dev/boot/src/docs/MKFS_HEFS.md @@ -1,6 +1,6 @@ -# `mkfs.hefs` – HeFS Filesystem Formatter +# `mkfs.hefs` – OpenHeFS Filesystem Formatter -`mkfs.hefs` is a command-line utility used to format a block device or disk image with the **High-throughput Extended File System (HeFS)** used by NeKernel. This tool initializes a HeFS volume by writing a boot node and configuring directory and inode index regions, block ranges, and volume metadata. +`mkfs.hefs` is a command-line utility used to format a block device or disk image with the **High-throughput Extended File System (OpenHeFS)** used by NeKernel. This tool initializes a OpenHeFS volume by writing a boot node and configuring directory and inode index regions, block ranges, and volume metadata. --- @@ -61,7 +61,7 @@ -is 0x800000 -ie 0xA00000 \ -S 128 -o hefs.img -This will create a 128 GiB formatted HeFS image named `hefs.img` with specified region boundaries. +This will create a 128 GiB formatted OpenHeFS image named `hefs.img` with specified region boundaries. --- @@ -96,7 +96,7 @@ The `BootNode` stores key filesystem metadata: ## 📚 Source Location -Part of the [HeFS Tooling module](https://github.com/nekernel-org/nekernel) and used during system setup or disk preparation for NeKernel. +Part of the [OpenHeFS Tooling module](https://github.com/nekernel-org/nekernel) and used during system setup or disk preparation for NeKernel. --- diff --git a/dev/kernel/ArchKit/ArchKit.h b/dev/kernel/ArchKit/ArchKit.h index 2042bded..9c45b6bb 100644 --- a/dev/kernel/ArchKit/ArchKit.h +++ b/dev/kernel/ArchKit/ArchKit.h @@ -75,6 +75,9 @@ struct HAL_DISPATCH_ENTRY final { Kernel::Bool fHooked; rt_syscall_proc fProc; + BOOL IsKernCall() { return NO; } + BOOL IsSysCall() { return YES; } + operator bool() { return fHooked; } }; @@ -86,6 +89,9 @@ struct HAL_KERNEL_DISPATCH_ENTRY final { Kernel::Bool fHooked; rt_kerncall_proc fProc; + BOOL IsKernCall() { return YES; } + BOOL IsSysCall() { return NO; } + operator bool() { return fHooked; } }; diff --git a/dev/kernel/CFKit/GUIDWizard.h b/dev/kernel/CFKit/GUIDWizard.h index c7cb18ac..e2d9bcb1 100644 --- a/dev/kernel/CFKit/GUIDWizard.h +++ b/dev/kernel/CFKit/GUIDWizard.h @@ -15,9 +15,7 @@ #include <NeKit/Ref.h> #include <NeKit/Stream.h> -namespace CF::XRN::Version1 { -using namespace Kernel; - -Ref<GUIDSequence*> cf_make_sequence(const ArrayList<UInt32>& seq); -ErrorOr<Ref<Kernel::KString>> cf_try_guid_to_string(Ref<GUIDSequence*>& guid); -} // namespace CF::XRN::Version1 +namespace Kernel::CF::XRN::Version1 { +Ref<GUIDSequence*> cf_make_sequence(const ArrayList<UInt32>& seq); +ErrorOr<Ref<KString>> cf_try_guid_to_string(Ref<GUIDSequence*>& guid); +} // namespace Kernel::CF::XRN::Version1 diff --git a/dev/kernel/CFKit/GUIDWrapper.h b/dev/kernel/CFKit/GUIDWrapper.h index a3920357..14a96fde 100644 --- a/dev/kernel/CFKit/GUIDWrapper.h +++ b/dev/kernel/CFKit/GUIDWrapper.h @@ -15,10 +15,8 @@ #define kXRNNil "@{........-....-M...-N...-............}" /// @brief eXtended Resource Namespace -namespace CF::XRN { -using namespace Kernel; - -union GUIDSequence { +namespace Kernel::CF::XRN { +union GUIDSequence final { alignas(8) UShort fU8[16]; alignas(8) UShort fU16[8]; alignas(8) UInt fU32[4]; @@ -38,8 +36,7 @@ class GUID final { ~GUID() = default; public: - GUID& operator=(const GUID&) = default; - GUID(const GUID&) = default; + NE_COPY_DEFAULT(GUID) public: GUIDSequence& operator->() noexcept { return fUUID; } @@ -48,4 +45,4 @@ class GUID final { private: GUIDSequence fUUID; }; -} // namespace CF::XRN +} // namespace Kernel::CF::XRN diff --git a/dev/kernel/CFKit/Property.h b/dev/kernel/CFKit/Property.h index 7fc9bf07..e8f2f713 100644 --- a/dev/kernel/CFKit/Property.h +++ b/dev/kernel/CFKit/Property.h @@ -15,9 +15,7 @@ #define kMaxPropLen (256U) -namespace CF { -using namespace Kernel; - +namespace Kernel::CF { /// @brief handle to anything (number, ptr, string...) using PropertyId = UIntPtr; @@ -32,9 +30,9 @@ class Property { Property& operator=(const Property&) = default; Property(const Property&) = default; - BOOL StringEquals(BasicKString<>& name); + BOOL StringEquals(KBasicString<>& name); PropertyId& GetValue(); - BasicKString<>& GetKey(); + KBasicString<>& GetKey(); private: KString fName{kMaxPropLen}; @@ -44,10 +42,10 @@ class Property { template <SizeT N> using PropertyArray = Array<Property, N>; -} // namespace CF +} // namespace Kernel::CF namespace Kernel { -using namespace CF; +using namespace Kernel::CF; } #endif // !CFKIT_PROPS_H diff --git a/dev/kernel/CFKit/Utils.h b/dev/kernel/CFKit/Utils.h index 97b0ee53..247ad5fb 100644 --- a/dev/kernel/CFKit/Utils.h +++ b/dev/kernel/CFKit/Utils.h @@ -5,9 +5,7 @@ #include <KernelKit/PE.h> /// @brief CFKit -namespace CF { -using namespace Kernel; - +namespace Kernel::CF { /// @brief Finds the PE header inside the blob. inline auto ldr_find_exec_header(DosHeaderPtr ptrDos) -> LDR_EXEC_HEADER_PTR { if (!ptrDos) return nullptr; @@ -45,6 +43,6 @@ inline auto ldr_find_exec_header(const Char* ptrDos) -> LDR_EXEC_HEADER_PTR { inline auto ldr_find_opt_exec_header(const Char* ptrDos) -> LDR_OPTIONAL_HEADER_PTR { return ldr_find_opt_exec_header((DosHeaderPtr) ptrDos); } -} // namespace CF +} // namespace Kernel::CF #endif // ifndef CFKIT_UTILS_H diff --git a/dev/kernel/FSKit/Ext2+IFS.h b/dev/kernel/FSKit/Ext2+IFS.h index 661c8d5f..44435a29 100644 --- a/dev/kernel/FSKit/Ext2+IFS.h +++ b/dev/kernel/FSKit/Ext2+IFS.h @@ -144,9 +144,9 @@ inline Kernel::ErrorOr<Ext2Node*> ext2_load_inode(Ext2Context* ctx, Kernel::UInt * * Provides high-level interface for EXT2 filesystem operations */ -class Ext2FileSystemParser { +class Ext2FileSystemParser final { private: - Ext2Context ctx; // Internal EXT2 context + Ext2Context fCtx; // Internal EXT2 context public: /* @@ -157,6 +157,8 @@ class Ext2FileSystemParser { */ explicit Ext2FileSystemParser(DriveTrait* drive); + NE_COPY_DELETE(Ext2FileSystemParser) + /* * Open a file or directory by path * diff --git a/dev/kernel/FSKit/IndexableProperty.h b/dev/kernel/FSKit/IndexableProperty.h index 8be6d7c3..d6b89d35 100644 --- a/dev/kernel/FSKit/IndexableProperty.h +++ b/dev/kernel/FSKit/IndexableProperty.h @@ -25,7 +25,7 @@ namespace Indexer { class IndexableProperty final : public Property { public: explicit IndexableProperty() : Property() { - Kernel::BasicKString<> strProp(kMaxPropLen); + Kernel::KBasicString<> strProp(kMaxPropLen); strProp += "/prop/indexable"; this->GetKey() = strProp; diff --git a/dev/kernel/FSKit/HeFS.h b/dev/kernel/FSKit/OpenHeFS.h index 845ef467..1361da9c 100644 --- a/dev/kernel/FSKit/HeFS.h +++ b/dev/kernel/FSKit/OpenHeFS.h @@ -14,8 +14,8 @@ #include <NeKit/KString.h>
#include <hint/CompilerHint.h>
-/// @file HeFS.h
-/// @brief HeFS filesystem support.
+/// @file OpenHeFS.h
+/// @brief OpenHeFS filesystem support.
#define kHeFSVersion (0x0103)
#define kHeFSMagic " HeFS"
@@ -27,11 +27,19 @@ #define kHeFSMinimumDiskSize (gib_cast(128))
-#define kHeFSDefaultVolumeName u8"HeFS Volume"
+#define kHeFSDefaultVolumeName u8"OpenHeFS Volume"
#define kHeFSINDStartOffset (sizeof(HEFS_BOOT_NODE))
#define kHeFSINStartOffset (sizeof(HEFS_INDEX_NODE_DIRECTORY))
+#define kHeFSRootDirectory "/"
+#define kHeFSRootDirectoryU8 u8"/"
+
+#define kHeFSSeparator '/'
+#define kHeFSUpDir ".."
+
+#define kHeFSRootDirectoryLen (2U)
+
#define kHeFSSearchAllStr u8"*"
struct HEFS_BOOT_NODE;
@@ -89,7 +97,7 @@ inline constexpr UInt16 kHeFSFileKindSymbolicLink = 0x06; inline constexpr UInt16 kHeFSFileKindUnknown = 0x07;
inline constexpr UInt16 kHeFSFileKindCount = 0x08;
-/// @brief HeFS blocks are array containing sparse blocks of data.
+/// @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 kHeFSSliceCount = 0x10;
@@ -101,7 +109,7 @@ namespace Kernel { /// @details Used to keep track of the INode, INodeDir allocation status.
typedef UInt64 ATime;
-/// @brief HeFS Boot node.
+/// @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 {
@@ -158,7 +166,7 @@ enum HeFSJournalKind : UInt8 { kJournalKindCount,
};
-/// @brief HeFS index node.
+/// @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.
@@ -192,7 +200,7 @@ enum { kHeFSColorCount,
};
-/// @brief HeFS directory node.
+/// @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 {
@@ -222,7 +230,7 @@ struct PACKED HEFS_INDEX_NODE_DIRECTORY final { } // namespace Kernel
namespace Kernel::Detail {
-/// @brief HeFS get year from ATime.
+/// @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.
@@ -230,7 +238,7 @@ inline UInt32 hefs_year_get(ATime raw_atime) noexcept { return (raw_atime) >> 32;
}
-/// @brief HeFS get month from ATime.
+/// @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.
@@ -238,7 +246,7 @@ inline UInt32 hefs_month_get(ATime raw_atime) noexcept { return (raw_atime) >> 24;
}
-/// @brief HeFS get day from ATime.
+/// @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.
@@ -246,7 +254,7 @@ inline UInt32 hefs_day_get(ATime raw_atime) noexcept { return (raw_atime) >> 16;
}
-/// @brief HeFS get hour from ATime.
+/// @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.
@@ -254,7 +262,7 @@ inline UInt32 hefs_hour_get(ATime raw_atime) noexcept { return (raw_atime) >> 8;
}
-/// @brief HeFS get minute from ATime.
+/// @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.
@@ -371,8 +379,8 @@ inline const Char* hefs_file_flags_to_string(UInt32 flags) noexcept { } // namespace Kernel::Detail
namespace Kernel {
-/// @brief HeFS filesystem parser class.
-/// @details This class is used to parse the HeFS filesystem.
+/// @brief OpenHeFS filesystem parser class.
+/// @details This class is used to parse the OpenHeFS filesystem.
class HeFileSystemParser final {
public:
HeFileSystemParser() = default;
@@ -386,7 +394,7 @@ class HeFileSystemParser final { HeFileSystemParser& operator=(HeFileSystemParser&&) = delete;
public:
- /// @brief Make a EPM+HeFS drive out of the disk.
+ /// @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,
@@ -417,10 +425,10 @@ class HeFileSystemParser final { const Utf8Char* dir, const BOOL delete_or_create);
};
-namespace HeFS {
+namespace OpenHeFS {
- /// @brief Initialize HeFS inside the main disk.
+ /// @brief Initialize OpenHeFS inside the main disk.
/// @return Whether it successfuly formated it or not.
Boolean fs_init_hefs(Void) noexcept;
-} // namespace HeFS
+} // namespace OpenHeFS
} // namespace Kernel
diff --git a/dev/kernel/FirmwareKit/EPM.h b/dev/kernel/FirmwareKit/EPM.h index dcab3607..20c966e4 100644 --- a/dev/kernel/FirmwareKit/EPM.h +++ b/dev/kernel/FirmwareKit/EPM.h @@ -89,7 +89,7 @@ struct PACKED EPM_PART_BLOCK { Kernel::Int16 Kind; Kernel::Int16 Flags; Kernel::Int32 FsVersion; - Kernel::Char Fs[kEPMFilesystemLength]; /* NeFS, HeFS... */ + Kernel::Char Fs[kEPMFilesystemLength]; /* NeFS, OpenHeFS... */ Kernel::Char Reserved[kEPMReserveLen]; // to fill a full sector. }; diff --git a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc index 7408639c..0cb991f9 100644 --- a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc +++ b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc @@ -8,7 +8,7 @@ #include <KernelKit/ProcessScheduler.h> #include <KernelKit/UserMgr.h> #include <NeKit/KString.h> -#include <SignalKit/SignalGen.h> +#include <SignalKit/Signals.h> EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip); diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc index 6f4d7e0a..2b478dd6 100644 --- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc @@ -145,7 +145,7 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) { HAL::mp_init_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr); #ifdef __FSKIT_INCLUDES_HEFS__ - HeFS::fs_init_hefs(); + OpenHeFS::fs_init_hefs(); #endif #ifdef __FSKIT_INCLUDES_NEFS__ diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index 77e3331d..1acfac0e 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -546,8 +546,8 @@ namespace Detail { /// @brief Read AHCI device. /// @param self device /// @param mnt mounted disk. - STATIC Void sk_io_read_ahci(DeviceInterface<MountpointInterface*>* self, - MountpointInterface* mnt) { + STATIC Void sk_io_read_ahci(DeviceInterface<IMountpoint*>* self, + IMountpoint* mnt) { AHCIDeviceInterface* dev = (AHCIDeviceInterface*) self; err_global_get() = kErrorDisk; @@ -568,8 +568,8 @@ namespace Detail { /// @brief Write AHCI device. /// @param self device /// @param mnt mounted disk. - STATIC Void sk_io_write_ahci(DeviceInterface<MountpointInterface*>* self, - MountpointInterface* mnt) { + STATIC Void sk_io_write_ahci(DeviceInterface<IMountpoint*>* self, + IMountpoint* mnt) { AHCIDeviceInterface* dev = (AHCIDeviceInterface*) self; err_global_get() = kErrorDisk; @@ -591,7 +591,7 @@ namespace Detail { /// @brief Acquires a new AHCI device with drv_index in mind. /// @param drv_index The drive index to assign. /// @return A wrapped device interface if successful, or error code. -ErrorOr<AHCIDeviceInterface> sk_acquire_ahci_device(Int32 drv_index) { +ErrorOr<AHCIDeviceInterface> sk_acquire_ahci_device(UInt32 drv_index) { if (!drv_std_detected_ahci()) return ErrorOr<AHCIDeviceInterface>(kErrorDisk); AHCIDeviceInterface device(Detail::sk_io_read_ahci, Detail::sk_io_write_ahci); diff --git a/dev/kernel/HALKit/AMD64/Storage/NVME+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/NVME+Generic.cc new file mode 100644 index 00000000..67b59813 --- /dev/null +++ b/dev/kernel/HALKit/AMD64/Storage/NVME+Generic.cc @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#include <modules/NVME/NVME.h> + +using namespace Kernel; diff --git a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc index 6fccbdfa..5b768fbb 100644 --- a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc @@ -200,8 +200,8 @@ namespace Detail { /// @brief Read PIO device. /// @param self device /// @param mnt mounted disk. - STATIC Void sk_io_read_pio(DeviceInterface<MountpointInterface*>* self, - MountpointInterface* mnt) { + STATIC Void sk_io_read_pio(DeviceInterface<IMountpoint*>* self, + IMountpoint* mnt) { ATADeviceInterface* dev = (ATADeviceInterface*) self; err_global_get() = kErrorDisk; @@ -222,8 +222,8 @@ namespace Detail { /// @brief Write PIO device. /// @param self device /// @param mnt mounted disk. - STATIC Void sk_io_write_pio(DeviceInterface<MountpointInterface*>* self, - MountpointInterface* mnt) { + STATIC Void sk_io_write_pio(DeviceInterface<IMountpoint*>* self, + IMountpoint* mnt) { ATADeviceInterface* dev = (ATADeviceInterface*) self; err_global_get() = kErrorDisk; diff --git a/dev/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc b/dev/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc index dd875c63..0c26f4cb 100644 --- a/dev/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc +++ b/dev/kernel/HALKit/ARM64/HalCoreInterruptHandler.cc @@ -8,7 +8,7 @@ #include <KernelKit/ProcessScheduler.h> #include <KernelKit/UserMgr.h> #include <NeKit/KString.h> -#include <SignalKit/SignalGen.h> +#include <SignalKit/Signals.h> EXTERN_C Kernel::Void int_handle_breakpoint(Kernel::UIntPtr rip); EXTERN_C BOOL mp_handle_gic_interrupt_el0(Void); diff --git a/dev/kernel/KernelKit/CodeMgr.h b/dev/kernel/KernelKit/CodeMgr.h index c733bc47..fc737a90 100644 --- a/dev/kernel/KernelKit/CodeMgr.h +++ b/dev/kernel/KernelKit/CodeMgr.h @@ -14,9 +14,10 @@ #pragma once +#ifdef __NE_USE_PEF__ #include <KernelKit/IPEFDylibObject.h> -#include <KernelKit/PECodeMgr.h> #include <KernelKit/PEFCodeMgr.h> +#endif /// @file CodeMgr.h /// @brief Code Manager header file. diff --git a/dev/kernel/KernelKit/CoreProcessScheduler.h b/dev/kernel/KernelKit/CoreProcessScheduler.h index f40ffc81..49e9363e 100644 --- a/dev/kernel/KernelKit/CoreProcessScheduler.h +++ b/dev/kernel/KernelKit/CoreProcessScheduler.h @@ -147,7 +147,8 @@ enum class ProcessSubsystem : Int32 { kProcessSubsystemUser, kProcessSubsystemService, kProcessSubsystemDriver, - kProcessSubsystemCount = kProcessSubsystemDriver - kProcessSubsystemSecurity + 1, + kProcessSubsystemKernel, + kProcessSubsystemCount = kProcessSubsystemKernel - kProcessSubsystemSecurity + 1, kProcessSubsystemInvalid = 0xFFFFFFF, }; diff --git a/dev/kernel/KernelKit/DriveMgr.h b/dev/kernel/KernelKit/DriveMgr.h index 69df1cec..6340d966 100644 --- a/dev/kernel/KernelKit/DriveMgr.h +++ b/dev/kernel/KernelKit/DriveMgr.h @@ -52,9 +52,9 @@ enum { /// @brief Media drive trait type. struct DriveTrait final { - Char fName[kDriveNameLen]; // /System, /boot, //./Devices/USB... - Int32 fKind; // fMassStorage, fFloppy, fOpticalDrive. - Int32 fFlags; // fReadOnly, fEPMDrive... + Char fName[kDriveNameLen] = {0}; // /System, /boot, //./Devices/USB... + UInt32 fKind{}; // fMassStorage, fFloppy, fOpticalDrive. + UInt32 fFlags{}; // fReadOnly, fEPMDrive... /// @brief Packet drive (StorageKit compilant.) struct DrivePacket final { @@ -70,11 +70,11 @@ struct DriveTrait final { Lba fLbaStart{0}, fLbaEnd{0}; SizeT fSectorSz{kDriveSectorSz}; - Void (*fInput)(DrivePacket& packet); - Void (*fOutput)(DrivePacket& packet); - Void (*fVerify)(DrivePacket& packet); - Void (*fInit)(DrivePacket& packet); - const Char* (*fProtocol)(Void); + Void (*fInput)(DrivePacket& packet){}; + Void (*fOutput)(DrivePacket& packet){}; + Void (*fVerify)(DrivePacket& packet){}; + Void (*fInit)(DrivePacket& packet){}; + const Char* (*fProtocol)(Void){}; }; namespace Detail { @@ -89,12 +89,12 @@ typedef DriveTrait* DriveTraitPtr; * @note This class has all of it's drive set to nullptr, allocate them using * GetAddressOf(index). */ -class MountpointInterface final { +class IMountpoint final { public: - explicit MountpointInterface() = default; - ~MountpointInterface() = default; + explicit IMountpoint() = default; + ~IMountpoint() = default; - NE_COPY_DEFAULT(MountpointInterface) + NE_COPY_DEFAULT(IMountpoint) public: DriveTrait& A() { return mA; } diff --git a/dev/kernel/KernelKit/FileMgr.h b/dev/kernel/KernelKit/FileMgr.h index bad6cf85..ff290780 100644 --- a/dev/kernel/KernelKit/FileMgr.h +++ b/dev/kernel/KernelKit/FileMgr.h @@ -23,12 +23,12 @@ #define INC_FILEMGR_H /// @file FileMgr.h -/// @brief File Manager. +/// @brief File Manager System. /// @author Amlal El Mahrouss (amlal@nekernel.org) //! Include filesystems that NeKernel supports. #include <FSKit/Ext2+IFS.h> -#include <FSKit/HeFS.h> +#include <FSKit/OpenHeFS.h> #include <FSKit/NeFS.h> #include <CompilerKit/CompilerKit.h> @@ -71,7 +71,7 @@ enum { kFileIOCnt = (kFileFlagData - kFileWriteAll) + 1, }; -typedef VoidPtr NodePtr; +using NodePtr = VoidPtr; /** @brief Filesystem Mgr Interface class @@ -298,7 +298,7 @@ class FileStream final { if (man) { man->Write(offset, fFile, data, len); - return ErrorOr<Int64>(0); + return ErrorOr<Int64>(kErrorSuccess); } return ErrorOr<Int64>(kErrorInvalidData); @@ -317,7 +317,7 @@ class FileStream final { if (man) { man->Write(name, fFile, data, 0, len); - return ErrorOr<Int64>(0); + return ErrorOr<Int64>(kErrorSuccess); } return ErrorOr<Int64>(kErrorInvalidData); diff --git a/dev/kernel/KernelKit/HardwareThreadScheduler.h b/dev/kernel/KernelKit/HardwareThreadScheduler.h index 76327a93..e26a353a 100644 --- a/dev/kernel/KernelKit/HardwareThreadScheduler.h +++ b/dev/kernel/KernelKit/HardwareThreadScheduler.h @@ -120,7 +120,7 @@ class HardwareThreadScheduler final : public ISchedulable { private: Array<HardwareThread, kMaxAPInsideSched> fThreadList; - ThreadID fCurrentThread{0}; + ThreadID fCurrentThreadIdx{0}; }; /// @brief wakes up thread. diff --git a/dev/kernel/KernelKit/IFS.h b/dev/kernel/KernelKit/IFS.h index ed1d87b5..b1dd2001 100644 --- a/dev/kernel/KernelKit/IFS.h +++ b/dev/kernel/KernelKit/IFS.h @@ -14,12 +14,12 @@ namespace Kernel { /// @param DrvTrait drive info /// @param DrvIndex drive index. /// @return -Int32 fs_ifs_read(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex); +Int32 fs_ifs_read(IMountpoint* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex); /// @brief Write to IFS disk. /// @param Mnt mounted interface. /// @param DrvTrait drive info /// @param DrvIndex drive index. /// @return -Int32 fs_ifs_write(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex); +Int32 fs_ifs_write(IMountpoint* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex); } // namespace Kernel diff --git a/dev/kernel/KernelKit/LoaderInterface.h b/dev/kernel/KernelKit/ILoader.h index 1f9b1e56..ec8ee1bc 100644 --- a/dev/kernel/KernelKit/LoaderInterface.h +++ b/dev/kernel/KernelKit/ILoader.h @@ -14,12 +14,12 @@ namespace Kernel { /// @brief This interface is used to make loader contracts (MSCOFF, PEF). /// @author @Amlal-El-Mahrouss -class LoaderInterface { +class ILoader { public: - explicit LoaderInterface() = default; - virtual ~LoaderInterface() = default; + explicit ILoader() = default; + virtual ~ILoader() = default; - NE_COPY_DEFAULT(LoaderInterface) + NE_COPY_DEFAULT(ILoader) public: virtual _Output ErrorOr<VoidPtr> GetBlob() = 0; diff --git a/dev/kernel/KernelKit/KernelTaskScheduler.h b/dev/kernel/KernelKit/KernelTaskScheduler.h index ce0ff30d..2029ae7b 100644 --- a/dev/kernel/KernelKit/KernelTaskScheduler.h +++ b/dev/kernel/KernelKit/KernelTaskScheduler.h @@ -24,7 +24,7 @@ typedef ProcessID KID; class KERNEL_TASK final { public: Char Name[kSchedNameLen] = {"KERNEL_TASK"}; - ProcessSubsystem SubSystem{ProcessSubsystem::kProcessSubsystemDriver}; + ProcessSubsystem SubSystem{ProcessSubsystem::kProcessSubsystemKernel}; HAL::StackFramePtr StackFrame{nullptr}; UInt8* StackReserve{nullptr}; SizeT StackSize{kSchedMaxStackSz}; @@ -40,7 +40,7 @@ class KernelTaskHelper final { public: STATIC Bool Switch(HAL::StackFramePtr frame_ptr, ProcessID new_kid); STATIC Bool CanBeScheduled(const KERNEL_TASK& process); - STATIC ErrorOr<ProcessID> TheCurrentKID(); - STATIC SizeT StartScheduling(); + STATIC ErrorOr<KID> TheCurrentKID(); + STATIC SizeT StartScheduling(); }; } // namespace Kernel
\ No newline at end of file diff --git a/dev/kernel/KernelKit/PECodeMgr.h b/dev/kernel/KernelKit/PECodeMgr.h deleted file mode 100644 index 15c2b7ee..00000000 --- a/dev/kernel/KernelKit/PECodeMgr.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - - File: PECodeMgr.h - Purpose: PE32+ Code Mgr and Dylib mgr. - - Revision History: - - 12/02/24: Added file (amlel) - -------------------------------------------- */ - -#pragma once - -//////////////////////////////////////////////////// - -// LAST REV: Mon Feb 12 13:52:01 CET 2024 - -//////////////////////////////////////////////////// - -#include <KernelKit/FileMgr.h> -#include <KernelKit/LoaderInterface.h> -#include <KernelKit/PE.h> -#include <NeKit/ErrorOr.h> -#include <NeKit/KString.h> - -#ifndef INC_PROCESS_SCHEDULER_H -#include <KernelKit/ProcessScheduler.h> -#endif - -#define kPeApplicationMime "application/vnd-portable-executable" - -namespace Kernel { -/// -/// \name PE32Loader -/// \brief PE32+ loader class. -/// -class PE32Loader : public LoaderInterface { - private: - explicit PE32Loader() = delete; - - public: - explicit PE32Loader(const VoidPtr blob); - explicit PE32Loader(const Char* path); - ~PE32Loader() override; - - public: - NE_COPY_DEFAULT(PE32Loader) - - public: - const Char* Path() override; - const Char* AsString() override; - const Char* MIME() override; - - public: - ErrorOr<VoidPtr> FindStart() override; - ErrorOr<VoidPtr> FindSymbol(const Char* name, Int32 kind) override; - ErrorOr<VoidPtr> GetBlob() override; - - public: - bool IsLoaded() noexcept; - - private: -#ifdef __FSKIT_INCLUDES_NEFS__ - OwnPtr<FileStream<Char, NeFileSystemMgr>> fFile; -#elif defined(__FSKIT_INCLUDES_HEFS__) - OwnPtr<FileStream<Char, HeFileSystemMgr>> fFile; -#else - OwnPtr<FileStream<Char>> fFile; -#endif // __FSKIT_INCLUDES_NEFS__ - - Ref<KString> fPath; - VoidPtr fCachedBlob; - bool fBad; -}; -} // namespace Kernel
\ No newline at end of file diff --git a/dev/kernel/KernelKit/PEF.h b/dev/kernel/KernelKit/PEF.h index f0ba9ef9..0410c63a 100644 --- a/dev/kernel/KernelKit/PEF.h +++ b/dev/kernel/KernelKit/PEF.h @@ -15,7 +15,7 @@ #define __KERNELKIT_PEF_H__ #include <CompilerKit/CompilerKit.h> -#include <KernelKit/LoaderInterface.h> +#include <KernelKit/ILoader.h> #include <NeKit/Defines.h> #define kPefMagic "Open" diff --git a/dev/kernel/KernelKit/PEFCodeMgr.h b/dev/kernel/KernelKit/PEFCodeMgr.h index d61aa863..3ed9c097 100644 --- a/dev/kernel/KernelKit/PEFCodeMgr.h +++ b/dev/kernel/KernelKit/PEFCodeMgr.h @@ -27,7 +27,7 @@ namespace Kernel { /// \name PEFLoader /// \brief PEF loader class. /// -class PEFLoader : public LoaderInterface { +class PEFLoader : public ILoader { private: explicit PEFLoader() = delete; diff --git a/dev/kernel/KernelKit/UserMgr.h b/dev/kernel/KernelKit/UserMgr.h index 6fa8ba14..c660025b 100644 --- a/dev/kernel/KernelKit/UserMgr.h +++ b/dev/kernel/KernelKit/UserMgr.h @@ -22,9 +22,9 @@ ///! We got the MGMT, STD (%s format) and GUEST users, ///! all are used to make authorized operations. -#define kSuperUser "OS AUTHORITY/MGMT/%s" -#define kGuestUser "OS AUTHORITY/GUEST/%s" -#define kStdUser "OS AUTHORITY/STD/%s" +#define kSuperUser "NEKERNEL/MGMT/%s" +#define kGuestUser "NEKERNEL/GUEST/%s" +#define kStdUser "NEKERNEL/STD/%s" #define kUsersDir "/users/" diff --git a/dev/kernel/KernelKit/UserProcessScheduler.h b/dev/kernel/KernelKit/UserProcessScheduler.h index e5b81f76..2cf65fe0 100644 --- a/dev/kernel/KernelKit/UserProcessScheduler.h +++ b/dev/kernel/KernelKit/UserProcessScheduler.h @@ -86,7 +86,7 @@ class USER_PROCESS final { /***********************************************************************************/ //! @brief boolean operator, check status. /***********************************************************************************/ - operator bool(); + explicit operator bool(); /***********************************************************************************/ ///! @brief Crashes the app, exits with code ~0. @@ -192,8 +192,8 @@ class UserProcessScheduler final : public ISchedulable { NE_MOVE_DELETE(UserProcessScheduler) public: - operator bool(); - bool operator!(); + explicit operator bool(); + bool operator!(); public: UserProcessTeam& TheCurrentTeam(); diff --git a/dev/kernel/KernelKit/ZXD.h b/dev/kernel/KernelKit/ZXD.h index 966c54c7..bae47258 100644 --- a/dev/kernel/KernelKit/ZXD.h +++ b/dev/kernel/KernelKit/ZXD.h @@ -23,7 +23,7 @@ enum ZXD_FLAGS { /// @brief ZXD executable header /// @details This header is used to identify ZXD executable files. -struct PACKED ZXD_EXEC_HEADER { +struct PACKED ZXD_EXEC_HEADER final { UInt32 fMagic; UInt32 fVersion; UInt32 fFlags; @@ -42,7 +42,7 @@ struct PACKED ZXD_EXEC_HEADER { /// @brief ZXD stub header /// @details This header is used to identify ZXD stub files. It contains the size of the stub, the /// offset of the stub, and the CRC32 checksum of the stub. -struct PACKED ZXD_STUB_HEADER { +struct PACKED ZXD_STUB_HEADER final { UInt32 fStubSize; UInt32 fStubOffset; UInt32 fStubCRC32; diff --git a/dev/kernel/NeKit/ArrayList.h b/dev/kernel/NeKit/ArrayList.h index 1f5226f4..ee1a4b40 100644 --- a/dev/kernel/NeKit/ArrayList.h +++ b/dev/kernel/NeKit/ArrayList.h @@ -12,7 +12,7 @@ namespace Kernel { template <typename T> class ArrayList final { public: - explicit ArrayList(T* list, SizeT length) : fList(reinterpret_cast<T>(list)) {} + explicit ArrayList(T* list, SizeT length) : fList(reinterpret_cast<T>(list)), fLen(length) {} ~ArrayList() = default; diff --git a/dev/kernel/NeKit/Crc32.h b/dev/kernel/NeKit/Crc32.h index 0fc35134..f6b04641 100644 --- a/dev/kernel/NeKit/Crc32.h +++ b/dev/kernel/NeKit/Crc32.h @@ -8,15 +8,13 @@ * ======================================================== */ -#ifndef CRC32_H -#define CRC32_H +#ifndef NEKIT_CRC32_H +#define NEKIT_CRC32_H #include <NeKit/Defines.h> -#define kCrcCnt (256) - namespace Kernel { UInt32 ke_calculate_crc32(const VoidPtr crc, Int32 len) noexcept; } // namespace Kernel -#endif // !CRC32_H +#endif // !NEKIT_CRC32_H diff --git a/dev/kernel/NeKit/Defines.h b/dev/kernel/NeKit/Defines.h index 0f9a7c4a..ed979e03 100644 --- a/dev/kernel/NeKit/Defines.h +++ b/dev/kernel/NeKit/Defines.h @@ -8,11 +8,11 @@ #include <NeKit/Macros.h> -#define NEWKIT_VERSION_STR "0.0.1" -#define NEWKIT_VERSION_BCD 0x0001 +#define NEKIT_VERSION_STR "0.0.1" +#define NEKIT_VERSION_BCD 0x0001 #ifndef __cplusplus -#error Kernel compiles with a C++ compiler. +#error !!! Kernel compiles only with a C++ compiler. !!! #endif #if __cplusplus <= 201703L @@ -35,13 +35,13 @@ using nullPtr = decltype(nullptr); using NullPtr = decltype(nullptr); using Int = int; -using Int32 = int; -using UShort = unsigned short; -using UInt16 = unsigned short; +using Int32 = __INT32_TYPE__; +using UShort = __UINT16_TYPE__; +using UInt16 = __UINT16_TYPE__; using Short = short; -using Int16 = short; -using UInt = unsigned int; -using UInt32 = unsigned int; +using Int16 = __INT16_TYPE__; +using UInt = __UINT32_TYPE__; +using UInt32 = __UINT32_TYPE__; using Long = __INT64_TYPE__; using Int64 = __INT64_TYPE__; using ULong = __UINT64_TYPE__; @@ -49,11 +49,13 @@ using UInt64 = __UINT64_TYPE__; using Boolean = bool; using Bool = bool; using Char = char; -using UChar = unsigned char; -using UInt8 = unsigned char; +using Int8 = __INT8_TYPE__; +using Char8 = char8_t; +using UChar = __UINT8_TYPE__; +using UInt8 = __UINT8_TYPE__; -using SSize = Int64; -using SSizeT = Int64; +using SSize = long; +using SSizeT = long; using Size = __SIZE_TYPE__; using SizeT = __SIZE_TYPE__; using IntPtr = __INTPTR_TYPE__; @@ -83,6 +85,7 @@ typedef UInt32 PhysicalAddressKind; typedef UIntPtr VirtualAddressKind; using Void = void; +using Any = void*; using Lba = UInt64; diff --git a/dev/kernel/NeKit/ErrorOr.h b/dev/kernel/NeKit/ErrorOr.h index e8b3b6fc..3351c65d 100644 --- a/dev/kernel/NeKit/ErrorOr.h +++ b/dev/kernel/NeKit/ErrorOr.h @@ -13,7 +13,7 @@ #include <NeKit/Ref.h> namespace Kernel { -using ErrorT = UInt; +using ErrorT = UInt32; template <typename T> class ErrorOr final { @@ -50,7 +50,7 @@ class ErrorOr final { private: Ref<T> mRef; - Int32 mId{0}; + ErrorT mId{0}; }; using ErrorOrAny = ErrorOr<voidPtr>; diff --git a/dev/kernel/NeKit/Json.h b/dev/kernel/NeKit/Json.h index 24357dd7..35f53b57 100644 --- a/dev/kernel/NeKit/Json.h +++ b/dev/kernel/NeKit/Json.h @@ -7,7 +7,7 @@ #pragma once -// last-rev: 02/04/25 +/// @brief Kernel JSON API. #include <CompilerKit/CompilerKit.h> #include <NeKit/Defines.h> @@ -15,58 +15,58 @@ #include <NeKit/Stream.h> #include <NeKit/Utils.h> -#define kJSONMaxLen (8196) -#define kJSONLen (256) -#define kJSONNullArr "[]" -#define kJSONNullObj "{}" +#define kNeJsonMaxLen (8196) +#define kNeJsonLen (256) +#define kNeJsonNullArr "[]" +#define kNeJsonNullObj "{}" namespace Kernel { /// @brief JavaScript object class -class Json final { +class JsonObject final { public: - explicit Json() { - auto len = kJSONMaxLen; - BasicKString<> key = KString(len); - key += kJSONNullObj; + explicit JsonObject() { + auto len = kNeJsonMaxLen; + KBasicString<> key = KString(len); + key += kNeJsonNullObj; this->AsKey() = key; this->AsValue() = key; } - explicit Json(SizeT lhsLen, SizeT rhsLen) : fKey(lhsLen), fValue(rhsLen) {} + explicit JsonObject(SizeT lhsLen, SizeT rhsLen) : fKey(lhsLen), fValue(rhsLen) {} - ~Json() = default; + ~JsonObject() = default; - NE_COPY_DEFAULT(Json) + NE_COPY_DEFAULT(JsonObject) Bool& IsUndefined() { return fUndefined; } private: Bool fUndefined; // is this instance undefined? - BasicKString<> fKey; - BasicKString<> fValue; + KBasicString<> fKey; + KBasicString<> fValue; public: /// @brief returns the key of the json /// @return the key as string view. - BasicKString<>& AsKey() { return fKey; } + KBasicString<>& AsKey() { return fKey; } /// @brief returns the value of the json. /// @return the key as string view. - BasicKString<>& AsValue() { return fValue; } + KBasicString<>& AsValue() { return fValue; } - static Json kNull; + static JsonObject kNull; }; -/// @brief Json stream reader helper. +/// @brief JsonObject stream reader helper. struct JsonStreamReader final { - STATIC Json In(const Char* full_array) { + STATIC JsonObject In(const Char* full_array) { auto start_val = '{'; auto end_val = '}'; Boolean probe_value = false; if (full_array[0] != start_val) { - if (full_array[0] != '[') return Json::kNull; + if (full_array[0] != '[') return JsonObject::kNull; start_val = '['; end_val = ']'; @@ -79,7 +79,7 @@ struct JsonStreamReader final { SizeT key_len = 0; SizeT value_len = 0; - Json type(kJSONMaxLen, kJSONMaxLen); + JsonObject type(kNeJsonMaxLen, kNeJsonMaxLen); for (SizeT i = 1; i < len; ++i) { if (full_array[i] == '\r' || full_array[i] == '\n') continue; @@ -125,5 +125,5 @@ struct JsonStreamReader final { } }; -using JsonStream = Stream<JsonStreamReader, Json>; +using JsonStream = Stream<JsonStreamReader, JsonObject>; } // namespace Kernel diff --git a/dev/kernel/NeKit/KString.h b/dev/kernel/NeKit/KString.h index bbe49f8e..6a1b04d2 100644 --- a/dev/kernel/NeKit/KString.h +++ b/dev/kernel/NeKit/KString.h @@ -12,52 +12,52 @@ #include <NeKit/KernelPanic.h> #include <NeKit/Utils.h> -#define kMinimumStringSize (8196U) - namespace Kernel { +inline auto kMinimumStringSize = 8196; + /// @brief Kernel string class, not dynamic. -template <SizeT MinSz = kMinimumStringSize> -class BasicKString final { +template <typename CharKind = Char> +class KBasicString final { public: - explicit BasicKString() { - fDataSz = MinSz; + explicit KBasicString() { + fDataSz = kMinimumStringSize; - fData = new Char[fDataSz]; + fData = new CharKind[fDataSz]; MUST_PASS(fData); rt_set_memory(fData, 0, fDataSz); } - explicit BasicKString(SizeT Sz) : fDataSz(Sz) { + explicit KBasicString(SizeT Sz) : fDataSz(Sz) { MUST_PASS(Sz > 1); - fData = new Char[Sz]; + fData = new CharKind[Sz]; MUST_PASS(fData); rt_set_memory(fData, 0, Sz); } - ~BasicKString() { + ~KBasicString() { if (fData) { delete[] fData; fData = nullptr; } } - NE_COPY_DEFAULT(BasicKString) + NE_COPY_DEFAULT(KBasicString) - Char* Data(); - const Char* CData() const; - Size Length() const; + CharKind* Data(); + const CharKind* CData() const; + Size Length() const; - bool operator==(const Char* rhs) const; - bool operator!=(const Char* rhs) const; + bool operator==(const CharKind* rhs) const; + bool operator!=(const CharKind* rhs) const; - bool operator==(const BasicKString<>& rhs) const; - bool operator!=(const BasicKString<>& rhs) const; + bool operator==(const KBasicString<CharKind>& rhs) const; + bool operator!=(const KBasicString<CharKind>& rhs) const; - BasicKString<>& operator+=(const Char* rhs); - BasicKString<>& operator+=(const BasicKString<>& rhs); + KBasicString<CharKind>& operator+=(const CharKind* rhs); + KBasicString<CharKind>& operator+=(const KBasicString<CharKind>& rhs); operator const char*() { return fData; } @@ -66,23 +66,26 @@ class BasicKString final { bool operator!() { return fData; } private: - Char* fData{nullptr}; - Size fDataSz{0}; - Size fCur{0}; + CharKind* fData{nullptr}; + Size fDataSz{0}; + Size fCur{0}; friend class KStringBuilder; }; -using KString = BasicKString<>; +using KString = KBasicString<>; using KStringOr = ErrorOr<KString>; class KStringBuilder final { public: - static ErrorOr<KString> Construct(const Char* data); - static const Char* FromBool(const Char* fmt, bool n); - static const Char* Format(const Char* fmt, const Char* from); - static bool Equals(const Char* lhs, const Char* rhs); - static bool Equals(const Utf8Char* lhs, const Utf8Char* rhs); + template <typename CharKind = Char> + static ErrorOr<KBasicString<CharKind>> Construct(const CharKind* data); + template <typename CharKind = Char> + static const CharKind* FromBool(const CharKind* fmt, bool n); + template <typename CharKind = Char> + static const CharKind* Format(const CharKind* fmt, const CharKind* from); + template <typename CharKind = Char> + static bool Equals(const CharKind* lhs, const CharKind* rhs); }; } // namespace Kernel diff --git a/dev/kernel/NeKit/KString.inl b/dev/kernel/NeKit/KString.inl index 1faefb08..d238818c 100644 --- a/dev/kernel/NeKit/KString.inl +++ b/dev/kernel/NeKit/KString.inl @@ -4,14 +4,13 @@ ------------------------------------------- */ -#include <NeKit/Utils.h> - -/// @file BasicKString<>.cc +/// @file KBasicString.inl /// @brief Kernel String manipulation file. namespace Kernel { -inline void rt_string_append(Char* lhs, const Char* rhs, Int32 cur) { - SizeT sz_rhs = rt_string_len(rhs); +template <typename CharKind> +inline void ort_string_append(CharKind* lhs, const CharKind* rhs, Int32 cur) { + SizeT sz_rhs = ort_string_len<CharKind>(rhs); SizeT rhs_i = 0; for (; rhs_i < sz_rhs; ++rhs_i) { @@ -19,23 +18,23 @@ inline void rt_string_append(Char* lhs, const Char* rhs, Int32 cur) { } } -template <> -inline Char* BasicKString<>::Data() { +template <typename CharKind> +inline CharKind* KBasicString<CharKind>::Data() { return this->fData; } -template <> -inline const Char* BasicKString<>::CData() const { - return const_cast<const Char*>(this->fData); +template <typename CharKind> +inline const CharKind* KBasicString<CharKind>::CData() const { + return const_cast<const CharKind*>(this->fData); } -template <> -inline SizeT BasicKString<>::Length() const { +template <typename CharKind> +inline SizeT KBasicString<CharKind>::Length() const { return this->fDataSz; } -template <> -inline bool BasicKString<>::operator==(const BasicKString<>& rhs) const { +template <typename CharKind> +inline bool KBasicString<CharKind>::operator==(const KBasicString<CharKind>& rhs) const { if (rhs.Length() != this->Length()) return false; for (Size index = 0; index < this->Length(); ++index) { @@ -45,19 +44,19 @@ inline bool BasicKString<>::operator==(const BasicKString<>& rhs) const { return true; } -template <> -inline bool BasicKString<>::operator==(const Char* rhs) const { - if (rt_string_len(rhs) != this->Length()) return false; +template <typename CharKind> +inline bool KBasicString<CharKind>::operator==(const CharKind* rhs) const { + if (ort_string_len<CharKind>(rhs) != this->Length()) return false; - for (Size index = 0; index < rt_string_len(rhs); ++index) { + for (Size index = 0; index < ort_string_len<CharKind>(rhs); ++index) { if (rhs[index] != this->fData[index]) return false; } return true; } -template <> -inline bool BasicKString<>::operator!=(const BasicKString<>& rhs) const { +template <typename CharKind> +inline bool KBasicString<CharKind>::operator!=(const KBasicString<CharKind>& rhs) const { if (rhs.Length() != this->Length()) return false; for (Size index = 0; index < rhs.Length(); ++index) { @@ -67,54 +66,55 @@ inline bool BasicKString<>::operator!=(const BasicKString<>& rhs) const { return true; } -template <> -inline bool BasicKString<>::operator!=(const Char* rhs) const { - if (rt_string_len(rhs) != this->Length()) return false; +template <typename CharKind> +inline bool KBasicString<CharKind>::operator!=(const CharKind* rhs) const { + if (ort_string_len<CharKind>(rhs) != this->Length()) return false; - for (Size index = 0; index < rt_string_len(rhs); ++index) { + for (Size index = 0; index < ort_string_len<CharKind>(rhs); ++index) { if (rhs[index] == this->fData[index]) return false; } return true; } -template <> -inline BasicKString<>& BasicKString<>::operator+=(const BasicKString<>& rhs) { - if (rt_string_len(rhs.fData) > this->Length()) return *this; +template <typename CharKind> +inline KBasicString<CharKind>& KBasicString<CharKind>::operator+=(const KBasicString<CharKind>& rhs) { + if (ort_string_len<CharKind>(rhs.fData) > this->Length()) return *this; - rt_string_append(this->fData, const_cast<Char*>(rhs.fData), this->fCur); - this->fCur += rt_string_len(const_cast<Char*>(rhs.fData)); + ort_string_append(this->fData, const_cast<CharKind*>(rhs.fData), this->fCur); + this->fCur += ort_string_len<CharKind>(const_cast<CharKind*>(rhs.fData)); return *this; } -template <> -inline BasicKString<>& BasicKString<>::operator+=(const Char* rhs) { - rt_string_append(this->fData, const_cast<Char*>(rhs), this->fCur); - this->fCur += rt_string_len(const_cast<Char*>(rhs)); +template <typename CharKind> +inline KBasicString<CharKind>& KBasicString<CharKind>::operator+=(const CharKind* rhs) { + ort_string_append(this->fData, const_cast<CharKind*>(rhs), this->fCur); + this->fCur += ort_string_len<CharKind>(const_cast<CharKind*>(rhs)); return *this; } -inline ErrorOr<BasicKString<>> KStringBuilder::Construct(const Char* data) { - if (!data || *data == 0) return ErrorOr<BasicKString<>>(new BasicKString<>(0)); +template <typename CharKind> +inline ErrorOr<KBasicString<CharKind>> KStringBuilder::Construct(const CharKind* data) { + if (!data || *data == 0) return ErrorOr<KBasicString<CharKind>>(nullptr); - BasicKString<>* view = new BasicKString<>(rt_string_len(data)); + KBasicString<CharKind>* view = new KBasicString<CharKind>(ort_string_len<CharKind>(data)); (*view) += data; - return ErrorOr<BasicKString<>>(*view); + return ErrorOr<KBasicString<CharKind>>(*view); } - -inline const Char* KStringBuilder::FromBool(const Char* fmt, bool i) { +template <typename CharKind> +inline const CharKind* KStringBuilder::FromBool(const CharKind* fmt, bool i) { if (!fmt) return ("?"); - const Char* boolean_expr = i ? "YES" : "NO"; - Char* ret = (Char*) RTL_ALLOCA(rt_string_len(boolean_expr) + rt_string_len(fmt)); + const CharKind* boolean_expr = i ? "YES" : "NO"; + CharKind* ret = (CharKind*) RTL_ALLOCA(ort_string_len<CharKind>(boolean_expr) + ort_string_len<CharKind>(fmt)); if (!ret) return ("?"); - const auto fmt_len = rt_string_len(fmt); - const auto res_len = rt_string_len(boolean_expr); + const auto fmt_len = ort_string_len<CharKind>(fmt); + const auto res_len = ort_string_len<CharKind>(boolean_expr); for (Size idx = 0; idx < fmt_len; ++idx) { if (fmt[idx] == '%') { @@ -133,41 +133,31 @@ inline const Char* KStringBuilder::FromBool(const Char* fmt, bool i) { return ret; } +template <typename CharKind> +inline bool KStringBuilder::Equals(const CharKind* lhs, const CharKind* rhs) { + if (ort_string_len<CharKind>(rhs) != ort_string_len<CharKind>(lhs)) return false; -inline bool KStringBuilder::Equals(const Char* lhs, const Char* rhs) { - if (rt_string_len(rhs) != rt_string_len(lhs)) return false; - - for (Size index = 0; index < rt_string_len(rhs); ++index) { + for (Size index = 0; index < ort_string_len<CharKind>(rhs); ++index) { if (rhs[index] != lhs[index]) return false; } return true; } - -inline bool KStringBuilder::Equals(const Utf8Char* lhs, const Utf8Char* rhs) { - if (urt_string_len(rhs) != urt_string_len(lhs)) return false; - - for (Size index = 0; rhs[index] != 0; ++index) { - if (rhs[index] != lhs[index]) return false; - } - - return true; -} - -inline const Char* KStringBuilder::Format(const Char* fmt, const Char* fmt2) { +template <typename CharKind> +inline const CharKind* KStringBuilder::Format(const CharKind* fmt, const CharKind* fmt2) { if (!fmt || !fmt2) return ("?"); - Char* ret = (Char*) RTL_ALLOCA(sizeof(char) * (rt_string_len(fmt2) + rt_string_len(fmt))); + CharKind* ret = (CharKind*) RTL_ALLOCA(sizeof(char) * (ort_string_len<CharKind>(fmt2) + ort_string_len<CharKind>(fmt))); if (!ret) return ("?"); - const auto len = rt_string_len(fmt); + const auto len = ort_string_len<CharKind>(fmt); for (Size idx = 0; idx < len; ++idx) { - if (fmt[idx] == '%' && idx < rt_string_len(fmt) && fmt[idx] == 's') { + if (fmt[idx] == '%' && idx < ort_string_len<CharKind>(fmt) && fmt[idx] == 's') { Size result_cnt = idx; - for (Size y_idx = 0; y_idx < rt_string_len(fmt2); ++y_idx) { + for (Size y_idx = 0; y_idx < ort_string_len<CharKind>(fmt2); ++y_idx) { ret[result_cnt] = fmt2[y_idx]; ++result_cnt; } diff --git a/dev/kernel/NeKit/Pair.h b/dev/kernel/NeKit/Pair.h index aeeeb8a2..61668f5a 100644 --- a/dev/kernel/NeKit/Pair.h +++ b/dev/kernel/NeKit/Pair.h @@ -6,8 +6,46 @@ #pragma once +#include <CompilerKit/CompilerKit.h> #include <NeKit/Defines.h> +#include <NeKit/ErrorOr.h> namespace Kernel { +template <typename T1, typename T2> class Pair; + +class PairBuilder; + +template <typename T1, typename T2> +class Pair final { + T1 fFirst{nullptr}; + T2 fSecond{nullptr}; + + friend PairBuilder; + + public: + explicit Pair() = default; + ~Pair() = default; + + NE_COPY_DEFAULT(Pair) + + T1& First() { return fFirst; } + T2& Second() { return fSecond; } + + const T1& First() const { return *fFirst; } + const T2& Second() const { return *fSecond; } + + private: + Pair(T1 first, T2 second) : fFirst(first), fSecond(second) {} +}; + +class PairBuilder final { + template <typename T1, typename T2> + STATIC Pair<T1, T2> Construct(T1 first, T2 second) { + return Pair(first, second); + } +}; + +template <typename T1, typename T2> +using PairOr = ErrorOr<Pair<T1, T2>>; } // namespace Kernel diff --git a/dev/kernel/NeKit/Ref.h b/dev/kernel/NeKit/Ref.h index a791ee1a..566f7486 100644 --- a/dev/kernel/NeKit/Ref.h +++ b/dev/kernel/NeKit/Ref.h @@ -5,8 +5,8 @@ ------------------------------------------- */ -#ifndef _NEWKIT_REF_H_ -#define _NEWKIT_REF_H_ +#ifndef _NEKIT_REF_H_ +#define _NEKIT_REF_H_ #include <CompilerKit/CompilerKit.h> #include <KernelKit/HeapMgr.h> @@ -65,6 +65,9 @@ class NonNullRef final { private: Ref<T> fRef{}; }; + +using RefAny = Ref<Any>; +using NonNullRefAny = NonNullRef<Any>; } // namespace Kernel -#endif // ifndef _NEWKIT_REF_H_ +#endif // ifndef _NEKIT_REF_H_ diff --git a/dev/kernel/NeKit/Utils.h b/dev/kernel/NeKit/Utils.h index a7576e77..ee18d04c 100644 --- a/dev/kernel/NeKit/Utils.h +++ b/dev/kernel/NeKit/Utils.h @@ -38,4 +38,16 @@ Int urt_string_cmp(const Utf8Char* src, const Utf8Char* cmp, Size len); Void urt_set_memory(const voidPtr src, UInt32 dst, Size len); Int urt_copy_memory(const voidPtr src, voidPtr dst, Size len); Size urt_string_len(const Utf8Char* str); + +/// OpenTemplate UTILS API + +template <typename CharType = Char> +inline SizeT ort_string_len(const CharType* str) { + if (!str) return 0; + + SizeT len{0}; + + while (str[len] != 0) ++len; + return len; +} } // namespace Kernel diff --git a/dev/kernel/NeKit/Variant.h b/dev/kernel/NeKit/Variant.h index 51548272..700c9d9a 100644 --- a/dev/kernel/NeKit/Variant.h +++ b/dev/kernel/NeKit/Variant.h @@ -33,9 +33,10 @@ class Variant final { ~Variant() = default; public: - explicit Variant(KString* stringView) : fPtr((VoidPtr) stringView), fKind(VariantKind::kString) {} + template <typename CharKind> + explicit Variant(KBasicString<CharKind>* stringView) : fPtr((VoidPtr) stringView), fKind(VariantKind::kString) {} - explicit Variant(Json* json) : fPtr((VoidPtr) json), fKind(VariantKind::kJson) {} + explicit Variant(JsonObject* json) : fPtr((VoidPtr) json), fKind(VariantKind::kJson) {} explicit Variant(nullPtr ptr) : fPtr(ptr), fKind(VariantKind::kNull) {} @@ -55,7 +56,7 @@ class Variant final { VariantKind& Kind(); private: - voidPtr fPtr{nullptr}; + VoidPtr fPtr{nullptr}; VariantKind fKind{VariantKind::kNull}; }; } // namespace Kernel diff --git a/dev/kernel/NetworkKit/IPC.h b/dev/kernel/NetworkKit/IPC.h index 223a112b..c65ec6fb 100644 --- a/dev/kernel/NetworkKit/IPC.h +++ b/dev/kernel/NetworkKit/IPC.h @@ -38,13 +38,10 @@ struct PACKED IPC_ADDR final { // some operators. //////////////////////////////////// - bool operator==(const IPC_ADDR& addr) noexcept; - - bool operator==(IPC_ADDR& addr) noexcept; - - bool operator!=(const IPC_ADDR& addr) noexcept; - - bool operator!=(IPC_ADDR& addr) noexcept; + BOOL operator==(const IPC_ADDR& addr) noexcept; + BOOL operator==(IPC_ADDR& addr) noexcept; + BOOL operator!=(const IPC_ADDR& addr) noexcept; + BOOL operator!=(IPC_ADDR& addr) noexcept; }; typedef struct IPC_ADDR IPC_ADDR; @@ -58,7 +55,7 @@ enum { constexpr inline auto kIPCMsgSize = 6094U; enum { - kIPCLockInvalid, + kIPCLockInvalid = 0, kIPCLockFree = 1, kIPCLockUsed = 2, }; @@ -77,17 +74,17 @@ typedef struct IPC_MSG final { UInt32 IpcLock; /// @brief Passes the message to target, could be anything, HTTP packet, JSON or whatever. static Bool Pass(IPC_MSG* self, IPC_MSG* target) noexcept; -} PACKED IPC_MSG; +} PACKED ALIGN(8) IPC_MSG; /// @brief Sanitize packet function /// @retval true packet is correct. /// @retval false packet is incorrect and process has crashed. -Bool ipc_sanitize_packet(_Input IPC_MSG* pckt_in); +BOOL ipc_sanitize_packet(_Input IPC_MSG* pckt_in); /// @brief Construct packet function /// @retval true packet is correct. /// @retval false packet is incorrect and process has crashed. -Bool ipc_construct_packet(_Output _Input IPC_MSG** pckt_in); +BOOL ipc_construct_packet(_Output _Input IPC_MSG** pckt_in); } // namespace Kernel #endif // INC_IPC_H diff --git a/dev/kernel/NetworkKit/MAC.h b/dev/kernel/NetworkKit/MAC.h index 805f7259..9cfd93c2 100644 --- a/dev/kernel/NetworkKit/MAC.h +++ b/dev/kernel/NetworkKit/MAC.h @@ -10,7 +10,7 @@ #include <NeKit/Defines.h> #include <NeKit/KString.h> -#define kMACAddrLen (32) +#define kMACAddrLen (32U) namespace Kernel { class MacAddressGetter; diff --git a/dev/kernel/SignalKit/SignalGen.h b/dev/kernel/SignalKit/Signals.h index 4be9452a..fdc27161 100644 --- a/dev/kernel/SignalKit/SignalGen.h +++ b/dev/kernel/SignalKit/Signals.h @@ -26,10 +26,10 @@ namespace Kernel { typedef SizeT rt_signal_kind; /// @brief Standard signal seed for general purpose usage. -inline static constexpr auto kUserSignalSeed = 0x0895034fUL; +inline constexpr auto kUserSignalSeed = 0x0895034fUL; /// @brief Special signal seed for kernel usage. -inline static constexpr auto kKernelSignalSeed = 0x0895034f9fUL; +inline constexpr auto kKernelSignalSeed = 0x0895034f9fUL; /// @brief Generate signal from **Sig** template <rt_signal_kind Sig, SizeT Seed = kUserSignalSeed> diff --git a/dev/kernel/StorageKit/AHCI.h b/dev/kernel/StorageKit/AHCI.h index 3b9dac67..d4f7cc55 100644 --- a/dev/kernel/StorageKit/AHCI.h +++ b/dev/kernel/StorageKit/AHCI.h @@ -14,10 +14,10 @@ namespace Kernel { /// @brief AHCIDeviceInterface class /// @details This class is used to send and receive data from the AHCI device. /// @note The class is derived from the DeviceInterface class. -class AHCIDeviceInterface NE_DEVICE<MountpointInterface*> { +class AHCIDeviceInterface NE_DEVICE<IMountpoint*> { public: - explicit AHCIDeviceInterface(void (*out)(DeviceInterface* self, MountpointInterface* out), - void (*in)(DeviceInterface* self, MountpointInterface* in)); + explicit AHCIDeviceInterface(void (*out)(DeviceInterface* self, IMountpoint* out), + void (*in)(DeviceInterface* self, IMountpoint* in)); virtual ~AHCIDeviceInterface() override; @@ -36,8 +36,8 @@ class AHCIDeviceInterface NE_DEVICE<MountpointInterface*> { Void SetIndex(const UInt32& drv); public: - AHCIDeviceInterface& operator<<(MountpointInterface* Data) override; - AHCIDeviceInterface& operator>>(MountpointInterface* Data) override; + AHCIDeviceInterface& operator<<(IMountpoint* Data) override; + AHCIDeviceInterface& operator>>(IMountpoint* Data) override; private: UInt16 fPortsImplemented{0U}; @@ -45,5 +45,5 @@ class AHCIDeviceInterface NE_DEVICE<MountpointInterface*> { }; UInt16 sk_init_ahci_device(BOOL atapi); -ErrorOr<AHCIDeviceInterface> sk_acquire_ahci_device(Int32 drv_index); +ErrorOr<AHCIDeviceInterface> sk_acquire_ahci_device(UInt32 drv_index); } // namespace Kernel diff --git a/dev/kernel/StorageKit/ATA.h b/dev/kernel/StorageKit/ATA.h index d4c894a3..49ab3e4e 100644 --- a/dev/kernel/StorageKit/ATA.h +++ b/dev/kernel/StorageKit/ATA.h @@ -13,16 +13,16 @@ namespace Kernel { /// @brief ATA device interface class. -class ATADeviceInterface : public DeviceInterface<MountpointInterface*> { +class ATADeviceInterface : public DeviceInterface<IMountpoint*> { public: - explicit ATADeviceInterface(void (*Out)(DeviceInterface*, MountpointInterface* outpacket), - void (*In)(DeviceInterface*, MountpointInterface* inpacket)); + explicit ATADeviceInterface(void (*Out)(DeviceInterface*, IMountpoint* outpacket), + void (*In)(DeviceInterface*, IMountpoint* inpacket)); virtual ~ATADeviceInterface(); public: - ATADeviceInterface& operator<<(MountpointInterface* Data) override; - ATADeviceInterface& operator>>(MountpointInterface* Data) override; + ATADeviceInterface& operator<<(IMountpoint* Data) override; + ATADeviceInterface& operator>>(IMountpoint* Data) override; public: ATADeviceInterface& operator=(const ATADeviceInterface&) = default; diff --git a/dev/kernel/StorageKit/NVME.h b/dev/kernel/StorageKit/NVME.h index 1b2b6358..9852c5eb 100644 --- a/dev/kernel/StorageKit/NVME.h +++ b/dev/kernel/StorageKit/NVME.h @@ -10,10 +10,10 @@ #include <KernelKit/DriveMgr.h> namespace Kernel { -class NVMEDeviceInterface final NE_DEVICE<MountpointInterface*> { +class NVMEDeviceInterface final NE_DEVICE<IMountpoint*> { public: - explicit NVMEDeviceInterface(Void (*out)(DeviceInterface*, MountpointInterface* out_packet), - Void (*in)(DeviceInterface*, MountpointInterface* in_packet), + explicit NVMEDeviceInterface(Void (*out)(DeviceInterface*, IMountpoint* out_packet), + Void (*in)(DeviceInterface*, IMountpoint* in_packet), Void (*cleanup)(Void)); ~NVMEDeviceInterface() override; @@ -24,7 +24,7 @@ class NVMEDeviceInterface final NE_DEVICE<MountpointInterface*> { const Char* Name() const override; public: - OwnPtr<MountpointInterface*> operator()(UInt32 dma_low, UInt32 dma_high, SizeT dma_sz); + OwnPtr<IMountpoint*> operator()(UInt32 dma_low, UInt32 dma_high, SizeT dma_sz); private: Void (*fCleanup)(Void) = {nullptr}; diff --git a/dev/kernel/amd64-desktop.make b/dev/kernel/amd64-desktop.make index bfcca16b..a3040c89 100644 --- a/dev/kernel/amd64-desktop.make +++ b/dev/kernel/amd64-desktop.make @@ -5,7 +5,7 @@ CXX = x86_64-w64-mingw32-g++ LD = x86_64-w64-mingw32-ld -CCFLAGS = -fshort-wchar -c -D__NE_AMD64__ -D__NE_VEPM__ -Wall -Wpedantic -Wextra -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__FSKIT_INCLUDES_HEFS__ -D__FSKIT_INCLUDES_EXT2__ -D__NE_SUPPORT_NX__ -O0 -I../vendor -D__NEOSKRNL__ -D__HAVE_NE_APIS__ -D__FREESTANDING__ -D__NE_VIRTUAL_MEMORY_SUPPORT__ -D__NE_AUTO_FORMAT__ -D__NE__ -I./ -I../ -I../boot +CCFLAGS = -fshort-wchar -c -D__NE_AMD64__ -D__NE_USE_PEF__ -D__NE_VEPM__ -Wall -Wpedantic -Wextra -mno-red-zone -fno-rtti -fno-exceptions -std=c++20 -D__FSKIT_INCLUDES_HEFS__ -D__FSKIT_INCLUDES_EXT2__ -D__NE_SUPPORT_NX__ -O0 -I../vendor -D__NEOSKRNL__ -D__HAVE_NE_APIS__ -D__FREESTANDING__ -D__NE_VIRTUAL_MEMORY_SUPPORT__ -D__NE_AUTO_FORMAT__ -D__NE__ -I./ -I../ -I../boot ASM = nasm diff --git a/dev/kernel/arm64-desktop.make b/dev/kernel/arm64-desktop.make index e83e1db8..da629254 100644 --- a/dev/kernel/arm64-desktop.make +++ b/dev/kernel/arm64-desktop.make @@ -37,7 +37,7 @@ nekernel-arm64-epm: clean $(CC) $(CCFLAGS) $(DISKDRIVER) $(DEBUG) $(wildcard src/*.cc) \ $(wildcard src/FS/*.cc) $(wildcard HALKit/ARM64/Storage/*.cc) \ $(wildcard HALKit/ARM64/PCI/*.cc) $(wildcard src/Network/*.cc) $(wildcard src/Storage/*.cc) \ - $(wildcard HALKit/ARM64/*.cc) $(wildcard HALKit/ARM64/*.cpp) \ + $(wildcard HALKit/ARM64/*.cc) $(wildcard HALKit/ARM64/*.cc) \ $(wildcard HALKit/ARM64/*.s) $(wildcard HALKit/ARM64/APM/*.cc) $(MOVEALL) diff --git a/dev/kernel/src/AsciiUtils.cc b/dev/kernel/src/AsciiUtils.cc index cca3a368..8d2f9dc5 100644 --- a/dev/kernel/src/AsciiUtils.cc +++ b/dev/kernel/src/AsciiUtils.cc @@ -52,9 +52,12 @@ Int32 rt_copy_memory_safe(const voidPtr src, voidPtr dst, Size len, Size dst_siz } return -1; } + auto s = reinterpret_cast<const UInt8*>(src); auto d = reinterpret_cast<UInt8*>(dst); + for (Size i = 0; i < len; ++i) d[i] = s[i]; + return static_cast<Int>(len); } diff --git a/dev/kernel/src/Atom.cc b/dev/kernel/src/Atom.cc index 6e84d7d5..a0e45468 100644 --- a/dev/kernel/src/Atom.cc +++ b/dev/kernel/src/Atom.cc @@ -6,5 +6,5 @@ #include <NeKit/Atom.h> -// @file Atom.cpp +// @file Atom.cc // @brief Atomic primitives diff --git a/dev/kernel/src/Crc32.cc b/dev/kernel/src/Crc32.cc index 46a1d940..df0b34e3 100644 --- a/dev/kernel/src/Crc32.cc +++ b/dev/kernel/src/Crc32.cc @@ -6,7 +6,9 @@ #include <NeKit/Crc32.h> -// @file CRC32.cpp +#define kCrcCnt (256) + +// @file CRC32.cc // @brief Check sequence implementation. namespace Kernel { diff --git a/dev/kernel/src/FS/Ext2+FileSystemParser.cc b/dev/kernel/src/FS/Ext2+FileSystemParser.cc deleted file mode 100644 index 318f83d6..00000000 --- a/dev/kernel/src/FS/Ext2+FileSystemParser.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#ifdef __FSKIT_INCLUDES_EXT2__ - -#include <FSKit/Ext2+IFS.h> -#include <FirmwareKit/EPM.h> -#include <KernelKit/KPC.h> -#include <KernelKit/ProcessScheduler.h> -#include <KernelKit/UserMgr.h> -#include <NeKit/Crc32.h> -#include <NeKit/KString.h> -#include <NeKit/KernelPanic.h> -#include <NeKit/Utils.h> -#include <modules/AHCI/AHCI.h> -#include <modules/ATA/ATA.h> - -#endif // ifdef __FSKIT_INCLUDES_EXT2__ diff --git a/dev/kernel/src/FS/Ext2+FileMgr.cc b/dev/kernel/src/FS/Ext2+IFS.cc index 7c28c0c9..2c359197 100644 --- a/dev/kernel/src/FS/Ext2+FileMgr.cc +++ b/dev/kernel/src/FS/Ext2+IFS.cc @@ -17,14 +17,14 @@ #include <NeKit/KernelPanic.h> #include <NeKit/Utils.h> -constexpr UInt32 EXT2_DIRECT_BLOCKS = 12; -constexpr UInt32 EXT2_SINGLE_INDIRECT_INDEX = 12; -constexpr UInt32 EXT2_DOUBLE_INDIRECT_INDEX = 13; -constexpr UInt32 EXT2_TRIPLE_INDIRECT_INDEX = 14; -constexpr UInt32 EXT2_ROOT_INODE = 2; -constexpr UInt32 EXT2_SUPERBLOCK_BLOCK = 1; -constexpr UInt32 EXT2_GROUP_DESC_BLOCK_SMALL = 2; -constexpr UInt32 EXT2_GROUP_DESC_BLOCK_LARGE = 1; +constexpr static UInt32 EXT2_DIRECT_BLOCKS = 12; +constexpr static UInt32 EXT2_SINGLE_INDIRECT_INDEX = 12; +constexpr static UInt32 EXT2_DOUBLE_INDIRECT_INDEX = 13; +constexpr ATTRIBUTE(unused) static UInt32 EXT2_TRIPLE_INDIRECT_INDEX = 14; +constexpr static UInt32 EXT2_ROOT_INODE = 2; +constexpr ATTRIBUTE(unused) static UInt32 EXT2_SUPERBLOCK_BLOCK = 1; +constexpr static UInt32 EXT2_GROUP_DESC_BLOCK_SMALL = 2; +constexpr static UInt32 EXT2_GROUP_DESC_BLOCK_LARGE = 1; static inline SizeT ext2_min(SizeT a, SizeT b) { return a < b ? a : b; @@ -38,8 +38,7 @@ struct Ext2GroupInfo { }; // Convert EXT2 block number -> LBA (sector index) for Drive I/O. -static inline UInt32 ext2_block_to_lba(Ext2Context* ctx, - UInt32 blockNumber) { +static inline UInt32 ext2_block_to_lba(Ext2Context* ctx, UInt32 blockNumber) { if (!ctx || !ctx->drive) return 0; UInt32 blockSize = ctx->BlockSize(); UInt32 sectorSize = ctx->drive->fSectorSz; @@ -48,13 +47,11 @@ static inline UInt32 ext2_block_to_lba(Ext2Context* ctx, } // Read a block and return a pointer to its content -static ErrorOr<UInt32*> ext2_read_block_ptr(Ext2Context* ctx, - UInt32 blockNumber) { - if (!ctx || !ctx->drive || !ctx->superblock) - return ErrorOr<UInt32*>(kErrorInvalidData); +static ErrorOr<UInt32*> ext2_read_block_ptr(Ext2Context* ctx, UInt32 blockNumber) { + if (!ctx || !ctx->drive || !ctx->superblock) return ErrorOr<UInt32*>(kErrorInvalidData); UInt32 blockSize = ctx->BlockSize(); - auto buf = (UInt32*) mm_alloc_ptr(blockSize, true, false); + auto buf = (UInt32*) mm_alloc_ptr(blockSize, true, false); if (!buf) return ErrorOr<UInt32*>(kErrorHeapOutOfMemory); UInt32 lba = ext2_block_to_lba(ctx, blockNumber); @@ -67,7 +64,7 @@ static ErrorOr<UInt32*> ext2_read_block_ptr(Ext2Context* ctx, // Get the block address for a given logical block index static ErrorOr<UInt32> ext2_get_block_address(Ext2Context* ctx, Ext2Node* node, - UInt32 logicalIndex) { + UInt32 logicalIndex) { if (!ctx || !node || !ctx->drive) return ErrorOr<UInt32>(kErrorInvalidData); UInt32 blockSize = ctx->BlockSize(); @@ -132,8 +129,7 @@ static ErrorOr<UInt32> ext2_get_block_address(Ext2Context* ctx, Ext2Node* node, return ErrorOr<UInt32>(kErrorUnimplemented); } -static ErrorOr<voidPtr> ext2_read_inode_data(Ext2Context* ctx, Ext2Node* node, - SizeT size) { +static ErrorOr<voidPtr> ext2_read_inode_data(Ext2Context* ctx, Ext2Node* node, SizeT size) { if (!ctx || !ctx->drive || !node || size == 0) return ErrorOr<voidPtr>(1); auto blockSize = ctx->BlockSize(); @@ -190,7 +186,7 @@ static ErrorOr<voidPtr> ext2_read_inode_data(Ext2Context* ctx, Ext2Node* node, // Get group descriptor information for a given block/inode number static ErrorOr<Ext2GroupInfo*> ext2_get_group_descriptor_info(Ext2Context* ctx, - UInt32 targetBlockOrInode) { + UInt32 targetBlockOrInode) { if (!ctx || !ctx->superblock || !ctx->drive) return ErrorOr<Ext2GroupInfo*>(kErrorInvalidData); UInt32 blockSize = ctx->BlockSize(); @@ -260,8 +256,7 @@ static ErrorOr<Ext2GroupInfo*> ext2_get_group_descriptor_info(Ext2Context* ctx, } // Allocate a new block -inline ErrorOr<UInt32> ext2_alloc_block(Ext2Context* ctx, - EXT2_GROUP_DESCRIPTOR* groupDesc) { +inline ErrorOr<UInt32> ext2_alloc_block(Ext2Context* ctx, EXT2_GROUP_DESCRIPTOR* groupDesc) { if (!ctx || !ctx->superblock || !groupDesc) return ErrorOr<UInt32>(kErrorInvalidData); UInt32 blockSize = ctx->BlockSize(); @@ -308,10 +303,8 @@ inline ErrorOr<UInt32> ext2_alloc_block(Ext2Context* ctx, } // Indirect blocks -static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, - Ext2Node* node, - UInt32 logicalBlockIndex, - UInt32 physicalBlockNumber) { +static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, Ext2Node* node, + UInt32 logicalBlockIndex, UInt32 physicalBlockNumber) { using namespace Kernel; if (!ctx || !ctx->drive || !node) return ErrorOr<Void*>(kErrorInvalidData); @@ -518,15 +511,14 @@ static ErrorOr<Void*> ext2_set_block_address(Ext2Context* ctx, // Find a directory entry by name within a directory inode static ErrorOr<EXT2_DIR_ENTRY*> ext2_find_dir_entry(Ext2Context* ctx, Ext2Node* dirNode, const char* name) { - if (!ctx || !ctx->drive || !dirNode || !name) - return ErrorOr<EXT2_DIR_ENTRY*>(kErrorInvalidData); + if (!ctx || !ctx->drive || !dirNode || !name) return ErrorOr<EXT2_DIR_ENTRY*>(kErrorInvalidData); // Check directory type auto type = (dirNode->inode.fMode >> 12) & 0xF; if (type != kExt2FileTypeDirectory) return ErrorOr<EXT2_DIR_ENTRY*>(kErrorInvalidData); UInt32 blockSize = ctx->BlockSize(); - auto blockBuf = mm_alloc_ptr(blockSize, true, false); + auto blockBuf = mm_alloc_ptr(blockSize, true, false); if (!blockBuf) return ErrorOr<EXT2_DIR_ENTRY*>(kErrorHeapOutOfMemory); SizeT nameLen = rt_string_len(name); @@ -578,8 +570,7 @@ static inline UInt16 ext2_dir_entry_ideal_len(UInt8 nameLen) { } static ErrorOr<Void*> ext2_add_dir_entry(Ext2Context* ctx, Ext2Node* parentDirNode, - const char* name, UInt32 inodeNumber, - UInt8 fileType) { + const char* name, UInt32 inodeNumber, UInt8 fileType) { using namespace Kernel; if (!ctx || !ctx->drive || !parentDirNode || !name) return ErrorOr<Void*>(kErrorInvalidData); @@ -763,8 +754,7 @@ static ErrorOr<Void*> ext2_add_dir_entry(Ext2Context* ctx, Ext2Node* parentDirNo } // Soon -static ErrorOr<UInt32> ext2_alloc_inode(Ext2Context* ctx, - EXT2_GROUP_DESCRIPTOR* groupDesc) { +static ErrorOr<UInt32> ext2_alloc_inode(Ext2Context* ctx, EXT2_GROUP_DESCRIPTOR* groupDesc) { if (!ctx || !ctx->superblock || !groupDesc) return ErrorOr<UInt32>(kErrorInvalidData); UInt32 blockSize = ctx->BlockSize(); @@ -902,8 +892,8 @@ struct PathComponents { return; } - UInt32 compCount = 0; - Char* p = buffer; + UInt32 compCount = 0; + Char* p = buffer; while (*p != '\0') { // skip slashes @@ -952,16 +942,19 @@ struct PathComponents { } // anonymous namespace // The Ext2FileSystemParser (not manager!) -Ext2FileSystemParser::Ext2FileSystemParser(DriveTrait* drive) : ctx(drive) {} +Ext2FileSystemParser::Ext2FileSystemParser(DriveTrait* drive) : fCtx(drive) { + MUST_PASS(fCtx); +} + NodePtr Ext2FileSystemParser::Open(const char* path, const char* restrict_type) { NE_UNUSED(restrict_type); - if (!path || *path == '\0' || !this->ctx.drive) { + if (!path || *path == '\0' || !this->fCtx.drive) { return nullptr; } // Root ("/") if (rt_string_len(path) == 1 && rt_string_cmp(path, "/", 1) == 0) { - auto inodeResult = ext2_load_inode(&this->ctx, EXT2_ROOT_INODE); + auto inodeResult = ext2_load_inode(&this->fCtx, EXT2_ROOT_INODE); if (!inodeResult) { return nullptr; } @@ -982,8 +975,8 @@ NodePtr Ext2FileSystemParser::Open(const char* path, const char* restrict_type) UInt32 currentInodeNumber = EXT2_ROOT_INODE; Ext2Node* currentDirNode = nullptr; - for (UInt32 i = 0; i < (UInt32)pathComponents.count; ++i) { - auto inodeResult = ext2_load_inode(&this->ctx, currentInodeNumber); + for (UInt32 i = 0; i < (UInt32) pathComponents.count; ++i) { + auto inodeResult = ext2_load_inode(&this->fCtx, currentInodeNumber); if (!inodeResult) { if (currentDirNode) mm_free_ptr(currentDirNode); return nullptr; @@ -1011,7 +1004,7 @@ NodePtr Ext2FileSystemParser::Open(const char* path, const char* restrict_type) } auto dirEntryResult = - ext2_find_dir_entry(&this->ctx, currentDirNode, pathComponents.components[i]); + ext2_find_dir_entry(&this->fCtx, currentDirNode, pathComponents.components[i]); if (!dirEntryResult) { mm_free_ptr(currentDirNode); return nullptr; @@ -1022,7 +1015,7 @@ NodePtr Ext2FileSystemParser::Open(const char* path, const char* restrict_type) mm_free_ptr(entryPtr); } - auto finalInodeResult = ext2_load_inode(&this->ctx, currentInodeNumber); + auto finalInodeResult = ext2_load_inode(&this->fCtx, currentInodeNumber); if (!finalInodeResult) { if (currentDirNode) mm_free_ptr(currentDirNode); return nullptr; @@ -1048,7 +1041,7 @@ void* Ext2FileSystemParser::Read(NodePtr node, Int32 flags, SizeT size) { NE_UNUSED(flags); auto extNode = reinterpret_cast<Ext2Node*>(node); - auto dataResult = ext2_read_inode_data(&this->ctx, extNode, size); + auto dataResult = ext2_read_inode_data(&this->fCtx, extNode, size); if (!dataResult) { return nullptr; // error, nothing to return @@ -1068,7 +1061,7 @@ void Ext2FileSystemParser::Write(NodePtr node, void* data, Int32 flags, SizeT si NE_UNUSED(flags); auto extNode = reinterpret_cast<Ext2Node*>(node); - auto blockSize = this->ctx.BlockSize(); + auto blockSize = this->fCtx.BlockSize(); SizeT bytesWritten = 0; UInt32 currentOffset = extNode->cursor; @@ -1078,19 +1071,19 @@ void Ext2FileSystemParser::Write(NodePtr node, void* data, Int32 flags, SizeT si UInt32 logicalBlockIndex = currentOffset / blockSize; UInt32 offsetInBlock = currentOffset % blockSize; - auto physBlockResult = ext2_get_block_address(&this->ctx, extNode, logicalBlockIndex); + auto physBlockResult = ext2_get_block_address(&this->fCtx, extNode, logicalBlockIndex); UInt32 physicalBlock = 0; if (!physBlockResult) { auto err = physBlockResult.Error(); if (err == kErrorInvalidData || err == kErrorUnimplemented) { - auto groupInfoResult = ext2_get_group_descriptor_info(&this->ctx, extNode->inodeNumber); + auto groupInfoResult = ext2_get_group_descriptor_info(&this->fCtx, extNode->inodeNumber); if (!groupInfoResult) { return; } auto groupInfo = *groupInfoResult.Leak(); - auto allocResult = ext2_alloc_block(&this->ctx, groupInfo->groupDesc); + auto allocResult = ext2_alloc_block(&this->fCtx, groupInfo->groupDesc); if (!allocResult) { mm_free_ptr(reinterpret_cast<void*>(groupInfo->blockBuffer)); mm_free_ptr(groupInfo); @@ -1099,15 +1092,16 @@ void Ext2FileSystemParser::Write(NodePtr node, void* data, Int32 flags, SizeT si physicalBlock = *allocResult.Leak(); - auto setRes = ext2_set_block_address(&this->ctx, extNode, logicalBlockIndex, physicalBlock); + auto setRes = + ext2_set_block_address(&this->fCtx, extNode, logicalBlockIndex, physicalBlock); if (!setRes) { mm_free_ptr(reinterpret_cast<void*>(groupInfo->blockBuffer)); mm_free_ptr(groupInfo); return; } - UInt32 gdtLba = ext2_block_to_lba(&this->ctx, groupInfo->groupDescriptorBlock); - if (!ext2_write_block(this->ctx.drive, gdtLba, groupInfo->blockBuffer, blockSize)) { + UInt32 gdtLba = ext2_block_to_lba(&this->fCtx, groupInfo->groupDescriptorBlock); + if (!ext2_write_block(this->fCtx.drive, gdtLba, groupInfo->blockBuffer, blockSize)) { mm_free_ptr(reinterpret_cast<void*>(groupInfo->blockBuffer)); mm_free_ptr(groupInfo); return; @@ -1122,13 +1116,13 @@ void Ext2FileSystemParser::Write(NodePtr node, void* data, Int32 flags, SizeT si physicalBlock = physBlockResult.Value(); } - UInt32 physicalLba = ext2_block_to_lba(&this->ctx, physicalBlock); + UInt32 physicalLba = ext2_block_to_lba(&this->fCtx, physicalBlock); auto blockBuf = mm_alloc_ptr(blockSize, true, false); if (!blockBuf) return; if (offsetInBlock > 0 || (size - bytesWritten) < blockSize) { - if (!ext2_read_block(this->ctx.drive, physicalLba, blockBuf, blockSize)) { + if (!ext2_read_block(this->fCtx.drive, physicalLba, blockBuf, blockSize)) { mm_free_ptr(blockBuf); return; } @@ -1141,7 +1135,7 @@ void Ext2FileSystemParser::Write(NodePtr node, void* data, Int32 flags, SizeT si rt_copy_memory_safe(src, static_cast<void*>((UInt8*) blockBuf + offsetInBlock), bytesInCurrentBlock, blockSize - offsetInBlock); - if (!ext2_write_block(this->ctx.drive, physicalLba, blockBuf, blockSize)) { + if (!ext2_write_block(this->fCtx.drive, physicalLba, blockBuf, blockSize)) { mm_free_ptr(blockBuf); return; } @@ -1160,7 +1154,7 @@ void Ext2FileSystemParser::Write(NodePtr node, void* data, Int32 flags, SizeT si extNode->inode.fBlocks = (extNode->inode.fSize + blockSize - 1) / blockSize; extNode->inode.fModifyTime = 0; - auto writeInodeRes = ext2_write_inode(&this->ctx, extNode); + auto writeInodeRes = ext2_write_inode(&this->fCtx, extNode); if (!writeInodeRes) { // Failed to persist inode } @@ -1226,7 +1220,7 @@ NodePtr Ext2FileSystemParser::Create(const char* path) { NodePtr parentDirNodePtr = nullptr; if (currentPathLen == 0) { // root - auto inodeRes = ext2_load_inode(&this->ctx, EXT2_ROOT_INODE); + auto inodeRes = ext2_load_inode(&this->fCtx, EXT2_ROOT_INODE); if (!inodeRes) return nullptr; parentDirNodePtr = mm_alloc_ptr(sizeof(Ext2Node), true, false); if (!parentDirNodePtr) return nullptr; @@ -1248,7 +1242,7 @@ NodePtr Ext2FileSystemParser::Create(const char* path) { } // Get group info for allocation - auto groupInfoResult = ext2_get_group_descriptor_info(&this->ctx, parentDirNode->inodeNumber); + auto groupInfoResult = ext2_get_group_descriptor_info(&this->fCtx, parentDirNode->inodeNumber); if (!groupInfoResult) { mm_free_ptr(parentDirNode); return nullptr; @@ -1256,7 +1250,7 @@ NodePtr Ext2FileSystemParser::Create(const char* path) { auto groupInfo = *groupInfoResult.Leak(); // Allocate new inode - auto newInodeRes = ext2_alloc_inode(&this->ctx, groupInfo->groupDesc); + auto newInodeRes = ext2_alloc_inode(&this->fCtx, groupInfo->groupDesc); if (!newInodeRes) { mm_free_ptr(reinterpret_cast<void*>(groupInfo->blockBuffer)); mm_free_ptr(groupInfo); // so this works @@ -1265,8 +1259,8 @@ NodePtr Ext2FileSystemParser::Create(const char* path) { } UInt32 newInodeNumber = newInodeRes.Value(); - UInt32 gdtLba = ext2_block_to_lba(&this->ctx, groupInfo->groupDescriptorBlock); - if (!ext2_write_block(this->ctx.drive, gdtLba, groupInfo->blockBuffer, this->ctx.BlockSize())) { + UInt32 gdtLba = ext2_block_to_lba(&this->fCtx, groupInfo->groupDescriptorBlock); + if (!ext2_write_block(this->fCtx.drive, gdtLba, groupInfo->blockBuffer, this->fCtx.BlockSize())) { mm_free_ptr(reinterpret_cast<void*>(groupInfo->blockBuffer)); mm_free_ptr(groupInfo); mm_free_ptr(parentDirNode); @@ -1296,7 +1290,7 @@ NodePtr Ext2FileSystemParser::Create(const char* path) { newFileNode->inode.fModifyTime = 0; // Persist new inode - auto writeInodeRes = ext2_write_inode(&this->ctx, newFileNode); + auto writeInodeRes = ext2_write_inode(&this->fCtx, newFileNode); if (!writeInodeRes) { mm_free_ptr(parentDirNode); mm_free_ptr(newFileNode); @@ -1304,8 +1298,8 @@ NodePtr Ext2FileSystemParser::Create(const char* path) { } // Add directory entry - auto addRes = - ext2_add_dir_entry(&this->ctx, parentDirNode, filename, newInodeNumber, kExt2FileTypeRegular); + auto addRes = ext2_add_dir_entry(&this->fCtx, parentDirNode, filename, newInodeNumber, + kExt2FileTypeRegular); if (!addRes) { mm_free_ptr(parentDirNode); mm_free_ptr(newFileNode); @@ -1313,7 +1307,7 @@ NodePtr Ext2FileSystemParser::Create(const char* path) { } // Update parent inode - auto parentWriteRes = ext2_write_inode(&this->ctx, parentDirNode); + auto parentWriteRes = ext2_write_inode(&this->fCtx, parentDirNode); // ignore failure NE_UNUSED(parentWriteRes); @@ -1360,7 +1354,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { // Open parent directory node NodePtr parentDirNodePtr = nullptr; if (currentPathLen == 0) { - auto inodeRes = ext2_load_inode(&this->ctx, EXT2_ROOT_INODE); + auto inodeRes = ext2_load_inode(&this->fCtx, EXT2_ROOT_INODE); if (!inodeRes) { return nullptr; } @@ -1390,7 +1384,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { } // Allocate inode - auto groupInfoResult = ext2_get_group_descriptor_info(&this->ctx, parentDirNode->inodeNumber); + auto groupInfoResult = ext2_get_group_descriptor_info(&this->fCtx, parentDirNode->inodeNumber); if (!groupInfoResult) { kout << "EXT2: Failed to get group descriptor info for new dir inode.\n"; mm_free_ptr(parentDirNode); @@ -1398,7 +1392,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { } auto groupInfo = *groupInfoResult.Leak(); - auto newInodeRes = ext2_alloc_inode(&this->ctx, groupInfo->groupDesc); + auto newInodeRes = ext2_alloc_inode(&this->fCtx, groupInfo->groupDesc); if (!newInodeRes) { kout << "EXT2: Failed to allocate inode for new directory.\n"; mm_free_ptr(reinterpret_cast<void*>(groupInfo->blockBuffer)); @@ -1410,8 +1404,8 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { UInt32 newInodeNumber = *newInodeRes.Leak(); // Write back group descriptor block - UInt32 gdtLba = ext2_block_to_lba(&this->ctx, groupInfo->groupDescriptorBlock); - if (!ext2_write_block(this->ctx.drive, gdtLba, groupInfo->blockBuffer, this->ctx.BlockSize())) { + UInt32 gdtLba = ext2_block_to_lba(&this->fCtx, groupInfo->groupDescriptorBlock); + if (!ext2_write_block(this->fCtx.drive, gdtLba, groupInfo->blockBuffer, this->fCtx.BlockSize())) { kout << "EXT2: Failed to write group descriptor after inode allocation.\n"; mm_free_ptr(reinterpret_cast<void*>(groupInfo->blockBuffer)); mm_free_ptr(groupInfo); @@ -1436,13 +1430,13 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { newDirNode->inode.fUID = 0; newDirNode->inode.fGID = 0; newDirNode->inode.fLinksCount = 2; // . and .. - newDirNode->inode.fSize = this->ctx.BlockSize(); + newDirNode->inode.fSize = this->fCtx.BlockSize(); newDirNode->inode.fBlocks = 1; newDirNode->inode.fCreateTime = 0; newDirNode->inode.fModifyTime = 0; // Allocate a data block for the new directory - auto groupForBlockRes = ext2_get_group_descriptor_info(&this->ctx, newDirNode->inodeNumber); + auto groupForBlockRes = ext2_get_group_descriptor_info(&this->fCtx, newDirNode->inodeNumber); if (!groupForBlockRes) { kout << "EXT2: Failed to get group info for directory block allocation.\n"; mm_free_ptr(parentDirNode); @@ -1451,7 +1445,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { } auto groupForBlock = *groupForBlockRes.Leak(); - auto newBlockRes = ext2_alloc_block(&this->ctx, groupForBlock->groupDesc); + auto newBlockRes = ext2_alloc_block(&this->fCtx, groupForBlock->groupDesc); if (!newBlockRes) { kout << "EXT2: Failed to allocate block for new directory contents.\n"; mm_free_ptr(reinterpret_cast<void*>(groupForBlock->blockBuffer)); @@ -1464,9 +1458,9 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { UInt32 newDirBlockNum = *newBlockRes.Leak(); // Write back GDT - UInt32 gdtLba2 = ext2_block_to_lba(&this->ctx, groupForBlock->groupDescriptorBlock); - if (!ext2_write_block(this->ctx.drive, gdtLba2, groupForBlock->blockBuffer, - this->ctx.BlockSize())) { + UInt32 gdtLba2 = ext2_block_to_lba(&this->fCtx, groupForBlock->groupDescriptorBlock); + if (!ext2_write_block(this->fCtx.drive, gdtLba2, groupForBlock->blockBuffer, + this->fCtx.BlockSize())) { kout << "EXT2: Failed to write GDT after directory block allocation.\n"; mm_free_ptr(reinterpret_cast<void*>(groupForBlock->blockBuffer)); mm_free_ptr(groupForBlock); @@ -1479,7 +1473,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { mm_free_ptr(groupForBlock); // Set the block in newDirNode - auto setBlkRes = ext2_set_block_address(&this->ctx, newDirNode, 0, newDirBlockNum); + auto setBlkRes = ext2_set_block_address(&this->fCtx, newDirNode, 0, newDirBlockNum); if (!setBlkRes) { kout << "EXT2: Failed to set data block for new directory.\n"; mm_free_ptr(parentDirNode); @@ -1488,7 +1482,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { } // Prepare block with '.' and '..' - auto dirBlockBuf = mm_alloc_ptr(this->ctx.BlockSize(), true, false); + auto dirBlockBuf = mm_alloc_ptr(this->fCtx.BlockSize(), true, false); if (!dirBlockBuf) { kout << "EXT2: Out of memory preparing directory block.\n"; mm_free_ptr(parentDirNode); @@ -1496,7 +1490,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { return nullptr; } - rt_zero_memory(dirBlockBuf, this->ctx.BlockSize()); + rt_zero_memory(dirBlockBuf, this->fCtx.BlockSize()); // '.' entry auto dot = reinterpret_cast<EXT2_DIR_ENTRY*>(dirBlockBuf); @@ -1511,13 +1505,13 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { dotdot->fInode = parentDirNode->inodeNumber; dotdot->fNameLength = 2; dotdot->fFileType = kExt2FileTypeDirectory; - dotdot->fRecordLength = static_cast<UInt16>(this->ctx.BlockSize() - dot->fRecordLength); + dotdot->fRecordLength = static_cast<UInt16>(this->fCtx.BlockSize() - dot->fRecordLength); dotdot->fName[0] = '.'; dotdot->fName[1] = '.'; // Write dir block to disk - UInt32 newDirBlockLba = ext2_block_to_lba(&this->ctx, newDirBlockNum); - if (!ext2_write_block(this->ctx.drive, newDirBlockLba, dirBlockBuf, this->ctx.BlockSize())) { + UInt32 newDirBlockLba = ext2_block_to_lba(&this->fCtx, newDirBlockNum); + if (!ext2_write_block(this->fCtx.drive, newDirBlockLba, dirBlockBuf, this->fCtx.BlockSize())) { kout << "EXT2: Failed to write directory block to disk.\n"; mm_free_ptr(dirBlockBuf); mm_free_ptr(parentDirNode); @@ -1528,7 +1522,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { mm_free_ptr(dirBlockBuf); // Persist new directory inode - auto writeInodeRes = ext2_write_inode(&this->ctx, newDirNode); + auto writeInodeRes = ext2_write_inode(&this->fCtx, newDirNode); if (!writeInodeRes) { kout << "EXT2: Failed to write new directory inode to disk.\n"; mm_free_ptr(parentDirNode); @@ -1537,7 +1531,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { } // Add directory entry into parent - auto addRes = ext2_add_dir_entry(&this->ctx, parentDirNode, dirname, newInodeNumber, + auto addRes = ext2_add_dir_entry(&this->fCtx, parentDirNode, dirname, newInodeNumber, kExt2FileTypeDirectory); if (!addRes) { kout << "EXT2: Failed to add directory entry for '" << dirname << "' to parent.\n"; @@ -1548,7 +1542,7 @@ NodePtr Ext2FileSystemParser::CreateDirectory(const char* path) { // Increment parent link count and persist parent inode parentDirNode->inode.fLinksCount += 1; - auto parentWriteRes = ext2_write_inode(&this->ctx, parentDirNode); + auto parentWriteRes = ext2_write_inode(&this->fCtx, parentDirNode); if (!parentWriteRes) { kout << "EXT2: Warning: failed to update parent inode after directory creation.\n"; } diff --git a/dev/kernel/src/FS/HeFS+FileMgr.cc b/dev/kernel/src/FS/HeFS+FileMgr.cc deleted file mode 100644 index e4985a3b..00000000 --- a/dev/kernel/src/FS/HeFS+FileMgr.cc +++ /dev/null @@ -1,14 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. - -------------------------------------------- */ - -#ifndef __NE_MINIMAL_OS__ -#ifdef __FSKIT_INCLUDES_HEFS__ - -#include <KernelKit/FileMgr.h> -#include <KernelKit/HeapMgr.h> - -#endif // ifdef __FSKIT_INCLUDES_HEFS__ -#endif // ifndef __NE_MINIMAL_OS__ diff --git a/dev/kernel/src/FS/NeFS+FileSystemParser.cc b/dev/kernel/src/FS/NeFS+FileSystemParser.cc index 14e0b974..b50841a4 100644 --- a/dev/kernel/src/FS/NeFS+FileSystemParser.cc +++ b/dev/kernel/src/FS/NeFS+FileSystemParser.cc @@ -74,7 +74,7 @@ static inline bool is_valid_lba(Lba lba, DriveTrait& drive) { return (lba >= part_block.StartCatalog) && (lba < maxLba); } -STATIC MountpointInterface kMountpoint; +STATIC IMountpoint kMountpoint; /***********************************************************************************/ /// @brief Creates a new fork inside the New filesystem partition. /// @param catalog it's catalog @@ -141,7 +141,7 @@ _Output BOOL NeFileSystemParser::CreateFork(_Input NEFS_FORK_STRUCT& the_fork) { drv.fPacket.fPacketContent = reinterpret_cast<VoidPtr>(&the_fork); drv.fOutput(drv.fPacket); - fs_ifs_write(&kMountpoint, drv, MountpointInterface::kDriveIndexA); + fs_ifs_write(&kMountpoint, drv, IMountpoint::kDriveIndexA); delete catalog; return YES; @@ -858,7 +858,7 @@ namespace Kernel::NeFS { /// @brief Construct NeFS drives. /***********************************************************************************/ Boolean fs_init_nefs(Void) noexcept { - kout << "Creating HeFS disk...\r"; + kout << "Creating OpenHeFS disk...\r"; kMountpoint.A() = io_construct_main_drive(); if (kMountpoint.A().fPacket.fPacketReadOnly == YES) ke_panic(RUNTIME_CHECK_FILESYSTEM, "Main disk cannot be mounted."); diff --git a/dev/kernel/src/FS/OpenHeFS+FileMgr.cc b/dev/kernel/src/FS/OpenHeFS+FileMgr.cc new file mode 100644 index 00000000..bb87fd67 --- /dev/null +++ b/dev/kernel/src/FS/OpenHeFS+FileMgr.cc @@ -0,0 +1,191 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#ifndef __NE_MINIMAL_OS__ +#ifdef __FSKIT_INCLUDES_HEFS__ + +#include <KernelKit/FileMgr.h> +#include <KernelKit/HeapMgr.h> + +/// @brief OpenHeFS File System Manager. +/// BUGS: 0 + +namespace Kernel { +/// @brief C++ constructor +HeFileSystemMgr::HeFileSystemMgr() { + mParser = new HeFileSystemParser(); + MUST_PASS(mParser); + + kout << "We are done allocating HeFileSystemParser...\n"; +} + +HeFileSystemMgr::~HeFileSystemMgr() { + if (mParser) { + kout << "Destroying HeFileSystemParser...\n"; + delete mParser; + mParser = nullptr; + } +} + +/// @brief Removes a node from the filesystem. +/// @param path The filename +/// @return If it was deleted or not. +bool HeFileSystemMgr::Remove(_Input const Char* path) { + if (path == nullptr || *path == 0) { + kout << "OpenHeFS: Remove called with null or empty path\n"; + return false; + } + + return NO; +} + +/// @brief Creates a node with the specified. +/// @param path The filename path. +/// @return The Node pointer. +NodePtr HeFileSystemMgr::Create(_Input const Char* path) { + if (!path || *path == 0) { + kout << "OpenHeFS: Create called with null or empty path\n"; + return nullptr; + } + return nullptr; +} + +/// @brief Creates a node which is a directory. +/// @param path The filename path. +/// @return The Node pointer. +NodePtr HeFileSystemMgr::CreateDirectory(const Char* path) { + if (!path || *path == 0) { + kout << "OpenHeFS: CreateDirectory called with null or empty path\n"; + return nullptr; + } + return nullptr; +} + +/// @brief Creates a node which is an alias. +/// @param path The filename path. +/// @return The Node pointer. +NodePtr HeFileSystemMgr::CreateAlias(const Char* path) { + if (!path || *path == 0) { + kout << "OpenHeFS: CreateAlias called with null or empty path\n"; + return nullptr; + } + return nullptr; +} + +NodePtr HeFileSystemMgr::CreateSwapFile(const Char* path) { + if (!path || *path == 0) { + kout << "OpenHeFS: CreateSwapFile called with null or empty path\n"; + return nullptr; + } + return nullptr; +} + +/// @brief Gets the root directory. +/// @return +const Char* NeFileSystemHelper::Root() { + return kHeFSRootDirectory; +} + +/// @brief Gets the up-dir directory. +/// @return +const Char* NeFileSystemHelper::UpDir() { + return kHeFSUpDir; +} + +/// @brief Gets the separator character. +/// @return +Char NeFileSystemHelper::Separator() { + return kHeFSSeparator; +} + +/// @brief Gets the metafile character. +/// @return +Char NeFileSystemHelper::MetaFile() { + return '\0'; +} + +/// @brief Opens a new file. +/// @param path +/// @param r +/// @return +_Output NodePtr HeFileSystemMgr::Open(_Input const Char* path, _Input const Char* r) { + if (!path || *path == 0) { + kout << "OpenHeFS: Open called with null or empty path\n"; + return nullptr; + } + if (!r || *r == 0) { + kout << "OpenHeFS: Open called with null or empty mode string\n"; + return nullptr; + } + return nullptr; +} + +Void HeFileSystemMgr::Write(_Input NodePtr node, _Input VoidPtr data, _Input Int32 flags, + _Input SizeT size) { + NE_UNUSED(node); + NE_UNUSED(flags); + NE_UNUSED(size); + NE_UNUSED(data); +} + +_Output VoidPtr HeFileSystemMgr::Read(_Input NodePtr node, _Input Int32 flags, _Input SizeT size) { + NE_UNUSED(node); + NE_UNUSED(flags); + NE_UNUSED(size); + + return nullptr; +} + +Void HeFileSystemMgr::Write(_Input const Char* name, _Input NodePtr node, _Input VoidPtr data, + _Input Int32 flags, _Input SizeT size) { + NE_UNUSED(node); + NE_UNUSED(flags); + NE_UNUSED(size); + NE_UNUSED(name); + NE_UNUSED(data); +} + +_Output VoidPtr HeFileSystemMgr::Read(_Input const Char* name, _Input NodePtr node, + _Input Int32 flags, _Input SizeT sz) { + NE_UNUSED(node); + NE_UNUSED(flags); + NE_UNUSED(sz); + NE_UNUSED(name); + + return nullptr; +} + +_Output Bool HeFileSystemMgr::Seek(NodePtr node, SizeT off) { + NE_UNUSED(node); + NE_UNUSED(off); + + return false; +} + +/// @brief Tell current offset within catalog. +/// @param node +/// @return kFileMgrNPos if invalid, else current offset. +_Output SizeT HeFileSystemMgr::Tell(NodePtr node) { + NE_UNUSED(node); + return kFileMgrNPos; +} + +/// @brief Rewinds the catalog +/// @param node +/// @return False if invalid, nah? calls Seek(node, 0). +_Output Bool HeFileSystemMgr::Rewind(NodePtr node) { + NE_UNUSED(node); + return kFileMgrNPos; +} + +/// @brief Returns the parser of OpenHeFS. +_Output HeFileSystemParser* HeFileSystemMgr::GetParser() noexcept { + return mParser; +} +} // namespace Kernel + +#endif // ifdef __FSKIT_INCLUDES_HEFS__ +#endif // ifndef __NE_MINIMAL_OS__ diff --git a/dev/kernel/src/FS/HeFS+FileSystemParser.cc b/dev/kernel/src/FS/OpenHeFS+FileSystemParser.cc index 86f929c0..3746ebc1 100644 --- a/dev/kernel/src/FS/HeFS+FileSystemParser.cc +++ b/dev/kernel/src/FS/OpenHeFS+FileSystemParser.cc @@ -6,7 +6,7 @@ #ifdef __FSKIT_INCLUDES_HEFS__ -#include <FSKit/HeFS.h> +#include <FSKit/OpenHeFS.h> #include <FirmwareKit/EPM.h> #include <FirmwareKit/GPT.h> #include <KernelKit/KPC.h> @@ -79,12 +79,14 @@ namespace Detail { const Utf8Char* dir_name, UInt16 flags, const BOOL delete_or_create); + /// @brief This helper makes it easier for other machines to understand OpenHeFS encoded hashes. STATIC UInt64 hefsi_to_big_endian_64(UInt64 val) { return ((val >> 56) & 0x00000000000000FFULL) | ((val >> 40) & 0x000000000000FF00ULL) | ((val >> 24) & 0x0000000000FF0000ULL) | ((val >> 8) & 0x00000000FF000000ULL) | ((val << 8) & 0x000000FF00000000ULL) | ((val << 24) & 0x0000FF0000000000ULL) | ((val << 40) & 0x00FF000000000000ULL) | ((val << 56) & 0xFF00000000000000ULL); } + /// @brief Simple algorithm to hash directory entries for INDs. /// @param path the directory path. /// @return The hashed path. @@ -741,12 +743,12 @@ namespace Detail { } // namespace Detail } // namespace Kernel -/// @note HeFS will allocate inodes and ind in advance, to avoid having to allocate them in +/// @note OpenHeFS will allocate inodes and ind in advance, to avoid having to allocate them in /// real-time. /// @note This is certainly take longer to format a disk with it, but worth-it in the long run. namespace Kernel { -/// @brief Make a EPM+HeFS mnt out of the disk. +/// @brief Make a EPM+OpenHeFS mnt out of the disk. /// @param mnt The mnt to write on. /// @return If it was sucessful, see err_local_get(). _Output Bool HeFileSystemParser::Format(_Input _Output DriveTrait* mnt, _Input const Int32 flags, @@ -764,7 +766,7 @@ _Output Bool HeFileSystemParser::Format(_Input _Output DriveTrait* mnt, _Input c (Void)(kout << "OpenHeFS recommends at least 128 GiB of free space." << kendl); (Void)( kout - << "The OS will still try to format a HeFS disk here anyway, don't expect perfect geometry." + << "The OS will still try to format a OpenHeFS disk here anyway, don't expect perfect geometry." << kendl); } @@ -820,7 +822,7 @@ _Output Bool HeFileSystemParser::Format(_Input _Output DriveTrait* mnt, _Input c MUST_PASS(boot->fSectorSize); - /// @note all HeFS strucutres are equal to 512, so here it's fine, unless fSectoSize is 2048. + /// @note all OpenHeFS strucutres are equal to 512, so here it's fine, unless fSectoSize is 2048. const SizeT max_lba = (drv_std_get_size()) / boot->fSectorSize; const SizeT dir_max = max_lba / 300; // 5% for directory inodes @@ -1005,7 +1007,7 @@ _Output Bool HeFileSystemParser::INodeManip(_Input DriveTrait* mnt, VoidPtr bloc mnt->fInput(mnt->fPacket); if (!KStringBuilder::Equals(boot->fMagic, kHeFSMagic) || boot->fVersion != kHeFSVersion) { - (Void)(kout << "Invalid Boot Node, HeFS partition is invalid." << kendl); + (Void)(kout << "Invalid Boot Node, OpenHeFS partition is invalid." << kendl); mm_free_ptr((VoidPtr) boot); err_global_get() = kErrorDisk; return NO; @@ -1145,9 +1147,9 @@ _Output Bool HeFileSystemParser::INodeCtlManip(_Input DriveTrait* mnt, _Input co STATIC DriveTrait kMountPoint; -/// @brief Initialize the HeFS filesystem. +/// @brief Initialize the OpenHeFS filesystem. /// @return To check its status, see err_local_get(). -Boolean HeFS::fs_init_hefs(Void) noexcept { +Boolean OpenHeFS::fs_init_hefs(Void) noexcept { kout << "Verifying disk...\r"; kMountPoint = io_construct_main_drive(); diff --git a/dev/kernel/src/GUIDWizard.cc b/dev/kernel/src/GUIDWizard.cc index 46915ace..b36fffc2 100644 --- a/dev/kernel/src/GUIDWizard.cc +++ b/dev/kernel/src/GUIDWizard.cc @@ -17,13 +17,15 @@ // @brief Size of UUID. #define kUUIDSize 37 -namespace CF::XRN::Version1 { +namespace Kernel::CF::XRN::Version1 { auto cf_make_sequence(const ArrayList<UInt32>& uuidSeq) -> Ref<GUIDSequence*> { GUIDSequence* seq = new GUIDSequence(); MUST_PASS(seq); Ref<GUIDSequence*> seq_ref{seq}; + if (!seq) return seq_ref; + seq_ref.Leak()->fUuid.fMs1 = uuidSeq[0]; seq_ref.Leak()->fUuid.fMs2 = uuidSeq[1]; seq_ref.Leak()->fUuid.fMs3 = uuidSeq[2]; @@ -60,6 +62,6 @@ auto cf_try_guid_to_string(Ref<GUIDSequence*>& seq) -> ErrorOr<Ref<KString>> { if (view) return ErrorOr<Ref<KString>>{view.Leak()}; - return ErrorOr<Ref<KString>>{-1}; + return ErrorOr<Ref<KString>>{kErrorInvalidData}; } -} // namespace CF::XRN::Version1 +} // namespace Kernel::CF::XRN::Version1 diff --git a/dev/kernel/src/GUIDWrapper.cc b/dev/kernel/src/GUIDWrapper.cc index f87a1bdd..d5ab6bb8 100644 --- a/dev/kernel/src/GUIDWrapper.cc +++ b/dev/kernel/src/GUIDWrapper.cc @@ -6,4 +6,4 @@ #include <CFKit/GUIDWrapper.h> -namespace CF::XRN {} +namespace Kernel::CF::XRN {} diff --git a/dev/kernel/src/HardwareThreadScheduler.cc b/dev/kernel/src/HardwareThreadScheduler.cc index 86f46718..a4b6b4b8 100644 --- a/dev/kernel/src/HardwareThreadScheduler.cc +++ b/dev/kernel/src/HardwareThreadScheduler.cc @@ -134,7 +134,7 @@ HardwareThreadScheduler& HardwareThreadScheduler::The() { /// @brief Get Stack Frame of AP. /***********************************************************************************/ HAL::StackFramePtr HardwareThreadScheduler::Leak() noexcept { - return fThreadList[fCurrentThread].fStack; + return fThreadList[fCurrentThreadIdx].fStack; } /***********************************************************************************/ @@ -150,6 +150,7 @@ Ref<HardwareThread*> HardwareThreadScheduler::operator[](SizeT idx) { return {kFakeThread}; } + fCurrentThreadIdx = idx; return &fThreadList[idx]; } diff --git a/dev/kernel/src/IFS.cc b/dev/kernel/src/IFS.cc index ba2ec8c0..ffb8ef8e 100644 --- a/dev/kernel/src/IFS.cc +++ b/dev/kernel/src/IFS.cc @@ -28,25 +28,25 @@ namespace Kernel { /// @param DrvTrait drive info /// @param DrvIndex drive index. /// @return -Int32 fs_ifs_read(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex) { +Int32 fs_ifs_read(IMountpoint* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex) { if (!Mnt) return kErrorDisk; DrvTrait.fPacket.fPacketGood = false; switch (DrvIndex) { - case MountpointInterface::kDriveIndexA: { + case IMountpoint::kDriveIndexA: { fsi_ifs_read(A, DrvTrait.fPacket, Mnt); break; } - case MountpointInterface::kDriveIndexB: { + case IMountpoint::kDriveIndexB: { fsi_ifs_read(B, DrvTrait.fPacket, Mnt); break; } - case MountpointInterface::kDriveIndexC: { + case IMountpoint::kDriveIndexC: { fsi_ifs_read(C, DrvTrait.fPacket, Mnt); break; } - case MountpointInterface::kDriveIndexD: { + case IMountpoint::kDriveIndexD: { fsi_ifs_read(D, DrvTrait.fPacket, Mnt); break; } @@ -60,25 +60,25 @@ Int32 fs_ifs_read(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex /// @param DrvTrait drive info /// @param DrvIndex drive index. /// @return -Int32 fs_ifs_write(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex) { +Int32 fs_ifs_write(IMountpoint* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex) { if (!Mnt) return kErrorDisk; DrvTrait.fPacket.fPacketGood = false; switch (DrvIndex) { - case MountpointInterface::kDriveIndexA: { + case IMountpoint::kDriveIndexA: { fsi_ifs_write(A, DrvTrait.fPacket, Mnt); break; } - case MountpointInterface::kDriveIndexB: { + case IMountpoint::kDriveIndexB: { fsi_ifs_write(B, DrvTrait.fPacket, Mnt); break; } - case MountpointInterface::kDriveIndexC: { + case IMountpoint::kDriveIndexC: { fsi_ifs_write(C, DrvTrait.fPacket, Mnt); break; } - case MountpointInterface::kDriveIndexD: { + case IMountpoint::kDriveIndexD: { fsi_ifs_write(D, DrvTrait.fPacket, Mnt); break; } diff --git a/dev/kernel/src/IPEFDylibObject.cc b/dev/kernel/src/IPEFDylibObject.cc index a24fba72..91f8c88a 100644 --- a/dev/kernel/src/IPEFDylibObject.cc +++ b/dev/kernel/src/IPEFDylibObject.cc @@ -90,6 +90,10 @@ EXTERN_C IDylibRef rtl_init_dylib_pef(USER_PROCESS& process) { EXTERN_C Void rtl_fini_dylib_pef(USER_PROCESS& process, IDylibRef dll_obj, BOOL* successful) { MUST_PASS(successful); + if (!successful) { + return; + } + // sanity check (will also trigger a bug check if this fails) if (dll_obj == nullptr) { *successful = false; diff --git a/dev/kernel/src/IndexableProperty.cc b/dev/kernel/src/IndexableProperty.cc index c11e328d..56143607 100644 --- a/dev/kernel/src/IndexableProperty.cc +++ b/dev/kernel/src/IndexableProperty.cc @@ -22,7 +22,7 @@ namespace Indexer { Void IndexableProperty::AddFlag(Int16 flag) { fFlags |= flag; } - Void IndexableProperty::RemoveFlag(Int16 flag) { fFlags &= flag; } + Void IndexableProperty::RemoveFlag(Int16 flag) { fFlags &= ~(flag); } Int16 IndexableProperty::HasFlag(Int16 flag) { return fFlags & flag; } @@ -33,6 +33,7 @@ namespace Indexer { /// @return none, check before if indexer can be claimed (using indexer.HasFlag(kIndexerClaimed)). Void fs_index_file(const Char* filename, SizeT filenameLen, IndexableProperty& indexer) { if (!indexer.HasFlag(kIndexerClaimed)) { + indexer.RemoveFlag(kIndexerUnclaimed); indexer.AddFlag(kIndexerClaimed); rt_copy_memory_safe(reinterpret_cast<VoidPtr>(const_cast<Char*>(filename)), (VoidPtr) indexer.Leak().Path, filenameLen, kIndexerCatalogNameLength); diff --git a/dev/kernel/src/Json.cc b/dev/kernel/src/Json.cc index 68ab55fc..d156c0ce 100644 --- a/dev/kernel/src/Json.cc +++ b/dev/kernel/src/Json.cc @@ -7,4 +7,4 @@ #include <NeKit/Json.h> /// @brief Undefined object, is null in length. -RTL_INIT_OBJECT(Kernel::Json::kNull, Kernel::Json); +RTL_INIT_OBJECT(Kernel::JsonObject::kNull, Kernel::JsonObject); diff --git a/dev/kernel/src/KernelTaskScheduler.cc b/dev/kernel/src/KernelTaskScheduler.cc index 1997c175..8bbe5601 100644 --- a/dev/kernel/src/KernelTaskScheduler.cc +++ b/dev/kernel/src/KernelTaskScheduler.cc @@ -15,4 +15,17 @@ /// @author Amlal El Mahrouss (amlal@nekernel.org) /***********************************************************************************/ -namespace Kernel {} // namespace Kernel
\ No newline at end of file +namespace Kernel { +EXTERN_C Void hal_switch_kernel_task(HAL::StackFramePtr frame, ProcessID kid); + +Bool KernelTaskHelper::Switch(HAL::StackFramePtr frame_ptr, ProcessID new_kid) { + NE_UNUSED(frame_ptr); + NE_UNUSED(new_kid); + + return NO; +} + +Bool KernelTaskHelper::CanBeScheduled(const KERNEL_TASK& task) { + return task.Kid > 0 && task.Image.HasCode(); +} +} // namespace Kernel
\ No newline at end of file diff --git a/dev/kernel/src/Network/IPAddress.cc b/dev/kernel/src/Network/IPAddress.cc index b02eae08..bc46292b 100644 --- a/dev/kernel/src/Network/IPAddress.cc +++ b/dev/kernel/src/Network/IPAddress.cc @@ -73,14 +73,14 @@ bool RawIPAddress6::operator!=(const RawIPAddress6& ipv6) { /// @todo ErrorOr<KString> IPFactory::ToKString(Ref<RawIPAddress6>& ipv6) { NE_UNUSED(ipv6); - auto str = KStringBuilder::Construct(0); + auto str = KStringBuilder::Construct(""); return str; } /// @todo ErrorOr<KString> IPFactory::ToKString(Ref<RawIPAddress>& ipv4) { NE_UNUSED(ipv4); - auto str = KStringBuilder::Construct(0); + auto str = KStringBuilder::Construct(""); return str; } diff --git a/dev/kernel/src/Network/NetworkDevice.cc b/dev/kernel/src/Network/NetworkDevice.cc index 7f93fa1b..ffdfa53b 100644 --- a/dev/kernel/src/Network/NetworkDevice.cc +++ b/dev/kernel/src/Network/NetworkDevice.cc @@ -11,7 +11,7 @@ namespace Kernel { /// \brief Getter for fNetworkName. /// \return Network device name. const Char* NetworkDevice::Name() const { - return "/devices/net{}"; + return "/devices/net/net{}"; } /// \brief Setter for fNetworkName. diff --git a/dev/kernel/src/PEFCodeMgr.cc b/dev/kernel/src/PEFCodeMgr.cc index c0caeb5b..a0d0a6af 100644 --- a/dev/kernel/src/PEFCodeMgr.cc +++ b/dev/kernel/src/PEFCodeMgr.cc @@ -53,7 +53,37 @@ namespace Detail { /***********************************************************************************/ PEFLoader::PEFLoader(const VoidPtr blob) : fCachedBlob(blob) { MUST_PASS(fCachedBlob); - fBad = false; + + if (!fCachedBlob) { + this->fBad = YES; + return; + } + + PEFContainer* container = reinterpret_cast<PEFContainer*>(fCachedBlob); + + if (container->Abi == kPefAbi && + container->Count >= + 3) { /* if same ABI, AND: .text, .bss, .data (or at least similar) exists */ + if (container->Cpu == Detail::ldr_get_platform() && container->Magic[0] == kPefMagic[0] && + container->Magic[1] == kPefMagic[1] && container->Magic[2] == kPefMagic[2] && + container->Magic[3] == kPefMagic[3] && container->Magic[4] == kPefMagic[4]) { + return; + } else if (container->Magic[0] == kPefMagicFat[0] && container->Magic[1] == kPefMagicFat[1] && + container->Magic[2] == kPefMagicFat[2] && container->Magic[3] == kPefMagicFat[3] && + container->Magic[4] == kPefMagicFat[4]) { + /// This is a fat binary. Treat it as such. + this->fFatBinary = YES; + return; + } + } + + kout << "PEFLoader: warning: Binary format error!\r"; + + this->fFatBinary = NO; + this->fBad = YES; + + if (this->fCachedBlob) mm_free_ptr(this->fCachedBlob); + this->fCachedBlob = nullptr; } /***********************************************************************************/ @@ -69,6 +99,11 @@ PEFLoader::PEFLoader(const Char* path) : fCachedBlob(nullptr), fFatBinary(false) /// @note zero here means that the FileMgr will read every container header inside the file. fCachedBlob = fFile->Read(kPefHeader, 0UL); + if (!fCachedBlob) { + this->fBad = YES; + return; + } + PEFContainer* container = reinterpret_cast<PEFContainer*>(fCachedBlob); if (container->Abi == kPefAbi && @@ -82,18 +117,18 @@ PEFLoader::PEFLoader(const Char* path) : fCachedBlob(nullptr), fFatBinary(false) container->Magic[2] == kPefMagicFat[2] && container->Magic[3] == kPefMagicFat[3] && container->Magic[4] == kPefMagicFat[4]) { /// This is a fat binary, treat it as such. - this->fFatBinary = true; + this->fFatBinary = YES; return; } } - fBad = true; + kout << "PEFLoader: warning: Binary format error!\r"; - if (fCachedBlob) mm_free_ptr(fCachedBlob); - - kout << "PEFLoader: warning: exec format error!\r"; + this->fFatBinary = NO; + this->fBad = YES; - fCachedBlob = nullptr; + if (this->fCachedBlob) mm_free_ptr(this->fCachedBlob); + this->fCachedBlob = nullptr; } /***********************************************************************************/ @@ -127,9 +162,8 @@ ErrorOr<VoidPtr> PEFLoader::FindSymbol(const Char* name, Int32 kind) { return ErrorOr<VoidPtr>{kErrorInvalidData}; /// fat binary check. - if (command_header->Cpu != container->Cpu && !this->fFatBinary) { + if (command_header->Cpu != container->Cpu && !this->fFatBinary) return ErrorOr<VoidPtr>{kErrorInvalidData}; - } const auto kMangleCharacter = '$'; const Char* kContainerKinds[] = {".code64", ".data64", ".zero64", nullptr}; @@ -183,7 +217,7 @@ ErrorOr<VoidPtr> PEFLoader::FindSymbol(const Char* name, Int32 kind) { mm_free_ptr(blob); - kout << "PEFLoader: info: Loaded stub: " << command_header->Name << "!\r"; + kout << "PEFLoader: info: Load stub: " << command_header->Name << "!\r"; Int32 ret = 0; SizeT pages_count = (command_header->VMSize + kPageSize - 1) / kPageSize; diff --git a/dev/kernel/src/Property.cc b/dev/kernel/src/Property.cc index 581da501..714fb2a4 100644 --- a/dev/kernel/src/Property.cc +++ b/dev/kernel/src/Property.cc @@ -6,7 +6,7 @@ #include <CFKit/Property.h> -namespace CF { +namespace Kernel::CF { /***********************************************************************************/ /// @brief Destructor. /***********************************************************************************/ @@ -21,14 +21,14 @@ Property::Property() = default; /// @brief Check if property's name equals to name. /// @param name string to check. /***********************************************************************************/ -Bool Property::StringEquals(BasicKString<>& name) { +Bool Property::StringEquals(KBasicString<>& name) { return this->fName && this->fName == name; } /***********************************************************************************/ /// @brief Gets the key (name) of property. /***********************************************************************************/ -BasicKString<>& Property::GetKey() { +KBasicString<>& Property::GetKey() { return this->fName; } @@ -38,4 +38,4 @@ BasicKString<>& Property::GetKey() { PropertyId& Property::GetValue() { return fValue; } -} // namespace CF +} // namespace Kernel::CF diff --git a/dev/kernel/src/Storage/AHCIDeviceInterface.cc b/dev/kernel/src/Storage/AHCIDeviceInterface.cc index 39570665..6dcfed69 100644 --- a/dev/kernel/src/Storage/AHCIDeviceInterface.cc +++ b/dev/kernel/src/Storage/AHCIDeviceInterface.cc @@ -13,9 +13,9 @@ using namespace Kernel; /// @param In Drive input /// @param Cleanup Drive cleanup. AHCIDeviceInterface::AHCIDeviceInterface(void (*out)(DeviceInterface* self, - MountpointInterface* outpacket), + IMountpoint* outpacket), void (*in)(DeviceInterface* self, - MountpointInterface* inpacket)) + IMountpoint* inpacket)) : DeviceInterface(out, in) {} /// @brief Class desctructor @@ -30,7 +30,7 @@ const Char* AHCIDeviceInterface::Name() const { /// @brief Output operator. /// @param mnt the disk mountpoint. /// @return the class itself after operation. -AHCIDeviceInterface& AHCIDeviceInterface::operator<<(MountpointInterface* mnt) { +AHCIDeviceInterface& AHCIDeviceInterface::operator<<(IMountpoint* mnt) { if (!mnt) return *this; for (SizeT driveCount = 0; driveCount < kDriveMaxCount; ++driveCount) { @@ -45,13 +45,13 @@ AHCIDeviceInterface& AHCIDeviceInterface::operator<<(MountpointInterface* mnt) { } } - return (AHCIDeviceInterface&) DeviceInterface<MountpointInterface*>::operator<<(mnt); + return (AHCIDeviceInterface&) DeviceInterface<IMountpoint*>::operator<<(mnt); } /// @brief Input operator. /// @param mnt the disk mountpoint. /// @return the class itself after operation. -AHCIDeviceInterface& AHCIDeviceInterface::operator>>(MountpointInterface* mnt) { +AHCIDeviceInterface& AHCIDeviceInterface::operator>>(IMountpoint* mnt) { if (!mnt) return *this; for (SizeT driveCount = 0; driveCount < kDriveMaxCount; ++driveCount) { @@ -67,7 +67,7 @@ AHCIDeviceInterface& AHCIDeviceInterface::operator>>(MountpointInterface* mnt) { } } - return (AHCIDeviceInterface&) DeviceInterface<MountpointInterface*>::operator>>(mnt); + return (AHCIDeviceInterface&) DeviceInterface<IMountpoint*>::operator>>(mnt); } const UInt16& AHCIDeviceInterface::GetPortsImplemented() { @@ -84,6 +84,6 @@ const UInt32& AHCIDeviceInterface::GetIndex() { } Void AHCIDeviceInterface::SetIndex(const UInt32& drv) { - MUST_PASS(MountpointInterface::kDriveIndexInvalid != drv); + MUST_PASS(IMountpoint::kDriveIndexInvalid < drv); this->fDriveIndex = drv; }
\ No newline at end of file diff --git a/dev/kernel/src/Storage/ATADeviceInterface.cc b/dev/kernel/src/Storage/ATADeviceInterface.cc index 609837af..70d6e9ae 100644 --- a/dev/kernel/src/Storage/ATADeviceInterface.cc +++ b/dev/kernel/src/Storage/ATADeviceInterface.cc @@ -13,8 +13,8 @@ using namespace Kernel; /// @param In Drive input /// @param Cleanup Drive cleanup. ATADeviceInterface::ATADeviceInterface(void (*Out)(DeviceInterface*, - MountpointInterface* outpacket), - void (*In)(DeviceInterface*, MountpointInterface* inpacket)) + IMountpoint* outpacket), + void (*In)(DeviceInterface*, IMountpoint* inpacket)) : DeviceInterface(Out, In) {} /// @brief Class desctructor @@ -29,7 +29,7 @@ const Char* ATADeviceInterface::Name() const { /// @brief Output operator. /// @param Data the disk mountpoint. /// @return the class itself after operation. -ATADeviceInterface& ATADeviceInterface::operator<<(MountpointInterface* Data) { +ATADeviceInterface& ATADeviceInterface::operator<<(IMountpoint* Data) { if (!Data) return *this; for (SizeT driveCount = 0; driveCount < kDriveMaxCount; ++driveCount) { @@ -44,13 +44,13 @@ ATADeviceInterface& ATADeviceInterface::operator<<(MountpointInterface* Data) { } } - return (ATADeviceInterface&) DeviceInterface<MountpointInterface*>::operator<<(Data); + return (ATADeviceInterface&) DeviceInterface<IMountpoint*>::operator<<(Data); } /// @brief Input operator. /// @param Data the disk mountpoint. /// @return the class itself after operation. -ATADeviceInterface& ATADeviceInterface::operator>>(MountpointInterface* Data) { +ATADeviceInterface& ATADeviceInterface::operator>>(IMountpoint* Data) { if (!Data) return *this; for (SizeT driveCount = 0; driveCount < kDriveMaxCount; ++driveCount) { @@ -66,7 +66,7 @@ ATADeviceInterface& ATADeviceInterface::operator>>(MountpointInterface* Data) { } } - return (ATADeviceInterface&) DeviceInterface<MountpointInterface*>::operator>>(Data); + return (ATADeviceInterface&) DeviceInterface<IMountpoint*>::operator>>(Data); } const UInt32& ATADeviceInterface::GetIndex() { @@ -74,7 +74,7 @@ const UInt32& ATADeviceInterface::GetIndex() { } Void ATADeviceInterface::SetIndex(const UInt32& drv) { - MUST_PASS(MountpointInterface::kDriveIndexInvalid != drv); + MUST_PASS(IMountpoint::kDriveIndexInvalid < drv); this->fDriveIndex = drv; } diff --git a/dev/kernel/src/Storage/NVMEDeviceInterface.cc b/dev/kernel/src/Storage/NVMEDeviceInterface.cc index 077595cf..0b8043b7 100644 --- a/dev/kernel/src/Storage/NVMEDeviceInterface.cc +++ b/dev/kernel/src/Storage/NVMEDeviceInterface.cc @@ -8,8 +8,8 @@ namespace Kernel { NVMEDeviceInterface::NVMEDeviceInterface( - void (*out)(DeviceInterface*, MountpointInterface* outpacket), - void (*in)(DeviceInterface*, MountpointInterface* inpacket), void (*cleanup)(void)) + void (*out)(DeviceInterface*, IMountpoint* outpacket), + void (*in)(DeviceInterface*, IMountpoint* inpacket), void (*cleanup)(void)) : DeviceInterface(out, in), fCleanup(cleanup) {} NVMEDeviceInterface::~NVMEDeviceInterface() { diff --git a/dev/kernel/src/Swap/DiskSwap.cc b/dev/kernel/src/Swap/DiskSwap.cc index 8578450c..99efb2c0 100644 --- a/dev/kernel/src/Swap/DiskSwap.cc +++ b/dev/kernel/src/Swap/DiskSwap.cc @@ -8,6 +8,8 @@ #include <SwapKit/DiskSwap.h> namespace Kernel { +static constexpr UInt32 kSwapDiskHeaderMagic = 0x44535750; // 'DSWP' + /***********************************************************************************/ /// @brief Write memory chunk onto disk. /// @param fork_name The swap name to recognize this memory region. @@ -20,7 +22,7 @@ BOOL DiskSwapInterface::Write(const Char* fork_name, SizeT fork_name_len, SWAP_D if (*fork_name == 0) return NO; - if (!data) return NO; + if (!data || data->fMagic != kSwapDiskHeaderMagic) return NO; FileStream file(kSwapPageFilePath, kRestrictWRB); @@ -52,6 +54,11 @@ SWAP_DISK_HEADER* DiskSwapInterface::Read(const Char* fork_name, SizeT fork_name VoidPtr blob = file.Read(fork_name, sizeof(SWAP_DISK_HEADER) + data_len); + if (!blob || ((SWAP_DISK_HEADER*) blob)->fMagic != kSwapDiskHeaderMagic) { + if (blob) mm_free_ptr(blob); + return nullptr; + } + return reinterpret_cast<SWAP_DISK_HEADER*>(blob); } } // namespace Kernel diff --git a/dev/kernel/src/UserMgr.cc b/dev/kernel/src/UserMgr.cc index 8e4ba540..5ee2aa33 100644 --- a/dev/kernel/src/UserMgr.cc +++ b/dev/kernel/src/UserMgr.cc @@ -22,7 +22,7 @@ #define kStdUserType (0xEE) #define kSuperUserType (0xEF) -/// @file User.cc +/// @file UserMgr.cc /// @brief Multi-user support. namespace Kernel { @@ -38,14 +38,14 @@ namespace Detail { kout << "user_fnv_generator: Hashing user password...\r"; - const UInt64 FNV_OFFSET_BASIS = 0xcbf29ce484222325ULL; - const UInt64 FNV_PRIME = 0x100000001b3ULL; + const UInt64 kFnvOffsetBasis = 0xcbf29ce484222325ULL; + const UInt64 fFnvPrime = 0x100000001b3ULL; - UInt64 hash = FNV_OFFSET_BASIS; + UInt64 hash = kFnvOffsetBasis; while (*password) { - hash ^= (Utf8Char) (*password++); - hash *= FNV_PRIME; + hash ^= (Char) (*password++); + hash *= fFnvPrime; } kout << "user_fnv_generator: Hashed user password.\r"; diff --git a/dev/kernel/src/UserProcessScheduler.cc b/dev/kernel/src/UserProcessScheduler.cc index 07c4a572..ac25c3d8 100644 --- a/dev/kernel/src/UserProcessScheduler.cc +++ b/dev/kernel/src/UserProcessScheduler.cc @@ -21,7 +21,7 @@ #include <KernelKit/ProcessScheduler.h> #include <NeKit/KString.h> #include <NeKit/Utils.h> -#include <SignalKit/SignalGen.h> +#include <SignalKit/Signals.h> ///! BUGS: 0 @@ -462,15 +462,10 @@ UserProcessScheduler& UserProcessScheduler::The() { /***********************************************************************************/ Void UserProcessScheduler::Remove(ProcessID process_id) { - if (process_id < 0 || process_id > kSchedProcessLimitPerTeam) { - return; - } - - if (this->mTeam.mProcessList[process_id].Status == ProcessStatusKind::kInvalid) { - return; - } + if (process_id < 0 || process_id > kSchedProcessLimitPerTeam) return; + if (this->mTeam.mProcessList[process_id].Status == ProcessStatusKind::kInvalid) return; - mTeam.mProcessList[process_id].Exit(0); + mTeam.mProcessList[process_id].Exit(kErrorSuccess); } /// @brief Is it a user scheduler? @@ -586,17 +581,13 @@ ErrorOr<ProcessID> UserProcessHelper::TheCurrentPID() { /// @retval true can be schedulded. /// @retval false cannot be schedulded. Bool UserProcessHelper::CanBeScheduled(const USER_PROCESS& process) { + if (process.Affinity == AffinityKind::kRealTime) return Yes; + if (process.Status != ProcessStatusKind::kRunning) return No; if (process.Affinity == AffinityKind::kInvalid) return No; if (process.StackSize > kSchedMaxStackSz) return No; if (!process.Name[0]) return No; - - // real time processes shouldn't wait that much. - if (process.Affinity == AffinityKind::kRealTime) return Yes; - - if (process.Signal.SignalID == sig_generate_unique<SIGTRAP>()) { - return No; - } + if (process.Signal.SignalID == sig_generate_unique<SIGTRAP>()) return No; return process.PTime < 1; } diff --git a/dev/kernel/src/UtfUtils.cc b/dev/kernel/src/UtfUtils.cc index e98b8306..d0523b96 100644 --- a/dev/kernel/src/UtfUtils.cc +++ b/dev/kernel/src/UtfUtils.cc @@ -10,6 +10,8 @@ namespace Kernel { Size urt_string_len(const Utf8Char* str) { + if (!str) return 0; + SizeT len{0}; while (str[len] != u8'\0') ++len; @@ -18,6 +20,8 @@ Size urt_string_len(const Utf8Char* str) { } Void urt_set_memory(const voidPtr src, UInt32 dst, Size len) { + if (!src) return; + Utf8Char* srcChr = reinterpret_cast<Utf8Char*>(src); Size index = 0; @@ -28,6 +32,8 @@ Void urt_set_memory(const voidPtr src, UInt32 dst, Size len) { } Int32 urt_string_cmp(const Utf8Char* src, const Utf8Char* cmp, Size size) { + if (!src) return 0; + Int32 counter = 0; for (Size index = 0; index < size; ++index) { @@ -38,6 +44,9 @@ Int32 urt_string_cmp(const Utf8Char* src, const Utf8Char* cmp, Size size) { } Int32 urt_copy_memory(const VoidPtr src, VoidPtr dst, Size len) { + if (!src) return 0; + if (!dst) return 0; + Utf8Char* srcChr = reinterpret_cast<Utf8Char*>(src); Utf8Char* dstChar = reinterpret_cast<Utf8Char*>(dst); diff --git a/dev/launch/LaunchKit/LaunchKit.h b/dev/launch/LaunchKit/Foundation.h index 2fa9607b..24df46f6 100644 --- a/dev/launch/LaunchKit/LaunchKit.h +++ b/dev/launch/LaunchKit/Foundation.h @@ -7,14 +7,15 @@ #pragma once #include <libSystem/SystemKit/System.h> +#include <CoreFoundation.fwrk/headers/Ref.h> /// @author Amlal El Mahrouss -/// @brief NeKernel Launch Kit. +/// @brief NeKernel Launch Kit - launch programs from it. #define NELAUNCH_INFO(MSG) PrintOut(nullptr, "INFO: [LAUNCH] %s\n", MSG) #define NELAUNCH_WARN(MSG) PrintOut(nullptr, "WARN: [LAUNCH] %s\n", MSG) namespace Launch { -using LaunchHandle = VoidPtr; -using KernelStatus = SInt32; +using AnyRef = CF::CFRef<VoidPtr>; +using StatusRef = CF::CFRef<SInt32>; } // namespace Launch diff --git a/dev/launch/ne_launch.json b/dev/launch/launch.json index e3d26a46..dbc111b2 100644 --- a/dev/launch/ne_launch.json +++ b/dev/launch/launch.json @@ -1,7 +1,7 @@ { "compiler_path": "x86_64-w64-mingw32-g++", "compiler_std": "c++20", - "headers_path": ["../", "./"], + "headers_path": ["../", "./", "../../public/frameworks"], "sources_path": ["src/*.cc", "src/*.S"], "output_name": "ne_launch", "compiler_flags": [ diff --git a/dev/launch/src/AppMain.cc b/dev/launch/src/AppMain.cc new file mode 100644 index 00000000..eef95fba --- /dev/null +++ b/dev/launch/src/AppMain.cc @@ -0,0 +1,31 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + + ------------------------------------------- */ + +#include <LaunchKit/Foundation.h> +#include <libSystem/SystemKit/Err.h> +#include <libSystem/SystemKit/Syscall.h> + +/// @note This called by _NeMain from its own runtime. +extern "C" SInt32 nelaunch_startup_fn(Void) { + /// @todo Start LaunchServices.fwrk services, make the launcher manageable too (via mgmt.launch) + + NELAUNCH_INFO("Turning on launcher..."); + + UInt32* ret = (UInt32*) libsys_syscall_arg_1(libsys_hash_64("__launch_register_pid0")); + + if (ret) { + switch (*ret) { + case kErrorSuccess: { + libsys_syscall_arg_1(libsys_hash_64("__launch_listen_as_root")); + return *ret; + } + default: + break; + } + } + + return kErrorExecutable; +} diff --git a/dev/launch/src/CRT0.S b/dev/launch/src/CRuntimeZero.S index 84a293e6..73fa5352 100644 --- a/dev/launch/src/CRT0.S +++ b/dev/launch/src/CRuntimeZero.S @@ -4,15 +4,20 @@ ------------------------------------------- */ - .text +.text .extern nelaunch_startup_fn +.extern ThrExitMainThread .globl _NeMain _NeMain: push %rbp movq %rsp, %rbp + callq nelaunch_startup_fn - popq %rbp - retq + movq %rcx, 0 + + callq ThrExitMainThread + + popq %rbp diff --git a/dev/launch/src/LaunchSrv.cc b/dev/launch/src/LaunchSrv.cc deleted file mode 100644 index f5c9ee3c..00000000 --- a/dev/launch/src/LaunchSrv.cc +++ /dev/null @@ -1,17 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - - ------------------------------------------- */ - -#include <LaunchKit/LaunchKit.h> -#include <libSystem/SystemKit/Err.h> - -/// @note This called by _NeMain from its own runtime. -extern "C" SInt32 nelaunch_startup_fn(Void) { - /// @todo Start LaunchServices.fwrk services, make the launcher manageable too (via mgmt.launch) - - NELAUNCH_INFO("Starting NeKernel services..."); - - return kErrorSuccess; -} diff --git a/dev/libDDK/DriverKit/dev.h b/dev/libDDK/DriverKit/dev.h index adb1c1d0..28f3617d 100644 --- a/dev/libDDK/DriverKit/dev.h +++ b/dev/libDDK/DriverKit/dev.h @@ -29,8 +29,8 @@ typedef struct _DDK_DEVICE DDK_FINAL { /// @brief Open a new device from path. /// @param path the device's path. -DDK_EXTERN DDK_DEVICE_PTR open(const char* path); +DDK_EXTERN DDK_DEVICE_PTR kopen_dev(const char* path); /// @brief Close any device. /// @param device valid device. -DDK_EXTERN BOOL close(DDK_DEVICE_PTR device); +DDK_EXTERN BOOL kclose_dev(DDK_DEVICE_PTR device); diff --git a/dev/libDDK/src/ddk_dev.c b/dev/libDDK/src/ddk_dev.c index d20684aa..c0396eb5 100644 --- a/dev/libDDK/src/ddk_dev.c +++ b/dev/libDDK/src/ddk_dev.c @@ -10,15 +10,15 @@ #include <DriverKit/str.h> /// @brief Open a new binary device from path. -DDK_EXTERN DDK_DEVICE_PTR open(const char* devicePath) { +DDK_EXTERN DDK_DEVICE_PTR kopen_dev(const char* devicePath) { if (nil == devicePath) return nil; - return ke_call_dispatch("dk_open_dev", 1, (void*) devicePath, kstrlen(devicePath)); + return (DDK_DEVICE_PTR)ke_call_dispatch("dk_open_dev", 1, (void*) devicePath, kstrlen(devicePath)); } /// @brief Close any device. /// @param device valid device. -DDK_EXTERN BOOL close(DDK_DEVICE_PTR device) { +DDK_EXTERN BOOL kclose_dev(DDK_DEVICE_PTR device) { if (nil == device) return NO; ke_call_dispatch("dk_close_dev", 1, device, sizeof(DDK_DEVICE)); diff --git a/dev/libDDK/src/ddk_io.c b/dev/libDDK/src/ddk_io.c index 825e82a7..ab0dd624 100644 --- a/dev/libDDK/src/ddk_io.c +++ b/dev/libDDK/src/ddk_io.c @@ -1,6 +1,6 @@ /* ------------------------------------------- - libDDK. + libDDK - Device Driver Kit Copyright 2025 - Amlal El Mahrouss and NeKernel contributors. File: ddk_io.c @@ -24,7 +24,7 @@ DDK_EXTERN void kputc(const char ch) { /// @param message UART to transmit. DDK_EXTERN void kprint(const char* message) { if (nil == message) return; - if (*message == 0) return; + if (*message == '\0') return; size_t index = 0; size_t len = kstrlen(message); diff --git a/dev/libMsg/MsgKit/Server.h b/dev/libMsg/MsgKit/Server.h index 022aa425..5bc9617d 100644 --- a/dev/libMsg/MsgKit/Server.h +++ b/dev/libMsg/MsgKit/Server.h @@ -13,6 +13,7 @@ #endif /// @author Amlal El Mahrouss +/// @file Server.h /// @brief libMsg LISP system. struct LIBMSG_EXPR; @@ -23,8 +24,8 @@ struct LIBMSG_EXPR final { CF::CFString* l_key{nullptr}; CF::CFString* l_value{nullptr}; #else - VoidPtr l_key{nullptr}; - VoidPtr l_value{nullptr}; + // if we use C< we won't know about CF, so let's make those private. + VoidPtr l_private_data[2]{nullptr}; #endif LIBMSG_EXPR* l_head{nullptr}; @@ -33,8 +34,8 @@ struct LIBMSG_EXPR final { }; /// @brief Function type for LibMSG lisp. -typedef Void (*libmsg_func_t)(struct LIBMSG_EXPR* self, VoidPtr arg, SizeT arg_size); +typedef Void (*libmsg_func_type)(struct LIBMSG_EXPR* self, VoidPtr arg, SizeT arg_size); -IMPORT_C Void libmsg_init_library(libmsg_func_t* funcs, SizeT cnt); +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); diff --git a/dev/libSystem/SystemKit/System.h b/dev/libSystem/SystemKit/System.h index f46fe523..88472513 100644 --- a/dev/libSystem/SystemKit/System.h +++ b/dev/libSystem/SystemKit/System.h @@ -79,7 +79,7 @@ IMPORT_C Void IoCloseFile(_Input Ref file_desc); /// @param in_data the input data.
/// @param out_data the output data.
/// @return the number of bytes written.
-/// @note This function is used to control the file descriptor, introduced for HeFS.
+/// @note This function is used to control the file descriptor, introduced for OpenHeFS.
IMPORT_C SInt32 IoCtrlFile(_Input Ref file_desc, _Input UInt32 ioctl_code, _Input VoidPtr in_data,
_Output VoidPtr out_data);
@@ -89,7 +89,7 @@ IMPORT_C const Char* IoMimeFile(_Input Ref file_desc); /// @brief Gets the dir DIM.
/// @param dir_desc directory descriptor.
-/// @note only works in HeFS, will return nil-x/nil if used on any other filesystem.
+/// @note only works in OpenHeFS, will return nil-x/nil if used on any other filesystem.
IMPORT_C const Char* IoDimFile(_Input Ref dir_desc);
/// @brief Write data to a file ref
diff --git a/dev/libSystem/SystemKit/Verify.h b/dev/libSystem/SystemKit/Verify.h index cbf85830..bc0c8be3 100644 --- a/dev/libSystem/SystemKit/Verify.h +++ b/dev/libSystem/SystemKit/Verify.h @@ -11,7 +11,7 @@ #include <libSystem/SystemKit/System.h> -namespace LibSystem::Detail { +namespace LibSystem::Verify { /// @author 0xf00sec, and Amlal El Mahrouss /// @brief safe cast operator. template <typename T, typename R = VoidPtr> @@ -34,7 +34,7 @@ struct must_cast_traits<T, T> { /// @brief Safe constexpr cast. template <typename T, typename R> inline constexpr R* sys_constexpr_cast(T* ptr) { - static_assert(must_cast_traits<T, R>::value, "constexpr cast failed! types are a mismatch!"); + static_assert(must_cast_traits<T, R>::value, "constexpr cast failed! types are mismatching!"); return static_cast<R*>(ptr); } -} // namespace LibSystem::Detail +} // namespace LibSystem::Verify diff --git a/dev/libSystem/src/JailCalls.cc b/dev/libSystem/src/JailCalls.cc new file mode 100644 index 00000000..5cb47bb5 --- /dev/null +++ b/dev/libSystem/src/JailCalls.cc @@ -0,0 +1,17 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#include <libSystem/SystemKit/Err.h> +#include <libSystem/SystemKit/Jail.h> +#include <libSystem/SystemKit/Syscall.h> +#include <libSystem/SystemKit/System.h> +#include <libSystem/SystemKit/Verify.h> + +using namespace LibSystem; + +IMPORT_C struct JAIL* JailGetCurrent(Void) { + return (struct JAIL*) libsys_syscall_arg_1(SYSCALL_HASH("JailGetCurrent")); +}
\ No newline at end of file diff --git a/dev/libSystem/src/Makefile b/dev/libSystem/src/Makefile index 64ef02cc..ea8e9905 100644 --- a/dev/libSystem/src/Makefile +++ b/dev/libSystem/src/Makefile @@ -1,5 +1,5 @@ ################################################## -# (c) Amlal El Mahrouss, all rights reserved. +# (c) Amlal El Mahrouss and NeKernel contributors, all rights reserved. # This file is for libSystem.dll's syscall stubs. ################################################## @@ -8,9 +8,9 @@ FLAGS=-f win64 .PHONY: error error: - @echo "==> Invalid rule." + @echo "==> Invalid recipe." @echo "==> Use libsys_asm_io_<arch> instead." .PHONY: libsys_asm_io_x64 libsys_asm_io_x64: - $(ASM) $(FLAGS) SystemProc.asm -o SystemProc.stub.obj + $(ASM) $(FLAGS) SystemCallsABI+AMD64.asm -o SystemCallsABI+AMD64.stub.obj diff --git a/dev/libSystem/src/System.cc b/dev/libSystem/src/SystemCalls.cc index da9931fe..3db9368d 100644 --- a/dev/libSystem/src/System.cc +++ b/dev/libSystem/src/SystemCalls.cc @@ -11,13 +11,6 @@ using namespace LibSystem;
-IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) {
- if (!expr) {
- PrintOut(nullptr, "Assertion failed: %s\r", origin);
- libsys_syscall_arg_1(SYSCALL_HASH("_rtl_debug_break"));
- }
-}
-
/// @note this uses the FNV 64-bit variant.
IMPORT_C UInt64 libsys_hash_64(const Char* path) {
if (!path || *path == 0) return 0;
@@ -147,7 +140,7 @@ IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) {
return static_cast<Ref>(libsys_syscall_arg_3(
- SYSCALL_HASH("IoOpenFile"), Detail::sys_safe_cast(path), Detail::sys_safe_cast(drv_letter)));
+ SYSCALL_HASH("IoOpenFile"), Verify::sys_safe_cast(path), Verify::sys_safe_cast(drv_letter)));
}
IMPORT_C Void IoCloseFile(_Input Ref desc) {
@@ -183,7 +176,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),
- Detail::sys_safe_cast(buf));
+ Verify::sys_safe_cast(buf));
if (!ret_ptr) return -kErrorInvalidData;
diff --git a/dev/libSystem/src/SystemProc.asm b/dev/libSystem/src/SystemCallsABI+AMD64.asm index 991a371f..da19f41f 100644 --- a/dev/libSystem/src/SystemProc.asm +++ b/dev/libSystem/src/SystemCallsABI+AMD64.asm @@ -1,7 +1,7 @@ ;; /* ;; * ======================================================== ;; * -;; * libSystem/src/SystemProc.asm +;; * libSystem/src/SystemCallsABI+AMD64.asm ;; * Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ;; * ;; * ======================================================== diff --git a/dev/libSystem/src/VerifyCalls.cc b/dev/libSystem/src/VerifyCalls.cc new file mode 100644 index 00000000..078f921b --- /dev/null +++ b/dev/libSystem/src/VerifyCalls.cc @@ -0,0 +1,18 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#include <libSystem/SystemKit/Err.h> +#include <libSystem/SystemKit/Syscall.h> +#include <libSystem/SystemKit/Verify.h> + +using namespace LibSystem; + +IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) { + if (!expr) { + PrintOut(nullptr, "Assertion failed: %s\r", origin); + libsys_syscall_arg_1(SYSCALL_HASH("_rtl_debug_break")); + } +}
\ No newline at end of file diff --git a/dev/launch/LaunchKit/.keep b/docs/drawio/LAUNCH_DESIGN.drawio index e69de29b..e69de29b 100644 --- a/dev/launch/LaunchKit/.keep +++ b/docs/drawio/LAUNCH_DESIGN.drawio diff --git a/docs/tex/hefs.tex b/docs/tex/hefs.tex index c35bca53..9ec68020 100644 --- a/docs/tex/hefs.tex +++ b/docs/tex/hefs.tex @@ -4,7 +4,7 @@ \usepackage{longtable} \usepackage{listings} \geometry{margin=1in} -\title{HeFS: Hight-throughput extended File System} +\title{OpenHeFS: Hight-throughput extended File System} \author{Amlal El Mahrouss} \date{\today} @@ -13,7 +13,7 @@ \maketitle \section{Overview} -The High-throughput Extended File System (HeFS) is a custom filesystem tailored for performance, structure, and compact representation. It uses red-black trees for directory indexing, sparse block slicing for file layout, and fixed-size metadata structures optimized for 512-byte sector alignment. +The High-throughput Extended File System (OpenHeFS) is a custom filesystem tailored for performance, structure, and compact representation. It uses red-black trees for directory indexing, sparse block slicing for file layout, and fixed-size metadata structures optimized for 512-byte sector alignment. \section{Constants and Macros} \begin{longtable}{|l|l|} @@ -21,13 +21,13 @@ The High-throughput Extended File System (HeFS) is a custom filesystem tailored \textbf{Name} & \textbf{Value / Description} \\ \hline \texttt{kHeFSVersion} & 0x0103 \\ -\texttt{kHeFSMagic} & " HeFS" (8-byte magic identifier) \\ +\texttt{kHeFSMagic} & " OpenHeFS" (8-byte magic identifier) \\ \texttt{kHeFSMagicLen} & 8 \\ \texttt{kHeFSBlockLen} & 512 bytes \\ \texttt{kHeFSFileNameLen} & 256 characters \\ \texttt{kHeFSPartNameLen} & 128 characters \\ \texttt{kHeFSMinimumDiskSize} & 128 GiB \\ -\texttt{kHeFSDefaultVolumeName} & "HeFS Volume" \\ +\texttt{kHeFSDefaultVolumeName} & "OpenHeFS Volume" \\ \texttt{kHeFSINDStartOffset} & Offset after boot node \\ \texttt{kHeFSSearchAllStr} & "*" (wildcard string) \\ \hline @@ -151,10 +151,10 @@ Constants: \section{Filesystem API}\label{sec:filesystem-api} -Provided by \texttt{Kernel::HeFS::HeFileSystemParser}. +Provided by \texttt{Kernel::OpenHeFS::HeFileSystemParser}. \begin{itemize} - \item \texttt{Format(drive, flags, name)} - Format drive with HeFS + \item \texttt{Format(drive, flags, name)} - Format drive with OpenHeFS \item \texttt{CreateINodeDirectory(drive, flags, dir)} \item \texttt{RemoveINodeDirectory(drive, flags, dir)} \item \texttt{CreateINode(drive, flags, dir, name, kind)} @@ -168,7 +168,7 @@ Internal helpers: \end{itemize} \section{Conclusion} -HeFS provides a modern and compact approach to high-performance file storage. +OpenHeFS provides a modern and compact approach to high-performance file storage. Its use of red-black trees, fixed-size metadata, slice-based sparse files, and minimal overhead makes it a strong candidate for performance-sensitive use cases. \end{document} diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h index 87005db1..c8d1ba69 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Ref.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Ref.h @@ -78,4 +78,4 @@ class CFNonNullRef final { }; } // namespace CF -#endif // ifndef _NEWKIT_REF_H_ +#endif // ifndef _NEKIT_REF_H_ diff --git a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h index 4a18b079..198d64a1 100644 --- a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h +++ b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h @@ -52,7 +52,7 @@ SInt32 DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) noexcept; /// @return Status code upon completion. SInt32 DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept; -/// @brief HeFS format over EPM. +/// @brief OpenHeFS format over EPM. /// @param img disk image structure. /// @return Status code upon completion. SInt32 DIFormatFilesystemHeFS(struct DI_DISK_IMAGE& img) noexcept; diff --git a/public/frameworks/DiskImage.fwrk/src/DiskImage+HeFS.cc b/public/frameworks/DiskImage.fwrk/src/DiskImage+HeFS.cc index 7f917052..aa7abdf4 100644 --- a/public/frameworks/DiskImage.fwrk/src/DiskImage+HeFS.cc +++ b/public/frameworks/DiskImage.fwrk/src/DiskImage+HeFS.cc @@ -2,17 +2,17 @@ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - FILE: DiskImage+HeFS.cc + FILE: DiskImage+OpenHeFS.cc PURPOSE: Disk Imaging framework. ------------------------------------------- */ #include <DiskImage.fwrk/headers/DiskImage.h> -#include <FSKit/HeFS.h> +#include <FSKit/OpenHeFS.h> #include <FirmwareKit/EPM.h> -/// @brief format HeFS over an EPM disk. +/// @brief format OpenHeFS over an EPM disk. /// @param img disk image structure. /// @return Status code upon completion. SInt32 DI::DIFormatFilesystemHeFS(struct DI_DISK_IMAGE& img) noexcept { diff --git a/public/manuals/nekernel/mgmt.hefs.util.man b/public/manuals/nekernel/mgmt.hefs.util.man index 3274f93a..1cb7022d 100644 --- a/public/manuals/nekernel/mgmt.hefs.util.man +++ b/public/manuals/nekernel/mgmt.hefs.util.man @@ -1,12 +1,12 @@ NAME - mgmt.hefs — HeFS Management utility command + mgmt.hefs — OpenHeFS Management utility command SYNOPSIS mgmt.hefs [OPTIONS] DESCRIPTION The `mgmt.hefs` command provides scheduling, execution, and remote orchestration - of a HeFS volume inside a System One environement. One might use this tool to + of a OpenHeFS volume inside a System One environement. One might use this tool to create, edit, and remove volumes from a disk. Usages include, but are not limited to: @@ -16,7 +16,7 @@ DESCRIPTION OPTIONS -v, --volume <DEVICE> Device input - -c, --create Create HeFS volume + -c, --create Create OpenHeFS volume -x, --xml <PLIST> Pass PropertyList to volume creation tool. -t, --time <HH:MMAM/PM> Time to run the script -d, --day <DAY> Day of the week (e.g., Mon, Tue, Wed) diff --git a/public/manuals/troff/cxxdrv.7 b/public/manuals/troff/cxxdrv.7 index 20e28fd4..65c5fc49 100644 --- a/public/manuals/troff/cxxdrv.7 +++ b/public/manuals/troff/cxxdrv.7 @@ -17,8 +17,8 @@ Specify the output file. .SH USAGE EXAMPLES .TP -.B Generate object file from the main.cpp unit. -.B cxxdrv main.cpp +.B Generate object file from the main.cc unit. +.B cxxdrv main.cc .SH EXIT STATUS .TP diff --git a/tools/fsck.hefs.cc b/tools/fsck.hefs.cc index df89bf07..a2162a4f 100644 --- a/tools/fsck.hefs.cc +++ b/tools/fsck.hefs.cc @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <tools/libmkfs/hefs.h> +#include <tools/libmkfs/openhefs.h> #include <tools/libmkfs/mkfs.h> #include <cstdlib> #include <fstream> @@ -26,7 +26,7 @@ int main(int argc, char** argv) { auto origin = mkfs::get_option<char>(args, "-org"); if (opt_disk.empty()) { - mkfs::console_out() << "fsck: hefs: error: HeFS partition is empty! Exiting..." + mkfs::console_out() << "fsck: hefs: error: OpenHeFS partition is empty! Exiting..." << "\n"; return EXIT_FAILURE; } @@ -59,16 +59,16 @@ int main(int argc, char** argv) { if (strncmp(boot_node.magic, kHeFSMagic, kHeFSMagicLen) != 0 || boot_node.sectorCount < 1 || boot_node.sectorSize < kMkFsSectorSz) { - mkfs::console_out() << "hefs: error: Device is not an HeFS disk: " << opt_disk << "\n"; + mkfs::console_out() << "hefs: error: Device is not an OpenHeFS disk: " << opt_disk << "\n"; return EXIT_FAILURE; } if (boot_node.badSectors > kMkFsMaxBadSectors) { - mkfs::console_out() << "hefs: error: HeFS disk has too much bad sectors: " << opt_disk << "\n"; + mkfs::console_out() << "hefs: error: OpenHeFS disk has too much bad sectors: " << opt_disk << "\n"; return EXIT_FAILURE; } - mkfs::console_out() << "hefs: HeFS partition is healthy, exiting...\n"; + mkfs::console_out() << "hefs: OpenHeFS partition is healthy, exiting...\n"; output_device.close(); diff --git a/tools/libmkfs/hefs.h b/tools/libmkfs/openhefs.h index 52bb3086..3bba79e8 100644 --- a/tools/libmkfs/hefs.h +++ b/tools/libmkfs/openhefs.h @@ -16,7 +16,7 @@ #define kHeFSFileNameLen (256U) #define kHeFSPartNameLen (128U) -#define kHeFSDefaultVolumeName u8"HeFS Volume" +#define kHeFSDefaultVolumeName u8"OpenHeFS Volume" namespace mkfs::hefs { diff --git a/tools/mkfs.hefs.cc b/tools/mkfs.hefs.cc index 9f70b78f..d1139e10 100644 --- a/tools/mkfs.hefs.cc +++ b/tools/mkfs.hefs.cc @@ -4,7 +4,7 @@ ------------------------------------------- */ -#include <tools/libmkfs/hefs.h> +#include <tools/libmkfs/openhefs.h> #include <tools/libmkfs/mkfs.h> #include <algorithm> #include <cstdlib> |
