summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar bunnei2016-12-15 19:01:48 -0500
committerGravatar bunnei2016-12-21 23:29:13 -0500
commit232ef55c1a13552e5ba8b72d61d1d072f5851598 (patch)
tree729ee82ded58202888a2c27bdc3beec6ab926768 /src/core/hle
parentfile_util: Remove unused paths. (diff)
downloadyuzu-232ef55c1a13552e5ba8b72d61d1d072f5851598.tar.gz
yuzu-232ef55c1a13552e5ba8b72d61d1d072f5851598.tar.xz
yuzu-232ef55c1a13552e5ba8b72d61d1d072f5851598.zip
core: Consolidate core and system state, remove system module & cleanups.
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/function_wrappers.h60
-rw-r--r--src/core/hle/hle.cpp4
-rw-r--r--src/core/hle/kernel/thread.cpp6
-rw-r--r--src/core/hle/service/ldr_ro/ldr_ro.cpp8
-rw-r--r--src/core/hle/svc.cpp12
5 files changed, 45 insertions, 45 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h
index 8ce0f6d2b..0f2a04e30 100644
--- a/src/core/hle/function_wrappers.h
+++ b/src/core/hle/function_wrappers.h
@@ -14,7 +14,7 @@
14 14
15namespace HLE { 15namespace HLE {
16 16
17#define PARAM(n) Core::g_app_core->GetReg(n) 17#define PARAM(n) Core::AppCore().GetReg(n)
18 18
19/// An invalid result code that is meant to be overwritten when a thread resumes from waiting 19/// An invalid result code that is meant to be overwritten when a thread resumes from waiting
20static const ResultCode RESULT_INVALID(0xDEADC0DE); 20static const ResultCode RESULT_INVALID(0xDEADC0DE);
@@ -24,7 +24,7 @@ static const ResultCode RESULT_INVALID(0xDEADC0DE);
24 * @param res Result to return 24 * @param res Result to return
25 */ 25 */
26static inline void FuncReturn(u32 res) { 26static inline void FuncReturn(u32 res) {
27 Core::g_app_core->SetReg(0, res); 27 Core::AppCore().SetReg(0, res);
28} 28}
29 29
30/** 30/**
@@ -33,8 +33,8 @@ static inline void FuncReturn(u32 res) {
33 * @todo Verify that this function is correct 33 * @todo Verify that this function is correct
34 */ 34 */
35static inline void FuncReturn64(u64 res) { 35static inline void FuncReturn64(u64 res) {
36 Core::g_app_core->SetReg(0, (u32)(res & 0xFFFFFFFF)); 36 Core::AppCore().SetReg(0, (u32)(res & 0xFFFFFFFF));
37 Core::g_app_core->SetReg(1, (u32)((res >> 32) & 0xFFFFFFFF)); 37 Core::AppCore().SetReg(1, (u32)((res >> 32) & 0xFFFFFFFF));
38} 38}
39 39
40//////////////////////////////////////////////////////////////////////////////////////////////////// 40////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -49,7 +49,7 @@ template <ResultCode func(u32*, u32, u32, u32, u32, u32)>
49void Wrap() { 49void Wrap() {
50 u32 param_1 = 0; 50 u32 param_1 = 0;
51 u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw; 51 u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw;
52 Core::g_app_core->SetReg(1, param_1); 52 Core::AppCore().SetReg(1, param_1);
53 FuncReturn(retval); 53 FuncReturn(retval);
54} 54}
55 55
@@ -57,7 +57,7 @@ template <ResultCode func(u32*, s32, u32, u32, u32, s32)>
57void Wrap() { 57void Wrap() {
58 u32 param_1 = 0; 58 u32 param_1 = 0;
59 u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw; 59 u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw;
60 Core::g_app_core->SetReg(1, param_1); 60 Core::AppCore().SetReg(1, param_1);
61 FuncReturn(retval); 61 FuncReturn(retval);
62} 62}
63 63
@@ -69,7 +69,7 @@ void Wrap() {
69 .raw; 69 .raw;
70 70
71 if (retval != RESULT_INVALID.raw) { 71 if (retval != RESULT_INVALID.raw) {
72 Core::g_app_core->SetReg(1, (u32)param_1); 72 Core::AppCore().SetReg(1, (u32)param_1);
73 FuncReturn(retval); 73 FuncReturn(retval);
74 } 74 }
75} 75}
@@ -84,7 +84,7 @@ template <ResultCode func(u32*)>
84void Wrap() { 84void Wrap() {
85 u32 param_1 = 0; 85 u32 param_1 = 0;
86 u32 retval = func(&param_1).raw; 86 u32 retval = func(&param_1).raw;
87 Core::g_app_core->SetReg(1, param_1); 87 Core::AppCore().SetReg(1, param_1);
88 FuncReturn(retval); 88 FuncReturn(retval);
89} 89}
90 90
@@ -102,11 +102,11 @@ void Wrap() {
102 MemoryInfo memory_info = {}; 102 MemoryInfo memory_info = {};
103 PageInfo page_info = {}; 103 PageInfo page_info = {};
104 u32 retval = func(&memory_info, &page_info, PARAM(2)).raw; 104 u32 retval = func(&memory_info, &page_info, PARAM(2)).raw;
105 Core::g_app_core->SetReg(1, memory_info.base_address); 105 Core::AppCore().SetReg(1, memory_info.base_address);
106 Core::g_app_core->SetReg(2, memory_info.size); 106 Core::AppCore().SetReg(2, memory_info.size);
107 Core::g_app_core->SetReg(3, memory_info.permission); 107 Core::AppCore().SetReg(3, memory_info.permission);
108 Core::g_app_core->SetReg(4, memory_info.state); 108 Core::AppCore().SetReg(4, memory_info.state);
109 Core::g_app_core->SetReg(5, page_info.flags); 109 Core::AppCore().SetReg(5, page_info.flags);
110 FuncReturn(retval); 110 FuncReturn(retval);
111} 111}
112 112
@@ -115,11 +115,11 @@ void Wrap() {
115 MemoryInfo memory_info = {}; 115 MemoryInfo memory_info = {};
116 PageInfo page_info = {}; 116 PageInfo page_info = {};
117 u32 retval = func(&memory_info, &page_info, PARAM(2), PARAM(3)).raw; 117 u32 retval = func(&memory_info, &page_info, PARAM(2), PARAM(3)).raw;
118 Core::g_app_core->SetReg(1, memory_info.base_address); 118 Core::AppCore().SetReg(1, memory_info.base_address);
119 Core::g_app_core->SetReg(2, memory_info.size); 119 Core::AppCore().SetReg(2, memory_info.size);
120 Core::g_app_core->SetReg(3, memory_info.permission); 120 Core::AppCore().SetReg(3, memory_info.permission);
121 Core::g_app_core->SetReg(4, memory_info.state); 121 Core::AppCore().SetReg(4, memory_info.state);
122 Core::g_app_core->SetReg(5, page_info.flags); 122 Core::AppCore().SetReg(5, page_info.flags);
123 FuncReturn(retval); 123 FuncReturn(retval);
124} 124}
125 125
@@ -127,7 +127,7 @@ template <ResultCode func(s32*, u32)>
127void Wrap() { 127void Wrap() {
128 s32 param_1 = 0; 128 s32 param_1 = 0;
129 u32 retval = func(&param_1, PARAM(1)).raw; 129 u32 retval = func(&param_1, PARAM(1)).raw;
130 Core::g_app_core->SetReg(1, param_1); 130 Core::AppCore().SetReg(1, param_1);
131 FuncReturn(retval); 131 FuncReturn(retval);
132} 132}
133 133
@@ -140,7 +140,7 @@ template <ResultCode func(u32*, u32)>
140void Wrap() { 140void Wrap() {
141 u32 param_1 = 0; 141 u32 param_1 = 0;
142 u32 retval = func(&param_1, PARAM(1)).raw; 142 u32 retval = func(&param_1, PARAM(1)).raw;
143 Core::g_app_core->SetReg(1, param_1); 143 Core::AppCore().SetReg(1, param_1);
144 FuncReturn(retval); 144 FuncReturn(retval);
145} 145}
146 146
@@ -160,7 +160,7 @@ template <ResultCode func(u32*, const char*)>
160void Wrap() { 160void Wrap() {
161 u32 param_1 = 0; 161 u32 param_1 = 0;
162 u32 retval = func(&param_1, (char*)Memory::GetPointer(PARAM(1))).raw; 162 u32 retval = func(&param_1, (char*)Memory::GetPointer(PARAM(1))).raw;
163 Core::g_app_core->SetReg(1, param_1); 163 Core::AppCore().SetReg(1, param_1);
164 FuncReturn(retval); 164 FuncReturn(retval);
165} 165}
166 166
@@ -168,7 +168,7 @@ template <ResultCode func(u32*, s32, s32)>
168void Wrap() { 168void Wrap() {
169 u32 param_1 = 0; 169 u32 param_1 = 0;
170 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw; 170 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
171 Core::g_app_core->SetReg(1, param_1); 171 Core::AppCore().SetReg(1, param_1);
172 FuncReturn(retval); 172 FuncReturn(retval);
173} 173}
174 174
@@ -176,7 +176,7 @@ template <ResultCode func(s32*, u32, s32)>
176void Wrap() { 176void Wrap() {
177 s32 param_1 = 0; 177 s32 param_1 = 0;
178 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw; 178 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
179 Core::g_app_core->SetReg(1, param_1); 179 Core::AppCore().SetReg(1, param_1);
180 FuncReturn(retval); 180 FuncReturn(retval);
181} 181}
182 182
@@ -184,8 +184,8 @@ template <ResultCode func(s64*, u32, s32)>
184void Wrap() { 184void Wrap() {
185 s64 param_1 = 0; 185 s64 param_1 = 0;
186 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw; 186 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
187 Core::g_app_core->SetReg(1, (u32)param_1); 187 Core::AppCore().SetReg(1, (u32)param_1);
188 Core::g_app_core->SetReg(2, (u32)(param_1 >> 32)); 188 Core::AppCore().SetReg(2, (u32)(param_1 >> 32));
189 FuncReturn(retval); 189 FuncReturn(retval);
190} 190}
191 191
@@ -194,7 +194,7 @@ void Wrap() {
194 u32 param_1 = 0; 194 u32 param_1 = 0;
195 // The last parameter is passed in R0 instead of R4 195 // The last parameter is passed in R0 instead of R4
196 u32 retval = func(&param_1, PARAM(1), PARAM(2), PARAM(3), PARAM(0)).raw; 196 u32 retval = func(&param_1, PARAM(1), PARAM(2), PARAM(3), PARAM(0)).raw;
197 Core::g_app_core->SetReg(1, param_1); 197 Core::AppCore().SetReg(1, param_1);
198 FuncReturn(retval); 198 FuncReturn(retval);
199} 199}
200 200
@@ -209,8 +209,8 @@ template <ResultCode func(s64*, Handle, u32)>
209void Wrap() { 209void Wrap() {
210 s64 param_1 = 0; 210 s64 param_1 = 0;
211 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw; 211 u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
212 Core::g_app_core->SetReg(1, (u32)param_1); 212 Core::AppCore().SetReg(1, (u32)param_1);
213 Core::g_app_core->SetReg(2, (u32)(param_1 >> 32)); 213 Core::AppCore().SetReg(2, (u32)(param_1 >> 32));
214 FuncReturn(retval); 214 FuncReturn(retval);
215} 215}
216 216
@@ -227,8 +227,8 @@ void Wrap() {
227 reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3)) 227 reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3))
228 .raw; 228 .raw;
229 // The first out parameter is moved into R2 and the second is moved into R1. 229 // The first out parameter is moved into R2 and the second is moved into R1.
230 Core::g_app_core->SetReg(1, param_2); 230 Core::AppCore().SetReg(1, param_2);
231 Core::g_app_core->SetReg(2, param_1); 231 Core::AppCore().SetReg(2, param_1);
232 FuncReturn(retval); 232 FuncReturn(retval);
233} 233}
234 234
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp
index 41b772163..d73d98a70 100644
--- a/src/core/hle/hle.cpp
+++ b/src/core/hle/hle.cpp
@@ -26,9 +26,9 @@ void Reschedule(const char* reason) {
26 // routines. This simulates that time by artificially advancing the number of CPU "ticks". 26 // routines. This simulates that time by artificially advancing the number of CPU "ticks".
27 // The value was chosen empirically, it seems to work well enough for everything tested, but 27 // The value was chosen empirically, it seems to work well enough for everything tested, but
28 // is likely not ideal. We should find a more accurate way to simulate timing with HLE. 28 // is likely not ideal. We should find a more accurate way to simulate timing with HLE.
29 Core::g_app_core->AddTicks(4000); 29 Core::AppCore().AddTicks(4000);
30 30
31 Core::g_app_core->PrepareReschedule(); 31 Core::AppCore().PrepareReschedule();
32 32
33 reschedule = true; 33 reschedule = true;
34} 34}
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 18b696f72..91c05fc42 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -188,7 +188,7 @@ static void SwitchContext(Thread* new_thread) {
188 // Save context for previous thread 188 // Save context for previous thread
189 if (previous_thread) { 189 if (previous_thread) {
190 previous_thread->last_running_ticks = CoreTiming::GetTicks(); 190 previous_thread->last_running_ticks = CoreTiming::GetTicks();
191 Core::g_app_core->SaveContext(previous_thread->context); 191 Core::AppCore().SaveContext(previous_thread->context);
192 192
193 if (previous_thread->status == THREADSTATUS_RUNNING) { 193 if (previous_thread->status == THREADSTATUS_RUNNING) {
194 // This is only the case when a reschedule is triggered without the current thread 194 // This is only the case when a reschedule is triggered without the current thread
@@ -214,8 +214,8 @@ static void SwitchContext(Thread* new_thread) {
214 // Restores thread to its nominal priority if it has been temporarily changed 214 // Restores thread to its nominal priority if it has been temporarily changed
215 new_thread->current_priority = new_thread->nominal_priority; 215 new_thread->current_priority = new_thread->nominal_priority;
216 216
217 Core::g_app_core->LoadContext(new_thread->context); 217 Core::AppCore().LoadContext(new_thread->context);
218 Core::g_app_core->SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress()); 218 Core::AppCore().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
219 } else { 219 } else {
220 current_thread = nullptr; 220 current_thread = nullptr;
221 } 221 }
diff --git a/src/core/hle/service/ldr_ro/ldr_ro.cpp b/src/core/hle/service/ldr_ro/ldr_ro.cpp
index 9e5d6a318..614f16d44 100644
--- a/src/core/hle/service/ldr_ro/ldr_ro.cpp
+++ b/src/core/hle/service/ldr_ro/ldr_ro.cpp
@@ -457,7 +457,7 @@ static void LoadCRO(Interface* self, bool link_on_load_bug_fix) {
457 } 457 }
458 } 458 }
459 459
460 Core::g_app_core->ClearInstructionCache(); 460 Core::AppCore().ClearInstructionCache();
461 461
462 LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X", cro.ModuleName().data(), 462 LOG_INFO(Service_LDR, "CRO \"%s\" loaded at 0x%08X, fixed_end=0x%08X", cro.ModuleName().data(),
463 cro_address, cro_address + fix_size); 463 cro_address, cro_address + fix_size);
@@ -562,7 +562,7 @@ static void UnloadCRO(Interface* self) {
562 memory_synchronizer.RemoveMemoryBlock(cro_address, cro_buffer_ptr); 562 memory_synchronizer.RemoveMemoryBlock(cro_address, cro_buffer_ptr);
563 } 563 }
564 564
565 Core::g_app_core->ClearInstructionCache(); 565 Core::AppCore().ClearInstructionCache();
566 566
567 cmd_buff[1] = result.raw; 567 cmd_buff[1] = result.raw;
568} 568}
@@ -624,7 +624,7 @@ static void LinkCRO(Interface* self) {
624 } 624 }
625 625
626 memory_synchronizer.SynchronizeOriginalMemory(); 626 memory_synchronizer.SynchronizeOriginalMemory();
627 Core::g_app_core->ClearInstructionCache(); 627 Core::AppCore().ClearInstructionCache();
628 628
629 cmd_buff[1] = result.raw; 629 cmd_buff[1] = result.raw;
630} 630}
@@ -686,7 +686,7 @@ static void UnlinkCRO(Interface* self) {
686 } 686 }
687 687
688 memory_synchronizer.SynchronizeOriginalMemory(); 688 memory_synchronizer.SynchronizeOriginalMemory();
689 Core::g_app_core->ClearInstructionCache(); 689 Core::AppCore().ClearInstructionCache();
690 690
691 cmd_buff[1] = result.raw; 691 cmd_buff[1] = result.raw;
692} 692}
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 5839d7230..b20f2aaa4 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -582,7 +582,7 @@ static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point
582 582
583/// Called when a thread exits 583/// Called when a thread exits
584static void ExitThread() { 584static void ExitThread() {
585 LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); 585 LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::AppCore().GetPC());
586 586
587 Kernel::ExitCurrentThread(); 587 Kernel::ExitCurrentThread();
588} 588}
@@ -612,7 +612,7 @@ static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) {
612 using Kernel::Mutex; 612 using Kernel::Mutex;
613 613
614 SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0); 614 SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0);
615 mutex->name = Common::StringFromFormat("mutex-%08x", Core::g_app_core->GetReg(14)); 615 mutex->name = Common::StringFromFormat("mutex-%08x", Core::AppCore().GetReg(14));
616 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(mutex))); 616 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(mutex)));
617 617
618 LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X", 618 LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X",
@@ -683,7 +683,7 @@ static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max
683 using Kernel::Semaphore; 683 using Kernel::Semaphore;
684 684
685 CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count)); 685 CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count));
686 semaphore->name = Common::StringFromFormat("semaphore-%08x", Core::g_app_core->GetReg(14)); 686 semaphore->name = Common::StringFromFormat("semaphore-%08x", Core::AppCore().GetReg(14));
687 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(semaphore))); 687 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(semaphore)));
688 688
689 LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X", 689 LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X",
@@ -740,7 +740,7 @@ static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
740 using Kernel::Event; 740 using Kernel::Event;
741 741
742 SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type)); 742 SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type));
743 evt->name = Common::StringFromFormat("event-%08x", Core::g_app_core->GetReg(14)); 743 evt->name = Common::StringFromFormat("event-%08x", Core::AppCore().GetReg(14));
744 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(evt))); 744 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(evt)));
745 745
746 LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, 746 LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type,
@@ -787,7 +787,7 @@ static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
787 using Kernel::Timer; 787 using Kernel::Timer;
788 788
789 SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type)); 789 SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type));
790 timer->name = Common::StringFromFormat("timer-%08x", Core::g_app_core->GetReg(14)); 790 timer->name = Common::StringFromFormat("timer-%08x", Core::AppCore().GetReg(14));
791 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(timer))); 791 CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(timer)));
792 792
793 LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, 793 LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type,
@@ -854,7 +854,7 @@ static void SleepThread(s64 nanoseconds) {
854static s64 GetSystemTick() { 854static s64 GetSystemTick() {
855 s64 result = CoreTiming::GetTicks(); 855 s64 result = CoreTiming::GetTicks();
856 // Advance time to defeat dumb games (like Cubic Ninja) that busy-wait for the frame to end. 856 // Advance time to defeat dumb games (like Cubic Ninja) that busy-wait for the frame to end.
857 Core::g_app_core->AddTicks( 857 Core::AppCore().AddTicks(
858 150); // Measured time between two calls on a 9.2 o3DS with Ninjhax 1.1b 858 150); // Measured time between two calls on a 9.2 o3DS with Ninjhax 1.1b
859 return result; 859 return result;
860} 860}