yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

Deglobalize System: NFP

This commit is contained in:
David Marcec 2019-09-21 19:03:20 +10:00
parent 482a03f8a5
commit 8df2a98f75
4 changed files with 16 additions and 14 deletions

View File

@ -23,9 +23,9 @@ constexpr ResultCode ERR_TAG_FAILED(ErrorModule::NFP,
constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152); constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152);
} // namespace ErrCodes } // namespace ErrCodes
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) Module::Interface::Interface(std::shared_ptr<Module> module, Core::System& system, const char* name)
: ServiceFramework(name), module(std::move(module)) { : ServiceFramework(name), module(std::move(module)), system(system) {
auto& kernel = Core::System::GetInstance().Kernel(); auto& kernel = system.Kernel();
nfc_tag_load = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic, nfc_tag_load = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Automatic,
"IUser:NFCTagDetected"); "IUser:NFCTagDetected");
} }
@ -34,8 +34,8 @@ Module::Interface::~Interface() = default;
class IUser final : public ServiceFramework<IUser> { class IUser final : public ServiceFramework<IUser> {
public: public:
IUser(Module::Interface& nfp_interface) IUser(Module::Interface& nfp_interface, Core::System& system)
: ServiceFramework("NFP::IUser"), nfp_interface(nfp_interface) { : ServiceFramework("NFP::IUser"), nfp_interface(nfp_interface), system(system) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &IUser::Initialize, "Initialize"}, {0, &IUser::Initialize, "Initialize"},
{1, &IUser::Finalize, "Finalize"}, {1, &IUser::Finalize, "Finalize"},
@ -65,7 +65,7 @@ public:
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
auto& kernel = Core::System::GetInstance().Kernel(); auto& kernel = system.Kernel();
deactivate_event = Kernel::WritableEvent::CreateEventPair( deactivate_event = Kernel::WritableEvent::CreateEventPair(
kernel, Kernel::ResetType::Automatic, "IUser:DeactivateEvent"); kernel, Kernel::ResetType::Automatic, "IUser:DeactivateEvent");
availability_change_event = Kernel::WritableEvent::CreateEventPair( availability_change_event = Kernel::WritableEvent::CreateEventPair(
@ -324,6 +324,7 @@ private:
Kernel::EventPair deactivate_event; Kernel::EventPair deactivate_event;
Kernel::EventPair availability_change_event; Kernel::EventPair availability_change_event;
const Module::Interface& nfp_interface; const Module::Interface& nfp_interface;
Core::System& system;
}; };
void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {
@ -331,7 +332,7 @@ void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 2, 0, 1}; IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<IUser>(*this); rb.PushIpcInterface<IUser>(*this, system);
} }
bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) { bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {
@ -353,9 +354,9 @@ const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const
return amiibo; return amiibo;
} }
void InstallInterfaces(SM::ServiceManager& service_manager) { void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
auto module = std::make_shared<Module>(); auto module = std::make_shared<Module>();
std::make_shared<NFP_User>(module)->InstallAsService(service_manager); std::make_shared<NFP_User>(module, system)->InstallAsService(service_manager);
} }
} // namespace Service::NFP } // namespace Service::NFP

View File

@ -16,7 +16,7 @@ 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, Core::System& system, const char* name);
~Interface() override; ~Interface() override;
struct ModelInfo { struct ModelInfo {
@ -43,9 +43,10 @@ public:
protected: protected:
std::shared_ptr<Module> module; std::shared_ptr<Module> module;
Core::System& system;
}; };
}; };
void InstallInterfaces(SM::ServiceManager& service_manager); void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
} // namespace Service::NFP } // namespace Service::NFP

View File

@ -6,8 +6,8 @@
namespace Service::NFP { namespace Service::NFP {
NFP_User::NFP_User(std::shared_ptr<Module> module) NFP_User::NFP_User(std::shared_ptr<Module> module, Core::System& system)
: Module::Interface(std::move(module), "nfp:user") { : Module::Interface(std::move(module), system, "nfp:user") {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &NFP_User::CreateUserInterface, "CreateUserInterface"}, {0, &NFP_User::CreateUserInterface, "CreateUserInterface"},
}; };

View File

@ -10,7 +10,7 @@ namespace Service::NFP {
class NFP_User final : public Module::Interface { class NFP_User final : public Module::Interface {
public: public:
explicit NFP_User(std::shared_ptr<Module> module); explicit NFP_User(std::shared_ptr<Module> module, Core::System& system);
~NFP_User() override; ~NFP_User() override;
}; };