mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-10 12:50:04 +00:00
kernel: Update to use atmosphere macros and correct Result (#7242)
* kernel: Switch to atmosphere style macros * code: Rename ResultCode to Result * code: Result constants are lower case * Address review comments * core: Remove CASCADE_CODE * R_TRY replaces completely * core: Run clang format
This commit is contained in:
parent
811303ea54
commit
5a7f615da1
132 changed files with 2807 additions and 2995 deletions
|
@ -59,7 +59,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
|
||||
SECTION("translates move handles") {
|
||||
auto a = MakeObject(kernel);
|
||||
Handle a_handle = process->handle_table.Create(a).Unwrap();
|
||||
Handle a_handle;
|
||||
process->handle_table.Create(std::addressof(a_handle), a);
|
||||
const u32_le input[]{
|
||||
IPC::MakeHeader(0, 0, 2),
|
||||
IPC::MoveHandleDesc(1),
|
||||
|
@ -75,7 +76,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
|
||||
SECTION("translates copy handles") {
|
||||
auto a = MakeObject(kernel);
|
||||
Handle a_handle = process->handle_table.Create(a).Unwrap();
|
||||
Handle a_handle;
|
||||
process->handle_table.Create(std::addressof(a_handle), a);
|
||||
const u32_le input[]{
|
||||
IPC::MakeHeader(0, 0, 2),
|
||||
IPC::CopyHandleDesc(1),
|
||||
|
@ -93,13 +95,17 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
auto a = MakeObject(kernel);
|
||||
auto b = MakeObject(kernel);
|
||||
auto c = MakeObject(kernel);
|
||||
Handle a_handle, b_handle, c_handle;
|
||||
process->handle_table.Create(std::addressof(a_handle), a);
|
||||
process->handle_table.Create(std::addressof(b_handle), b);
|
||||
process->handle_table.Create(std::addressof(c_handle), c);
|
||||
const u32_le input[]{
|
||||
IPC::MakeHeader(0, 0, 5),
|
||||
IPC::MoveHandleDesc(2),
|
||||
process->handle_table.Create(a).Unwrap(),
|
||||
process->handle_table.Create(b).Unwrap(),
|
||||
a_handle,
|
||||
b_handle,
|
||||
IPC::MoveHandleDesc(1),
|
||||
process->handle_table.Create(c).Unwrap(),
|
||||
c_handle,
|
||||
};
|
||||
|
||||
context.PopulateFromIncomingCommandBuffer(input, process);
|
||||
|
@ -119,7 +125,7 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
|
||||
auto result = context.PopulateFromIncomingCommandBuffer(input, process);
|
||||
|
||||
REQUIRE(result == RESULT_SUCCESS);
|
||||
REQUIRE(result == ResultSuccess);
|
||||
auto* output = context.CommandBuffer();
|
||||
REQUIRE(context.GetIncomingHandle(output[2]) == nullptr);
|
||||
}
|
||||
|
@ -144,7 +150,7 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
VAddr target_address = 0x10000000;
|
||||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address, buffer, static_cast<u32>(buffer.GetSize()), MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
const u32_le input[]{
|
||||
IPC::MakeHeader(0, 0, 2),
|
||||
|
@ -157,7 +163,7 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
CHECK(context.GetStaticBuffer(0) == mem->Vector());
|
||||
|
||||
REQUIRE(process->vm_manager.UnmapRange(
|
||||
target_address, static_cast<u32>(buffer.GetSize())) == RESULT_SUCCESS);
|
||||
target_address, static_cast<u32>(buffer.GetSize())) == ResultSuccess);
|
||||
}
|
||||
|
||||
SECTION("translates MappedBuffer descriptors") {
|
||||
|
@ -168,7 +174,7 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
VAddr target_address = 0x10000000;
|
||||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address, buffer, static_cast<u32>(buffer.GetSize()), MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
const u32_le input[]{
|
||||
IPC::MakeHeader(0, 0, 2),
|
||||
|
@ -184,7 +190,7 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
CHECK(other_buffer == mem->Vector());
|
||||
|
||||
REQUIRE(process->vm_manager.UnmapRange(
|
||||
target_address, static_cast<u32>(buffer.GetSize())) == RESULT_SUCCESS);
|
||||
target_address, static_cast<u32>(buffer.GetSize())) == ResultSuccess);
|
||||
}
|
||||
|
||||
SECTION("translates mixed params") {
|
||||
|
@ -200,21 +206,23 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address_static, buffer_static, static_cast<u32>(buffer_static.GetSize()),
|
||||
MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
VAddr target_address_mapped = 0x20000000;
|
||||
result = process->vm_manager.MapBackingMemory(target_address_mapped, buffer_mapped,
|
||||
static_cast<u32>(buffer_mapped.GetSize()),
|
||||
MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
auto a = MakeObject(kernel);
|
||||
Handle a_handle;
|
||||
process->handle_table.Create(std::addressof(a_handle), a);
|
||||
const u32_le input[]{
|
||||
IPC::MakeHeader(0, 2, 8),
|
||||
0x12345678,
|
||||
0xABCDEF00,
|
||||
IPC::MoveHandleDesc(1),
|
||||
process->handle_table.Create(a).Unwrap(),
|
||||
a_handle,
|
||||
IPC::CallingPidDesc(),
|
||||
0,
|
||||
IPC::StaticBufferDesc(buffer_static.GetSize(), 0),
|
||||
|
@ -237,10 +245,10 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
|||
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address_static,
|
||||
static_cast<u32>(buffer_static.GetSize())) ==
|
||||
RESULT_SUCCESS);
|
||||
ResultSuccess);
|
||||
REQUIRE(process->vm_manager.UnmapRange(target_address_mapped,
|
||||
static_cast<u32>(buffer_mapped.GetSize())) ==
|
||||
RESULT_SUCCESS);
|
||||
ResultSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +309,7 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||
|
||||
auto result = context.WriteToOutgoingCommandBuffer(output, *process);
|
||||
|
||||
REQUIRE(result == RESULT_SUCCESS);
|
||||
REQUIRE(result == ResultSuccess);
|
||||
REQUIRE(output[2] == 0);
|
||||
}
|
||||
|
||||
|
@ -336,7 +344,7 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address, output_buffer, static_cast<u32>(output_buffer.GetSize()),
|
||||
MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
input[0] = IPC::MakeHeader(0, 0, 2);
|
||||
input[1] = IPC::StaticBufferDesc(input_buffer.size(), 0);
|
||||
|
@ -354,7 +362,7 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||
|
||||
CHECK(output_mem->Vector() == input_buffer);
|
||||
REQUIRE(process->vm_manager.UnmapRange(
|
||||
target_address, static_cast<u32>(output_buffer.GetSize())) == RESULT_SUCCESS);
|
||||
target_address, static_cast<u32>(output_buffer.GetSize())) == ResultSuccess);
|
||||
}
|
||||
|
||||
SECTION("translates StaticBuffer descriptors") {
|
||||
|
@ -368,7 +376,7 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||
auto result = process->vm_manager.MapBackingMemory(
|
||||
target_address, output_buffer, static_cast<u32>(output_buffer.GetSize()),
|
||||
MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
const u32_le input_cmdbuff[]{
|
||||
IPC::MakeHeader(0, 0, 2),
|
||||
|
@ -390,7 +398,7 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
|||
CHECK(output[2] == target_address);
|
||||
CHECK(output_mem->Vector() == input_buffer);
|
||||
REQUIRE(process->vm_manager.UnmapRange(
|
||||
target_address, static_cast<u32>(output_buffer.GetSize())) == RESULT_SUCCESS);
|
||||
target_address, static_cast<u32>(output_buffer.GetSize())) == ResultSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <vector>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
|
@ -27,7 +26,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
auto result =
|
||||
manager->MapBackingMemory(Memory::HEAP_VADDR, block, static_cast<u32>(block.GetSize()),
|
||||
Kernel::MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
CHECK(vma != manager->vma_map.end());
|
||||
|
@ -43,11 +42,10 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
auto result =
|
||||
manager->MapBackingMemory(Memory::HEAP_VADDR, block, static_cast<u32>(block.GetSize()),
|
||||
Kernel::MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
ResultCode code =
|
||||
manager->UnmapRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()));
|
||||
REQUIRE(code == RESULT_SUCCESS);
|
||||
Result code = manager->UnmapRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()));
|
||||
REQUIRE(code == ResultSuccess);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
CHECK(vma != manager->vma_map.end());
|
||||
|
@ -61,18 +59,18 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
auto result =
|
||||
manager->MapBackingMemory(Memory::HEAP_VADDR, block, static_cast<u32>(block.GetSize()),
|
||||
Kernel::MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
ResultCode code = manager->ReprotectRange(
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::VMAPermission::Execute);
|
||||
CHECK(code == RESULT_SUCCESS);
|
||||
Result code = manager->ReprotectRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()),
|
||||
Kernel::VMAPermission::Execute);
|
||||
CHECK(code == ResultSuccess);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
CHECK(vma != manager->vma_map.end());
|
||||
CHECK(vma->second.permissions == Kernel::VMAPermission::Execute);
|
||||
|
||||
code = manager->UnmapRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()));
|
||||
REQUIRE(code == RESULT_SUCCESS);
|
||||
REQUIRE(code == ResultSuccess);
|
||||
}
|
||||
|
||||
SECTION("changing memory state") {
|
||||
|
@ -81,29 +79,29 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
auto result =
|
||||
manager->MapBackingMemory(Memory::HEAP_VADDR, block, static_cast<u32>(block.GetSize()),
|
||||
Kernel::MemoryState::Private);
|
||||
REQUIRE(result.Code() == RESULT_SUCCESS);
|
||||
REQUIRE(result.Code() == ResultSuccess);
|
||||
|
||||
SECTION("reprotect memory range") {
|
||||
ResultCode code =
|
||||
Result code =
|
||||
manager->ReprotectRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()),
|
||||
Kernel::VMAPermission::ReadWrite);
|
||||
REQUIRE(code == RESULT_SUCCESS);
|
||||
REQUIRE(code == ResultSuccess);
|
||||
}
|
||||
|
||||
SECTION("with invalid address") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
Result code = manager->ChangeMemoryState(
|
||||
0xFFFFFFFF, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Locked,
|
||||
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Aliased,
|
||||
Kernel::VMAPermission::Execute);
|
||||
CHECK(code == Kernel::ERR_INVALID_ADDRESS);
|
||||
CHECK(code == Kernel::ResultInvalidAddress);
|
||||
}
|
||||
|
||||
SECTION("ignoring the original permissions") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
Result code = manager->ChangeMemoryState(
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Private,
|
||||
Kernel::VMAPermission::None, Kernel::MemoryState::Locked,
|
||||
Kernel::VMAPermission::Write);
|
||||
CHECK(code == RESULT_SUCCESS);
|
||||
CHECK(code == ResultSuccess);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
CHECK(vma != manager->vma_map.end());
|
||||
|
@ -112,11 +110,11 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
}
|
||||
|
||||
SECTION("enforcing the original permissions with correct expectations") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
Result code = manager->ChangeMemoryState(
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Private,
|
||||
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Aliased,
|
||||
Kernel::VMAPermission::Execute);
|
||||
CHECK(code == RESULT_SUCCESS);
|
||||
CHECK(code == ResultSuccess);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
CHECK(vma != manager->vma_map.end());
|
||||
|
@ -125,11 +123,11 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
}
|
||||
|
||||
SECTION("with incorrect permission expectations") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
Result code = manager->ChangeMemoryState(
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Private,
|
||||
Kernel::VMAPermission::Execute, Kernel::MemoryState::Aliased,
|
||||
Kernel::VMAPermission::Execute);
|
||||
CHECK(code == Kernel::ERR_INVALID_ADDRESS_STATE);
|
||||
CHECK(code == Kernel::ResultInvalidAddressState);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
CHECK(vma != manager->vma_map.end());
|
||||
|
@ -138,11 +136,11 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
}
|
||||
|
||||
SECTION("with incorrect state expectations") {
|
||||
ResultCode code = manager->ChangeMemoryState(
|
||||
Result code = manager->ChangeMemoryState(
|
||||
Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()), Kernel::MemoryState::Locked,
|
||||
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Aliased,
|
||||
Kernel::VMAPermission::Execute);
|
||||
CHECK(code == Kernel::ERR_INVALID_ADDRESS_STATE);
|
||||
CHECK(code == Kernel::ResultInvalidAddressState);
|
||||
|
||||
auto vma = manager->FindVMA(Memory::HEAP_VADDR);
|
||||
CHECK(vma != manager->vma_map.end());
|
||||
|
@ -150,8 +148,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
|
|||
CHECK(vma->second.meminfo_state == Kernel::MemoryState::Private);
|
||||
}
|
||||
|
||||
ResultCode code =
|
||||
manager->UnmapRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()));
|
||||
REQUIRE(code == RESULT_SUCCESS);
|
||||
Result code = manager->UnmapRange(Memory::HEAP_VADDR, static_cast<u32>(block.GetSize()));
|
||||
REQUIRE(code == ResultSuccess);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue