citra-emu
/
citra
Archived
1
0
Fork 0

remove GetCurrentModule() functions in HLE Services

This commit is contained in:
B3n30 2018-10-11 11:12:07 +02:00
parent 4ee914c7a8
commit 9d53136f20
14 changed files with 99 additions and 69 deletions

View File

@ -246,7 +246,13 @@ void ConfigureSystem::setConfiguration() {
ui->edit_init_time->setDateTime(date_time); ui->edit_init_time->setDateTime(date_time);
if (!enabled) { if (!enabled) {
cfg = Service::CFG::GetCurrentModule();
auto cfg_interface = Core::System::GetInstance()
.ServiceManager()
.GetService<Service::CFG::Module::Interface>("cfg:u");
ASSERT_MSG(cfg_interface, "cfg:u not started!");
cfg = cfg_interface->GetModule();
ASSERT_MSG(cfg, "CFG Module missing!");
ReadSystemSettings(); ReadSystemSettings();
ui->group_system_settings->setEnabled(false); ui->group_system_settings->setEnabled(false);
} else { } else {

View File

@ -135,7 +135,14 @@ ValidationError SoftwareKeyboard::Finalize(const std::string& text, u8 button) {
void DefaultKeyboard::Setup(const Frontend::KeyboardConfig* config) { void DefaultKeyboard::Setup(const Frontend::KeyboardConfig* config) {
SoftwareKeyboard::Setup(config); SoftwareKeyboard::Setup(config);
std::string username = Common::UTF16ToUTF8(Service::CFG::GetCurrentModule()->GetUsername());
auto cfg =
Core::System::GetInstance().ServiceManager().GetService<Service::CFG::Module::Interface>(
"cfg:u");
ASSERT_MSG(cfg, "cfg:u not started!");
auto cfg_module = cfg->GetModule();
ASSERT_MSG(cfg_module, "CFG Module missing!");
std::string username = Common::UTF16ToUTF8(cfg_module->GetUsername());
switch (this->config.button_config) { switch (this->config.button_config) {
case ButtonConfig::None: case ButtonConfig::None:
case ButtonConfig::Single: case ButtonConfig::Single:

View File

@ -69,7 +69,7 @@ static constexpr std::array<AppletTitleData, NumApplets> applet_titleids = {{
// TODO(Subv): Fill in the rest of the titleids // TODO(Subv): Fill in the rest of the titleids
}}; }};
static u64 GetTitleIdForApplet(AppletId id) { static u64 GetTitleIdForApplet(AppletId id, u32 region_value) {
ASSERT_MSG(id != AppletId::None, "Invalid applet id"); ASSERT_MSG(id != AppletId::None, "Invalid applet id");
auto itr = std::find_if(applet_titleids.begin(), applet_titleids.end(), auto itr = std::find_if(applet_titleids.begin(), applet_titleids.end(),
@ -79,7 +79,7 @@ static u64 GetTitleIdForApplet(AppletId id) {
ASSERT_MSG(itr != applet_titleids.end(), "Unknown applet id 0x{:#05X}", static_cast<u32>(id)); ASSERT_MSG(itr != applet_titleids.end(), "Unknown applet id 0x{:#05X}", static_cast<u32>(id));
return itr->title_ids[CFG::GetCurrentModule()->GetRegionValue()]; return itr->title_ids[region_value];
} }
AppletManager::AppletSlotData* AppletManager::GetAppletSlotData(AppletId id) { AppletManager::AppletSlotData* AppletManager::GetAppletSlotData(AppletId id) {
@ -327,8 +327,8 @@ ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) {
// There are some problems with LLE applets. The rasterizer cache gets out of sync // There are some problems with LLE applets. The rasterizer cache gets out of sync
// when the applet is closed. To avoid breaking applications because of the issue, // when the applet is closed. To avoid breaking applications because of the issue,
// we are going to disable loading LLE applets before further fixes are done. // we are going to disable loading LLE applets before further fixes are done.
// auto process = NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id)); // auto process = NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id,
// if (process) { // region_value)); if (process) {
// return RESULT_SUCCESS; // return RESULT_SUCCESS;
// } // }
@ -354,8 +354,8 @@ ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) {
// There are some problems with LLE applets. The rasterizer cache gets out of sync // There are some problems with LLE applets. The rasterizer cache gets out of sync
// when the applet is closed. To avoid breaking applications because of the issue, // when the applet is closed. To avoid breaking applications because of the issue,
// we are going to disable loading LLE applets before further fixes are done. // we are going to disable loading LLE applets before further fixes are done.
// auto process = NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id)); // auto process = NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id,
// if (process) { // region_value)); if (process) {
// return RESULT_SUCCESS; // return RESULT_SUCCESS;
// } // }
@ -465,8 +465,14 @@ ResultVal<AppletManager::AppletInfo> AppletManager::GetAppletInfo(AppletId app_i
ErrorLevel::Status); ErrorLevel::Status);
} }
return MakeResult<AppletInfo>({GetTitleIdForApplet(app_id), Service::FS::MediaType::NAND, auto cfg = system.ServiceManager().GetService<Service::CFG::Module::Interface>("cfg:u");
slot->registered, slot->loaded, slot->attributes.raw}); ASSERT_MSG(cfg, "cfg:u not started!");
auto cfg_module = cfg->GetModule();
ASSERT_MSG(cfg_module, "CFG Module missing!");
u32 region_value = cfg_module->GetRegionValue();
return MakeResult<AppletInfo>({GetTitleIdForApplet(app_id, region_value),
Service::FS::MediaType::NAND, slot->registered, slot->loaded,
slot->attributes.raw});
} }
ResultCode AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type, ResultCode AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type,
@ -548,7 +554,12 @@ void AppletManager::EnsureHomeMenuLoaded() {
return; return;
} }
u64 menu_title_id = GetTitleIdForApplet(AppletId::HomeMenu); auto cfg = system.ServiceManager().GetService<Service::CFG::Module::Interface>("cfg:u");
ASSERT_MSG(cfg, "cfg:u not started!");
auto cfg_module = cfg->GetModule();
ASSERT_MSG(cfg_module, "CFG Module missing!");
u32 region_value = cfg_module->GetRegionValue();
u64 menu_title_id = GetTitleIdForApplet(AppletId::HomeMenu, region_value);
auto process = NS::LaunchTitle(FS::MediaType::NAND, menu_title_id); auto process = NS::LaunchTitle(FS::MediaType::NAND, menu_title_id);
if (!process) { if (!process) {
LOG_WARNING(Service_APT, LOG_WARNING(Service_APT,

View File

@ -5,6 +5,7 @@
#include "common/common_paths.h" #include "common/common_paths.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/string_util.h"
#include "core/core.h" #include "core/core.h"
#include "core/file_sys/archive_ncch.h" #include "core/file_sys/archive_ncch.h"
#include "core/file_sys/file_backend.h" #include "core/file_sys/file_backend.h"
@ -103,7 +104,14 @@ static u32 DecompressLZ11(const u8* in, u8* out) {
bool Module::LoadSharedFont() { bool Module::LoadSharedFont() {
u8 font_region_code; u8 font_region_code;
switch (CFG::GetCurrentModule()->GetRegionValue()) { auto cfg =
Core::System::GetInstance().ServiceManager().GetService<Service::CFG::Module::Interface>(
"cfg:u");
ASSERT_MSG(cfg, "cfg:u not started!");
auto cfg_module = cfg->GetModule();
ASSERT_MSG(cfg_module, "CFG Module missing!");
std::string username = Common::UTF16ToUTF8(cfg_module->GetUsername());
switch (cfg_module->GetRegionValue()) {
case 4: // CHN case 4: // CHN
font_region_code = 2; font_region_code = 2;
break; break;

View File

@ -22,8 +22,6 @@
namespace Service::CAM { namespace Service::CAM {
static std::weak_ptr<Module> current_cam;
// built-in resolution parameters // built-in resolution parameters
constexpr std::array<Resolution, 8> PRESET_RESOLUTION{{ constexpr std::array<Resolution, 8> PRESET_RESOLUTION{{
{640, 480, 0, 0, 639, 479}, // VGA {640, 480, 0, 0, 639, 479}, // VGA
@ -200,6 +198,10 @@ Module::Interface::Interface(std::shared_ptr<Module> cam, const char* name, u32
Module::Interface::~Interface() = default; Module::Interface::~Interface() = default;
std::shared_ptr<Module> Module::Interface::GetModule() const {
return cam;
}
void Module::Interface::StartCapture(Kernel::HLERequestContext& ctx) { void Module::Interface::StartCapture(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x01, 1, 0); IPC::RequestParser rp(ctx, 0x01, 1, 0);
const PortSet port_select(rp.Pop<u8>()); const PortSet port_select(rp.Pop<u8>());
@ -1050,15 +1052,9 @@ void Module::LoadCameraImplementation(CameraConfig& camera, int camera_id) {
camera.impl->SetResolution(camera.contexts[0].resolution); camera.impl->SetResolution(camera.contexts[0].resolution);
} }
void ReloadCameraDevices() {
if (auto cam = current_cam.lock())
cam->ReloadCameraDevices();
}
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
auto cam = std::make_shared<Module>(); auto cam = std::make_shared<Module>();
current_cam = cam;
std::make_shared<CAM_U>(cam)->InstallAsService(service_manager); std::make_shared<CAM_U>(cam)->InstallAsService(service_manager);
std::make_shared<CAM_S>(cam)->InstallAsService(service_manager); std::make_shared<CAM_S>(cam)->InstallAsService(service_manager);

View File

@ -250,6 +250,8 @@ public:
Interface(std::shared_ptr<Module> cam, const char* name, u32 max_session); Interface(std::shared_ptr<Module> cam, const char* name, u32 max_session);
~Interface(); ~Interface();
std::shared_ptr<Module> GetModule() const;
protected: protected:
/** /**
* Starts capturing at the selected port. * Starts capturing at the selected port.
@ -783,9 +785,6 @@ private:
std::atomic<bool> is_camera_reload_pending{false}; std::atomic<bool> is_camera_reload_pending{false};
}; };
/// Reload camera devices. Used when input configuration changed
void ReloadCameraDevices();
void InstallInterfaces(Core::System& system); void InstallInterfaces(Core::System& system);
} // namespace Service::CAM } // namespace Service::CAM

View File

@ -114,14 +114,6 @@ static const std::vector<u8> cfg_system_savedata_id = {
0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x01, 0x00,
}; };
static std::weak_ptr<Module> current_cfg;
std::shared_ptr<Module> GetCurrentModule() {
auto cfg = current_cfg.lock();
ASSERT_MSG(cfg, "No CFG module running!");
return cfg;
}
Module::Interface::Interface(std::shared_ptr<Module> cfg, const char* name, u32 max_session) Module::Interface::Interface(std::shared_ptr<Module> cfg, const char* name, u32 max_session)
: ServiceFramework(name, max_session), cfg(std::move(cfg)) {} : ServiceFramework(name, max_session), cfg(std::move(cfg)) {}
@ -145,6 +137,10 @@ void Module::Interface::GetCountryCodeString(Kernel::HLERequestContext& ctx) {
rb.Push<u32>(country_codes[country_code_id]); rb.Push<u32>(country_codes[country_code_id]);
} }
std::shared_ptr<Module> Module::Interface::GetModule() const {
return cfg;
}
void Module::Interface::GetCountryCodeID(Kernel::HLERequestContext& ctx) { void Module::Interface::GetCountryCodeID(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x0A, 1, 0); IPC::RequestParser rp(ctx, 0x0A, 1, 0);
u16 country_code = rp.Pop<u16>(); u16 country_code = rp.Pop<u16>();
@ -729,7 +725,6 @@ void InstallInterfaces(Core::System& system) {
std::make_shared<CFG_S>(cfg)->InstallAsService(service_manager); std::make_shared<CFG_S>(cfg)->InstallAsService(service_manager);
std::make_shared<CFG_U>(cfg)->InstallAsService(service_manager); std::make_shared<CFG_U>(cfg)->InstallAsService(service_manager);
std::make_shared<CFG_NOR>()->InstallAsService(service_manager); std::make_shared<CFG_NOR>()->InstallAsService(service_manager);
current_cfg = cfg;
} }
} // namespace Service::CFG } // namespace Service::CFG

View File

@ -97,6 +97,8 @@ public:
Interface(std::shared_ptr<Module> cfg, const char* name, u32 max_session); Interface(std::shared_ptr<Module> cfg, const char* name, u32 max_session);
~Interface(); ~Interface();
std::shared_ptr<Module> GetModule() const;
/** /**
* CFG::GetCountryCodeString service function * CFG::GetCountryCodeString service function
* Inputs: * Inputs:
@ -117,8 +119,6 @@ public:
*/ */
void GetCountryCodeID(Kernel::HLERequestContext& ctx); void GetCountryCodeID(Kernel::HLERequestContext& ctx);
u32 GetRegionValue();
/** /**
* CFG::SecureInfoGetRegion service function * CFG::SecureInfoGetRegion service function
* Inputs: * Inputs:
@ -412,6 +412,5 @@ private:
}; };
void InstallInterfaces(Core::System& system); void InstallInterfaces(Core::System& system);
std::shared_ptr<Module> GetCurrentModule();
} // namespace Service::CFG } // namespace Service::CFG

View File

@ -21,8 +21,6 @@
namespace Service::HID { namespace Service::HID {
static std::weak_ptr<Module> current_module;
// Updating period for each HID device. These empirical values are measured from a 11.2 3DS. // Updating period for each HID device. These empirical values are measured from a 11.2 3DS.
constexpr u64 pad_update_ticks = BASE_CLOCK_RATE_ARM11 / 234; constexpr u64 pad_update_ticks = BASE_CLOCK_RATE_ARM11 / 234;
constexpr u64 accelerometer_update_ticks = BASE_CLOCK_RATE_ARM11 / 104; constexpr u64 accelerometer_update_ticks = BASE_CLOCK_RATE_ARM11 / 104;
@ -354,6 +352,10 @@ void Module::Interface::GetSoundVolume(Kernel::HLERequestContext& ctx) {
Module::Interface::Interface(std::shared_ptr<Module> hid, const char* name, u32 max_session) Module::Interface::Interface(std::shared_ptr<Module> hid, const char* name, u32 max_session)
: ServiceFramework(name, max_session), hid(std::move(hid)) {} : ServiceFramework(name, max_session), hid(std::move(hid)) {}
std::shared_ptr<Module> Module::Interface::GetModule() const {
return hid;
}
Module::Module(Core::System& system) : system(system) { Module::Module(Core::System& system) : system(system) {
using namespace Kernel; using namespace Kernel;
@ -388,17 +390,11 @@ void Module::ReloadInputDevices() {
is_device_reload_pending.store(true); is_device_reload_pending.store(true);
} }
void ReloadInputDevices() {
if (auto hid = current_module.lock())
hid->ReloadInputDevices();
}
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
auto hid = std::make_shared<Module>(system); auto hid = std::make_shared<Module>(system);
std::make_shared<User>(hid)->InstallAsService(service_manager); std::make_shared<User>(hid)->InstallAsService(service_manager);
std::make_shared<Spvr>(hid)->InstallAsService(service_manager); std::make_shared<Spvr>(hid)->InstallAsService(service_manager);
current_module = hid;
} }
} // namespace Service::HID } // namespace Service::HID

View File

@ -208,6 +208,8 @@ public:
public: public:
Interface(std::shared_ptr<Module> hid, const char* name, u32 max_session); Interface(std::shared_ptr<Module> hid, const char* name, u32 max_session);
std::shared_ptr<Module> GetModule() const;
protected: protected:
/** /**
* HID::GetIPCHandles service function * HID::GetIPCHandles service function
@ -336,7 +338,4 @@ private:
}; };
void InstallInterfaces(Core::System& system); void InstallInterfaces(Core::System& system);
/// Reload input devices. Used when input configuration changed
void ReloadInputDevices();
} // namespace Service::HID } // namespace Service::HID

View File

@ -12,28 +12,15 @@
namespace Service::IR { namespace Service::IR {
static std::weak_ptr<IR_RST> current_ir_rst;
static std::weak_ptr<IR_USER> current_ir_user;
void ReloadInputDevices() {
if (auto ir_user = current_ir_user.lock())
ir_user->ReloadInputDevices();
if (auto ir_rst = current_ir_rst.lock())
ir_rst->ReloadInputDevices();
}
void InstallInterfaces(Core::System& system) { void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager(); auto& service_manager = system.ServiceManager();
std::make_shared<IR_U>()->InstallAsService(service_manager); std::make_shared<IR_U>()->InstallAsService(service_manager);
auto ir_user = std::make_shared<IR_USER>(); auto ir_user = std::make_shared<IR_USER>();
ir_user->InstallAsService(service_manager); ir_user->InstallAsService(service_manager);
current_ir_user = ir_user;
auto ir_rst = std::make_shared<IR_RST>(); auto ir_rst = std::make_shared<IR_RST>();
ir_rst->InstallAsService(service_manager); ir_rst->InstallAsService(service_manager);
current_ir_rst = ir_rst;
} }
} // namespace Service::IR } // namespace Service::IR

View File

@ -14,9 +14,6 @@ class ServiceManager;
namespace Service::IR { namespace Service::IR {
/// Reload input devices. Used when input configuration changed
void ReloadInputDevices();
void InstallInterfaces(Core::System& system); void InstallInterfaces(Core::System& system);
} // namespace Service::IR } // namespace Service::IR

View File

@ -144,7 +144,13 @@ void AppLoader_NCCH::ParseRegionLockoutInfo() {
} }
region_lockout >>= 1; region_lockout >>= 1;
} }
Service::CFG::GetCurrentModule()->SetPreferredRegionCodes(regions); auto cfg = Core::System::GetInstance()
.ServiceManager()
.GetService<Service::CFG::Module::Interface>("cfg:u");
ASSERT_MSG(cfg, "cfg:u not started!");
auto cfg_module = cfg->GetModule();
ASSERT_MSG(cfg_module, "CFG Module missing!");
cfg_module->SetPreferredRegionCodes(regions);
} }
} }

View File

@ -6,7 +6,8 @@
#include "core/core.h" #include "core/core.h"
#include "core/gdbstub/gdbstub.h" #include "core/gdbstub/gdbstub.h"
#include "core/hle/service/hid/hid.h" #include "core/hle/service/hid/hid.h"
#include "core/hle/service/ir/ir.h" #include "core/hle/service/ir/ir_rst.h"
#include "core/hle/service/ir/ir_user.h"
#include "core/settings.h" #include "core/settings.h"
#include "video_core/renderer_base.h" #include "video_core/renderer_base.h"
#include "video_core/video_core.h" #include "video_core/video_core.h"
@ -32,14 +33,37 @@ void Apply() {
VideoCore::g_renderer_bg_color_update_requested = true; VideoCore::g_renderer_bg_color_update_requested = true;
if (Core::System::GetInstance().IsPoweredOn()) { auto& system = Core::System::GetInstance();
if (system.IsPoweredOn()) {
Core::DSP().SetSink(values.sink_id, values.audio_device_id); Core::DSP().SetSink(values.sink_id, values.audio_device_id);
Core::DSP().EnableStretching(values.enable_audio_stretching); Core::DSP().EnableStretching(values.enable_audio_stretching);
}
Service::HID::ReloadInputDevices(); auto& sm = system.ServiceManager();
Service::IR::ReloadInputDevices();
Service::CAM::ReloadCameraDevices(); auto hid = sm.GetService<Service::HID::Module::Interface>("hid:USER");
if (hid) {
auto hid_module = hid->GetModule();
if (hid_module) {
hid_module->ReloadInputDevices();
}
}
auto ir_user = sm.GetService<Service::IR::IR_USER>("ir:USER");
if (ir_user)
ir_user->ReloadInputDevices();
auto ir_rst = sm.GetService<Service::IR::IR_RST>("ir:rst");
if (ir_rst)
ir_rst->ReloadInputDevices();
auto cam = sm.GetService<Service::CAM::Module::Interface>("cam:u");
if (cam) {
auto cam_module = cam->GetModule();
if (cam_module) {
cam_module->ReloadCameraDevices();
}
}
}
} }
template <typename T> template <typename T>