fs: first pass at compressed storage (works on iridium with wip hac2l code)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/os.hpp>
|
||||
#include <stratosphere/fs/fs_i_buffer_manager.hpp>
|
||||
|
||||
namespace ams::fssystem::buffers {
|
||||
|
||||
@@ -88,13 +89,13 @@ namespace ams::fssystem::buffers {
|
||||
};
|
||||
|
||||
template<typename IsValidBufferFunction>
|
||||
Result AllocateBufferUsingBufferManagerContext(std::pair<uintptr_t, size_t> *out, fssystem::IBufferManager *buffer_manager, size_t size, const IBufferManager::BufferAttribute attribute, IsValidBufferFunction is_valid_buffer, const char *func_name) {
|
||||
Result AllocateBufferUsingBufferManagerContext(fs::IBufferManager::MemoryRange *out, fs::IBufferManager *buffer_manager, size_t size, const fs::IBufferManager::BufferAttribute attribute, IsValidBufferFunction is_valid_buffer, const char *func_name) {
|
||||
AMS_ASSERT(out != nullptr);
|
||||
AMS_ASSERT(buffer_manager != nullptr);
|
||||
AMS_ASSERT(func_name != nullptr);
|
||||
|
||||
/* Clear the output. */
|
||||
*out = std::pair<uintptr_t, size_t>(0, 0);
|
||||
*out = fs::IBufferManager::MakeMemoryRange(0, 0);
|
||||
|
||||
/* Get the context. */
|
||||
auto context = GetBufferManagerContext();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/fs/impl/fs_newable.hpp>
|
||||
#include <stratosphere/fs/fs_i_buffer_manager.hpp>
|
||||
|
||||
namespace ams::fssystem {
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/lmem.hpp>
|
||||
#include <stratosphere/fs/fs_memory_management.hpp>
|
||||
#include <stratosphere/fssystem/buffers/fssystem_i_buffer_manager.hpp>
|
||||
#include <stratosphere/fs/fs_i_buffer_manager.hpp>
|
||||
#include <stratosphere/fssystem/buffers/fssystem_file_system_buddy_heap.hpp>
|
||||
|
||||
namespace ams::fssystem {
|
||||
|
||||
class FileSystemBufferManager : public IBufferManager {
|
||||
class FileSystemBufferManager : public fs::IBufferManager {
|
||||
NON_COPYABLE(FileSystemBufferManager);
|
||||
NON_MOVEABLE(FileSystemBufferManager);
|
||||
public:
|
||||
@@ -194,7 +194,7 @@ namespace ams::fssystem {
|
||||
size_t m_peak_free_size;
|
||||
size_t m_peak_total_allocatable_size;
|
||||
size_t m_retried_count;
|
||||
mutable os::SdkRecursiveMutex m_mutex;
|
||||
mutable os::SdkMutex m_mutex;
|
||||
public:
|
||||
static constexpr size_t QueryWorkBufferSize(s32 max_cache_count, s32 max_order) {
|
||||
const auto buddy_size = FileSystemBuddyHeap::QueryWorkBufferSize(max_order);
|
||||
@@ -269,27 +269,27 @@ namespace ams::fssystem {
|
||||
m_cache_handle_table.Finalize();
|
||||
}
|
||||
private:
|
||||
virtual const std::pair<uintptr_t, size_t> AllocateBufferImpl(size_t size, const BufferAttribute &attr) override;
|
||||
virtual const std::pair<uintptr_t, size_t> DoAllocateBuffer(size_t size, const BufferAttribute &attr) override;
|
||||
|
||||
virtual void DeallocateBufferImpl(uintptr_t address, size_t size) override;
|
||||
virtual void DoDeallocateBuffer(uintptr_t address, size_t size) override;
|
||||
|
||||
virtual CacheHandle RegisterCacheImpl(uintptr_t address, size_t size, const BufferAttribute &attr) override;
|
||||
virtual CacheHandle DoRegisterCache(uintptr_t address, size_t size, const BufferAttribute &attr) override;
|
||||
|
||||
virtual const std::pair<uintptr_t, size_t> AcquireCacheImpl(CacheHandle handle) override;
|
||||
virtual const std::pair<uintptr_t, size_t> DoAcquireCache(CacheHandle handle) override;
|
||||
|
||||
virtual size_t GetTotalSizeImpl() const override;
|
||||
virtual size_t DoGetTotalSize() const override;
|
||||
|
||||
virtual size_t GetFreeSizeImpl() const override;
|
||||
virtual size_t DoGetFreeSize() const override;
|
||||
|
||||
virtual size_t GetTotalAllocatableSizeImpl() const override;
|
||||
virtual size_t DoGetTotalAllocatableSize() const override;
|
||||
|
||||
virtual size_t GetPeakFreeSizeImpl() const override;
|
||||
virtual size_t DoGetFreeSizePeak() const override;
|
||||
|
||||
virtual size_t GetPeakTotalAllocatableSizeImpl() const override;
|
||||
virtual size_t DoGetTotalAllocatableSizePeak() const override;
|
||||
|
||||
virtual size_t GetRetriedCountImpl() const override;
|
||||
virtual size_t DoGetRetriedCount() const override;
|
||||
|
||||
virtual void ClearPeakImpl() override;
|
||||
virtual void DoClearPeak() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,110 +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 {
|
||||
|
||||
class IBufferManager {
|
||||
public:
|
||||
class BufferAttribute {
|
||||
private:
|
||||
s32 m_level;
|
||||
public:
|
||||
constexpr BufferAttribute() : m_level(0) { /* ... */ }
|
||||
constexpr explicit BufferAttribute(s32 l) : m_level(l) { /* ... */ }
|
||||
|
||||
constexpr s32 GetLevel() const { return m_level; }
|
||||
};
|
||||
|
||||
using CacheHandle = s64;
|
||||
|
||||
static constexpr s32 BufferLevelMin = 0;
|
||||
public:
|
||||
virtual ~IBufferManager() { /* ... */ }
|
||||
|
||||
const std::pair<uintptr_t, size_t> AllocateBuffer(size_t size, const BufferAttribute &attr) {
|
||||
return this->AllocateBufferImpl(size, attr);
|
||||
}
|
||||
|
||||
const std::pair<uintptr_t, size_t> AllocateBuffer(size_t size) {
|
||||
return this->AllocateBufferImpl(size, BufferAttribute());
|
||||
}
|
||||
|
||||
void DeallocateBuffer(uintptr_t address, size_t size) {
|
||||
return this->DeallocateBufferImpl(address, size);
|
||||
}
|
||||
|
||||
CacheHandle RegisterCache(uintptr_t address, size_t size, const BufferAttribute &attr) {
|
||||
return this->RegisterCacheImpl(address, size, attr);
|
||||
}
|
||||
|
||||
const std::pair<uintptr_t, size_t> AcquireCache(CacheHandle handle) {
|
||||
return this->AcquireCacheImpl(handle);
|
||||
}
|
||||
|
||||
size_t GetTotalSize() const {
|
||||
return this->GetTotalSizeImpl();
|
||||
}
|
||||
|
||||
size_t GetFreeSize() const {
|
||||
return this->GetFreeSizeImpl();
|
||||
}
|
||||
|
||||
size_t GetTotalAllocatableSize() const {
|
||||
return this->GetTotalAllocatableSizeImpl();
|
||||
}
|
||||
|
||||
size_t GetPeakFreeSize() const {
|
||||
return this->GetPeakFreeSizeImpl();
|
||||
}
|
||||
|
||||
size_t GetPeakTotalAllocatableSize() const {
|
||||
return this->GetPeakTotalAllocatableSizeImpl();
|
||||
}
|
||||
|
||||
size_t GetRetriedCount() const {
|
||||
return this->GetRetriedCountImpl();
|
||||
}
|
||||
|
||||
void ClearPeak() {
|
||||
return this->ClearPeakImpl();
|
||||
}
|
||||
protected:
|
||||
virtual const std::pair<uintptr_t, size_t> AllocateBufferImpl(size_t size, const BufferAttribute &attr) = 0;
|
||||
|
||||
virtual void DeallocateBufferImpl(uintptr_t address, size_t size) = 0;
|
||||
|
||||
virtual CacheHandle RegisterCacheImpl(uintptr_t address, size_t size, const BufferAttribute &attr) = 0;
|
||||
|
||||
virtual const std::pair<uintptr_t, size_t> AcquireCacheImpl(CacheHandle handle) = 0;
|
||||
|
||||
virtual size_t GetTotalSizeImpl() const = 0;
|
||||
|
||||
virtual size_t GetFreeSizeImpl() const = 0;
|
||||
|
||||
virtual size_t GetTotalAllocatableSizeImpl() const = 0;
|
||||
|
||||
virtual size_t GetPeakFreeSizeImpl() const = 0;
|
||||
|
||||
virtual size_t GetPeakTotalAllocatableSizeImpl() const = 0;
|
||||
|
||||
virtual size_t GetRetriedCountImpl() const = 0;
|
||||
|
||||
virtual void ClearPeakImpl() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user