Core: pass down Core::System reference to all services (#4272)

* Core: pass down Core::System reference to all services

This has to be done at once due to unified interface used by HLE/LLE switcher

* apt: eliminate Core::System::GetInstance

* gpu_gsp: eliminate Core::System::GetInstance in service

* hid: eliminate Core::System::GetInstance

* nwm: eliminate Core::System::GetInstance

* err_f: eliminate Core::System::GetInstance
This commit is contained in:
Weiyi Wang 2018-10-05 10:59:43 -04:00 committed by GitHub
parent 008242c5f3
commit b163502744
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 329 additions and 111 deletions

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <vector>
#include "core/core.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/gsp/gsp.h"
@ -23,8 +24,9 @@ void SignalInterrupt(InterruptId interrupt_id) {
return gpu->SignalInterrupt(interrupt_id);
}
void InstallInterfaces(SM::ServiceManager& service_manager) {
auto gpu = std::make_shared<GSP_GPU>();
void InstallInterfaces(Core::System& system) {
auto& service_manager = system.ServiceManager();
auto gpu = std::make_shared<GSP_GPU>(system);
gpu->InstallAsService(service_manager);
gsp_gpu = gpu;

View file

@ -11,6 +11,10 @@
#include "core/hle/service/gsp/gsp_gpu.h"
#include "core/hle/service/gsp/gsp_lcd.h"
namespace Core {
class System;
}
namespace Service::GSP {
/**
* Retrieves the framebuffer info stored in the GSP shared memory for the
@ -27,5 +31,5 @@ FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index);
*/
void SignalInterrupt(InterruptId interrupt_id);
void InstallInterfaces(SM::ServiceManager& service_manager);
void InstallInterfaces(Core::System& system);
} // namespace Service::GSP

View file

@ -731,7 +731,7 @@ void GSP_GPU::SetLedForceOff(Kernel::HLERequestContext& ctx) {
u8 state = rp.Pop<u8>();
Core::System::GetInstance().GetSharedPageHandler()->Set3DLed(state);
system.GetSharedPageHandler()->Set3DLed(state);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
@ -749,7 +749,7 @@ SessionData* GSP_GPU::FindRegisteredThreadData(u32 thread_id) {
return nullptr;
}
GSP_GPU::GSP_GPU() : ServiceFramework("gsp::Gpu", 2) {
GSP_GPU::GSP_GPU(Core::System& system) : ServiceFramework("gsp::Gpu", 2), system(system) {
static const FunctionInfo functions[] = {
{0x00010082, &GSP_GPU::WriteHWRegs, "WriteHWRegs"},
{0x00020084, &GSP_GPU::WriteHWRegsWithMask, "WriteHWRegsWithMask"},

View file

@ -13,6 +13,10 @@
#include "core/hle/result.h"
#include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Kernel {
class SharedMemory;
} // namespace Kernel
@ -192,7 +196,7 @@ struct SessionData : public Kernel::SessionRequestHandler::SessionDataBase {
class GSP_GPU final : public ServiceFramework<GSP_GPU, SessionData> {
public:
GSP_GPU();
explicit GSP_GPU(Core::System& system);
~GSP_GPU() = default;
void ClientDisconnected(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
@ -399,6 +403,8 @@ private:
/// Returns the session data for the specified registered thread id, or nullptr if not found.
SessionData* FindRegisteredThreadData(u32 thread_id);
Core::System& system;
/// GSP shared memory
Kernel::SharedPtr<Kernel::SharedMemory> shared_memory;