|
|
@ -3,6 +3,7 @@
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
|
|
|
|
#include "core/core_timing.h"
|
|
|
|
#include "core/hle/ipc.h"
|
|
|
|
#include "core/hle/ipc.h"
|
|
|
|
#include "core/hle/kernel/client_port.h"
|
|
|
|
#include "core/hle/kernel/client_port.h"
|
|
|
|
#include "core/hle/kernel/client_session.h"
|
|
|
|
#include "core/hle/kernel/client_session.h"
|
|
|
@ -14,16 +15,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
|
|
|
|
static SharedPtr<Object> MakeObject() {
|
|
|
|
static SharedPtr<Object> MakeObject(Kernel::KernelSystem& kernel) {
|
|
|
|
static Kernel::KernelSystem kernel(0);
|
|
|
|
|
|
|
|
return kernel.CreateEvent(ResetType::OneShot);
|
|
|
|
return kernel.CreateEvent(ResetType::OneShot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel]") {
|
|
|
|
TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel]") {
|
|
|
|
|
|
|
|
CoreTiming::Init();
|
|
|
|
|
|
|
|
Kernel::KernelSystem kernel(0);
|
|
|
|
auto session = std::get<SharedPtr<ServerSession>>(ServerSession::CreateSessionPair());
|
|
|
|
auto session = std::get<SharedPtr<ServerSession>>(ServerSession::CreateSessionPair());
|
|
|
|
HLERequestContext context(std::move(session));
|
|
|
|
HLERequestContext context(std::move(session));
|
|
|
|
|
|
|
|
|
|
|
|
auto process = Process::Create(CodeSet::Create("", 0));
|
|
|
|
auto process = Process::Create(kernel.CreateCodeSet("", 0));
|
|
|
|
HandleTable handle_table;
|
|
|
|
HandleTable handle_table;
|
|
|
|
|
|
|
|
|
|
|
|
SECTION("works with empty cmdbuf") {
|
|
|
|
SECTION("works with empty cmdbuf") {
|
|
|
@ -53,7 +55,7 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SECTION("translates move handles") {
|
|
|
|
SECTION("translates move handles") {
|
|
|
|
auto a = MakeObject();
|
|
|
|
auto a = MakeObject(kernel);
|
|
|
|
Handle a_handle = handle_table.Create(a).Unwrap();
|
|
|
|
Handle a_handle = handle_table.Create(a).Unwrap();
|
|
|
|
const u32_le input[]{
|
|
|
|
const u32_le input[]{
|
|
|
|
IPC::MakeHeader(0, 0, 2),
|
|
|
|
IPC::MakeHeader(0, 0, 2),
|
|
|
@ -69,7 +71,7 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SECTION("translates copy handles") {
|
|
|
|
SECTION("translates copy handles") {
|
|
|
|
auto a = MakeObject();
|
|
|
|
auto a = MakeObject(kernel);
|
|
|
|
Handle a_handle = handle_table.Create(a).Unwrap();
|
|
|
|
Handle a_handle = handle_table.Create(a).Unwrap();
|
|
|
|
const u32_le input[]{
|
|
|
|
const u32_le input[]{
|
|
|
|
IPC::MakeHeader(0, 0, 2),
|
|
|
|
IPC::MakeHeader(0, 0, 2),
|
|
|
@ -85,9 +87,9 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SECTION("translates multi-handle descriptors") {
|
|
|
|
SECTION("translates multi-handle descriptors") {
|
|
|
|
auto a = MakeObject();
|
|
|
|
auto a = MakeObject(kernel);
|
|
|
|
auto b = MakeObject();
|
|
|
|
auto b = MakeObject(kernel);
|
|
|
|
auto c = MakeObject();
|
|
|
|
auto c = MakeObject(kernel);
|
|
|
|
const u32_le input[]{
|
|
|
|
const u32_le input[]{
|
|
|
|
IPC::MakeHeader(0, 0, 5), IPC::MoveHandleDesc(2),
|
|
|
|
IPC::MakeHeader(0, 0, 5), IPC::MoveHandleDesc(2),
|
|
|
|
handle_table.Create(a).Unwrap(), handle_table.Create(b).Unwrap(),
|
|
|
|
handle_table.Create(a).Unwrap(), handle_table.Create(b).Unwrap(),
|
|
|
@ -191,7 +193,7 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|
|
|
buffer_mapped->size(), MemoryState::Private);
|
|
|
|
buffer_mapped->size(), MemoryState::Private);
|
|
|
|
REQUIRE(result.Code() == RESULT_SUCCESS);
|
|
|
|
REQUIRE(result.Code() == RESULT_SUCCESS);
|
|
|
|
|
|
|
|
|
|
|
|
auto a = MakeObject();
|
|
|
|
auto a = MakeObject(kernel);
|
|
|
|
const u32_le input[]{
|
|
|
|
const u32_le input[]{
|
|
|
|
IPC::MakeHeader(0, 2, 8),
|
|
|
|
IPC::MakeHeader(0, 2, 8),
|
|
|
|
0x12345678,
|
|
|
|
0x12345678,
|
|
|
@ -223,13 +225,17 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|
|
|
REQUIRE(process->vm_manager.UnmapRange(target_address_mapped, buffer_mapped->size()) ==
|
|
|
|
REQUIRE(process->vm_manager.UnmapRange(target_address_mapped, buffer_mapped->size()) ==
|
|
|
|
RESULT_SUCCESS);
|
|
|
|
RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CoreTiming::Shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|
|
|
TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|
|
|
|
|
|
|
CoreTiming::Init();
|
|
|
|
|
|
|
|
Kernel::KernelSystem kernel(0);
|
|
|
|
auto session = std::get<SharedPtr<ServerSession>>(ServerSession::CreateSessionPair());
|
|
|
|
auto session = std::get<SharedPtr<ServerSession>>(ServerSession::CreateSessionPair());
|
|
|
|
HLERequestContext context(std::move(session));
|
|
|
|
HLERequestContext context(std::move(session));
|
|
|
|
|
|
|
|
|
|
|
|
auto process = Process::Create(CodeSet::Create("", 0));
|
|
|
|
auto process = Process::Create(kernel.CreateCodeSet("", 0));
|
|
|
|
HandleTable handle_table;
|
|
|
|
HandleTable handle_table;
|
|
|
|
auto* input = context.CommandBuffer();
|
|
|
|
auto* input = context.CommandBuffer();
|
|
|
|
u32_le output[IPC::COMMAND_BUFFER_LENGTH];
|
|
|
|
u32_le output[IPC::COMMAND_BUFFER_LENGTH];
|
|
|
@ -256,8 +262,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SECTION("translates move/copy handles") {
|
|
|
|
SECTION("translates move/copy handles") {
|
|
|
|
auto a = MakeObject();
|
|
|
|
auto a = MakeObject(kernel);
|
|
|
|
auto b = MakeObject();
|
|
|
|
auto b = MakeObject(kernel);
|
|
|
|
input[0] = IPC::MakeHeader(0, 0, 4);
|
|
|
|
input[0] = IPC::MakeHeader(0, 0, 4);
|
|
|
|
input[1] = IPC::MoveHandleDesc(1);
|
|
|
|
input[1] = IPC::MoveHandleDesc(1);
|
|
|
|
input[2] = context.AddOutgoingHandle(a);
|
|
|
|
input[2] = context.AddOutgoingHandle(a);
|
|
|
@ -282,9 +288,9 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SECTION("translates multi-handle descriptors") {
|
|
|
|
SECTION("translates multi-handle descriptors") {
|
|
|
|
auto a = MakeObject();
|
|
|
|
auto a = MakeObject(kernel);
|
|
|
|
auto b = MakeObject();
|
|
|
|
auto b = MakeObject(kernel);
|
|
|
|
auto c = MakeObject();
|
|
|
|
auto c = MakeObject(kernel);
|
|
|
|
input[0] = IPC::MakeHeader(0, 0, 5);
|
|
|
|
input[0] = IPC::MakeHeader(0, 0, 5);
|
|
|
|
input[1] = IPC::MoveHandleDesc(2);
|
|
|
|
input[1] = IPC::MoveHandleDesc(2);
|
|
|
|
input[2] = context.AddOutgoingHandle(a);
|
|
|
|
input[2] = context.AddOutgoingHandle(a);
|
|
|
@ -362,6 +368,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|
|
|
REQUIRE(process->vm_manager.UnmapRange(target_address, output_buffer->size()) ==
|
|
|
|
REQUIRE(process->vm_manager.UnmapRange(target_address, output_buffer->size()) ==
|
|
|
|
RESULT_SUCCESS);
|
|
|
|
RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CoreTiming::Shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Kernel
|
|
|
|
} // namespace Kernel
|
|
|
|