aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/svc')
-rw-r--r--src/core/hle/kernel/svc/svc_activity.cpp30
-rw-r--r--src/core/hle/kernel/svc/svc_address_arbiter.cpp29
-rw-r--r--src/core/hle/kernel/svc/svc_address_translation.cpp46
-rw-r--r--src/core/hle/kernel/svc/svc_cache.cpp71
-rw-r--r--src/core/hle/kernel/svc/svc_code_memory.cpp57
-rw-r--r--src/core/hle/kernel/svc/svc_condition_variable.cpp30
-rw-r--r--src/core/hle/kernel/svc/svc_debug.cpp190
-rw-r--r--src/core/hle/kernel/svc/svc_debug_string.cpp16
-rw-r--r--src/core/hle/kernel/svc/svc_device_address_space.cpp254
-rw-r--r--src/core/hle/kernel/svc/svc_event.cpp43
-rw-r--r--src/core/hle/kernel/svc/svc_exception.cpp32
-rw-r--r--src/core/hle/kernel/svc/svc_info.cpp53
-rw-r--r--src/core/hle/kernel/svc/svc_insecure_memory.cpp35
-rw-r--r--src/core/hle/kernel/svc/svc_interrupt_event.cpp21
-rw-r--r--src/core/hle/kernel/svc/svc_io_pool.cpp67
-rw-r--r--src/core/hle/kernel/svc/svc_ipc.cpp103
-rw-r--r--src/core/hle/kernel/svc/svc_kernel_debug.cpp26
-rw-r--r--src/core/hle/kernel/svc/svc_light_ipc.cpp69
-rw-r--r--src/core/hle/kernel/svc/svc_lock.cpp25
-rw-r--r--src/core/hle/kernel/svc/svc_memory.cpp56
-rw-r--r--src/core/hle/kernel/svc/svc_physical_memory.cpp80
-rw-r--r--src/core/hle/kernel/svc/svc_port.cpp105
-rw-r--r--src/core/hle/kernel/svc/svc_power_management.cpp17
-rw-r--r--src/core/hle/kernel/svc/svc_process.cpp126
-rw-r--r--src/core/hle/kernel/svc/svc_process_memory.cpp60
-rw-r--r--src/core/hle/kernel/svc/svc_processor.cpp10
-rw-r--r--src/core/hle/kernel/svc/svc_query_memory.cpp56
-rw-r--r--src/core/hle/kernel/svc/svc_register.cpp23
-rw-r--r--src/core/hle/kernel/svc/svc_resource_limit.cpp80
-rw-r--r--src/core/hle/kernel/svc/svc_secure_monitor_call.cpp49
-rw-r--r--src/core/hle/kernel/svc/svc_session.cpp31
-rw-r--r--src/core/hle/kernel/svc/svc_shared_memory.cpp45
-rw-r--r--src/core/hle/kernel/svc/svc_synchronization.cpp70
-rw-r--r--src/core/hle/kernel/svc/svc_thread.cpp193
-rw-r--r--src/core/hle/kernel/svc/svc_thread_profiler.cpp56
-rw-r--r--src/core/hle/kernel/svc/svc_tick.cpp14
-rw-r--r--src/core/hle/kernel/svc/svc_transfer_memory.cpp48
37 files changed, 1961 insertions, 355 deletions
diff --git a/src/core/hle/kernel/svc/svc_activity.cpp b/src/core/hle/kernel/svc/svc_activity.cpp
index 8774a5c98..63bc08555 100644
--- a/src/core/hle/kernel/svc/svc_activity.cpp
+++ b/src/core/hle/kernel/svc/svc_activity.cpp
@@ -16,18 +16,19 @@ Result SetThreadActivity(Core::System& system, Handle thread_handle,
thread_activity);
// Validate the activity.
- constexpr auto IsValidThreadActivity = [](ThreadActivity activity) {
+ static constexpr auto IsValidThreadActivity = [](ThreadActivity activity) {
return activity == ThreadActivity::Runnable || activity == ThreadActivity::Paused;
};
R_UNLESS(IsValidThreadActivity(thread_activity), ResultInvalidEnumValue);
// Get the thread from its handle.
KScopedAutoObject thread =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Check that the activity is being set on a non-current thread for the current process.
- R_UNLESS(thread->GetOwnerProcess() == system.Kernel().CurrentProcess(), ResultInvalidHandle);
+ R_UNLESS(thread->GetOwnerProcess() == GetCurrentProcessPointer(system.Kernel()),
+ ResultInvalidHandle);
R_UNLESS(thread.GetPointerUnsafe() != GetCurrentThreadPointer(system.Kernel()), ResultBusy);
// Set the activity.
@@ -36,9 +37,30 @@ Result SetThreadActivity(Core::System& system, Handle thread_handle,
return ResultSuccess;
}
-Result SetThreadActivity32(Core::System& system, Handle thread_handle,
+Result SetProcessActivity(Core::System& system, Handle process_handle,
+ ProcessActivity process_activity) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result SetThreadActivity64(Core::System& system, Handle thread_handle,
ThreadActivity thread_activity) {
return SetThreadActivity(system, thread_handle, thread_activity);
}
+Result SetProcessActivity64(Core::System& system, Handle process_handle,
+ ProcessActivity process_activity) {
+ return SetProcessActivity(system, process_handle, process_activity);
+}
+
+Result SetThreadActivity64From32(Core::System& system, Handle thread_handle,
+ ThreadActivity thread_activity) {
+ return SetThreadActivity(system, thread_handle, thread_activity);
+}
+
+Result SetProcessActivity64From32(Core::System& system, Handle process_handle,
+ ProcessActivity process_activity) {
+ return SetProcessActivity(system, process_handle, process_activity);
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_address_arbiter.cpp b/src/core/hle/kernel/svc/svc_address_arbiter.cpp
index 842107726..998bd3f22 100644
--- a/src/core/hle/kernel/svc/svc_address_arbiter.cpp
+++ b/src/core/hle/kernel/svc/svc_address_arbiter.cpp
@@ -72,13 +72,7 @@ Result WaitForAddress(Core::System& system, VAddr address, ArbitrationType arb_t
timeout = timeout_ns;
}
- return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout);
-}
-
-Result WaitForAddress32(Core::System& system, u32 address, ArbitrationType arb_type, s32 value,
- u32 timeout_ns_low, u32 timeout_ns_high) {
- const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32));
- return WaitForAddress(system, address, arb_type, value, timeout);
+ return GetCurrentProcess(system.Kernel()).WaitAddressArbiter(address, arb_type, value, timeout);
}
// Signals to an address (via Address Arbiter)
@@ -101,13 +95,28 @@ Result SignalToAddress(Core::System& system, VAddr address, SignalType signal_ty
return ResultInvalidEnumValue;
}
- return system.Kernel().CurrentProcess()->SignalAddressArbiter(address, signal_type, value,
- count);
+ return GetCurrentProcess(system.Kernel())
+ .SignalAddressArbiter(address, signal_type, value, count);
}
-Result SignalToAddress32(Core::System& system, u32 address, SignalType signal_type, s32 value,
+Result WaitForAddress64(Core::System& system, VAddr address, ArbitrationType arb_type, s32 value,
+ s64 timeout_ns) {
+ return WaitForAddress(system, address, arb_type, value, timeout_ns);
+}
+
+Result SignalToAddress64(Core::System& system, VAddr address, SignalType signal_type, s32 value,
s32 count) {
return SignalToAddress(system, address, signal_type, value, count);
}
+Result WaitForAddress64From32(Core::System& system, u32 address, ArbitrationType arb_type,
+ s32 value, s64 timeout_ns) {
+ return WaitForAddress(system, address, arb_type, value, timeout_ns);
+}
+
+Result SignalToAddress64From32(Core::System& system, u32 address, SignalType signal_type, s32 value,
+ s32 count) {
+ return SignalToAddress(system, address, signal_type, value, count);
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_address_translation.cpp b/src/core/hle/kernel/svc/svc_address_translation.cpp
index 299e22ae6..c25e144cd 100644
--- a/src/core/hle/kernel/svc/svc_address_translation.cpp
+++ b/src/core/hle/kernel/svc/svc_address_translation.cpp
@@ -2,5 +2,49 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/kernel/svc.h"
+#include "core/hle/kernel/svc_results.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+Result QueryPhysicalAddress(Core::System& system, lp64::PhysicalMemoryInfo* out_info,
+ uint64_t address) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result QueryIoMapping(Core::System& system, uintptr_t* out_address, uintptr_t* out_size,
+ uint64_t physical_address, uint64_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result QueryPhysicalAddress64(Core::System& system, lp64::PhysicalMemoryInfo* out_info,
+ uint64_t address) {
+ R_RETURN(QueryPhysicalAddress(system, out_info, address));
+}
+
+Result QueryIoMapping64(Core::System& system, uintptr_t* out_address, uintptr_t* out_size,
+ uint64_t physical_address, uint64_t size) {
+ R_RETURN(QueryIoMapping(system, out_address, out_size, physical_address, size));
+}
+
+Result QueryPhysicalAddress64From32(Core::System& system, ilp32::PhysicalMemoryInfo* out_info,
+ uint32_t address) {
+ lp64::PhysicalMemoryInfo info{};
+ R_TRY(QueryPhysicalAddress(system, std::addressof(info), address));
+
+ *out_info = {
+ .physical_address = info.physical_address,
+ .virtual_address = static_cast<u32>(info.virtual_address),
+ .size = static_cast<u32>(info.size),
+ };
+ R_SUCCEED();
+}
+
+Result QueryIoMapping64From32(Core::System& system, uintptr_t* out_address, uintptr_t* out_size,
+ uint64_t physical_address, uint32_t size) {
+ R_RETURN(QueryIoMapping(system, reinterpret_cast<uintptr_t*>(out_address),
+ reinterpret_cast<uintptr_t*>(out_size), physical_address, size));
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_cache.cpp b/src/core/hle/kernel/svc/svc_cache.cpp
index 42167d35b..598b71da5 100644
--- a/src/core/hle/kernel/svc/svc_cache.cpp
+++ b/src/core/hle/kernel/svc/svc_cache.cpp
@@ -9,7 +9,28 @@
namespace Kernel::Svc {
-Result FlushProcessDataCache32(Core::System& system, Handle process_handle, u64 address, u64 size) {
+void FlushEntireDataCache(Core::System& system) {
+ UNIMPLEMENTED();
+}
+
+Result FlushDataCache(Core::System& system, VAddr address, size_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result InvalidateProcessDataCache(Core::System& system, Handle process_handle, uint64_t address,
+ uint64_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result StoreProcessDataCache(Core::System& system, Handle process_handle, uint64_t address,
+ uint64_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result FlushProcessDataCache(Core::System& system, Handle process_handle, u64 address, u64 size) {
// Validate address/size.
R_UNLESS(size > 0, ResultInvalidSize);
R_UNLESS(address == static_cast<uintptr_t>(address), ResultInvalidCurrentMemory);
@@ -17,7 +38,7 @@ Result FlushProcessDataCache32(Core::System& system, Handle process_handle, u64
// Get the process from its handle.
KScopedAutoObject process =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
// Verify the region is within range.
@@ -28,4 +49,50 @@ Result FlushProcessDataCache32(Core::System& system, Handle process_handle, u64
R_RETURN(system.Memory().FlushDataCache(*process, address, size));
}
+void FlushEntireDataCache64(Core::System& system) {
+ FlushEntireDataCache(system);
+}
+
+Result FlushDataCache64(Core::System& system, VAddr address, size_t size) {
+ R_RETURN(FlushDataCache(system, address, size));
+}
+
+Result InvalidateProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address,
+ uint64_t size) {
+ R_RETURN(InvalidateProcessDataCache(system, process_handle, address, size));
+}
+
+Result StoreProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address,
+ uint64_t size) {
+ R_RETURN(StoreProcessDataCache(system, process_handle, address, size));
+}
+
+Result FlushProcessDataCache64(Core::System& system, Handle process_handle, uint64_t address,
+ uint64_t size) {
+ R_RETURN(FlushProcessDataCache(system, process_handle, address, size));
+}
+
+void FlushEntireDataCache64From32(Core::System& system) {
+ return FlushEntireDataCache(system);
+}
+
+Result FlushDataCache64From32(Core::System& system, uint32_t address, uint32_t size) {
+ R_RETURN(FlushDataCache(system, address, size));
+}
+
+Result InvalidateProcessDataCache64From32(Core::System& system, Handle process_handle,
+ uint64_t address, uint64_t size) {
+ R_RETURN(InvalidateProcessDataCache(system, process_handle, address, size));
+}
+
+Result StoreProcessDataCache64From32(Core::System& system, Handle process_handle, uint64_t address,
+ uint64_t size) {
+ R_RETURN(StoreProcessDataCache(system, process_handle, address, size));
+}
+
+Result FlushProcessDataCache64From32(Core::System& system, Handle process_handle, uint64_t address,
+ uint64_t size) {
+ R_RETURN(FlushProcessDataCache(system, process_handle, address, size));
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_code_memory.cpp b/src/core/hle/kernel/svc/svc_code_memory.cpp
index 4cb21e101..538ff1c71 100644
--- a/src/core/hle/kernel/svc/svc_code_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_code_memory.cpp
@@ -46,7 +46,7 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t
R_UNLESS(code_mem != nullptr, ResultOutOfResource);
// Verify that the region is in range.
- R_UNLESS(system.CurrentProcess()->PageTable().Contains(address, size),
+ R_UNLESS(GetCurrentProcess(system.Kernel()).PageTable().Contains(address, size),
ResultInvalidCurrentMemory);
// Initialize the code memory.
@@ -56,19 +56,16 @@ Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t
KCodeMemory::Register(kernel, code_mem);
// Add the code memory to the handle table.
- R_TRY(system.CurrentProcess()->GetHandleTable().Add(out, code_mem));
+ R_TRY(GetCurrentProcess(system.Kernel()).GetHandleTable().Add(out, code_mem));
code_mem->Close();
return ResultSuccess;
}
-Result CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) {
- return CreateCodeMemory(system, out, address, size);
-}
-
-Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation,
- VAddr address, size_t size, MemoryPermission perm) {
+Result ControlCodeMemory(Core::System& system, Handle code_memory_handle,
+ CodeMemoryOperation operation, VAddr address, size_t size,
+ MemoryPermission perm) {
LOG_TRACE(Kernel_SVC,
"called, code_memory_handle=0x{:X}, operation=0x{:X}, address=0x{:X}, size=0x{:X}, "
@@ -82,20 +79,22 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 op
R_UNLESS((address < address + size), ResultInvalidCurrentMemory);
// Get the code memory from its handle.
- KScopedAutoObject code_mem =
- system.CurrentProcess()->GetHandleTable().GetObject<KCodeMemory>(code_memory_handle);
+ KScopedAutoObject code_mem = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KCodeMemory>(code_memory_handle);
R_UNLESS(code_mem.IsNotNull(), ResultInvalidHandle);
// NOTE: Here, Atmosphere extends the SVC to allow code memory operations on one's own process.
// This enables homebrew usage of these SVCs for JIT.
// Perform the operation.
- switch (static_cast<CodeMemoryOperation>(operation)) {
+ switch (operation) {
case CodeMemoryOperation::Map: {
// Check that the region is in range.
- R_UNLESS(
- system.CurrentProcess()->PageTable().CanContain(address, size, KMemoryState::CodeOut),
- ResultInvalidMemoryRegion);
+ R_UNLESS(GetCurrentProcess(system.Kernel())
+ .PageTable()
+ .CanContain(address, size, KMemoryState::CodeOut),
+ ResultInvalidMemoryRegion);
// Check the memory permission.
R_UNLESS(IsValidMapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission);
@@ -105,9 +104,10 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 op
} break;
case CodeMemoryOperation::Unmap: {
// Check that the region is in range.
- R_UNLESS(
- system.CurrentProcess()->PageTable().CanContain(address, size, KMemoryState::CodeOut),
- ResultInvalidMemoryRegion);
+ R_UNLESS(GetCurrentProcess(system.Kernel())
+ .PageTable()
+ .CanContain(address, size, KMemoryState::CodeOut),
+ ResultInvalidMemoryRegion);
// Check the memory permission.
R_UNLESS(IsValidUnmapCodeMemoryPermission(perm), ResultInvalidNewMemoryPermission);
@@ -146,9 +146,26 @@ Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 op
return ResultSuccess;
}
-Result ControlCodeMemory32(Core::System& system, Handle code_memory_handle, u32 operation,
- u64 address, u64 size, MemoryPermission perm) {
- return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm);
+Result CreateCodeMemory64(Core::System& system, Handle* out_handle, uint64_t address,
+ uint64_t size) {
+ R_RETURN(CreateCodeMemory(system, out_handle, address, size));
+}
+
+Result ControlCodeMemory64(Core::System& system, Handle code_memory_handle,
+ CodeMemoryOperation operation, uint64_t address, uint64_t size,
+ MemoryPermission perm) {
+ R_RETURN(ControlCodeMemory(system, code_memory_handle, operation, address, size, perm));
+}
+
+Result CreateCodeMemory64From32(Core::System& system, Handle* out_handle, uint32_t address,
+ uint32_t size) {
+ R_RETURN(CreateCodeMemory(system, out_handle, address, size));
+}
+
+Result ControlCodeMemory64From32(Core::System& system, Handle code_memory_handle,
+ CodeMemoryOperation operation, uint64_t address, uint64_t size,
+ MemoryPermission perm) {
+ R_RETURN(ControlCodeMemory(system, code_memory_handle, operation, address, size, perm));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_condition_variable.cpp b/src/core/hle/kernel/svc/svc_condition_variable.cpp
index d6cfc87c5..8ad1a0b8f 100644
--- a/src/core/hle/kernel/svc/svc_condition_variable.cpp
+++ b/src/core/hle/kernel/svc/svc_condition_variable.cpp
@@ -43,14 +43,8 @@ Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_ke
}
// Wait on the condition variable.
- return system.Kernel().CurrentProcess()->WaitConditionVariable(
- address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout);
-}
-
-Result WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag,
- u32 timeout_ns_low, u32 timeout_ns_high) {
- const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32));
- return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns);
+ return GetCurrentProcess(system.Kernel())
+ .WaitConditionVariable(address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout);
}
/// Signal process wide key
@@ -58,11 +52,25 @@ void SignalProcessWideKey(Core::System& system, VAddr cv_key, s32 count) {
LOG_TRACE(Kernel_SVC, "called, cv_key=0x{:X}, count=0x{:08X}", cv_key, count);
// Signal the condition variable.
- return system.Kernel().CurrentProcess()->SignalConditionVariable(
- Common::AlignDown(cv_key, sizeof(u32)), count);
+ return GetCurrentProcess(system.Kernel())
+ .SignalConditionVariable(Common::AlignDown(cv_key, sizeof(u32)), count);
+}
+
+Result WaitProcessWideKeyAtomic64(Core::System& system, uint64_t address, uint64_t cv_key,
+ uint32_t tag, int64_t timeout_ns) {
+ R_RETURN(WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns));
+}
+
+void SignalProcessWideKey64(Core::System& system, uint64_t cv_key, int32_t count) {
+ SignalProcessWideKey(system, cv_key, count);
+}
+
+Result WaitProcessWideKeyAtomic64From32(Core::System& system, uint32_t address, uint32_t cv_key,
+ uint32_t tag, int64_t timeout_ns) {
+ R_RETURN(WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns));
}
-void SignalProcessWideKey32(Core::System& system, u32 cv_key, s32 count) {
+void SignalProcessWideKey64From32(Core::System& system, uint32_t cv_key, int32_t count) {
SignalProcessWideKey(system, cv_key, count);
}
diff --git a/src/core/hle/kernel/svc/svc_debug.cpp b/src/core/hle/kernel/svc/svc_debug.cpp
index 299e22ae6..a14050fa7 100644
--- a/src/core/hle/kernel/svc/svc_debug.cpp
+++ b/src/core/hle/kernel/svc/svc_debug.cpp
@@ -2,5 +2,193 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/kernel/svc.h"
+#include "core/hle/kernel/svc_results.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+Result DebugActiveProcess(Core::System& system, Handle* out_handle, uint64_t process_id) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result BreakDebugProcess(Core::System& system, Handle debug_handle) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result TerminateDebugProcess(Core::System& system, Handle debug_handle) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result GetDebugEvent(Core::System& system, uint64_t out_info, Handle debug_handle) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result ContinueDebugEvent(Core::System& system, Handle debug_handle, uint32_t flags,
+ uint64_t user_thread_ids, int32_t num_thread_ids) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result GetDebugThreadContext(Core::System& system, uint64_t out_context, Handle debug_handle,
+ uint64_t thread_id, uint32_t context_flags) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result SetDebugThreadContext(Core::System& system, Handle debug_handle, uint64_t thread_id,
+ uint64_t user_context, uint32_t context_flags) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result QueryDebugProcessMemory(Core::System& system, uint64_t out_memory_info,
+ PageInfo* out_page_info, Handle debug_handle, uintptr_t address) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result ReadDebugProcessMemory(Core::System& system, uintptr_t buffer, Handle debug_handle,
+ uintptr_t address, size_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result WriteDebugProcessMemory(Core::System& system, Handle debug_handle, uintptr_t buffer,
+ uintptr_t address, size_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result SetHardwareBreakPoint(Core::System& system, HardwareBreakPointRegisterName name,
+ uint64_t flags, uint64_t value) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result GetDebugThreadParam(Core::System& system, uint64_t* out_64, uint32_t* out_32,
+ Handle debug_handle, uint64_t thread_id, DebugThreadParam param) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result DebugActiveProcess64(Core::System& system, Handle* out_handle, uint64_t process_id) {
+ R_RETURN(DebugActiveProcess(system, out_handle, process_id));
+}
+
+Result BreakDebugProcess64(Core::System& system, Handle debug_handle) {
+ R_RETURN(BreakDebugProcess(system, debug_handle));
+}
+
+Result TerminateDebugProcess64(Core::System& system, Handle debug_handle) {
+ R_RETURN(TerminateDebugProcess(system, debug_handle));
+}
+
+Result GetDebugEvent64(Core::System& system, uint64_t out_info, Handle debug_handle) {
+ R_RETURN(GetDebugEvent(system, out_info, debug_handle));
+}
+
+Result ContinueDebugEvent64(Core::System& system, Handle debug_handle, uint32_t flags,
+ uint64_t thread_ids, int32_t num_thread_ids) {
+ R_RETURN(ContinueDebugEvent(system, debug_handle, flags, thread_ids, num_thread_ids));
+}
+
+Result GetDebugThreadContext64(Core::System& system, uint64_t out_context, Handle debug_handle,
+ uint64_t thread_id, uint32_t context_flags) {
+ R_RETURN(GetDebugThreadContext(system, out_context, debug_handle, thread_id, context_flags));
+}
+
+Result SetDebugThreadContext64(Core::System& system, Handle debug_handle, uint64_t thread_id,
+ uint64_t context, uint32_t context_flags) {
+ R_RETURN(SetDebugThreadContext(system, debug_handle, thread_id, context, context_flags));
+}
+
+Result QueryDebugProcessMemory64(Core::System& system, uint64_t out_memory_info,
+ PageInfo* out_page_info, Handle debug_handle, uint64_t address) {
+ R_RETURN(
+ QueryDebugProcessMemory(system, out_memory_info, out_page_info, debug_handle, address));
+}
+
+Result ReadDebugProcessMemory64(Core::System& system, uint64_t buffer, Handle debug_handle,
+ uint64_t address, uint64_t size) {
+ R_RETURN(ReadDebugProcessMemory(system, buffer, debug_handle, address, size));
+}
+
+Result WriteDebugProcessMemory64(Core::System& system, Handle debug_handle, uint64_t buffer,
+ uint64_t address, uint64_t size) {
+ R_RETURN(WriteDebugProcessMemory(system, debug_handle, buffer, address, size));
+}
+
+Result SetHardwareBreakPoint64(Core::System& system, HardwareBreakPointRegisterName name,
+ uint64_t flags, uint64_t value) {
+ R_RETURN(SetHardwareBreakPoint(system, name, flags, value));
+}
+
+Result GetDebugThreadParam64(Core::System& system, uint64_t* out_64, uint32_t* out_32,
+ Handle debug_handle, uint64_t thread_id, DebugThreadParam param) {
+ R_RETURN(GetDebugThreadParam(system, out_64, out_32, debug_handle, thread_id, param));
+}
+
+Result DebugActiveProcess64From32(Core::System& system, Handle* out_handle, uint64_t process_id) {
+ R_RETURN(DebugActiveProcess(system, out_handle, process_id));
+}
+
+Result BreakDebugProcess64From32(Core::System& system, Handle debug_handle) {
+ R_RETURN(BreakDebugProcess(system, debug_handle));
+}
+
+Result TerminateDebugProcess64From32(Core::System& system, Handle debug_handle) {
+ R_RETURN(TerminateDebugProcess(system, debug_handle));
+}
+
+Result GetDebugEvent64From32(Core::System& system, uint32_t out_info, Handle debug_handle) {
+ R_RETURN(GetDebugEvent(system, out_info, debug_handle));
+}
+
+Result ContinueDebugEvent64From32(Core::System& system, Handle debug_handle, uint32_t flags,
+ uint32_t thread_ids, int32_t num_thread_ids) {
+ R_RETURN(ContinueDebugEvent(system, debug_handle, flags, thread_ids, num_thread_ids));
+}
+
+Result GetDebugThreadContext64From32(Core::System& system, uint32_t out_context,
+ Handle debug_handle, uint64_t thread_id,
+ uint32_t context_flags) {
+ R_RETURN(GetDebugThreadContext(system, out_context, debug_handle, thread_id, context_flags));
+}
+
+Result SetDebugThreadContext64From32(Core::System& system, Handle debug_handle, uint64_t thread_id,
+ uint32_t context, uint32_t context_flags) {
+ R_RETURN(SetDebugThreadContext(system, debug_handle, thread_id, context, context_flags));
+}
+
+Result QueryDebugProcessMemory64From32(Core::System& system, uint32_t out_memory_info,
+ PageInfo* out_page_info, Handle debug_handle,
+ uint32_t address) {
+ R_RETURN(
+ QueryDebugProcessMemory(system, out_memory_info, out_page_info, debug_handle, address));
+}
+
+Result ReadDebugProcessMemory64From32(Core::System& system, uint32_t buffer, Handle debug_handle,
+ uint32_t address, uint32_t size) {
+ R_RETURN(ReadDebugProcessMemory(system, buffer, debug_handle, address, size));
+}
+
+Result WriteDebugProcessMemory64From32(Core::System& system, Handle debug_handle, uint32_t buffer,
+ uint32_t address, uint32_t size) {
+ R_RETURN(WriteDebugProcessMemory(system, debug_handle, buffer, address, size));
+}
+
+Result SetHardwareBreakPoint64From32(Core::System& system, HardwareBreakPointRegisterName name,
+ uint64_t flags, uint64_t value) {
+ R_RETURN(SetHardwareBreakPoint(system, name, flags, value));
+}
+
+Result GetDebugThreadParam64From32(Core::System& system, uint64_t* out_64, uint32_t* out_32,
+ Handle debug_handle, uint64_t thread_id,
+ DebugThreadParam param) {
+ R_RETURN(GetDebugThreadParam(system, out_64, out_32, debug_handle, thread_id, param));
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_debug_string.cpp b/src/core/hle/kernel/svc/svc_debug_string.cpp
index 486e62cc4..d4bf062d1 100644
--- a/src/core/hle/kernel/svc/svc_debug_string.cpp
+++ b/src/core/hle/kernel/svc/svc_debug_string.cpp
@@ -8,18 +8,22 @@
namespace Kernel::Svc {
/// Used to output a message on a debug hardware unit - does nothing on a retail unit
-void OutputDebugString(Core::System& system, VAddr address, u64 len) {
- if (len == 0) {
- return;
- }
+Result OutputDebugString(Core::System& system, VAddr address, u64 len) {
+ R_SUCCEED_IF(len == 0);
std::string str(len, '\0');
system.Memory().ReadBlock(address, str.data(), str.size());
LOG_DEBUG(Debug_Emulated, "{}", str);
+
+ R_SUCCEED();
+}
+
+Result OutputDebugString64(Core::System& system, uint64_t debug_str, uint64_t len) {
+ R_RETURN(OutputDebugString(system, debug_str, len));
}
-void OutputDebugString32(Core::System& system, u32 address, u32 len) {
- OutputDebugString(system, address, len);
+Result OutputDebugString64From32(Core::System& system, uint32_t debug_str, uint32_t len) {
+ R_RETURN(OutputDebugString(system, debug_str, len));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_device_address_space.cpp b/src/core/hle/kernel/svc/svc_device_address_space.cpp
index 299e22ae6..f68c0e6a9 100644
--- a/src/core/hle/kernel/svc/svc_device_address_space.cpp
+++ b/src/core/hle/kernel/svc/svc_device_address_space.cpp
@@ -1,6 +1,258 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "common/alignment.h"
+#include "common/scope_exit.h"
+#include "core/core.h"
+#include "core/hle/kernel/k_device_address_space.h"
+#include "core/hle/kernel/k_process.h"
#include "core/hle/kernel/svc.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+constexpr inline u64 DeviceAddressSpaceAlignMask = (1ULL << 22) - 1;
+
+constexpr bool IsProcessAndDeviceAligned(uint64_t process_address, uint64_t device_address) {
+ return (process_address & DeviceAddressSpaceAlignMask) ==
+ (device_address & DeviceAddressSpaceAlignMask);
+}
+
+Result CreateDeviceAddressSpace(Core::System& system, Handle* out, uint64_t das_address,
+ uint64_t das_size) {
+ // Validate input.
+ R_UNLESS(Common::IsAligned(das_address, PageSize), ResultInvalidMemoryRegion);
+ R_UNLESS(Common::IsAligned(das_size, PageSize), ResultInvalidMemoryRegion);
+ R_UNLESS(das_size > 0, ResultInvalidMemoryRegion);
+ R_UNLESS((das_address < das_address + das_size), ResultInvalidMemoryRegion);
+
+ // Create the device address space.
+ KDeviceAddressSpace* das = KDeviceAddressSpace::Create(system.Kernel());
+ R_UNLESS(das != nullptr, ResultOutOfResource);
+ SCOPE_EXIT({ das->Close(); });
+
+ // Initialize the device address space.
+ R_TRY(das->Initialize(das_address, das_size));
+
+ // Register the device address space.
+ KDeviceAddressSpace::Register(system.Kernel(), das);
+
+ // Add to the handle table.
+ R_TRY(GetCurrentProcess(system.Kernel()).GetHandleTable().Add(out, das));
+
+ R_SUCCEED();
+}
+
+Result AttachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) {
+ // Get the device address space.
+ KScopedAutoObject das = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KDeviceAddressSpace>(das_handle);
+ R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
+
+ // Attach.
+ R_RETURN(das->Attach(device_name));
+}
+
+Result DetachDeviceAddressSpace(Core::System& system, DeviceName device_name, Handle das_handle) {
+ // Get the device address space.
+ KScopedAutoObject das = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KDeviceAddressSpace>(das_handle);
+ R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
+
+ // Detach.
+ R_RETURN(das->Detach(device_name));
+}
+
+constexpr bool IsValidDeviceMemoryPermission(MemoryPermission device_perm) {
+ switch (device_perm) {
+ case MemoryPermission::Read:
+ case MemoryPermission::Write:
+ case MemoryPermission::ReadWrite:
+ return true;
+ default:
+ return false;
+ }
+}
+
+Result MapDeviceAddressSpaceByForce(Core::System& system, Handle das_handle, Handle process_handle,
+ uint64_t process_address, size_t size, uint64_t device_address,
+ u32 option) {
+ // Decode the option.
+ const MapDeviceAddressSpaceOption option_pack{option};
+ const auto device_perm = option_pack.permission;
+ const auto reserved = option_pack.reserved;
+
+ // Validate input.
+ R_UNLESS(Common::IsAligned(process_address, PageSize), ResultInvalidAddress);
+ R_UNLESS(Common::IsAligned(device_address, PageSize), ResultInvalidAddress);
+ R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize);
+ R_UNLESS(size > 0, ResultInvalidSize);
+ R_UNLESS((process_address < process_address + size), ResultInvalidCurrentMemory);
+ R_UNLESS((device_address < device_address + size), ResultInvalidMemoryRegion);
+ R_UNLESS((process_address == static_cast<uintptr_t>(process_address)),
+ ResultInvalidCurrentMemory);
+ R_UNLESS(IsValidDeviceMemoryPermission(device_perm), ResultInvalidNewMemoryPermission);
+ R_UNLESS(reserved == 0, ResultInvalidEnumValue);
+
+ // Get the device address space.
+ KScopedAutoObject das = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KDeviceAddressSpace>(das_handle);
+ R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
+
+ // Get the process.
+ KScopedAutoObject process =
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
+ R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
+
+ // Validate that the process address is within range.
+ auto& page_table = process->PageTable();
+ R_UNLESS(page_table.Contains(process_address, size), ResultInvalidCurrentMemory);
+
+ // Map.
+ R_RETURN(
+ das->MapByForce(std::addressof(page_table), process_address, size, device_address, option));
+}
+
+Result MapDeviceAddressSpaceAligned(Core::System& system, Handle das_handle, Handle process_handle,
+ uint64_t process_address, size_t size, uint64_t device_address,
+ u32 option) {
+ // Decode the option.
+ const MapDeviceAddressSpaceOption option_pack{option};
+ const auto device_perm = option_pack.permission;
+ const auto reserved = option_pack.reserved;
+
+ // Validate input.
+ R_UNLESS(Common::IsAligned(process_address, PageSize), ResultInvalidAddress);
+ R_UNLESS(Common::IsAligned(device_address, PageSize), ResultInvalidAddress);
+ R_UNLESS(IsProcessAndDeviceAligned(process_address, device_address), ResultInvalidAddress);
+ R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize);
+ R_UNLESS(size > 0, ResultInvalidSize);
+ R_UNLESS((process_address < process_address + size), ResultInvalidCurrentMemory);
+ R_UNLESS((device_address < device_address + size), ResultInvalidMemoryRegion);
+ R_UNLESS((process_address == static_cast<uintptr_t>(process_address)),
+ ResultInvalidCurrentMemory);
+ R_UNLESS(IsValidDeviceMemoryPermission(device_perm), ResultInvalidNewMemoryPermission);
+ R_UNLESS(reserved == 0, ResultInvalidEnumValue);
+
+ // Get the device address space.
+ KScopedAutoObject das = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KDeviceAddressSpace>(das_handle);
+ R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
+
+ // Get the process.
+ KScopedAutoObject process =
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
+ R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
+
+ // Validate that the process address is within range.
+ auto& page_table = process->PageTable();
+ R_UNLESS(page_table.Contains(process_address, size), ResultInvalidCurrentMemory);
+
+ // Map.
+ R_RETURN(
+ das->MapAligned(std::addressof(page_table), process_address, size, device_address, option));
+}
+
+Result UnmapDeviceAddressSpace(Core::System& system, Handle das_handle, Handle process_handle,
+ uint64_t process_address, size_t size, uint64_t device_address) {
+ // Validate input.
+ R_UNLESS(Common::IsAligned(process_address, PageSize), ResultInvalidAddress);
+ R_UNLESS(Common::IsAligned(device_address, PageSize), ResultInvalidAddress);
+ R_UNLESS(Common::IsAligned(size, PageSize), ResultInvalidSize);
+ R_UNLESS(size > 0, ResultInvalidSize);
+ R_UNLESS((process_address < process_address + size), ResultInvalidCurrentMemory);
+ R_UNLESS((device_address < device_address + size), ResultInvalidMemoryRegion);
+ R_UNLESS((process_address == static_cast<uintptr_t>(process_address)),
+ ResultInvalidCurrentMemory);
+
+ // Get the device address space.
+ KScopedAutoObject das = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KDeviceAddressSpace>(das_handle);
+ R_UNLESS(das.IsNotNull(), ResultInvalidHandle);
+
+ // Get the process.
+ KScopedAutoObject process =
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
+ R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
+
+ // Validate that the process address is within range.
+ auto& page_table = process->PageTable();
+ R_UNLESS(page_table.Contains(process_address, size), ResultInvalidCurrentMemory);
+
+ R_RETURN(das->Unmap(std::addressof(page_table), process_address, size, device_address));
+}
+
+Result CreateDeviceAddressSpace64(Core::System& system, Handle* out_handle, uint64_t das_address,
+ uint64_t das_size) {
+ R_RETURN(CreateDeviceAddressSpace(system, out_handle, das_address, das_size));
+}
+
+Result AttachDeviceAddressSpace64(Core::System& system, DeviceName device_name, Handle das_handle) {
+ R_RETURN(AttachDeviceAddressSpace(system, device_name, das_handle));
+}
+
+Result DetachDeviceAddressSpace64(Core::System& system, DeviceName device_name, Handle das_handle) {
+ R_RETURN(DetachDeviceAddressSpace(system, device_name, das_handle));
+}
+
+Result MapDeviceAddressSpaceByForce64(Core::System& system, Handle das_handle,
+ Handle process_handle, uint64_t process_address,
+ uint64_t size, uint64_t device_address, u32 option) {
+ R_RETURN(MapDeviceAddressSpaceByForce(system, das_handle, process_handle, process_address, size,
+ device_address, option));
+}
+
+Result MapDeviceAddressSpaceAligned64(Core::System& system, Handle das_handle,
+ Handle process_handle, uint64_t process_address,
+ uint64_t size, uint64_t device_address, u32 option) {
+ R_RETURN(MapDeviceAddressSpaceAligned(system, das_handle, process_handle, process_address, size,
+ device_address, option));
+}
+
+Result UnmapDeviceAddressSpace64(Core::System& system, Handle das_handle, Handle process_handle,
+ uint64_t process_address, uint64_t size, uint64_t device_address) {
+ R_RETURN(UnmapDeviceAddressSpace(system, das_handle, process_handle, process_address, size,
+ device_address));
+}
+
+Result CreateDeviceAddressSpace64From32(Core::System& system, Handle* out_handle,
+ uint64_t das_address, uint64_t das_size) {
+ R_RETURN(CreateDeviceAddressSpace(system, out_handle, das_address, das_size));
+}
+
+Result AttachDeviceAddressSpace64From32(Core::System& system, DeviceName device_name,
+ Handle das_handle) {
+ R_RETURN(AttachDeviceAddressSpace(system, device_name, das_handle));
+}
+
+Result DetachDeviceAddressSpace64From32(Core::System& system, DeviceName device_name,
+ Handle das_handle) {
+ R_RETURN(DetachDeviceAddressSpace(system, device_name, das_handle));
+}
+
+Result MapDeviceAddressSpaceByForce64From32(Core::System& system, Handle das_handle,
+ Handle process_handle, uint64_t process_address,
+ uint32_t size, uint64_t device_address, u32 option) {
+ R_RETURN(MapDeviceAddressSpaceByForce(system, das_handle, process_handle, process_address, size,
+ device_address, option));
+}
+
+Result MapDeviceAddressSpaceAligned64From32(Core::System& system, Handle das_handle,
+ Handle process_handle, uint64_t process_address,
+ uint32_t size, uint64_t device_address, u32 option) {
+ R_RETURN(MapDeviceAddressSpaceAligned(system, das_handle, process_handle, process_address, size,
+ device_address, option));
+}
+
+Result UnmapDeviceAddressSpace64From32(Core::System& system, Handle das_handle,
+ Handle process_handle, uint64_t process_address,
+ uint32_t size, uint64_t device_address) {
+ R_RETURN(UnmapDeviceAddressSpace(system, das_handle, process_handle, process_address, size,
+ device_address));
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_event.cpp b/src/core/hle/kernel/svc/svc_event.cpp
index 885f02f50..a948493e8 100644
--- a/src/core/hle/kernel/svc/svc_event.cpp
+++ b/src/core/hle/kernel/svc/svc_event.cpp
@@ -15,7 +15,7 @@ Result SignalEvent(Core::System& system, Handle event_handle) {
LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
// Get the current handle table.
- const KHandleTable& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
+ const KHandleTable& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
// Get the event.
KScopedAutoObject event = handle_table.GetObject<KEvent>(event_handle);
@@ -24,15 +24,11 @@ Result SignalEvent(Core::System& system, Handle event_handle) {
return event->Signal();
}
-Result SignalEvent32(Core::System& system, Handle event_handle) {
- return SignalEvent(system, event_handle);
-}
-
Result ClearEvent(Core::System& system, Handle event_handle) {
LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
// Get the current handle table.
- const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
+ const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
// Try to clear the writable event.
{
@@ -55,19 +51,15 @@ Result ClearEvent(Core::System& system, Handle event_handle) {
return ResultInvalidHandle;
}
-Result ClearEvent32(Core::System& system, Handle event_handle) {
- return ClearEvent(system, event_handle);
-}
-
Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
LOG_DEBUG(Kernel_SVC, "called");
// Get the kernel reference and handle table.
auto& kernel = system.Kernel();
- auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
+ auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
// Reserve a new event from the process resource limit
- KScopedResourceReservation event_reservation(kernel.CurrentProcess(),
+ KScopedResourceReservation event_reservation(GetCurrentProcessPointer(kernel),
LimitableResource::EventCountMax);
R_UNLESS(event_reservation.Succeeded(), ResultLimitReached);
@@ -76,7 +68,7 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
R_UNLESS(event != nullptr, ResultOutOfResource);
// Initialize the event.
- event->Initialize(kernel.CurrentProcess());
+ event->Initialize(GetCurrentProcessPointer(kernel));
// Commit the thread reservation.
event_reservation.Commit();
@@ -104,8 +96,29 @@ Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
return ResultSuccess;
}
-Result CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) {
- return CreateEvent(system, out_write, out_read);
+Result SignalEvent64(Core::System& system, Handle event_handle) {
+ R_RETURN(SignalEvent(system, event_handle));
+}
+
+Result ClearEvent64(Core::System& system, Handle event_handle) {
+ R_RETURN(ClearEvent(system, event_handle));
+}
+
+Result CreateEvent64(Core::System& system, Handle* out_write_handle, Handle* out_read_handle) {
+ R_RETURN(CreateEvent(system, out_write_handle, out_read_handle));
+}
+
+Result SignalEvent64From32(Core::System& system, Handle event_handle) {
+ R_RETURN(SignalEvent(system, event_handle));
+}
+
+Result ClearEvent64From32(Core::System& system, Handle event_handle) {
+ R_RETURN(ClearEvent(system, event_handle));
+}
+
+Result CreateEvent64From32(Core::System& system, Handle* out_write_handle,
+ Handle* out_read_handle) {
+ R_RETURN(CreateEvent(system, out_write_handle, out_read_handle));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_exception.cpp b/src/core/hle/kernel/svc/svc_exception.cpp
index fb9f133c1..c2782908d 100644
--- a/src/core/hle/kernel/svc/svc_exception.cpp
+++ b/src/core/hle/kernel/svc/svc_exception.cpp
@@ -12,10 +12,10 @@
namespace Kernel::Svc {
/// Break program execution
-void Break(Core::System& system, u32 reason, u64 info1, u64 info2) {
+void Break(Core::System& system, BreakReason reason, u64 info1, u64 info2) {
BreakReason break_reason =
- static_cast<BreakReason>(reason & ~static_cast<u32>(BreakReason::NotificationOnlyFlag));
- bool notification_only = (reason & static_cast<u32>(BreakReason::NotificationOnlyFlag)) != 0;
+ reason & static_cast<BreakReason>(~BreakReason::NotificationOnlyFlag);
+ bool notification_only = True(reason & BreakReason::NotificationOnlyFlag);
bool has_dumped_buffer{};
std::vector<u8> debug_buffer;
@@ -90,9 +90,9 @@ void Break(Core::System& system, u32 reason, u64 info1, u64 info2) {
break;
}
- system.GetReporter().SaveSvcBreakReport(reason, notification_only, info1, info2,
- has_dumped_buffer ? std::make_optional(debug_buffer)
- : std::nullopt);
+ system.GetReporter().SaveSvcBreakReport(
+ static_cast<u32>(reason), notification_only, info1, info2,
+ has_dumped_buffer ? std::make_optional(debug_buffer) : std::nullopt);
if (!notification_only) {
LOG_CRITICAL(
@@ -114,8 +114,24 @@ void Break(Core::System& system, u32 reason, u64 info1, u64 info2) {
}
}
-void Break32(Core::System& system, u32 reason, u32 info1, u32 info2) {
- Break(system, reason, info1, info2);
+void ReturnFromException(Core::System& system, Result result) {
+ UNIMPLEMENTED();
+}
+
+void Break64(Core::System& system, BreakReason break_reason, uint64_t arg, uint64_t size) {
+ Break(system, break_reason, arg, size);
+}
+
+void Break64From32(Core::System& system, BreakReason break_reason, uint32_t arg, uint32_t size) {
+ Break(system, break_reason, arg, size);
+}
+
+void ReturnFromException64(Core::System& system, Result result) {
+ ReturnFromException(system, result);
+}
+
+void ReturnFromException64From32(Core::System& system, Result result) {
+ ReturnFromException(system, result);
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp
index df5dd85a4..58dc47508 100644
--- a/src/core/hle/kernel/svc/svc_info.cpp
+++ b/src/core/hle/kernel/svc/svc_info.cpp
@@ -10,11 +10,12 @@
namespace Kernel::Svc {
/// Gets system/memory information for the current process
-Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u64 info_sub_id) {
- LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
- info_sub_id, handle);
+Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle handle,
+ u64 info_sub_id) {
+ LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}",
+ info_id_type, info_sub_id, handle);
- const auto info_id_type = static_cast<InfoType>(info_id);
+ u32 info_id = static_cast<u32>(info_id_type);
switch (info_id_type) {
case InfoType::CoreMask:
@@ -43,7 +44,7 @@ Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u6
return ResultInvalidEnumValue;
}
- const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
+ const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(handle);
if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Process is not valid! info_id={}, info_sub_id={}, handle={:08X}",
@@ -153,7 +154,7 @@ Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u6
return ResultInvalidCombination;
}
- KProcess* const current_process = system.Kernel().CurrentProcess();
+ KProcess* const current_process = GetCurrentProcessPointer(system.Kernel());
KHandleTable& handle_table = current_process->GetHandleTable();
const auto resource_limit = current_process->GetResourceLimit();
if (!resource_limit) {
@@ -182,7 +183,7 @@ Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u6
return ResultInvalidCombination;
}
- *result = system.Kernel().CurrentProcess()->GetRandomEntropy(info_sub_id);
+ *result = GetCurrentProcess(system.Kernel()).GetRandomEntropy(info_sub_id);
return ResultSuccess;
case InfoType::InitialProcessIdRange:
@@ -199,9 +200,9 @@ Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u6
return ResultInvalidCombination;
}
- KScopedAutoObject thread =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(
- static_cast<Handle>(handle));
+ KScopedAutoObject thread = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KThread>(static_cast<Handle>(handle));
if (thread.IsNull()) {
LOG_ERROR(Kernel_SVC, "Thread handle does not exist, handle=0x{:08X}",
static_cast<Handle>(handle));
@@ -248,7 +249,7 @@ Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u6
R_UNLESS(info_sub_id == 0, ResultInvalidCombination);
// Get the handle table.
- KProcess* current_process = system.Kernel().CurrentProcess();
+ KProcess* current_process = GetCurrentProcessPointer(system.Kernel());
KHandleTable& handle_table = current_process->GetHandleTable();
// Get a new handle for the current process.
@@ -267,16 +268,30 @@ Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, u6
}
}
-Result GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low,
- u32 info_id, u32 handle, u32 sub_id_high) {
- const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)};
- u64 res_value{};
+Result GetSystemInfo(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle,
+ uint64_t info_subtype) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result GetInfo64(Core::System& system, uint64_t* out, InfoType info_type, Handle handle,
+ uint64_t info_subtype) {
+ R_RETURN(GetInfo(system, out, info_type, handle, info_subtype));
+}
- const Result result{GetInfo(system, &res_value, info_id, handle, sub_id)};
- *result_high = static_cast<u32>(res_value >> 32);
- *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max());
+Result GetSystemInfo64(Core::System& system, uint64_t* out, SystemInfoType info_type, Handle handle,
+ uint64_t info_subtype) {
+ R_RETURN(GetSystemInfo(system, out, info_type, handle, info_subtype));
+}
+
+Result GetInfo64From32(Core::System& system, uint64_t* out, InfoType info_type, Handle handle,
+ uint64_t info_subtype) {
+ R_RETURN(GetInfo(system, out, info_type, handle, info_subtype));
+}
- return result;
+Result GetSystemInfo64From32(Core::System& system, uint64_t* out, SystemInfoType info_type,
+ Handle handle, uint64_t info_subtype) {
+ R_RETURN(GetSystemInfo(system, out, info_type, handle, info_subtype));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_insecure_memory.cpp b/src/core/hle/kernel/svc/svc_insecure_memory.cpp
new file mode 100644
index 000000000..79882685d
--- /dev/null
+++ b/src/core/hle/kernel/svc/svc_insecure_memory.cpp
@@ -0,0 +1,35 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "core/hle/kernel/svc.h"
+#include "core/hle/kernel/svc_results.h"
+
+namespace Kernel::Svc {
+
+Result MapInsecureMemory(Core::System& system, uintptr_t address, size_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result UnmapInsecureMemory(Core::System& system, uintptr_t address, size_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result MapInsecureMemory64(Core::System& system, uint64_t address, uint64_t size) {
+ R_RETURN(MapInsecureMemory(system, address, size));
+}
+
+Result UnmapInsecureMemory64(Core::System& system, uint64_t address, uint64_t size) {
+ R_RETURN(UnmapInsecureMemory(system, address, size));
+}
+
+Result MapInsecureMemory64From32(Core::System& system, uint32_t address, uint32_t size) {
+ R_RETURN(MapInsecureMemory(system, address, size));
+}
+
+Result UnmapInsecureMemory64From32(Core::System& system, uint32_t address, uint32_t size) {
+ R_RETURN(UnmapInsecureMemory(system, address, size));
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_interrupt_event.cpp b/src/core/hle/kernel/svc/svc_interrupt_event.cpp
index 299e22ae6..768b30a1f 100644
--- a/src/core/hle/kernel/svc/svc_interrupt_event.cpp
+++ b/src/core/hle/kernel/svc/svc_interrupt_event.cpp
@@ -2,5 +2,24 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/kernel/svc.h"
+#include "core/hle/kernel/svc_results.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+Result CreateInterruptEvent(Core::System& system, Handle* out, int32_t interrupt_id,
+ InterruptType type) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result CreateInterruptEvent64(Core::System& system, Handle* out_read_handle, int32_t interrupt_id,
+ InterruptType interrupt_type) {
+ R_RETURN(CreateInterruptEvent(system, out_read_handle, interrupt_id, interrupt_type));
+}
+
+Result CreateInterruptEvent64From32(Core::System& system, Handle* out_read_handle,
+ int32_t interrupt_id, InterruptType interrupt_type) {
+ R_RETURN(CreateInterruptEvent(system, out_read_handle, interrupt_id, interrupt_type));
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_io_pool.cpp b/src/core/hle/kernel/svc/svc_io_pool.cpp
index 299e22ae6..33f3d69bf 100644
--- a/src/core/hle/kernel/svc/svc_io_pool.cpp
+++ b/src/core/hle/kernel/svc/svc_io_pool.cpp
@@ -2,5 +2,70 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/kernel/svc.h"
+#include "core/hle/kernel/svc_results.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+Result CreateIoPool(Core::System& system, Handle* out, IoPoolType pool_type) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result CreateIoRegion(Core::System& system, Handle* out, Handle io_pool_handle, uint64_t phys_addr,
+ size_t size, MemoryMapping mapping, MemoryPermission perm) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result MapIoRegion(Core::System& system, Handle io_region_handle, uintptr_t address, size_t size,
+ MemoryPermission map_perm) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result UnmapIoRegion(Core::System& system, Handle io_region_handle, uintptr_t address,
+ size_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result CreateIoPool64(Core::System& system, Handle* out_handle, IoPoolType pool_type) {
+ R_RETURN(CreateIoPool(system, out_handle, pool_type));
+}
+
+Result CreateIoRegion64(Core::System& system, Handle* out_handle, Handle io_pool,
+ uint64_t physical_address, uint64_t size, MemoryMapping mapping,
+ MemoryPermission perm) {
+ R_RETURN(CreateIoRegion(system, out_handle, io_pool, physical_address, size, mapping, perm));
+}
+
+Result MapIoRegion64(Core::System& system, Handle io_region, uint64_t address, uint64_t size,
+ MemoryPermission perm) {
+ R_RETURN(MapIoRegion(system, io_region, address, size, perm));
+}
+
+Result UnmapIoRegion64(Core::System& system, Handle io_region, uint64_t address, uint64_t size) {
+ R_RETURN(UnmapIoRegion(system, io_region, address, size));
+}
+
+Result CreateIoPool64From32(Core::System& system, Handle* out_handle, IoPoolType pool_type) {
+ R_RETURN(CreateIoPool(system, out_handle, pool_type));
+}
+
+Result CreateIoRegion64From32(Core::System& system, Handle* out_handle, Handle io_pool,
+ uint64_t physical_address, uint32_t size, MemoryMapping mapping,
+ MemoryPermission perm) {
+ R_RETURN(CreateIoRegion(system, out_handle, io_pool, physical_address, size, mapping, perm));
+}
+
+Result MapIoRegion64From32(Core::System& system, Handle io_region, uint32_t address, uint32_t size,
+ MemoryPermission perm) {
+ R_RETURN(MapIoRegion(system, io_region, address, size, perm));
+}
+
+Result UnmapIoRegion64From32(Core::System& system, Handle io_region, uint32_t address,
+ uint32_t size) {
+ R_RETURN(UnmapIoRegion(system, io_region, address, size));
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_ipc.cpp b/src/core/hle/kernel/svc/svc_ipc.cpp
index dbb68e89a..a7a2c3b92 100644
--- a/src/core/hle/kernel/svc/svc_ipc.cpp
+++ b/src/core/hle/kernel/svc/svc_ipc.cpp
@@ -12,11 +12,9 @@ namespace Kernel::Svc {
/// Makes a blocking IPC call to a service.
Result SendSyncRequest(Core::System& system, Handle handle) {
- auto& kernel = system.Kernel();
-
// Get the client session from its handle.
KScopedAutoObject session =
- kernel.CurrentProcess()->GetHandleTable().GetObject<KClientSession>(handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KClientSession>(handle);
R_UNLESS(session.IsNotNull(), ResultInvalidHandle);
LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({})", handle, session->GetName());
@@ -24,20 +22,37 @@ Result SendSyncRequest(Core::System& system, Handle handle) {
return session->SendSyncRequest();
}
-Result SendSyncRequest32(Core::System& system, Handle handle) {
- return SendSyncRequest(system, handle);
+Result SendSyncRequestWithUserBuffer(Core::System& system, uint64_t message_buffer,
+ uint64_t message_buffer_size, Handle session_handle) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result SendAsyncRequestWithUserBuffer(Core::System& system, Handle* out_event_handle,
+ uint64_t message_buffer, uint64_t message_buffer_size,
+ Handle session_handle) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
}
-Result ReplyAndReceive(Core::System& system, s32* out_index, Handle* handles, s32 num_handles,
+Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_addr, s32 num_handles,
Handle reply_target, s64 timeout_ns) {
auto& kernel = system.Kernel();
- auto& handle_table = GetCurrentThread(kernel).GetOwnerProcess()->GetHandleTable();
+ auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
+
+ R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange);
+ R_UNLESS(system.Memory().IsValidVirtualAddressRange(
+ handles_addr, static_cast<u64>(sizeof(Handle) * num_handles)),
+ ResultInvalidPointer);
+
+ std::vector<Handle> handles(num_handles);
+ system.Memory().ReadBlock(handles_addr, handles.data(), sizeof(Handle) * num_handles);
// Convert handle list to object table.
std::vector<KSynchronizationObject*> objs(num_handles);
- R_UNLESS(
- handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles, num_handles),
- ResultInvalidHandle);
+ R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles.data(),
+ num_handles),
+ ResultInvalidHandle);
// Ensure handles are closed when we're done.
SCOPE_EXIT({
@@ -86,4 +101,72 @@ Result ReplyAndReceive(Core::System& system, s32* out_index, Handle* handles, s3
}
}
+Result ReplyAndReceiveWithUserBuffer(Core::System& system, int32_t* out_index,
+ uint64_t message_buffer, uint64_t message_buffer_size,
+ uint64_t handles, int32_t num_handles, Handle reply_target,
+ int64_t timeout_ns) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result SendSyncRequest64(Core::System& system, Handle session_handle) {
+ R_RETURN(SendSyncRequest(system, session_handle));
+}
+
+Result SendSyncRequestWithUserBuffer64(Core::System& system, uint64_t message_buffer,
+ uint64_t message_buffer_size, Handle session_handle) {
+ R_RETURN(
+ SendSyncRequestWithUserBuffer(system, message_buffer, message_buffer_size, session_handle));
+}
+
+Result SendAsyncRequestWithUserBuffer64(Core::System& system, Handle* out_event_handle,
+ uint64_t message_buffer, uint64_t message_buffer_size,
+ Handle session_handle) {
+ R_RETURN(SendAsyncRequestWithUserBuffer(system, out_event_handle, message_buffer,
+ message_buffer_size, session_handle));
+}
+
+Result ReplyAndReceive64(Core::System& system, int32_t* out_index, uint64_t handles,
+ int32_t num_handles, Handle reply_target, int64_t timeout_ns) {
+ R_RETURN(ReplyAndReceive(system, out_index, handles, num_handles, reply_target, timeout_ns));
+}
+
+Result ReplyAndReceiveWithUserBuffer64(Core::System& system, int32_t* out_index,
+ uint64_t message_buffer, uint64_t message_buffer_size,
+ uint64_t handles, int32_t num_handles, Handle reply_target,
+ int64_t timeout_ns) {
+ R_RETURN(ReplyAndReceiveWithUserBuffer(system, out_index, message_buffer, message_buffer_size,
+ handles, num_handles, reply_target, timeout_ns));
+}
+
+Result SendSyncRequest64From32(Core::System& system, Handle session_handle) {
+ R_RETURN(SendSyncRequest(system, session_handle));
+}
+
+Result SendSyncRequestWithUserBuffer64From32(Core::System& system, uint32_t message_buffer,
+ uint32_t message_buffer_size, Handle session_handle) {
+ R_RETURN(
+ SendSyncRequestWithUserBuffer(system, message_buffer, message_buffer_size, session_handle));
+}
+
+Result SendAsyncRequestWithUserBuffer64From32(Core::System& system, Handle* out_event_handle,
+ uint32_t message_buffer, uint32_t message_buffer_size,
+ Handle session_handle) {
+ R_RETURN(SendAsyncRequestWithUserBuffer(system, out_event_handle, message_buffer,
+ message_buffer_size, session_handle));
+}
+
+Result ReplyAndReceive64From32(Core::System& system, int32_t* out_index, uint32_t handles,
+ int32_t num_handles, Handle reply_target, int64_t timeout_ns) {
+ R_RETURN(ReplyAndReceive(system, out_index, handles, num_handles, reply_target, timeout_ns));
+}
+
+Result ReplyAndReceiveWithUserBuffer64From32(Core::System& system, int32_t* out_index,
+ uint32_t message_buffer, uint32_t message_buffer_size,
+ uint32_t handles, int32_t num_handles,
+ Handle reply_target, int64_t timeout_ns) {
+ R_RETURN(ReplyAndReceiveWithUserBuffer(system, out_index, message_buffer, message_buffer_size,
+ handles, num_handles, reply_target, timeout_ns));
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_kernel_debug.cpp b/src/core/hle/kernel/svc/svc_kernel_debug.cpp
index 454255e7a..cee048279 100644
--- a/src/core/hle/kernel/svc/svc_kernel_debug.cpp
+++ b/src/core/hle/kernel/svc/svc_kernel_debug.cpp
@@ -5,15 +5,31 @@
namespace Kernel::Svc {
-void KernelDebug([[maybe_unused]] Core::System& system, [[maybe_unused]] u32 kernel_debug_type,
- [[maybe_unused]] u64 param1, [[maybe_unused]] u64 param2,
- [[maybe_unused]] u64 param3) {
+void KernelDebug(Core::System& system, KernelDebugType kernel_debug_type, u64 arg0, u64 arg1,
+ u64 arg2) {
// Intentionally do nothing, as this does nothing in released kernel binaries.
}
-void ChangeKernelTraceState([[maybe_unused]] Core::System& system,
- [[maybe_unused]] u32 trace_state) {
+void ChangeKernelTraceState(Core::System& system, KernelTraceState trace_state) {
// Intentionally do nothing, as this does nothing in released kernel binaries.
}
+void KernelDebug64(Core::System& system, KernelDebugType kern_debug_type, uint64_t arg0,
+ uint64_t arg1, uint64_t arg2) {
+ KernelDebug(system, kern_debug_type, arg0, arg1, arg2);
+}
+
+void ChangeKernelTraceState64(Core::System& system, KernelTraceState kern_trace_state) {
+ ChangeKernelTraceState(system, kern_trace_state);
+}
+
+void KernelDebug64From32(Core::System& system, KernelDebugType kern_debug_type, uint64_t arg0,
+ uint64_t arg1, uint64_t arg2) {
+ KernelDebug(system, kern_debug_type, arg0, arg1, arg2);
+}
+
+void ChangeKernelTraceState64From32(Core::System& system, KernelTraceState kern_trace_state) {
+ ChangeKernelTraceState(system, kern_trace_state);
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_light_ipc.cpp b/src/core/hle/kernel/svc/svc_light_ipc.cpp
index 299e22ae6..b76ce984c 100644
--- a/src/core/hle/kernel/svc/svc_light_ipc.cpp
+++ b/src/core/hle/kernel/svc/svc_light_ipc.cpp
@@ -1,6 +1,73 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "core/arm/arm_interface.h"
+#include "core/core.h"
#include "core/hle/kernel/svc.h"
+#include "core/hle/kernel/svc_results.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+Result SendSyncRequestLight(Core::System& system, Handle session_handle, u32* args) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result ReplyAndReceiveLight(Core::System& system, Handle session_handle, u32* args) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result SendSyncRequestLight64(Core::System& system, Handle session_handle, u32* args) {
+ R_RETURN(SendSyncRequestLight(system, session_handle, args));
+}
+
+Result ReplyAndReceiveLight64(Core::System& system, Handle session_handle, u32* args) {
+ R_RETURN(ReplyAndReceiveLight(system, session_handle, args));
+}
+
+Result SendSyncRequestLight64From32(Core::System& system, Handle session_handle, u32* args) {
+ R_RETURN(SendSyncRequestLight(system, session_handle, args));
+}
+
+Result ReplyAndReceiveLight64From32(Core::System& system, Handle session_handle, u32* args) {
+ R_RETURN(ReplyAndReceiveLight(system, session_handle, args));
+}
+
+// Custom ABI implementation for light IPC.
+
+template <typename F>
+static void SvcWrap_LightIpc(Core::System& system, F&& cb) {
+ auto& core = system.CurrentArmInterface();
+ std::array<u32, 7> arguments{};
+
+ Handle session_handle = static_cast<Handle>(core.GetReg(0));
+ for (int i = 0; i < 7; i++) {
+ arguments[i] = static_cast<u32>(core.GetReg(i + 1));
+ }
+
+ Result ret = cb(system, session_handle, arguments.data());
+
+ core.SetReg(0, ret.raw);
+ for (int i = 0; i < 7; i++) {
+ core.SetReg(i + 1, arguments[i]);
+ }
+}
+
+void SvcWrap_SendSyncRequestLight64(Core::System& system) {
+ SvcWrap_LightIpc(system, SendSyncRequestLight64);
+}
+
+void SvcWrap_ReplyAndReceiveLight64(Core::System& system) {
+ SvcWrap_LightIpc(system, ReplyAndReceiveLight64);
+}
+
+void SvcWrap_SendSyncRequestLight64From32(Core::System& system) {
+ SvcWrap_LightIpc(system, SendSyncRequestLight64From32);
+}
+
+void SvcWrap_ReplyAndReceiveLight64From32(Core::System& system) {
+ SvcWrap_LightIpc(system, ReplyAndReceiveLight64From32);
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_lock.cpp b/src/core/hle/kernel/svc/svc_lock.cpp
index 45f2a6553..f3d3e140b 100644
--- a/src/core/hle/kernel/svc/svc_lock.cpp
+++ b/src/core/hle/kernel/svc/svc_lock.cpp
@@ -24,11 +24,7 @@ Result ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address,
return ResultInvalidAddress;
}
- return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag);
-}
-
-Result ArbitrateLock32(Core::System& system, Handle thread_handle, u32 address, u32 tag) {
- return ArbitrateLock(system, thread_handle, address, tag);
+ return GetCurrentProcess(system.Kernel()).WaitForAddress(thread_handle, address, tag);
}
/// Unlock a mutex
@@ -47,11 +43,24 @@ Result ArbitrateUnlock(Core::System& system, VAddr address) {
return ResultInvalidAddress;
}
- return system.Kernel().CurrentProcess()->SignalToAddress(address);
+ return GetCurrentProcess(system.Kernel()).SignalToAddress(address);
+}
+
+Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) {
+ R_RETURN(ArbitrateLock(system, thread_handle, address, tag));
+}
+
+Result ArbitrateUnlock64(Core::System& system, uint64_t address) {
+ R_RETURN(ArbitrateUnlock(system, address));
+}
+
+Result ArbitrateLock64From32(Core::System& system, Handle thread_handle, uint32_t address,
+ uint32_t tag) {
+ R_RETURN(ArbitrateLock(system, thread_handle, address, tag));
}
-Result ArbitrateUnlock32(Core::System& system, u32 address) {
- return ArbitrateUnlock(system, address);
+Result ArbitrateUnlock64From32(Core::System& system, uint32_t address) {
+ R_RETURN(ArbitrateUnlock(system, address));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_memory.cpp b/src/core/hle/kernel/svc/svc_memory.cpp
index f78b1239b..214bcd073 100644
--- a/src/core/hle/kernel/svc/svc_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_memory.cpp
@@ -113,7 +113,7 @@ Result SetMemoryPermission(Core::System& system, VAddr address, u64 size, Memory
R_UNLESS(IsValidSetMemoryPermission(perm), ResultInvalidNewMemoryPermission);
// Validate that the region is in range for the current process.
- auto& page_table = system.Kernel().CurrentProcess()->PageTable();
+ auto& page_table = GetCurrentProcess(system.Kernel()).PageTable();
R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory);
// Set the memory attribute.
@@ -137,23 +137,19 @@ Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mas
R_UNLESS((mask | attr | SupportedMask) == SupportedMask, ResultInvalidCombination);
// Validate that the region is in range for the current process.
- auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
+ auto& page_table{GetCurrentProcess(system.Kernel()).PageTable()};
R_UNLESS(page_table.Contains(address, size), ResultInvalidCurrentMemory);
// Set the memory attribute.
return page_table.SetMemoryAttribute(address, size, mask, attr);
}
-Result SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask, u32 attr) {
- return SetMemoryAttribute(system, address, size, mask, attr);
-}
-
/// Maps a memory range into a different range.
Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
src_addr, size);
- auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
+ auto& page_table{GetCurrentProcess(system.Kernel()).PageTable()};
if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
result.IsError()) {
@@ -163,16 +159,12 @@ Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size)
return page_table.MapMemory(dst_addr, src_addr, size);
}
-Result MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) {
- return MapMemory(system, dst_addr, src_addr, size);
-}
-
/// Unmaps a region that was previously mapped with svcMapMemory
Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
src_addr, size);
- auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
+ auto& page_table{GetCurrentProcess(system.Kernel()).PageTable()};
if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
result.IsError()) {
@@ -182,8 +174,44 @@ Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 siz
return page_table.UnmapMemory(dst_addr, src_addr, size);
}
-Result UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) {
- return UnmapMemory(system, dst_addr, src_addr, size);
+Result SetMemoryPermission64(Core::System& system, uint64_t address, uint64_t size,
+ MemoryPermission perm) {
+ R_RETURN(SetMemoryPermission(system, address, size, perm));
+}
+
+Result SetMemoryAttribute64(Core::System& system, uint64_t address, uint64_t size, uint32_t mask,
+ uint32_t attr) {
+ R_RETURN(SetMemoryAttribute(system, address, size, mask, attr));
+}
+
+Result MapMemory64(Core::System& system, uint64_t dst_address, uint64_t src_address,
+ uint64_t size) {
+ R_RETURN(MapMemory(system, dst_address, src_address, size));
+}
+
+Result UnmapMemory64(Core::System& system, uint64_t dst_address, uint64_t src_address,
+ uint64_t size) {
+ R_RETURN(UnmapMemory(system, dst_address, src_address, size));
+}
+
+Result SetMemoryPermission64From32(Core::System& system, uint32_t address, uint32_t size,
+ MemoryPermission perm) {
+ R_RETURN(SetMemoryPermission(system, address, size, perm));
+}
+
+Result SetMemoryAttribute64From32(Core::System& system, uint32_t address, uint32_t size,
+ uint32_t mask, uint32_t attr) {
+ R_RETURN(SetMemoryAttribute(system, address, size, mask, attr));
+}
+
+Result MapMemory64From32(Core::System& system, uint32_t dst_address, uint32_t src_address,
+ uint32_t size) {
+ R_RETURN(MapMemory(system, dst_address, src_address, size));
+}
+
+Result UnmapMemory64From32(Core::System& system, uint32_t dst_address, uint32_t src_address,
+ uint32_t size) {
+ R_RETURN(UnmapMemory(system, dst_address, src_address, size));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_physical_memory.cpp b/src/core/hle/kernel/svc/svc_physical_memory.cpp
index 0fc262203..a1f534454 100644
--- a/src/core/hle/kernel/svc/svc_physical_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_physical_memory.cpp
@@ -16,18 +16,11 @@ Result SetHeapSize(Core::System& system, VAddr* out_address, u64 size) {
R_UNLESS(size < MainMemorySizeMax, ResultInvalidSize);
// Set the heap size.
- R_TRY(system.Kernel().CurrentProcess()->PageTable().SetHeapSize(out_address, size));
+ R_TRY(GetCurrentProcess(system.Kernel()).PageTable().SetHeapSize(out_address, size));
return ResultSuccess;
}
-Result SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size) {
- VAddr temp_heap_addr{};
- const Result result{SetHeapSize(system, &temp_heap_addr, heap_size)};
- *heap_addr = static_cast<u32>(temp_heap_addr);
- return result;
-}
-
/// Maps memory at a desired address
Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
@@ -52,7 +45,7 @@ Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
return ResultInvalidMemoryRegion;
}
- KProcess* const current_process{system.Kernel().CurrentProcess()};
+ KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())};
auto& page_table{current_process->PageTable()};
if (current_process->GetSystemResourceSize() == 0) {
@@ -77,10 +70,6 @@ Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
return page_table.MapPhysicalMemory(addr, size);
}
-Result MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) {
- return MapPhysicalMemory(system, addr, size);
-}
-
/// Unmaps memory previously mapped via MapPhysicalMemory
Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
@@ -105,7 +94,7 @@ Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
return ResultInvalidMemoryRegion;
}
- KProcess* const current_process{system.Kernel().CurrentProcess()};
+ KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())};
auto& page_table{current_process->PageTable()};
if (current_process->GetSystemResourceSize() == 0) {
@@ -130,8 +119,67 @@ Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
return page_table.UnmapPhysicalMemory(addr, size);
}
-Result UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) {
- return UnmapPhysicalMemory(system, addr, size);
+Result MapPhysicalMemoryUnsafe(Core::System& system, uint64_t address, uint64_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result UnmapPhysicalMemoryUnsafe(Core::System& system, uint64_t address, uint64_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result SetUnsafeLimit(Core::System& system, uint64_t limit) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result SetHeapSize64(Core::System& system, uint64_t* out_address, uint64_t size) {
+ R_RETURN(SetHeapSize(system, out_address, size));
+}
+
+Result MapPhysicalMemory64(Core::System& system, uint64_t address, uint64_t size) {
+ R_RETURN(MapPhysicalMemory(system, address, size));
+}
+
+Result UnmapPhysicalMemory64(Core::System& system, uint64_t address, uint64_t size) {
+ R_RETURN(UnmapPhysicalMemory(system, address, size));
+}
+
+Result MapPhysicalMemoryUnsafe64(Core::System& system, uint64_t address, uint64_t size) {
+ R_RETURN(MapPhysicalMemoryUnsafe(system, address, size));
+}
+
+Result UnmapPhysicalMemoryUnsafe64(Core::System& system, uint64_t address, uint64_t size) {
+ R_RETURN(UnmapPhysicalMemoryUnsafe(system, address, size));
+}
+
+Result SetUnsafeLimit64(Core::System& system, uint64_t limit) {
+ R_RETURN(SetUnsafeLimit(system, limit));
+}
+
+Result SetHeapSize64From32(Core::System& system, uintptr_t* out_address, uint32_t size) {
+ R_RETURN(SetHeapSize(system, out_address, size));
+}
+
+Result MapPhysicalMemory64From32(Core::System& system, uint32_t address, uint32_t size) {
+ R_RETURN(MapPhysicalMemory(system, address, size));
+}
+
+Result UnmapPhysicalMemory64From32(Core::System& system, uint32_t address, uint32_t size) {
+ R_RETURN(UnmapPhysicalMemory(system, address, size));
+}
+
+Result MapPhysicalMemoryUnsafe64From32(Core::System& system, uint32_t address, uint32_t size) {
+ R_RETURN(MapPhysicalMemoryUnsafe(system, address, size));
+}
+
+Result UnmapPhysicalMemoryUnsafe64From32(Core::System& system, uint32_t address, uint32_t size) {
+ R_RETURN(UnmapPhysicalMemoryUnsafe(system, address, size));
+}
+
+Result SetUnsafeLimit64From32(Core::System& system, uint32_t limit) {
+ R_RETURN(SetUnsafeLimit(system, limit));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_port.cpp b/src/core/hle/kernel/svc/svc_port.cpp
index cdfe0dd16..2f9bfcb52 100644
--- a/src/core/hle/kernel/svc/svc_port.cpp
+++ b/src/core/hle/kernel/svc/svc_port.cpp
@@ -5,6 +5,7 @@
#include "core/core.h"
#include "core/hle/kernel/k_client_port.h"
#include "core/hle/kernel/k_client_session.h"
+#include "core/hle/kernel/k_object_name.h"
#include "core/hle/kernel/k_port.h"
#include "core/hle/kernel/k_process.h"
#include "core/hle/kernel/svc.h"
@@ -34,7 +35,7 @@ Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_add
// Get the current handle table.
auto& kernel = system.Kernel();
- auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
+ auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
// Find the client port.
auto port = kernel.CreateNamedServicePort(port_name);
@@ -63,9 +64,107 @@ Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_add
return ResultSuccess;
}
-Result ConnectToNamedPort32(Core::System& system, Handle* out_handle, u32 port_name_address) {
+Result CreatePort(Core::System& system, Handle* out_server, Handle* out_client,
+ int32_t max_sessions, bool is_light, uintptr_t name) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result ConnectToPort(Core::System& system, Handle* out_handle, Handle port) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result ManageNamedPort(Core::System& system, Handle* out_server_handle, uint64_t user_name,
+ int32_t max_sessions) {
+ // Copy the provided name from user memory to kernel memory.
+ std::array<char, KObjectName::NameLengthMax> name{};
+ system.Memory().ReadBlock(user_name, name.data(), sizeof(name));
+
+ // Validate that sessions and name are valid.
+ R_UNLESS(max_sessions >= 0, ResultOutOfRange);
+ R_UNLESS(name[sizeof(name) - 1] == '\x00', ResultOutOfRange);
+
+ if (max_sessions > 0) {
+ // Get the current handle table.
+ auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
+
+ // Create a new port.
+ KPort* port = KPort::Create(system.Kernel());
+ R_UNLESS(port != nullptr, ResultOutOfResource);
+
+ // Initialize the new port.
+ port->Initialize(max_sessions, false, "");
+
+ // Register the port.
+ KPort::Register(system.Kernel(), port);
+
+ // Ensure that our only reference to the port is in the handle table when we're done.
+ SCOPE_EXIT({
+ port->GetClientPort().Close();
+ port->GetServerPort().Close();
+ });
+
+ // Register the handle in the table.
+ R_TRY(handle_table.Add(out_server_handle, std::addressof(port->GetServerPort())));
+ ON_RESULT_FAILURE {
+ handle_table.Remove(*out_server_handle);
+ };
+
+ // Create a new object name.
+ R_TRY(KObjectName::NewFromName(system.Kernel(), std::addressof(port->GetClientPort()),
+ name.data()));
+ } else /* if (max_sessions == 0) */ {
+ // Ensure that this else case is correct.
+ ASSERT(max_sessions == 0);
+
+ // If we're closing, there's no server handle.
+ *out_server_handle = InvalidHandle;
+
+ // Delete the object.
+ R_TRY(KObjectName::Delete<KClientPort>(system.Kernel(), name.data()));
+ }
+
+ R_SUCCEED();
+}
+
+Result ConnectToNamedPort64(Core::System& system, Handle* out_handle, uint64_t name) {
+ R_RETURN(ConnectToNamedPort(system, out_handle, name));
+}
+
+Result CreatePort64(Core::System& system, Handle* out_server_handle, Handle* out_client_handle,
+ int32_t max_sessions, bool is_light, uint64_t name) {
+ R_RETURN(
+ CreatePort(system, out_server_handle, out_client_handle, max_sessions, is_light, name));
+}
+
+Result ManageNamedPort64(Core::System& system, Handle* out_server_handle, uint64_t name,
+ int32_t max_sessions) {
+ R_RETURN(ManageNamedPort(system, out_server_handle, name, max_sessions));
+}
+
+Result ConnectToPort64(Core::System& system, Handle* out_handle, Handle port) {
+ R_RETURN(ConnectToPort(system, out_handle, port));
+}
+
+Result ConnectToNamedPort64From32(Core::System& system, Handle* out_handle, uint32_t name) {
+ R_RETURN(ConnectToNamedPort(system, out_handle, name));
+}
+
+Result CreatePort64From32(Core::System& system, Handle* out_server_handle,
+ Handle* out_client_handle, int32_t max_sessions, bool is_light,
+ uint32_t name) {
+ R_RETURN(
+ CreatePort(system, out_server_handle, out_client_handle, max_sessions, is_light, name));
+}
+
+Result ManageNamedPort64From32(Core::System& system, Handle* out_server_handle, uint32_t name,
+ int32_t max_sessions) {
+ R_RETURN(ManageNamedPort(system, out_server_handle, name, max_sessions));
+}
- return ConnectToNamedPort(system, out_handle, port_name_address);
+Result ConnectToPort64From32(Core::System& system, Handle* out_handle, Handle port) {
+ R_RETURN(ConnectToPort(system, out_handle, port));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_power_management.cpp b/src/core/hle/kernel/svc/svc_power_management.cpp
index 299e22ae6..f605a0317 100644
--- a/src/core/hle/kernel/svc/svc_power_management.cpp
+++ b/src/core/hle/kernel/svc/svc_power_management.cpp
@@ -2,5 +2,20 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/kernel/svc.h"
+#include "core/hle/kernel/svc_results.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+void SleepSystem(Core::System& system) {
+ UNIMPLEMENTED();
+}
+
+void SleepSystem64(Core::System& system) {
+ return SleepSystem(system);
+}
+
+void SleepSystem64From32(Core::System& system) {
+ return SleepSystem(system);
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_process.cpp b/src/core/hle/kernel/svc/svc_process.cpp
index d6c8b4561..c35d2be76 100644
--- a/src/core/hle/kernel/svc/svc_process.cpp
+++ b/src/core/hle/kernel/svc/svc_process.cpp
@@ -9,7 +9,7 @@ namespace Kernel::Svc {
/// Exits the current process
void ExitProcess(Core::System& system) {
- auto* current_process = system.Kernel().CurrentProcess();
+ auto* current_process = GetCurrentProcessPointer(system.Kernel());
LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID());
ASSERT_MSG(current_process->GetState() == KProcess::State::Running,
@@ -18,18 +18,14 @@ void ExitProcess(Core::System& system) {
system.Exit();
}
-void ExitProcess32(Core::System& system) {
- ExitProcess(system);
-}
-
/// Gets the ID of the specified process or a specified thread's owning process.
Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) {
LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle);
// Get the object from the handle table.
- KScopedAutoObject obj =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KAutoObject>(
- static_cast<Handle>(handle));
+ KScopedAutoObject obj = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KAutoObject>(static_cast<Handle>(handle));
R_UNLESS(obj.IsNotNull(), ResultInvalidHandle);
// Get the process from the object.
@@ -54,17 +50,8 @@ Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) {
return ResultSuccess;
}
-Result GetProcessId32(Core::System& system, u32* out_process_id_low, u32* out_process_id_high,
- Handle handle) {
- u64 out_process_id{};
- const auto result = GetProcessId(system, &out_process_id, handle);
- *out_process_id_low = static_cast<u32>(out_process_id);
- *out_process_id_high = static_cast<u32>(out_process_id >> 32);
- return result;
-}
-
-Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_process_ids,
- u32 out_process_ids_size) {
+Result GetProcessList(Core::System& system, s32* out_num_processes, VAddr out_process_ids,
+ int32_t out_process_ids_size) {
LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}",
out_process_ids, out_process_ids_size);
@@ -76,10 +63,10 @@ Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_pr
return ResultOutOfRange;
}
- const auto& kernel = system.Kernel();
+ auto& kernel = system.Kernel();
const auto total_copy_size = out_process_ids_size * sizeof(u64);
- if (out_process_ids_size > 0 && !kernel.CurrentProcess()->PageTable().IsInsideAddressSpace(
+ if (out_process_ids_size > 0 && !GetCurrentProcess(kernel).PageTable().IsInsideAddressSpace(
out_process_ids, total_copy_size)) {
LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}",
out_process_ids, out_process_ids + total_copy_size);
@@ -89,7 +76,8 @@ Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_pr
auto& memory = system.Memory();
const auto& process_list = kernel.GetProcessList();
const auto num_processes = process_list.size();
- const auto copy_amount = std::min(std::size_t{out_process_ids_size}, num_processes);
+ const auto copy_amount =
+ std::min(static_cast<std::size_t>(out_process_ids_size), num_processes);
for (std::size_t i = 0; i < copy_amount; ++i) {
memory.Write64(out_process_ids, process_list[i]->GetProcessID());
@@ -100,10 +88,11 @@ Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_pr
return ResultSuccess;
}
-Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) {
- LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type);
+Result GetProcessInfo(Core::System& system, s64* out, Handle process_handle,
+ ProcessInfoType info_type) {
+ LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, info_type);
- const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
+ const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}",
@@ -111,14 +100,95 @@ Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32
return ResultInvalidHandle;
}
- const auto info_type = static_cast<ProcessInfoType>(type);
if (info_type != ProcessInfoType::ProcessState) {
- LOG_ERROR(Kernel_SVC, "Expected info_type to be ProcessState but got {} instead", type);
+ LOG_ERROR(Kernel_SVC, "Expected info_type to be ProcessState but got {} instead",
+ info_type);
return ResultInvalidEnumValue;
}
- *out = static_cast<u64>(process->GetState());
+ *out = static_cast<s64>(process->GetState());
return ResultSuccess;
}
+Result CreateProcess(Core::System& system, Handle* out_handle, uint64_t parameters, uint64_t caps,
+ int32_t num_caps) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result StartProcess(Core::System& system, Handle process_handle, int32_t priority, int32_t core_id,
+ uint64_t main_thread_stack_size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result TerminateProcess(Core::System& system, Handle process_handle) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+void ExitProcess64(Core::System& system) {
+ ExitProcess(system);
+}
+
+Result GetProcessId64(Core::System& system, uint64_t* out_process_id, Handle process_handle) {
+ R_RETURN(GetProcessId(system, out_process_id, process_handle));
+}
+
+Result GetProcessList64(Core::System& system, int32_t* out_num_processes, uint64_t out_process_ids,
+ int32_t max_out_count) {
+ R_RETURN(GetProcessList(system, out_num_processes, out_process_ids, max_out_count));
+}
+
+Result CreateProcess64(Core::System& system, Handle* out_handle, uint64_t parameters, uint64_t caps,
+ int32_t num_caps) {
+ R_RETURN(CreateProcess(system, out_handle, parameters, caps, num_caps));
+}
+
+Result StartProcess64(Core::System& system, Handle process_handle, int32_t priority,
+ int32_t core_id, uint64_t main_thread_stack_size) {
+ R_RETURN(StartProcess(system, process_handle, priority, core_id, main_thread_stack_size));
+}
+
+Result TerminateProcess64(Core::System& system, Handle process_handle) {
+ R_RETURN(TerminateProcess(system, process_handle));
+}
+
+Result GetProcessInfo64(Core::System& system, int64_t* out_info, Handle process_handle,
+ ProcessInfoType info_type) {
+ R_RETURN(GetProcessInfo(system, out_info, process_handle, info_type));
+}
+
+void ExitProcess64From32(Core::System& system) {
+ ExitProcess(system);
+}
+
+Result GetProcessId64From32(Core::System& system, uint64_t* out_process_id, Handle process_handle) {
+ R_RETURN(GetProcessId(system, out_process_id, process_handle));
+}
+
+Result GetProcessList64From32(Core::System& system, int32_t* out_num_processes,
+ uint32_t out_process_ids, int32_t max_out_count) {
+ R_RETURN(GetProcessList(system, out_num_processes, out_process_ids, max_out_count));
+}
+
+Result CreateProcess64From32(Core::System& system, Handle* out_handle, uint32_t parameters,
+ uint32_t caps, int32_t num_caps) {
+ R_RETURN(CreateProcess(system, out_handle, parameters, caps, num_caps));
+}
+
+Result StartProcess64From32(Core::System& system, Handle process_handle, int32_t priority,
+ int32_t core_id, uint64_t main_thread_stack_size) {
+ R_RETURN(StartProcess(system, process_handle, priority, core_id, main_thread_stack_size));
+}
+
+Result TerminateProcess64From32(Core::System& system, Handle process_handle) {
+ R_RETURN(TerminateProcess(system, process_handle));
+}
+
+Result GetProcessInfo64From32(Core::System& system, int64_t* out_info, Handle process_handle,
+ ProcessInfoType info_type) {
+ R_RETURN(GetProcessInfo(system, out_info, process_handle, info_type));
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_process_memory.cpp b/src/core/hle/kernel/svc/svc_process_memory.cpp
index b6ac43af2..4dfd9e5bb 100644
--- a/src/core/hle/kernel/svc/svc_process_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_process_memory.cpp
@@ -45,7 +45,7 @@ Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, V
// Get the process from its handle.
KScopedAutoObject process =
- system.CurrentProcess()->GetHandleTable().GetObject<KProcess>(process_handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KProcess>(process_handle);
R_UNLESS(process.IsNotNull(), ResultInvalidHandle);
// Validate that the address is in range.
@@ -71,7 +71,7 @@ Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_
R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory);
// Get the processes.
- KProcess* dst_process = system.CurrentProcess();
+ KProcess* dst_process = GetCurrentProcessPointer(system.Kernel());
KScopedAutoObject src_process =
dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle);
R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle);
@@ -114,7 +114,7 @@ Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle proces
R_UNLESS((src_address < src_address + size), ResultInvalidCurrentMemory);
// Get the processes.
- KProcess* dst_process = system.CurrentProcess();
+ KProcess* dst_process = GetCurrentProcessPointer(system.Kernel());
KScopedAutoObject src_process =
dst_process->GetHandleTable().GetObjectWithoutPseudoHandle<KProcess>(process_handle);
R_UNLESS(src_process.IsNotNull(), ResultInvalidHandle);
@@ -174,7 +174,7 @@ Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst
return ResultInvalidCurrentMemory;
}
- const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
+ const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).",
@@ -242,7 +242,7 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d
return ResultInvalidCurrentMemory;
}
- const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
+ const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).",
@@ -271,4 +271,54 @@ Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 d
KPageTable::ICacheInvalidationStrategy::InvalidateAll);
}
+Result SetProcessMemoryPermission64(Core::System& system, Handle process_handle, uint64_t address,
+ uint64_t size, MemoryPermission perm) {
+ R_RETURN(SetProcessMemoryPermission(system, process_handle, address, size, perm));
+}
+
+Result MapProcessMemory64(Core::System& system, uint64_t dst_address, Handle process_handle,
+ uint64_t src_address, uint64_t size) {
+ R_RETURN(MapProcessMemory(system, dst_address, process_handle, src_address, size));
+}
+
+Result UnmapProcessMemory64(Core::System& system, uint64_t dst_address, Handle process_handle,
+ uint64_t src_address, uint64_t size) {
+ R_RETURN(UnmapProcessMemory(system, dst_address, process_handle, src_address, size));
+}
+
+Result MapProcessCodeMemory64(Core::System& system, Handle process_handle, uint64_t dst_address,
+ uint64_t src_address, uint64_t size) {
+ R_RETURN(MapProcessCodeMemory(system, process_handle, dst_address, src_address, size));
+}
+
+Result UnmapProcessCodeMemory64(Core::System& system, Handle process_handle, uint64_t dst_address,
+ uint64_t src_address, uint64_t size) {
+ R_RETURN(UnmapProcessCodeMemory(system, process_handle, dst_address, src_address, size));
+}
+
+Result SetProcessMemoryPermission64From32(Core::System& system, Handle process_handle,
+ uint64_t address, uint64_t size, MemoryPermission perm) {
+ R_RETURN(SetProcessMemoryPermission(system, process_handle, address, size, perm));
+}
+
+Result MapProcessMemory64From32(Core::System& system, uint32_t dst_address, Handle process_handle,
+ uint64_t src_address, uint32_t size) {
+ R_RETURN(MapProcessMemory(system, dst_address, process_handle, src_address, size));
+}
+
+Result UnmapProcessMemory64From32(Core::System& system, uint32_t dst_address, Handle process_handle,
+ uint64_t src_address, uint32_t size) {
+ R_RETURN(UnmapProcessMemory(system, dst_address, process_handle, src_address, size));
+}
+
+Result MapProcessCodeMemory64From32(Core::System& system, Handle process_handle,
+ uint64_t dst_address, uint64_t src_address, uint64_t size) {
+ R_RETURN(MapProcessCodeMemory(system, process_handle, dst_address, src_address, size));
+}
+
+Result UnmapProcessCodeMemory64From32(Core::System& system, Handle process_handle,
+ uint64_t dst_address, uint64_t src_address, uint64_t size) {
+ R_RETURN(UnmapProcessCodeMemory(system, process_handle, dst_address, src_address, size));
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_processor.cpp b/src/core/hle/kernel/svc/svc_processor.cpp
index 8561cf74f..7602ce6c0 100644
--- a/src/core/hle/kernel/svc/svc_processor.cpp
+++ b/src/core/hle/kernel/svc/svc_processor.cpp
@@ -9,12 +9,16 @@
namespace Kernel::Svc {
/// Get which CPU core is executing the current thread
-u32 GetCurrentProcessorNumber(Core::System& system) {
+int32_t GetCurrentProcessorNumber(Core::System& system) {
LOG_TRACE(Kernel_SVC, "called");
- return static_cast<u32>(system.CurrentPhysicalCore().CoreIndex());
+ return static_cast<int32_t>(system.CurrentPhysicalCore().CoreIndex());
}
-u32 GetCurrentProcessorNumber32(Core::System& system) {
+int32_t GetCurrentProcessorNumber64(Core::System& system) {
+ return GetCurrentProcessorNumber(system);
+}
+
+int32_t GetCurrentProcessorNumber64From32(Core::System& system) {
return GetCurrentProcessorNumber(system);
}
diff --git a/src/core/hle/kernel/svc/svc_query_memory.cpp b/src/core/hle/kernel/svc/svc_query_memory.cpp
index aac3b2eca..ee75ad370 100644
--- a/src/core/hle/kernel/svc/svc_query_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_query_memory.cpp
@@ -7,26 +7,22 @@
namespace Kernel::Svc {
-Result QueryMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address,
+Result QueryMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
VAddr query_address) {
LOG_TRACE(Kernel_SVC,
- "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, "
+ "called, out_memory_info=0x{:016X}, "
"query_address=0x{:016X}",
- memory_info_address, page_info_address, query_address);
+ out_memory_info, query_address);
- return QueryProcessMemory(system, memory_info_address, page_info_address, CurrentProcess,
+ // Query memory is just QueryProcessMemory on the current process.
+ return QueryProcessMemory(system, out_memory_info, out_page_info, CurrentProcess,
query_address);
}
-Result QueryMemory32(Core::System& system, u32 memory_info_address, u32 page_info_address,
- u32 query_address) {
- return QueryMemory(system, memory_info_address, page_info_address, query_address);
-}
-
-Result QueryProcessMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address,
- Handle process_handle, VAddr address) {
+Result QueryProcessMemory(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
+ Handle process_handle, uint64_t address) {
LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
- const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
+ const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}",
@@ -37,19 +33,33 @@ Result QueryProcessMemory(Core::System& system, VAddr memory_info_address, VAddr
auto& memory{system.Memory()};
const auto memory_info{process->PageTable().QueryInfo(address).GetSvcMemoryInfo()};
- memory.Write64(memory_info_address + 0x00, memory_info.base_address);
- memory.Write64(memory_info_address + 0x08, memory_info.size);
- memory.Write32(memory_info_address + 0x10, static_cast<u32>(memory_info.state) & 0xff);
- memory.Write32(memory_info_address + 0x14, static_cast<u32>(memory_info.attribute));
- memory.Write32(memory_info_address + 0x18, static_cast<u32>(memory_info.permission));
- memory.Write32(memory_info_address + 0x1c, memory_info.ipc_count);
- memory.Write32(memory_info_address + 0x20, memory_info.device_count);
- memory.Write32(memory_info_address + 0x24, 0);
+ memory.WriteBlock(out_memory_info, &memory_info, sizeof(memory_info));
+
+ //! This is supposed to be part of the QueryInfo call.
+ *out_page_info = {};
+
+ R_SUCCEED();
+}
+
+Result QueryMemory64(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
+ uint64_t address) {
+ R_RETURN(QueryMemory(system, out_memory_info, out_page_info, address));
+}
- // Page info appears to be currently unused by the kernel and is always set to zero.
- memory.Write32(page_info_address, 0);
+Result QueryProcessMemory64(Core::System& system, uint64_t out_memory_info, PageInfo* out_page_info,
+ Handle process_handle, uint64_t address) {
+ R_RETURN(QueryProcessMemory(system, out_memory_info, out_page_info, process_handle, address));
+}
+
+Result QueryMemory64From32(Core::System& system, uint32_t out_memory_info, PageInfo* out_page_info,
+ uint32_t address) {
+ R_RETURN(QueryMemory(system, out_memory_info, out_page_info, address));
+}
- return ResultSuccess;
+Result QueryProcessMemory64From32(Core::System& system, uint32_t out_memory_info,
+ PageInfo* out_page_info, Handle process_handle,
+ uint64_t address) {
+ R_RETURN(QueryProcessMemory(system, out_memory_info, out_page_info, process_handle, address));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_register.cpp b/src/core/hle/kernel/svc/svc_register.cpp
index 299e22ae6..b883e6618 100644
--- a/src/core/hle/kernel/svc/svc_register.cpp
+++ b/src/core/hle/kernel/svc/svc_register.cpp
@@ -2,5 +2,26 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/kernel/svc.h"
+#include "core/hle/kernel/svc_results.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+Result ReadWriteRegister(Core::System& system, uint32_t* out, uint64_t address, uint32_t mask,
+ uint32_t value) {
+ *out = 0;
+
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result ReadWriteRegister64(Core::System& system, uint32_t* out_value, uint64_t address,
+ uint32_t mask, uint32_t value) {
+ R_RETURN(ReadWriteRegister(system, out_value, address, mask, value));
+}
+
+Result ReadWriteRegister64From32(Core::System& system, uint32_t* out_value, uint64_t address,
+ uint32_t mask, uint32_t value) {
+ R_RETURN(ReadWriteRegister(system, out_value, address, mask, value));
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_resource_limit.cpp b/src/core/hle/kernel/svc/svc_resource_limit.cpp
index 679ba10fa..88166299e 100644
--- a/src/core/hle/kernel/svc/svc_resource_limit.cpp
+++ b/src/core/hle/kernel/svc/svc_resource_limit.cpp
@@ -27,12 +27,12 @@ Result CreateResourceLimit(Core::System& system, Handle* out_handle) {
KResourceLimit::Register(kernel, resource_limit);
// Add the limit to the handle table.
- R_TRY(kernel.CurrentProcess()->GetHandleTable().Add(out_handle, resource_limit));
+ R_TRY(GetCurrentProcess(kernel).GetHandleTable().Add(out_handle, resource_limit));
return ResultSuccess;
}
-Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value,
+Result GetResourceLimitLimitValue(Core::System& system, s64* out_limit_value,
Handle resource_limit_handle, LimitableResource which) {
LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle,
which);
@@ -41,9 +41,9 @@ Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value,
R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue);
// Get the resource limit.
- auto& kernel = system.Kernel();
- KScopedAutoObject resource_limit =
- kernel.CurrentProcess()->GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle);
+ KScopedAutoObject resource_limit = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KResourceLimit>(resource_limit_handle);
R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle);
// Get the limit value.
@@ -52,7 +52,7 @@ Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value,
return ResultSuccess;
}
-Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value,
+Result GetResourceLimitCurrentValue(Core::System& system, s64* out_current_value,
Handle resource_limit_handle, LimitableResource which) {
LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle,
which);
@@ -61,9 +61,9 @@ Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value
R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue);
// Get the resource limit.
- auto& kernel = system.Kernel();
- KScopedAutoObject resource_limit =
- kernel.CurrentProcess()->GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle);
+ KScopedAutoObject resource_limit = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KResourceLimit>(resource_limit_handle);
R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle);
// Get the current value.
@@ -73,7 +73,7 @@ Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value
}
Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle,
- LimitableResource which, u64 limit_value) {
+ LimitableResource which, s64 limit_value) {
LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}",
resource_limit_handle, which, limit_value);
@@ -81,9 +81,9 @@ Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_ha
R_UNLESS(IsValidResourceType(which), ResultInvalidEnumValue);
// Get the resource limit.
- auto& kernel = system.Kernel();
- KScopedAutoObject resource_limit =
- kernel.CurrentProcess()->GetHandleTable().GetObject<KResourceLimit>(resource_limit_handle);
+ KScopedAutoObject resource_limit = GetCurrentProcess(system.Kernel())
+ .GetHandleTable()
+ .GetObject<KResourceLimit>(resource_limit_handle);
R_UNLESS(resource_limit.IsNotNull(), ResultInvalidHandle);
// Set the limit value.
@@ -92,4 +92,58 @@ Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_ha
return ResultSuccess;
}
+Result GetResourceLimitPeakValue(Core::System& system, int64_t* out_peak_value,
+ Handle resource_limit_handle, LimitableResource which) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result GetResourceLimitLimitValue64(Core::System& system, int64_t* out_limit_value,
+ Handle resource_limit_handle, LimitableResource which) {
+ R_RETURN(GetResourceLimitLimitValue(system, out_limit_value, resource_limit_handle, which));
+}
+
+Result GetResourceLimitCurrentValue64(Core::System& system, int64_t* out_current_value,
+ Handle resource_limit_handle, LimitableResource which) {
+ R_RETURN(GetResourceLimitCurrentValue(system, out_current_value, resource_limit_handle, which));
+}
+
+Result GetResourceLimitPeakValue64(Core::System& system, int64_t* out_peak_value,
+ Handle resource_limit_handle, LimitableResource which) {
+ R_RETURN(GetResourceLimitPeakValue(system, out_peak_value, resource_limit_handle, which));
+}
+
+Result CreateResourceLimit64(Core::System& system, Handle* out_handle) {
+ R_RETURN(CreateResourceLimit(system, out_handle));
+}
+
+Result SetResourceLimitLimitValue64(Core::System& system, Handle resource_limit_handle,
+ LimitableResource which, int64_t limit_value) {
+ R_RETURN(SetResourceLimitLimitValue(system, resource_limit_handle, which, limit_value));
+}
+
+Result GetResourceLimitLimitValue64From32(Core::System& system, int64_t* out_limit_value,
+ Handle resource_limit_handle, LimitableResource which) {
+ R_RETURN(GetResourceLimitLimitValue(system, out_limit_value, resource_limit_handle, which));
+}
+
+Result GetResourceLimitCurrentValue64From32(Core::System& system, int64_t* out_current_value,
+ Handle resource_limit_handle, LimitableResource which) {
+ R_RETURN(GetResourceLimitCurrentValue(system, out_current_value, resource_limit_handle, which));
+}
+
+Result GetResourceLimitPeakValue64From32(Core::System& system, int64_t* out_peak_value,
+ Handle resource_limit_handle, LimitableResource which) {
+ R_RETURN(GetResourceLimitPeakValue(system, out_peak_value, resource_limit_handle, which));
+}
+
+Result CreateResourceLimit64From32(Core::System& system, Handle* out_handle) {
+ R_RETURN(CreateResourceLimit(system, out_handle));
+}
+
+Result SetResourceLimitLimitValue64From32(Core::System& system, Handle resource_limit_handle,
+ LimitableResource which, int64_t limit_value) {
+ R_RETURN(SetResourceLimitLimitValue(system, resource_limit_handle, which, limit_value));
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp b/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp
index 299e22ae6..20f6ec643 100644
--- a/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp
+++ b/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp
@@ -1,6 +1,53 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "core/core.h"
+#include "core/hle/kernel/physical_core.h"
#include "core/hle/kernel/svc.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+void CallSecureMonitor(Core::System& system, lp64::SecureMonitorArguments* args) {
+ UNIMPLEMENTED();
+}
+
+void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args) {
+ CallSecureMonitor(system, args);
+}
+
+void CallSecureMonitor64From32(Core::System& system, ilp32::SecureMonitorArguments* args) {
+ // CallSecureMonitor64From32 is not supported.
+ UNIMPLEMENTED_MSG("CallSecureMonitor64From32");
+}
+
+// Custom ABI for CallSecureMonitor.
+
+void SvcWrap_CallSecureMonitor64(Core::System& system) {
+ auto& core = system.CurrentPhysicalCore().ArmInterface();
+ lp64::SecureMonitorArguments args{};
+ for (int i = 0; i < 8; i++) {
+ args.r[i] = core.GetReg(i);
+ }
+
+ CallSecureMonitor64(system, &args);
+
+ for (int i = 0; i < 8; i++) {
+ core.SetReg(i, args.r[i]);
+ }
+}
+
+void SvcWrap_CallSecureMonitor64From32(Core::System& system) {
+ auto& core = system.CurrentPhysicalCore().ArmInterface();
+ ilp32::SecureMonitorArguments args{};
+ for (int i = 0; i < 8; i++) {
+ args.r[i] = static_cast<u32>(core.GetReg(i));
+ }
+
+ CallSecureMonitor64From32(system, &args);
+
+ for (int i = 0; i < 8; i++) {
+ core.SetReg(i, args.r[i]);
+ }
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp
index dac8ce33c..00fd1605e 100644
--- a/src/core/hle/kernel/svc/svc_session.cpp
+++ b/src/core/hle/kernel/svc/svc_session.cpp
@@ -13,7 +13,7 @@ namespace {
template <typename T>
Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u64 name) {
- auto& process = *system.CurrentProcess();
+ auto& process = GetCurrentProcess(system.Kernel());
auto& handle_table = process.GetHandleTable();
// Declare the session we're going to allocate.
@@ -90,14 +90,39 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien
} // namespace
-Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u32 is_light,
+Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, bool is_light,
u64 name) {
if (is_light) {
// return CreateSession<KLightSession>(system, out_server, out_client, name);
- return ResultUnknown;
+ return ResultNotImplemented;
} else {
return CreateSession<KSession>(system, out_server, out_client, name);
}
}
+Result AcceptSession(Core::System& system, Handle* out_handle, Handle port_handle) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result CreateSession64(Core::System& system, Handle* out_server_session_handle,
+ Handle* out_client_session_handle, bool is_light, uint64_t name) {
+ R_RETURN(CreateSession(system, out_server_session_handle, out_client_session_handle, is_light,
+ name));
+}
+
+Result AcceptSession64(Core::System& system, Handle* out_handle, Handle port) {
+ R_RETURN(AcceptSession(system, out_handle, port));
+}
+
+Result CreateSession64From32(Core::System& system, Handle* out_server_session_handle,
+ Handle* out_client_session_handle, bool is_light, uint32_t name) {
+ R_RETURN(CreateSession(system, out_server_session_handle, out_client_session_handle, is_light,
+ name));
+}
+
+Result AcceptSession64From32(Core::System& system, Handle* out_handle, Handle port) {
+ R_RETURN(AcceptSession(system, out_handle, port));
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_shared_memory.cpp b/src/core/hle/kernel/svc/svc_shared_memory.cpp
index d465bcbe7..18e0dc904 100644
--- a/src/core/hle/kernel/svc/svc_shared_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_shared_memory.cpp
@@ -42,7 +42,7 @@ Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address,
R_UNLESS(IsValidSharedMemoryPermission(map_perm), ResultInvalidNewMemoryPermission);
// Get the current process.
- auto& process = *system.Kernel().CurrentProcess();
+ auto& process = GetCurrentProcess(system.Kernel());
auto& page_table = process.PageTable();
// Get the shared memory.
@@ -67,11 +67,6 @@ Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address,
return ResultSuccess;
}
-Result MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size,
- Svc::MemoryPermission map_perm) {
- return MapSharedMemory(system, shmem_handle, address, size, map_perm);
-}
-
Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size) {
// Validate the address/size.
R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress);
@@ -80,7 +75,7 @@ Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr addres
R_UNLESS((address < address + size), ResultInvalidCurrentMemory);
// Get the current process.
- auto& process = *system.Kernel().CurrentProcess();
+ auto& process = GetCurrentProcess(system.Kernel());
auto& page_table = process.PageTable();
// Get the shared memory.
@@ -99,8 +94,40 @@ Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr addres
return ResultSuccess;
}
-Result UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size) {
- return UnmapSharedMemory(system, shmem_handle, address, size);
+Result CreateSharedMemory(Core::System& system, Handle* out_handle, uint64_t size,
+ MemoryPermission owner_perm, MemoryPermission remote_perm) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result MapSharedMemory64(Core::System& system, Handle shmem_handle, uint64_t address, uint64_t size,
+ MemoryPermission map_perm) {
+ R_RETURN(MapSharedMemory(system, shmem_handle, address, size, map_perm));
+}
+
+Result UnmapSharedMemory64(Core::System& system, Handle shmem_handle, uint64_t address,
+ uint64_t size) {
+ R_RETURN(UnmapSharedMemory(system, shmem_handle, address, size));
+}
+
+Result CreateSharedMemory64(Core::System& system, Handle* out_handle, uint64_t size,
+ MemoryPermission owner_perm, MemoryPermission remote_perm) {
+ R_RETURN(CreateSharedMemory(system, out_handle, size, owner_perm, remote_perm));
+}
+
+Result MapSharedMemory64From32(Core::System& system, Handle shmem_handle, uint32_t address,
+ uint32_t size, MemoryPermission map_perm) {
+ R_RETURN(MapSharedMemory(system, shmem_handle, address, size, map_perm));
+}
+
+Result UnmapSharedMemory64From32(Core::System& system, Handle shmem_handle, uint32_t address,
+ uint32_t size) {
+ R_RETURN(UnmapSharedMemory(system, shmem_handle, address, size));
+}
+
+Result CreateSharedMemory64From32(Core::System& system, Handle* out_handle, uint32_t size,
+ MemoryPermission owner_perm, MemoryPermission remote_perm) {
+ R_RETURN(CreateSharedMemory(system, out_handle, size, owner_perm, remote_perm));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_synchronization.cpp b/src/core/hle/kernel/svc/svc_synchronization.cpp
index 1bf6a612a..1a8f7e191 100644
--- a/src/core/hle/kernel/svc/svc_synchronization.cpp
+++ b/src/core/hle/kernel/svc/svc_synchronization.cpp
@@ -14,22 +14,18 @@ Result CloseHandle(Core::System& system, Handle handle) {
LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle);
// Remove the handle.
- R_UNLESS(system.Kernel().CurrentProcess()->GetHandleTable().Remove(handle),
+ R_UNLESS(GetCurrentProcess(system.Kernel()).GetHandleTable().Remove(handle),
ResultInvalidHandle);
return ResultSuccess;
}
-Result CloseHandle32(Core::System& system, Handle handle) {
- return CloseHandle(system, handle);
-}
-
/// Clears the signaled state of an event or process.
Result ResetSignal(Core::System& system, Handle handle) {
LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle);
// Get the current handle table.
- const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
+ const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
// Try to reset as readable event.
{
@@ -52,10 +48,6 @@ Result ResetSignal(Core::System& system, Handle handle) {
return ResultInvalidHandle;
}
-Result ResetSignal32(Core::System& system, Handle handle) {
- return ResetSignal(system, handle);
-}
-
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, s32 num_handles,
s64 nano_seconds) {
@@ -67,7 +59,7 @@ Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_addre
auto& kernel = system.Kernel();
std::vector<KSynchronizationObject*> objs(num_handles);
- const auto& handle_table = kernel.CurrentProcess()->GetHandleTable();
+ const auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
Handle* handles = system.Memory().GetPointer<Handle>(handles_address);
// Copy user handles.
@@ -93,19 +85,13 @@ Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_addre
nano_seconds);
}
-Result WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address,
- s32 num_handles, u32 timeout_high, s32* index) {
- const s64 nano_seconds{(static_cast<s64>(timeout_high) << 32) | static_cast<s64>(timeout_low)};
- return WaitSynchronization(system, index, handles_address, num_handles, nano_seconds);
-}
-
/// Resumes a thread waiting on WaitSynchronization
Result CancelSynchronization(Core::System& system, Handle handle) {
LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle);
// Get the thread from its handle.
KScopedAutoObject thread =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Cancel the thread's wait.
@@ -113,10 +99,6 @@ Result CancelSynchronization(Core::System& system, Handle handle) {
return ResultSuccess;
}
-Result CancelSynchronization32(Core::System& system, Handle handle) {
- return CancelSynchronization(system, handle);
-}
-
void SynchronizePreemptionState(Core::System& system) {
auto& kernel = system.Kernel();
@@ -124,7 +106,7 @@ void SynchronizePreemptionState(Core::System& system) {
KScopedSchedulerLock sl{kernel};
// If the current thread is pinned, unpin it.
- KProcess* cur_process = system.Kernel().CurrentProcess();
+ KProcess* cur_process = GetCurrentProcessPointer(kernel);
const auto core_id = GetCurrentCoreId(kernel);
if (cur_process->GetPinnedThread(core_id) == GetCurrentThreadPointer(kernel)) {
@@ -136,4 +118,46 @@ void SynchronizePreemptionState(Core::System& system) {
}
}
+Result CloseHandle64(Core::System& system, Handle handle) {
+ R_RETURN(CloseHandle(system, handle));
+}
+
+Result ResetSignal64(Core::System& system, Handle handle) {
+ R_RETURN(ResetSignal(system, handle));
+}
+
+Result WaitSynchronization64(Core::System& system, int32_t* out_index, uint64_t handles,
+ int32_t num_handles, int64_t timeout_ns) {
+ R_RETURN(WaitSynchronization(system, out_index, handles, num_handles, timeout_ns));
+}
+
+Result CancelSynchronization64(Core::System& system, Handle handle) {
+ R_RETURN(CancelSynchronization(system, handle));
+}
+
+void SynchronizePreemptionState64(Core::System& system) {
+ SynchronizePreemptionState(system);
+}
+
+Result CloseHandle64From32(Core::System& system, Handle handle) {
+ R_RETURN(CloseHandle(system, handle));
+}
+
+Result ResetSignal64From32(Core::System& system, Handle handle) {
+ R_RETURN(ResetSignal(system, handle));
+}
+
+Result WaitSynchronization64From32(Core::System& system, int32_t* out_index, uint32_t handles,
+ int32_t num_handles, int64_t timeout_ns) {
+ R_RETURN(WaitSynchronization(system, out_index, handles, num_handles, timeout_ns));
+}
+
+Result CancelSynchronization64From32(Core::System& system, Handle handle) {
+ R_RETURN(CancelSynchronization(system, handle));
+}
+
+void SynchronizePreemptionState64From32(Core::System& system) {
+ SynchronizePreemptionState(system);
+}
+
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp
index dd9f8e8b1..b39807841 100644
--- a/src/core/hle/kernel/svc/svc_thread.cpp
+++ b/src/core/hle/kernel/svc/svc_thread.cpp
@@ -20,7 +20,7 @@ constexpr bool IsValidVirtualCoreId(int32_t core_id) {
/// Creates a new thread
Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg,
- VAddr stack_bottom, u32 priority, s32 core_id) {
+ VAddr stack_bottom, s32 priority, s32 core_id) {
LOG_DEBUG(Kernel_SVC,
"called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, "
"priority=0x{:08X}, core_id=0x{:08X}",
@@ -28,7 +28,7 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
// Adjust core id, if it's the default magic.
auto& kernel = system.Kernel();
- auto& process = *kernel.CurrentProcess();
+ auto& process = GetCurrentProcess(kernel);
if (core_id == IdealCoreUseProcessValue) {
core_id = process.GetIdealCoreId();
}
@@ -53,9 +53,9 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
}
// Reserve a new thread from the process resource limit (waiting up to 100ms).
- KScopedResourceReservation thread_reservation(
- kernel.CurrentProcess(), LimitableResource::ThreadCountMax, 1,
- system.CoreTiming().GetGlobalTimeNs().count() + 100000000);
+ KScopedResourceReservation thread_reservation(&process, LimitableResource::ThreadCountMax, 1,
+ system.CoreTiming().GetGlobalTimeNs().count() +
+ 100000000);
if (!thread_reservation.Succeeded()) {
LOG_ERROR(Kernel_SVC, "Could not reserve a new thread");
return ResultLimitReached;
@@ -91,18 +91,13 @@ Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point,
return ResultSuccess;
}
-Result CreateThread32(Core::System& system, Handle* out_handle, u32 priority, u32 entry_point,
- u32 arg, u32 stack_top, s32 processor_id) {
- return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id);
-}
-
/// Starts the thread for the provided handle
Result StartThread(Core::System& system, Handle thread_handle) {
LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle);
// Get the thread from its handle.
KScopedAutoObject thread =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Try to start the thread.
@@ -115,10 +110,6 @@ Result StartThread(Core::System& system, Handle thread_handle) {
return ResultSuccess;
}
-Result StartThread32(Core::System& system, Handle thread_handle) {
- return StartThread(system, thread_handle);
-}
-
/// Called when a thread exits
void ExitThread(Core::System& system) {
LOG_DEBUG(Kernel_SVC, "called, pc=0x{:08X}", system.CurrentArmInterface().GetPC());
@@ -129,10 +120,6 @@ void ExitThread(Core::System& system) {
system.Kernel().UnregisterInUseObject(current_thread);
}
-void ExitThread32(Core::System& system) {
- ExitThread(system);
-}
-
/// Sleep the current thread
void SleepThread(Core::System& system, s64 nanoseconds) {
auto& kernel = system.Kernel();
@@ -160,13 +147,8 @@ void SleepThread(Core::System& system, s64 nanoseconds) {
}
}
-void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanoseconds_high) {
- const auto nanoseconds = static_cast<s64>(u64{nanoseconds_low} | (u64{nanoseconds_high} << 32));
- SleepThread(system, nanoseconds);
-}
-
/// Gets the thread context
-Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) {
+Result GetThreadContext3(Core::System& system, VAddr out_context, Handle thread_handle) {
LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context,
thread_handle);
@@ -174,11 +156,11 @@ Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_h
// Get the thread from its handle.
KScopedAutoObject thread =
- kernel.CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
+ GetCurrentProcess(kernel).GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Require the handle be to a non-current thread in the current process.
- const auto* current_process = kernel.CurrentProcess();
+ const auto* current_process = GetCurrentProcessPointer(kernel);
R_UNLESS(current_process == thread->GetOwnerProcess(), ResultInvalidId);
// Verify that the thread isn't terminated.
@@ -223,17 +205,13 @@ Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_h
return ResultSuccess;
}
-Result GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) {
- return GetThreadContext(system, out_context, thread_handle);
-}
-
/// Gets the priority for the specified thread
-Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) {
+Result GetThreadPriority(Core::System& system, s32* out_priority, Handle handle) {
LOG_TRACE(Kernel_SVC, "called");
// Get the thread from its handle.
KScopedAutoObject thread =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Get the thread's priority.
@@ -241,14 +219,10 @@ Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle)
return ResultSuccess;
}
-Result GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) {
- return GetThreadPriority(system, out_priority, handle);
-}
-
/// Sets the priority for the specified thread
-Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) {
+Result SetThreadPriority(Core::System& system, Handle thread_handle, s32 priority) {
// Get the current process.
- KProcess& process = *system.Kernel().CurrentProcess();
+ KProcess& process = GetCurrentProcess(system.Kernel());
// Validate the priority.
R_UNLESS(HighestThreadPriority <= priority && priority <= LowestThreadPriority,
@@ -264,12 +238,8 @@ Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priorit
return ResultSuccess;
}
-Result SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) {
- return SetThreadPriority(system, thread_handle, priority);
-}
-
-Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids,
- u32 out_thread_ids_size, Handle debug_handle) {
+Result GetThreadList(Core::System& system, s32* out_num_threads, VAddr out_thread_ids,
+ s32 out_thread_ids_size, Handle debug_handle) {
// TODO: Handle this case when debug events are supported.
UNIMPLEMENTED_IF(debug_handle != InvalidHandle);
@@ -283,7 +253,7 @@ Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_threa
return ResultOutOfRange;
}
- auto* const current_process = system.Kernel().CurrentProcess();
+ auto* const current_process = GetCurrentProcessPointer(system.Kernel());
const auto total_copy_size = out_thread_ids_size * sizeof(u64);
if (out_thread_ids_size > 0 &&
@@ -296,7 +266,7 @@ Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_threa
auto& memory = system.Memory();
const auto& thread_list = current_process->GetThreadList();
const auto num_threads = thread_list.size();
- const auto copy_amount = std::min(std::size_t{out_thread_ids_size}, num_threads);
+ const auto copy_amount = std::min(static_cast<std::size_t>(out_thread_ids_size), num_threads);
auto list_iter = thread_list.cbegin();
for (std::size_t i = 0; i < copy_amount; ++i, ++list_iter) {
@@ -308,13 +278,13 @@ Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_threa
return ResultSuccess;
}
-Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id,
- u64* out_affinity_mask) {
+Result GetThreadCoreMask(Core::System& system, s32* out_core_id, u64* out_affinity_mask,
+ Handle thread_handle) {
LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle);
// Get the thread from its handle.
KScopedAutoObject thread =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Get the core mask.
@@ -323,24 +293,15 @@ Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_co
return ResultSuccess;
}
-Result GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id,
- u32* out_affinity_mask_low, u32* out_affinity_mask_high) {
- u64 out_affinity_mask{};
- const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask);
- *out_affinity_mask_high = static_cast<u32>(out_affinity_mask >> 32);
- *out_affinity_mask_low = static_cast<u32>(out_affinity_mask);
- return result;
-}
-
Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id,
u64 affinity_mask) {
// Determine the core id/affinity mask.
if (core_id == IdealCoreUseProcessValue) {
- core_id = system.Kernel().CurrentProcess()->GetIdealCoreId();
+ core_id = GetCurrentProcess(system.Kernel()).GetIdealCoreId();
affinity_mask = (1ULL << core_id);
} else {
// Validate the affinity mask.
- const u64 process_core_mask = system.Kernel().CurrentProcess()->GetCoreMask();
+ const u64 process_core_mask = GetCurrentProcess(system.Kernel()).GetCoreMask();
R_UNLESS((affinity_mask | process_core_mask) == process_core_mask, ResultInvalidCoreId);
R_UNLESS(affinity_mask != 0, ResultInvalidCombination);
@@ -355,7 +316,7 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id
// Get the thread from its handle.
KScopedAutoObject thread =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Set the core mask.
@@ -364,17 +325,11 @@ Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id
return ResultSuccess;
}
-Result SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id,
- u32 affinity_mask_low, u32 affinity_mask_high) {
- const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32);
- return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask);
-}
-
/// Get the ID for the specified thread.
Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) {
// Get the thread from its handle.
KScopedAutoObject thread =
- system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
+ GetCurrentProcess(system.Kernel()).GetHandleTable().GetObject<KThread>(thread_handle);
R_UNLESS(thread.IsNotNull(), ResultInvalidHandle);
// Get the thread's id.
@@ -382,15 +337,101 @@ Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handl
return ResultSuccess;
}
-Result GetThreadId32(Core::System& system, u32* out_thread_id_low, u32* out_thread_id_high,
- Handle thread_handle) {
- u64 out_thread_id{};
- const Result result{GetThreadId(system, &out_thread_id, thread_handle)};
+Result CreateThread64(Core::System& system, Handle* out_handle, uint64_t func, uint64_t arg,
+ uint64_t stack_bottom, int32_t priority, int32_t core_id) {
+ R_RETURN(CreateThread(system, out_handle, func, arg, stack_bottom, priority, core_id));
+}
+
+Result StartThread64(Core::System& system, Handle thread_handle) {
+ R_RETURN(StartThread(system, thread_handle));
+}
+
+void ExitThread64(Core::System& system) {
+ return ExitThread(system);
+}
+
+void SleepThread64(Core::System& system, int64_t ns) {
+ return SleepThread(system, ns);
+}
+
+Result GetThreadPriority64(Core::System& system, int32_t* out_priority, Handle thread_handle) {
+ R_RETURN(GetThreadPriority(system, out_priority, thread_handle));
+}
+
+Result SetThreadPriority64(Core::System& system, Handle thread_handle, int32_t priority) {
+ R_RETURN(SetThreadPriority(system, thread_handle, priority));
+}
+
+Result GetThreadCoreMask64(Core::System& system, int32_t* out_core_id, uint64_t* out_affinity_mask,
+ Handle thread_handle) {
+ R_RETURN(GetThreadCoreMask(system, out_core_id, out_affinity_mask, thread_handle));
+}
+
+Result SetThreadCoreMask64(Core::System& system, Handle thread_handle, int32_t core_id,
+ uint64_t affinity_mask) {
+ R_RETURN(SetThreadCoreMask(system, thread_handle, core_id, affinity_mask));
+}
+
+Result GetThreadId64(Core::System& system, uint64_t* out_thread_id, Handle thread_handle) {
+ R_RETURN(GetThreadId(system, out_thread_id, thread_handle));
+}
+
+Result GetThreadContext364(Core::System& system, uint64_t out_context, Handle thread_handle) {
+ R_RETURN(GetThreadContext3(system, out_context, thread_handle));
+}
- *out_thread_id_low = static_cast<u32>(out_thread_id >> 32);
- *out_thread_id_high = static_cast<u32>(out_thread_id & std::numeric_limits<u32>::max());
+Result GetThreadList64(Core::System& system, int32_t* out_num_threads, uint64_t out_thread_ids,
+ int32_t max_out_count, Handle debug_handle) {
+ R_RETURN(GetThreadList(system, out_num_threads, out_thread_ids, max_out_count, debug_handle));
+}
+
+Result CreateThread64From32(Core::System& system, Handle* out_handle, uint32_t func, uint32_t arg,
+ uint32_t stack_bottom, int32_t priority, int32_t core_id) {
+ R_RETURN(CreateThread(system, out_handle, func, arg, stack_bottom, priority, core_id));
+}
+
+Result StartThread64From32(Core::System& system, Handle thread_handle) {
+ R_RETURN(StartThread(system, thread_handle));
+}
+
+void ExitThread64From32(Core::System& system) {
+ return ExitThread(system);
+}
+
+void SleepThread64From32(Core::System& system, int64_t ns) {
+ return SleepThread(system, ns);
+}
+
+Result GetThreadPriority64From32(Core::System& system, int32_t* out_priority,
+ Handle thread_handle) {
+ R_RETURN(GetThreadPriority(system, out_priority, thread_handle));
+}
+
+Result SetThreadPriority64From32(Core::System& system, Handle thread_handle, int32_t priority) {
+ R_RETURN(SetThreadPriority(system, thread_handle, priority));
+}
+
+Result GetThreadCoreMask64From32(Core::System& system, int32_t* out_core_id,
+ uint64_t* out_affinity_mask, Handle thread_handle) {
+ R_RETURN(GetThreadCoreMask(system, out_core_id, out_affinity_mask, thread_handle));
+}
+
+Result SetThreadCoreMask64From32(Core::System& system, Handle thread_handle, int32_t core_id,
+ uint64_t affinity_mask) {
+ R_RETURN(SetThreadCoreMask(system, thread_handle, core_id, affinity_mask));
+}
+
+Result GetThreadId64From32(Core::System& system, uint64_t* out_thread_id, Handle thread_handle) {
+ R_RETURN(GetThreadId(system, out_thread_id, thread_handle));
+}
+
+Result GetThreadContext364From32(Core::System& system, uint32_t out_context, Handle thread_handle) {
+ R_RETURN(GetThreadContext3(system, out_context, thread_handle));
+}
- return result;
+Result GetThreadList64From32(Core::System& system, int32_t* out_num_threads,
+ uint32_t out_thread_ids, int32_t max_out_count, Handle debug_handle) {
+ R_RETURN(GetThreadList(system, out_num_threads, out_thread_ids, max_out_count, debug_handle));
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_thread_profiler.cpp b/src/core/hle/kernel/svc/svc_thread_profiler.cpp
index 299e22ae6..40de7708b 100644
--- a/src/core/hle/kernel/svc/svc_thread_profiler.cpp
+++ b/src/core/hle/kernel/svc/svc_thread_profiler.cpp
@@ -2,5 +2,59 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/kernel/svc.h"
+#include "core/hle/kernel/svc_results.h"
-namespace Kernel::Svc {} // namespace Kernel::Svc
+namespace Kernel::Svc {
+
+Result GetDebugFutureThreadInfo(Core::System& system, lp64::LastThreadContext* out_context,
+ uint64_t* out_thread_id, Handle debug_handle, int64_t ns) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result GetLastThreadInfo(Core::System& system, lp64::LastThreadContext* out_context,
+ uint64_t* out_tls_address, uint32_t* out_flags) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result GetDebugFutureThreadInfo64(Core::System& system, lp64::LastThreadContext* out_context,
+ uint64_t* out_thread_id, Handle debug_handle, int64_t ns) {
+ R_RETURN(GetDebugFutureThreadInfo(system, out_context, out_thread_id, debug_handle, ns));
+}
+
+Result GetLastThreadInfo64(Core::System& system, lp64::LastThreadContext* out_context,
+ uint64_t* out_tls_address, uint32_t* out_flags) {
+ R_RETURN(GetLastThreadInfo(system, out_context, out_tls_address, out_flags));
+}
+
+Result GetDebugFutureThreadInfo64From32(Core::System& system, ilp32::LastThreadContext* out_context,
+ uint64_t* out_thread_id, Handle debug_handle, int64_t ns) {
+ lp64::LastThreadContext context{};
+ R_TRY(
+ GetDebugFutureThreadInfo(system, std::addressof(context), out_thread_id, debug_handle, ns));
+
+ *out_context = {
+ .fp = static_cast<u32>(context.fp),
+ .sp = static_cast<u32>(context.sp),
+ .lr = static_cast<u32>(context.lr),
+ .pc = static_cast<u32>(context.pc),
+ };
+ R_SUCCEED();
+}
+
+Result GetLastThreadInfo64From32(Core::System& system, ilp32::LastThreadContext* out_context,
+ uint64_t* out_tls_address, uint32_t* out_flags) {
+ lp64::LastThreadContext context{};
+ R_TRY(GetLastThreadInfo(system, std::addressof(context), out_tls_address, out_flags));
+
+ *out_context = {
+ .fp = static_cast<u32>(context.fp),
+ .sp = static_cast<u32>(context.sp),
+ .lr = static_cast<u32>(context.lr),
+ .pc = static_cast<u32>(context.pc),
+ };
+ R_SUCCEED();
+}
+
+} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_tick.cpp b/src/core/hle/kernel/svc/svc_tick.cpp
index e9b4fd5a6..561336482 100644
--- a/src/core/hle/kernel/svc/svc_tick.cpp
+++ b/src/core/hle/kernel/svc/svc_tick.cpp
@@ -9,7 +9,7 @@
namespace Kernel::Svc {
/// This returns the total CPU ticks elapsed since the CPU was powered-on
-u64 GetSystemTick(Core::System& system) {
+int64_t GetSystemTick(Core::System& system) {
LOG_TRACE(Kernel_SVC, "called");
auto& core_timing = system.CoreTiming();
@@ -21,13 +21,15 @@ u64 GetSystemTick(Core::System& system) {
core_timing.AddTicks(400U);
}
- return result;
+ return static_cast<int64_t>(result);
}
-void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high) {
- const auto time = GetSystemTick(system);
- *time_low = static_cast<u32>(time);
- *time_high = static_cast<u32>(time >> 32);
+int64_t GetSystemTick64(Core::System& system) {
+ return GetSystemTick(system);
+}
+
+int64_t GetSystemTick64From32(Core::System& system) {
+ return GetSystemTick(system);
}
} // namespace Kernel::Svc
diff --git a/src/core/hle/kernel/svc/svc_transfer_memory.cpp b/src/core/hle/kernel/svc/svc_transfer_memory.cpp
index b14ae24a1..7ffc24adf 100644
--- a/src/core/hle/kernel/svc/svc_transfer_memory.cpp
+++ b/src/core/hle/kernel/svc/svc_transfer_memory.cpp
@@ -39,11 +39,11 @@ Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u6
R_UNLESS(IsValidTransferMemoryPermission(map_perm), ResultInvalidNewMemoryPermission);
// Get the current process and handle table.
- auto& process = *kernel.CurrentProcess();
+ auto& process = GetCurrentProcess(kernel);
auto& handle_table = process.GetHandleTable();
// Reserve a new transfer memory from the process resource limit.
- KScopedResourceReservation trmem_reservation(kernel.CurrentProcess(),
+ KScopedResourceReservation trmem_reservation(&process,
LimitableResource::TransferMemoryCountMax);
R_UNLESS(trmem_reservation.Succeeded(), ResultLimitReached);
@@ -72,8 +72,46 @@ Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u6
return ResultSuccess;
}
-Result CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size,
- MemoryPermission map_perm) {
- return CreateTransferMemory(system, out, address, size, map_perm);
+Result MapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t address, uint64_t size,
+ MemoryPermission owner_perm) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
}
+
+Result UnmapTransferMemory(Core::System& system, Handle trmem_handle, uint64_t address,
+ uint64_t size) {
+ UNIMPLEMENTED();
+ R_THROW(ResultNotImplemented);
+}
+
+Result MapTransferMemory64(Core::System& system, Handle trmem_handle, uint64_t address,
+ uint64_t size, MemoryPermission owner_perm) {
+ R_RETURN(MapTransferMemory(system, trmem_handle, address, size, owner_perm));
+}
+
+Result UnmapTransferMemory64(Core::System& system, Handle trmem_handle, uint64_t address,
+ uint64_t size) {
+ R_RETURN(UnmapTransferMemory(system, trmem_handle, address, size));
+}
+
+Result CreateTransferMemory64(Core::System& system, Handle* out_handle, uint64_t address,
+ uint64_t size, MemoryPermission map_perm) {
+ R_RETURN(CreateTransferMemory(system, out_handle, address, size, map_perm));
+}
+
+Result MapTransferMemory64From32(Core::System& system, Handle trmem_handle, uint32_t address,
+ uint32_t size, MemoryPermission owner_perm) {
+ R_RETURN(MapTransferMemory(system, trmem_handle, address, size, owner_perm));
+}
+
+Result UnmapTransferMemory64From32(Core::System& system, Handle trmem_handle, uint32_t address,
+ uint32_t size) {
+ R_RETURN(UnmapTransferMemory(system, trmem_handle, address, size));
+}
+
+Result CreateTransferMemory64From32(Core::System& system, Handle* out_handle, uint32_t address,
+ uint32_t size, MemoryPermission map_perm) {
+ R_RETURN(CreateTransferMemory(system, out_handle, address, size, map_perm));
+}
+
} // namespace Kernel::Svc