fs: move bitmap classes out of save::

This commit is contained in:
Michael Scire 2022-03-12 14:08:39 -08:00 committed by SciresM
parent 7a69723021
commit be9338eb33
14 changed files with 52 additions and 85 deletions

View file

@ -13,10 +13,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/fssystem/fssystem_allocator_utility.hpp>
#include <stratosphere/fssystem/fssystem_utility.hpp>
#include <stratosphere/fssystem/fssystem_bitmap_utils.hpp>
#include <stratosphere/fssystem/fssystem_speed_emulation_configuration.hpp>
#include <stratosphere/fssystem/fssystem_external_code.hpp>
#include <stratosphere/fssystem/fssystem_forwarding_file_system.hpp>
@ -46,8 +46,8 @@
#include <stratosphere/fssystem/fssystem_alignment_matching_storage_impl.hpp>
#include <stratosphere/fssystem/fssystem_alignment_matching_storage.hpp>
#include <stratosphere/fssystem/fssystem_compressed_storage.hpp>
#include <stratosphere/fssystem/save/fssystem_buffered_storage.hpp>
#include <stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp>
#include <stratosphere/fssystem/fssystem_buffered_storage.hpp>
#include <stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp>
#include <stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp>
#include <stratosphere/fssystem/fssystem_sha256_hash_generator.hpp>
#include <stratosphere/fssystem/fssystem_local_file_system.hpp>

View file

@ -1,43 +0,0 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::fssystem::dbm {
namespace {
constexpr inline s32 CountLeadingZeros(u32 val) {
return util::CountLeadingZeros(val);
}
constexpr inline s32 CountLeadingOnes(u32 val) {
return CountLeadingZeros(~val);
}
inline u32 ReadU32(const u8 *buf, size_t index) {
u32 val;
std::memcpy(std::addressof(val), buf + index, sizeof(u32));
return val;
}
inline void WriteU32(u8 *buf, size_t index, u32 val) {
std::memcpy(buf + index, std::addressof(val), sizeof(u32));
}
}
}

View file

@ -15,12 +15,26 @@
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/lmem.hpp>
#include <stratosphere/fs/fs_directory.hpp>
#include <stratosphere/fs/fs_filesystem.hpp>
#include <stratosphere/fssystem/dbm/fssystem_dbm_utils.hpp>
namespace ams::fssystem::save {
namespace ams::fssystem {
constexpr inline s32 CountLeadingZeros(u32 val) {
return util::CountLeadingZeros(val);
}
constexpr inline s32 CountLeadingOnes(u32 val) {
return CountLeadingZeros(~val);
}
inline u32 ReadU32(const u8 *buf, size_t index) {
u32 val;
std::memcpy(std::addressof(val), buf + index, sizeof(u32));
return val;
}
inline void WriteU32(u8 *buf, size_t index, u32 val) {
std::memcpy(buf + index, std::addressof(val), sizeof(u32));
}
constexpr inline bool IsPowerOfTwo(s32 val) {
return util::IsPowerOfTwo(val);
@ -28,14 +42,15 @@ namespace ams::fssystem::save {
constexpr inline u32 ILog2(u32 val) {
AMS_ASSERT(val > 0);
return (BITSIZEOF(u32) - 1 - dbm::CountLeadingZeros(val));
return (BITSIZEOF(u32) - 1 - util::CountLeadingZeros<u32>(val));
}
constexpr inline u32 CeilPowerOfTwo(u32 val) {
constexpr inline u32 CeilingPowerOfTwo(u32 val) {
if (val == 0) {
return 1;
}
return ((1u << (BITSIZEOF(u32) - 1)) >> (dbm::CountLeadingZeros(val - 1) - 1));
return util::CeilingPowerOfTwo<u32>(val);
}
}

View file

@ -19,11 +19,10 @@
#include <stratosphere/fs/fs_storage_type.hpp>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/fs_memory_management.hpp>
#include <stratosphere/fssystem/save/fssystem_i_save_file_system_driver.hpp>
#include <stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp>
#include <stratosphere/fssystem/impl/fssystem_block_cache_manager.hpp>
namespace ams::fssystem::save {
namespace ams::fssystem {
constexpr inline size_t IntegrityMinLayerCount = 2;
constexpr inline size_t IntegrityMaxLayerCount = 7;

View file

@ -20,7 +20,7 @@
#include <stratosphere/fs/fs_substorage.hpp>
#include <stratosphere/fs/fs_i_buffer_manager.hpp>
namespace ams::fssystem::save {
namespace ams::fssystem {
class BufferedStorage : public ::ams::fs::IStorage {
NON_COPYABLE(BufferedStorage);

View file

@ -19,11 +19,10 @@
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/fs_substorage.hpp>
#include <stratosphere/fs/fs_storage_type.hpp>
#include <stratosphere/fssystem/save/fssystem_i_save_file.hpp>
#include <stratosphere/fssystem/save/fssystem_integrity_verification_storage.hpp>
#include <stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp>
#include <stratosphere/fssystem/fssystem_integrity_verification_storage.hpp>
#include <stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp>
namespace ams::fssystem::save {
namespace ams::fssystem {
struct HierarchicalIntegrityVerificationLevelInformation {
fs::Int64 offset;

View file

@ -19,7 +19,7 @@
#include <stratosphere/fs/fs_memory_storage.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/fssystem/fssystem_nca_header.hpp>
#include <stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp>
#include <stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp>
namespace ams::fssystem {
@ -28,8 +28,8 @@ namespace ams::fssystem {
class IntegrityRomFsStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
private:
save::HierarchicalIntegrityVerificationStorage m_integrity_storage;
save::FileSystemBufferManagerSet m_buffers;
HierarchicalIntegrityVerificationStorage m_integrity_storage;
FileSystemBufferManagerSet m_buffers;
os::SdkRecursiveMutex m_mutex;
Hash m_master_hash;
std::unique_ptr<fs::MemoryStorage> m_master_hash_storage;
@ -37,7 +37,7 @@ namespace ams::fssystem {
IntegrityRomFsStorage() : m_mutex() { /* ... */ }
virtual ~IntegrityRomFsStorage() override { this->Finalize(); }
Result Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf);
Result Initialize(HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf);
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override {
@ -66,7 +66,7 @@ namespace ams::fssystem {
return m_integrity_storage.Commit();
}
save::FileSystemBufferManagerSet *GetBuffers() {
FileSystemBufferManagerSet *GetBuffers() {
return m_integrity_storage.GetBuffers();
}
};

View file

@ -19,12 +19,9 @@
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/fs_substorage.hpp>
#include <stratosphere/fs/fs_storage_type.hpp>
#include <stratosphere/fs/fs_save_data_types.hpp>
#include <stratosphere/fssystem/save/fssystem_save_types.hpp>
#include <stratosphere/fssystem/save/fssystem_i_save_file_system_driver.hpp>
#include <stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp>
#include <stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp>
namespace ams::fssystem::save {
namespace ams::fssystem {
class IntegrityVerificationStorage : public ::ams::fs::IStorage {
NON_COPYABLE(IntegrityVerificationStorage);