2018-01-13 22:22:39 +01:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2014-12-17 06:38:14 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-06-07 05:31:29 +02:00
|
|
|
// Refer to the license.txt file included.
|
2014-04-11 01:58:28 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
2014-12-22 07:30:09 +01:00
|
|
|
#include "core/arm/arm_interface.h"
|
2016-09-20 17:21:23 +02:00
|
|
|
#include "core/core.h"
|
2015-06-08 05:39:37 +02:00
|
|
|
#include "core/hle/result.h"
|
2014-04-11 01:58:28 +02:00
|
|
|
|
2018-01-03 02:40:30 +01:00
|
|
|
namespace Kernel {
|
2014-04-11 01:58:28 +02:00
|
|
|
|
2018-09-18 10:25:35 +02:00
|
|
|
static inline u64 Param(int n) {
|
|
|
|
return Core::CurrentArmInterface().GetReg(n);
|
|
|
|
}
|
2014-08-15 02:01:02 +02:00
|
|
|
|
|
|
|
/**
|
2017-12-31 21:46:30 +01:00
|
|
|
* HLE a function return from the current ARM userland process
|
2014-08-15 02:01:02 +02:00
|
|
|
* @param res Result to return
|
|
|
|
*/
|
2017-08-29 03:09:42 +02:00
|
|
|
static inline void FuncReturn(u64 res) {
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(0, res);
|
2014-08-15 02:01:02 +02:00
|
|
|
}
|
|
|
|
|
2014-06-07 05:31:29 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2015-01-23 06:36:58 +01:00
|
|
|
// Function wrappers that return type ResultCode
|
2014-04-11 01:58:28 +02:00
|
|
|
|
2017-10-10 05:56:20 +02:00
|
|
|
template <ResultCode func(u64)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-09-18 10:25:35 +02:00
|
|
|
FuncReturn(func(Param(0)).raw);
|
2017-10-10 05:56:20 +02:00
|
|
|
}
|
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <ResultCode func(u32)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(func(static_cast<u32>(Param(0))).raw);
|
2017-12-29 03:38:38 +01:00
|
|
|
}
|
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <ResultCode func(u32, u32)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(func(static_cast<u32>(Param(0)), static_cast<u32>(Param(1))).raw);
|
2017-12-28 21:29:52 +01:00
|
|
|
}
|
|
|
|
|
2018-11-27 00:23:12 +01:00
|
|
|
template <ResultCode func(u32*)>
|
|
|
|
void SvcWrap() {
|
|
|
|
u32 param = 0;
|
|
|
|
const u32 retval = func(¶m).raw;
|
|
|
|
Core::CurrentArmInterface().SetReg(1, param);
|
|
|
|
FuncReturn(retval);
|
|
|
|
}
|
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <ResultCode func(u32*, u32)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2017-12-31 21:46:30 +01:00
|
|
|
u32 param_1 = 0;
|
2018-10-10 03:49:08 +02:00
|
|
|
u32 retval = func(¶m_1, static_cast<u32>(Param(1))).raw;
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
2017-12-28 21:29:52 +01:00
|
|
|
FuncReturn(retval);
|
2017-10-10 05:56:20 +02:00
|
|
|
}
|
|
|
|
|
2018-12-04 21:11:18 +01:00
|
|
|
template <ResultCode func(u32*, u32*)>
|
|
|
|
void SvcWrap() {
|
|
|
|
u32 param_1 = 0;
|
|
|
|
u32 param_2 = 0;
|
|
|
|
const u32 retval = func(¶m_1, ¶m_2).raw;
|
|
|
|
|
|
|
|
auto& arm_interface = Core::CurrentArmInterface();
|
|
|
|
arm_interface.SetReg(1, param_1);
|
|
|
|
arm_interface.SetReg(2, param_2);
|
|
|
|
|
|
|
|
FuncReturn(retval);
|
|
|
|
}
|
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <ResultCode func(u32*, u64)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2017-12-31 21:46:30 +01:00
|
|
|
u32 param_1 = 0;
|
2018-09-18 10:25:35 +02:00
|
|
|
u32 retval = func(¶m_1, Param(1)).raw;
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
2017-10-10 05:56:20 +02:00
|
|
|
FuncReturn(retval);
|
|
|
|
}
|
|
|
|
|
2018-01-07 22:55:17 +01:00
|
|
|
template <ResultCode func(u64, s32)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(func(Param(0), static_cast<s32>(Param(1))).raw);
|
2014-04-11 01:58:28 +02:00
|
|
|
}
|
|
|
|
|
2018-09-30 01:58:21 +02:00
|
|
|
template <ResultCode func(u64, u32)>
|
|
|
|
void SvcWrap() {
|
|
|
|
FuncReturn(func(Param(0), static_cast<u32>(Param(1))).raw);
|
|
|
|
}
|
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <ResultCode func(u64*, u64)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2017-12-31 21:46:30 +01:00
|
|
|
u64 param_1 = 0;
|
2018-09-18 10:25:35 +02:00
|
|
|
u32 retval = func(¶m_1, Param(1)).raw;
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
2015-03-24 04:55:21 +01:00
|
|
|
FuncReturn(retval);
|
|
|
|
}
|
|
|
|
|
2018-10-13 20:31:46 +02:00
|
|
|
template <ResultCode func(u64*, u32, u32)>
|
|
|
|
void SvcWrap() {
|
|
|
|
u64 param_1 = 0;
|
|
|
|
u32 retval = func(¶m_1, static_cast<u32>(Param(1)), static_cast<u32>(Param(2))).raw;
|
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
|
|
|
FuncReturn(retval);
|
|
|
|
}
|
|
|
|
|
2018-04-03 05:50:17 +02:00
|
|
|
template <ResultCode func(u32, u64)>
|
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(func(static_cast<u32>(Param(0)), Param(1)).raw);
|
2018-04-03 05:50:17 +02:00
|
|
|
}
|
|
|
|
|
2018-03-30 03:07:49 +02:00
|
|
|
template <ResultCode func(u32, u32, u64)>
|
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(func(static_cast<u32>(Param(0)), static_cast<u32>(Param(1)), Param(2)).raw);
|
2018-03-30 03:07:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <ResultCode func(u32, u32*, u64*)>
|
|
|
|
void SvcWrap() {
|
|
|
|
u32 param_1 = 0;
|
|
|
|
u64 param_2 = 0;
|
2018-10-10 03:49:08 +02:00
|
|
|
ResultCode retval = func(static_cast<u32>(Param(2)), ¶m_1, ¶m_2);
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
|
|
|
Core::CurrentArmInterface().SetReg(2, param_2);
|
2018-03-30 03:07:49 +02:00
|
|
|
FuncReturn(retval.raw);
|
|
|
|
}
|
|
|
|
|
2018-01-08 03:23:42 +01:00
|
|
|
template <ResultCode func(u64, u64, u32, u32)>
|
|
|
|
void SvcWrap() {
|
|
|
|
FuncReturn(
|
2018-10-10 03:49:08 +02:00
|
|
|
func(Param(0), Param(1), static_cast<u32>(Param(3)), static_cast<u32>(Param(3))).raw);
|
2018-01-08 03:23:42 +01:00
|
|
|
}
|
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <ResultCode func(u32, u64, u32)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(func(static_cast<u32>(Param(0)), Param(1), static_cast<u32>(Param(2))).raw);
|
2017-06-21 02:27:20 +02:00
|
|
|
}
|
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <ResultCode func(u64, u64, u64)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-09-18 10:25:35 +02:00
|
|
|
FuncReturn(func(Param(0), Param(1), Param(2)).raw);
|
2014-04-11 01:58:28 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 16:01:34 +01:00
|
|
|
template <ResultCode func(u64, u64, u32)>
|
|
|
|
void SvcWrap() {
|
|
|
|
FuncReturn(func(Param(0), Param(1), static_cast<u32>(Param(2))).raw);
|
|
|
|
}
|
|
|
|
|
2018-01-14 23:15:31 +01:00
|
|
|
template <ResultCode func(u32, u64, u64, u32)>
|
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(
|
|
|
|
func(static_cast<u32>(Param(0)), Param(1), Param(2), static_cast<u32>(Param(3))).raw);
|
2018-01-14 23:15:31 +01:00
|
|
|
}
|
|
|
|
|
2018-02-22 20:16:43 +01:00
|
|
|
template <ResultCode func(u32, u64, u64)>
|
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(func(static_cast<u32>(Param(0)), Param(1), Param(2)).raw);
|
2018-02-22 20:16:43 +01:00
|
|
|
}
|
|
|
|
|
2018-01-09 17:53:50 +01:00
|
|
|
template <ResultCode func(u32*, u64, u64, s64)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-01-09 17:53:50 +01:00
|
|
|
u32 param_1 = 0;
|
2018-10-10 03:49:08 +02:00
|
|
|
ResultCode retval =
|
|
|
|
func(¶m_1, Param(1), static_cast<u32>(Param(2)), static_cast<s64>(Param(3)));
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
2018-01-09 17:53:50 +01:00
|
|
|
FuncReturn(retval.raw);
|
2014-07-07 04:17:34 +02:00
|
|
|
}
|
|
|
|
|
2018-01-06 22:14:12 +01:00
|
|
|
template <ResultCode func(u64, u64, u32, s64)>
|
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(
|
|
|
|
func(Param(0), Param(1), static_cast<u32>(Param(2)), static_cast<s64>(Param(3))).raw);
|
2018-01-06 22:14:12 +01:00
|
|
|
}
|
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <ResultCode func(u64*, u64, u64, u64)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2017-10-10 05:56:20 +02:00
|
|
|
u64 param_1 = 0;
|
2018-09-18 10:25:35 +02:00
|
|
|
u32 retval = func(¶m_1, Param(1), Param(2), Param(3)).raw;
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
2017-10-10 05:56:20 +02:00
|
|
|
FuncReturn(retval);
|
|
|
|
}
|
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <ResultCode func(u32*, u64, u64, u64, u32, s32)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2014-07-07 04:17:34 +02:00
|
|
|
u32 param_1 = 0;
|
2018-10-10 03:49:08 +02:00
|
|
|
u32 retval = func(¶m_1, Param(1), Param(2), Param(3), static_cast<u32>(Param(4)),
|
|
|
|
static_cast<s32>(Param(5)))
|
|
|
|
.raw;
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
2014-08-15 02:01:02 +02:00
|
|
|
FuncReturn(retval);
|
2014-04-11 01:58:28 +02:00
|
|
|
}
|
|
|
|
|
2018-01-08 03:24:19 +01:00
|
|
|
template <ResultCode func(u32*, u64, u64, u32)>
|
|
|
|
void SvcWrap() {
|
|
|
|
u32 param_1 = 0;
|
2018-10-10 03:49:08 +02:00
|
|
|
u32 retval = func(¶m_1, Param(1), Param(2), static_cast<u32>(Param(3))).raw;
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
2018-01-20 01:35:25 +01:00
|
|
|
FuncReturn(retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <ResultCode func(Handle*, u64, u32, u32)>
|
|
|
|
void SvcWrap() {
|
|
|
|
u32 param_1 = 0;
|
|
|
|
u32 retval =
|
2018-10-10 03:49:08 +02:00
|
|
|
func(¶m_1, Param(1), static_cast<u32>(Param(2)), static_cast<u32>(Param(3))).raw;
|
2018-05-03 04:36:51 +02:00
|
|
|
Core::CurrentArmInterface().SetReg(1, param_1);
|
2018-01-08 03:24:19 +01:00
|
|
|
FuncReturn(retval);
|
|
|
|
}
|
|
|
|
|
2018-06-21 08:49:43 +02:00
|
|
|
template <ResultCode func(u64, u32, s32, s64)>
|
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(func(Param(0), static_cast<u32>(Param(1)), static_cast<s32>(Param(2)),
|
|
|
|
static_cast<s64>(Param(3)))
|
|
|
|
.raw);
|
2018-06-21 08:49:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <ResultCode func(u64, u32, s32, s32)>
|
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
FuncReturn(func(Param(0), static_cast<u32>(Param(1)), static_cast<s32>(Param(2)),
|
|
|
|
static_cast<s32>(Param(3)))
|
2018-06-22 05:09:51 +02:00
|
|
|
.raw);
|
2018-06-21 08:49:43 +02:00
|
|
|
}
|
|
|
|
|
2014-06-07 05:31:29 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Function wrappers that return type u32
|
2014-04-11 01:58:28 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
template <u32 func()>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2014-08-15 02:01:02 +02:00
|
|
|
FuncReturn(func());
|
|
|
|
}
|
|
|
|
|
2018-01-12 03:59:31 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Function wrappers that return type u64
|
|
|
|
|
|
|
|
template <u64 func()>
|
|
|
|
void SvcWrap() {
|
|
|
|
FuncReturn(func());
|
|
|
|
}
|
|
|
|
|
2014-08-15 02:01:02 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2017-12-31 21:46:30 +01:00
|
|
|
/// Function wrappers that return type void
|
2014-08-15 02:01:02 +02:00
|
|
|
|
2017-12-31 21:46:30 +01:00
|
|
|
template <void func()>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2017-12-31 21:46:30 +01:00
|
|
|
func();
|
2014-04-11 01:58:28 +02:00
|
|
|
}
|
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
template <void func(s64)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
func(static_cast<s64>(Param(0)));
|
2014-06-01 16:41:41 +02:00
|
|
|
}
|
|
|
|
|
2018-09-12 10:49:08 +02:00
|
|
|
template <void func(u64, u64 len)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-09-18 10:25:35 +02:00
|
|
|
func(Param(0), Param(1));
|
2014-05-18 05:37:25 +02:00
|
|
|
}
|
|
|
|
|
2017-10-10 05:56:20 +02:00
|
|
|
template <void func(u64, u64, u64)>
|
2018-01-03 02:40:30 +01:00
|
|
|
void SvcWrap() {
|
2018-09-18 10:25:35 +02:00
|
|
|
func(Param(0), Param(1), Param(2));
|
2015-05-17 07:06:59 +02:00
|
|
|
}
|
|
|
|
|
2018-10-10 03:23:50 +02:00
|
|
|
template <void func(u32, u64, u64)>
|
|
|
|
void SvcWrap() {
|
2018-10-10 03:49:08 +02:00
|
|
|
func(static_cast<u32>(Param(0)), Param(1), Param(2));
|
2018-10-10 03:23:50 +02:00
|
|
|
}
|
|
|
|
|
2018-01-03 02:40:30 +01:00
|
|
|
} // namespace Kernel
|