summaryrefslogtreecommitdiff
path: root/src/core/hle/function_wrappers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/function_wrappers.h')
-rw-r--r--src/core/hle/function_wrappers.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h
index 23c86a72d..5949cb470 100644
--- a/src/core/hle/function_wrappers.h
+++ b/src/core/hle/function_wrappers.h
@@ -9,11 +9,15 @@
9#include "core/arm/arm_interface.h" 9#include "core/arm/arm_interface.h"
10#include "core/memory.h" 10#include "core/memory.h"
11#include "core/hle/hle.h" 11#include "core/hle/hle.h"
12#include "core/hle/result.h"
12 13
13namespace HLE { 14namespace HLE {
14 15
15#define PARAM(n) Core::g_app_core->GetReg(n) 16#define PARAM(n) Core::g_app_core->GetReg(n)
16 17
18/// An invalid result code that is meant to be overwritten when a thread resumes from waiting
19static const ResultCode RESULT_INVALID(0xDEADC0DE);
20
17/** 21/**
18 * HLE a function return from the current ARM11 userland process 22 * HLE a function return from the current ARM11 userland process
19 * @param res Result to return 23 * @param res Result to return
@@ -57,8 +61,11 @@ template<ResultCode func(s32*, u32*, s32, bool, s64)> void Wrap() {
57 s32 param_1 = 0; 61 s32 param_1 = 0;
58 s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), 62 s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
59 (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))).raw; 63 (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))).raw;
60 Core::g_app_core->SetReg(1, (u32)param_1); 64
61 FuncReturn(retval); 65 if (retval != RESULT_INVALID.raw) {
66 Core::g_app_core->SetReg(1, (u32)param_1);
67 FuncReturn(retval);
68 }
62} 69}
63 70
64template<ResultCode func(u32, u32, u32, u32, s64)> void Wrap() { 71template<ResultCode func(u32, u32, u32, u32, s64)> void Wrap() {
@@ -73,7 +80,11 @@ template<ResultCode func(u32*)> void Wrap(){
73} 80}
74 81
75template<ResultCode func(u32, s64)> void Wrap() { 82template<ResultCode func(u32, s64)> void Wrap() {
76 FuncReturn(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))).raw); 83 s32 retval = func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))).raw;
84
85 if (retval != RESULT_INVALID.raw) {
86 FuncReturn(retval);
87 }
77} 88}
78 89
79template<ResultCode func(void*, void*, u32)> void Wrap(){ 90template<ResultCode func(void*, void*, u32)> void Wrap(){