summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2019-11-26 16:29:34 -0500
committerGravatar Lioncash2019-11-26 21:55:39 -0500
commitb05bfc603689419dc515a656b9fc711d79994f13 (patch)
treebc0937d11bbe31458785a69478edbf11a720b0ae /src/core/hle/kernel/svc.cpp
parentcore/memory: Migrate over ZeroBlock() and CopyBlock() to the Memory class (diff)
downloadyuzu-b05bfc603689419dc515a656b9fc711d79994f13.tar.gz
yuzu-b05bfc603689419dc515a656b9fc711d79994f13.tar.xz
yuzu-b05bfc603689419dc515a656b9fc711d79994f13.zip
core/memory: Migrate over Read{8, 16, 32, 64, Block} to the Memory class
With all of the trivial parts of the memory interface moved over, we can get right into moving over the bits that are used. Note that this does require the use of GetInstance from the global system instance to be used within hle_ipc.cpp and the gdbstub. This is fine for the time being, as they both already rely on the global system instance in other functions. These will be removed in a change directed at both of these respectively. For now, it's sufficient, as it still accomplishes the goal of de-globalizing the memory code.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 738db528d..a6c377cfc 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -454,7 +454,8 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
454 LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, handle_count={}, nano_seconds={}", 454 LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, handle_count={}, nano_seconds={}",
455 handles_address, handle_count, nano_seconds); 455 handles_address, handle_count, nano_seconds);
456 456
457 if (!system.Memory().IsValidVirtualAddress(handles_address)) { 457 auto& memory = system.Memory();
458 if (!memory.IsValidVirtualAddress(handles_address)) {
458 LOG_ERROR(Kernel_SVC, 459 LOG_ERROR(Kernel_SVC,
459 "Handle address is not a valid virtual address, handle_address=0x{:016X}", 460 "Handle address is not a valid virtual address, handle_address=0x{:016X}",
460 handles_address); 461 handles_address);
@@ -476,7 +477,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
476 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); 477 const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
477 478
478 for (u64 i = 0; i < handle_count; ++i) { 479 for (u64 i = 0; i < handle_count; ++i) {
479 const Handle handle = Memory::Read32(handles_address + i * sizeof(Handle)); 480 const Handle handle = memory.Read32(handles_address + i * sizeof(Handle));
480 const auto object = handle_table.Get<WaitObject>(handle); 481 const auto object = handle_table.Get<WaitObject>(handle);
481 482
482 if (object == nullptr) { 483 if (object == nullptr) {
@@ -618,13 +619,15 @@ static void Break(Core::System& system, u32 reason, u64 info1, u64 info2) {
618 return; 619 return;
619 } 620 }
620 621
622 auto& memory = system.Memory();
623
621 // This typically is an error code so we're going to assume this is the case 624 // This typically is an error code so we're going to assume this is the case
622 if (sz == sizeof(u32)) { 625 if (sz == sizeof(u32)) {
623 LOG_CRITICAL(Debug_Emulated, "debug_buffer_err_code={:X}", Memory::Read32(addr)); 626 LOG_CRITICAL(Debug_Emulated, "debug_buffer_err_code={:X}", memory.Read32(addr));
624 } else { 627 } else {
625 // We don't know what's in here so we'll hexdump it 628 // We don't know what's in here so we'll hexdump it
626 debug_buffer.resize(sz); 629 debug_buffer.resize(sz);
627 Memory::ReadBlock(addr, debug_buffer.data(), sz); 630 memory.ReadBlock(addr, debug_buffer.data(), sz);
628 std::string hexdump; 631 std::string hexdump;
629 for (std::size_t i = 0; i < debug_buffer.size(); i++) { 632 for (std::size_t i = 0; i < debug_buffer.size(); i++) {
630 hexdump += fmt::format("{:02X} ", debug_buffer[i]); 633 hexdump += fmt::format("{:02X} ", debug_buffer[i]);
@@ -714,7 +717,7 @@ static void OutputDebugString([[maybe_unused]] Core::System& system, VAddr addre
714 } 717 }
715 718
716 std::string str(len, '\0'); 719 std::string str(len, '\0');
717 Memory::ReadBlock(address, str.data(), str.size()); 720 system.Memory().ReadBlock(address, str.data(), str.size());
718 LOG_DEBUG(Debug_Emulated, "{}", str); 721 LOG_DEBUG(Debug_Emulated, "{}", str);
719} 722}
720 723
@@ -1674,6 +1677,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var
1674 1677
1675 const std::size_t current_core = system.CurrentCoreIndex(); 1678 const std::size_t current_core = system.CurrentCoreIndex();
1676 auto& monitor = system.Monitor(); 1679 auto& monitor = system.Monitor();
1680 auto& memory = system.Memory();
1677 1681
1678 // Atomically read the value of the mutex. 1682 // Atomically read the value of the mutex.
1679 u32 mutex_val = 0; 1683 u32 mutex_val = 0;
@@ -1683,7 +1687,7 @@ static ResultCode SignalProcessWideKey(Core::System& system, VAddr condition_var
1683 monitor.SetExclusive(current_core, mutex_address); 1687 monitor.SetExclusive(current_core, mutex_address);
1684 1688
1685 // If the mutex is not yet acquired, acquire it. 1689 // If the mutex is not yet acquired, acquire it.
1686 mutex_val = Memory::Read32(mutex_address); 1690 mutex_val = memory.Read32(mutex_address);
1687 1691
1688 if (mutex_val != 0) { 1692 if (mutex_val != 0) {
1689 update_val = mutex_val | Mutex::MutexHasWaitersFlag; 1693 update_val = mutex_val | Mutex::MutexHasWaitersFlag;