summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/core.cpp14
-rw-r--r--src/core/hle/kernel/thread.cpp44
-rw-r--r--src/core/hle/service/srv.cpp2
-rw-r--r--src/core/mem_map.cpp60
-rw-r--r--src/core/mem_map_funcs.cpp18
5 files changed, 69 insertions, 69 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 25c78d33c..865898b24 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -16,10 +16,10 @@
16 16
17namespace Core { 17namespace Core {
18 18
19u64 g_last_ticks = 0; ///< Last CPU ticks 19static u64 last_ticks = 0; ///< Last CPU ticks
20ARM_Disasm* g_disasm = nullptr; ///< ARM disassembler 20static ARM_Disasm* disasm = nullptr; ///< ARM disassembler
21ARM_Interface* g_app_core = nullptr; ///< ARM11 application core 21ARM_Interface* g_app_core = nullptr; ///< ARM11 application core
22ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core 22ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core
23 23
24/// Run the core CPU loop 24/// Run the core CPU loop
25void RunLoop(int tight_loop) { 25void RunLoop(int tight_loop) {
@@ -49,7 +49,7 @@ void Stop() {
49int Init() { 49int Init() {
50 NOTICE_LOG(MASTER_LOG, "initialized OK"); 50 NOTICE_LOG(MASTER_LOG, "initialized OK");
51 51
52 g_disasm = new ARM_Disasm(); 52 disasm = new ARM_Disasm();
53 g_sys_core = new ARM_Interpreter(); 53 g_sys_core = new ARM_Interpreter();
54 54
55 switch (Settings::values.cpu_core) { 55 switch (Settings::values.cpu_core) {
@@ -62,13 +62,13 @@ int Init() {
62 break; 62 break;
63 } 63 }
64 64
65 g_last_ticks = Core::g_app_core->GetTicks(); 65 last_ticks = Core::g_app_core->GetTicks();
66 66
67 return 0; 67 return 0;
68} 68}
69 69
70void Shutdown() { 70void Shutdown() {
71 delete g_disasm; 71 delete disasm;
72 delete g_app_core; 72 delete g_app_core;
73 delete g_sys_core; 73 delete g_sys_core;
74 74
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index e15590c49..35ff9a379 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -71,17 +71,17 @@ public:
71}; 71};
72 72
73// Lists all thread ids that aren't deleted/etc. 73// Lists all thread ids that aren't deleted/etc.
74std::vector<Handle> g_thread_queue; 74static std::vector<Handle> thread_queue;
75 75
76// Lists only ready thread ids. 76// Lists only ready thread ids.
77Common::ThreadQueueList<Handle> g_thread_ready_queue; 77static Common::ThreadQueueList<Handle> thread_ready_queue;
78 78
79Handle g_current_thread_handle; 79static Handle current_thread_handle;
80Thread* g_current_thread; 80static Thread* current_thread;
81 81
82/// Gets the current thread 82/// Gets the current thread
83inline Thread* GetCurrentThread() { 83inline Thread* GetCurrentThread() {
84 return g_current_thread; 84 return current_thread;
85} 85}
86 86
87/// Gets the current thread handle 87/// Gets the current thread handle
@@ -91,8 +91,8 @@ Handle GetCurrentThreadHandle() {
91 91
92/// Sets the current thread 92/// Sets the current thread
93inline void SetCurrentThread(Thread* t) { 93inline void SetCurrentThread(Thread* t) {
94 g_current_thread = t; 94 current_thread = t;
95 g_current_thread_handle = t->GetHandle(); 95 current_thread_handle = t->GetHandle();
96} 96}
97 97
98/// Saves the current CPU context 98/// Saves the current CPU context
@@ -131,13 +131,13 @@ void ChangeReadyState(Thread* t, bool ready) {
131 Handle handle = t->GetHandle(); 131 Handle handle = t->GetHandle();
132 if (t->IsReady()) { 132 if (t->IsReady()) {
133 if (!ready) { 133 if (!ready) {
134 g_thread_ready_queue.remove(t->current_priority, handle); 134 thread_ready_queue.remove(t->current_priority, handle);
135 } 135 }
136 } else if (ready) { 136 } else if (ready) {
137 if (t->IsRunning()) { 137 if (t->IsRunning()) {
138 g_thread_ready_queue.push_front(t->current_priority, handle); 138 thread_ready_queue.push_front(t->current_priority, handle);
139 } else { 139 } else {
140 g_thread_ready_queue.push_back(t->current_priority, handle); 140 thread_ready_queue.push_back(t->current_priority, handle);
141 } 141 }
142 t->status = THREADSTATUS_READY; 142 t->status = THREADSTATUS_READY;
143 } 143 }
@@ -195,7 +195,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) {
195 s32 priority = THREADPRIO_LOWEST; 195 s32 priority = THREADPRIO_LOWEST;
196 196
197 // Iterate through threads, find highest priority thread that is waiting to be arbitrated... 197 // Iterate through threads, find highest priority thread that is waiting to be arbitrated...
198 for (const auto& handle : g_thread_queue) { 198 for (const auto& handle : thread_queue) {
199 199
200 // TODO(bunnei): Verify arbiter address... 200 // TODO(bunnei): Verify arbiter address...
201 if (!VerifyWait(handle, WAITTYPE_ARB, arbiter)) 201 if (!VerifyWait(handle, WAITTYPE_ARB, arbiter))
@@ -218,7 +218,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) {
218void ArbitrateAllThreads(u32 arbiter, u32 address) { 218void ArbitrateAllThreads(u32 arbiter, u32 address) {
219 219
220 // Iterate through threads, find highest priority thread that is waiting to be arbitrated... 220 // Iterate through threads, find highest priority thread that is waiting to be arbitrated...
221 for (const auto& handle : g_thread_queue) { 221 for (const auto& handle : thread_queue) {
222 222
223 // TODO(bunnei): Verify arbiter address... 223 // TODO(bunnei): Verify arbiter address...
224 if (VerifyWait(handle, WAITTYPE_ARB, arbiter)) 224 if (VerifyWait(handle, WAITTYPE_ARB, arbiter))
@@ -265,9 +265,9 @@ Thread* NextThread() {
265 Thread* cur = GetCurrentThread(); 265 Thread* cur = GetCurrentThread();
266 266
267 if (cur && cur->IsRunning()) { 267 if (cur && cur->IsRunning()) {
268 next = g_thread_ready_queue.pop_first_better(cur->current_priority); 268 next = thread_ready_queue.pop_first_better(cur->current_priority);
269 } else { 269 } else {
270 next = g_thread_ready_queue.pop_first(); 270 next = thread_ready_queue.pop_first();
271 } 271 }
272 if (next == 0) { 272 if (next == 0) {
273 return nullptr; 273 return nullptr;
@@ -306,9 +306,9 @@ void DebugThreadQueue() {
306 return; 306 return;
307 } 307 }
308 INFO_LOG(KERNEL, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThreadHandle()); 308 INFO_LOG(KERNEL, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThreadHandle());
309 for (u32 i = 0; i < g_thread_queue.size(); i++) { 309 for (u32 i = 0; i < thread_queue.size(); i++) {
310 Handle handle = g_thread_queue[i]; 310 Handle handle = thread_queue[i];
311 s32 priority = g_thread_ready_queue.contains(handle); 311 s32 priority = thread_ready_queue.contains(handle);
312 if (priority != -1) { 312 if (priority != -1) {
313 INFO_LOG(KERNEL, "0x%02X 0x%08X", priority, handle); 313 INFO_LOG(KERNEL, "0x%02X 0x%08X", priority, handle);
314 } 314 }
@@ -326,8 +326,8 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
326 326
327 handle = Kernel::g_object_pool.Create(thread); 327 handle = Kernel::g_object_pool.Create(thread);
328 328
329 g_thread_queue.push_back(handle); 329 thread_queue.push_back(handle);
330 g_thread_ready_queue.prepare(priority); 330 thread_ready_queue.prepare(priority);
331 331
332 thread->status = THREADSTATUS_DORMANT; 332 thread->status = THREADSTATUS_DORMANT;
333 thread->entry_point = entry_point; 333 thread->entry_point = entry_point;
@@ -405,16 +405,16 @@ Result SetThreadPriority(Handle handle, s32 priority) {
405 405
406 // Change thread priority 406 // Change thread priority
407 s32 old = thread->current_priority; 407 s32 old = thread->current_priority;
408 g_thread_ready_queue.remove(old, handle); 408 thread_ready_queue.remove(old, handle);
409 thread->current_priority = priority; 409 thread->current_priority = priority;
410 g_thread_ready_queue.prepare(thread->current_priority); 410 thread_ready_queue.prepare(thread->current_priority);
411 411
412 // Change thread status to "ready" and push to ready queue 412 // Change thread status to "ready" and push to ready queue
413 if (thread->IsRunning()) { 413 if (thread->IsRunning()) {
414 thread->status = (thread->status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY; 414 thread->status = (thread->status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY;
415 } 415 }
416 if (thread->IsReady()) { 416 if (thread->IsReady()) {
417 g_thread_ready_queue.push_back(thread->current_priority, handle); 417 thread_ready_queue.push_back(thread->current_priority, handle);
418 } 418 }
419 419
420 return 0; 420 return 0;
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp
index 420f53f8f..df38bd93c 100644
--- a/src/core/hle/service/srv.cpp
+++ b/src/core/hle/service/srv.cpp
@@ -11,7 +11,7 @@
11 11
12namespace SRV { 12namespace SRV {
13 13
14Handle g_event_handle = 0; 14static Handle g_event_handle = 0;
15 15
16static void Initialize(Service::Interface* self) { 16static void Initialize(Service::Interface* self) {
17 DEBUG_LOG(OSHLE, "called"); 17 DEBUG_LOG(OSHLE, "called");
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp
index cf12f24d9..74a93b1d9 100644
--- a/src/core/mem_map.cpp
+++ b/src/core/mem_map.cpp
@@ -11,38 +11,38 @@
11 11
12namespace Memory { 12namespace Memory {
13 13
14u8* g_base = NULL; ///< The base pointer to the auto-mirrored arena. 14u8* g_base = nullptr; ///< The base pointer to the auto-mirrored arena.
15 15
16MemArena g_arena; ///< The MemArena class 16static MemArena arena; ///< The MemArena class
17 17
18u8* g_exefs_code = NULL; ///< ExeFS:/.code is loaded here 18u8* g_exefs_code = nullptr; ///< ExeFS:/.code is loaded here
19u8* g_system_mem = NULL; ///< System memory 19u8* g_system_mem = nullptr; ///< System memory
20u8* g_heap = NULL; ///< Application heap (main memory) 20u8* g_heap = nullptr; ///< Application heap (main memory)
21u8* g_heap_gsp = NULL; ///< GSP heap (main memory) 21u8* g_heap_gsp = nullptr; ///< GSP heap (main memory)
22u8* g_vram = NULL; ///< Video memory (VRAM) pointer 22u8* g_vram = nullptr; ///< Video memory (VRAM) pointer
23u8* g_shared_mem = NULL; ///< Shared memory 23u8* g_shared_mem = nullptr; ///< Shared memory
24u8* g_kernel_mem; ///< Kernel memory 24u8* g_kernel_mem; ///< Kernel memory
25 25
26u8* g_physical_bootrom = NULL; ///< Bootrom physical memory 26static u8* physical_bootrom = nullptr; ///< Bootrom physical memory
27u8* g_uncached_bootrom = NULL; 27static u8* uncached_bootrom = nullptr;
28 28
29u8* g_physical_exefs_code = NULL; ///< Phsical ExeFS:/.code is loaded here 29static u8* physical_exefs_code = nullptr; ///< Phsical ExeFS:/.code is loaded here
30u8* g_physical_system_mem = NULL; ///< System physical memory 30static u8* physical_system_mem = nullptr; ///< System physical memory
31u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM) 31static u8* physical_fcram = nullptr; ///< Main physical memory (FCRAM)
32u8* g_physical_heap_gsp = NULL; ///< GSP heap physical memory 32static u8* physical_heap_gsp = nullptr; ///< GSP heap physical memory
33u8* g_physical_vram = NULL; ///< Video physical memory (VRAM) 33static u8* physical_vram = nullptr; ///< Video physical memory (VRAM)
34u8* g_physical_shared_mem = NULL; ///< Physical shared memory 34static u8* physical_shared_mem = nullptr; ///< Physical shared memory
35u8* g_physical_kernel_mem; ///< Kernel memory 35static u8* physical_kernel_mem; ///< Kernel memory
36 36
37// We don't declare the IO region in here since its handled by other means. 37// We don't declare the IO region in here since its handled by other means.
38static MemoryView g_views[] = { 38static MemoryView g_views[] = {
39 {&g_exefs_code, &g_physical_exefs_code, EXEFS_CODE_VADDR, EXEFS_CODE_SIZE, 0}, 39 {&g_exefs_code, &physical_exefs_code, EXEFS_CODE_VADDR, EXEFS_CODE_SIZE, 0},
40 {&g_vram, &g_physical_vram, VRAM_VADDR, VRAM_SIZE, 0}, 40 {&g_vram, &physical_vram, VRAM_VADDR, VRAM_SIZE, 0},
41 {&g_heap, &g_physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM}, 41 {&g_heap, &physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM},
42 {&g_shared_mem, &g_physical_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE, 0}, 42 {&g_shared_mem, &physical_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE, 0},
43 {&g_system_mem, &g_physical_system_mem, SYSTEM_MEMORY_VADDR, SYSTEM_MEMORY_SIZE, 0}, 43 {&g_system_mem, &physical_system_mem, SYSTEM_MEMORY_VADDR, SYSTEM_MEMORY_SIZE, 0},
44 {&g_kernel_mem, &g_physical_kernel_mem, KERNEL_MEMORY_VADDR, KERNEL_MEMORY_SIZE, 0}, 44 {&g_kernel_mem, &physical_kernel_mem, KERNEL_MEMORY_VADDR, KERNEL_MEMORY_SIZE, 0},
45 {&g_heap_gsp, &g_physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0}, 45 {&g_heap_gsp, &physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0},
46}; 46};
47 47
48/*static MemoryView views[] = 48/*static MemoryView views[] =
@@ -69,18 +69,18 @@ void Init() {
69 g_views[i].size = FCRAM_SIZE; 69 g_views[i].size = FCRAM_SIZE;
70 } 70 }
71 71
72 g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &g_arena); 72 g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &arena);
73 73
74 NOTICE_LOG(MEMMAP, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap, 74 NOTICE_LOG(MEMMAP, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap,
75 g_physical_fcram); 75 physical_fcram);
76} 76}
77 77
78void Shutdown() { 78void Shutdown() {
79 u32 flags = 0; 79 u32 flags = 0;
80 MemoryMap_Shutdown(g_views, kNumMemViews, flags, &g_arena); 80 MemoryMap_Shutdown(g_views, kNumMemViews, flags, &arena);
81 81
82 g_arena.ReleaseSpace(); 82 arena.ReleaseSpace();
83 g_base = NULL; 83 g_base = nullptr;
84 84
85 NOTICE_LOG(MEMMAP, "shutdown OK"); 85 NOTICE_LOG(MEMMAP, "shutdown OK");
86} 86}
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp
index 90951812b..443d5ad7e 100644
--- a/src/core/mem_map_funcs.cpp
+++ b/src/core/mem_map_funcs.cpp
@@ -12,9 +12,9 @@
12 12
13namespace Memory { 13namespace Memory {
14 14
15std::map<u32, MemoryBlock> g_heap_map; 15static std::map<u32, MemoryBlock> heap_map;
16std::map<u32, MemoryBlock> g_heap_gsp_map; 16static std::map<u32, MemoryBlock> heap_gsp_map;
17std::map<u32, MemoryBlock> g_shared_map; 17static std::map<u32, MemoryBlock> shared_map;
18 18
19/// Convert a physical address to virtual address 19/// Convert a physical address to virtual address
20VAddr PhysicalToVirtualAddress(const PAddr addr) { 20VAddr PhysicalToVirtualAddress(const PAddr addr) {
@@ -194,11 +194,11 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) {
194 block.operation = operation; 194 block.operation = operation;
195 block.permissions = permissions; 195 block.permissions = permissions;
196 196
197 if (g_heap_map.size() > 0) { 197 if (heap_map.size() > 0) {
198 const MemoryBlock last_block = g_heap_map.rbegin()->second; 198 const MemoryBlock last_block = heap_map.rbegin()->second;
199 block.address = last_block.address + last_block.size; 199 block.address = last_block.address + last_block.size;
200 } 200 }
201 g_heap_map[block.GetVirtualAddress()] = block; 201 heap_map[block.GetVirtualAddress()] = block;
202 202
203 return block.GetVirtualAddress(); 203 return block.GetVirtualAddress();
204} 204}
@@ -217,11 +217,11 @@ u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) {
217 block.operation = operation; 217 block.operation = operation;
218 block.permissions = permissions; 218 block.permissions = permissions;
219 219
220 if (g_heap_gsp_map.size() > 0) { 220 if (heap_gsp_map.size() > 0) {
221 const MemoryBlock last_block = g_heap_gsp_map.rbegin()->second; 221 const MemoryBlock last_block = heap_gsp_map.rbegin()->second;
222 block.address = last_block.address + last_block.size; 222 block.address = last_block.address + last_block.size;
223 } 223 }
224 g_heap_gsp_map[block.GetVirtualAddress()] = block; 224 heap_gsp_map[block.GetVirtualAddress()] = block;
225 225
226 return block.GetVirtualAddress(); 226 return block.GetVirtualAddress();
227} 227}