yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

svc: Implement MapMemory.

This commit is contained in:
bunnei 2017-12-28 21:38:38 -05:00
parent 3421e1617e
commit 6e021f22b8
3 changed files with 17 additions and 4 deletions

View File

@ -42,6 +42,11 @@ void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1)).raw); FuncReturn(func(PARAM(0), PARAM(1)).raw);
} }
template <ResultCode func(u64, u64, u64)>
void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1), PARAM(2)).raw);
}
template <ResultCode func(u64, u64, s64)> template <ResultCode func(u64, u64, s64)>
void Wrap() { void Wrap() {
FuncReturn(func(PARAM(1), PARAM(2), (s64)PARAM(3)).raw); FuncReturn(func(PARAM(1), PARAM(2), (s64)PARAM(3)).raw);

View File

@ -26,12 +26,20 @@ namespace SVC {
/// Set the process heap to a given Size. It can both extend and shrink the heap. /// Set the process heap to a given Size. It can both extend and shrink the heap.
static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) {
LOG_TRACE(Kernel_SVC, "called, heap_size=%ull", heap_size); LOG_TRACE(Kernel_SVC, "called, heap_size=0x%llx", heap_size);
auto& process = *Kernel::g_current_process; auto& process = *Kernel::g_current_process;
CASCADE_RESULT(*heap_addr, process.HeapAllocate(Memory::HEAP_VADDR, heap_size, Kernel::VMAPermission::ReadWrite)); CASCADE_RESULT(*heap_addr, process.HeapAllocate(Memory::HEAP_VADDR, heap_size,
Kernel::VMAPermission::ReadWrite));
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
/// Maps a memory range into a different range.
static ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, u64 size) {
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x%llx, src_addr=0x%llx, size=0x%llx", dst_addr,
src_addr, size);
return Kernel::g_current_process->MirrorMemory(dst_addr, src_addr, size);
}
/// Connect to an OS service given the port name, returns the handle to the port to out /// Connect to an OS service given the port name, returns the handle to the port to out
static ResultCode ConnectToPort(Kernel::Handle* out_handle, VAddr port_name_address) { static ResultCode ConnectToPort(Kernel::Handle* out_handle, VAddr port_name_address) {
if (!Memory::IsValidVirtualAddress(port_name_address)) if (!Memory::IsValidVirtualAddress(port_name_address))
@ -216,7 +224,7 @@ static const FunctionDef SVC_Table[] = {
{0x01, HLE::Wrap<SetHeapSize>, "svcSetHeapSize"}, {0x01, HLE::Wrap<SetHeapSize>, "svcSetHeapSize"},
{0x02, nullptr, "svcSetMemoryPermission"}, {0x02, nullptr, "svcSetMemoryPermission"},
{0x03, nullptr, "svcSetMemoryAttribute"}, {0x03, nullptr, "svcSetMemoryAttribute"},
{0x04, nullptr, "svcMapMemory"}, {0x04, HLE::Wrap<MapMemory>, "svcMapMemory"},
{0x05, nullptr, "svcUnmapMemory"}, {0x05, nullptr, "svcUnmapMemory"},
{0x06, HLE::Wrap<QueryMemory>, "svcQueryMemory"}, {0x06, HLE::Wrap<QueryMemory>, "svcQueryMemory"},
{0x07, nullptr, "svcExitProcess"}, {0x07, nullptr, "svcExitProcess"},

View File

@ -136,7 +136,7 @@ enum : VAddr {
/// Application heap (includes stack). /// Application heap (includes stack).
HEAP_VADDR = 0x108000000, HEAP_VADDR = 0x108000000,
HEAP_SIZE = 0x08000000, HEAP_SIZE = 0x18000000,
HEAP_VADDR_END = HEAP_VADDR + HEAP_SIZE, HEAP_VADDR_END = HEAP_VADDR + HEAP_SIZE,
/// Area where shared memory buffers are mapped onto. /// Area where shared memory buffers are mapped onto.