service/cecd: Migrate to ServiceFramework

This commit is contained in:
NarcolepticK 2018-06-30 23:27:57 -04:00
parent 4564fc5baa
commit 363d6fdb89
9 changed files with 148 additions and 140 deletions

View file

@ -3,64 +3,62 @@
// Refer to the license.txt file included.
#include "common/logging/log.h"
#include "core/hle/ipc.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/handle_table.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/result.h"
#include "core/hle/service/cecd/cecd.h"
#include "core/hle/service/cecd/cecd_ndm.h"
#include "core/hle/service/cecd/cecd_s.h"
#include "core/hle/service/cecd/cecd_u.h"
#include "core/hle/service/service.h"
namespace Service {
namespace CECD {
static Kernel::SharedPtr<Kernel::Event> cecinfo_event;
static Kernel::SharedPtr<Kernel::Event> change_state_event;
void Module::Interface::GetCecStateAbbreviated(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x0E, 0, 0);
void GetCecStateAbbreviated(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[2] = static_cast<u32>(CecStateAbbreviated::CEC_STATE_ABBREV_IDLE);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push<u32>(static_cast<u32>(CecStateAbbreviated::CEC_STATE_ABBREV_IDLE));
LOG_WARNING(Service_CECD, "(STUBBED) called");
}
void GetCecInfoEventHandle(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
void Module::Interface::GetCecInfoEventHandle(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x0F, 0, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[3] = Kernel::g_handle_table.Create(cecinfo_event).Unwrap(); // Event handle
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.PushCopyObjects(cecd->cecinfo_event);
LOG_WARNING(Service_CECD, "(STUBBED) called");
}
void GetChangeStateEventHandle(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
void Module::Interface::GetChangeStateEventHandle(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x10, 0, 0);
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[3] = Kernel::g_handle_table.Create(change_state_event).Unwrap(); // Event handle
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.PushCopyObjects(cecd->change_state_event);
LOG_WARNING(Service_CECD, "(STUBBED) called");
}
void Init() {
AddService(new CECD_NDM);
AddService(new CECD_S);
AddService(new CECD_U);
Module::Interface::Interface(std::shared_ptr<Module> cecd, const char* name, u32 max_session)
: ServiceFramework(name, max_session), cecd(std::move(cecd)) {}
cecinfo_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD::cecinfo_event");
change_state_event =
Kernel::Event::Create(Kernel::ResetType::OneShot, "CECD::change_state_event");
Module::Module() {
using namespace Kernel;
cecinfo_event = Event::Create(Kernel::ResetType::OneShot, "CECD::cecinfo_event");
change_state_event = Event::Create(Kernel::ResetType::OneShot, "CECD::change_state_event");
}
void Shutdown() {
cecinfo_event = nullptr;
change_state_event = nullptr;
void InstallInterfaces(SM::ServiceManager& service_manager) {
auto cecd = std::make_shared<Module>();
std::make_shared<CECD_NDM>(cecd)->InstallAsService(service_manager);
std::make_shared<CECD_S>(cecd)->InstallAsService(service_manager);
std::make_shared<CECD_U>(cecd)->InstallAsService(service_manager);
}
} // namespace CECD
} // namespace Service

View file

@ -4,10 +4,10 @@
#pragma once
#include "core/hle/kernel/event.h"
#include "core/hle/service/service.h"
namespace Service {
class Interface;
namespace CECD {
enum class CecStateAbbreviated {
@ -20,7 +20,18 @@ enum class CecStateAbbreviated {
/// OVER_BOSS and those listed here
};
/**
class Module final {
public:
Module();
~Module() = default;
class Interface : public ServiceFramework<Interface> {
public:
Interface(std::shared_ptr<Module> cecd, const char* name, u32 max_session);
~Interface() = default;
protected:
/**
* GetCecStateAbbreviated service function
* Inputs:
* 0: 0x000E0000
@ -28,9 +39,9 @@ enum class CecStateAbbreviated {
* 1: ResultCode
* 2: CecStateAbbreviated
*/
void GetCecStateAbbreviated(Service::Interface* self);
void GetCecStateAbbreviated(Kernel::HLERequestContext& ctx);
/**
/**
* GetCecInfoEventHandle service function
* Inputs:
* 0: 0x000F0000
@ -38,9 +49,9 @@ void GetCecStateAbbreviated(Service::Interface* self);
* 1: ResultCode
* 3: Event Handle
*/
void GetCecInfoEventHandle(Service::Interface* self);
void GetCecInfoEventHandle(Kernel::HLERequestContext& ctx);
/**
/**
* GetChangeStateEventHandle service function
* Inputs:
* 0: 0x00100000
@ -48,13 +59,19 @@ void GetCecInfoEventHandle(Service::Interface* self);
* 1: ResultCode
* 3: Event Handle
*/
void GetChangeStateEventHandle(Service::Interface* self);
void GetChangeStateEventHandle(Kernel::HLERequestContext& ctx);
private:
std::shared_ptr<Module> cecd;
};
private:
Kernel::SharedPtr<Kernel::Event> cecinfo_event;
Kernel::SharedPtr<Kernel::Event> change_state_event;
};
/// Initialize CECD service(s)
void Init();
/// Shutdown CECD service(s)
void Shutdown();
void InstallInterfaces(SM::ServiceManager& service_manager);
} // namespace CECD
} // namespace Service

View file

@ -2,21 +2,23 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/cecd/cecd.h"
#include "core/hle/service/cecd/cecd_ndm.h"
namespace Service {
namespace CECD {
static const Interface::FunctionInfo FunctionTable[] = {
CECD_NDM::CECD_NDM(std::shared_ptr<Module> cecd)
: Module::Interface(std::move(cecd), "cecd:ndm", DefaultMaxSessions) {
static const FunctionInfo functions[] = {
// clang-format off
{0x00010000, nullptr, "Initialize"},
{0x00020000, nullptr, "Deinitialize"},
{0x00030000, nullptr, "ResumeDaemon"},
{0x00040040, nullptr, "SuspendDaemon"},
};
// clang-format on
};
CECD_NDM::CECD_NDM() {
Register(FunctionTable);
RegisterHandlers(functions);
}
} // namespace CECD

View file

@ -4,18 +4,14 @@
#pragma once
#include "core/hle/service/service.h"
#include "core/hle/service/cecd/cecd.h"
namespace Service {
namespace CECD {
class CECD_NDM : public Interface {
class CECD_NDM final : public Module::Interface {
public:
CECD_NDM();
std::string GetPortName() const override {
return "cecd:ndm";
}
explicit CECD_NDM(std::shared_ptr<Module> cecd);
};
} // namespace CECD

View file

@ -2,14 +2,16 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/cecd/cecd.h"
#include "core/hle/service/cecd/cecd_s.h"
namespace Service {
namespace CECD {
static const Interface::FunctionInfo FunctionTable[] = {
CECD_S::CECD_S(std::shared_ptr<Module> cecd)
: Module::Interface(std::move(cecd), "cecd:s", DefaultMaxSessions) {
static const FunctionInfo functions[] = {
// cecd:u shared commands
// clang-format off
{0x000100C2, nullptr, "OpenRawFile"},
{0x00020042, nullptr, "ReadRawFile"},
{0x00030104, nullptr, "ReadMessage"},
@ -21,15 +23,15 @@ static const Interface::FunctionInfo FunctionTable[] = {
{0x000A00C4, nullptr, "GetSystemInfo"},
{0x000B0040, nullptr, "RunCommand"},
{0x000C0040, nullptr, "RunCommandAlt"},
{0x000E0000, GetCecStateAbbreviated, "GetCecStateAbbreviated"},
{0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"},
{0x00100000, GetChangeStateEventHandle, "GetChangeStateEventHandle"},
{0x000E0000, &CECD_S::GetCecStateAbbreviated, "GetCecStateAbbreviated"},
{0x000F0000, &CECD_S::GetCecInfoEventHandle, "GetCecInfoEventHandle"},
{0x00100000, &CECD_S::GetChangeStateEventHandle, "GetChangeStateEventHandle"},
{0x00110104, nullptr, "OpenAndWrite"},
{0x00120104, nullptr, "OpenAndRead"},
};
// clang-format on
};
CECD_S::CECD_S() {
Register(FunctionTable);
RegisterHandlers(functions);
}
} // namespace CECD

View file

@ -4,18 +4,14 @@
#pragma once
#include "core/hle/service/service.h"
#include "core/hle/service/cecd/cecd.h"
namespace Service {
namespace CECD {
class CECD_S : public Interface {
class CECD_S final : public Module::Interface {
public:
CECD_S();
std::string GetPortName() const override {
return "cecd:s";
}
explicit CECD_S(std::shared_ptr<Module> cecd);
};
} // namespace CECD

View file

@ -2,14 +2,16 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/cecd/cecd.h"
#include "core/hle/service/cecd/cecd_u.h"
namespace Service {
namespace CECD {
static const Interface::FunctionInfo FunctionTable[] = {
CECD_U::CECD_U(std::shared_ptr<Module> cecd)
: Module::Interface(std::move(cecd), "cecd:u", DefaultMaxSessions) {
static const FunctionInfo functions[] = {
// cecd:u shared commands
// clang-format off
{0x000100C2, nullptr, "OpenRawFile"},
{0x00020042, nullptr, "ReadRawFile"},
{0x00030104, nullptr, "ReadMessage"},
@ -21,15 +23,15 @@ static const Interface::FunctionInfo FunctionTable[] = {
{0x000A00C4, nullptr, "GetSystemInfo"},
{0x000B0040, nullptr, "RunCommand"},
{0x000C0040, nullptr, "RunCommandAlt"},
{0x000E0000, GetCecStateAbbreviated, "GetCecStateAbbreviated"},
{0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"},
{0x00100000, GetChangeStateEventHandle, "GetChangeStateEventHandle"},
{0x000E0000, &CECD_U::GetCecStateAbbreviated, "GetCecStateAbbreviated"},
{0x000F0000, &CECD_U::GetCecInfoEventHandle, "GetCecInfoEventHandle"},
{0x00100000, &CECD_U::GetChangeStateEventHandle, "GetChangeStateEventHandle"},
{0x00110104, nullptr, "OpenAndWrite"},
{0x00120104, nullptr, "OpenAndRead"},
};
// clang-format on
};
CECD_U::CECD_U() {
Register(FunctionTable);
RegisterHandlers(functions);
}
} // namespace CECD

View file

@ -4,18 +4,14 @@
#pragma once
#include "core/hle/service/service.h"
#include "core/hle/service/cecd/cecd.h"
namespace Service {
namespace CECD {
class CECD_U : public Interface {
class CECD_U final : public Module::Interface {
public:
CECD_U();
std::string GetPortName() const override {
return "cecd:u";
}
explicit CECD_U(std::shared_ptr<Module> cecd);
};
} // namespace CECD

View file

@ -239,7 +239,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) {
APT::InstallInterfaces(*sm);
BOSS::Init();
CAM::InstallInterfaces(*sm);
CECD::Init();
CECD::InstallInterfaces(*sm);
CFG::InstallInterfaces(*sm);
DLP::InstallInterfaces(*sm);
FRD::InstallInterfaces(*sm);
@ -268,7 +268,6 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) {
/// Shutdown ServiceManager
void Shutdown() {
CECD::Shutdown();
BOSS::Shutdown();
FS::ArchiveShutdown();