2016-12-12 08:56:43 +00:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2017-11-05 17:50:22 +00:00
|
|
|
#include <vector>
|
2017-06-06 08:29:46 +00:00
|
|
|
#include "common/common_types.h"
|
2016-12-12 08:56:43 +00:00
|
|
|
#include "common/logging/log.h"
|
2017-06-06 08:29:46 +00:00
|
|
|
#include "core/hle/ipc.h"
|
2017-10-04 21:22:14 +00:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
2016-12-12 08:56:43 +00:00
|
|
|
#include "core/hle/kernel/event.h"
|
2017-06-06 08:29:46 +00:00
|
|
|
#include "core/hle/kernel/handle_table.h"
|
|
|
|
#include "core/hle/result.h"
|
2016-12-12 08:56:43 +00:00
|
|
|
#include "core/hle/service/ac/ac.h"
|
|
|
|
#include "core/hle/service/ac/ac_i.h"
|
|
|
|
#include "core/hle/service/ac/ac_u.h"
|
2017-06-06 08:29:46 +00:00
|
|
|
#include "core/memory.h"
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
namespace Service {
|
|
|
|
namespace AC {
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::CreateDefaultConfig(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x1, 0, 0);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-11-05 17:50:22 +00:00
|
|
|
std::vector<u8> buffer(sizeof(ACConfig));
|
|
|
|
std::memcpy(buffer.data(), &ac->default_config, buffer.size());
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2017-11-05 17:50:22 +00:00
|
|
|
rb.PushStaticBuffer(std::move(buffer), 0);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
LOG_WARNING(Service_AC, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::ConnectAsync(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x4, 0, 6);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
rp.Skip(2, false); // ProcessId descriptor
|
|
|
|
ac->connect_event = rp.PopObject<Kernel::Event>();
|
|
|
|
|
|
|
|
if (ac->connect_event) {
|
|
|
|
ac->connect_event->name = "AC:connect_event";
|
|
|
|
ac->connect_event->Signal();
|
|
|
|
ac->ac_connected = true;
|
2016-12-12 08:56:43 +00:00
|
|
|
}
|
2017-10-04 21:22:14 +00:00
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
LOG_WARNING(Service_AC, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::GetConnectResult(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x5, 0, 2);
|
|
|
|
rp.Skip(2, false); // ProcessId descriptor
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-12-12 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::CloseAsync(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x8, 0, 4);
|
|
|
|
rp.Skip(2, false); // ProcessId descriptor
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
ac->close_event = rp.PopObject<Kernel::Event>();
|
|
|
|
|
|
|
|
if (ac->ac_connected && ac->disconnect_event) {
|
|
|
|
ac->disconnect_event->Signal();
|
2016-12-12 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
if (ac->close_event) {
|
|
|
|
ac->close_event->name = "AC:close_event";
|
|
|
|
ac->close_event->Signal();
|
2016-12-12 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
ac->ac_connected = false;
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-12-12 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::GetCloseResult(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x9, 0, 2);
|
|
|
|
rp.Skip(2, false); // ProcessId descriptor
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
LOG_WARNING(Service_AC, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::GetWifiStatus(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0xD, 0, 0);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
// TODO(purpasmart96): This function is only a stub,
|
|
|
|
// it returns a valid result without implementing full functionality.
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(0); // Connection type set to none
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
LOG_WARNING(Service_AC, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::GetInfraPriority(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x27, 0, 2);
|
2017-11-05 17:50:22 +00:00
|
|
|
const std::vector<u8>& ac_config = rp.PopStaticBuffer();
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(0); // Infra Priority, default 0
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
LOG_WARNING(Service_AC, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::SetRequestEulaVersion(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x2D, 2, 2);
|
|
|
|
|
|
|
|
u32 major = rp.Pop<u8>();
|
|
|
|
u32 minor = rp.Pop<u8>();
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-11-05 17:50:22 +00:00
|
|
|
const std::vector<u8>& ac_config = rp.PopStaticBuffer();
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
// TODO(Subv): Copy over the input ACConfig to the stored ACConfig.
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2017-11-05 17:50:22 +00:00
|
|
|
rb.PushStaticBuffer(std::move(ac_config), 0);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
LOG_WARNING(Service_AC, "(STUBBED) called, major=%u, minor=%u", major, minor);
|
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::RegisterDisconnectEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x30, 0, 4);
|
|
|
|
rp.Skip(2, false); // ProcessId descriptor
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
ac->disconnect_event = rp.PopObject<Kernel::Event>();
|
|
|
|
if (ac->disconnect_event) {
|
|
|
|
ac->disconnect_event->name = "AC:disconnect_event";
|
2016-12-12 08:56:43 +00:00
|
|
|
}
|
2017-10-04 21:22:14 +00:00
|
|
|
|
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
LOG_WARNING(Service_AC, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::IsConnected(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x3E, 1, 2);
|
|
|
|
u32 unk = rp.Pop<u32>();
|
|
|
|
u32 unk_descriptor = rp.Pop<u32>();
|
|
|
|
u32 unk_param = rp.Pop<u32>();
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(ac->ac_connected);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
LOG_WARNING(Service_AC, "(STUBBED) called unk=%08X descriptor=%08X param=%08X", unk,
|
|
|
|
unk_descriptor, unk_param);
|
2016-12-12 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void Module::Interface::SetClientVersion(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp(ctx, 0x40, 1, 2);
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
u32 version = rp.Pop<u32>();
|
|
|
|
rp.Skip(2, false); // ProcessId descriptor
|
2016-12-12 08:56:43 +00:00
|
|
|
|
|
|
|
LOG_WARNING(Service_AC, "(STUBBED) called, version: 0x%08X", version);
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2016-12-12 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
Module::Interface::Interface(std::shared_ptr<Module> ac, const char* name, u32 max_session)
|
|
|
|
: ac(std::move(ac)), ServiceFramework(name, max_session) {}
|
2016-12-12 08:56:43 +00:00
|
|
|
|
2017-10-04 21:22:14 +00:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
|
|
|
auto ac = std::make_shared<Module>();
|
|
|
|
std::make_shared<AC_I>(ac)->InstallAsService(service_manager);
|
|
|
|
std::make_shared<AC_U>(ac)->InstallAsService(service_manager);
|
2016-12-12 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace AC
|
|
|
|
} // namespace Service
|