2015-06-11 22:12:16 +00:00
|
|
|
// Copyright 2015 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "common/logging/log.h"
|
2018-07-01 03:27:57 +00:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
2017-06-06 08:29:46 +00:00
|
|
|
#include "core/hle/result.h"
|
2016-09-21 06:52:38 +00:00
|
|
|
#include "core/hle/service/cecd/cecd.h"
|
2016-12-15 06:52:40 +00:00
|
|
|
#include "core/hle/service/cecd/cecd_ndm.h"
|
2015-06-11 22:12:16 +00:00
|
|
|
#include "core/hle/service/cecd/cecd_s.h"
|
|
|
|
#include "core/hle/service/cecd/cecd_u.h"
|
2018-07-01 03:27:57 +00:00
|
|
|
|
2015-06-11 22:12:16 +00:00
|
|
|
namespace Service {
|
|
|
|
namespace CECD {
|
|
|
|
|
2018-07-26 04:54:11 +00:00
|
|
|
void Module::Interface::OpenRawFile(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x01, 3, 2);
|
|
|
|
const u32 ncch_program_id = rp.Pop<u32>();
|
|
|
|
const u32 path_type = rp.Pop<u32>();
|
|
|
|
const u32 file_open_flag = rp.Pop<u32>();
|
|
|
|
rp.PopPID();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(0); /// File size?
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD,
|
|
|
|
"(STUBBED) called, ncch_program_id={:#010x}, path_type={:#010x}, "
|
|
|
|
"file_open_flag={:#010x}",
|
|
|
|
ncch_program_id, path_type, file_open_flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::Interface::ReadRawFile(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x02, 1, 2);
|
|
|
|
const u32 buffer_size = rp.Pop<u32>();
|
|
|
|
auto buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(0); /// Read size
|
|
|
|
rb.PushStaticBuffer(buffer, 0);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD, "(STUBBED) called, buffer_size={:#010x}", buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::Interface::ReadMessage(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x03, 4, 4);
|
|
|
|
const u32 ncch_program_id = rp.Pop<u32>();
|
|
|
|
const bool is_out_box = rp.Pop<bool>();
|
|
|
|
const u32 message_id_size = rp.Pop<u32>();
|
|
|
|
const u32 buffer_size = rp.Pop<u32>();
|
|
|
|
const auto message_id_buffer = rp.PopStaticBuffer();
|
|
|
|
auto write_buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 4);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(0); /// Read size
|
|
|
|
rb.PushStaticBuffer(message_id_buffer, 0);
|
|
|
|
rb.PushStaticBuffer(write_buffer, 1);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD, "(STUBBED) called, ncch_program_id={:#010x}, is_out_box={}",
|
|
|
|
ncch_program_id, is_out_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::Interface::ReadMessageWithHMAC(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x04, 4, 6);
|
|
|
|
const u32 ncch_program_id = rp.Pop<u32>();
|
|
|
|
const bool is_out_box = rp.Pop<bool>();
|
|
|
|
const u32 message_id_size = rp.Pop<u32>();
|
|
|
|
const u32 buffer_size = rp.Pop<u32>();
|
|
|
|
const auto message_id_buffer = rp.PopStaticBuffer();
|
|
|
|
const auto hmac_key_buffer = rp.PopStaticBuffer();
|
|
|
|
auto write_buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 6);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(0); /// Read size
|
|
|
|
rb.PushStaticBuffer(message_id_buffer, 0);
|
|
|
|
rb.PushStaticBuffer(hmac_key_buffer, 1);
|
|
|
|
rb.PushStaticBuffer(write_buffer, 2);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD, "(STUBBED) called, ncch_program_id={:#010x}, is_out_box={}",
|
|
|
|
ncch_program_id, is_out_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::Interface::WriteRawFile(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x05, 1, 2);
|
|
|
|
const u32 buffer_size = rp.Pop<u32>();
|
|
|
|
const auto buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushStaticBuffer(buffer, 0);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD, "(STUBBED) called, buffer_size={:#010x}", buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::Interface::WriteMessage(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x06, 4, 4);
|
|
|
|
const u32 ncch_program_id = rp.Pop<u32>();
|
|
|
|
const bool is_out_box = rp.Pop<bool>();
|
|
|
|
const u32 message_id_size = rp.Pop<u32>();
|
|
|
|
const u32 buffer_size = rp.Pop<u32>();
|
|
|
|
const auto read_buffer = rp.PopStaticBuffer();
|
|
|
|
auto message_id_buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushStaticBuffer(read_buffer, 0);
|
|
|
|
rb.PushStaticBuffer(message_id_buffer, 1);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD, "(STUBBED) called, ncch_program_id={:#010x}, is_out_box={}",
|
|
|
|
ncch_program_id, is_out_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::Interface::WriteMessageWithHMAC(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x07, 4, 6);
|
|
|
|
const u32 ncch_program_id = rp.Pop<u32>();
|
|
|
|
const bool is_out_box = rp.Pop<bool>();
|
|
|
|
const u32 message_id_size = rp.Pop<u32>();
|
|
|
|
const u32 buffer_size = rp.Pop<u32>();
|
|
|
|
const auto read_buffer = rp.PopStaticBuffer();
|
|
|
|
const auto hmac_key_buffer = rp.PopStaticBuffer();
|
|
|
|
auto message_id_buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 6);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushStaticBuffer(read_buffer, 0);
|
|
|
|
rb.PushStaticBuffer(hmac_key_buffer, 1);
|
|
|
|
rb.PushStaticBuffer(message_id_buffer, 2);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD, "(STUBBED) called, ncch_program_id={:#010x}, is_out_box={}",
|
|
|
|
ncch_program_id, is_out_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::Interface::Delete(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x10, 4, 2);
|
|
|
|
const u32 ncch_program_id = rp.Pop<u32>();
|
|
|
|
const u32 path_type = rp.Pop<u32>();
|
|
|
|
const bool is_out_box = rp.Pop<bool>();
|
|
|
|
const u32 message_id_size = rp.Pop<u32>();
|
|
|
|
const auto message_id_buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushStaticBuffer(message_id_buffer, 0);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD,
|
|
|
|
"(STUBBED) called, ncch_program_id={:#010x}, path_type={:#010x}, is_out_box={}",
|
|
|
|
ncch_program_id, path_type, is_out_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::Interface::GetSystemInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x10, 3, 4);
|
|
|
|
const u32 dest_buffer_size = rp.Pop<u32>();
|
|
|
|
const u32 info_type = rp.Pop<u32>();
|
|
|
|
const u32 param_buffer_size = rp.Pop<u32>();
|
|
|
|
const auto param_buffer = rp.PopStaticBuffer();
|
|
|
|
auto dest_buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushStaticBuffer(param_buffer, 0);
|
|
|
|
rb.PushStaticBuffer(dest_buffer, 1);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD,
|
|
|
|
"(STUBBED) called, dest_buffer_size={:#010x}, info_type={:#010x}, "
|
|
|
|
"param_buffer_size={:#010x}",
|
|
|
|
dest_buffer_size, info_type, param_buffer_size);
|
|
|
|
}
|
|
|
|
|
2018-07-01 03:27:57 +00:00
|
|
|
void Module::Interface::GetCecStateAbbreviated(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x0E, 0, 0);
|
2016-04-08 19:39:52 +00:00
|
|
|
|
2018-07-01 03:27:57 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-07-01 16:38:40 +00:00
|
|
|
rb.PushEnum(CecStateAbbreviated::CEC_STATE_ABBREV_IDLE);
|
2016-04-08 19:39:52 +00:00
|
|
|
|
2018-06-29 11:18:07 +00:00
|
|
|
LOG_WARNING(Service_CECD, "(STUBBED) called");
|
2016-04-08 19:39:52 +00:00
|
|
|
}
|
|
|
|
|
2018-07-01 03:27:57 +00:00
|
|
|
void Module::Interface::GetCecInfoEventHandle(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x0F, 0, 0);
|
2016-03-31 09:21:02 +00:00
|
|
|
|
2018-07-01 03:27:57 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(cecd->cecinfo_event);
|
2016-03-31 09:21:02 +00:00
|
|
|
|
2018-06-29 11:18:07 +00:00
|
|
|
LOG_WARNING(Service_CECD, "(STUBBED) called");
|
2016-03-31 09:21:02 +00:00
|
|
|
}
|
|
|
|
|
2018-07-01 03:27:57 +00:00
|
|
|
void Module::Interface::GetChangeStateEventHandle(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x10, 0, 0);
|
2015-06-11 22:12:16 +00:00
|
|
|
|
2018-07-01 03:27:57 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(cecd->change_state_event);
|
2016-03-31 09:21:02 +00:00
|
|
|
|
2018-06-29 11:18:07 +00:00
|
|
|
LOG_WARNING(Service_CECD, "(STUBBED) called");
|
2016-03-31 09:21:02 +00:00
|
|
|
}
|
|
|
|
|
2018-07-26 04:54:11 +00:00
|
|
|
void Module::Interface::OpenAndWrite(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x11, 4, 4);
|
|
|
|
const u32 buffer_size = rp.Pop<u32>();
|
|
|
|
const u32 ncch_program_id = rp.Pop<u32>();
|
|
|
|
const u32 path_type = rp.Pop<u32>();
|
|
|
|
const u32 file_open_flag = rp.Pop<u32>();
|
|
|
|
rp.PopPID();
|
|
|
|
const auto read_buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushStaticBuffer(read_buffer, 0);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD,
|
|
|
|
"(STUBBED) called, ncch_program_id={:#010x}, path_type={:#010x}, "
|
|
|
|
"file_open_flag={:#010x}",
|
|
|
|
ncch_program_id, path_type, file_open_flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x12, 4, 4);
|
|
|
|
const u32 buffer_size = rp.Pop<u32>();
|
|
|
|
const u32 ncch_program_id = rp.Pop<u32>();
|
|
|
|
const u32 path_type = rp.Pop<u32>();
|
|
|
|
const u32 file_open_flag = rp.Pop<u32>();
|
|
|
|
rp.PopPID();
|
|
|
|
auto write_buffer = rp.PopStaticBuffer();
|
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushStaticBuffer(write_buffer, 0);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_CECD,
|
|
|
|
"(STUBBED) called, ncch_program_id={:#010x}, path_type={:#010x}, "
|
|
|
|
"file_open_flag={:#010x}",
|
|
|
|
ncch_program_id, path_type, file_open_flag);
|
|
|
|
}
|
|
|
|
|
2018-07-01 03:27:57 +00:00
|
|
|
Module::Interface::Interface(std::shared_ptr<Module> cecd, const char* name, u32 max_session)
|
|
|
|
: ServiceFramework(name, max_session), cecd(std::move(cecd)) {}
|
2016-03-31 09:21:02 +00:00
|
|
|
|
2018-07-01 03:27:57 +00:00
|
|
|
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");
|
2015-06-11 22:12:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-01 03:27:57 +00:00
|
|
|
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);
|
2015-06-11 22:12:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace CECD
|
|
|
|
} // namespace Service
|