summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/hle/kernel/kernel.h2
-rw-r--r--src/core/hle/lock.cpp11
-rw-r--r--src/core/hle/lock.h18
-rw-r--r--src/core/hle/svc.cpp8
5 files changed, 38 insertions, 3 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 360f407f3..14027e182 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -60,6 +60,7 @@ set(SRCS
60 hle/kernel/timer.cpp 60 hle/kernel/timer.cpp
61 hle/kernel/vm_manager.cpp 61 hle/kernel/vm_manager.cpp
62 hle/kernel/wait_object.cpp 62 hle/kernel/wait_object.cpp
63 hle/lock.cpp
63 hle/romfs.cpp 64 hle/romfs.cpp
64 hle/service/ac/ac.cpp 65 hle/service/ac/ac.cpp
65 hle/service/ac/ac_i.cpp 66 hle/service/ac/ac_i.cpp
@@ -258,6 +259,7 @@ set(HEADERS
258 hle/kernel/timer.h 259 hle/kernel/timer.h
259 hle/kernel/vm_manager.h 260 hle/kernel/vm_manager.h
260 hle/kernel/wait_object.h 261 hle/kernel/wait_object.h
262 hle/lock.h
261 hle/result.h 263 hle/result.h
262 hle/romfs.h 264 hle/romfs.h
263 hle/service/ac/ac.h 265 hle/service/ac/ac.h
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 9cf288b08..255cda359 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -129,4 +129,4 @@ void Init(u32 system_mode);
129/// Shutdown the kernel 129/// Shutdown the kernel
130void Shutdown(); 130void Shutdown();
131 131
132} // namespace 132} // namespace Kernel
diff --git a/src/core/hle/lock.cpp b/src/core/hle/lock.cpp
new file mode 100644
index 000000000..082f689c8
--- /dev/null
+++ b/src/core/hle/lock.cpp
@@ -0,0 +1,11 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <core/hle/lock.h>
8
9namespace HLE {
10std::mutex g_hle_lock;
11}
diff --git a/src/core/hle/lock.h b/src/core/hle/lock.h
new file mode 100644
index 000000000..8265621e1
--- /dev/null
+++ b/src/core/hle/lock.h
@@ -0,0 +1,18 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <mutex>
8
9namespace HLE {
10/*
11 * Synchronizes access to the internal HLE kernel structures, it is acquired when a guest
12 * application thread performs a syscall. It should be acquired by any host threads that read or
13 * modify the HLE kernel state. Note: Any operation that directly or indirectly reads from or writes
14 * to the emulated memory is not protected by this mutex, and should be avoided in any threads other
15 * than the CPU thread.
16 */
17extern std::mutex g_hle_lock;
18} // namespace HLE
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index e4b803046..b98938cb4 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -31,6 +31,7 @@
31#include "core/hle/kernel/timer.h" 31#include "core/hle/kernel/timer.h"
32#include "core/hle/kernel/vm_manager.h" 32#include "core/hle/kernel/vm_manager.h"
33#include "core/hle/kernel/wait_object.h" 33#include "core/hle/kernel/wait_object.h"
34#include "core/hle/lock.h"
34#include "core/hle/result.h" 35#include "core/hle/result.h"
35#include "core/hle/service/service.h" 36#include "core/hle/service/service.h"
36 37
@@ -1188,7 +1189,7 @@ struct FunctionDef {
1188 Func* func; 1189 Func* func;
1189 const char* name; 1190 const char* name;
1190}; 1191};
1191} 1192} // namespace
1192 1193
1193static const FunctionDef SVC_Table[] = { 1194static const FunctionDef SVC_Table[] = {
1194 {0x00, nullptr, "Unknown"}, 1195 {0x00, nullptr, "Unknown"},
@@ -1332,6 +1333,9 @@ MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70));
1332void CallSVC(u32 immediate) { 1333void CallSVC(u32 immediate) {
1333 MICROPROFILE_SCOPE(Kernel_SVC); 1334 MICROPROFILE_SCOPE(Kernel_SVC);
1334 1335
1336 // Lock the global kernel mutex when we enter the kernel HLE.
1337 std::lock_guard<std::mutex> lock(HLE::g_hle_lock);
1338
1335 const FunctionDef* info = GetSVCInfo(immediate); 1339 const FunctionDef* info = GetSVCInfo(immediate);
1336 if (info) { 1340 if (info) {
1337 if (info->func) { 1341 if (info->func) {
@@ -1342,4 +1346,4 @@ void CallSVC(u32 immediate) {
1342 } 1346 }
1343} 1347}
1344 1348
1345} // namespace 1349} // namespace SVC