diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-01 08:30:44 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-01 08:30:44 +0200 |
| commit | 2a7a9825fd275d6d999b94614fe87c1d705c7f8f (patch) | |
| tree | a1acef0bd6286f03197c0e1839e8d41ac5e5538f /public | |
| parent | fd288fed29eff48503abf842676085701e04c38d (diff) | |
boot, kernel, modules: unify gfx headers, fix AHCI LBA48, standardize ModuleMain
- Consolidated CoreGfx headers:
* Renamed `FBMgr.h` to `CoreGfx.h`
* Renamed `TextMgr.h` → `TextGfx.h`, `MathMgr.h` → `MathGfx.h`, and `AccessibilityMgr.h` → `CoreAccess.h`
* Updated all includes across bootloader, HAL, and kernel to use new names
- Standardized EFI entrypoint:
* Replaced `Main` with `ModuleMain` in EFI boot sources and linker flags
* Updated GDB and build scripts accordingly
- Improved AHCI identify logic:
* Added full 48-bit LBA extraction (words 100–102)
* Fallback to 28-bit if LBA48 not supported
* Refactored `drv_get_size` and `drv_std_detected` into separate `#ifdef __AHCI__` region
- DiskImage framework improvements:
* Namespaced API into `DI` namespace
* Split implementation: `DiskImage+EPM.cc` and `DiskImage+NeFS.cc`
* Updated CLI tool accordingly
- KernelTest framework:
* Namespaced macros and classes with `KT_`
* Changed test result to use `MUST_PASS` and boolean return
- Misc:
* Corrected minor logic in `NetworkDevice::Name()`
* Bumped down KernelKit and NewKit versions to 0.0.1
* Renamed `HalUtils.asm` → `HalUtilsAPI.asm`
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'public')
| -rw-r--r-- | public/frameworks/DiskImage.fwrk/headers/DiskImage.h | 50 | ||||
| -rw-r--r-- | public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc | 53 | ||||
| -rw-r--r-- | public/frameworks/DiskImage.fwrk/src/DiskImage+NeFS.cc (renamed from public/frameworks/DiskImage.fwrk/src/DiskImage.cc) | 46 | ||||
| -rw-r--r-- | public/frameworks/KernelTest.fwrk/headers/KernelTest.h | 26 | ||||
| -rw-r--r-- | public/tools/diutil/src/CommandLine.cc | 6 |
5 files changed, 100 insertions, 81 deletions
diff --git a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h index c20a12f8..1dc23c0a 100644 --- a/public/frameworks/DiskImage.fwrk/headers/DiskImage.h +++ b/public/frameworks/DiskImage.fwrk/headers/DiskImage.h @@ -22,27 +22,31 @@ #define kDIDiskNameLen (16) #define kDIOutNameLen (256) -/// @brief Disk Image file structure. -/// @param disk_name Disk partition name. -/// @param sector_sz Disk sector_sz. -/// @param block_cnt Disk block count. -/// @param disk_sz Disk size. -/// @param out_name Output file name. -struct DI_DISK_IMAGE +namespace DI { - Char disk_name[kDIDiskNameLen] = kDIDefaultDiskName; - SInt32 sector_sz = kDISectorSz; - SInt32 block_cnt = 0; - SizeT disk_sz = kDIMinDiskSz; - Char out_name[kDIOutNameLen] = kDIDefaultOutputName; -}; - -/// @brief Format with an EPM partition. -/// @param img disk image structure. -/// @return Status code upon completion. -SInt32 DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) noexcept; - -/// @brief NeFS format over EPM. -/// @param img disk image structure. -/// @return Status code upon completion. -SInt32 DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept; + /// @brief Disk Image file structure. + /// @param disk_name Disk partition name. + /// @param sector_sz Disk sector_sz. + /// @param block_cnt Disk block count. + /// @param disk_sz Disk size. + /// @param out_name Output file name. + struct DI_DISK_IMAGE + { + Char disk_name[kDIDiskNameLen] = kDIDefaultDiskName; + SInt32 sector_sz = kDISectorSz; + SInt32 block_cnt = 0; + SizeT disk_sz = kDIMinDiskSz; + Char out_name[kDIOutNameLen] = kDIDefaultOutputName; + }; + + /// @brief Format with an EPM partition. + /// @param img disk image structure. + /// @return Status code upon completion. + SInt32 DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) noexcept; + + /// @brief NeFS format over EPM. + /// @param img disk image structure. + /// @return Status code upon completion. + SInt32 DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept; + +} // namespace DI diff --git a/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc b/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc new file mode 100644 index 00000000..4d2a6694 --- /dev/null +++ b/public/frameworks/DiskImage.fwrk/src/DiskImage+EPM.cc @@ -0,0 +1,53 @@ +/* ------------------------------------------- + + Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. + + FILE: DiskImage+EPM.cc + PURPOSE: Disk Imaging framework. + + ------------------------------------------- */ + +#include <DiskImage.fwrk/headers/DiskImage.h> + +#include <FirmwareKit/EPM.h> +#include <FSKit/NeFS.h> + +/// @brief EPM format disk +/// @param img disk image structure. +/// @return Status code upon completion. +SInt32 DI::DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) noexcept +{ + if (!img.sector_sz || (img.sector_sz % 512 != 0)) + return kDIFailureStatus; + + if (*img.out_name == 0 || + *img.disk_name == 0) + return kDIFailureStatus; + + struct ::EPM_PART_BLOCK block + { + }; + + block.NumBlocks = img.block_cnt; + block.SectorSz = img.sector_sz; + block.Version = kEPMRevisionBcd; + block.LbaStart = sizeof(struct ::EPM_PART_BLOCK); + block.LbaEnd = img.disk_sz - block.LbaStart; + block.FsVersion = kNeFSVersionInteger; + + ::MmCopyMemory(block.Name, (VoidPtr)img.disk_name, ::MmStrLen(img.disk_name)); + ::MmCopyMemory(block.Magic, (VoidPtr)kEPMMagic86, ::MmStrLen(kEPMMagic86)); + + IORef handle = IoOpenFile(img.out_name, nullptr); + + if (!handle) + return kDIFailureStatus; + + ::IoWriteFile(handle, (Char*)&block, sizeof(struct ::EPM_PART_BLOCK)); + + ::IoCloseFile(handle); + + handle = nullptr; + + return kDISuccessStatus; +} diff --git a/public/frameworks/DiskImage.fwrk/src/DiskImage.cc b/public/frameworks/DiskImage.fwrk/src/DiskImage+NeFS.cc index 0c4ee06a..4928c878 100644 --- a/public/frameworks/DiskImage.fwrk/src/DiskImage.cc +++ b/public/frameworks/DiskImage.fwrk/src/DiskImage+NeFS.cc @@ -2,7 +2,7 @@ Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. - FILE: DiskImage.cc + FILE: DiskImage+NeFS.cc PURPOSE: Disk Imaging framework. ------------------------------------------- */ @@ -12,50 +12,10 @@ #include <FirmwareKit/EPM.h> #include <FSKit/NeFS.h> -/// @brief EPM format disk -/// @param img disk image structure. -/// @return Status code upon completion. -SInt32 DIFormatPartitionEPM(struct DI_DISK_IMAGE& img) noexcept -{ - if (!img.sector_sz || (img.sector_sz % 512 != 0)) - return kDIFailureStatus; - - if (*img.out_name == 0 || - *img.disk_name == 0) - return kDIFailureStatus; - - struct ::EPM_PART_BLOCK block - { - }; - - block.NumBlocks = img.block_cnt; - block.SectorSz = img.sector_sz; - block.Version = kEPMRevisionBcd; - block.LbaStart = sizeof(struct ::EPM_PART_BLOCK); - block.LbaEnd = img.disk_sz - block.LbaStart; - block.FsVersion = kNeFSVersionInteger; - - ::MmCopyMemory(block.Name, (VoidPtr)img.disk_name, ::MmStrLen(img.disk_name)); - ::MmCopyMemory(block.Magic, (VoidPtr)kEPMMagic86, ::MmStrLen(kEPMMagic86)); - - IOObject handle = IoOpenFile(img.out_name, nullptr); - - if (!handle) - return kDIFailureStatus; - - ::IoWriteFile(handle, (Char*)&block, sizeof(struct ::EPM_PART_BLOCK)); - - ::IoCloseFile(handle); - - handle = nullptr; - - return kDISuccessStatus; -} - /// @brief NeFS format over EPM. /// @param img disk image structure. /// @return Status code upon completion. -SInt32 DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept +SInt32 DI::DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept { if (!img.sector_sz || (img.sector_sz % 512 != 0)) return kDIFailureStatus; @@ -85,7 +45,7 @@ SInt32 DIFormatFilesystemNeFS(struct DI_DISK_IMAGE& img) noexcept rpb.FreeSectors = rpb.SectorCount; rpb.FreeCatalog = rpb.DiskSize / sizeof(NEFS_CATALOG_STRUCT); - IOObject handle = IoOpenFile(img.out_name, nullptr); + IORef handle = IoOpenFile(img.out_name, nullptr); if (!handle) return kDIFailureStatus; diff --git a/public/frameworks/KernelTest.fwrk/headers/KernelTest.h b/public/frameworks/KernelTest.fwrk/headers/KernelTest.h index c802574b..30fb3ce6 100644 --- a/public/frameworks/KernelTest.fwrk/headers/KernelTest.h +++ b/public/frameworks/KernelTest.fwrk/headers/KernelTest.h @@ -6,28 +6,30 @@ #pragma once -#define NE_TEST_VERSION_BCD (0x0001) -#define NE_TEST_VERSION "0.0.1" +#include <NewKit/KernelPanic.h> -#define NE_TEST_FAILURE (1) +#define KT_TEST_VERSION_BCD (0x0001) +#define KT_TEST_VERSION "0.0.1" -#define NE_TEST_SUCCESS (0) +#define KT_TEST_FAILURE (1) -#define NE_DECL_TEST(NAME, FN) \ - class NAME final \ +#define KT_TEST_SUCCESS (0) + +#define KT_DECL_TEST(NAME, FN) \ + class KT_##NAME final \ { \ public: \ - int Run(); \ + void Run(); \ const char* ToString(); \ }; \ - inline int NAME::Run() \ + inline void KT_##NAME::Run() \ { \ - return FN() == 0; \ + MUST_PASS(FN() == true); \ } \ - inline const char* NAME::ToString() \ + inline const char* KT_##NAME::ToString() \ { \ return #FN; \ } -NE_DECL_TEST(ALWAYS_BREAK, []() -> bool { return false; }); -NE_DECL_TEST(ALWAYS_GOOD, []() -> bool { return true; });
\ No newline at end of file +KT_DECL_TEST(ALWAYS_BREAK, []() -> bool { return false; }); +KT_DECL_TEST(ALWAYS_GOOD, []() -> bool { return true; });
\ No newline at end of file diff --git a/public/tools/diutil/src/CommandLine.cc b/public/tools/diutil/src/CommandLine.cc index d05b6e3a..61154e7a 100644 --- a/public/tools/diutil/src/CommandLine.cc +++ b/public/tools/diutil/src/CommandLine.cc @@ -54,7 +54,7 @@ int main(int argc, char** argv) // create disk image. - DI_DISK_IMAGE img{}; + DI::DI_DISK_IMAGE img{}; img.disk_sz = kDiskSz; img.sector_sz = kDiskSectorSz; @@ -63,6 +63,6 @@ int main(int argc, char** argv) MmCopyMemory((VoidPtr)img.disk_name, (VoidPtr)kDiskName, kDIDiskNameLen); MmCopyMemory((VoidPtr)img.out_name, (VoidPtr)kOutDisk, kDIDiskNameLen); - // format disk image. - return DIFormatPartitionEPM(img); + // format disk image to explicit partition map. + return DI::DIFormatPartitionEPM(img); }
\ No newline at end of file |
