Merge pull request #3906 from NarcolepticK/cecd-migrate-framework

service/cecd: Migrate to ServiceFramework
This commit is contained in:
Weiyi Wang 2018-07-03 01:45:22 +03:00 committed by GitHub
commit 945b3413a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 148 additions and 141 deletions

View file

@ -3,64 +3,61 @@
// 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.PushEnum(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,13 +4,13 @@
#pragma once
#include "core/hle/kernel/event.h"
#include "core/hle/service/service.h"
namespace Service {
class Interface;
namespace CECD {
enum class CecStateAbbreviated {
enum class CecStateAbbreviated : u32 {
CEC_STATE_ABBREV_IDLE = 1, ///< Corresponds to CEC_STATE_IDLE
CEC_STATE_ABBREV_NOT_LOCAL = 2, ///< Corresponds to CEC_STATEs *FINISH*, *POST, and OVER_BOSS
CEC_STATE_ABBREV_SCANNING = 3, ///< Corresponds to CEC_STATE_SCANNING
@ -20,41 +20,58 @@ enum class CecStateAbbreviated {
/// OVER_BOSS and those listed here
};
/**
* GetCecStateAbbreviated service function
* Inputs:
* 0: 0x000E0000
* Outputs:
* 1: ResultCode
* 2: CecStateAbbreviated
*/
void GetCecStateAbbreviated(Service::Interface* self);
class Module final {
public:
Module();
~Module() = default;
/**
* GetCecInfoEventHandle service function
* Inputs:
* 0: 0x000F0000
* Outputs:
* 1: ResultCode
* 3: Event Handle
*/
void GetCecInfoEventHandle(Service::Interface* self);
class Interface : public ServiceFramework<Interface> {
public:
Interface(std::shared_ptr<Module> cecd, const char* name, u32 max_session);
~Interface() = default;
/**
* GetChangeStateEventHandle service function
* Inputs:
* 0: 0x00100000
* Outputs:
* 1: ResultCode
* 3: Event Handle
*/
void GetChangeStateEventHandle(Service::Interface* self);
protected:
/**
* GetCecStateAbbreviated service function
* Inputs:
* 0: 0x000E0000
* Outputs:
* 1: ResultCode
* 2: CecStateAbbreviated
*/
void GetCecStateAbbreviated(Kernel::HLERequestContext& ctx);
/**
* GetCecInfoEventHandle service function
* Inputs:
* 0: 0x000F0000
* Outputs:
* 1: ResultCode
* 3: Event Handle
*/
void GetCecInfoEventHandle(Kernel::HLERequestContext& ctx);
/**
* GetChangeStateEventHandle service function
* Inputs:
* 0: 0x00100000
* Outputs:
* 1: ResultCode
* 3: Event Handle
*/
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[] = {
{0x00010000, nullptr, "Initialize"},
{0x00020000, nullptr, "Deinitialize"},
{0x00030000, nullptr, "ResumeDaemon"},
{0x00040040, nullptr, "SuspendDaemon"},
};
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,34 +2,36 @@
// 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:u shared commands
{0x000100C2, nullptr, "OpenRawFile"},
{0x00020042, nullptr, "ReadRawFile"},
{0x00030104, nullptr, "ReadMessage"},
{0x00040106, nullptr, "ReadMessageWithHMAC"},
{0x00050042, nullptr, "WriteRawFile"},
{0x00060104, nullptr, "WriteMessage"},
{0x00070106, nullptr, "WriteMessageWithHMAC"},
{0x00080102, nullptr, "Delete"},
{0x000A00C4, nullptr, "GetSystemInfo"},
{0x000B0040, nullptr, "RunCommand"},
{0x000C0040, nullptr, "RunCommandAlt"},
{0x000E0000, GetCecStateAbbreviated, "GetCecStateAbbreviated"},
{0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"},
{0x00100000, GetChangeStateEventHandle, "GetChangeStateEventHandle"},
{0x00110104, nullptr, "OpenAndWrite"},
{0x00120104, nullptr, "OpenAndRead"},
};
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"},
{0x00040106, nullptr, "ReadMessageWithHMAC"},
{0x00050042, nullptr, "WriteRawFile"},
{0x00060104, nullptr, "WriteMessage"},
{0x00070106, nullptr, "WriteMessageWithHMAC"},
{0x00080102, nullptr, "Delete"},
{0x000A00C4, nullptr, "GetSystemInfo"},
{0x000B0040, nullptr, "RunCommand"},
{0x000C0040, nullptr, "RunCommandAlt"},
{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,34 +2,36 @@
// 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 shared commands
{0x000100C2, nullptr, "OpenRawFile"},
{0x00020042, nullptr, "ReadRawFile"},
{0x00030104, nullptr, "ReadMessage"},
{0x00040106, nullptr, "ReadMessageWithHMAC"},
{0x00050042, nullptr, "WriteRawFile"},
{0x00060104, nullptr, "WriteMessage"},
{0x00070106, nullptr, "WriteMessageWithHMAC"},
{0x00080102, nullptr, "Delete"},
{0x000A00C4, nullptr, "GetSystemInfo"},
{0x000B0040, nullptr, "RunCommand"},
{0x000C0040, nullptr, "RunCommandAlt"},
{0x000E0000, GetCecStateAbbreviated, "GetCecStateAbbreviated"},
{0x000F0000, GetCecInfoEventHandle, "GetCecInfoEventHandle"},
{0x00100000, GetChangeStateEventHandle, "GetChangeStateEventHandle"},
{0x00110104, nullptr, "OpenAndWrite"},
{0x00120104, nullptr, "OpenAndRead"},
};
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"},
{0x00040106, nullptr, "ReadMessageWithHMAC"},
{0x00050042, nullptr, "WriteRawFile"},
{0x00060104, nullptr, "WriteMessage"},
{0x00070106, nullptr, "WriteMessageWithHMAC"},
{0x00080102, nullptr, "Delete"},
{0x000A00C4, nullptr, "GetSystemInfo"},
{0x000B0040, nullptr, "RunCommand"},
{0x000C0040, nullptr, "RunCommandAlt"},
{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();