summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Lioncash2019-11-26 13:46:41 -0500
committerGravatar Lioncash2019-11-26 21:53:34 -0500
commite58748fd802dc069e90928d12d4db9ff994a869d (patch)
tree152c306a9a51f0ba49e2a34d1dc0db9eb2923013 /src/core/hle/kernel
parentcore/memory: Migrate over memory mapping functions to the new Memory class (diff)
downloadyuzu-e58748fd802dc069e90928d12d4db9ff994a869d.tar.gz
yuzu-e58748fd802dc069e90928d12d4db9ff994a869d.tar.xz
yuzu-e58748fd802dc069e90928d12d4db9ff994a869d.zip
core/memory: Migrate over address checking functions to the new Memory class
A fairly straightforward migration. These member functions can just be mostly moved verbatim with minor changes. We already have the necessary plumbing in places that they're used. IsKernelVirtualAddress() can remain a non-member function, since it doesn't rely on class state in any form.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp8
-rw-r--r--src/core/hle/kernel/svc.cpp4
-rw-r--r--src/core/hle/kernel/thread.cpp4
3 files changed, 8 insertions, 8 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index 4859954cb..7f9a559d2 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -68,7 +68,7 @@ ResultCode AddressArbiter::SignalToAddressOnly(VAddr address, s32 num_to_wake) {
68ResultCode AddressArbiter::IncrementAndSignalToAddressIfEqual(VAddr address, s32 value, 68ResultCode AddressArbiter::IncrementAndSignalToAddressIfEqual(VAddr address, s32 value,
69 s32 num_to_wake) { 69 s32 num_to_wake) {
70 // Ensure that we can write to the address. 70 // Ensure that we can write to the address.
71 if (!Memory::IsValidVirtualAddress(address)) { 71 if (!system.Memory().IsValidVirtualAddress(address)) {
72 return ERR_INVALID_ADDRESS_STATE; 72 return ERR_INVALID_ADDRESS_STATE;
73 } 73 }
74 74
@@ -83,7 +83,7 @@ ResultCode AddressArbiter::IncrementAndSignalToAddressIfEqual(VAddr address, s32
83ResultCode AddressArbiter::ModifyByWaitingCountAndSignalToAddressIfEqual(VAddr address, s32 value, 83ResultCode AddressArbiter::ModifyByWaitingCountAndSignalToAddressIfEqual(VAddr address, s32 value,
84 s32 num_to_wake) { 84 s32 num_to_wake) {
85 // Ensure that we can write to the address. 85 // Ensure that we can write to the address.
86 if (!Memory::IsValidVirtualAddress(address)) { 86 if (!system.Memory().IsValidVirtualAddress(address)) {
87 return ERR_INVALID_ADDRESS_STATE; 87 return ERR_INVALID_ADDRESS_STATE;
88 } 88 }
89 89
@@ -135,7 +135,7 @@ ResultCode AddressArbiter::WaitForAddress(VAddr address, ArbitrationType type, s
135ResultCode AddressArbiter::WaitForAddressIfLessThan(VAddr address, s32 value, s64 timeout, 135ResultCode AddressArbiter::WaitForAddressIfLessThan(VAddr address, s32 value, s64 timeout,
136 bool should_decrement) { 136 bool should_decrement) {
137 // Ensure that we can read the address. 137 // Ensure that we can read the address.
138 if (!Memory::IsValidVirtualAddress(address)) { 138 if (!system.Memory().IsValidVirtualAddress(address)) {
139 return ERR_INVALID_ADDRESS_STATE; 139 return ERR_INVALID_ADDRESS_STATE;
140 } 140 }
141 141
@@ -158,7 +158,7 @@ ResultCode AddressArbiter::WaitForAddressIfLessThan(VAddr address, s32 value, s6
158 158
159ResultCode AddressArbiter::WaitForAddressIfEqual(VAddr address, s32 value, s64 timeout) { 159ResultCode AddressArbiter::WaitForAddressIfEqual(VAddr address, s32 value, s64 timeout) {
160 // Ensure that we can read the address. 160 // Ensure that we can read the address.
161 if (!Memory::IsValidVirtualAddress(address)) { 161 if (!system.Memory().IsValidVirtualAddress(address)) {
162 return ERR_INVALID_ADDRESS_STATE; 162 return ERR_INVALID_ADDRESS_STATE;
163 } 163 }
164 // Only wait for the address if equal. 164 // Only wait for the address if equal.
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 9928b3a26..eddafaf60 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -332,7 +332,7 @@ static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_ad
332/// Connect to an OS service given the port name, returns the handle to the port to out 332/// Connect to an OS service given the port name, returns the handle to the port to out
333static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle, 333static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle,
334 VAddr port_name_address) { 334 VAddr port_name_address) {
335 if (!Memory::IsValidVirtualAddress(port_name_address)) { 335 if (!system.Memory().IsValidVirtualAddress(port_name_address)) {
336 LOG_ERROR(Kernel_SVC, 336 LOG_ERROR(Kernel_SVC,
337 "Port Name Address is not a valid virtual address, port_name_address=0x{:016X}", 337 "Port Name Address is not a valid virtual address, port_name_address=0x{:016X}",
338 port_name_address); 338 port_name_address);
@@ -452,7 +452,7 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
452 LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, handle_count={}, nano_seconds={}", 452 LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, handle_count={}, nano_seconds={}",
453 handles_address, handle_count, nano_seconds); 453 handles_address, handle_count, nano_seconds);
454 454
455 if (!Memory::IsValidVirtualAddress(handles_address)) { 455 if (!system.Memory().IsValidVirtualAddress(handles_address)) {
456 LOG_ERROR(Kernel_SVC, 456 LOG_ERROR(Kernel_SVC,
457 "Handle address is not a valid virtual address, handle_address=0x{:016X}", 457 "Handle address is not a valid virtual address, handle_address=0x{:016X}",
458 handles_address); 458 handles_address);
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 735019d96..e84e5ce0d 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -162,13 +162,13 @@ ResultVal<std::shared_ptr<Thread>> Thread::Create(KernelCore& kernel, std::strin
162 return ERR_INVALID_PROCESSOR_ID; 162 return ERR_INVALID_PROCESSOR_ID;
163 } 163 }
164 164
165 if (!Memory::IsValidVirtualAddress(owner_process, entry_point)) { 165 auto& system = Core::System::GetInstance();
166 if (!system.Memory().IsValidVirtualAddress(owner_process, entry_point)) {
166 LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:016X}", name, entry_point); 167 LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:016X}", name, entry_point);
167 // TODO (bunnei): Find the correct error code to use here 168 // TODO (bunnei): Find the correct error code to use here
168 return RESULT_UNKNOWN; 169 return RESULT_UNKNOWN;
169 } 170 }
170 171
171 auto& system = Core::System::GetInstance();
172 std::shared_ptr<Thread> thread = std::make_shared<Thread>(kernel); 172 std::shared_ptr<Thread> thread = std::make_shared<Thread>(kernel);
173 173
174 thread->thread_id = kernel.CreateNewThreadID(); 174 thread->thread_id = kernel.CreateNewThreadID();