From 462d618e9988b5172d544e177186bc89bfd303ac Mon Sep 17 00:00:00 2001 From: Amlal Date: Mon, 24 Feb 2025 18:06:23 +0100 Subject: ADD: ARM64: MBCI 'FLSH' driver. Signed-off-by: Amlal --- dev/Kernel/HALKit/AMD64/Storage/AHCI.cc | 4 +-- dev/Kernel/HALKit/ARM64/HalApplicationProcessor.cc | 4 +-- dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc | 36 +++++++++++++++++++++- 3 files changed, 38 insertions(+), 6 deletions(-) (limited to 'dev/Kernel') diff --git a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc b/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc index cf5d1096..cb32cd56 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc @@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, DeVrije Corporation, all rights reserved. + Copyright (C) 2024-2025, DeVrije-Aker Corporation, all rights reserved. ------------------------------------------- */ @@ -11,7 +11,7 @@ * @version 0.1 * @date 2024-02-02 * - * @Copyright (C) 2024, DeVrije, all rights reserved. + * @Copyright (C) 2024, DeVrije-Aker, all rights reserved. * */ diff --git a/dev/Kernel/HALKit/ARM64/HalApplicationProcessor.cc b/dev/Kernel/HALKit/ARM64/HalApplicationProcessor.cc index 415ad5b1..12fb27ae 100644 --- a/dev/Kernel/HALKit/ARM64/HalApplicationProcessor.cc +++ b/dev/Kernel/HALKit/ARM64/HalApplicationProcessor.cc @@ -127,10 +127,8 @@ namespace NeOS { Detail::kGICEnabled = YES; Detail::mp_setup_gic_el0(); - - return YES; } - return NO; + return Detail::kGICEnabled; } } // namespace NeOS \ No newline at end of file diff --git a/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc b/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc index 18071fea..99200349 100644 --- a/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc +++ b/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc @@ -19,7 +19,7 @@ namespace NeOS { /// /Mount/Flash/n - constexpr auto kFlashBridgeMagic = "FLSH"; + constexpr auto kFlashBridgeMagic = 0x70768372; constexpr auto kFlashBridgeRevision = 1; STATIC BOOL kFlashEnabled = NO; @@ -28,6 +28,8 @@ namespace NeOS STATIC IMBCIHost* kFlashMetaPackets[kMaxFlashSlots] = {}; STATIC IMBCIHost* kFlashDataPackets[kMaxFlashSlots] = {}; + STATIC Void drv_std_io(Int32 slot, UInt64 lba, Char* buf, SizeT sector_sz, SizeT buf_sz); + /// @brief Enable flash memory builtin. STATIC Void drv_enable_flash(Int32 slot); @@ -79,6 +81,38 @@ namespace NeOS return YES; } + + STATIC Void drv_std_io(Int32 slot, UInt64 lba, Char* buf, SizeT sector_sz, SizeT buf_sz) + { + UInt64* packet_frame = (UInt64*)kFlashDataPackets[slot]->BaseAddressRegister; + + if (packet_frame[0] != (UInt64)kFlashBridgeMagic) + return; + + if (packet_frame[8] != (UInt64)kFlashBridgeRevision) + return; + + packet_frame[16+0] = lba; + packet_frame[16+4] = sector_sz; + packet_frame[16+8] = lba; + packet_frame[16+12] = buf_sz; + packet_frame[16+14] = (UIntPtr)HAL::hal_get_phys_address(buf); + + while (packet_frame[0] == lba); + } + + Void drv_std_read(Int32 slot, UInt64 lba, Char* buf, SizeT sector_sz, SizeT buf_sz) + { + rt_set_memory(buf, 0, buf_sz); + + drv_std_io(slot, lba, buf, sector_sz, buf_sz); + } + + Void drv_std_write(Int32 slot, UInt64 lba, Char* buf, SizeT sector_sz, SizeT buf_sz) + { + drv_std_io(slot, lba, buf, sector_sz, buf_sz); + } + } // namespace NeOS #endif // if NE_USE_MBCI_FLASH -- cgit v1.2.3