diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-01-03 09:58:24 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-01-03 09:58:24 +0100 |
| commit | cbfd279a1410e11d734edc99509a3e0c02dc6fcc (patch) | |
| tree | 9fdda9fed9bd39f5f0ad8f2ba8bf0820d7495cff /dev/Kernel/HALKit/ARM64/Storage | |
| parent | 69b47cf75b49ffe571ab528497b30a2499d372cb (diff) | |
Worked on the AARCH64 HAL for TQ's boards, Add new spec in /doc/
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/HALKit/ARM64/Storage')
| -rw-r--r-- | dev/Kernel/HALKit/ARM64/Storage/HalMFlash.cc | 67 | ||||
| -rw-r--r-- | dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc | 84 |
2 files changed, 84 insertions, 67 deletions
diff --git a/dev/Kernel/HALKit/ARM64/Storage/HalMFlash.cc b/dev/Kernel/HALKit/ARM64/Storage/HalMFlash.cc deleted file mode 100644 index 2a764101..00000000 --- a/dev/Kernel/HALKit/ARM64/Storage/HalMFlash.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024, Theater Quality Corp, all rights reserved. - -------------------------------------------- */ - -#ifdef ZKA_USE_MBCI_FLASH - -#include <NewKit/Defines.h> -#include <ArchKit/ArchKit.h> -#include <Mod/MFlash/MFlash.h> - -/// @file HalMFlash.cc -/// @brief MBCI Flash builtin. - -#define kMaxFlash (4U) - -namespace Kernel -{ - /// /Mount/Flash/n - constexpr auto kFlashBridgeMagic = "FLSH"; - constexpr auto kFlashBridgeRevision = 1; - - STATIC CONST Boolean kFlashEnabled = No; - STATIC SizeT kFlashSize[kMaxFlash] = {}; - STATIC SizeT kFlashSectorSz[kMaxFlash] = {}; - - /// @brief Enable flash memory builtin. - STATIC Void drv_enable_flash(Int32 slot); - - /// @brief Disable flash memory builtin. - STATIC Void drv_disable_flash(Int32 slot); - - /// @brief get sector count. - /// @return drive sector count. - SizeT drv_get_sector_count(Int32 slot) - { - if (slot > kMaxFlash) - return 0; - - return kFlashSectorSz[slot]; - } - - /// @brief get device size. - /// @return drive size - SizeT drv_get_size(Int32 slot) - { - if (slot > kMaxFlash) - return 0; - - return kFlashSize[slot]; - } - - /// @brief Enable flash memory at slot. - STATIC Void drv_enable_flash(Int32 arg) - { - kcout << "Enabled FLSH hardware.\r"; - } - - /// @brief Disable flash memory at slot. - STATIC Void drv_disable_flash(Int32 arg) - { - kcout << "Disabled FLSH hardware.\r"; - } -} // namespace Kernel - -#endif // if ZKA_USE_MBCI_FLASH (Bridge) diff --git a/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc b/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc new file mode 100644 index 00000000..2d556b96 --- /dev/null +++ b/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc @@ -0,0 +1,84 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Theater Quality Corp, all rights reserved. + +------------------------------------------- */ + +#ifdef ZKA_USE_MBCI_FLASH + +#include <NewKit/Defines.h> +#include <ArchKit/ArchKit.h> +#include <Mod/MFlash/MFlash.h> +#include <Mod/MBCI/MBCI.h> + +/// @file MFlash.cc +/// @brief MBCI Flash support. + +#define kMaxFlashSlots (8U) + +namespace Kernel +{ + /// /Mount/Flash/n + constexpr auto kFlashBridgeMagic = "FLSH"; + constexpr auto kFlashBridgeRevision = 1; + + STATIC BOOL kFlashEnabled = NO; + STATIC SizeT kFlashSize[kMaxFlashSlots] = {}; + STATIC SizeT kFlashSectorSz[kMaxFlashSlots] = {}; + STATIC IMBCIHost* kFlashMetaPackets[kMaxFlashSlots] = {}; + STATIC IMBCIHost* kFlashDataPackets[kMaxFlashSlots] = {}; + + /// @brief Enable flash memory builtin. + STATIC Void drv_enable_flash(Int32 slot); + + /// @brief Disable flash memory builtin. + STATIC Void drv_disable_flash(Int32 slot); + + /// @brief get slot sector count. + /// @return slot sector count. + SizeT drv_get_sector_count(Int32 slot) + { + if (slot > kMaxFlashSlots) + return 0; + + return kFlashSectorSz[slot]; + } + + /// @brief get slot full size (in bytes). + /// @return drive slot size + SizeT drv_get_size(Int32 slot) + { + if (slot > kMaxFlashSlots) + return 0; + + return kFlashSize[slot]; + } + + /// @brief Enable flash memory at slot. + BOOL drv_enable_at(Int32 slot) + { + if (slot > kMaxFlashSlots) + return NO; + + kFlashMetaPackets[slot]->InterruptEnable = YES; + + kcout << "Enabled hardware slot at: " << number(slot) << endl; + + return YES; + } + + /// @brief Disable flash memory at slot. + BOOL drv_disable_at(Int32 slot) + { + if (slot > kMaxFlashSlots) + return NO; + + kFlashMetaPackets[slot]->InterruptEnable = NO; + + kcout << "Disabled hardware slot at: " << number(slot) << endl; + + return YES; + } +} // namespace Kernel + +#endif // if ZKA_USE_MBCI_FLASH |
