mirror of https://git.suyu.dev/suyu/suyu
bcat: Add FSC accessors for BCAT data
Ports BCAT to use FSC interface
This commit is contained in:
parent
bcf1eafb8b
commit
19c466dfb1
|
@ -1140,7 +1140,8 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_AM, "called, kind={:08X}", static_cast<u8>(kind));
|
LOG_DEBUG(Service_AM, "called, kind={:08X}", static_cast<u8>(kind));
|
||||||
|
|
||||||
if (kind == LaunchParameterKind::ApplicationSpecific && !launch_popped_application_specific) {
|
if (kind == LaunchParameterKind::ApplicationSpecific && !launch_popped_application_specific) {
|
||||||
const auto backend = BCAT::CreateBackendFromSettings(&FileSystem::GetBCATDirectory);
|
const auto backend = BCAT::CreateBackendFromSettings(
|
||||||
|
[this](u64 tid) { return system.GetFileSystemController().GetBCATDirectory(tid); });
|
||||||
const auto build_id_full = Core::System::GetInstance().GetCurrentProcessBuildID();
|
const auto build_id_full = Core::System::GetInstance().GetCurrentProcessBuildID();
|
||||||
u64 build_id{};
|
u64 build_id{};
|
||||||
std::memcpy(&build_id, build_id_full.data(), sizeof(u64));
|
std::memcpy(&build_id, build_id_full.data(), sizeof(u64));
|
||||||
|
|
|
@ -57,11 +57,6 @@ static_assert(sizeof(DeliveryCacheProgressImpl) == 0x200,
|
||||||
class ProgressServiceBackend {
|
class ProgressServiceBackend {
|
||||||
friend class IBcatService;
|
friend class IBcatService;
|
||||||
|
|
||||||
ProgressServiceBackend(std::string event_name);
|
|
||||||
|
|
||||||
Kernel::SharedPtr<Kernel::ReadableEvent> GetEvent();
|
|
||||||
DeliveryCacheProgressImpl& GetImpl();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Clients should call this with true if any of the functions are going to be called from a
|
// Clients should call this with true if any of the functions are going to be called from a
|
||||||
// non-HLE thread and this class need to lock the hle mutex. (default is false)
|
// non-HLE thread and this class need to lock the hle mutex. (default is false)
|
||||||
|
@ -90,6 +85,11 @@ public:
|
||||||
void FinishDownload(ResultCode result);
|
void FinishDownload(ResultCode result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
explicit ProgressServiceBackend(std::string event_name);
|
||||||
|
|
||||||
|
Kernel::SharedPtr<Kernel::ReadableEvent> GetEvent();
|
||||||
|
DeliveryCacheProgressImpl& GetImpl();
|
||||||
|
|
||||||
void SignalUpdate() const;
|
void SignalUpdate() const;
|
||||||
|
|
||||||
DeliveryCacheProgressImpl impl;
|
DeliveryCacheProgressImpl impl;
|
||||||
|
|
|
@ -364,17 +364,18 @@ void SynchronizeInternal(DirectoryGetter dir_getter, TitleIDVersion title,
|
||||||
|
|
||||||
bool Boxcat::Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) {
|
bool Boxcat::Synchronize(TitleIDVersion title, ProgressServiceBackend& progress) {
|
||||||
is_syncing.exchange(true);
|
is_syncing.exchange(true);
|
||||||
std::thread([this, title, &progress] { SynchronizeInternal(dir_getter, title, progress); })
|
std::thread([this, title, &progress] {
|
||||||
.detach();
|
SynchronizeInternal(dir_getter, title, progress);
|
||||||
|
}).detach();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Boxcat::SynchronizeDirectory(TitleIDVersion title, std::string name,
|
bool Boxcat::SynchronizeDirectory(TitleIDVersion title, std::string name,
|
||||||
ProgressServiceBackend& progress) {
|
ProgressServiceBackend& progress) {
|
||||||
is_syncing.exchange(true);
|
is_syncing.exchange(true);
|
||||||
std::thread(
|
std::thread([this, title, name, &progress] {
|
||||||
[this, title, name, &progress] { SynchronizeInternal(dir_getter, title, progress, name); })
|
SynchronizeInternal(dir_getter, title, progress, name);
|
||||||
.detach();
|
}).detach();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
namespace Service::BCAT {
|
namespace Service::BCAT {
|
||||||
|
|
||||||
BCAT::BCAT(std::shared_ptr<Module> module, const char* name)
|
BCAT::BCAT(std::shared_ptr<Module> module, FileSystem::FileSystemController& fsc, const char* name)
|
||||||
: Module::Interface(std::move(module), name) {
|
: Module::Interface(std::move(module), fsc, name) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &BCAT::CreateBcatService, "CreateBcatService"},
|
{0, &BCAT::CreateBcatService, "CreateBcatService"},
|
||||||
|
|
|
@ -10,7 +10,8 @@ namespace Service::BCAT {
|
||||||
|
|
||||||
class BCAT final : public Module::Interface {
|
class BCAT final : public Module::Interface {
|
||||||
public:
|
public:
|
||||||
explicit BCAT(std::shared_ptr<Module> module, const char* name);
|
explicit BCAT(std::shared_ptr<Module> module, FileSystem::FileSystemController& fsc,
|
||||||
|
const char* name);
|
||||||
~BCAT() override;
|
~BCAT() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,7 @@ void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestCont
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushIpcInterface<IDeliveryCacheStorageService>(
|
rb.PushIpcInterface<IDeliveryCacheStorageService>(
|
||||||
Service::FileSystem::GetBCATDirectory(Core::CurrentProcess()->GetTitleID()));
|
fsc.GetBCATDirectory(Core::CurrentProcess()->GetTitleID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId(
|
void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId(
|
||||||
|
@ -551,8 +551,7 @@ void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId(
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushIpcInterface<IDeliveryCacheStorageService>(
|
rb.PushIpcInterface<IDeliveryCacheStorageService>(fsc.GetBCATDirectory(title_id));
|
||||||
Service::FileSystem::GetBCATDirectory(title_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Backend> CreateBackendFromSettings(DirectoryGetter getter) {
|
std::unique_ptr<Backend> CreateBackendFromSettings(DirectoryGetter getter) {
|
||||||
|
@ -566,18 +565,23 @@ std::unique_ptr<Backend> CreateBackendFromSettings(DirectoryGetter getter) {
|
||||||
return std::make_unique<NullBackend>(std::move(getter));
|
return std::make_unique<NullBackend>(std::move(getter));
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
Module::Interface::Interface(std::shared_ptr<Module> module, FileSystem::FileSystemController& fsc,
|
||||||
: ServiceFramework(name), module(std::move(module)),
|
const char* name)
|
||||||
backend(CreateBackendFromSettings(&Service::FileSystem::GetBCATDirectory)) {}
|
: ServiceFramework(name), module(std::move(module)), fsc(fsc),
|
||||||
|
backend(CreateBackendFromSettings([&fsc](u64 tid) { return fsc.GetBCATDirectory(tid); })) {}
|
||||||
|
|
||||||
Module::Interface::~Interface() = default;
|
Module::Interface::~Interface() = default;
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
void InstallInterfaces(Core::System& system) {
|
||||||
auto module = std::make_shared<Module>();
|
auto module = std::make_shared<Module>();
|
||||||
std::make_shared<BCAT>(module, "bcat:a")->InstallAsService(service_manager);
|
std::make_shared<BCAT>(module, system.GetFileSystemController(), "bcat:a")
|
||||||
std::make_shared<BCAT>(module, "bcat:m")->InstallAsService(service_manager);
|
->InstallAsService(system.ServiceManager());
|
||||||
std::make_shared<BCAT>(module, "bcat:u")->InstallAsService(service_manager);
|
std::make_shared<BCAT>(module, system.GetFileSystemController(), "bcat:m")
|
||||||
std::make_shared<BCAT>(module, "bcat:s")->InstallAsService(service_manager);
|
->InstallAsService(system.ServiceManager());
|
||||||
|
std::make_shared<BCAT>(module, system.GetFileSystemController(), "bcat:u")
|
||||||
|
->InstallAsService(system.ServiceManager());
|
||||||
|
std::make_shared<BCAT>(module, system.GetFileSystemController(), "bcat:s")
|
||||||
|
->InstallAsService(system.ServiceManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::BCAT
|
} // namespace Service::BCAT
|
||||||
|
|
|
@ -6,7 +6,13 @@
|
||||||
|
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
namespace Service::BCAT {
|
namespace Service {
|
||||||
|
|
||||||
|
namespace FileSystem {
|
||||||
|
class FileSystemController;
|
||||||
|
} // namespace FileSystem
|
||||||
|
|
||||||
|
namespace BCAT {
|
||||||
|
|
||||||
class Backend;
|
class Backend;
|
||||||
|
|
||||||
|
@ -14,7 +20,8 @@ class Module final {
|
||||||
public:
|
public:
|
||||||
class Interface : public ServiceFramework<Interface> {
|
class Interface : public ServiceFramework<Interface> {
|
||||||
public:
|
public:
|
||||||
explicit Interface(std::shared_ptr<Module> module, const char* name);
|
explicit Interface(std::shared_ptr<Module> module, FileSystem::FileSystemController& fsc,
|
||||||
|
const char* name);
|
||||||
~Interface() override;
|
~Interface() override;
|
||||||
|
|
||||||
void CreateBcatService(Kernel::HLERequestContext& ctx);
|
void CreateBcatService(Kernel::HLERequestContext& ctx);
|
||||||
|
@ -22,12 +29,16 @@ public:
|
||||||
void CreateDeliveryCacheStorageServiceWithApplicationId(Kernel::HLERequestContext& ctx);
|
void CreateDeliveryCacheStorageServiceWithApplicationId(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
FileSystem::FileSystemController& fsc;
|
||||||
|
|
||||||
std::shared_ptr<Module> module;
|
std::shared_ptr<Module> module;
|
||||||
std::unique_ptr<Backend> backend;
|
std::unique_ptr<Backend> backend;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Registers all BCAT services with the specified service manager.
|
/// Registers all BCAT services with the specified service manager.
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
void InstallInterfaces(Core::System& system);
|
||||||
|
|
||||||
} // namespace Service::BCAT
|
} // namespace BCAT
|
||||||
|
|
||||||
|
} // namespace Service
|
||||||
|
|
|
@ -674,7 +674,7 @@ FileSys::VirtualDir FileSystemController::GetModificationDumpRoot(u64 title_id)
|
||||||
return bis_factory->GetModificationDumpRoot(title_id);
|
return bis_factory->GetModificationDumpRoot(title_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir GetBCATDirectory(u64 title_id) {
|
FileSys::VirtualDir FileSystemController::GetBCATDirectory(u64 title_id) const {
|
||||||
LOG_TRACE(Service_FS, "Opening BCAT root for tid={:016X}", title_id);
|
LOG_TRACE(Service_FS, "Opening BCAT root for tid={:016X}", title_id);
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
|
|
@ -110,6 +110,8 @@ public:
|
||||||
FileSys::VirtualDir GetModificationLoadRoot(u64 title_id) const;
|
FileSys::VirtualDir GetModificationLoadRoot(u64 title_id) const;
|
||||||
FileSys::VirtualDir GetModificationDumpRoot(u64 title_id) const;
|
FileSys::VirtualDir GetModificationDumpRoot(u64 title_id) const;
|
||||||
|
|
||||||
|
FileSys::VirtualDir GetBCATDirectory(u64 title_id) const;
|
||||||
|
|
||||||
// Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function
|
// Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function
|
||||||
// above is called.
|
// above is called.
|
||||||
void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite = true);
|
void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite = true);
|
||||||
|
|
|
@ -208,7 +208,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) {
|
||||||
AOC::InstallInterfaces(*sm, system);
|
AOC::InstallInterfaces(*sm, system);
|
||||||
APM::InstallInterfaces(system);
|
APM::InstallInterfaces(system);
|
||||||
Audio::InstallInterfaces(*sm, system);
|
Audio::InstallInterfaces(*sm, system);
|
||||||
BCAT::InstallInterfaces(*sm);
|
BCAT::InstallInterfaces(system);
|
||||||
BPC::InstallInterfaces(*sm);
|
BPC::InstallInterfaces(*sm);
|
||||||
BtDrv::InstallInterfaces(*sm, system);
|
BtDrv::InstallInterfaces(*sm, system);
|
||||||
BTM::InstallInterfaces(*sm, system);
|
BTM::InstallInterfaces(*sm, system);
|
||||||
|
|
Loading…
Reference in New Issue