Skip to content

Commit fc91354

Browse files
author
N3xoX1
committed
Add GetPMControlMetadata to ISystemloader and some code clean up
1 parent d62ba93 commit fc91354

7 files changed

Lines changed: 25 additions & 68 deletions

File tree

src/nxemu-loader/core/file_sys/registered_cache.cpp

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ VirtualFile ContentProvider::GetEntryRaw(ContentProviderEntry entry) const {
122122
return GetEntryRaw(entry.titleID, entry.type);
123123
}
124124

125-
std::unique_ptr<NCA> ContentProvider::GetEntryNCA(ContentProviderEntry entry) const {
126-
return GetEntryNCA(entry.titleID, entry.type);
127-
}
128-
129125
std::vector<ContentProviderEntry> ContentProvider::ListEntries() const {
130126
return ListEntriesFilter(std::nullopt, std::nullopt, std::nullopt);
131127
}
@@ -491,14 +487,10 @@ VirtualFile RegisteredCache::GetEntryRaw(u64 title_id, LoaderContentRecordType t
491487
}
492488

493489
IFileSysNCA * RegisteredCache::GetEntry(u64 title_id, LoaderContentRecordType type) const {
494-
return GetEntryNCA(title_id, type).release();
495-
}
496-
497-
std::unique_ptr<NCA> RegisteredCache::GetEntryNCA(u64 title_id, LoaderContentRecordType type) const {
498490
const auto raw = GetEntryRaw(title_id, type);
499491
if (raw == nullptr)
500492
return nullptr;
501-
return std::make_unique<NCA>(raw);
493+
return std::make_unique<NCA>(raw).release();
502494
}
503495

504496
template <typename T>
@@ -816,19 +808,6 @@ VirtualFile ContentProviderUnion::GetEntryRaw(u64 title_id, LoaderContentRecordT
816808
return nullptr;
817809
}
818810

