2015-03-27 16:51:54 -07:00
|
|
|
// Copyright 2015 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-02-21 03:48:28 -08:00
|
|
|
#include "core/hle/kernel/event.h"
|
|
|
|
#include "core/hle/kernel/shared_memory.h"
|
2016-09-20 23:52:38 -07:00
|
|
|
#include "core/hle/service/ir/ir.h"
|
2015-03-27 16:51:54 -07:00
|
|
|
#include "core/hle/service/ir/ir_rst.h"
|
|
|
|
#include "core/hle/service/ir/ir_u.h"
|
|
|
|
#include "core/hle/service/ir/ir_user.h"
|
2016-09-17 17:38:01 -07:00
|
|
|
#include "core/hle/service/service.h"
|
2015-03-27 16:51:54 -07:00
|
|
|
|
|
|
|
namespace Service {
|
|
|
|
namespace IR {
|
|
|
|
|
2015-04-27 19:01:48 -07:00
|
|
|
static Kernel::SharedPtr<Kernel::Event> handle_event;
|
2016-02-21 03:48:28 -08:00
|
|
|
static Kernel::SharedPtr<Kernel::Event> conn_status_event;
|
2015-04-27 19:01:48 -07:00
|
|
|
static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory;
|
2016-02-21 03:48:28 -08:00
|
|
|
static Kernel::SharedPtr<Kernel::SharedMemory> transfer_shared_memory;
|
2015-03-27 16:51:54 -07:00
|
|
|
|
|
|
|
void GetHandles(Service::Interface* self) {
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
|
|
cmd_buff[2] = 0x4000000;
|
|
|
|
cmd_buff[3] = Kernel::g_handle_table.Create(Service::IR::shared_memory).MoveFrom();
|
|
|
|
cmd_buff[4] = Kernel::g_handle_table.Create(Service::IR::handle_event).MoveFrom();
|
|
|
|
}
|
|
|
|
|
2016-02-21 03:48:28 -08:00
|
|
|
void InitializeIrNopShared(Interface* self) {
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
u32 transfer_buff_size = cmd_buff[1];
|
2016-09-17 17:38:01 -07:00
|
|
|
u32 recv_buff_size = cmd_buff[2];
|
|
|
|
u32 unk1 = cmd_buff[3];
|
|
|
|
u32 send_buff_size = cmd_buff[4];
|
|
|
|
u32 unk2 = cmd_buff[5];
|
|
|
|
u8 baud_rate = cmd_buff[6] & 0xFF;
|
|
|
|
Handle handle = cmd_buff[8];
|
|
|
|
|
|
|
|
if (Kernel::g_handle_table.IsValid(handle)) {
|
2016-02-21 03:48:28 -08:00
|
|
|
transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle);
|
|
|
|
transfer_shared_memory->name = "IR:TransferSharedMemory";
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
|
|
|
|
|
|
LOG_WARNING(Service_IR, "(STUBBED) called, transfer_buff_size=%d, recv_buff_size=%d, "
|
2016-09-17 17:38:01 -07:00
|
|
|
"unk1=%d, send_buff_size=%d, unk2=%d, baud_rate=%u, handle=0x%08X",
|
2016-02-21 03:48:28 -08:00
|
|
|
transfer_buff_size, recv_buff_size, unk1, send_buff_size, unk2, baud_rate, handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequireConnection(Interface* self) {
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
conn_status_event->Signal();
|
|
|
|
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
|
|
|
|
|
|
LOG_WARNING(Service_IR, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Disconnect(Interface* self) {
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
|
|
|
|
|
|
LOG_WARNING(Service_IR, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetConnectionStatusEvent(Interface* self) {
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
|
|
cmd_buff[3] = Kernel::g_handle_table.Create(Service::IR::conn_status_event).MoveFrom();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_IR, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
void FinalizeIrNop(Interface* self) {
|
|
|
|
u32* cmd_buff = Kernel::GetCommandBuffer();
|
|
|
|
|
|
|
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
|
|
|
|
|
|
|
LOG_WARNING(Service_IR, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2015-03-27 16:51:54 -07:00
|
|
|
void Init() {
|
|
|
|
using namespace Kernel;
|
|
|
|
|
|
|
|
AddService(new IR_RST_Interface);
|
|
|
|
AddService(new IR_U_Interface);
|
|
|
|
AddService(new IR_User_Interface);
|
|
|
|
|
2015-05-10 15:47:07 -07:00
|
|
|
using Kernel::MemoryPermission;
|
2016-09-17 17:38:01 -07:00
|
|
|
shared_memory = SharedMemory::Create(nullptr, 0x1000, Kernel::MemoryPermission::ReadWrite,
|
|
|
|
Kernel::MemoryPermission::ReadWrite, 0,
|
|
|
|
Kernel::MemoryRegion::BASE, "IR:SharedMemory");
|
2016-02-21 03:48:28 -08:00
|
|
|
transfer_shared_memory = nullptr;
|
2015-03-27 16:51:54 -07:00
|
|
|
|
|
|
|
// Create event handle(s)
|
2016-09-17 17:38:01 -07:00
|
|
|
handle_event = Event::Create(ResetType::OneShot, "IR:HandleEvent");
|
2016-03-12 12:06:31 -08:00
|
|
|
conn_status_event = Event::Create(ResetType::OneShot, "IR:ConnectionStatusEvent");
|
2015-03-27 16:51:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Shutdown() {
|
2016-02-21 03:48:28 -08:00
|
|
|
transfer_shared_memory = nullptr;
|
2015-04-27 19:01:48 -07:00
|
|
|
shared_memory = nullptr;
|
|
|
|
handle_event = nullptr;
|
2016-02-21 03:48:28 -08:00
|
|
|
conn_status_event = nullptr;
|
2015-03-27 16:51:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace IR
|
|
|
|
|
|
|
|
} // namespace Service
|