From 0d9e027a0b54ff8c4a3be2ce3b743eb98b2d35bc Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 14 Jul 2023 04:13:31 +0200 Subject: [PATCH] IOS/FS: Move NAND size related constants to FileSystem.h. That way they're available for calculating NAND stats to display to the user. This also adds a few more constants. --- Source/Core/Core/IOS/FS/FileSystem.h | 27 ++++++++++++++++++++++ Source/Core/Core/IOS/FS/HostBackend/FS.cpp | 15 ------------ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Source/Core/Core/IOS/FS/FileSystem.h b/Source/Core/Core/IOS/FS/FileSystem.h index 581df6fbee..f02d2eb350 100644 --- a/Source/Core/Core/IOS/FS/FileSystem.h +++ b/Source/Core/Core/IOS/FS/FileSystem.h @@ -107,6 +107,33 @@ struct Metadata u16 fst_index; }; +// size of a single cluster in the NAND in bytes +constexpr u16 CLUSTER_SIZE = 16384; + +// total number of clusters available in the NAND +constexpr u16 TOTAL_CLUSTERS = 0x7ec0; + +// number of clusters reserved for bad blocks and similar, not accessible to normal writes +constexpr u16 RESERVED_CLUSTERS = 0x0300; + +// number of clusters actually usable by the file system +constexpr u16 USABLE_CLUSTERS = TOTAL_CLUSTERS - RESERVED_CLUSTERS; + +// size of a single 'block' as defined by the Wii System Menu in clusters +constexpr u16 CLUSTERS_PER_BLOCK = 8; + +// total number of user-accessible blocks in the NAND +constexpr u16 USER_BLOCKS = 2176; + +// total number of user-accessible clusters in the NAND +constexpr u16 USER_CLUSTERS = USER_BLOCKS * CLUSTERS_PER_BLOCK; + +// the inverse of that, the amount of usable clusters reserved for system files +constexpr u16 SYSTEM_CLUSTERS = USABLE_CLUSTERS - USER_CLUSTERS; + +// total number of inodes available in the NAND +constexpr u16 TOTAL_INODES = 0x17ff; + struct NandStats { u32 cluster_size; diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp index f09cadb7c8..8c832b2934 100644 --- a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp +++ b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp @@ -29,21 +29,6 @@ namespace IOS::HLE::FS { constexpr u32 BUFFER_CHUNK_SIZE = 65536; -// size of a single cluster in the NAND -constexpr u16 CLUSTER_SIZE = 16384; - -// total number of clusters available in the NAND -constexpr u16 TOTAL_CLUSTERS = 0x7ec0; - -// number of clusters reserved for bad blocks and similar, not accessible to normal writes -constexpr u16 RESERVED_CLUSTERS = 0x0300; - -// number of clusters actually usable by the file system -constexpr u16 USABLE_CLUSTERS = TOTAL_CLUSTERS - RESERVED_CLUSTERS; - -// total number of inodes available in the NAND -constexpr u16 TOTAL_INODES = 0x17ff; - HostFileSystem::HostFilename HostFileSystem::BuildFilename(const std::string& wii_path) const { for (const auto& redirect : m_nand_redirects)