mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-21 19:12:42 +02:00
ams_mitm: update to use new NcaFileSystemDriver intf
This commit is contained in:
parent
513c5e732a
commit
936b36fc6e
@ -28,7 +28,7 @@ namespace ams::fssystem {
|
|||||||
Result QueryNextOffset(s64 *out, s64 start_offset, s64 end_offset, s64 access_size, s64 alignment_size);
|
Result QueryNextOffset(s64 *out, s64 start_offset, s64 end_offset, s64 access_size, s64 alignment_size);
|
||||||
public:
|
public:
|
||||||
virtual Result QueryAppropriateOffset(s64 *out, s64 offset, s64 access_size, s64 alignment_size) = 0;
|
virtual Result QueryAppropriateOffset(s64 *out, s64 offset, s64 access_size, s64 alignment_size) = 0;
|
||||||
virtual Result QueryInvocationCount(s64 *out, s64 start_offset, s64 end_offset, s64 access_size, s64 alignment_size);
|
virtual Result QueryInvocationCount(s64 *out, s64 start_offset, s64 end_offset, s64 access_size, s64 alignment_size) { AMS_UNUSED(out, start_offset, end_offset, access_size, alignment_size); AMS_ABORT("TODO"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class DefaultAsynchronousAccessSplitter final : public IAsynchronousAccessSplitter {
|
class DefaultAsynchronousAccessSplitter final : public IAsynchronousAccessSplitter {
|
||||||
|
@ -56,7 +56,10 @@ namespace ams::fssystem {
|
|||||||
CompressedStorage() { /* ... */ }
|
CompressedStorage() { /* ... */ }
|
||||||
virtual ~CompressedStorage() { this->Finalize(); }
|
virtual ~CompressedStorage() { this->Finalize(); }
|
||||||
|
|
||||||
Result Initialize(MemoryResource *bktr_allocator, IBufferManager *cache_allocator, fs::SubStorage data_storage, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 bktr_entry_count, size_t block_size_max, size_t continuous_reading_size_max, GetDecompressorFunction get_decompressor, size_t cache_size_0, size_t cache_size_1, s32 max_cache_entries);
|
Result Initialize(MemoryResource *bktr_allocator, IBufferManager *cache_allocator, fs::SubStorage data_storage, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 bktr_entry_count, size_t block_size_max, size_t continuous_reading_size_max, GetDecompressorFunction get_decompressor, size_t cache_size_0, size_t cache_size_1, s32 max_cache_entries) {
|
||||||
|
AMS_UNUSED(bktr_allocator, cache_allocator, data_storage, node_storage, entry_storage, bktr_entry_count, block_size_max, continuous_reading_size_max, get_decompressor, cache_size_0, cache_size_1, max_cache_entries);
|
||||||
|
AMS_ABORT("TODO");
|
||||||
|
}
|
||||||
|
|
||||||
void Finalize() {
|
void Finalize() {
|
||||||
AMS_ABORT("TODO");
|
AMS_ABORT("TODO");
|
||||||
@ -70,8 +73,8 @@ namespace ams::fssystem {
|
|||||||
/* return m_core.QueryAppropriateOffsetForAsynchronousAccess(out, offset, access_size, alignment_size); */
|
/* return m_core.QueryAppropriateOffsetForAsynchronousAccess(out, offset, access_size, alignment_size); */
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
virtual Result Read(s64 offset, void *buffer, size_t size) override;
|
virtual Result Read(s64 offset, void *buffer, size_t size) override { AMS_UNUSED(offset, buffer, size); AMS_ABORT("TODO"); }
|
||||||
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
|
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { AMS_UNUSED(dst, dst_size, op_id, offset, size, src, src_size); AMS_ABORT("TODO"); }
|
||||||
|
|
||||||
virtual Result GetSize(s64 *out) override {
|
virtual Result GetSize(s64 *out) override {
|
||||||
AMS_ABORT("TODO");
|
AMS_ABORT("TODO");
|
||||||
|
@ -28,6 +28,8 @@ namespace ams::fssystem {
|
|||||||
/* This should be re-examined when FS is reimplemented. */
|
/* This should be re-examined when FS is reimplemented. */
|
||||||
void InitializeForFileSystemProxy();
|
void InitializeForFileSystemProxy();
|
||||||
|
|
||||||
|
void InitializeForAtmosphereMitm();
|
||||||
|
|
||||||
const ::ams::fssrv::fscreator::FileSystemCreatorInterfaces *GetFileSystemCreatorInterfaces();
|
const ::ams::fssrv::fscreator::FileSystemCreatorInterfaces *GetFileSystemCreatorInterfaces();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -185,6 +185,73 @@ namespace ams::fssystem {
|
|||||||
/* TODO FS-REIMPL: spl::Finalize(); */
|
/* TODO FS-REIMPL: spl::Finalize(); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitializeForAtmosphereMitm() {
|
||||||
|
/* Initialize spl library. */
|
||||||
|
spl::InitializeForFs();
|
||||||
|
|
||||||
|
/* TODO FS-REIMPL: spl::SetIsAvailableAccessKeyHandler(fssrv::IsAvailableAccessKey) */
|
||||||
|
|
||||||
|
/* Determine whether we're prod or dev. */
|
||||||
|
bool is_prod = !spl::IsDevelopment();
|
||||||
|
bool is_development_function_enabled = spl::IsDevelopmentFunctionEnabled();
|
||||||
|
|
||||||
|
/* Set debug flags. */
|
||||||
|
fssrv::SetDebugFlagEnabled(is_development_function_enabled);
|
||||||
|
|
||||||
|
/* Setup our crypto configuration. */
|
||||||
|
SetUpKekAccessKeys(is_prod);
|
||||||
|
|
||||||
|
/* Setup our heap. */
|
||||||
|
InitializeExpHeap();
|
||||||
|
|
||||||
|
/* Initialize buffer allocator. */
|
||||||
|
util::ConstructAt(g_buffer_allocator, g_buffer_pool, BufferPoolSize);
|
||||||
|
util::ConstructAt(g_allocator, GetPointer(g_buffer_allocator));
|
||||||
|
|
||||||
|
/* Set allocators. */
|
||||||
|
/* TODO FS-REIMPL: sf::SetGlobalDefaultMemoryResource() */
|
||||||
|
fs::SetAllocator(AllocateForFileSystemProxy, DeallocateForFileSystemProxy);
|
||||||
|
fssystem::InitializeAllocator(AllocateForFileSystemProxy, DeallocateForFileSystemProxy);
|
||||||
|
fssystem::InitializeAllocatorForSystem(AllocateForFileSystemProxy, DeallocateForFileSystemProxy);
|
||||||
|
|
||||||
|
/* Initialize the buffer manager. */
|
||||||
|
/* TODO FS-REIMPL: os::AllocateMemoryBlock(...); */
|
||||||
|
util::ConstructAt(g_buffer_manager);
|
||||||
|
GetReference(g_buffer_manager).Initialize(MaxCacheCount, reinterpret_cast<uintptr_t>(g_buffer_manager_heap), BufferManagerHeapSize, BlockSize);
|
||||||
|
|
||||||
|
/* TODO FS-REIMPL: os::AllocateMemoryBlock(...); */
|
||||||
|
/* TODO FS-REIMPL: fssrv::storage::CreateDeviceAddressSpace(...); */
|
||||||
|
fssystem::InitializeBufferPool(reinterpret_cast<char *>(g_device_buffer), DeviceBufferSize);
|
||||||
|
|
||||||
|
/* TODO FS-REIMPL: Create Pooled Threads/Stack Usage Reporter, fssystem::RegisterThreadPool. */
|
||||||
|
|
||||||
|
/* TODO FS-REIMPL: fssrv::GetFileSystemProxyServices(), some service creation. */
|
||||||
|
|
||||||
|
/* Initialize fs creators. */
|
||||||
|
/* TODO FS-REIMPL: Revise for accuracy. */
|
||||||
|
util::ConstructAt(g_rom_fs_creator, GetPointer(g_allocator));
|
||||||
|
util::ConstructAt(g_partition_fs_creator);
|
||||||
|
util::ConstructAt(g_storage_on_nca_creator, GetPointer(g_allocator), *GetNcaCryptoConfiguration(is_prod), *GetNcaCompressionConfiguration(), GetPointer(g_buffer_manager), fs::impl::GetNcaHashGeneratorFactorySelector());
|
||||||
|
|
||||||
|
/* TODO FS-REIMPL: Initialize other creators. */
|
||||||
|
g_fs_creator_interfaces = {
|
||||||
|
.rom_fs_creator = GetPointer(g_rom_fs_creator),
|
||||||
|
.partition_fs_creator = GetPointer(g_partition_fs_creator),
|
||||||
|
.storage_on_nca_creator = GetPointer(g_storage_on_nca_creator),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Initialize fssrv. TODO FS-REIMPL: More arguments, more actions taken. */
|
||||||
|
fssrv::InitializeForFileSystemProxy(std::addressof(g_fs_creator_interfaces), GetPointer(g_buffer_manager), is_development_function_enabled);
|
||||||
|
|
||||||
|
/* Disable auto-abort in fs library code. */
|
||||||
|
fs::SetEnabledAutoAbort(false);
|
||||||
|
|
||||||
|
/* Quick sanity check, before we leave. */
|
||||||
|
#if defined(ATMOSPHERE_OS_HORIZON)
|
||||||
|
AMS_ABORT_UNLESS(os::GetCurrentProgramId() == ncm::AtmosphereProgramId::Mitm);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
const ::ams::fssrv::fscreator::FileSystemCreatorInterfaces *GetFileSystemCreatorInterfaces() {
|
const ::ams::fssrv::fscreator::FileSystemCreatorInterfaces *GetFileSystemCreatorInterfaces() {
|
||||||
return std::addressof(g_fs_creator_interfaces);
|
return std::addressof(g_fs_creator_interfaces);
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1022,7 @@ namespace ams::fssystem {
|
|||||||
R_TRY(buffer_hold_storage->GetSize(std::addressof(base_size)));
|
R_TRY(buffer_hold_storage->GetSize(std::addressof(base_size)));
|
||||||
|
|
||||||
/* Check that we're within range. */
|
/* Check that we're within range. */
|
||||||
R_UNLESS(data_region.offset + data_region.size <= base_size, fs::ResultNcaBaseStorageOutOfRangeC());
|
R_UNLESS(hash_region.offset + hash_region.size <= base_size, fs::ResultNcaBaseStorageOutOfRangeC());
|
||||||
R_UNLESS(data_region.offset + data_region.size <= base_size, fs::ResultNcaBaseStorageOutOfRangeC());
|
R_UNLESS(data_region.offset + data_region.size <= base_size, fs::ResultNcaBaseStorageOutOfRangeC());
|
||||||
|
|
||||||
/* Create the master hash storage. */
|
/* Create the master hash storage. */
|
||||||
|
Loading…
Reference in New Issue
Block a user