forked from ShuriZma/suyu
1
0
Fork 0

function_wrappers: Cleanup, fix warnings, remove unused code.

This commit is contained in:
bunnei 2017-12-31 15:46:30 -05:00
parent 3a91a62b8f
commit f24531b1a2
1 changed files with 50 additions and 202 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2014 Citra Emulator Project
// Copyright 2017 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@ -7,7 +7,6 @@
#include "common/common_types.h"
#include "core/arm/arm_interface.h"
#include "core/core.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/result.h"
#include "core/hle/svc.h"
#include "core/memory.h"
@ -17,7 +16,7 @@ namespace HLE {
#define PARAM(n) Core::CPU().GetReg(n)
/**
* HLE a function return from the current ARM11 userland process
* HLE a function return from the current ARM userland process
* @param res Result to return
*/
static inline void FuncReturn(u64 res) {
@ -32,14 +31,48 @@ void Wrap() {
FuncReturn(func(PARAM(0)).raw);
}
template <ResultCode func(u32, u64, u32)>
template <ResultCode func(u32)>
void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1), PARAM(2)).raw);
FuncReturn(func((u32)PARAM(0)).raw);
}
template <ResultCode func(u32, u32)>
void Wrap() {
FuncReturn(func((u32)PARAM(0), (u32)PARAM(1)).raw);
}
template <ResultCode func(u32*, u32)>
void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, (u32)PARAM(1)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u32*, u64)>
void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u64, u32)>
void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1)).raw);
FuncReturn(func(PARAM(0), (u32)PARAM(1)).raw);
}
template <ResultCode func(u64*, u64)>
void Wrap() {
u64 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u32, u64, u32)>
void Wrap() {
FuncReturn(func((u32)PARAM(0), PARAM(1), (u32)PARAM(2)).raw);
}
template <ResultCode func(u64, u64, u64)>
@ -52,14 +85,6 @@ void Wrap() {
FuncReturn(func(PARAM(1), PARAM(2), (s64)PARAM(3)).raw);
}
template <ResultCode func(u64*, u64)>
void Wrap() {
u64 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u64*, u64, u64, u64)>
void Wrap() {
u64 param_1 = 0;
@ -68,76 +93,16 @@ void Wrap() {
FuncReturn(retval);
}
template <ResultCode func(u32, u32, u32, u32)>
void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)).raw);
}
template <ResultCode func(u32*, u32, u32, u32, u32, u32)>
template <ResultCode func(u32*, u64, u64, u64, u32, s32)>
void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u32*, u32, u32, u32, u32, s32)>
void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(s32*, VAddr, s32, bool, s64)>
void Wrap() {
s32 param_1 = 0;
s32 retval =
func(&param_1, PARAM(1), (s32)PARAM(2), (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)))
u32 retval =
func(&param_1, PARAM(1), PARAM(2), PARAM(3), (u32)PARAM(4), (s32)(PARAM(5) & 0xFFFFFFFF))
.raw;
Core::CPU().SetReg(1, (u32)param_1);
FuncReturn(retval);
}
template <ResultCode func(s32*, VAddr, s32, u32)>
void Wrap() {
s32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), (s32)PARAM(2), PARAM(3)).raw;
Core::CPU().SetReg(1, (u32)param_1);
FuncReturn(retval);
}
template <ResultCode func(u32, u32, u32, u32, s64)>
void Wrap() {
FuncReturn(
func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(5) << 32) | PARAM(4))).raw);
}
template <ResultCode func(u32, u64*)>
void Wrap() {
u64 param_1 = 0;
u32 retval = func(PARAM(0), &param_1).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u32*)>
void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u32, s64)>
void Wrap() {
s32 retval = func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))).raw;
FuncReturn(retval);
}
template <ResultCode func(MemoryInfo*, PageInfo*, u64)>
void Wrap() {
MemoryInfo memory_info = {};
@ -153,120 +118,6 @@ void Wrap() {
FuncReturn(retval);
}
template <ResultCode func(s32*, u32)>
void Wrap() {
s32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u32, s32)>
void Wrap() {
FuncReturn(func(PARAM(0), (s32)PARAM(1)).raw);
}
template <ResultCode func(u32*, u64)>
void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u32*, Kernel::Handle)>
void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u32)>
void Wrap() {
FuncReturn(func(PARAM(0)).raw);
}
template <ResultCode func(u32*, s32, s32)>
void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(s32*, u32, s32)>
void Wrap() {
s32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(s64*, u32, s32)>
void Wrap() {
s64 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
Core::CPU().SetReg(1, (u32)param_1);
Core::CPU().SetReg(2, (u32)(param_1 >> 32));
FuncReturn(retval);
}
template <ResultCode func(u32*, u32, u32, u32, u32)>
void Wrap() {
u32 param_1 = 0;
// The last parameter is passed in R0 instead of R4
u32 retval = func(&param_1, PARAM(1), PARAM(2), PARAM(3), PARAM(0)).raw;
Core::CPU().SetReg(1, param_1);
FuncReturn(retval);
}
template <ResultCode func(u32, s64, s64)>
void Wrap() {
s64 param1 = ((u64)PARAM(3) << 32) | PARAM(2);
s64 param2 = ((u64)PARAM(4) << 32) | PARAM(1);
FuncReturn(func(PARAM(0), param1, param2).raw);
}
template <ResultCode func(s64*, Kernel::Handle, u32)>
void Wrap() {
s64 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
Core::CPU().SetReg(1, (u32)param_1);
Core::CPU().SetReg(2, (u32)(param_1 >> 32));
FuncReturn(retval);
}
template <ResultCode func(Kernel::Handle, u32)>
void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1)).raw);
}
template <ResultCode func(Kernel::Handle*, Kernel::Handle*, VAddr, u32)>
void Wrap() {
Kernel::Handle param_1 = 0;
Kernel::Handle param_2 = 0;
u32 retval = func(&param_1, &param_2, PARAM(2), PARAM(3)).raw;
Core::CPU().SetReg(1, param_1);
Core::CPU().SetReg(2, param_2);
FuncReturn(retval);
}
template <ResultCode func(Kernel::Handle*, Kernel::Handle*)>
void Wrap() {
Kernel::Handle param_1 = 0;
Kernel::Handle param_2 = 0;
u32 retval = func(&param_1, &param_2).raw;
Core::CPU().SetReg(1, param_1);
Core::CPU().SetReg(2, param_2);
FuncReturn(retval);
}
template <ResultCode func(u32, u32, u32)>
void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1), PARAM(2)).raw);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type u32
@ -275,25 +126,22 @@ void Wrap() {
FuncReturn(func());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type s64
template <s64 func()>
void Wrap() {
FuncReturn64(func());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Function wrappers that return type void
template <void func()>
void Wrap() {
func();
}
template <void func(s64)>
void Wrap() {
func(((s64)PARAM(1) << 32) | PARAM(0));
func((s64)PARAM(0));
}
template <void func(VAddr, int len)>
template <void func(u64, s32 len)>
void Wrap() {
func(PARAM(0), PARAM(1));
func(PARAM(0), (s32)(PARAM(1) & 0xFFFFFFFF));
}
template <void func(u64, u64, u64)>