summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt12
-rw-r--r--src/core/arm/arm_interface.h6
-rw-r--r--src/core/arm/disassembler/load_symbol_map.cpp4
-rw-r--r--src/core/arm/dyncom/arm_dyncom.cpp4
-rw-r--r--src/core/arm/dyncom/arm_dyncom.h4
-rw-r--r--src/core/arm/dyncom/arm_dyncom_interpreter.h2
-rw-r--r--src/core/arm/interpreter/arm_interpreter.cpp4
-rw-r--r--src/core/arm/interpreter/arm_interpreter.h4
-rw-r--r--src/core/core.cpp14
-rw-r--r--src/core/core_timing.cpp50
-rw-r--r--src/core/core_timing.h2
-rw-r--r--src/core/file_sys/archive.h2
-rw-r--r--src/core/file_sys/archive_romfs.cpp2
-rw-r--r--src/core/file_sys/archive_romfs.h4
-rw-r--r--src/core/file_sys/archive_sdmc.h2
-rw-r--r--src/core/file_sys/directory_sdmc.cpp2
-rw-r--r--src/core/hle/config_mem.cpp2
-rw-r--r--src/core/hle/coprocessor.cpp2
-rw-r--r--src/core/hle/function_wrappers.h4
-rw-r--r--src/core/hle/hle.cpp6
-rw-r--r--src/core/hle/hle.h2
-rw-r--r--src/core/hle/kernel/address_arbiter.h2
-rw-r--r--src/core/hle/kernel/archive.cpp6
-rw-r--r--src/core/hle/kernel/event.cpp4
-rw-r--r--src/core/hle/kernel/event.h2
-rw-r--r--src/core/hle/kernel/kernel.cpp6
-rw-r--r--src/core/hle/kernel/kernel.h12
-rw-r--r--src/core/hle/kernel/mutex.cpp4
-rw-r--r--src/core/hle/kernel/mutex.h2
-rw-r--r--src/core/hle/kernel/shared_memory.cpp4
-rw-r--r--src/core/hle/kernel/shared_memory.h4
-rw-r--r--src/core/hle/kernel/thread.cpp82
-rw-r--r--src/core/hle/kernel/thread.h2
-rw-r--r--src/core/hle/service/ac_u.cpp6
-rw-r--r--src/core/hle/service/ac_u.h4
-rw-r--r--src/core/hle/service/am_net.cpp47
-rw-r--r--src/core/hle/service/am_net.h27
-rw-r--r--src/core/hle/service/apt_u.cpp4
-rw-r--r--src/core/hle/service/apt_u.h4
-rw-r--r--src/core/hle/service/boss_u.cpp4
-rw-r--r--src/core/hle/service/cfg_i.cpp59
-rw-r--r--src/core/hle/service/cfg_i.h27
-rw-r--r--src/core/hle/service/cfg_u.h2
-rw-r--r--src/core/hle/service/csnd_snd.cpp39
-rw-r--r--src/core/hle/service/csnd_snd.h27
-rw-r--r--src/core/hle/service/dsp_dsp.cpp4
-rw-r--r--src/core/hle/service/dsp_dsp.h2
-rw-r--r--src/core/hle/service/err_f.cpp4
-rw-r--r--src/core/hle/service/err_f.h4
-rw-r--r--src/core/hle/service/frd_u.h2
-rw-r--r--src/core/hle/service/fs_user.cpp16
-rw-r--r--src/core/hle/service/gsp_gpu.cpp16
-rw-r--r--src/core/hle/service/hid_user.cpp4
-rw-r--r--src/core/hle/service/hid_user.h2
-rw-r--r--src/core/hle/service/ir_rst.cpp36
-rw-r--r--src/core/hle/service/ir_rst.h27
-rw-r--r--src/core/hle/service/ir_u.cpp45
-rw-r--r--src/core/hle/service/ir_u.h27
-rw-r--r--src/core/hle/service/mic_u.cpp2
-rw-r--r--src/core/hle/service/mic_u.h2
-rw-r--r--src/core/hle/service/nwm_uds.h2
-rw-r--r--src/core/hle/service/pm_app.cpp35
-rw-r--r--src/core/hle/service/pm_app.h27
-rw-r--r--src/core/hle/service/ptm_u.cpp6
-rw-r--r--src/core/hle/service/ptm_u.h2
-rw-r--r--src/core/hle/service/service.cpp14
-rw-r--r--src/core/hle/service/service.h14
-rw-r--r--src/core/hle/service/soc_u.h2
-rw-r--r--src/core/hle/service/srv.cpp8
-rw-r--r--src/core/hle/svc.cpp80
-rw-r--r--src/core/hle/svc.h2
-rw-r--r--src/core/hw/hw.cpp6
-rw-r--r--src/core/loader/elf.cpp4
-rw-r--r--src/core/loader/ncch.cpp10
-rw-r--r--src/core/loader/ncch.h2
-rw-r--r--src/core/mem_map.cpp60
-rw-r--r--src/core/mem_map.h2
-rw-r--r--src/core/mem_map_funcs.cpp18
-rw-r--r--src/core/system.h22
79 files changed, 735 insertions, 288 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 2315cc791..b3bfbca9e 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -31,18 +31,24 @@ set(SRCS
31 hle/kernel/shared_memory.cpp 31 hle/kernel/shared_memory.cpp
32 hle/kernel/thread.cpp 32 hle/kernel/thread.cpp
33 hle/service/ac_u.cpp 33 hle/service/ac_u.cpp
34 hle/service/am_net.cpp
34 hle/service/apt_u.cpp 35 hle/service/apt_u.cpp
35 hle/service/boss_u.cpp 36 hle/service/boss_u.cpp
37 hle/service/cfg_i.cpp
36 hle/service/cfg_u.cpp 38 hle/service/cfg_u.cpp
39 hle/service/csnd_snd.cpp
37 hle/service/dsp_dsp.cpp 40 hle/service/dsp_dsp.cpp
38 hle/service/err_f.cpp 41 hle/service/err_f.cpp
39 hle/service/fs_user.cpp 42 hle/service/fs_user.cpp
40 hle/service/frd_u.cpp 43 hle/service/frd_u.cpp
41 hle/service/gsp_gpu.cpp 44 hle/service/gsp_gpu.cpp
42 hle/service/hid_user.cpp 45 hle/service/hid_user.cpp
46 hle/service/ir_rst.cpp
47 hle/service/ir_u.cpp
43 hle/service/mic_u.cpp 48 hle/service/mic_u.cpp
44 hle/service/ndm_u.cpp 49 hle/service/ndm_u.cpp
45 hle/service/nwm_uds.cpp 50 hle/service/nwm_uds.cpp
51 hle/service/pm_app.cpp
46 hle/service/ptm_u.cpp 52 hle/service/ptm_u.cpp
47 hle/service/service.cpp 53 hle/service/service.cpp
48 hle/service/soc_u.cpp 54 hle/service/soc_u.cpp
@@ -103,18 +109,24 @@ set(HEADERS
103 hle/kernel/shared_memory.h 109 hle/kernel/shared_memory.h
104 hle/kernel/thread.h 110 hle/kernel/thread.h
105 hle/service/ac_u.h 111 hle/service/ac_u.h
112 hle/service/am_net.h
106 hle/service/apt_u.h 113 hle/service/apt_u.h
107 hle/service/boss_u.h 114 hle/service/boss_u.h
115 hle/service/cfg_i.h
108 hle/service/cfg_u.h 116 hle/service/cfg_u.h
117 hle/service/csnd_snd.h
109 hle/service/dsp_dsp.h 118 hle/service/dsp_dsp.h
110 hle/service/err_f.h 119 hle/service/err_f.h
111 hle/service/fs_user.h 120 hle/service/fs_user.h
112 hle/service/frd_u.h 121 hle/service/frd_u.h
113 hle/service/gsp_gpu.h 122 hle/service/gsp_gpu.h
114 hle/service/hid_user.h 123 hle/service/hid_user.h
124 hle/service/ir_rst.h
125 hle/service/ir_u.h
115 hle/service/mic_u.h 126 hle/service/mic_u.h
116 hle/service/ndm_u.h 127 hle/service/ndm_u.h
117 hle/service/nwm_uds.h 128 hle/service/nwm_uds.h
129 hle/service/pm_app.h
118 hle/service/ptm_u.h 130 hle/service/ptm_u.h
119 hle/service/service.h 131 hle/service/service.h
120 hle/service/soc_u.h 132 hle/service/soc_u.h
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index 4b93d3313..3ae528562 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
@@ -63,7 +63,7 @@ public:
63 * Get the current CPSR register 63 * Get the current CPSR register
64 * @return Returns the value of the CPSR register 64 * @return Returns the value of the CPSR register
65 */ 65 */
66 virtual u32 GetCPSR() const = 0; 66 virtual u32 GetCPSR() const = 0;
67 67
68 /** 68 /**
69 * Set the current CPSR register 69 * Set the current CPSR register
@@ -98,7 +98,7 @@ public:
98 } 98 }
99 99
100protected: 100protected:
101 101
102 /** 102 /**
103 * Executes the given number of instructions 103 * Executes the given number of instructions
104 * @param num_instructions Number of instructions to executes 104 * @param num_instructions Number of instructions to executes
diff --git a/src/core/arm/disassembler/load_symbol_map.cpp b/src/core/arm/disassembler/load_symbol_map.cpp
index 0f384ad3e..55278474b 100644
--- a/src/core/arm/disassembler/load_symbol_map.cpp
+++ b/src/core/arm/disassembler/load_symbol_map.cpp
@@ -22,8 +22,8 @@ void LoadSymbolMap(std::string filename) {
22 22
23 while (std::getline(infile, line)) { 23 while (std::getline(infile, line)) {
24 std::istringstream iss(line); 24 std::istringstream iss(line);
25 if (!(iss >> address_str >> size >> function_name)) { 25 if (!(iss >> address_str >> size >> function_name)) {
26 break; // Error parsing 26 break; // Error parsing
27 } 27 }
28 u32 address = std::stoul(address_str, nullptr, 16); 28 u32 address = std::stoul(address_str, nullptr, 16);
29 29
diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp
index a3ed3e31e..6c8ea211e 100644
--- a/src/core/arm/dyncom/arm_dyncom.cpp
+++ b/src/core/arm/dyncom/arm_dyncom.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "core/arm/skyeye_common/armcpu.h" 5#include "core/arm/skyeye_common/armcpu.h"
6#include "core/arm/skyeye_common/armemu.h" 6#include "core/arm/skyeye_common/armemu.h"
@@ -113,7 +113,7 @@ void ARM_DynCom::ExecuteInstructions(int num_instructions) {
113 state->NumInstrsToExecute = num_instructions; 113 state->NumInstrsToExecute = num_instructions;
114 114
115 // Dyncom only breaks on instruction dispatch. This only happens on every instruction when 115 // Dyncom only breaks on instruction dispatch. This only happens on every instruction when
116 // executing one instruction at a time. Otherwise, if a block is being executed, more 116 // executing one instruction at a time. Otherwise, if a block is being executed, more
117 // instructions may actually be executed than specified. 117 // instructions may actually be executed than specified.
118 ticks += InterpreterMainLoop(state.get()); 118 ticks += InterpreterMainLoop(state.get());
119} 119}
diff --git a/src/core/arm/dyncom/arm_dyncom.h b/src/core/arm/dyncom/arm_dyncom.h
index 1f8cd3a3a..51eea41ed 100644
--- a/src/core/arm/dyncom/arm_dyncom.h
+++ b/src/core/arm/dyncom/arm_dyncom.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
@@ -19,7 +19,7 @@ public:
19 19
20 /** 20 /**
21 * Set the Program Counter to an address 21 * Set the Program Counter to an address
22 * @param addr Address to set PC to 22 * @param pc Address to set PC to
23 */ 23 */
24 void SetPC(u32 pc) override; 24 void SetPC(u32 pc) override;
25 25
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.h b/src/core/arm/dyncom/arm_dyncom_interpreter.h
index c65eb23f7..3a2462f55 100644
--- a/src/core/arm/dyncom/arm_dyncom_interpreter.h
+++ b/src/core/arm/dyncom/arm_dyncom_interpreter.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
diff --git a/src/core/arm/interpreter/arm_interpreter.cpp b/src/core/arm/interpreter/arm_interpreter.cpp
index ed4415082..e2aa5ce92 100644
--- a/src/core/arm/interpreter/arm_interpreter.cpp
+++ b/src/core/arm/interpreter/arm_interpreter.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "core/arm/interpreter/arm_interpreter.h" 5#include "core/arm/interpreter/arm_interpreter.h"
6 6
@@ -24,7 +24,7 @@ ARM_Interpreter::ARM_Interpreter() {
24 state->lateabtSig = LOW; 24 state->lateabtSig = LOW;
25 25
26 // Reset the core to initial state 26 // Reset the core to initial state
27 ARMul_CoProInit(state); 27 ARMul_CoProInit(state);
28 ARMul_Reset(state); 28 ARMul_Reset(state);
29 state->NextInstr = RESUME; // NOTE: This will be overwritten by LoadContext 29 state->NextInstr = RESUME; // NOTE: This will be overwritten by LoadContext
30 state->Emulate = 3; 30 state->Emulate = 3;
diff --git a/src/core/arm/interpreter/arm_interpreter.h b/src/core/arm/interpreter/arm_interpreter.h
index ceb1be438..ed53d997c 100644
--- a/src/core/arm/interpreter/arm_interpreter.h
+++ b/src/core/arm/interpreter/arm_interpreter.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
@@ -18,7 +18,7 @@ public:
18 18
19 /** 19 /**
20 * Set the Program Counter to an address 20 * Set the Program Counter to an address
21 * @param addr Address to set PC to 21 * @param pc Address to set PC to
22 */ 22 */
23 void SetPC(u32 pc) override; 23 void SetPC(u32 pc) override;
24 24
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/core_timing.cpp b/src/core/core_timing.cpp
index 0116cb376..558c6cbf7 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -41,7 +41,7 @@ struct BaseEvent
41 s64 time; 41 s64 time;
42 u64 userdata; 42 u64 userdata;
43 int type; 43 int type;
44 // Event *next; 44 // Event *next;
45}; 45};
46 46
47typedef LinkedListItem<BaseEvent> Event; 47typedef LinkedListItem<BaseEvent> Event;
@@ -249,7 +249,7 @@ void AddEventToQueue(Event* ne)
249 249
250// This must be run ONLY from within the cpu thread 250// This must be run ONLY from within the cpu thread
251// cyclesIntoFuture may be VERY inaccurate if called from anything else 251// cyclesIntoFuture may be VERY inaccurate if called from anything else
252// than Advance 252// than Advance
253void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata) 253void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata)
254{ 254{
255 Event *ne = GetNewEvent(); 255 Event *ne = GetNewEvent();
@@ -469,8 +469,8 @@ void ProcessFifoWaitEvents()
469 { 469 {
470 if (first->time <= globalTimer) 470 if (first->time <= globalTimer)
471 { 471 {
472 // LOG(TIMER, "[Scheduler] %s (%lld, %lld) ", 472 //LOG(TIMER, "[Scheduler] %s (%lld, %lld) ",
473 // first->name ? first->name : "?", (u64)globalTimer, (u64)first->time); 473 // first->name ? first->name : "?", (u64)globalTimer, (u64)first->time);
474 Event* evt = first; 474 Event* evt = first;
475 first = first->next; 475 first = first->next;
476 event_types[evt->type].callback(evt->userdata, (int)(globalTimer - evt->time)); 476 event_types[evt->type].callback(evt->userdata, (int)(globalTimer - evt->time));
@@ -516,23 +516,23 @@ void Advance()
516 //currentMIPS->downcount = slicelength; 516 //currentMIPS->downcount = slicelength;
517 517
518 //if (Common::AtomicLoadAcquire(hasTsEvents)) 518 //if (Common::AtomicLoadAcquire(hasTsEvents))
519 // MoveEvents(); 519 // MoveEvents();
520 //ProcessFifoWaitEvents(); 520 //ProcessFifoWaitEvents();
521 521
522 //if (!first) 522 //if (!first)
523 //{ 523 //{
524 // // WARN_LOG(TIMER, "WARNING - no events in queue. Setting currentMIPS->downcount to 10000"); 524 // // WARN_LOG(TIMER, "WARNING - no events in queue. Setting currentMIPS->downcount to 10000");
525 // currentMIPS->downcount += 10000; 525 // currentMIPS->downcount += 10000;
526 //} 526 //}
527 //else 527 //else
528 //{ 528 //{
529 // slicelength = (int)(first->time - globalTimer); 529 // slicelength = (int)(first->time - globalTimer);
530 // if (slicelength > MAX_SLICE_LENGTH) 530 // if (slicelength > MAX_SLICE_LENGTH)
531 // slicelength = MAX_SLICE_LENGTH; 531 // slicelength = MAX_SLICE_LENGTH;
532 // currentMIPS->downcount = slicelength; 532 // currentMIPS->downcount = slicelength;
533 //} 533 //}
534 //if (advanceCallback) 534 //if (advanceCallback)
535 // advanceCallback(cyclesExecuted); 535 // advanceCallback(cyclesExecuted);
536} 536}
537 537
538void LogPendingEvents() 538void LogPendingEvents()
@@ -550,20 +550,20 @@ void Idle(int maxIdle)
550 ERROR_LOG(TIME, "Unimplemented function!"); 550 ERROR_LOG(TIME, "Unimplemented function!");
551 //int cyclesDown = currentMIPS->downcount; 551 //int cyclesDown = currentMIPS->downcount;
552 //if (maxIdle != 0 && cyclesDown > maxIdle) 552 //if (maxIdle != 0 && cyclesDown > maxIdle)
553 // cyclesDown = maxIdle; 553 // cyclesDown = maxIdle;
554 554
555 //if (first && cyclesDown > 0) 555 //if (first && cyclesDown > 0)
556 //{ 556 //{
557 // int cyclesExecuted = slicelength - currentMIPS->downcount; 557 // int cyclesExecuted = slicelength - currentMIPS->downcount;
558 // int cyclesNextEvent = (int) (first->time - globalTimer); 558 // int cyclesNextEvent = (int) (first->time - globalTimer);
559 559
560 // if (cyclesNextEvent < cyclesExecuted + cyclesDown) 560 // if (cyclesNextEvent < cyclesExecuted + cyclesDown)
561 // { 561 // {
562 // cyclesDown = cyclesNextEvent - cyclesExecuted; 562 // cyclesDown = cyclesNextEvent - cyclesExecuted;
563 // // Now, now... no time machines, please. 563 // // Now, now... no time machines, please.
564 // if (cyclesDown < 0) 564 // if (cyclesDown < 0)
565 // cyclesDown = 0; 565 // cyclesDown = 0;
566 // } 566 // }
567 //} 567 //}
568 568
569 //INFO_LOG(TIME, "Idle for %i cycles! (%f ms)", cyclesDown, cyclesDown / (float)(g_clock_rate_arm11 * 0.001f)); 569 //INFO_LOG(TIME, "Idle for %i cycles! (%f ms)", cyclesDown, cyclesDown / (float)(g_clock_rate_arm11 * 0.001f));
@@ -571,7 +571,7 @@ void Idle(int maxIdle)
571 //idledCycles += cyclesDown; 571 //idledCycles += cyclesDown;
572 //currentMIPS->downcount -= cyclesDown; 572 //currentMIPS->downcount -= cyclesDown;
573 //if (currentMIPS->downcount == 0) 573 //if (currentMIPS->downcount == 0)
574 // currentMIPS->downcount = -1; 574 // currentMIPS->downcount = -1;
575} 575}
576 576
577std::string GetScheduledEventsSummary() 577std::string GetScheduledEventsSummary()
@@ -623,4 +623,4 @@ void DoState(PointerWrap &p)
623 p.Do(idledCycles); 623 p.Do(idledCycles);
624} 624}
625 625
626} // namespace 626} // namespace
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index 09fdf7a90..b197cf40c 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -106,4 +106,4 @@ void SetClockFrequencyMHz(int cpuMhz);
106int GetClockFrequencyMHz(); 106int GetClockFrequencyMHz();
107extern int slicelength; 107extern int slicelength;
108 108
109}; // namespace 109} // namespace
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h
index 4cf47f30a..2e79bb883 100644
--- a/src/core/file_sys/archive.h
+++ b/src/core/file_sys/archive.h
@@ -236,7 +236,7 @@ public:
236 * @return Size of the archive in bytes 236 * @return Size of the archive in bytes
237 */ 237 */
238 virtual size_t GetSize() const = 0; 238 virtual size_t GetSize() const = 0;
239 239
240 /** 240 /**
241 * Set the size of the archive in bytes 241 * Set the size of the archive in bytes
242 */ 242 */
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index 05fc1f87f..53dc57954 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -61,7 +61,7 @@ bool Archive_RomFS::DeleteDirectory(const FileSys::Path& path) const {
61bool Archive_RomFS::CreateDirectory(const Path& path) const { 61bool Archive_RomFS::CreateDirectory(const Path& path) const {
62 ERROR_LOG(FILESYS, "Attempted to create a directory in ROMFS."); 62 ERROR_LOG(FILESYS, "Attempted to create a directory in ROMFS.");
63 return false; 63 return false;
64}; 64}
65 65
66/** 66/**
67 * Open a directory specified by its path 67 * Open a directory specified by its path
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h
index aa6446c51..0649dde99 100644
--- a/src/core/file_sys/archive_romfs.h
+++ b/src/core/file_sys/archive_romfs.h
@@ -26,7 +26,7 @@ public:
26 * Get the IdCode of the archive (e.g. RomFS, SaveData, etc.) 26 * Get the IdCode of the archive (e.g. RomFS, SaveData, etc.)
27 * @return IdCode of the archive 27 * @return IdCode of the archive
28 */ 28 */
29 IdCode GetIdCode() const override { return IdCode::RomFS; }; 29 IdCode GetIdCode() const override { return IdCode::RomFS; }
30 30
31 /** 31 /**
32 * Open a file specified by its path, using the specified mode 32 * Open a file specified by its path, using the specified mode
@@ -88,7 +88,7 @@ public:
88 * @return Size of the archive in bytes 88 * @return Size of the archive in bytes
89 */ 89 */
90 size_t GetSize() const override; 90 size_t GetSize() const override;
91 91
92 /** 92 /**
93 * Set the size of the archive in bytes 93 * Set the size of the archive in bytes
94 */ 94 */
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h
index 8ac06484c..74ce29c0d 100644
--- a/src/core/file_sys/archive_sdmc.h
+++ b/src/core/file_sys/archive_sdmc.h
@@ -30,7 +30,7 @@ public:
30 * Get the IdCode of the archive (e.g. RomFS, SaveData, etc.) 30 * Get the IdCode of the archive (e.g. RomFS, SaveData, etc.)
31 * @return IdCode of the archive 31 * @return IdCode of the archive
32 */ 32 */
33 IdCode GetIdCode() const override { return IdCode::SDMC; }; 33 IdCode GetIdCode() const override { return IdCode::SDMC; }
34 34
35 /** 35 /**
36 * Open a file specified by its path, using the specified mode 36 * Open a file specified by its path, using the specified mode
diff --git a/src/core/file_sys/directory_sdmc.cpp b/src/core/file_sys/directory_sdmc.cpp
index 923ca6862..60a197ce9 100644
--- a/src/core/file_sys/directory_sdmc.cpp
+++ b/src/core/file_sys/directory_sdmc.cpp
@@ -45,7 +45,7 @@ u32 Directory_SDMC::Read(const u32 count, Entry* entries) {
45 WARN_LOG(FILESYS, "File %s: size=%llu dir=%d", filename.c_str(), file.size, file.isDirectory); 45 WARN_LOG(FILESYS, "File %s: size=%llu dir=%d", filename.c_str(), file.size, file.isDirectory);
46 46
47 // TODO(Link Mauve): use a proper conversion to UTF-16. 47 // TODO(Link Mauve): use a proper conversion to UTF-16.
48 for (int j = 0; j < FILENAME_LENGTH; ++j) { 48 for (size_t j = 0; j < FILENAME_LENGTH; ++j) {
49 entry.filename[j] = filename[j]; 49 entry.filename[j] = filename[j];
50 if (!filename[j]) 50 if (!filename[j])
51 break; 51 break;
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp
index a45e61427..c7cf5b1d3 100644
--- a/src/core/hle/config_mem.cpp
+++ b/src/core/hle/config_mem.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common_types.h" 5#include "common/common_types.h"
6 6
diff --git a/src/core/hle/coprocessor.cpp b/src/core/hle/coprocessor.cpp
index 1eb33eb86..e34229a57 100644
--- a/src/core/hle/coprocessor.cpp
+++ b/src/core/hle/coprocessor.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "core/hle/coprocessor.h" 5#include "core/hle/coprocessor.h"
6#include "core/hle/hle.h" 6#include "core/hle/hle.h"
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h
index 55eaf0621..3dbe25037 100644
--- a/src/core/hle/function_wrappers.h
+++ b/src/core/hle/function_wrappers.h
@@ -50,7 +50,7 @@ template<s32 func(u32*, u32, u32, u32, u32, u32)> void Wrap(){
50 50
51template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() { 51template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() {
52 s32 param_1 = 0; 52 s32 param_1 = 0;
53 s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), 53 s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
54 (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))); 54 (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)));
55 Core::g_app_core->SetReg(1, (u32)param_1); 55 Core::g_app_core->SetReg(1, (u32)param_1);
56 FuncReturn(retval); 56 FuncReturn(retval);
@@ -103,7 +103,7 @@ template<s32 func(void*)> void Wrap() {
103} 103}
104 104
105template<s32 func(s64*, u32, void*, s32)> void Wrap(){ 105template<s32 func(s64*, u32, void*, s32)> void Wrap(){
106 FuncReturn(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)), 106 FuncReturn(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)),
107 (s32)PARAM(3))); 107 (s32)PARAM(3)));
108} 108}
109 109
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp
index b03894ad7..b8ac186f6 100644
--- a/src/core/hle/hle.cpp
+++ b/src/core/hle/hle.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <vector> 5#include <vector>
6 6
@@ -20,7 +20,7 @@ bool g_reschedule = false; ///< If true, immediately reschedules the CPU to a n
20const FunctionDef* GetSVCInfo(u32 opcode) { 20const FunctionDef* GetSVCInfo(u32 opcode) {
21 u32 func_num = opcode & 0xFFFFFF; // 8 bits 21 u32 func_num = opcode & 0xFFFFFF; // 8 bits
22 if (func_num > 0xFF) { 22 if (func_num > 0xFF) {
23 ERROR_LOG(HLE,"unknown svc=0x%02X", func_num); 23 ERROR_LOG(HLE,"unknown svc=0x%02X", func_num);
24 return nullptr; 24 return nullptr;
25 } 25 }
26 return &g_module_db[0].func_table[func_num]; 26 return &g_module_db[0].func_table[func_num];
@@ -58,7 +58,7 @@ void RegisterAllModules() {
58 58
59void Init() { 59void Init() {
60 Service::Init(); 60 Service::Init();
61 61
62 RegisterAllModules(); 62 RegisterAllModules();
63 63
64 NOTICE_LOG(HLE, "initialized OK"); 64 NOTICE_LOG(HLE, "initialized OK");
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h
index bf4d84575..4ab258c69 100644
--- a/src/core/hle/hle.h
+++ b/src/core/hle/hle.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
diff --git a/src/core/hle/kernel/address_arbiter.h b/src/core/hle/kernel/address_arbiter.h
index a483fe466..6886e479d 100644
--- a/src/core/hle/kernel/address_arbiter.h
+++ b/src/core/hle/kernel/address_arbiter.h
@@ -11,7 +11,7 @@
11// Address arbiters are an underlying kernel synchronization object that can be created/used via 11// Address arbiters are an underlying kernel synchronization object that can be created/used via
12// supervisor calls (SVCs). They function as sort of a global lock. Typically, games/other CTR 12// supervisor calls (SVCs). They function as sort of a global lock. Typically, games/other CTR
13// applications use them as an underlying mechanism to implement thread-safe barriers, events, and 13// applications use them as an underlying mechanism to implement thread-safe barriers, events, and
14// semphores. 14// semphores.
15 15
16//////////////////////////////////////////////////////////////////////////////////////////////////// 16////////////////////////////////////////////////////////////////////////////////////////////////////
17// Kernel namespace 17// Kernel namespace
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp
index 85defeb7a..900f484c7 100644
--- a/src/core/hle/kernel/archive.cpp
+++ b/src/core/hle/kernel/archive.cpp
@@ -52,14 +52,14 @@ public:
52 FileSys::Archive* backend; ///< Archive backend interface 52 FileSys::Archive* backend; ///< Archive backend interface
53 53
54 /** 54 /**
55 * Synchronize kernel object 55 * Synchronize kernel object
56 * @param wait Boolean wait set if current thread should wait as a result of sync operation 56 * @param wait Boolean wait set if current thread should wait as a result of sync operation
57 * @return Result of operation, 0 on success, otherwise error code 57 * @return Result of operation, 0 on success, otherwise error code
58 */ 58 */
59 Result SyncRequest(bool* wait) override { 59 Result SyncRequest(bool* wait) override {
60 u32* cmd_buff = Service::GetCommandBuffer(); 60 u32* cmd_buff = Service::GetCommandBuffer();
61 FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); 61 FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
62 62
63 switch (cmd) { 63 switch (cmd) {
64 // Read from archive... 64 // Read from archive...
65 case FileCommand::Read: 65 case FileCommand::Read:
@@ -343,7 +343,7 @@ Archive* CreateArchive(Handle& handle, FileSys::Archive* backend, const std::str
343 archive->backend = backend; 343 archive->backend = backend;
344 344
345 MountArchive(archive); 345 MountArchive(archive);
346 346
347 return archive; 347 return archive;
348} 348}
349 349
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp
index 45ed79be8..e0117c0bc 100644
--- a/src/core/hle/kernel/event.cpp
+++ b/src/core/hle/kernel/event.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <map> 5#include <map>
6#include <algorithm> 6#include <algorithm>
@@ -95,7 +95,7 @@ Result SignalEvent(const Handle handle) {
95 for (size_t i = 0; i < evt->waiting_threads.size(); ++i) { 95 for (size_t i = 0; i < evt->waiting_threads.size(); ++i) {
96 ResumeThreadFromWait( evt->waiting_threads[i]); 96 ResumeThreadFromWait( evt->waiting_threads[i]);
97 97
98 // If any thread is signalled awake by this event, assume the event was "caught" and reset 98 // If any thread is signalled awake by this event, assume the event was "caught" and reset
99 // the event. This will result in the next thread waiting on the event to block. Otherwise, 99 // the event. This will result in the next thread waiting on the event to block. Otherwise,
100 // the event will not be reset, and the next thread to call WaitSynchronization on it will 100 // the event will not be reset, and the next thread to call WaitSynchronization on it will
101 // not block. Not sure if this is correct behavior, but it seems to work. 101 // not block. Not sure if this is correct behavior, but it seems to work.
diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h
index c39b33180..6add72897 100644
--- a/src/core/hle/kernel/event.h
+++ b/src/core/hle/kernel/event.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 88cbc1af5..018000abd 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project / PPSSPP Project 1// Copyright 2014 Citra Emulator Project / PPSSPP Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/common.h"
6 6
@@ -68,7 +68,7 @@ void ObjectPool::List() {
68 for (int i = 0; i < MAX_COUNT; i++) { 68 for (int i = 0; i < MAX_COUNT; i++) {
69 if (occupied[i]) { 69 if (occupied[i]) {
70 if (pool[i]) { 70 if (pool[i]) {
71 INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(), 71 INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(),
72 pool[i]->GetName().c_str()); 72 pool[i]->GetName().c_str());
73 } 73 }
74 } 74 }
@@ -110,7 +110,7 @@ void Shutdown() {
110 */ 110 */
111bool LoadExec(u32 entry_point) { 111bool LoadExec(u32 entry_point) {
112 Init(); 112 Init();
113 113
114 Core::g_app_core->SetPC(entry_point); 114 Core::g_app_core->SetPC(entry_point);
115 115
116 // 0x30 is the typical main thread priority I've seen used so far 116 // 0x30 is the typical main thread priority I've seen used so far
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 867d1b89c..e0c94f186 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project / PPSSPP Project 1// Copyright 2014 Citra Emulator Project / PPSSPP Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
@@ -34,7 +34,7 @@ enum class HandleType : u32 {
34 Archive = 12, 34 Archive = 12,
35 Directory = 13, 35 Directory = 13,
36}; 36};
37 37
38enum { 38enum {
39 DEFAULT_STACK_SIZE = 0x4000, 39 DEFAULT_STACK_SIZE = 0x4000,
40}; 40};
@@ -52,7 +52,7 @@ public:
52 virtual Kernel::HandleType GetHandleType() const = 0; 52 virtual Kernel::HandleType GetHandleType() const = 0;
53 53
54 /** 54 /**
55 * Synchronize kernel object 55 * Synchronize kernel object
56 * @param wait Boolean wait set if current thread should wait as a result of sync operation 56 * @param wait Boolean wait set if current thread should wait as a result of sync operation
57 * @return Result of operation, 0 on success, otherwise error code 57 * @return Result of operation, 0 on success, otherwise error code
58 */ 58 */
@@ -87,7 +87,7 @@ public:
87 delete pool[handle - HANDLE_OFFSET]; 87 delete pool[handle - HANDLE_OFFSET];
88 } 88 }
89 return error; 89 return error;
90 }; 90 }
91 91
92 bool IsValid(Handle handle); 92 bool IsValid(Handle handle);
93 93
@@ -139,7 +139,7 @@ public:
139 } 139 }
140 140
141 bool GetIDType(Handle handle, HandleType* type) const { 141 bool GetIDType(Handle handle, HandleType* type) const {
142 if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) || 142 if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) ||
143 !occupied[handle - HANDLE_OFFSET]) { 143 !occupied[handle - HANDLE_OFFSET]) {
144 ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); 144 ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle);
145 return false; 145 return false;
@@ -155,7 +155,7 @@ public:
155 int GetCount(); 155 int GetCount();
156 156
157private: 157private:
158 158
159 enum { 159 enum {
160 MAX_COUNT = 0x1000, 160 MAX_COUNT = 0x1000,
161 HANDLE_OFFSET = 0x100, 161 HANDLE_OFFSET = 0x100,
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index fcfd061ac..31129fd86 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <map> 5#include <map>
6#include <vector> 6#include <vector>
@@ -28,7 +28,7 @@ public:
28 std::string name; ///< Name of mutex (optional) 28 std::string name; ///< Name of mutex (optional)
29 29
30 /** 30 /**
31 * Synchronize kernel object 31 * Synchronize kernel object
32 * @param wait Boolean wait set if current thread should wait as a result of sync operation 32 * @param wait Boolean wait set if current thread should wait as a result of sync operation
33 * @return Result of operation, 0 on success, otherwise error code 33 * @return Result of operation, 0 on success, otherwise error code
34 */ 34 */
diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h
index 7d7b5137e..313ba6fee 100644
--- a/src/core/hle/kernel/mutex.h
+++ b/src/core/hle/kernel/mutex.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index f538c6550..7ef3e54cc 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/common.h"
6 6
@@ -67,7 +67,7 @@ Handle CreateSharedMemory(const std::string& name) {
67 * @param other_permissions Memory block map other permissions (specified by SVC field) 67 * @param other_permissions Memory block map other permissions (specified by SVC field)
68 * @return Result of operation, 0 on success, otherwise error code 68 * @return Result of operation, 0 on success, otherwise error code
69 */ 69 */
70Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions, 70Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions,
71 MemoryPermission other_permissions) { 71 MemoryPermission other_permissions) {
72 72
73 if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) { 73 if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) {
diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h
index 5312b8854..0aec03538 100644
--- a/src/core/hle/kernel/shared_memory.h
+++ b/src/core/hle/kernel/shared_memory.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
@@ -34,7 +34,7 @@ Handle CreateSharedMemory(const std::string& name="Unknown");
34 * @param other_permissions Memory block map other permissions (specified by SVC field) 34 * @param other_permissions Memory block map other permissions (specified by SVC field)
35 * @return Result of operation, 0 on success, otherwise error code 35 * @return Result of operation, 0 on success, otherwise error code
36 */ 36 */
37Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions, 37Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions,
38 MemoryPermission other_permissions); 38 MemoryPermission other_permissions);
39 39
40/** 40/**
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index e15590c49..cc70cbca7 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project / PPSSPP Project 1// Copyright 2014 Citra Emulator Project / PPSSPP Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <list> 6#include <list>
@@ -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
@@ -113,7 +113,7 @@ void ResetThread(Thread* t, u32 arg, s32 lowest_priority) {
113 t->context.pc = t->context.reg_15 = t->entry_point; 113 t->context.pc = t->context.reg_15 = t->entry_point;
114 t->context.sp = t->stack_top; 114 t->context.sp = t->stack_top;
115 t->context.cpsr = 0x1F; // Usermode 115 t->context.cpsr = 0x1F; // Usermode
116 116
117 // TODO(bunnei): This instructs the CPU core to start the execution as if it is "resuming" a 117 // TODO(bunnei): This instructs the CPU core to start the execution as if it is "resuming" a
118 // thread. This is somewhat Sky-Eye specific, and should be re-architected in the future to be 118 // thread. This is somewhat Sky-Eye specific, and should be re-architected in the future to be
119 // agnostic of the CPU core. 119 // agnostic of the CPU core.
@@ -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 }
@@ -148,7 +148,7 @@ inline bool VerifyWait(const Handle& handle, WaitType type, Handle wait_handle)
148 Thread* thread = g_object_pool.GetFast<Thread>(handle); 148 Thread* thread = g_object_pool.GetFast<Thread>(handle);
149 _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!"); 149 _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!");
150 150
151 if (type != thread->wait_type || wait_handle != thread->wait_handle) 151 if (type != thread->wait_type || wait_handle != thread->wait_handle)
152 return false; 152 return false;
153 153
154 return true; 154 return true;
@@ -158,7 +158,7 @@ inline bool VerifyWait(const Handle& handle, WaitType type, Handle wait_handle)
158void StopThread(Handle handle, const char* reason) { 158void StopThread(Handle handle, const char* reason) {
159 Thread* thread = g_object_pool.GetFast<Thread>(handle); 159 Thread* thread = g_object_pool.GetFast<Thread>(handle);
160 _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!"); 160 _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!");
161 161
162 ChangeReadyState(thread, false); 162 ChangeReadyState(thread, false);
163 thread->status = THREADSTATUS_DORMANT; 163 thread->status = THREADSTATUS_DORMANT;
164 for (size_t i = 0; i < thread->waiting_threads.size(); ++i) { 164 for (size_t i = 0; i < thread->waiting_threads.size(); ++i) {
@@ -181,7 +181,7 @@ void ChangeThreadState(Thread* t, ThreadStatus new_status) {
181 } 181 }
182 ChangeReadyState(t, (new_status & THREADSTATUS_READY) != 0); 182 ChangeReadyState(t, (new_status & THREADSTATUS_READY) != 0);
183 t->status = new_status; 183 t->status = new_status;
184 184
185 if (new_status == THREADSTATUS_WAIT) { 185 if (new_status == THREADSTATUS_WAIT) {
186 if (t->wait_type == WAITTYPE_NONE) { 186 if (t->wait_type == WAITTYPE_NONE) {
187 ERROR_LOG(KERNEL, "Waittype none not allowed"); 187 ERROR_LOG(KERNEL, "Waittype none not allowed");
@@ -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))
@@ -216,9 +216,9 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) {
216 216
217/// Arbitrate all threads currently waiting 217/// Arbitrate all threads currently waiting
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))
@@ -238,11 +238,11 @@ void CallThread(Thread* t) {
238/// Switches CPU context to that of the specified thread 238/// Switches CPU context to that of the specified thread
239void SwitchContext(Thread* t) { 239void SwitchContext(Thread* t) {
240 Thread* cur = GetCurrentThread(); 240 Thread* cur = GetCurrentThread();
241 241
242 // Save context for current thread 242 // Save context for current thread
243 if (cur) { 243 if (cur) {
244 SaveContext(cur->context); 244 SaveContext(cur->context);
245 245
246 if (cur->IsRunning()) { 246 if (cur->IsRunning()) {
247 ChangeReadyState(cur, true); 247 ChangeReadyState(cur, true);
248 } 248 }
@@ -263,11 +263,11 @@ void SwitchContext(Thread* t) {
263Thread* NextThread() { 263Thread* NextThread() {
264 Handle next; 264 Handle next;
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 }
@@ -319,15 +319,15 @@ void DebugThreadQueue() {
319Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 priority, 319Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 priority,
320 s32 processor_id, u32 stack_top, int stack_size) { 320 s32 processor_id, u32 stack_top, int stack_size) {
321 321
322 _assert_msg_(KERNEL, (priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST), 322 _assert_msg_(KERNEL, (priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST),
323 "CreateThread priority=%d, outside of allowable range!", priority) 323 "CreateThread priority=%d, outside of allowable range!", priority)
324 324
325 Thread* thread = new Thread; 325 Thread* thread = new Thread;
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;
@@ -351,7 +351,7 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3
351 return -1; 351 return -1;
352 } 352 }
353 if ((u32)stack_size < 0x200) { 353 if ((u32)stack_size < 0x200) {
354 ERROR_LOG(KERNEL, "CreateThread(name=%s): invalid stack_size=0x%08X", name, 354 ERROR_LOG(KERNEL, "CreateThread(name=%s): invalid stack_size=0x%08X", name,
355 stack_size); 355 stack_size);
356 return -1; 356 return -1;
357 } 357 }
@@ -368,7 +368,7 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3
368 return -1; 368 return -1;
369 } 369 }
370 Handle handle; 370 Handle handle;
371 Thread* thread = CreateThread(handle, name, entry_point, priority, processor_id, stack_top, 371 Thread* thread = CreateThread(handle, name, entry_point, priority, processor_id, stack_top,
372 stack_size); 372 stack_size);
373 373
374 ResetThread(thread, arg, 0); 374 ResetThread(thread, arg, 0);
@@ -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;
@@ -423,19 +423,19 @@ Result SetThreadPriority(Handle handle, s32 priority) {
423/// Sets up the primary application thread 423/// Sets up the primary application thread
424Handle SetupMainThread(s32 priority, int stack_size) { 424Handle SetupMainThread(s32 priority, int stack_size) {
425 Handle handle; 425 Handle handle;
426 426
427 // Initialize new "main" thread 427 // Initialize new "main" thread
428 Thread* thread = CreateThread(handle, "main", Core::g_app_core->GetPC(), priority, 428 Thread* thread = CreateThread(handle, "main", Core::g_app_core->GetPC(), priority,
429 THREADPROCESSORID_0, Memory::SCRATCHPAD_VADDR_END, stack_size); 429 THREADPROCESSORID_0, Memory::SCRATCHPAD_VADDR_END, stack_size);
430 430
431 ResetThread(thread, 0, 0); 431 ResetThread(thread, 0, 0);
432 432
433 // If running another thread already, set it to "ready" state 433 // If running another thread already, set it to "ready" state
434 Thread* cur = GetCurrentThread(); 434 Thread* cur = GetCurrentThread();
435 if (cur && cur->IsRunning()) { 435 if (cur && cur->IsRunning()) {
436 ChangeReadyState(cur, true); 436 ChangeReadyState(cur, true);
437 } 437 }
438 438
439 // Run new "main" thread 439 // Run new "main" thread
440 SetCurrentThread(thread); 440 SetCurrentThread(thread);
441 thread->status = THREADSTATUS_RUNNING; 441 thread->status = THREADSTATUS_RUNNING;
@@ -452,12 +452,12 @@ void Reschedule() {
452 HLE::g_reschedule = false; 452 HLE::g_reschedule = false;
453 if (next > 0) { 453 if (next > 0) {
454 INFO_LOG(KERNEL, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle()); 454 INFO_LOG(KERNEL, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle());
455 455
456 SwitchContext(next); 456 SwitchContext(next);
457 457
458 // Hack - There is no mechanism yet to waken the primary thread if it has been put to sleep 458 // Hack - There is no mechanism yet to waken the primary thread if it has been put to sleep
459 // by a simulated VBLANK thread switch. So, we'll just immediately set it to "ready" again. 459 // by a simulated VBLANK thread switch. So, we'll just immediately set it to "ready" again.
460 // This results in the current thread yielding on a VBLANK once, and then it will be 460 // This results in the current thread yielding on a VBLANK once, and then it will be
461 // immediately placed back in the queue for execution. 461 // immediately placed back in the queue for execution.
462 if (prev->wait_type == WAITTYPE_VBLANK) { 462 if (prev->wait_type == WAITTYPE_VBLANK) {
463 ResumeThreadFromWait(prev->GetHandle()); 463 ResumeThreadFromWait(prev->GetHandle());
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index 39fa38b75..2a43797ee 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project / PPSSPP Project 1// Copyright 2014 Citra Emulator Project / PPSSPP Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cpp
index b39603bdf..9af96f6b8 100644
--- a/src/core/hle/service/ac_u.cpp
+++ b/src/core/hle/service/ac_u.cpp
@@ -22,12 +22,12 @@ const Interface::FunctionInfo FunctionTable[] = {
22 {0x000E0042, nullptr, "GetCurrentAPInfo"}, 22 {0x000E0042, nullptr, "GetCurrentAPInfo"},
23 {0x00100042, nullptr, "GetCurrentNZoneInfo"}, 23 {0x00100042, nullptr, "GetCurrentNZoneInfo"},
24 {0x00110042, nullptr, "GetNZoneApNumService"}, 24 {0x00110042, nullptr, "GetNZoneApNumService"},
25 {0x00240042, nullptr, "AddDenyApType "}, 25 {0x00240042, nullptr, "AddDenyApType"},
26 {0x00270002, nullptr, "GetInfraPriority "}, 26 {0x00270002, nullptr, "GetInfraPriority"},
27 {0x002D0082, nullptr, "SetRequestEulaVersion"}, 27 {0x002D0082, nullptr, "SetRequestEulaVersion"},
28 {0x00300004, nullptr, "RegisterDisconnectEvent"}, 28 {0x00300004, nullptr, "RegisterDisconnectEvent"},
29 {0x003C0042, nullptr, "GetAPSSIDList"}, 29 {0x003C0042, nullptr, "GetAPSSIDList"},
30 {0x003E0042, nullptr, "IsConnected "}, 30 {0x003E0042, nullptr, "IsConnected"},
31 {0x00400042, nullptr, "SetClientVersion"}, 31 {0x00400042, nullptr, "SetClientVersion"},
32}; 32};
33 33
diff --git a/src/core/hle/service/ac_u.h b/src/core/hle/service/ac_u.h
index 3c5958d27..c91b28353 100644
--- a/src/core/hle/service/ac_u.h
+++ b/src/core/hle/service/ac_u.h
@@ -9,7 +9,7 @@
9//////////////////////////////////////////////////////////////////////////////////////////////////// 9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace AC_U 10// Namespace AC_U
11 11
12// socket service "ac:u" 12// socket service "ac:u"
13 13
14namespace AC_U { 14namespace AC_U {
15 15
@@ -21,7 +21,7 @@ public:
21 * Gets the string port name used by CTROS for the service 21 * Gets the string port name used by CTROS for the service
22 * @return Port name of service 22 * @return Port name of service
23 */ 23 */
24 std::string GetPortName() const { 24 std::string GetPortName() const override {
25 return "ac:u"; 25 return "ac:u";
26 } 26 }
27}; 27};
diff --git a/src/core/hle/service/am_net.cpp b/src/core/hle/service/am_net.cpp
new file mode 100644
index 000000000..403cac353
--- /dev/null
+++ b/src/core/hle/service/am_net.cpp
@@ -0,0 +1,47 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/log.h"
6#include "core/hle/hle.h"
7#include "core/hle/service/am_net.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace AM_NET
11
12namespace AM_NET {
13
14const Interface::FunctionInfo FunctionTable[] = {
15 {0x08010000, nullptr, "OpenTicket"},
16 {0x08020002, nullptr, "TicketAbortInstall"},
17 {0x08030002, nullptr, "TicketFinalizeInstall"},
18 {0x08040100, nullptr, "InstallTitleBegin"},
19 {0x08050000, nullptr, "InstallTitleAbort"},
20 {0x080600C0, nullptr, "InstallTitleResume"},
21 {0x08070000, nullptr, "InstallTitleAbortTMD"},
22 {0x08080000, nullptr, "InstallTitleFinish"},
23 {0x080A0000, nullptr, "OpenTMD"},
24 {0x080B0002, nullptr, "TMDAbortInstall"},
25 {0x080C0042, nullptr, "TMDFinalizeInstall"},
26 {0x080E0040, nullptr, "OpenContentCreate"},
27 {0x080F0002, nullptr, "ContentAbortInstall"},
28 {0x08100040, nullptr, "OpenContentResume"},
29 {0x08120002, nullptr, "ContentFinalizeInstall"},
30 {0x08130000, nullptr, "GetTotalContents"},
31 {0x08140042, nullptr, "GetContentIndexes"},
32 {0x08150044, nullptr, "GetContentsInfo"},
33 {0x08190108, nullptr, "Unknown"},
34 {0x081B00C2, nullptr, "InstallTitlesFinish"},
35};
36
37////////////////////////////////////////////////////////////////////////////////////////////////////
38// Interface class
39
40Interface::Interface() {
41 Register(FunctionTable, ARRAY_SIZE(FunctionTable));
42}
43
44Interface::~Interface() {
45}
46
47} // namespace
diff --git a/src/core/hle/service/am_net.h b/src/core/hle/service/am_net.h
new file mode 100644
index 000000000..4816e1697
--- /dev/null
+++ b/src/core/hle/service/am_net.h
@@ -0,0 +1,27 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/hle/service/service.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace AM_NET
11
12namespace AM_NET {
13
14class Interface : public Service::Interface {
15public:
16 Interface();
17 ~Interface();
18 /**
19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service
21 */
22 std::string GetPortName() const override {
23 return "am:net";
24 }
25};
26
27} // namespace
diff --git a/src/core/hle/service/apt_u.cpp b/src/core/hle/service/apt_u.cpp
index 4f41ec5f4..4bb05ce40 100644
--- a/src/core/hle/service/apt_u.cpp
+++ b/src/core/hle/service/apt_u.cpp
@@ -27,7 +27,7 @@ enum class SignalType : u32 {
27 27
28void Initialize(Service::Interface* self) { 28void Initialize(Service::Interface* self) {
29 u32* cmd_buff = Service::GetCommandBuffer(); 29 u32* cmd_buff = Service::GetCommandBuffer();
30 30
31 cmd_buff[3] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Menu"); // APT menu event handle 31 cmd_buff[3] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Menu"); // APT menu event handle
32 cmd_buff[4] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Pause"); // APT pause event handle 32 cmd_buff[4] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Pause"); // APT pause event handle
33 33
@@ -168,7 +168,7 @@ void AppletUtility(Service::Interface* self) {
168 cmd_buff[1] = 0; // No error 168 cmd_buff[1] = 0; // No error
169 169
170 WARN_LOG(KERNEL, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08x, buffer2_size=0x%08x, " 170 WARN_LOG(KERNEL, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08x, buffer2_size=0x%08x, "
171 "buffer1_addr=0x%08x, buffer2_addr=0x%08x", unk, buffer1_size, buffer2_size, 171 "buffer1_addr=0x%08x, buffer2_addr=0x%08x", unk, buffer1_size, buffer2_size,
172 buffer1_addr, buffer2_addr); 172 buffer1_addr, buffer2_addr);
173} 173}
174 174
diff --git a/src/core/hle/service/apt_u.h b/src/core/hle/service/apt_u.h
index 5af39e085..306730400 100644
--- a/src/core/hle/service/apt_u.h
+++ b/src/core/hle/service/apt_u.h
@@ -13,8 +13,8 @@ namespace APT_U {
13 13
14// Application and title launching service. These services handle signaling for home/power button as 14// Application and title launching service. These services handle signaling for home/power button as
15// well. Only one session for either APT service can be open at a time, normally processes close the 15// well. Only one session for either APT service can be open at a time, normally processes close the
16// service handle immediately once finished using the service. The commands for APT:U and APT:S are 16// service handle immediately once finished using the service. The commands for APT:U and APT:S are
17// exactly the same, however certain commands are only accessible with APT:S(NS module will call 17// exactly the same, however certain commands are only accessible with APT:S(NS module will call
18// svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services. 18// svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services.
19 19
20/// Interface to "APT:U" service 20/// Interface to "APT:U" service
diff --git a/src/core/hle/service/boss_u.cpp b/src/core/hle/service/boss_u.cpp
index d398edc68..b2ff4a756 100644
--- a/src/core/hle/service/boss_u.cpp
+++ b/src/core/hle/service/boss_u.cpp
@@ -21,8 +21,8 @@ namespace BOSS_U {
21 Interface::Interface() { 21 Interface::Interface() {
22 Register(FunctionTable, ARRAY_SIZE(FunctionTable)); 22 Register(FunctionTable, ARRAY_SIZE(FunctionTable));
23 } 23 }
24 24
25 Interface::~Interface() { 25 Interface::~Interface() {
26 } 26 }
27 27
28} // namespace 28} // namespace
diff --git a/src/core/hle/service/cfg_i.cpp b/src/core/hle/service/cfg_i.cpp
new file mode 100644
index 000000000..88d13d459
--- /dev/null
+++ b/src/core/hle/service/cfg_i.cpp
@@ -0,0 +1,59 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/log.h"
6#include "core/hle/hle.h"
7#include "core/hle/service/cfg_i.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace CFG_I
11
12namespace CFG_I {
13
14const Interface::FunctionInfo FunctionTable[] = {
15 {0x04010082, nullptr, "GetConfigInfoBlk8"},
16 {0x04020082, nullptr, "GetConfigInfoBlk4"},
17 {0x04030000, nullptr, "UpdateConfigNANDSavegame"},
18 {0x04040042, nullptr, "GetLocalFriendCodeSeedData"},
19 {0x04050000, nullptr, "GetLocalFriendCodeSeed"},
20 {0x04060000, nullptr, "SecureInfoGetRegion"},
21 {0x04070000, nullptr, "SecureInfoGetByte101"},
22 {0x04080042, nullptr, "SecureInfoGetSerialNo"},
23 {0x04090000, nullptr, "UpdateConfigBlk00040003"},
24 {0x08010082, nullptr, "GetConfigInfoBlk8"},
25 {0x08020082, nullptr, "GetConfigInfoBlk4"},
26 {0x08030000, nullptr, "UpdateConfigNANDSavegame"},
27 {0x080400C2, nullptr, "CreateConfigInfoBlk"},
28 {0x08050000, nullptr, "DeleteConfigNANDSavefile"},
29 {0x08060000, nullptr, "FormatConfig"},
30 {0x08070000, nullptr, "Unknown"},
31 {0x08080000, nullptr, "UpdateConfigBlk1"},
32 {0x08090000, nullptr, "UpdateConfigBlk2"},
33 {0x080A0000, nullptr, "UpdateConfigBlk3"},
34 {0x080B0082, nullptr, "SetGetLocalFriendCodeSeedData"},
35 {0x080C0042, nullptr, "SetLocalFriendCodeSeedSignature"},
36 {0x080D0000, nullptr, "DeleteCreateNANDLocalFriendCodeSeed"},
37 {0x080E0000, nullptr, "VerifySigLocalFriendCodeSeed"},
38 {0x080F0042, nullptr, "GetLocalFriendCodeSeedData"},
39 {0x08100000, nullptr, "GetLocalFriendCodeSeed"},
40 {0x08110084, nullptr, "SetSecureInfo"},
41 {0x08120000, nullptr, "DeleteCreateNANDSecureInfo"},
42 {0x08130000, nullptr, "VerifySigSecureInfo"},
43 {0x08140042, nullptr, "SecureInfoGetData"},
44 {0x08150042, nullptr, "SecureInfoGetSignature"},
45 {0x08160000, nullptr, "SecureInfoGetRegion"},
46 {0x08170000, nullptr, "SecureInfoGetByte101"},
47 {0x08180042, nullptr, "SecureInfoGetSerialNo"},
48};
49////////////////////////////////////////////////////////////////////////////////////////////////////
50// Interface class
51
52Interface::Interface() {
53 Register(FunctionTable, ARRAY_SIZE(FunctionTable));
54}
55
56Interface::~Interface() {
57}
58
59} // namespace
diff --git a/src/core/hle/service/cfg_i.h b/src/core/hle/service/cfg_i.h
new file mode 100644
index 000000000..fe343c968
--- /dev/null
+++ b/src/core/hle/service/cfg_i.h
@@ -0,0 +1,27 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/hle/service/service.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace CFG_I
11
12namespace CFG_I {
13
14class Interface : public Service::Interface {
15public:
16 Interface();
17 ~Interface();
18 /**
19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service
21 */
22 std::string GetPortName() const override {
23 return "cfg:i";
24 }
25};
26
27} // namespace
diff --git a/src/core/hle/service/cfg_u.h b/src/core/hle/service/cfg_u.h
index 7525bd7c6..8075d19a8 100644
--- a/src/core/hle/service/cfg_u.h
+++ b/src/core/hle/service/cfg_u.h
@@ -19,7 +19,7 @@ public:
19 * Gets the string port name used by CTROS for the service 19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service 20 * @return Port name of service
21 */ 21 */
22 std::string GetPortName() const { 22 std::string GetPortName() const override {
23 return "cfg:u"; 23 return "cfg:u";
24 } 24 }
25}; 25};
diff --git a/src/core/hle/service/csnd_snd.cpp b/src/core/hle/service/csnd_snd.cpp
new file mode 100644
index 000000000..6e59a9bf3
--- /dev/null
+++ b/src/core/hle/service/csnd_snd.cpp
@@ -0,0 +1,39 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/log.h"
6#include "core/hle/hle.h"
7#include "core/hle/service/csnd_snd.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace CSND_SND
11
12namespace CSND_SND {
13
14const Interface::FunctionInfo FunctionTable[] = {
15 {0x00010140, nullptr, "Initialize"},
16 {0x00020000, nullptr, "Shutdown"},
17 {0x00030040, nullptr, "Unknown"},
18 {0x00040080, nullptr, "Unknown"},
19 {0x00050000, nullptr, "Unknown"},
20 {0x00060000, nullptr, "Unknown"},
21 {0x00070000, nullptr, "Unknown"},
22 {0x00080040, nullptr, "Unknown"},
23 {0x00090082, nullptr, "FlushDCache"},
24 {0x000A0082, nullptr, "StoreDCache"},
25 {0x000B0082, nullptr, "InvalidateDCache"},
26 {0x000C0000, nullptr, "Unknown"},
27};
28
29////////////////////////////////////////////////////////////////////////////////////////////////////
30// Interface class
31
32Interface::Interface() {
33 Register(FunctionTable, ARRAY_SIZE(FunctionTable));
34}
35
36Interface::~Interface() {
37}
38
39} // namespace
diff --git a/src/core/hle/service/csnd_snd.h b/src/core/hle/service/csnd_snd.h
new file mode 100644
index 000000000..31cc85b07
--- /dev/null
+++ b/src/core/hle/service/csnd_snd.h
@@ -0,0 +1,27 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/hle/service/service.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace CSND_SND
11
12namespace CSND_SND {
13
14class Interface : public Service::Interface {
15public:
16 Interface();
17 ~Interface();
18 /**
19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service
21 */
22 std::string GetPortName() const override {
23 return "csnd:SND";
24 }
25};
26
27} // namespace
diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp
index 9e84ac938..bbcf26f61 100644
--- a/src/core/hle/service/dsp_dsp.cpp
+++ b/src/core/hle/service/dsp_dsp.cpp
@@ -26,12 +26,12 @@ const Interface::FunctionInfo FunctionTable[] = {
26 {0x001100C2, nullptr, "LoadComponent"}, 26 {0x001100C2, nullptr, "LoadComponent"},
27 {0x00120000, nullptr, "UnloadComponent"}, 27 {0x00120000, nullptr, "UnloadComponent"},
28 {0x00130082, nullptr, "FlushDataCache"}, 28 {0x00130082, nullptr, "FlushDataCache"},
29 {0x00140082, nullptr, "InvalidateDCache "}, 29 {0x00140082, nullptr, "InvalidateDCache"},
30 {0x00150082, nullptr, "RegisterInterruptEvents"}, 30 {0x00150082, nullptr, "RegisterInterruptEvents"},
31 {0x00160000, nullptr, "GetSemaphoreEventHandle"}, 31 {0x00160000, nullptr, "GetSemaphoreEventHandle"},
32 {0x00170040, nullptr, "SetSemaphoreMask"}, 32 {0x00170040, nullptr, "SetSemaphoreMask"},
33 {0x00180040, nullptr, "GetPhysicalAddress"}, 33 {0x00180040, nullptr, "GetPhysicalAddress"},
34 {0x00190040, nullptr, "GetVirtualAddress" }, 34 {0x00190040, nullptr, "GetVirtualAddress"},
35 {0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"}, 35 {0x001A0042, nullptr, "SetIirFilterI2S1_cmd1"},
36 {0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"}, 36 {0x001B0042, nullptr, "SetIirFilterI2S1_cmd2"},
37 {0x001C0082, nullptr, "SetIirFilterEQ"}, 37 {0x001C0082, nullptr, "SetIirFilterEQ"},
diff --git a/src/core/hle/service/dsp_dsp.h b/src/core/hle/service/dsp_dsp.h
index c439ed266..c4ce44245 100644
--- a/src/core/hle/service/dsp_dsp.h
+++ b/src/core/hle/service/dsp_dsp.h
@@ -19,7 +19,7 @@ public:
19 * Gets the string port name used by CTROS for the service 19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service 20 * @return Port name of service
21 */ 21 */
22 std::string GetPortName() const { 22 std::string GetPortName() const override {
23 return "dsp:DSP"; 23 return "dsp:DSP";
24 } 24 }
25}; 25};
diff --git a/src/core/hle/service/err_f.cpp b/src/core/hle/service/err_f.cpp
index 917b2f8ca..785c351e9 100644
--- a/src/core/hle/service/err_f.cpp
+++ b/src/core/hle/service/err_f.cpp
@@ -20,8 +20,8 @@ namespace ERR_F {
20 Interface::Interface() { 20 Interface::Interface() {
21 Register(FunctionTable, ARRAY_SIZE(FunctionTable)); 21 Register(FunctionTable, ARRAY_SIZE(FunctionTable));
22 } 22 }
23 23
24 Interface::~Interface() { 24 Interface::~Interface() {
25 } 25 }
26 26
27} // namespace 27} // namespace
diff --git a/src/core/hle/service/err_f.h b/src/core/hle/service/err_f.h
index 5da663267..6d7141c1b 100644
--- a/src/core/hle/service/err_f.h
+++ b/src/core/hle/service/err_f.h
@@ -19,9 +19,9 @@ namespace ERR_F {
19 * Gets the string port name used by CTROS for the service 19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service 20 * @return Port name of service
21 */ 21 */
22 std::string GetPortName() const { 22 std::string GetPortName() const override {
23 return "err:f"; 23 return "err:f";
24 } 24 }
25 }; 25 };
26 26
27} // namespace 27} // namespace
diff --git a/src/core/hle/service/frd_u.h b/src/core/hle/service/frd_u.h
index 9df8a815a..4020c6664 100644
--- a/src/core/hle/service/frd_u.h
+++ b/src/core/hle/service/frd_u.h
@@ -19,7 +19,7 @@ namespace FRD_U {
19 * Gets the string port name used by CTROS for the service 19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service 20 * @return Port name of service
21 */ 21 */
22 std::string GetPortName() const { 22 std::string GetPortName() const override {
23 return "frd:u"; 23 return "frd:u";
24 } 24 }
25 }; 25 };
diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp
index 609c1cb0a..2aec1a52a 100644
--- a/src/core/hle/service/fs_user.cpp
+++ b/src/core/hle/service/fs_user.cpp
@@ -18,7 +18,7 @@ namespace FS_User {
18// puts all the sections of the http://3dbrew.org/wiki/Error_codes to something non-zero, to make 18// puts all the sections of the http://3dbrew.org/wiki/Error_codes to something non-zero, to make
19// sure we don't mislead the application into thinking something worked. 19// sure we don't mislead the application into thinking something worked.
20 20
21void Initialize(Service::Interface* self) { 21static void Initialize(Service::Interface* self) {
22 u32* cmd_buff = Service::GetCommandBuffer(); 22 u32* cmd_buff = Service::GetCommandBuffer();
23 23
24 // TODO(Link Mauve): check the behavior when cmd_buff[1] isn't 32, as per 24 // TODO(Link Mauve): check the behavior when cmd_buff[1] isn't 32, as per
@@ -44,7 +44,7 @@ void Initialize(Service::Interface* self) {
44 * 1 : Result of function, 0 on success, otherwise error code 44 * 1 : Result of function, 0 on success, otherwise error code
45 * 3 : File handle 45 * 3 : File handle
46 */ 46 */
47void OpenFile(Service::Interface* self) { 47static void OpenFile(Service::Interface* self) {
48 u32* cmd_buff = Service::GetCommandBuffer(); 48 u32* cmd_buff = Service::GetCommandBuffer();
49 49
50 // TODO(Link Mauve): cmd_buff[2], aka archive handle lower word, isn't used according to 50 // TODO(Link Mauve): cmd_buff[2], aka archive handle lower word, isn't used according to
@@ -91,7 +91,7 @@ void OpenFile(Service::Interface* self) {
91 * 1 : Result of function, 0 on success, otherwise error code 91 * 1 : Result of function, 0 on success, otherwise error code
92 * 3 : File handle 92 * 3 : File handle
93 */ 93 */
94void OpenFileDirectly(Service::Interface* self) { 94static void OpenFileDirectly(Service::Interface* self) {
95 u32* cmd_buff = Service::GetCommandBuffer(); 95 u32* cmd_buff = Service::GetCommandBuffer();
96 96
97 auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[2]); 97 auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[2]);
@@ -210,7 +210,7 @@ void DeleteDirectory(Service::Interface* self) {
210 * Outputs: 210 * Outputs:
211 * 1 : Result of function, 0 on success, otherwise error code 211 * 1 : Result of function, 0 on success, otherwise error code
212 */ 212 */
213void CreateDirectory(Service::Interface* self) { 213static void CreateDirectory(Service::Interface* self) {
214 u32* cmd_buff = Service::GetCommandBuffer(); 214 u32* cmd_buff = Service::GetCommandBuffer();
215 215
216 // TODO: cmd_buff[2], aka archive handle lower word, isn't used according to 216 // TODO: cmd_buff[2], aka archive handle lower word, isn't used according to
@@ -229,7 +229,7 @@ void CreateDirectory(Service::Interface* self) {
229 DEBUG_LOG(KERNEL, "called"); 229 DEBUG_LOG(KERNEL, "called");
230} 230}
231 231
232void OpenDirectory(Service::Interface* self) { 232static void OpenDirectory(Service::Interface* self) {
233 u32* cmd_buff = Service::GetCommandBuffer(); 233 u32* cmd_buff = Service::GetCommandBuffer();
234 234
235 // TODO(Link Mauve): cmd_buff[2], aka archive handle lower word, isn't used according to 235 // TODO(Link Mauve): cmd_buff[2], aka archive handle lower word, isn't used according to
@@ -269,7 +269,7 @@ void OpenDirectory(Service::Interface* self) {
269 * 2 : Archive handle lower word (unused) 269 * 2 : Archive handle lower word (unused)
270 * 3 : Archive handle upper word (same as file handle) 270 * 3 : Archive handle upper word (same as file handle)
271 */ 271 */
272void OpenArchive(Service::Interface* self) { 272static void OpenArchive(Service::Interface* self) {
273 u32* cmd_buff = Service::GetCommandBuffer(); 273 u32* cmd_buff = Service::GetCommandBuffer();
274 274
275 auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[1]); 275 auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[1]);
@@ -306,12 +306,12 @@ void OpenArchive(Service::Interface* self) {
306* 1 : Result of function, 0 on success, otherwise error code 306* 1 : Result of function, 0 on success, otherwise error code
307* 2 : Whether the Sdmc could be detected 307* 2 : Whether the Sdmc could be detected
308*/ 308*/
309void IsSdmcDetected(Service::Interface* self) { 309static void IsSdmcDetected(Service::Interface* self) {
310 u32* cmd_buff = Service::GetCommandBuffer(); 310 u32* cmd_buff = Service::GetCommandBuffer();
311 311
312 cmd_buff[1] = 0; 312 cmd_buff[1] = 0;
313 cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0; 313 cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0;
314 314
315 DEBUG_LOG(KERNEL, "called"); 315 DEBUG_LOG(KERNEL, "called");
316} 316}
317 317
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp
index 6119e6300..66daded94 100644
--- a/src/core/hle/service/gsp_gpu.cpp
+++ b/src/core/hle/service/gsp_gpu.cpp
@@ -52,7 +52,7 @@ static inline InterruptRelayQueue* GetInterruptRelayQueue(u32 thread_id) {
52 sizeof(InterruptRelayQueue) * thread_id); 52 sizeof(InterruptRelayQueue) * thread_id);
53} 53}
54 54
55void WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) { 55static void WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) {
56 // TODO: Return proper error codes 56 // TODO: Return proper error codes
57 if (base_address + size_in_bytes >= 0x420000) { 57 if (base_address + size_in_bytes >= 0x420000) {
58 ERROR_LOG(GPU, "Write address out of range! (address=0x%08x, size=0x%08x)", 58 ERROR_LOG(GPU, "Write address out of range! (address=0x%08x, size=0x%08x)",
@@ -76,7 +76,7 @@ void WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) {
76} 76}
77 77
78/// Write a GSP GPU hardware register 78/// Write a GSP GPU hardware register
79void WriteHWRegs(Service::Interface* self) { 79static void WriteHWRegs(Service::Interface* self) {
80 u32* cmd_buff = Service::GetCommandBuffer(); 80 u32* cmd_buff = Service::GetCommandBuffer();
81 u32 reg_addr = cmd_buff[1]; 81 u32 reg_addr = cmd_buff[1];
82 u32 size = cmd_buff[2]; 82 u32 size = cmd_buff[2];
@@ -87,7 +87,7 @@ void WriteHWRegs(Service::Interface* self) {
87} 87}
88 88
89/// Read a GSP GPU hardware register 89/// Read a GSP GPU hardware register
90void ReadHWRegs(Service::Interface* self) { 90static void ReadHWRegs(Service::Interface* self) {
91 u32* cmd_buff = Service::GetCommandBuffer(); 91 u32* cmd_buff = Service::GetCommandBuffer();
92 u32 reg_addr = cmd_buff[1]; 92 u32 reg_addr = cmd_buff[1];
93 u32 size = cmd_buff[2]; 93 u32 size = cmd_buff[2];
@@ -115,7 +115,7 @@ void ReadHWRegs(Service::Interface* self) {
115 } 115 }
116} 116}
117 117
118void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { 118static void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) {
119 u32 base_address = 0x400000; 119 u32 base_address = 0x400000;
120 if (info.active_fb == 0) { 120 if (info.active_fb == 0) {
121 WriteHWRegs(base_address + 4 * GPU_REG_INDEX(framebuffer_config[screen_id].address_left1), 4, &info.address_left); 121 WriteHWRegs(base_address + 4 * GPU_REG_INDEX(framebuffer_config[screen_id].address_left1), 4, &info.address_left);
@@ -140,7 +140,7 @@ void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) {
140 * Outputs: 140 * Outputs:
141 * 1: Result code 141 * 1: Result code
142 */ 142 */
143void SetBufferSwap(Service::Interface* self) { 143static void SetBufferSwap(Service::Interface* self) {
144 u32* cmd_buff = Service::GetCommandBuffer(); 144 u32* cmd_buff = Service::GetCommandBuffer();
145 u32 screen_id = cmd_buff[1]; 145 u32 screen_id = cmd_buff[1];
146 FrameBufferInfo* fb_info = (FrameBufferInfo*)&cmd_buff[2]; 146 FrameBufferInfo* fb_info = (FrameBufferInfo*)&cmd_buff[2];
@@ -159,7 +159,7 @@ void SetBufferSwap(Service::Interface* self) {
159 * 2 : Thread index into GSP command buffer 159 * 2 : Thread index into GSP command buffer
160 * 4 : Handle to GSP shared memory 160 * 4 : Handle to GSP shared memory
161 */ 161 */
162void RegisterInterruptRelayQueue(Service::Interface* self) { 162static void RegisterInterruptRelayQueue(Service::Interface* self) {
163 u32* cmd_buff = Service::GetCommandBuffer(); 163 u32* cmd_buff = Service::GetCommandBuffer();
164 u32 flags = cmd_buff[1]; 164 u32 flags = cmd_buff[1];
165 g_interrupt_event = cmd_buff[3]; 165 g_interrupt_event = cmd_buff[3];
@@ -202,7 +202,7 @@ void SignalInterrupt(InterruptId interrupt_id) {
202} 202}
203 203
204/// Executes the next GSP command 204/// Executes the next GSP command
205void ExecuteCommand(const Command& command, u32 thread_id) { 205static void ExecuteCommand(const Command& command, u32 thread_id) {
206 // Utility function to convert register ID to address 206 // Utility function to convert register ID to address
207 auto WriteGPURegister = [](u32 id, u32 data) { 207 auto WriteGPURegister = [](u32 id, u32 data) {
208 GPU::Write<u32>(0x1EF00000 + 4 * id, data); 208 GPU::Write<u32>(0x1EF00000 + 4 * id, data);
@@ -308,7 +308,7 @@ void ExecuteCommand(const Command& command, u32 thread_id) {
308} 308}
309 309
310/// This triggers handling of the GX command written to the command buffer in shared memory. 310/// This triggers handling of the GX command written to the command buffer in shared memory.
311void TriggerCmdReqQueue(Service::Interface* self) { 311static void TriggerCmdReqQueue(Service::Interface* self) {
312 312
313 // Iterate through each thread's command queue... 313 // Iterate through each thread's command queue...
314 for (unsigned thread_id = 0; thread_id < 0x4; ++thread_id) { 314 for (unsigned thread_id = 0; thread_id < 0x4; ++thread_id) {
diff --git a/src/core/hle/service/hid_user.cpp b/src/core/hle/service/hid_user.cpp
index 0eb32ba4a..5f6bf1eff 100644
--- a/src/core/hle/service/hid_user.cpp
+++ b/src/core/hle/service/hid_user.cpp
@@ -47,7 +47,7 @@ static inline PadData* GetPadData() {
47 * 47 *
48 * Indicate the circle pad is pushed completely to the edge in 1 of 8 directions. 48 * Indicate the circle pad is pushed completely to the edge in 1 of 8 directions.
49 */ 49 */
50void UpdateNextCirclePadState() { 50static void UpdateNextCirclePadState() {
51 static const s16 max_value = 0x9C; 51 static const s16 max_value = 0x9C;
52 next_circle_x = next_state.circle_left ? -max_value : 0x0; 52 next_circle_x = next_state.circle_left ? -max_value : 0x0;
53 next_circle_x += next_state.circle_right ? max_value : 0x0; 53 next_circle_x += next_state.circle_right ? max_value : 0x0;
@@ -155,7 +155,7 @@ void PadUpdateComplete() {
155 * 7 : Gyroscope event 155 * 7 : Gyroscope event
156 * 8 : Event signaled by HID_User 156 * 8 : Event signaled by HID_User
157 */ 157 */
158void GetIPCHandles(Service::Interface* self) { 158static void GetIPCHandles(Service::Interface* self) {
159 u32* cmd_buff = Service::GetCommandBuffer(); 159 u32* cmd_buff = Service::GetCommandBuffer();
160 160
161 cmd_buff[1] = 0; // No error 161 cmd_buff[1] = 0; // No error
diff --git a/src/core/hle/service/hid_user.h b/src/core/hle/service/hid_user.h
index 9f6c4d5ed..5ed97085d 100644
--- a/src/core/hle/service/hid_user.h
+++ b/src/core/hle/service/hid_user.h
@@ -15,7 +15,7 @@
15 15
16namespace HID_User { 16namespace HID_User {
17 17
18/** 18/**
19 * Structure of a Pad controller state. 19 * Structure of a Pad controller state.
20 */ 20 */
21struct PadState { 21struct PadState {
diff --git a/src/core/hle/service/ir_rst.cpp b/src/core/hle/service/ir_rst.cpp
new file mode 100644
index 000000000..be15db231
--- /dev/null
+++ b/src/core/hle/service/ir_rst.cpp
@@ -0,0 +1,36 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/log.h"
6#include "core/hle/hle.h"
7#include "core/hle/service/ir_rst.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace IR_RST
11
12namespace IR_RST {
13
14const Interface::FunctionInfo FunctionTable[] = {
15 {0x00010000, nullptr, "GetHandles"},
16 {0x00020080, nullptr, "Initialize"},
17 {0x00030000, nullptr, "Shutdown"},
18 {0x00040000, nullptr, "Unknown"},
19 {0x00050000, nullptr, "Unknown"},
20 {0x00060000, nullptr, "Unknown"},
21 {0x00070080, nullptr, "Unknown"},
22 {0x00080000, nullptr, "Unknown"},
23 {0x00090000, nullptr, "Unknown"},
24};
25
26////////////////////////////////////////////////////////////////////////////////////////////////////
27// Interface class
28
29Interface::Interface() {
30 Register(FunctionTable, ARRAY_SIZE(FunctionTable));
31}
32
33Interface::~Interface() {
34}
35
36} // namespace
diff --git a/src/core/hle/service/ir_rst.h b/src/core/hle/service/ir_rst.h
new file mode 100644
index 000000000..73effd7e3
--- /dev/null
+++ b/src/core/hle/service/ir_rst.h
@@ -0,0 +1,27 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/hle/service/service.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace IR_RST
11
12namespace IR_RST {
13
14class Interface : public Service::Interface {
15public:
16 Interface();
17 ~Interface();
18 /**
19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service
21 */
22 std::string GetPortName() const override {
23 return "ir:rst";
24 }
25};
26
27} // namespace
diff --git a/src/core/hle/service/ir_u.cpp b/src/core/hle/service/ir_u.cpp
new file mode 100644
index 000000000..aa9db6f6d
--- /dev/null
+++ b/src/core/hle/service/ir_u.cpp
@@ -0,0 +1,45 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/log.h"
6#include "core/hle/hle.h"
7#include "core/hle/service/ir_u.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace IR_U
11
12namespace IR_U {
13
14const Interface::FunctionInfo FunctionTable[] = {
15 {0x00010000, nullptr, "Initialize"},
16 {0x00020000, nullptr, "Shutdown"},
17 {0x00030042, nullptr, "StartSendTransfer"},
18 {0x00040000, nullptr, "WaitSendTransfer"},
19 {0x000500C2, nullptr, "StartRecvTransfer"},
20 {0x00060000, nullptr, "WaitRecvTransfer"},
21 {0x00070080, nullptr, "GetRecvTransferCount"},
22 {0x00080000, nullptr, "GetSendState"},
23 {0x00090040, nullptr, "SetBitRate"},
24 {0x000A0000, nullptr, "GetBitRate"},
25 {0x000B0040, nullptr, "SetIRLEDState"},
26 {0x000C0000, nullptr, "GetIRLEDRecvState"},
27 {0x000D0000, nullptr, "GetSendFinishedEvent"},
28 {0x000E0000, nullptr, "GetRecvFinishedEvent"},
29 {0x000F0000, nullptr, "GetTransferState"},
30 {0x00100000, nullptr, "GetErrorStatus"},
31 {0x00110040, nullptr, "SetSleepModeActive"},
32 {0x00120040, nullptr, "SetSleepModeState"},
33};
34
35////////////////////////////////////////////////////////////////////////////////////////////////////
36// Interface class
37
38Interface::Interface() {
39 Register(FunctionTable, ARRAY_SIZE(FunctionTable));
40}
41
42Interface::~Interface() {
43}
44
45} // namespace
diff --git a/src/core/hle/service/ir_u.h b/src/core/hle/service/ir_u.h
new file mode 100644
index 000000000..86d98d079
--- /dev/null
+++ b/src/core/hle/service/ir_u.h
@@ -0,0 +1,27 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/hle/service/service.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace IR_U
11
12namespace IR_U {
13
14class Interface : public Service::Interface {
15public:
16 Interface();
17 ~Interface();
18 /**
19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service
21 */
22 std::string GetPortName() const override {
23 return "ir:u";
24 }
25};
26
27} // namespace
diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp
index 58051f133..d6f30e9ae 100644
--- a/src/core/hle/service/mic_u.cpp
+++ b/src/core/hle/service/mic_u.cpp
@@ -27,7 +27,7 @@ const Interface::FunctionInfo FunctionTable[] = {
27 {0x000D0040, nullptr, "SetClamp"}, 27 {0x000D0040, nullptr, "SetClamp"},
28 {0x000E0000, nullptr, "GetClamp"}, 28 {0x000E0000, nullptr, "GetClamp"},
29 {0x000F0040, nullptr, "unknown_input1"}, 29 {0x000F0040, nullptr, "unknown_input1"},
30 {0x00100040, nullptr, "unknown_input2"}, 30 {0x00100040, nullptr, "unknown_input2"},
31}; 31};
32 32
33//////////////////////////////////////////////////////////////////////////////////////////////////// 33////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/service/mic_u.h b/src/core/hle/service/mic_u.h
index 72ba048ef..2a495f3a9 100644
--- a/src/core/hle/service/mic_u.h
+++ b/src/core/hle/service/mic_u.h
@@ -21,7 +21,7 @@ public:
21 * Gets the string port name used by CTROS for the service 21 * Gets the string port name used by CTROS for the service
22 * @return Port name of service 22 * @return Port name of service
23 */ 23 */
24 std::string GetPortName() const { 24 std::string GetPortName() const override {
25 return "mic:u"; 25 return "mic:u";
26 } 26 }
27}; 27};
diff --git a/src/core/hle/service/nwm_uds.h b/src/core/hle/service/nwm_uds.h
index a956ca812..69d2c2002 100644
--- a/src/core/hle/service/nwm_uds.h
+++ b/src/core/hle/service/nwm_uds.h
@@ -21,7 +21,7 @@ public:
21 * Gets the string port name used by CTROS for the service 21 * Gets the string port name used by CTROS for the service
22 * @return Port name of service 22 * @return Port name of service
23 */ 23 */
24 std::string GetPortName() const { 24 std::string GetPortName() const override {
25 return "nwm:UDS"; 25 return "nwm:UDS";
26 } 26 }
27}; 27};
diff --git a/src/core/hle/service/pm_app.cpp b/src/core/hle/service/pm_app.cpp
new file mode 100644
index 000000000..90e9b1bfa
--- /dev/null
+++ b/src/core/hle/service/pm_app.cpp
@@ -0,0 +1,35 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/log.h"
6#include "core/hle/hle.h"
7#include "core/hle/service/pm_app.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace PM_APP
11
12namespace PM_APP {
13
14const Interface::FunctionInfo FunctionTable[] = {
15 {0x00010140, nullptr, "LaunchTitle"},
16 {0x00020082, nullptr, "LaunchFIRMSetParams"},
17 {0x00030080, nullptr, "TerminateProcesse"},
18 {0x00040100, nullptr, "TerminateProcessTID"},
19 {0x000500C0, nullptr, "TerminateProcessTID_unknown"},
20 {0x00070042, nullptr, "GetFIRMLaunchParams"},
21 {0x00080100, nullptr, "GetTitleExheaderFlags"},
22 {0x00090042, nullptr, "SetFIRMLaunchParams"},
23};
24
25////////////////////////////////////////////////////////////////////////////////////////////////////
26// Interface class
27
28Interface::Interface() {
29 Register(FunctionTable, ARRAY_SIZE(FunctionTable));
30}
31
32Interface::~Interface() {
33}
34
35} // namespace
diff --git a/src/core/hle/service/pm_app.h b/src/core/hle/service/pm_app.h
new file mode 100644
index 000000000..28c38f582
--- /dev/null
+++ b/src/core/hle/service/pm_app.h
@@ -0,0 +1,27 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/hle/service/service.h"
8
9////////////////////////////////////////////////////////////////////////////////////////////////////
10// Namespace PM_APP
11
12namespace PM_APP {
13
14class Interface : public Service::Interface {
15public:
16 Interface();
17 ~Interface();
18 /**
19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service
21 */
22 std::string GetPortName() const override {
23 return "pm:app";
24 }
25};
26
27} // namespace
diff --git a/src/core/hle/service/ptm_u.cpp b/src/core/hle/service/ptm_u.cpp
index f6a14d509..d9122dbbc 100644
--- a/src/core/hle/service/ptm_u.cpp
+++ b/src/core/hle/service/ptm_u.cpp
@@ -17,13 +17,13 @@ const Interface::FunctionInfo FunctionTable[] = {
17 {0x00030000, nullptr, "GetRtcAlarm"}, 17 {0x00030000, nullptr, "GetRtcAlarm"},
18 {0x00040000, nullptr, "CancelRtcAlarm"}, 18 {0x00040000, nullptr, "CancelRtcAlarm"},
19 {0x00050000, nullptr, "GetAdapterState"}, 19 {0x00050000, nullptr, "GetAdapterState"},
20 {0x00060000, nullptr, "GetShellState "}, 20 {0x00060000, nullptr, "GetShellState"},
21 {0x00070000, nullptr, "GetBatteryLevel"}, 21 {0x00070000, nullptr, "GetBatteryLevel"},
22 {0x00080000, nullptr, "GetBatteryChargeState"}, 22 {0x00080000, nullptr, "GetBatteryChargeState"},
23 {0x00090000, nullptr, "GetPedometerState"}, 23 {0x00090000, nullptr, "GetPedometerState"},
24 {0x000A0042, nullptr, "GetStepHistoryEntry"}, 24 {0x000A0042, nullptr, "GetStepHistoryEntry"},
25 {0x000B00C2, nullptr, "GetStepHistory "}, 25 {0x000B00C2, nullptr, "GetStepHistory"},
26 {0x000C0000, nullptr, "GetTotalStepCount "}, 26 {0x000C0000, nullptr, "GetTotalStepCount"},
27 {0x000D0040, nullptr, "SetPedometerRecordingMode"}, 27 {0x000D0040, nullptr, "SetPedometerRecordingMode"},
28 {0x000E0000, nullptr, "GetPedometerRecordingMode"}, 28 {0x000E0000, nullptr, "GetPedometerRecordingMode"},
29 {0x000F0084, nullptr, "GetStepHistoryAll"}, 29 {0x000F0084, nullptr, "GetStepHistoryAll"},
diff --git a/src/core/hle/service/ptm_u.h b/src/core/hle/service/ptm_u.h
index 82749fa39..f8d9f57be 100644
--- a/src/core/hle/service/ptm_u.h
+++ b/src/core/hle/service/ptm_u.h
@@ -21,7 +21,7 @@ public:
21 * Gets the string port name used by CTROS for the service 21 * Gets the string port name used by CTROS for the service
22 * @return Port name of service 22 * @return Port name of service
23 */ 23 */
24 std::string GetPortName() const { 24 std::string GetPortName() const override {
25 return "ptm:u"; 25 return "ptm:u";
26 } 26 }
27}; 27};
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index ba7299170..abc8d5edb 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -7,18 +7,24 @@
7 7
8#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
9#include "core/hle/service/ac_u.h" 9#include "core/hle/service/ac_u.h"
10#include "core/hle/service/am_net.h"
10#include "core/hle/service/apt_u.h" 11#include "core/hle/service/apt_u.h"
11#include "core/hle/service/boss_u.h" 12#include "core/hle/service/boss_u.h"
13#include "core/hle/service/cfg_i.h"
12#include "core/hle/service/cfg_u.h" 14#include "core/hle/service/cfg_u.h"
15#include "core/hle/service/csnd_snd.h"
13#include "core/hle/service/dsp_dsp.h" 16#include "core/hle/service/dsp_dsp.h"
14#include "core/hle/service/err_f.h" 17#include "core/hle/service/err_f.h"
15#include "core/hle/service/fs_user.h" 18#include "core/hle/service/fs_user.h"
16#include "core/hle/service/frd_u.h" 19#include "core/hle/service/frd_u.h"
17#include "core/hle/service/gsp_gpu.h" 20#include "core/hle/service/gsp_gpu.h"
18#include "core/hle/service/hid_user.h" 21#include "core/hle/service/hid_user.h"
22#include "core/hle/service/ir_rst.h"
23#include "core/hle/service/ir_u.h"
19#include "core/hle/service/mic_u.h" 24#include "core/hle/service/mic_u.h"
20#include "core/hle/service/ndm_u.h" 25#include "core/hle/service/ndm_u.h"
21#include "core/hle/service/nwm_uds.h" 26#include "core/hle/service/nwm_uds.h"
27#include "core/hle/service/pm_app.h"
22#include "core/hle/service/ptm_u.h" 28#include "core/hle/service/ptm_u.h"
23#include "core/hle/service/soc_u.h" 29#include "core/hle/service/soc_u.h"
24#include "core/hle/service/srv.h" 30#include "core/hle/service/srv.h"
@@ -75,21 +81,27 @@ Interface* Manager::FetchFromPortName(const std::string& port_name) {
75/// Initialize ServiceManager 81/// Initialize ServiceManager
76void Init() { 82void Init() {
77 g_manager = new Manager; 83 g_manager = new Manager;
78 84
79 g_manager->AddService(new SRV::Interface); 85 g_manager->AddService(new SRV::Interface);
80 g_manager->AddService(new AC_U::Interface); 86 g_manager->AddService(new AC_U::Interface);
87 g_manager->AddService(new AM_NET::Interface);
81 g_manager->AddService(new APT_U::Interface); 88 g_manager->AddService(new APT_U::Interface);
82 g_manager->AddService(new BOSS_U::Interface); 89 g_manager->AddService(new BOSS_U::Interface);
90 g_manager->AddService(new CFG_I::Interface);
83 g_manager->AddService(new CFG_U::Interface); 91 g_manager->AddService(new CFG_U::Interface);
92 g_manager->AddService(new CSND_SND::Interface);
84 g_manager->AddService(new DSP_DSP::Interface); 93 g_manager->AddService(new DSP_DSP::Interface);
85 g_manager->AddService(new ERR_F::Interface); 94 g_manager->AddService(new ERR_F::Interface);
86 g_manager->AddService(new FRD_U::Interface); 95 g_manager->AddService(new FRD_U::Interface);
87 g_manager->AddService(new FS_User::Interface); 96 g_manager->AddService(new FS_User::Interface);
88 g_manager->AddService(new GSP_GPU::Interface); 97 g_manager->AddService(new GSP_GPU::Interface);
89 g_manager->AddService(new HID_User::Interface); 98 g_manager->AddService(new HID_User::Interface);
99 g_manager->AddService(new IR_RST::Interface);
100 g_manager->AddService(new IR_U::Interface);
90 g_manager->AddService(new MIC_U::Interface); 101 g_manager->AddService(new MIC_U::Interface);
91 g_manager->AddService(new NDM_U::Interface); 102 g_manager->AddService(new NDM_U::Interface);
92 g_manager->AddService(new NWM_UDS::Interface); 103 g_manager->AddService(new NWM_UDS::Interface);
104 g_manager->AddService(new PM_APP::Interface);
93 g_manager->AddService(new PTM_U::Interface); 105 g_manager->AddService(new PTM_U::Interface);
94 g_manager->AddService(new SOC_U::Interface); 106 g_manager->AddService(new SOC_U::Interface);
95 g_manager->AddService(new SSL_C::Interface); 107 g_manager->AddService(new SSL_C::Interface);
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 2f5a866c9..55aa84e83 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -38,7 +38,7 @@ class Manager;
38class Interface : public Kernel::Object { 38class Interface : public Kernel::Object {
39 friend class Manager; 39 friend class Manager;
40public: 40public:
41 41
42 std::string GetName() const override { return GetPortName(); } 42 std::string GetName() const override { return GetPortName(); }
43 std::string GetTypeName() const override { return GetPortName(); } 43 std::string GetTypeName() const override { return GetPortName(); }
44 44
@@ -76,7 +76,7 @@ public:
76 } 76 }
77 77
78 /** 78 /**
79 * Synchronize kernel object 79 * Synchronize kernel object
80 * @param wait Boolean wait set if current thread should wait as a result of sync operation 80 * @param wait Boolean wait set if current thread should wait as a result of sync operation
81 * @return Result of operation, 0 on success, otherwise error code 81 * @return Result of operation, 0 on success, otherwise error code
82 */ 82 */
@@ -85,23 +85,23 @@ public:
85 auto itr = m_functions.find(cmd_buff[0]); 85 auto itr = m_functions.find(cmd_buff[0]);
86 86
87 if (itr == m_functions.end()) { 87 if (itr == m_functions.end()) {
88 ERROR_LOG(OSHLE, "unknown/unimplemented function: port=%s, command=0x%08X", 88 ERROR_LOG(OSHLE, "unknown/unimplemented function: port=%s, command=0x%08X",
89 GetPortName().c_str(), cmd_buff[0]); 89 GetPortName().c_str(), cmd_buff[0]);
90 90
91 // TODO(bunnei): Hack - ignore error 91 // TODO(bunnei): Hack - ignore error
92 u32* cmd_buff = Service::GetCommandBuffer(); 92 u32* cmd_buff = Service::GetCommandBuffer();
93 cmd_buff[1] = 0; 93 cmd_buff[1] = 0;
94 return 0; 94 return 0;
95 } 95 }
96 if (itr->second.func == nullptr) { 96 if (itr->second.func == nullptr) {
97 ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s", 97 ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s",
98 GetPortName().c_str(), itr->second.name.c_str()); 98 GetPortName().c_str(), itr->second.name.c_str());
99 99
100 // TODO(bunnei): Hack - ignore error 100 // TODO(bunnei): Hack - ignore error
101 u32* cmd_buff = Service::GetCommandBuffer(); 101 u32* cmd_buff = Service::GetCommandBuffer();
102 cmd_buff[1] = 0; 102 cmd_buff[1] = 0;
103 return 0; 103 return 0;
104 } 104 }
105 105
106 itr->second.func(this); 106 itr->second.func(this);
107 107
diff --git a/src/core/hle/service/soc_u.h b/src/core/hle/service/soc_u.h
index e27a2b1fe..d5590a683 100644
--- a/src/core/hle/service/soc_u.h
+++ b/src/core/hle/service/soc_u.h
@@ -19,7 +19,7 @@ public:
19 * Gets the string port name used by CTROS for the service 19 * Gets the string port name used by CTROS for the service
20 * @return Port name of service 20 * @return Port name of service
21 */ 21 */
22 std::string GetPortName() const { 22 std::string GetPortName() const override {
23 return "soc:U"; 23 return "soc:U";
24 } 24 }
25}; 25};
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp
index 6c02a43d9..df38bd93c 100644
--- a/src/core/hle/service/srv.cpp
+++ b/src/core/hle/service/srv.cpp
@@ -11,9 +11,9 @@
11 11
12namespace SRV { 12namespace SRV {
13 13
14Handle g_event_handle = 0; 14static Handle g_event_handle = 0;
15 15
16void Initialize(Service::Interface* self) { 16static void Initialize(Service::Interface* self) {
17 DEBUG_LOG(OSHLE, "called"); 17 DEBUG_LOG(OSHLE, "called");
18 18
19 u32* cmd_buff = Service::GetCommandBuffer(); 19 u32* cmd_buff = Service::GetCommandBuffer();
@@ -21,7 +21,7 @@ void Initialize(Service::Interface* self) {
21 cmd_buff[1] = 0; // No error 21 cmd_buff[1] = 0; // No error
22} 22}
23 23
24void GetProcSemaphore(Service::Interface* self) { 24static void GetProcSemaphore(Service::Interface* self) {
25 DEBUG_LOG(OSHLE, "called"); 25 DEBUG_LOG(OSHLE, "called");
26 26
27 u32* cmd_buff = Service::GetCommandBuffer(); 27 u32* cmd_buff = Service::GetCommandBuffer();
@@ -34,7 +34,7 @@ void GetProcSemaphore(Service::Interface* self) {
34 cmd_buff[3] = g_event_handle; 34 cmd_buff[3] = g_event_handle;
35} 35}
36 36
37void GetServiceHandle(Service::Interface* self) { 37static void GetServiceHandle(Service::Interface* self) {
38 Result res = 0; 38 Result res = 0;
39 u32* cmd_buff = Service::GetCommandBuffer(); 39 u32* cmd_buff = Service::GetCommandBuffer();
40 40
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 1eda36c53..3a06d6765 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <map> 5#include <map>
6 6
@@ -29,8 +29,8 @@ enum ControlMemoryOperation {
29}; 29};
30 30
31/// Map application or GSP heap memory 31/// Map application or GSP heap memory
32Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { 32static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
33 DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", 33 DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X",
34 operation, addr0, addr1, size, permissions); 34 operation, addr0, addr1, size, permissions);
35 35
36 switch (operation) { 36 switch (operation) {
@@ -53,8 +53,8 @@ Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 siz
53} 53}
54 54
55/// Maps a memory block to specified address 55/// Maps a memory block to specified address
56Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { 56static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) {
57 DEBUG_LOG(SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", 57 DEBUG_LOG(SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d",
58 handle, addr, permissions, other_permissions); 58 handle, addr, permissions, other_permissions);
59 59
60 Kernel::MemoryPermission permissions_type = static_cast<Kernel::MemoryPermission>(permissions); 60 Kernel::MemoryPermission permissions_type = static_cast<Kernel::MemoryPermission>(permissions);
@@ -63,7 +63,7 @@ Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permis
63 case Kernel::MemoryPermission::Write: 63 case Kernel::MemoryPermission::Write:
64 case Kernel::MemoryPermission::ReadWrite: 64 case Kernel::MemoryPermission::ReadWrite:
65 case Kernel::MemoryPermission::DontCare: 65 case Kernel::MemoryPermission::DontCare:
66 Kernel::MapSharedMemory(handle, addr, permissions_type, 66 Kernel::MapSharedMemory(handle, addr, permissions_type,
67 static_cast<Kernel::MemoryPermission>(other_permissions)); 67 static_cast<Kernel::MemoryPermission>(other_permissions));
68 break; 68 break;
69 default: 69 default:
@@ -73,7 +73,7 @@ Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permis
73} 73}
74 74
75/// Connect to an OS service given the port name, returns the handle to the port to out 75/// Connect to an OS service given the port name, returns the handle to the port to out
76Result ConnectToPort(Handle* out, const char* port_name) { 76static Result ConnectToPort(Handle* out, const char* port_name) {
77 Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); 77 Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
78 78
79 DEBUG_LOG(SVC, "called port_name=%s", port_name); 79 DEBUG_LOG(SVC, "called port_name=%s", port_name);
@@ -85,7 +85,7 @@ Result ConnectToPort(Handle* out, const char* port_name) {
85} 85}
86 86
87/// Synchronize to an OS service 87/// Synchronize to an OS service
88Result SendSyncRequest(Handle handle) { 88static Result SendSyncRequest(Handle handle) {
89 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle); 89 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
90 90
91 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!"); 91 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!");
@@ -101,21 +101,21 @@ Result SendSyncRequest(Handle handle) {
101} 101}
102 102
103/// Close a handle 103/// Close a handle
104Result CloseHandle(Handle handle) { 104static Result CloseHandle(Handle handle) {
105 // ImplementMe 105 // ImplementMe
106 ERROR_LOG(SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle); 106 ERROR_LOG(SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle);
107 return 0; 107 return 0;
108} 108}
109 109
110/// Wait for a handle to synchronize, timeout after the specified nanoseconds 110/// Wait for a handle to synchronize, timeout after the specified nanoseconds
111Result WaitSynchronization1(Handle handle, s64 nano_seconds) { 111static Result WaitSynchronization1(Handle handle, s64 nano_seconds) {
112 // TODO(bunnei): Do something with nano_seconds, currently ignoring this 112 // TODO(bunnei): Do something with nano_seconds, currently ignoring this
113 bool wait = false; 113 bool wait = false;
114 bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated 114 bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated
115 115
116 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle); 116 Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
117 117
118 DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(), 118 DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(),
119 object->GetName().c_str(), nano_seconds); 119 object->GetName().c_str(), nano_seconds);
120 120
121 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!"); 121 _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!");
@@ -132,13 +132,13 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) {
132} 132}
133 133
134/// Wait for the given handles to synchronize, timeout after the specified nanoseconds 134/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
135Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all, 135static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all,
136 s64 nano_seconds) { 136 s64 nano_seconds) {
137 // TODO(bunnei): Do something with nano_seconds, currently ignoring this 137 // TODO(bunnei): Do something with nano_seconds, currently ignoring this
138 bool unlock_all = true; 138 bool unlock_all = true;
139 bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated 139 bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated
140 140
141 DEBUG_LOG(SVC, "called handle_count=%d, wait_all=%s, nanoseconds=%lld", 141 DEBUG_LOG(SVC, "called handle_count=%d, wait_all=%s, nanoseconds=%lld",
142 handle_count, (wait_all ? "true" : "false"), nano_seconds); 142 handle_count, (wait_all ? "true" : "false"), nano_seconds);
143 143
144 // Iterate through each handle, synchronize kernel object 144 // Iterate through each handle, synchronize kernel object
@@ -149,7 +149,7 @@ Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wa
149 _assert_msg_(KERNEL, (object != nullptr), "called handle=0x%08X, but kernel object " 149 _assert_msg_(KERNEL, (object != nullptr), "called handle=0x%08X, but kernel object "
150 "is nullptr!", handles[i]); 150 "is nullptr!", handles[i]);
151 151
152 DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(), 152 DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(),
153 object->GetName().c_str()); 153 object->GetName().c_str());
154 154
155 Result res = object->WaitSynchronization(&wait); 155 Result res = object->WaitSynchronization(&wait);
@@ -174,7 +174,7 @@ Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wa
174} 174}
175 175
176/// Create an address arbiter (to allocate access to shared resources) 176/// Create an address arbiter (to allocate access to shared resources)
177Result CreateAddressArbiter(u32* arbiter) { 177static Result CreateAddressArbiter(u32* arbiter) {
178 DEBUG_LOG(SVC, "called"); 178 DEBUG_LOG(SVC, "called");
179 Handle handle = Kernel::CreateAddressArbiter(); 179 Handle handle = Kernel::CreateAddressArbiter();
180 *arbiter = handle; 180 *arbiter = handle;
@@ -182,20 +182,20 @@ Result CreateAddressArbiter(u32* arbiter) {
182} 182}
183 183
184/// Arbitrate address 184/// Arbitrate address
185Result ArbitrateAddress(Handle arbiter, u32 address, u32 type, u32 value, s64 nanoseconds) { 185static Result ArbitrateAddress(Handle arbiter, u32 address, u32 type, u32 value, s64 nanoseconds) {
186 return Kernel::ArbitrateAddress(arbiter, static_cast<Kernel::ArbitrationType>(type), address, 186 return Kernel::ArbitrateAddress(arbiter, static_cast<Kernel::ArbitrationType>(type), address,
187 value); 187 value);
188} 188}
189 189
190/// Used to output a message on a debug hardware unit - does nothing on a retail unit 190/// Used to output a message on a debug hardware unit - does nothing on a retail unit
191void OutputDebugString(const char* string) { 191static void OutputDebugString(const char* string) {
192 OS_LOG(SVC, "%s", string); 192 OS_LOG(SVC, "%s", string);
193} 193}
194 194
195/// Get resource limit 195/// Get resource limit
196Result GetResourceLimit(Handle* resource_limit, Handle process) { 196static Result GetResourceLimit(Handle* resource_limit, Handle process) {
197 // With regards to proceess values: 197 // With regards to proceess values:
198 // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for 198 // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for
199 // the current KThread. 199 // the current KThread.
200 *resource_limit = 0xDEADBEEF; 200 *resource_limit = 0xDEADBEEF;
201 ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process); 201 ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process);
@@ -203,7 +203,7 @@ Result GetResourceLimit(Handle* resource_limit, Handle process) {
203} 203}
204 204
205/// Get resource limit current values 205/// Get resource limit current values
206Result GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names, 206static Result GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names,
207 s32 name_count) { 207 s32 name_count) {
208 ERROR_LOG(SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%s, name_count=%d", 208 ERROR_LOG(SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%s, name_count=%d",
209 resource_limit, names, name_count); 209 resource_limit, names, name_count);
@@ -212,7 +212,7 @@ Result GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* n
212} 212}
213 213
214/// Creates a new thread 214/// Creates a new thread
215Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 processor_id) { 215static Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 processor_id) {
216 std::string name; 216 std::string name;
217 if (Symbols::HasSymbol(entry_point)) { 217 if (Symbols::HasSymbol(entry_point)) {
218 TSymbol symbol = Symbols::GetSymbol(entry_point); 218 TSymbol symbol = Symbols::GetSymbol(entry_point);
@@ -227,14 +227,14 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p
227 Core::g_app_core->SetReg(1, thread); 227 Core::g_app_core->SetReg(1, thread);
228 228
229 DEBUG_LOG(SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " 229 DEBUG_LOG(SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, "
230 "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, 230 "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point,
231 name.c_str(), arg, stack_top, priority, processor_id, thread); 231 name.c_str(), arg, stack_top, priority, processor_id, thread);
232 232
233 return 0; 233 return 0;
234} 234}
235 235
236/// Called when a thread exits 236/// Called when a thread exits
237u32 ExitThread() { 237static u32 ExitThread() {
238 Handle thread = Kernel::GetCurrentThreadHandle(); 238 Handle thread = Kernel::GetCurrentThreadHandle();
239 239
240 DEBUG_LOG(SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); // PC = 0x0010545C 240 DEBUG_LOG(SVC, "called, pc=0x%08X", Core::g_app_core->GetPC()); // PC = 0x0010545C
@@ -245,26 +245,26 @@ u32 ExitThread() {
245} 245}
246 246
247/// Gets the priority for the specified thread 247/// Gets the priority for the specified thread
248Result GetThreadPriority(s32* priority, Handle handle) { 248static Result GetThreadPriority(s32* priority, Handle handle) {
249 *priority = Kernel::GetThreadPriority(handle); 249 *priority = Kernel::GetThreadPriority(handle);
250 return 0; 250 return 0;
251} 251}
252 252
253/// Sets the priority for the specified thread 253/// Sets the priority for the specified thread
254Result SetThreadPriority(Handle handle, s32 priority) { 254static Result SetThreadPriority(Handle handle, s32 priority) {
255 return Kernel::SetThreadPriority(handle, priority); 255 return Kernel::SetThreadPriority(handle, priority);
256} 256}
257 257
258/// Create a mutex 258/// Create a mutex
259Result CreateMutex(Handle* mutex, u32 initial_locked) { 259static Result CreateMutex(Handle* mutex, u32 initial_locked) {
260 *mutex = Kernel::CreateMutex((initial_locked != 0)); 260 *mutex = Kernel::CreateMutex((initial_locked != 0));
261 DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", 261 DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X",
262 initial_locked ? "true" : "false", *mutex); 262 initial_locked ? "true" : "false", *mutex);
263 return 0; 263 return 0;
264} 264}
265 265
266/// Release a mutex 266/// Release a mutex
267Result ReleaseMutex(Handle handle) { 267static Result ReleaseMutex(Handle handle) {
268 DEBUG_LOG(SVC, "called handle=0x%08X", handle); 268 DEBUG_LOG(SVC, "called handle=0x%08X", handle);
269 _assert_msg_(KERNEL, (handle != 0), "called, but handle is nullptr!"); 269 _assert_msg_(KERNEL, (handle != 0), "called, but handle is nullptr!");
270 Kernel::ReleaseMutex(handle); 270 Kernel::ReleaseMutex(handle);
@@ -272,27 +272,27 @@ Result ReleaseMutex(Handle handle) {
272} 272}
273 273
274/// Get current thread ID 274/// Get current thread ID
275Result GetThreadId(u32* thread_id, Handle thread) { 275static Result GetThreadId(u32* thread_id, Handle thread) {
276 ERROR_LOG(SVC, "(UNIMPLEMENTED) called thread=0x%08X", thread); 276 ERROR_LOG(SVC, "(UNIMPLEMENTED) called thread=0x%08X", thread);
277 return 0; 277 return 0;
278} 278}
279 279
280/// Query memory 280/// Query memory
281Result QueryMemory(void* info, void* out, u32 addr) { 281static Result QueryMemory(void* info, void* out, u32 addr) {
282 ERROR_LOG(SVC, "(UNIMPLEMENTED) called addr=0x%08X", addr); 282 ERROR_LOG(SVC, "(UNIMPLEMENTED) called addr=0x%08X", addr);
283 return 0; 283 return 0;
284} 284}
285 285
286/// Create an event 286/// Create an event
287Result CreateEvent(Handle* evt, u32 reset_type) { 287static Result CreateEvent(Handle* evt, u32 reset_type) {
288 *evt = Kernel::CreateEvent((ResetType)reset_type); 288 *evt = Kernel::CreateEvent((ResetType)reset_type);
289 DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", 289 DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X",
290 reset_type, *evt); 290 reset_type, *evt);
291 return 0; 291 return 0;
292} 292}
293 293
294/// Duplicates a kernel handle 294/// Duplicates a kernel handle
295Result DuplicateHandle(Handle* out, Handle handle) { 295static Result DuplicateHandle(Handle* out, Handle handle) {
296 DEBUG_LOG(SVC, "called handle=0x%08X", handle); 296 DEBUG_LOG(SVC, "called handle=0x%08X", handle);
297 297
298 // Translate kernel handles -> real handles 298 // Translate kernel handles -> real handles
@@ -301,7 +301,7 @@ Result DuplicateHandle(Handle* out, Handle handle) {
301 } 301 }
302 _assert_msg_(KERNEL, (handle != Kernel::CurrentProcess), 302 _assert_msg_(KERNEL, (handle != Kernel::CurrentProcess),
303 "(UNIMPLEMENTED) process handle duplication!"); 303 "(UNIMPLEMENTED) process handle duplication!");
304 304
305 // TODO(bunnei): FixMe - This is a hack to return the handle that we were asked to duplicate. 305 // TODO(bunnei): FixMe - This is a hack to return the handle that we were asked to duplicate.
306 *out = handle; 306 *out = handle;
307 307
@@ -309,26 +309,26 @@ Result DuplicateHandle(Handle* out, Handle handle) {
309} 309}
310 310
311/// Signals an event 311/// Signals an event
312Result SignalEvent(Handle evt) { 312static Result SignalEvent(Handle evt) {
313 Result res = Kernel::SignalEvent(evt); 313 Result res = Kernel::SignalEvent(evt);
314 DEBUG_LOG(SVC, "called event=0x%08X", evt); 314 DEBUG_LOG(SVC, "called event=0x%08X", evt);
315 return res; 315 return res;
316} 316}
317 317
318/// Clears an event 318/// Clears an event
319Result ClearEvent(Handle evt) { 319static Result ClearEvent(Handle evt) {
320 Result res = Kernel::ClearEvent(evt); 320 Result res = Kernel::ClearEvent(evt);
321 DEBUG_LOG(SVC, "called event=0x%08X", evt); 321 DEBUG_LOG(SVC, "called event=0x%08X", evt);
322 return res; 322 return res;
323} 323}
324 324
325/// Sleep the current thread 325/// Sleep the current thread
326void SleepThread(s64 nanoseconds) { 326static void SleepThread(s64 nanoseconds) {
327 DEBUG_LOG(SVC, "called nanoseconds=%lld", nanoseconds); 327 DEBUG_LOG(SVC, "called nanoseconds=%lld", nanoseconds);
328} 328}
329 329
330/// This returns the total CPU ticks elapsed since the CPU was powered-on 330/// This returns the total CPU ticks elapsed since the CPU was powered-on
331s64 GetSystemTick() { 331static s64 GetSystemTick() {
332 return (s64)Core::g_app_core->GetTicks(); 332 return (s64)Core::g_app_core->GetTicks();
333} 333}
334 334
diff --git a/src/core/hle/svc.h b/src/core/hle/svc.h
index 1d125faf6..6be393d0b 100644
--- a/src/core/hle/svc.h
+++ b/src/core/hle/svc.h
@@ -1,6 +1,6 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#pragma once 5#pragma once
6 6
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp
index 33f75c50a..4d0719263 100644
--- a/src/core/hw/hw.cpp
+++ b/src/core/hw/hw.cpp
@@ -39,7 +39,7 @@ enum {
39template <typename T> 39template <typename T>
40inline void Read(T &var, const u32 addr) { 40inline void Read(T &var, const u32 addr) {
41 switch (addr & 0xFFFFF000) { 41 switch (addr & 0xFFFFF000) {
42 42
43 // TODO(bunnei): What is the virtual address of NDMA? 43 // TODO(bunnei): What is the virtual address of NDMA?
44 // case VADDR_NDMA: 44 // case VADDR_NDMA:
45 // NDMA::Read(var, addr); 45 // NDMA::Read(var, addr);
@@ -57,9 +57,9 @@ inline void Read(T &var, const u32 addr) {
57template <typename T> 57template <typename T>
58inline void Write(u32 addr, const T data) { 58inline void Write(u32 addr, const T data) {
59 switch (addr & 0xFFFFF000) { 59 switch (addr & 0xFFFFF000) {
60 60
61 // TODO(bunnei): What is the virtual address of NDMA? 61 // TODO(bunnei): What is the virtual address of NDMA?
62 // case VADDR_NDMA 62 // case VADDR_NDMA
63 // NDMA::Write(addr, data); 63 // NDMA::Write(addr, data);
64 // break; 64 // break;
65 65
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 389d5a8c9..63d2496ed 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -273,13 +273,13 @@ bool ElfReader::LoadInto(u32 vaddr) {
273 273
274 for (int i = 0; i < header->e_phnum; i++) { 274 for (int i = 0; i < header->e_phnum; i++) {
275 Elf32_Phdr *p = segments + i; 275 Elf32_Phdr *p = segments + i;
276 INFO_LOG(MASTER_LOG, "Type: %i Vaddr: %08x Filesz: %i Memsz: %i ", p->p_type, p->p_vaddr, 276 INFO_LOG(MASTER_LOG, "Type: %i Vaddr: %08x Filesz: %i Memsz: %i ", p->p_type, p->p_vaddr,
277 p->p_filesz, p->p_memsz); 277 p->p_filesz, p->p_memsz);
278 278
279 if (p->p_type == PT_LOAD) { 279 if (p->p_type == PT_LOAD) {
280 segment_addr[i] = base_addr + p->p_vaddr; 280 segment_addr[i] = base_addr + p->p_vaddr;
281 memcpy(Memory::GetPointer(segment_addr[i]), GetSegmentPtr(i), p->p_filesz); 281 memcpy(Memory::GetPointer(segment_addr[i]), GetSegmentPtr(i), p->p_filesz);
282 INFO_LOG(MASTER_LOG, "Loadable Segment Copied to %08x, size %08x", segment_addr[i], 282 INFO_LOG(MASTER_LOG, "Loadable Segment Copied to %08x, size %08x", segment_addr[i],
283 p->p_memsz); 283 p->p_memsz);
284 } 284 }
285 } 285 }
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 1e5501e6d..343bb7523 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -24,7 +24,7 @@ static const int kBlockSize = 0x200; ///< Size of ExeFS blocks (in bytes)
24 * @param size Size of compressed buffer 24 * @param size Size of compressed buffer
25 * @return Size of decompressed buffer 25 * @return Size of decompressed buffer
26 */ 26 */
27u32 LZSS_GetDecompressedSize(u8* buffer, u32 size) { 27static u32 LZSS_GetDecompressedSize(u8* buffer, u32 size) {
28 u32 offset_size = *(u32*)(buffer + size - 4); 28 u32 offset_size = *(u32*)(buffer + size - 4);
29 return offset_size + size; 29 return offset_size + size;
30} 30}
@@ -37,7 +37,7 @@ u32 LZSS_GetDecompressedSize(u8* buffer, u32 size) {
37 * @param decompressed_size Size of decompressed buffer 37 * @param decompressed_size Size of decompressed buffer
38 * @return True on success, otherwise false 38 * @return True on success, otherwise false
39 */ 39 */
40bool LZSS_Decompress(u8* compressed, u32 compressed_size, u8* decompressed, u32 decompressed_size) { 40static bool LZSS_Decompress(u8* compressed, u32 compressed_size, u8* decompressed, u32 decompressed_size) {
41 u8* footer = compressed + compressed_size - 8; 41 u8* footer = compressed + compressed_size - 8;
42 u32 buffer_top_and_bottom = *(u32*)footer; 42 u32 buffer_top_and_bottom = *(u32*)footer;
43 u32 out = decompressed_size; 43 u32 out = decompressed_size;
@@ -118,7 +118,7 @@ AppLoader_NCCH::~AppLoader_NCCH() {
118 * @return ResultStatus result of function 118 * @return ResultStatus result of function
119 */ 119 */
120ResultStatus AppLoader_NCCH::LoadExec() const { 120ResultStatus AppLoader_NCCH::LoadExec() const {
121 if (!is_loaded) 121 if (!is_loaded)
122 return ResultStatus::ErrorNotLoaded; 122 return ResultStatus::ErrorNotLoaded;
123 123
124 std::vector<u8> code; 124 std::vector<u8> code;
@@ -185,7 +185,7 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>&
185 return ResultStatus::Error; 185 return ResultStatus::Error;
186 } 186 }
187 return ResultStatus::ErrorNotUsed; 187 return ResultStatus::ErrorNotUsed;
188} 188}
189 189
190/** 190/**
191 * Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI) 191 * Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI)
@@ -210,7 +210,7 @@ ResultStatus AppLoader_NCCH::Load() {
210 file.Seek(ncch_offset, 0); 210 file.Seek(ncch_offset, 0);
211 file.ReadBytes(&ncch_header, sizeof(NCCH_Header)); 211 file.ReadBytes(&ncch_header, sizeof(NCCH_Header));
212 } 212 }
213 213
214 // Verify we are loading the correct file type... 214 // Verify we are loading the correct file type...
215 if (0 != memcmp(&ncch_header.magic, "NCCH", 4)) 215 if (0 != memcmp(&ncch_header.magic, "NCCH", 4))
216 return ResultStatus::ErrorInvalidFormat; 216 return ResultStatus::ErrorInvalidFormat;
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index f40a258b7..03116add8 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -215,7 +215,7 @@ private:
215 u32 entry_point; 215 u32 entry_point;
216 u32 ncch_offset; // Offset to NCCH header, can be 0 or after NCSD header 216 u32 ncch_offset; // Offset to NCCH header, can be 0 or after NCSD header
217 u32 exefs_offset; 217 u32 exefs_offset;
218 218
219 NCCH_Header ncch_header; 219 NCCH_Header ncch_header;
220 ExeFs_Header exefs_header; 220 ExeFs_Header exefs_header;
221 ExHeader_Header exheader_header; 221 ExHeader_Header exheader_header;
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.h b/src/core/mem_map.h
index 87de5cd63..a58c59244 100644
--- a/src/core/mem_map.h
+++ b/src/core/mem_map.h
@@ -157,7 +157,7 @@ u8* GetPointer(VAddr virtual_address);
157 * Maps a block of memory on the heap 157 * Maps a block of memory on the heap
158 * @param size Size of block in bytes 158 * @param size Size of block in bytes
159 * @param operation Memory map operation type 159 * @param operation Memory map operation type
160 * @param flags Memory allocation flags 160 * @param permissions Memory allocation permissions
161 */ 161 */
162u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions); 162u32 MapBlock_Heap(u32 size, u32 operation, u32 permissions);
163 163
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}
diff --git a/src/core/system.h b/src/core/system.h
index 8f8ddf87b..2bc2edc75 100644
--- a/src/core/system.h
+++ b/src/core/system.h
@@ -11,16 +11,16 @@
11namespace System { 11namespace System {
12 12
13// State of the full emulator 13// State of the full emulator
14typedef enum { 14enum State {
15 STATE_NULL = 0, ///< System is in null state, nothing initialized 15 STATE_NULL = 0, ///< System is in null state, nothing initialized
16 STATE_IDLE, ///< System is in an initialized state, but not running 16 STATE_IDLE, ///< System is in an initialized state, but not running
17 STATE_RUNNING, ///< System is running 17 STATE_RUNNING, ///< System is running
18 STATE_LOADING, ///< System is loading a ROM 18 STATE_LOADING, ///< System is loading a ROM
19 STATE_HALTED, ///< System is halted (error) 19 STATE_HALTED, ///< System is halted (error)
20 STATE_STALLED, ///< System is stalled (unused) 20 STATE_STALLED, ///< System is stalled (unused)
21 STATE_DEBUG, ///< System is in a special debug mode (unused) 21 STATE_DEBUG, ///< System is in a special debug mode (unused)
22 STATE_DIE ///< System is shutting down 22 STATE_DIE ///< System is shutting down
23} State; 23};
24 24
25extern volatile State g_state; 25extern volatile State g_state;
26 26
@@ -30,4 +30,4 @@ void RunLoopFor(int cycles);
30void RunLoopUntil(u64 global_cycles); 30void RunLoopUntil(u64 global_cycles);
31void Shutdown(); 31void Shutdown();
32 32
33}; 33}