819-
std::unique_ptr<NCA> ContentProviderUnion::GetEntryNCA(u64 title_id, LoaderContentRecordType type) const {
820-
for (const auto& provider : providers) {
821-
if (provider.second == nullptr)
822-
continue;
823-
824-
auto res = provider.second->GetEntryNCA(title_id, type);
825-
if (res != nullptr)
826-
return res;
827-
}
828-
829-
return nullptr;
830-
}
831-
832811
std::vector<ContentProviderEntry> ContentProviderUnion::ListEntriesFilter(
833812
std::optional<LoaderTitleType> title_type, std::optional<LoaderContentRecordType> record_type,
834813
std::optional<u64> title_id) const {
@@ -924,13 +903,6 @@ VirtualFile ManualContentProvider::GetEntryRaw(u64 title_id, LoaderContentRecord
924903
return iter->second;
925904
}
926905

927-
std::unique_ptr<NCA> ManualContentProvider::GetEntryNCA(u64 title_id, LoaderContentRecordType type) const {
928-
const auto res = GetEntryRaw(title_id, type);
929-
if (res == nullptr)
930-
return nullptr;
931-
return std::make_unique<NCA>(res);
932-
}
933-
934906
std::vector<ContentProviderEntry> ManualContentProvider::ListEntriesFilter(
935907
std::optional<LoaderTitleType> title_type, std::optional<LoaderContentRecordType> record_type,
936908
std::optional<u64> title_id) const {

src/nxemu-loader/core/file_sys/registered_cache.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ class ContentProvider {
7272
virtual VirtualFile GetEntryRaw(u64 title_id, LoaderContentRecordType type) const = 0;
7373
VirtualFile GetEntryRaw(ContentProviderEntry entry) const;
7474

75-
virtual std::unique_ptr<NCA> GetEntryNCA(u64 title_id, LoaderContentRecordType type) const = 0;
76-
std::unique_ptr<NCA> GetEntryNCA(ContentProviderEntry entry) const;
77-
7875
virtual std::vector<ContentProviderEntry> ListEntries() const;
7976

8077
// If a parameter is not std::nullopt, it will be filtered for from all entries.
@@ -145,7 +142,6 @@ class RegisteredCache :
145142

146143
VirtualFile GetEntryRaw(u64 title_id, LoaderContentRecordType type) const override;
147144

148-
std::unique_ptr<NCA> GetEntryNCA(u64 title_id, LoaderContentRecordType type) const override;
149145

150146
// If a parameter is not std::nullopt, it will be filtered for from all entries.
151147
std::vector<ContentProviderEntry> ListEntriesFilter(
@@ -219,7 +215,6 @@ class ContentProviderUnion : public ContentProvider {
219215
std::optional<u32> GetEntryVersion(u64 title_id) const override;
220216
VirtualFile GetEntryUnparsed(u64 title_id, LoaderContentRecordType type) const override;
221217
VirtualFile GetEntryRaw(u64 title_id, LoaderContentRecordType type) const override;
222-
std::unique_ptr<NCA> GetEntryNCA(u64 title_id, LoaderContentRecordType type) const override;
223218
std::vector<ContentProviderEntry> ListEntriesFilter(
224219
std::optional<LoaderTitleType> title_type, std::optional<LoaderContentRecordType> record_type,
225220
std::optional<u64> title_id) const override;
@@ -249,7 +244,6 @@ class ManualContentProvider : public ContentProvider {
249244
std::optional<u32> GetEntryVersion(u64 title_id) const override;
250245
VirtualFile GetEntryUnparsed(u64 title_id, LoaderContentRecordType type) const override;
251246
VirtualFile GetEntryRaw(u64 title_id, LoaderContentRecordType type) const override;
252-
std::unique_ptr<NCA> GetEntryNCA(u64 title_id, LoaderContentRecordType type) const override;
253247
std::vector<ContentProviderEntry> ListEntriesFilter(
254248
std::optional<LoaderTitleType> title_type, std::optional<LoaderContentRecordType> record_type,
255249
std::optional<u64> title_id) const override;

src/nxemu-loader/core/loader/loader.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
#include "core/file_sys/control_metadata.h"
1717
#include "core/file_sys/vfs/vfs.h"
1818

19-
namespace Core {
20-
class System;
21-
}
19+
class Systemloader;
2220

23-
namespace FileSys {
21+
namespace FileSys
22+
{
2423
class NACP;
2524
} // namespace FileSys
2625

@@ -98,7 +97,7 @@ class AppLoader {
9897
*
9998
* @return The status result of the operation.
10099
*/
101-
virtual LoadResult Load(Kernel::KProcess& process, Core::System& system) = 0;
100+
virtual LoadResult Load(Systemloader & loader) = 0;
102101

103102
/**
104103
* Try to verify the integrity of the file.
@@ -264,7 +263,7 @@ class AppLoader {
264263
*
265264
* @return the best loader for this file.
266265
*/
267-
std::unique_ptr<AppLoader> GetLoader(Core::System& system, FileSys::VirtualFile file,
268-
u64 program_id = 0, std::size_t program_index = 0);
266+
std::unique_ptr<AppLoader> GetLoader(Systemloader & loader, FileSys::VirtualFile file,
267+
uint64_t program_id = 0, std::size_t program_index = 0);
269268

270269
} // namespace Loader

src/nxemu-loader/core/loader/nso.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ class AppLoader_NSO final : public AppLoader {
8989
return IdentifyType(file);
9090
}
9191

92-
static std::optional<VAddr> LoadModule(Kernel::KProcess& process, Core::System& system,
92+
static std::optional<VAddr> LoadModule(Systemloader & loader,
9393
const FileSys::VfsFile& nso_file, VAddr load_base,
9494
bool should_pass_arguments, bool load_into_process,
9595
std::optional<FileSys::PatchManager> pm = {},
9696
std::vector<Core::NCE::Patcher>* patches = nullptr,
9797
s32 patch_index = -1);
9898

99-
LoadResult Load(Kernel::KProcess& process, Core::System& system) override;
99+
LoadResult Load(Systemloader & loader) override;
100100

101-
ResultStatus ReadNSOModules(Modules& out_modules) override;
101+
LoaderResultStatus ReadNSOModules(Modules& out_modules) override;
102102

103103
private:
104104
Modules modules;

src/nxemu-loader/system_loader.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ struct Systemloader::Impl {
1818
m_loader(loader),
1919
m_system(system),
2020
m_fsController(loader),
21-
m_provider(std::make_unique<FileSys::ManualContentProvider>()),
22-
m_processID(0),
2321
m_titleID(0)
2422
{
2523
}
@@ -33,9 +31,7 @@ struct Systemloader::Impl {
3331
/// ContentProviderUnion instance
3432
std::unique_ptr<FileSys::ContentProviderUnion> m_contentProvider;
3533
FileSys::FileSystemController m_fsController;
36-
std::unique_ptr<FileSys::ManualContentProvider> m_provider;
3734
std::unique_ptr<Nro> m_nro;
38-
uint64_t m_processID;
3935
uint64_t m_titleID;
4036
};
4137

@@ -56,7 +52,6 @@ bool Systemloader::Initialize(void)
5652
if (impl->m_contentProvider == nullptr) {
5753
impl->m_contentProvider = std::make_unique<FileSys::ContentProviderUnion>();
5854
}
59-
impl->m_contentProvider->SetSlot(FileSys::ContentProviderUnionSlot::FrontendManual, impl->m_provider.get());
6055
GetFileSystemController().CreateFactories(*GetFilesystem(), false);
6156
return true;
6257
}
@@ -99,10 +94,6 @@ ISwitchSystem & Systemloader::GetSystem() {
9994
return impl->m_system;
10095
}
10196

102-
FileSys::ContentProvider & Systemloader::GetContentProvider() {
103-
return *impl->m_contentProvider;
104-
}
105-
10697
FileSys::VirtualFilesystem Systemloader::GetFilesystem() {
10798
return impl->m_virtualFilesystem;
10899
}
@@ -116,16 +107,6 @@ void Systemloader::RegisterContentProvider(FileSys::ContentProviderUnionSlot slo
116107
impl->m_contentProvider->SetSlot(slot, provider);
117108
}
118109

119-
void Systemloader::SetProcessID(uint64_t processID)
120-
{
121-
impl->m_processID = processID;
122-
}
123-
124-
void Systemloader::SetTitleID(uint64_t titleID)
125-
{
126-
impl->m_titleID = titleID;
127-
}
128-
129110
bool Systemloader::Impl::LoadNRO(const char* nroFile)
130111
{
131112
Path filePath(nroFile);
@@ -203,3 +184,9 @@ IFileSysNCA * Systemloader::GetContentProviderEntry(uint64_t title_id, LoaderCon
203184
UNIMPLEMENTED();
204185
return nullptr;
205186
}
187+
188+
IFileSysNACP * Systemloader::GetPMControlMetadata(uint64_t programID)
189+
{
190+
UNIMPLEMENTED();
191+
return nullptr;
192+
}

src/nxemu-loader/system_loader.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ class Systemloader :
2020
~Systemloader();
2121

2222
ISwitchSystem & GetSystem();
23-
FileSys::ContentProvider & GetContentProvider();
2423
FileSys::VirtualFilesystem GetFilesystem();
2524
FileSys::FileSystemController & GetFileSystemController();
2625
void RegisterContentProvider(FileSys::ContentProviderUnionSlot slot, FileSys::ContentProvider* provider);
2726

28-
void SetProcessID(uint64_t processID);
29-
void SetTitleID(uint64_t titleID);
30-
3127
//ISystemloader
3228
bool Initialize() override;
3329
bool SelectAndLoad(void * parentWindow) override;
@@ -38,6 +34,7 @@ class Systemloader :
3834
uint32_t GetContentProviderEntriesCount(bool useTitleType, LoaderTitleType titleType, bool useContentRecordType, LoaderContentRecordType contentRecordType, bool useTitleId, unsigned long long titleId) override;
3935
uint32_t GetContentProviderEntries(bool useTitleType, LoaderTitleType titleType, bool useContentRecordType, LoaderContentRecordType contentRecordType, bool useTitleId, unsigned long long titleId, ContentProviderEntry * entries, uint32_t entryCount) override;
4036
IFileSysNCA * GetContentProviderEntry(uint64_t title_id, LoaderContentRecordType type) override;
37+
IFileSysNACP * GetPMControlMetadata(uint64_t programID) override;
4138

4239
private:
4340
Systemloader() = delete;

src/nxemu-module-spec/system_loader.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ __interface IRomFsController
129129
void Release() = 0;
130130
};
131131

132+
__interface IFileSysNACP
133+
{
134+
uint32_t GetParentalControlFlag() const = 0;
135+
bool GetRatingAge(uint8_t * buffer, uint32_t bufferSize) const = 0;
136+
void Release() = 0;
137+
};
138+
132139
__interface IFileSysNCA
133140
{
134141
LoaderResultStatus GetStatus() const = 0;
@@ -159,6 +166,7 @@ __interface ISystemloader
159166
uint32_t GetContentProviderEntriesCount(bool useTitleType, LoaderTitleType titleType, bool useContentRecordType, LoaderContentRecordType contentRecordType, bool useTitleId, unsigned long long titleId) = 0;
160167
uint32_t GetContentProviderEntries(bool useTitleType, LoaderTitleType titleType, bool useContentRecordType, LoaderContentRecordType contentRecordType, bool useTitleId, unsigned long long titleId, ContentProviderEntry* entries, uint32_t entryCount) = 0;
161168
IFileSysNCA * GetContentProviderEntry(uint64_t title_id, LoaderContentRecordType type) = 0;
169+
IFileSysNACP * GetPMControlMetadata(uint64_t programID) = 0;
162170
};
163171

164172
EXPORT ISystemloader * CALL CreateSystemLoader(ISwitchSystem & system);

0 commit comments

Comments
 (0)