Merge pull request #208 from lioncash/statics

Add static to some variables
master
bunnei 2014-11-19 09:39:20 +07:00
commit 112768f436
5 changed files with 69 additions and 69 deletions

@ -16,10 +16,10 @@
namespace Core { namespace Core {
u64 g_last_ticks = 0; ///< Last CPU ticks static u64 last_ticks = 0; ///< Last CPU ticks
ARM_Disasm* g_disasm = nullptr; ///< ARM disassembler static ARM_Disasm* disasm = nullptr; ///< ARM disassembler
ARM_Interface* g_app_core = nullptr; ///< ARM11 application core ARM_Interface* g_app_core = nullptr; ///< ARM11 application core
ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core
/// Run the core CPU loop /// Run the core CPU loop
void RunLoop(int tight_loop) { void RunLoop(int tight_loop) {
@ -49,7 +49,7 @@ void Stop() {
int Init() { int Init() {
NOTICE_LOG(MASTER_LOG, "initialized OK"); NOTICE_LOG(MASTER_LOG, "initialized OK");
g_disasm = new ARM_Disasm(); disasm = new ARM_Disasm();
g_sys_core = new ARM_Interpreter(); g_sys_core = new ARM_Interpreter();
switch (Settings::values.cpu_core) { switch (Settings::values.cpu_core) {
@ -62,13 +62,13 @@ int Init() {
break; break;
} }
g_last_ticks = Core::g_app_core->GetTicks(); last_ticks = Core::g_app_core->GetTicks();
return 0; return 0;
} }
void Shutdown() { void Shutdown() {
delete g_disasm; delete disasm;
delete g_app_core; delete g_app_core;
delete g_sys_core; delete g_sys_core;

@ -71,17 +71,17 @@ public:
}; };
// Lists all thread ids that aren't deleted/etc. // Lists all thread ids that aren't deleted/etc.
std::vector<Handle> g_thread_queue; static std::vector<Handle> thread_queue;
// Lists only ready thread ids. // Lists only ready thread ids.
Common::ThreadQueueList<Handle> g_thread_ready_queue; static Common::ThreadQueueList<Handle> thread_ready_queue;
Handle g_current_thread_handle; static Handle current_thread_handle;
Thread* g_current_thread; static Thread* current_thread;
/// Gets the current thread /// Gets the current thread
inline Thread* GetCurrentThread() { inline Thread* GetCurrentThread() {
return g_current_thread; return current_thread;
} }
/// Gets the current thread handle /// Gets the current thread handle
@ -91,8 +91,8 @@ Handle GetCurrentThreadHandle() {
/// Sets the current thread /// Sets the current thread
inline void SetCurrentThread(Thread* t) { inline void SetCurrentThread(Thread* t) {
g_current_thread = t; current_thread = t;
g_current_thread_handle = t->GetHandle(); current_thread_handle = t->GetHandle();
} }
/// Saves the current CPU context /// Saves the current CPU context
@ -131,13 +131,13 @@ void ChangeReadyState(Thread* t, bool ready) {
Handle handle = t->GetHandle(); Handle handle = t->GetHandle();
if (t->IsReady()) { if (t->IsReady()) {
if (!ready) { if (!ready) {
g_thread_ready_queue.remove(t->current_priority, handle); thread_ready_queue.remove(t->current_priority, handle);
} }
} else if (ready) { } else if (ready) {
if (t->IsRunning()) { if (t->IsRunning()) {
g_thread_ready_queue.push_front(t->current_priority, handle); thread_ready_queue.push_front(t->current_priority, handle);
} else { } else {
g_thread_ready_queue.push_back(t->current_priority, handle); thread_ready_queue.push_back(t->current_priority, handle);
} }
t->status = THREADSTATUS_READY; t->status = THREADSTATUS_READY;
} }
@ -195,7 +195,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) {
s32 priority = THREADPRIO_LOWEST; s32 priority = THREADPRIO_LOWEST;
// Iterate through threads, find highest priority thread that is waiting to be arbitrated... // Iterate through threads, find highest priority thread that is waiting to be arbitrated...
for (const auto& handle : g_thread_queue) { for (const auto& handle : thread_queue) {
// TODO(bunnei): Verify arbiter address... // TODO(bunnei): Verify arbiter address...
if (!VerifyWait(handle, WAITTYPE_ARB, arbiter)) if (!VerifyWait(handle, WAITTYPE_ARB, arbiter))
@ -218,7 +218,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) {
void ArbitrateAllThreads(u32 arbiter, u32 address) { void ArbitrateAllThreads(u32 arbiter, u32 address) {
// Iterate through threads, find highest priority thread that is waiting to be arbitrated... // Iterate through threads, find highest priority thread that is waiting to be arbitrated...
for (const auto& handle : g_thread_queue) { for (const auto& handle : thread_queue) {
// TODO(bunnei): Verify arbiter address... // TODO(bunnei): Verify arbiter address...
if (VerifyWait(handle, WAITTYPE_ARB, arbiter)) if (VerifyWait(handle, WAITTYPE_ARB, arbiter))
@ -265,9 +265,9 @@ Thread* NextThread() {
Thread* cur = GetCurrentThread(); Thread* cur = GetCurrentThread();
if (cur && cur->IsRunning()) { if (cur && cur->IsRunning()) {
next = g_thread_ready_queue.pop_first_better(cur->current_priority); next = thread_ready_queue.pop_first_better(cur->current_priority);
} else { } else {
next = g_thread_ready_queue.pop_first(); next = thread_ready_queue.pop_first();
} }
if (next == 0) { if (next == 0) {
return nullptr; return nullptr;
@ -306,9 +306,9 @@ void DebugThreadQueue() {
return; return;
} }
INFO_LOG(KERNEL, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThreadHandle()); INFO_LOG(KERNEL, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThreadHandle());
for (u32 i = 0; i < g_thread_queue.size(); i++) { for (u32 i = 0; i < thread_queue.size(); i++) {
Handle handle = g_thread_queue[i]; Handle handle = thread_queue[i];
s32 priority = g_thread_ready_queue.contains(handle); s32 priority = thread_ready_queue.contains(handle);
if (priority != -1) { if (priority != -1) {
INFO_LOG(KERNEL, "0x%02X 0x%08X", priority, handle); INFO_LOG(KERNEL, "0x%02X 0x%08X", priority, handle);
} }
@ -326,8 +326,8 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
handle = Kernel::g_object_pool.Create(thread); handle = Kernel::g_object_pool.Create(thread);
g_thread_queue.push_back(handle); thread_queue.push_back(handle);
g_thread_ready_queue.prepare(priority); thread_ready_queue.prepare(priority);
thread->status = THREADSTATUS_DORMANT; thread->status = THREADSTATUS_DORMANT;
thread->entry_point = entry_point; thread->entry_point = entry_point;
@ -405,16 +405,16 @@ Result SetThreadPriority(Handle handle, s32 priority) {
// Change thread priority // Change thread priority
s32 old = thread->current_priority; s32 old = thread->current_priority;
g_thread_ready_queue.remove(old, handle); thread_ready_queue.remove(old, handle);
thread->current_priority = priority; thread->current_priority = priority;
g_thread_ready_queue.prepare(thread->current_priority); thread_ready_queue.prepare(thread->current_priority);
// Change thread status to "ready" and push to ready queue // Change thread status to "ready" and push to ready queue
if (thread->IsRunning()) { if (thread->IsRunning()) {
thread->status = (thread->status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY; thread->status = (thread->status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY;
} }
if (thread->IsReady()) { if (thread->IsReady()) {
g_thread_ready_queue.push_back(thread->current_priority, handle); thread_ready_queue.push_back(thread->current_priority, handle);
} }
return 0; return 0;

@ -11,7 +11,7 @@
namespace SRV { namespace SRV {
Handle g_event_handle = 0; static Handle g_event_handle = 0;
static void Initialize(Service::Interface* self) { static void Initialize(Service::Interface* self) {
DEBUG_LOG(OSHLE, "called"); DEBUG_LOG(OSHLE, "called");

@ -11,38 +11,38 @@
namespace Memory { namespace Memory {
u8* g_base = NULL; ///< The base pointer to the auto-mirrored arena. u8* g_base = nullptr; ///< The base pointer to the auto-mirrored arena.
MemArena g_arena; ///< The MemArena class static MemArena arena; ///< The MemArena class
u8* g_exefs_code = NULL; ///< ExeFS:/.code is loaded here u8* g_exefs_code = nullptr; ///< ExeFS:/.code is loaded here
u8* g_system_mem = NULL; ///< System memory u8* g_system_mem = nullptr; ///< System memory
u8* g_heap = NULL; ///< Application heap (main memory) u8* g_heap = nullptr; ///< Application heap (main memory)
u8* g_heap_gsp = NULL; ///< GSP heap (main memory) u8* g_heap_gsp = nullptr; ///< GSP heap (main memory)
u8* g_vram = NULL; ///< Video memory (VRAM) pointer u8* g_vram = nullptr; ///< Video memory (VRAM) pointer
u8* g_shared_mem = NULL; ///< Shared memory u8* g_shared_mem = nullptr; ///< Shared memory
u8* g_kernel_mem; ///< Kernel memory u8* g_kernel_mem; ///< Kernel memory
u8* g_physical_bootrom = NULL; ///< Bootrom physical memory static u8* physical_bootrom = nullptr; ///< Bootrom physical memory
u8* g_uncached_bootrom = NULL; static u8* uncached_bootrom = nullptr;
u8* g_physical_exefs_code = NULL; ///< Phsical ExeFS:/.code is loaded here static u8* physical_exefs_code = nullptr; ///< Phsical ExeFS:/.code is loaded here
u8* g_physical_system_mem = NULL; ///< System physical memory static u8* physical_system_mem = nullptr; ///< System physical memory
u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM) static u8* physical_fcram = nullptr; ///< Main physical memory (FCRAM)
u8* g_physical_heap_gsp = NULL; ///< GSP heap physical memory static u8* physical_heap_gsp = nullptr; ///< GSP heap physical memory
u8* g_physical_vram = NULL; ///< Video physical memory (VRAM) static u8* physical_vram = nullptr; ///< Video physical memory (VRAM)
u8* g_physical_shared_mem = NULL; ///< Physical shared memory static u8* physical_shared_mem = nullptr; ///< Physical shared memory
u8* g_physical_kernel_mem; ///< Kernel memory static u8* physical_kernel_mem; ///< Kernel memory
// We don't declare the IO region in here since its handled by other means. // We don't declare the IO region in here since its handled by other means.
static MemoryView g_views[] = { static MemoryView g_views[] = {
{&g_exefs_code, &g_physical_exefs_code, EXEFS_CODE_VADDR, EXEFS_CODE_SIZE, 0}, {&g_exefs_code, &physical_exefs_code, EXEFS_CODE_VADDR, EXEFS_CODE_SIZE, 0},
{&g_vram, &g_physical_vram, VRAM_VADDR, VRAM_SIZE, 0}, {&g_vram, &physical_vram, VRAM_VADDR, VRAM_SIZE, 0},
{&g_heap, &g_physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM}, {&g_heap, &physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM},
{&g_shared_mem, &g_physical_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE, 0}, {&g_shared_mem, &physical_shared_mem, SHARED_MEMORY_VADDR, SHARED_MEMORY_SIZE, 0},
{&g_system_mem, &g_physical_system_mem, SYSTEM_MEMORY_VADDR, SYSTEM_MEMORY_SIZE, 0}, {&g_system_mem, &physical_system_mem, SYSTEM_MEMORY_VADDR, SYSTEM_MEMORY_SIZE, 0},
{&g_kernel_mem, &g_physical_kernel_mem, KERNEL_MEMORY_VADDR, KERNEL_MEMORY_SIZE, 0}, {&g_kernel_mem, &physical_kernel_mem, KERNEL_MEMORY_VADDR, KERNEL_MEMORY_SIZE, 0},
{&g_heap_gsp, &g_physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0}, {&g_heap_gsp, &physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0},
}; };
/*static MemoryView views[] = /*static MemoryView views[] =
@ -69,18 +69,18 @@ void Init() {
g_views[i].size = FCRAM_SIZE; g_views[i].size = FCRAM_SIZE;
} }
g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &g_arena); g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &arena);
NOTICE_LOG(MEMMAP, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap, NOTICE_LOG(MEMMAP, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap,
g_physical_fcram); physical_fcram);
} }
void Shutdown() { void Shutdown() {
u32 flags = 0; u32 flags = 0;
MemoryMap_Shutdown(g_views, kNumMemViews, flags, &g_arena); MemoryMap_Shutdown(g_views, kNumMemViews, flags, &arena);
g_arena.ReleaseSpace(); arena.ReleaseSpace();
g_base = NULL; g_base = nullptr;
NOTICE_LOG(MEMMAP, "shutdown OK"); NOTICE_LOG(MEMMAP, "shutdown OK");
} }

@ -12,9 +12,9 @@
namespace Memory { namespace Memory {
std::map<u32, MemoryBlock> g_heap_map; static std::map<u32, MemoryBlock> heap_map;
std::map<u32, MemoryBlock> g_heap_gsp_map; static std::map<u32, MemoryBlock> heap_gsp_map;
std::map<u32, MemoryBlock> g_shared_map; static std::map<u32, MemoryBlock> shared_map;
/// Convert a physical address to virtual address /// Convert a physical address to virtual address
VAddr PhysicalToVirtualAddress(const PAddr addr) { VAddr PhysicalToVirtualAddress(const PAddr addr) {
@ -194,11 +194,11 @@ u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions) {
block.operation = operation; block.operation = operation;
block.permissions = permissions; block.permissions = permissions;
if (g_heap_map.size() > 0) { if (heap_map.size() > 0) {
const MemoryBlock last_block = g_heap_map.rbegin()->second; const MemoryBlock last_block = heap_map.rbegin()->second;
block.address = last_block.address + last_block.size; block.address = last_block.address + last_block.size;
} }
g_heap_map[block.GetVirtualAddress()] = block; heap_map[block.GetVirtualAddress()] = block;
return block.GetVirtualAddress(); return block.GetVirtualAddress();
} }
@ -217,11 +217,11 @@ u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) {
block.operation = operation; block.operation = operation;
block.permissions = permissions; block.permissions = permissions;
if (g_heap_gsp_map.size() > 0) { if (heap_gsp_map.size() > 0) {
const MemoryBlock last_block = g_heap_gsp_map.rbegin()->second; const MemoryBlock last_block = heap_gsp_map.rbegin()->second;
block.address = last_block.address + last_block.size; block.address = last_block.address + last_block.size;
} }
g_heap_gsp_map[block.GetVirtualAddress()] = block; heap_gsp_map[block.GetVirtualAddress()] = block;
return block.GetVirtualAddress(); return block.GetVirtualAddress();
} }