summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/config_mem.cpp5
-rw-r--r--src/core/hle/config_mem.h2
-rw-r--r--src/core/hle/hle.cpp9
-rw-r--r--src/core/hle/kernel/kernel.cpp11
-rw-r--r--src/core/hle/kernel/kernel.h5
-rw-r--r--src/core/hle/kernel/thread.cpp10
-rw-r--r--src/core/hle/kernel/timer.cpp3
-rw-r--r--src/core/hle/service/apt/apt.cpp17
-rw-r--r--src/core/hle/service/cfg/cfg.cpp2
-rw-r--r--src/core/hle/service/dsp_dsp.cpp2
-rw-r--r--src/core/hle/service/hid/hid.cpp22
-rw-r--r--src/core/hle/service/ir/ir.cpp6
-rw-r--r--src/core/hle/service/nwm_uds.cpp2
-rw-r--r--src/core/hle/service/ptm/ptm.cpp7
-rw-r--r--src/core/hle/service/y2r_u.cpp2
-rw-r--r--src/core/hle/shared_page.cpp5
-rw-r--r--src/core/hle/shared_page.h2
17 files changed, 78 insertions, 34 deletions
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp
index 30d73adac..9fcfcc285 100644
--- a/src/core/hle/config_mem.cpp
+++ b/src/core/hle/config_mem.cpp
@@ -61,6 +61,8 @@ template void Read<u16>(u16 &var, const u32 addr);
61template void Read<u8>(u8 &var, const u32 addr); 61template void Read<u8>(u8 &var, const u32 addr);
62 62
63void Init() { 63void Init() {
64 memset(&config_mem, 0, sizeof(config_mem));
65
64 config_mem.update_flag = 0; // No update 66 config_mem.update_flag = 0; // No update
65 config_mem.sys_core_ver = 0x2; 67 config_mem.sys_core_ver = 0x2;
66 config_mem.unit_info = 0x1; // Bit 0 set for Retail 68 config_mem.unit_info = 0x1; // Bit 0 set for Retail
@@ -76,4 +78,7 @@ void Init() {
76 config_mem.firm_sys_core_ver = 0x2; 78 config_mem.firm_sys_core_ver = 0x2;
77} 79}
78 80
81void Shutdown() {
82}
83
79} // namespace 84} // namespace
diff --git a/src/core/hle/config_mem.h b/src/core/hle/config_mem.h
index 94853901a..cbb478fb3 100644
--- a/src/core/hle/config_mem.h
+++ b/src/core/hle/config_mem.h
@@ -20,4 +20,6 @@ void Read(T &var, const u32 addr);
20 20
21void Init(); 21void Init();
22 22
23void Shutdown();
24
23} // namespace 25} // namespace
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp
index c645d6563..191d0411e 100644
--- a/src/core/hle/hle.cpp
+++ b/src/core/hle/hle.cpp
@@ -23,7 +23,7 @@ Common::Profiling::TimingCategory profiler_svc("SVC Calls");
23 23
24static std::vector<ModuleDef> g_module_db; 24static std::vector<ModuleDef> g_module_db;
25 25
26bool g_reschedule = false; ///< If true, immediately reschedules the CPU to a new thread 26bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread
27 27
28static const FunctionDef* GetSVCInfo(u32 opcode) { 28static const FunctionDef* GetSVCInfo(u32 opcode) {
29 u32 func_num = opcode & 0xFFFFFF; // 8 bits 29 u32 func_num = opcode & 0xFFFFFF; // 8 bits
@@ -73,17 +73,20 @@ static void RegisterAllModules() {
73} 73}
74 74
75void Init() { 75void Init() {
76 Service::Init();
77
78 RegisterAllModules(); 76 RegisterAllModules();
79 77
78 Service::Init();
80 ConfigMem::Init(); 79 ConfigMem::Init();
81 SharedPage::Init(); 80 SharedPage::Init();
82 81
82 g_reschedule = false;
83
83 LOG_DEBUG(Kernel, "initialized OK"); 84 LOG_DEBUG(Kernel, "initialized OK");
84} 85}
85 86
86void Shutdown() { 87void Shutdown() {
88 ConfigMem::Shutdown();
89 SharedPage::Shutdown();
87 Service::Shutdown(); 90 Service::Shutdown();
88 91
89 g_module_db.clear(); 92 g_module_db.clear();
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 6261b82b6..fca582bbe 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -14,11 +14,10 @@
14 14
15namespace Kernel { 15namespace Kernel {
16 16
17unsigned int Object::next_object_id = 0; 17unsigned int Object::next_object_id;
18 18SharedPtr<Thread> g_main_thread;
19SharedPtr<Thread> g_main_thread = nullptr;
20HandleTable g_handle_table; 19HandleTable g_handle_table;
21u64 g_program_id = 0; 20u64 g_program_id;
22 21
23void WaitObject::AddWaitingThread(SharedPtr<Thread> thread) { 22void WaitObject::AddWaitingThread(SharedPtr<Thread> thread) {
24 auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); 23 auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread);
@@ -138,6 +137,10 @@ void HandleTable::Clear() {
138void Init() { 137void Init() {
139 Kernel::ThreadingInit(); 138 Kernel::ThreadingInit();
140 Kernel::TimersInit(); 139 Kernel::TimersInit();
140
141 Object::next_object_id = 0;
142 g_program_id = 0;
143 g_main_thread = nullptr;
141} 144}
142 145
143/// Shutdown the kernel 146/// Shutdown the kernel
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 2d295ea00..ab06fa025 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -95,12 +95,13 @@ public:
95 return false; 95 return false;
96 } 96 }
97 97
98public:
99 static unsigned int next_object_id;
100
98private: 101private:
99 friend void intrusive_ptr_add_ref(Object*); 102 friend void intrusive_ptr_add_ref(Object*);
100 friend void intrusive_ptr_release(Object*); 103 friend void intrusive_ptr_release(Object*);
101 104
102 static unsigned int next_object_id;
103
104 unsigned int ref_count = 0; 105 unsigned int ref_count = 0;
105 unsigned int object_id = next_object_id++; 106 unsigned int object_id = next_object_id++;
106}; 107};
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 33d66b986..d678f5f6f 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -23,7 +23,7 @@
23namespace Kernel { 23namespace Kernel {
24 24
25/// Event type for the thread wake up event 25/// Event type for the thread wake up event
26static int ThreadWakeupEventType = -1; 26static int ThreadWakeupEventType;
27 27
28bool Thread::ShouldWait() { 28bool Thread::ShouldWait() {
29 return status != THREADSTATUS_DEAD; 29 return status != THREADSTATUS_DEAD;
@@ -42,7 +42,7 @@ static Common::ThreadQueueList<Thread*, THREADPRIO_LOWEST+1> ready_queue;
42static Thread* current_thread; 42static Thread* current_thread;
43 43
44// The first available thread id at startup 44// The first available thread id at startup
45static u32 next_thread_id = 1; 45static u32 next_thread_id;
46 46
47/** 47/**
48 * Creates a new thread ID 48 * Creates a new thread ID
@@ -497,6 +497,12 @@ void Thread::SetWaitSynchronizationOutput(s32 output) {
497void ThreadingInit() { 497void ThreadingInit() {
498 ThreadWakeupEventType = CoreTiming::RegisterEvent("ThreadWakeupCallback", ThreadWakeupCallback); 498 ThreadWakeupEventType = CoreTiming::RegisterEvent("ThreadWakeupCallback", ThreadWakeupCallback);
499 499
500 current_thread = nullptr;
501 next_thread_id = 1;
502
503 thread_list.clear();
504 ready_queue.clear();
505
500 // Setup the idle thread 506 // Setup the idle thread
501 SetupIdleThread(); 507 SetupIdleThread();
502} 508}
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp
index 1ec2a4b10..36979248d 100644
--- a/src/core/hle/kernel/timer.cpp
+++ b/src/core/hle/kernel/timer.cpp
@@ -12,7 +12,7 @@
12namespace Kernel { 12namespace Kernel {
13 13
14/// The event type of the generic timer callback event 14/// The event type of the generic timer callback event
15static int timer_callback_event_type = -1; 15static int timer_callback_event_type;
16// TODO(yuriks): This can be removed if Timer objects are explicitly pooled in the future, allowing 16// TODO(yuriks): This can be removed if Timer objects are explicitly pooled in the future, allowing
17// us to simply use a pool index or similar. 17// us to simply use a pool index or similar.
18static Kernel::HandleTable timer_callback_handle_table; 18static Kernel::HandleTable timer_callback_handle_table;
@@ -89,6 +89,7 @@ static void TimerCallback(u64 timer_handle, int cycles_late) {
89} 89}
90 90
91void TimersInit() { 91void TimersInit() {
92 timer_callback_handle_table.Clear();
92 timer_callback_event_type = CoreTiming::RegisterEvent("TimerCallback", TimerCallback); 93 timer_callback_event_type = CoreTiming::RegisterEvent("TimerCallback", TimerCallback);
93} 94}
94 95
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 190c5df7a..98ae80b3a 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -28,15 +28,15 @@ namespace APT {
28static const VAddr SHARED_FONT_VADDR = 0x18000000; 28static const VAddr SHARED_FONT_VADDR = 0x18000000;
29 29
30/// Handle to shared memory region designated to for shared system font 30/// Handle to shared memory region designated to for shared system font
31static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem = nullptr; 31static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem;
32 32
33static Kernel::SharedPtr<Kernel::Mutex> lock = nullptr; 33static Kernel::SharedPtr<Kernel::Mutex> lock;
34static Kernel::SharedPtr<Kernel::Event> notification_event = nullptr; ///< APT notification event 34static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event
35static Kernel::SharedPtr<Kernel::Event> start_event = nullptr; ///< APT start event 35static Kernel::SharedPtr<Kernel::Event> start_event; ///< APT start event
36 36
37static std::vector<u8> shared_font; 37static std::vector<u8> shared_font;
38 38
39static u32 cpu_percent = 0; ///< CPU time available to the running application 39static u32 cpu_percent; ///< CPU time available to the running application
40 40
41void Initialize(Service::Interface* self) { 41void Initialize(Service::Interface* self) {
42 u32* cmd_buff = Kernel::GetCommandBuffer(); 42 u32* cmd_buff = Kernel::GetCommandBuffer();
@@ -309,6 +309,7 @@ void Init() {
309 } 309 }
310 310
311 lock = Kernel::Mutex::Create(false, "APT_U:Lock"); 311 lock = Kernel::Mutex::Create(false, "APT_U:Lock");
312
312 cpu_percent = 0; 313 cpu_percent = 0;
313 314
314 // TODO(bunnei): Check if these are created in Initialize or on APT process startup. 315 // TODO(bunnei): Check if these are created in Initialize or on APT process startup.
@@ -317,7 +318,11 @@ void Init() {
317} 318}
318 319
319void Shutdown() { 320void Shutdown() {
320 321 shared_font.clear();
322 shared_font_mem = nullptr;
323 lock = nullptr;
324 notification_event = nullptr;
325 start_event = nullptr;
321} 326}
322 327
323} // namespace APT 328} // namespace APT
diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp
index 6af0352ac..5eccdecf7 100644
--- a/src/core/hle/service/cfg/cfg.cpp
+++ b/src/core/hle/service/cfg/cfg.cpp
@@ -207,6 +207,7 @@ void Init() {
207 207
208 // Initialize the Username block 208 // Initialize the Username block
209 // TODO(Subv): Initialize this directly in the variable when MSVC supports char16_t string literals 209 // TODO(Subv): Initialize this directly in the variable when MSVC supports char16_t string literals
210 memset(&CONSOLE_USERNAME_BLOCK, 0, sizeof(CONSOLE_USERNAME_BLOCK));
210 CONSOLE_USERNAME_BLOCK.ng_word = 0; 211 CONSOLE_USERNAME_BLOCK.ng_word = 0;
211 CONSOLE_USERNAME_BLOCK.zero = 0; 212 CONSOLE_USERNAME_BLOCK.zero = 0;
212 213
@@ -219,7 +220,6 @@ void Init() {
219} 220}
220 221
221void Shutdown() { 222void Shutdown() {
222
223} 223}
224 224
225} // namespace CFG 225} // namespace CFG
diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp
index 4d6c70f4d..2e759a3e3 100644
--- a/src/core/hle/service/dsp_dsp.cpp
+++ b/src/core/hle/service/dsp_dsp.cpp
@@ -11,7 +11,7 @@
11 11
12namespace DSP_DSP { 12namespace DSP_DSP {
13 13
14static u32 read_pipe_count = 0; 14static u32 read_pipe_count;
15static Kernel::SharedPtr<Kernel::Event> semaphore_event; 15static Kernel::SharedPtr<Kernel::Event> semaphore_event;
16static Kernel::SharedPtr<Kernel::Event> interrupt_event; 16static Kernel::SharedPtr<Kernel::Event> interrupt_event;
17 17
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 9ca5d13d4..0f30f743a 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -20,17 +20,17 @@ namespace HID {
20static const int MAX_CIRCLEPAD_POS = 0x9C; ///< Max value for a circle pad position 20static const int MAX_CIRCLEPAD_POS = 0x9C; ///< Max value for a circle pad position
21 21
22// Handle to shared memory region designated to HID_User service 22// Handle to shared memory region designated to HID_User service
23static Kernel::SharedPtr<Kernel::SharedMemory> shared_mem = nullptr; 23static Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;
24 24
25// Event handles 25// Event handles
26static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_1 = nullptr; 26static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_1;
27static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_2 = nullptr; 27static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_2;
28static Kernel::SharedPtr<Kernel::Event> event_accelerometer = nullptr; 28static Kernel::SharedPtr<Kernel::Event> event_accelerometer;
29static Kernel::SharedPtr<Kernel::Event> event_gyroscope = nullptr; 29static Kernel::SharedPtr<Kernel::Event> event_gyroscope;
30static Kernel::SharedPtr<Kernel::Event> event_debug_pad = nullptr; 30static Kernel::SharedPtr<Kernel::Event> event_debug_pad;
31 31
32static u32 next_pad_index = 0; 32static u32 next_pad_index;
33static u32 next_touch_index = 0; 33static u32 next_touch_index;
34 34
35// TODO(peachum): 35// TODO(peachum):
36// Add a method for setting analog input from joystick device for the circle Pad. 36// Add a method for setting analog input from joystick device for the circle Pad.
@@ -175,6 +175,12 @@ void Init() {
175} 175}
176 176
177void Shutdown() { 177void Shutdown() {
178 shared_mem = nullptr;
179 event_pad_or_touch_1 = nullptr;
180 event_pad_or_touch_2 = nullptr;
181 event_accelerometer = nullptr;
182 event_gyroscope = nullptr;
183 event_debug_pad = nullptr;
178} 184}
179 185
180} // namespace HID 186} // namespace HID
diff --git a/src/core/hle/service/ir/ir.cpp b/src/core/hle/service/ir/ir.cpp
index 58dfd8e1a..15ac477ef 100644
--- a/src/core/hle/service/ir/ir.cpp
+++ b/src/core/hle/service/ir/ir.cpp
@@ -15,8 +15,8 @@
15namespace Service { 15namespace Service {
16namespace IR { 16namespace IR {
17 17
18static Kernel::SharedPtr<Kernel::Event> handle_event = nullptr; 18static Kernel::SharedPtr<Kernel::Event> handle_event;
19static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr; 19static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory;
20 20
21void GetHandles(Service::Interface* self) { 21void GetHandles(Service::Interface* self) {
22 u32* cmd_buff = Kernel::GetCommandBuffer(); 22 u32* cmd_buff = Kernel::GetCommandBuffer();
@@ -41,6 +41,8 @@ void Init() {
41} 41}
42 42
43void Shutdown() { 43void Shutdown() {
44 shared_memory = nullptr;
45 handle_event = nullptr;
44} 46}
45 47
46} // namespace IR 48} // namespace IR
diff --git a/src/core/hle/service/nwm_uds.cpp b/src/core/hle/service/nwm_uds.cpp
index 1cee81ab2..4b06efc3a 100644
--- a/src/core/hle/service/nwm_uds.cpp
+++ b/src/core/hle/service/nwm_uds.cpp
@@ -11,7 +11,7 @@
11 11
12namespace NWM_UDS { 12namespace NWM_UDS {
13 13
14static Kernel::SharedPtr<Kernel::Event> handle_event = nullptr; 14static Kernel::SharedPtr<Kernel::Event> handle_event;
15 15
16/** 16/**
17 * NWM_UDS::Shutdown service function 17 * NWM_UDS::Shutdown service function
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp
index 57a301bec..d44510c1b 100644
--- a/src/core/hle/service/ptm/ptm.cpp
+++ b/src/core/hle/service/ptm/ptm.cpp
@@ -18,9 +18,9 @@ static const GameCoin default_game_coin = { 0x4F00, 42, 0, 0, 0, 2014, 12, 29 };
18/// Id of the SharedExtData archive used by the PTM process 18/// Id of the SharedExtData archive used by the PTM process
19static const std::vector<u8> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0}; 19static const std::vector<u8> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0};
20 20
21static bool shell_open = true; 21static bool shell_open;
22 22
23static bool battery_is_charging = true; 23static bool battery_is_charging;
24 24
25u32 GetAdapterState() { 25u32 GetAdapterState() {
26 // TODO(purpasmart96): This function is only a stub, 26 // TODO(purpasmart96): This function is only a stub,
@@ -43,6 +43,9 @@ void Init() {
43 AddService(new PTM_Sysm_Interface); 43 AddService(new PTM_Sysm_Interface);
44 AddService(new PTM_U_Interface); 44 AddService(new PTM_U_Interface);
45 45
46 shell_open = true;
47 battery_is_charging = true;
48
46 // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't exist 49 // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't exist
47 FileSys::Path archive_path(ptm_shared_extdata_id); 50 FileSys::Path archive_path(ptm_shared_extdata_id);
48 auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path); 51 auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp
index 6607965e1..33ecf64a2 100644
--- a/src/core/hle/service/y2r_u.cpp
+++ b/src/core/hle/service/y2r_u.cpp
@@ -11,7 +11,7 @@
11 11
12namespace Y2R_U { 12namespace Y2R_U {
13 13
14static Kernel::SharedPtr<Kernel::Event> completion_event = 0; 14static Kernel::SharedPtr<Kernel::Event> completion_event;
15 15
16/** 16/**
17 * Y2R_U::IsBusyConversion service function 17 * Y2R_U::IsBusyConversion service function
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp
index 568dad684..94fae2551 100644
--- a/src/core/hle/shared_page.cpp
+++ b/src/core/hle/shared_page.cpp
@@ -62,6 +62,8 @@ template void Read<u16>(u16 &var, const u32 addr);
62template void Read<u8>(u8 &var, const u32 addr); 62template void Read<u8>(u8 &var, const u32 addr);
63 63
64void Set3DSlider(float amount) { 64void Set3DSlider(float amount) {
65 memset(&shared_page, 0, sizeof(shared_page));
66
65 shared_page.sliderstate_3d = amount; 67 shared_page.sliderstate_3d = amount;
66 shared_page.ledstate_3d = (amount == 0.0f); // off when non-zero 68 shared_page.ledstate_3d = (amount == 0.0f); // off when non-zero
67} 69}
@@ -71,4 +73,7 @@ void Init() {
71 Set3DSlider(0.0f); 73 Set3DSlider(0.0f);
72} 74}
73 75
76void Shutdown() {
77}
78
74} // namespace 79} // namespace
diff --git a/src/core/hle/shared_page.h b/src/core/hle/shared_page.h
index 8f93545ec..1b6e4e581 100644
--- a/src/core/hle/shared_page.h
+++ b/src/core/hle/shared_page.h
@@ -23,4 +23,6 @@ void Set3DSlider(float amount);
23 23
24void Init(); 24void Init();
25 25
26void Shutdown();
27
26} // namespace 28} // namespace