diff options
| author | 2014-11-19 09:39:20 -0500 | |
|---|---|---|
| committer | 2014-11-19 09:39:20 -0500 | |
| commit | 112768f4365816d345b0dc9b93bfecc3d41a69b5 (patch) | |
| tree | 6d49fe44d004cb998e0b4b4d26066ae91eef01aa /src | |
| parent | Merge pull request #212 from archshift/idea (diff) | |
| parent | Add static to some variables (diff) | |
| download | yuzu-112768f4365816d345b0dc9b93bfecc3d41a69b5.tar.gz yuzu-112768f4365816d345b0dc9b93bfecc3d41a69b5.tar.xz yuzu-112768f4365816d345b0dc9b93bfecc3d41a69b5.zip | |
Merge pull request #208 from lioncash/statics
Add static to some variables
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 44 | ||||
| -rw-r--r-- | src/core/hle/service/srv.cpp | 2 | ||||
| -rw-r--r-- | src/core/mem_map.cpp | 60 | ||||
| -rw-r--r-- | src/core/mem_map_funcs.cpp | 18 |
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 | ||
| 17 | namespace Core { | 17 | namespace Core { |
| 18 | 18 | ||
| 19 | u64 g_last_ticks = 0; ///< Last CPU ticks | 19 | static u64 last_ticks = 0; ///< Last CPU ticks |
| 20 | ARM_Disasm* g_disasm = nullptr; ///< ARM disassembler | 20 | static ARM_Disasm* disasm = nullptr; ///< ARM disassembler |
| 21 | ARM_Interface* g_app_core = nullptr; ///< ARM11 application core | 21 | ARM_Interface* g_app_core = nullptr; ///< ARM11 application core |
| 22 | ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core | 22 | ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core |
| 23 | 23 | ||
| 24 | /// Run the core CPU loop | 24 | /// Run the core CPU loop |
| 25 | void RunLoop(int tight_loop) { | 25 | void RunLoop(int tight_loop) { |
| @@ -49,7 +49,7 @@ void Stop() { | |||
| 49 | int Init() { | 49 | int 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 | ||
| 70 | void Shutdown() { | 70 | void 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. |
| 74 | std::vector<Handle> g_thread_queue; | 74 | static std::vector<Handle> thread_queue; |
| 75 | 75 | ||
| 76 | // Lists only ready thread ids. | 76 | // Lists only ready thread ids. |
| 77 | Common::ThreadQueueList<Handle> g_thread_ready_queue; | 77 | static Common::ThreadQueueList<Handle> thread_ready_queue; |
| 78 | 78 | ||
| 79 | Handle g_current_thread_handle; | 79 | static Handle current_thread_handle; |
| 80 | Thread* g_current_thread; | 80 | static Thread* current_thread; |
| 81 | 81 | ||
| 82 | /// Gets the current thread | 82 | /// Gets the current thread |
| 83 | inline Thread* GetCurrentThread() { | 83 | inline 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 |
| 93 | inline void SetCurrentThread(Thread* t) { | 93 | inline 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) { | |||
| 218 | void ArbitrateAllThreads(u32 arbiter, u32 address) { | 218 | void 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 | ||
| 12 | namespace SRV { | 12 | namespace SRV { |
| 13 | 13 | ||
| 14 | Handle g_event_handle = 0; | 14 | static Handle g_event_handle = 0; |
| 15 | 15 | ||
| 16 | static void Initialize(Service::Interface* self) { | 16 | static 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 | ||
| 12 | namespace Memory { | 12 | namespace Memory { |
| 13 | 13 | ||
| 14 | u8* g_base = NULL; ///< The base pointer to the auto-mirrored arena. | 14 | u8* g_base = nullptr; ///< The base pointer to the auto-mirrored arena. |
| 15 | 15 | ||
| 16 | MemArena g_arena; ///< The MemArena class | 16 | static MemArena arena; ///< The MemArena class |
| 17 | 17 | ||
| 18 | u8* g_exefs_code = NULL; ///< ExeFS:/.code is loaded here | 18 | u8* g_exefs_code = nullptr; ///< ExeFS:/.code is loaded here |
| 19 | u8* g_system_mem = NULL; ///< System memory | 19 | u8* g_system_mem = nullptr; ///< System memory |
| 20 | u8* g_heap = NULL; ///< Application heap (main memory) | 20 | u8* g_heap = nullptr; ///< Application heap (main memory) |
| 21 | u8* g_heap_gsp = NULL; ///< GSP heap (main memory) | 21 | u8* g_heap_gsp = nullptr; ///< GSP heap (main memory) |
| 22 | u8* g_vram = NULL; ///< Video memory (VRAM) pointer | 22 | u8* g_vram = nullptr; ///< Video memory (VRAM) pointer |
| 23 | u8* g_shared_mem = NULL; ///< Shared memory | 23 | u8* g_shared_mem = nullptr; ///< Shared memory |
| 24 | u8* g_kernel_mem; ///< Kernel memory | 24 | u8* g_kernel_mem; ///< Kernel memory |
| 25 | 25 | ||
| 26 | u8* g_physical_bootrom = NULL; ///< Bootrom physical memory | 26 | static u8* physical_bootrom = nullptr; ///< Bootrom physical memory |
| 27 | u8* g_uncached_bootrom = NULL; | 27 | static u8* uncached_bootrom = nullptr; |
| 28 | 28 | ||
| 29 | u8* g_physical_exefs_code = NULL; ///< Phsical ExeFS:/.code is loaded here | 29 | static u8* physical_exefs_code = nullptr; ///< Phsical ExeFS:/.code is loaded here |
| 30 | u8* g_physical_system_mem = NULL; ///< System physical memory | 30 | static u8* physical_system_mem = nullptr; ///< System physical memory |
| 31 | u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM) | 31 | static u8* physical_fcram = nullptr; ///< Main physical memory (FCRAM) |
| 32 | u8* g_physical_heap_gsp = NULL; ///< GSP heap physical memory | 32 | static u8* physical_heap_gsp = nullptr; ///< GSP heap physical memory |
| 33 | u8* g_physical_vram = NULL; ///< Video physical memory (VRAM) | 33 | static u8* physical_vram = nullptr; ///< Video physical memory (VRAM) |
| 34 | u8* g_physical_shared_mem = NULL; ///< Physical shared memory | 34 | static u8* physical_shared_mem = nullptr; ///< Physical shared memory |
| 35 | u8* g_physical_kernel_mem; ///< Kernel memory | 35 | static 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. |
| 38 | static MemoryView g_views[] = { | 38 | static 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 | ||
| 78 | void Shutdown() { | 78 | void 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 | ||
| 13 | namespace Memory { | 13 | namespace Memory { |
| 14 | 14 | ||
| 15 | std::map<u32, MemoryBlock> g_heap_map; | 15 | static std::map<u32, MemoryBlock> heap_map; |
| 16 | std::map<u32, MemoryBlock> g_heap_gsp_map; | 16 | static std::map<u32, MemoryBlock> heap_gsp_map; |
| 17 | std::map<u32, MemoryBlock> g_shared_map; | 17 | static std::map<u32, MemoryBlock> shared_map; |
| 18 | 18 | ||
| 19 | /// Convert a physical address to virtual address | 19 | /// Convert a physical address to virtual address |
| 20 | VAddr PhysicalToVirtualAddress(const PAddr addr) { | 20 | VAddr 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 | } |