diff options
| author | 2020-12-08 15:38:28 -0500 | |
|---|---|---|
| committer | 2020-12-08 15:42:10 -0500 | |
| commit | 2de124e2235f28cc25e2b213f8ba76c9f670f36c (patch) | |
| tree | 4981a70c4cf943c0fc38ad73c50839d7a62a1b3b /src/core/hle/kernel/svc.cpp | |
| parent | Merge pull request #5171 from lat9nq/ci-unicorn-cleanup (diff) | |
| download | yuzu-2de124e2235f28cc25e2b213f8ba76c9f670f36c.tar.gz yuzu-2de124e2235f28cc25e2b213f8ba76c9f670f36c.tar.xz yuzu-2de124e2235f28cc25e2b213f8ba76c9f670f36c.zip | |
svc: Remove unnecessary casts
Simplifies and removes some casts. In all cases, these were generally
widening from a 32-bit unsigned type to a 64-bit unsigned type, so no
information would be lost from the conversion.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 95d6e2b4d..c8060f179 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -234,8 +234,7 @@ static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 si | |||
| 234 | 234 | ||
| 235 | static ResultCode SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask, | 235 | static ResultCode SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask, |
| 236 | u32 attribute) { | 236 | u32 attribute) { |
| 237 | return SetMemoryAttribute(system, static_cast<VAddr>(address), static_cast<std::size_t>(size), | 237 | return SetMemoryAttribute(system, address, size, mask, attribute); |
| 238 | mask, attribute); | ||
| 239 | } | 238 | } |
| 240 | 239 | ||
| 241 | /// Maps a memory range into a different range. | 240 | /// Maps a memory range into a different range. |
| @@ -255,8 +254,7 @@ static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr | |||
| 255 | } | 254 | } |
| 256 | 255 | ||
| 257 | static ResultCode MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { | 256 | static ResultCode MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { |
| 258 | return MapMemory(system, static_cast<VAddr>(dst_addr), static_cast<VAddr>(src_addr), | 257 | return MapMemory(system, dst_addr, src_addr, size); |
| 259 | static_cast<std::size_t>(size)); | ||
| 260 | } | 258 | } |
| 261 | 259 | ||
| 262 | /// Unmaps a region that was previously mapped with svcMapMemory | 260 | /// Unmaps a region that was previously mapped with svcMapMemory |
| @@ -276,8 +274,7 @@ static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_ad | |||
| 276 | } | 274 | } |
| 277 | 275 | ||
| 278 | static ResultCode UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { | 276 | static ResultCode UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { |
| 279 | return UnmapMemory(system, static_cast<VAddr>(dst_addr), static_cast<VAddr>(src_addr), | 277 | return UnmapMemory(system, dst_addr, src_addr, size); |
| 280 | static_cast<std::size_t>(size)); | ||
| 281 | } | 278 | } |
| 282 | 279 | ||
| 283 | /// Connect to an OS service given the port name, returns the handle to the port to out | 280 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| @@ -531,8 +528,7 @@ static ResultCode ArbitrateLock(Core::System& system, Handle holding_thread_hand | |||
| 531 | 528 | ||
| 532 | static ResultCode ArbitrateLock32(Core::System& system, Handle holding_thread_handle, | 529 | static ResultCode ArbitrateLock32(Core::System& system, Handle holding_thread_handle, |
| 533 | u32 mutex_addr, Handle requesting_thread_handle) { | 530 | u32 mutex_addr, Handle requesting_thread_handle) { |
| 534 | return ArbitrateLock(system, holding_thread_handle, static_cast<VAddr>(mutex_addr), | 531 | return ArbitrateLock(system, holding_thread_handle, mutex_addr, requesting_thread_handle); |
| 535 | requesting_thread_handle); | ||
| 536 | } | 532 | } |
| 537 | 533 | ||
| 538 | /// Unlock a mutex | 534 | /// Unlock a mutex |
| @@ -555,7 +551,7 @@ static ResultCode ArbitrateUnlock(Core::System& system, VAddr mutex_addr) { | |||
| 555 | } | 551 | } |
| 556 | 552 | ||
| 557 | static ResultCode ArbitrateUnlock32(Core::System& system, u32 mutex_addr) { | 553 | static ResultCode ArbitrateUnlock32(Core::System& system, u32 mutex_addr) { |
| 558 | return ArbitrateUnlock(system, static_cast<VAddr>(mutex_addr)); | 554 | return ArbitrateUnlock(system, mutex_addr); |
| 559 | } | 555 | } |
| 560 | 556 | ||
| 561 | enum class BreakType : u32 { | 557 | enum class BreakType : u32 { |
| @@ -677,7 +673,7 @@ static void Break(Core::System& system, u32 reason, u64 info1, u64 info2) { | |||
| 677 | } | 673 | } |
| 678 | 674 | ||
| 679 | static void Break32(Core::System& system, u32 reason, u32 info1, u32 info2) { | 675 | static void Break32(Core::System& system, u32 reason, u32 info1, u32 info2) { |
| 680 | Break(system, reason, static_cast<u64>(info1), static_cast<u64>(info2)); | 676 | Break(system, reason, info1, info2); |
| 681 | } | 677 | } |
| 682 | 678 | ||
| 683 | /// Used to output a message on a debug hardware unit - does nothing on a retail unit | 679 | /// Used to output a message on a debug hardware unit - does nothing on a retail unit |
| @@ -948,7 +944,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha | |||
| 948 | 944 | ||
| 949 | static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, | 945 | static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, |
| 950 | u32 info_id, u32 handle, u32 sub_id_high) { | 946 | u32 info_id, u32 handle, u32 sub_id_high) { |
| 951 | const u64 sub_id{static_cast<u64>(sub_id_low | (static_cast<u64>(sub_id_high) << 32))}; | 947 | const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)}; |
| 952 | u64 res_value{}; | 948 | u64 res_value{}; |
| 953 | 949 | ||
| 954 | const ResultCode result{GetInfo(system, &res_value, info_id, handle, sub_id)}; | 950 | const ResultCode result{GetInfo(system, &res_value, info_id, handle, sub_id)}; |
| @@ -1009,7 +1005,7 @@ static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) | |||
| 1009 | } | 1005 | } |
| 1010 | 1006 | ||
| 1011 | static ResultCode MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { | 1007 | static ResultCode MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { |
| 1012 | return MapPhysicalMemory(system, static_cast<VAddr>(addr), static_cast<std::size_t>(size)); | 1008 | return MapPhysicalMemory(system, addr, size); |
| 1013 | } | 1009 | } |
| 1014 | 1010 | ||
| 1015 | /// Unmaps memory previously mapped via MapPhysicalMemory | 1011 | /// Unmaps memory previously mapped via MapPhysicalMemory |
| @@ -1063,7 +1059,7 @@ static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size | |||
| 1063 | } | 1059 | } |
| 1064 | 1060 | ||
| 1065 | static ResultCode UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { | 1061 | static ResultCode UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { |
| 1066 | return UnmapPhysicalMemory(system, static_cast<VAddr>(addr), static_cast<std::size_t>(size)); | 1062 | return UnmapPhysicalMemory(system, addr, size); |
| 1067 | } | 1063 | } |
| 1068 | 1064 | ||
| 1069 | /// Sets the thread activity | 1065 | /// Sets the thread activity |
| @@ -1144,7 +1140,7 @@ static ResultCode GetThreadContext(Core::System& system, VAddr thread_context, H | |||
| 1144 | } | 1140 | } |
| 1145 | 1141 | ||
| 1146 | static ResultCode GetThreadContext32(Core::System& system, u32 thread_context, Handle handle) { | 1142 | static ResultCode GetThreadContext32(Core::System& system, u32 thread_context, Handle handle) { |
| 1147 | return GetThreadContext(system, static_cast<VAddr>(thread_context), handle); | 1143 | return GetThreadContext(system, thread_context, handle); |
| 1148 | } | 1144 | } |
| 1149 | 1145 | ||
| 1150 | /// Gets the priority for the specified thread | 1146 | /// Gets the priority for the specified thread |
| @@ -1281,8 +1277,7 @@ static ResultCode MapSharedMemory(Core::System& system, Handle shared_memory_han | |||
| 1281 | 1277 | ||
| 1282 | static ResultCode MapSharedMemory32(Core::System& system, Handle shared_memory_handle, u32 addr, | 1278 | static ResultCode MapSharedMemory32(Core::System& system, Handle shared_memory_handle, u32 addr, |
| 1283 | u32 size, u32 permissions) { | 1279 | u32 size, u32 permissions) { |
| 1284 | return MapSharedMemory(system, shared_memory_handle, static_cast<VAddr>(addr), | 1280 | return MapSharedMemory(system, shared_memory_handle, addr, size, permissions); |
| 1285 | static_cast<std::size_t>(size), permissions); | ||
| 1286 | } | 1281 | } |
| 1287 | 1282 | ||
| 1288 | static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, | 1283 | static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, |
| @@ -1552,8 +1547,7 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e | |||
| 1552 | 1547 | ||
| 1553 | static ResultCode CreateThread32(Core::System& system, Handle* out_handle, u32 priority, | 1548 | static ResultCode CreateThread32(Core::System& system, Handle* out_handle, u32 priority, |
| 1554 | u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) { | 1549 | u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) { |
| 1555 | return CreateThread(system, out_handle, static_cast<VAddr>(entry_point), static_cast<u64>(arg), | 1550 | return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id); |
| 1556 | static_cast<VAddr>(stack_top), priority, processor_id); | ||
| 1557 | } | 1551 | } |
| 1558 | 1552 | ||
| 1559 | /// Starts the thread for the provided handle | 1553 | /// Starts the thread for the provided handle |
| @@ -1637,8 +1631,7 @@ static void SleepThread(Core::System& system, s64 nanoseconds) { | |||
| 1637 | } | 1631 | } |
| 1638 | 1632 | ||
| 1639 | static void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanoseconds_high) { | 1633 | static void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanoseconds_high) { |
| 1640 | const s64 nanoseconds = static_cast<s64>(static_cast<u64>(nanoseconds_low) | | 1634 | const auto nanoseconds = static_cast<s64>(u64{nanoseconds_low} | (u64{nanoseconds_high} << 32)); |
| 1641 | (static_cast<u64>(nanoseconds_high) << 32)); | ||
| 1642 | SleepThread(system, nanoseconds); | 1635 | SleepThread(system, nanoseconds); |
| 1643 | } | 1636 | } |
| 1644 | 1637 | ||
| @@ -1724,10 +1717,8 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add | |||
| 1724 | static ResultCode WaitProcessWideKeyAtomic32(Core::System& system, u32 mutex_addr, | 1717 | static ResultCode WaitProcessWideKeyAtomic32(Core::System& system, u32 mutex_addr, |
| 1725 | u32 condition_variable_addr, Handle thread_handle, | 1718 | u32 condition_variable_addr, Handle thread_handle, |
| 1726 | u32 nanoseconds_low, u32 nanoseconds_high) { | 1719 | u32 nanoseconds_low, u32 nanoseconds_high) { |
| 1727 | const s64 nanoseconds = | 1720 | const auto nanoseconds = static_cast<s64>(nanoseconds_low | (u64{nanoseconds_high} << 32)); |
| 1728 | static_cast<s64>(nanoseconds_low | (static_cast<u64>(nanoseconds_high) << 32)); | 1721 | return WaitProcessWideKeyAtomic(system, mutex_addr, condition_variable_addr, thread_handle, |
| 1729 | return WaitProcessWideKeyAtomic(system, static_cast<VAddr>(mutex_addr), | ||
| 1730 | static_cast<VAddr>(condition_variable_addr), thread_handle, | ||
| 1731 | nanoseconds); | 1722 | nanoseconds); |
| 1732 | } | 1723 | } |
| 1733 | 1724 | ||
| @@ -1833,8 +1824,8 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type, | |||
| 1833 | 1824 | ||
| 1834 | static ResultCode WaitForAddress32(Core::System& system, u32 address, u32 type, s32 value, | 1825 | static ResultCode WaitForAddress32(Core::System& system, u32 address, u32 type, s32 value, |
| 1835 | u32 timeout_low, u32 timeout_high) { | 1826 | u32 timeout_low, u32 timeout_high) { |
| 1836 | s64 timeout = static_cast<s64>(timeout_low | (static_cast<u64>(timeout_high) << 32)); | 1827 | const auto timeout = static_cast<s64>(timeout_low | (u64{timeout_high} << 32)); |
| 1837 | return WaitForAddress(system, static_cast<VAddr>(address), type, value, timeout); | 1828 | return WaitForAddress(system, address, type, value, timeout); |
| 1838 | } | 1829 | } |
| 1839 | 1830 | ||
| 1840 | // Signals to an address (via Address Arbiter) | 1831 | // Signals to an address (via Address Arbiter) |
| @@ -1862,7 +1853,7 @@ static ResultCode SignalToAddress(Core::System& system, VAddr address, u32 type, | |||
| 1862 | 1853 | ||
| 1863 | static ResultCode SignalToAddress32(Core::System& system, u32 address, u32 type, s32 value, | 1854 | static ResultCode SignalToAddress32(Core::System& system, u32 address, u32 type, s32 value, |
| 1864 | s32 num_to_wake) { | 1855 | s32 num_to_wake) { |
| 1865 | return SignalToAddress(system, static_cast<VAddr>(address), type, value, num_to_wake); | 1856 | return SignalToAddress(system, address, type, value, num_to_wake); |
| 1866 | } | 1857 | } |
| 1867 | 1858 | ||
| 1868 | static void KernelDebug([[maybe_unused]] Core::System& system, | 1859 | static void KernelDebug([[maybe_unused]] Core::System& system, |
| @@ -1893,7 +1884,7 @@ static u64 GetSystemTick(Core::System& system) { | |||
| 1893 | } | 1884 | } |
| 1894 | 1885 | ||
| 1895 | static void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high) { | 1886 | static void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high) { |
| 1896 | u64 time = GetSystemTick(system); | 1887 | const auto time = GetSystemTick(system); |
| 1897 | *time_low = static_cast<u32>(time); | 1888 | *time_low = static_cast<u32>(time); |
| 1898 | *time_high = static_cast<u32>(time >> 32); | 1889 | *time_high = static_cast<u32>(time >> 32); |
| 1899 | } | 1890 | } |
| @@ -1984,8 +1975,7 @@ static ResultCode CreateTransferMemory(Core::System& system, Handle* handle, VAd | |||
| 1984 | 1975 | ||
| 1985 | static ResultCode CreateTransferMemory32(Core::System& system, Handle* handle, u32 addr, u32 size, | 1976 | static ResultCode CreateTransferMemory32(Core::System& system, Handle* handle, u32 addr, u32 size, |
| 1986 | u32 permissions) { | 1977 | u32 permissions) { |
| 1987 | return CreateTransferMemory(system, handle, static_cast<VAddr>(addr), | 1978 | return CreateTransferMemory(system, handle, addr, size, permissions); |
| 1988 | static_cast<std::size_t>(size), permissions); | ||
| 1989 | } | 1979 | } |
| 1990 | 1980 | ||
| 1991 | static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, u32* core, | 1981 | static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, u32* core, |
| @@ -2075,8 +2065,7 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, | |||
| 2075 | 2065 | ||
| 2076 | static ResultCode SetThreadCoreMask32(Core::System& system, Handle thread_handle, u32 core, | 2066 | static ResultCode SetThreadCoreMask32(Core::System& system, Handle thread_handle, u32 core, |
| 2077 | u32 affinity_mask_low, u32 affinity_mask_high) { | 2067 | u32 affinity_mask_low, u32 affinity_mask_high) { |
| 2078 | const u64 affinity_mask = | 2068 | const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32); |
| 2079 | static_cast<u64>(affinity_mask_low) | (static_cast<u64>(affinity_mask_high) << 32); | ||
| 2080 | return SetThreadCoreMask(system, thread_handle, core, affinity_mask); | 2069 | return SetThreadCoreMask(system, thread_handle, core, affinity_mask); |
| 2081 | } | 2070 | } |
| 2082 | 2071 | ||
| @@ -2341,9 +2330,10 @@ static ResultCode GetThreadList(Core::System& system, u32* out_num_threads, VAdd | |||
| 2341 | return RESULT_SUCCESS; | 2330 | return RESULT_SUCCESS; |
| 2342 | } | 2331 | } |
| 2343 | 2332 | ||
| 2344 | static ResultCode FlushProcessDataCache32(Core::System& system, Handle handle, u32 address, | 2333 | static ResultCode FlushProcessDataCache32([[maybe_unused]] Core::System& system, |
| 2345 | u32 size) { | 2334 | [[maybe_unused]] Handle handle, |
| 2346 | // Note(Blinkhawk): For emulation purposes of the data cache this is mostly a nope | 2335 | [[maybe_unused]] u32 address, [[maybe_unused]] u32 size) { |
| 2336 | // Note(Blinkhawk): For emulation purposes of the data cache this is mostly a no-op, | ||
| 2347 | // as all emulation is done in the same cache level in host architecture, thus data cache | 2337 | // as all emulation is done in the same cache level in host architecture, thus data cache |
| 2348 | // does not need flushing. | 2338 | // does not need flushing. |
| 2349 | LOG_DEBUG(Kernel_SVC, "called"); | 2339 | LOG_DEBUG(Kernel_SVC, "called"); |