1
0
Fork 0
forked from suyu/suyu

Merge pull request #7866 from xerpi/svc-OutputDebugString32-CreateCodeMemory32-ControlCodeMemory32

kernel: svc: Add OutputDebugString32, CreateCodeMemory32, ControlCodeMemory32
This commit is contained in:
Mai M 2022-02-16 22:49:56 -05:00 committed by GitHub
commit c48b9668f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 4 deletions

View file

@ -645,6 +645,10 @@ static void OutputDebugString(Core::System& system, VAddr address, u64 len) {
LOG_DEBUG(Debug_Emulated, "{}", str); LOG_DEBUG(Debug_Emulated, "{}", str);
} }
static void OutputDebugString32(Core::System& system, u32 address, u32 len) {
OutputDebugString(system, address, len);
}
/// Gets system/memory information for the current process /// Gets system/memory information for the current process
static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle,
u64 info_sub_id) { u64 info_sub_id) {
@ -1404,7 +1408,7 @@ static ResultCode UnmapProcessMemory(Core::System& system, VAddr dst_address, Ha
} }
static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) { static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) {
LOG_TRACE(Kernel_SVC, "called, handle_out=0x{:X}, address=0x{:X}, size=0x{:X}", LOG_TRACE(Kernel_SVC, "called, handle_out={}, address=0x{:X}, size=0x{:X}",
static_cast<void*>(out), address, size); static_cast<void*>(out), address, size);
// Get kernel instance. // Get kernel instance.
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
@ -1438,6 +1442,10 @@ static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr addr
return ResultSuccess; return ResultSuccess;
} }
static ResultCode CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) {
return CreateCodeMemory(system, out, address, size);
}
static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation, static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation,
VAddr address, size_t size, Svc::MemoryPermission perm) { VAddr address, size_t size, Svc::MemoryPermission perm) {
@ -1517,6 +1525,12 @@ static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_han
return ResultSuccess; return ResultSuccess;
} }
static ResultCode ControlCodeMemory32(Core::System& system, Handle code_memory_handle,
u32 operation, u64 address, u64 size,
Svc::MemoryPermission perm) {
return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm);
}
static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address,
VAddr page_info_address, Handle process_handle, VAddr page_info_address, Handle process_handle,
VAddr address) { VAddr address) {
@ -2598,7 +2612,7 @@ static const FunctionDef SVC_Table_32[] = {
{0x24, SvcWrap32<GetProcessId32>, "GetProcessId32"}, {0x24, SvcWrap32<GetProcessId32>, "GetProcessId32"},
{0x25, SvcWrap32<GetThreadId32>, "GetThreadId32"}, {0x25, SvcWrap32<GetThreadId32>, "GetThreadId32"},
{0x26, SvcWrap32<Break32>, "Break32"}, {0x26, SvcWrap32<Break32>, "Break32"},
{0x27, nullptr, "OutputDebugString32"}, {0x27, SvcWrap32<OutputDebugString32>, "OutputDebugString32"},
{0x28, nullptr, "ReturnFromException32"}, {0x28, nullptr, "ReturnFromException32"},
{0x29, SvcWrap32<GetInfo32>, "GetInfo32"}, {0x29, SvcWrap32<GetInfo32>, "GetInfo32"},
{0x2a, nullptr, "FlushEntireDataCache32"}, {0x2a, nullptr, "FlushEntireDataCache32"},
@ -2634,8 +2648,8 @@ static const FunctionDef SVC_Table_32[] = {
{0x48, nullptr, "MapPhysicalMemoryUnsafe32"}, {0x48, nullptr, "MapPhysicalMemoryUnsafe32"},
{0x49, nullptr, "UnmapPhysicalMemoryUnsafe32"}, {0x49, nullptr, "UnmapPhysicalMemoryUnsafe32"},
{0x4a, nullptr, "SetUnsafeLimit32"}, {0x4a, nullptr, "SetUnsafeLimit32"},
{0x4b, nullptr, "CreateCodeMemory32"}, {0x4b, SvcWrap32<CreateCodeMemory32>, "CreateCodeMemory32"},
{0x4c, nullptr, "ControlCodeMemory32"}, {0x4c, SvcWrap32<ControlCodeMemory32>, "ControlCodeMemory32"},
{0x4d, nullptr, "SleepSystem32"}, {0x4d, nullptr, "SleepSystem32"},
{0x4e, nullptr, "ReadWriteRegister32"}, {0x4e, nullptr, "ReadWriteRegister32"},
{0x4f, nullptr, "SetProcessActivity32"}, {0x4f, nullptr, "SetProcessActivity32"},

View file

@ -669,4 +669,26 @@ void SvcWrap32(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
// Used by CreateCodeMemory32
template <ResultCode func(Core::System&, Handle*, u32, u32)>
void SvcWrap32(Core::System& system) {
Handle handle = 0;
const u32 retval = func(system, &handle, Param32(system, 1), Param32(system, 2)).raw;
system.CurrentArmInterface().SetReg(1, handle);
FuncReturn(system, retval);
}
// Used by ControlCodeMemory32
template <ResultCode func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)>
void SvcWrap32(Core::System& system) {
const u32 retval =
func(system, Param32(system, 0), Param32(system, 1), Param(system, 2), Param(system, 4),
static_cast<Svc::MemoryPermission>(Param32(system, 6)))
.raw;
FuncReturn(system, retval);
}
} // namespace Kernel } // namespace Kernel