From 862db811f02f8d28c4537a6be7b6a8f6c8fec812 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 6 Jun 2014 23:31:29 -0400 Subject: SVC: Cleaned up function wrappers to pass in correct argument types. --- src/core/hle/function_wrappers.h | 785 ++++----------------------------------- src/core/hle/svc.cpp | 286 +++++++------- 2 files changed, 201 insertions(+), 870 deletions(-) diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index 2d0dcf476..e8afa90d6 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h @@ -1,19 +1,6 @@ -// Copyright (c) 2012- PPSSPP Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0 or later versions. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official git repository and contact information can be found at -// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. #pragma once @@ -21,759 +8,113 @@ #include "core/mem_map.h" #include "core/hle/hle.h" -// For easy parameter parsing and return value processing. - -//32bit wrappers -template void WrapV_V() { - func(); -} - -template void WrapU_V() { - RETURN(func()); -} - -template void WrapI_VC() { - u32 param_1 = 0; - u32 retval = func(¶m_1, Memory::GetCharPointer(PARAM(1))); - Core::g_app_core->SetReg(1, param_1); - RETURN(retval); -} - -template void WrapU_IVI() { - u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), PARAM(2)); - RETURN(retval); -} - -template void WrapI_CIIU() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_ICUVVUI() { - u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), - Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6)); - RETURN(retval); -} - -// Hm, do so many params get passed in registers? -template void WrapI_CICIIIII() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), Memory::GetCharPointer(PARAM(2)), - PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7)); - RETURN(retval); -} - -// Hm, do so many params get passed in registers? -template void WrapI_CIIIIII() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), - PARAM(3), PARAM(4), PARAM(5), PARAM(6)); - RETURN(retval); -} - -// Hm, do so many params get passed in registers? -template void WrapI_IIIIIIU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); - RETURN(retval); -} - -// Hm, do so many params get passed in registers? -template void WrapI_IIIIIIIIU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7), PARAM(8)); - RETURN(retval); -} - -template void WrapU_IV() { - u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1))); - RETURN(retval); -} - -template void WrapF_V() { - RETURNF(func()); -} - -// TODO: Not sure about the floating point parameter passing -template void WrapF_IFU() { - RETURNF(func(PARAM(0), PARAMF(0), PARAM(1))); -} - -template void WrapU_U() { - u32 retval = func(PARAM(0)); - RETURN(retval); -} - -template void WrapU_UI() { - u32 retval = func(PARAM(0), PARAM(1)); - RETURN(retval); -} - -template void WrapI_U() { - int retval = func(PARAM(0)); - RETURN(retval); -} - -template void WrapI_UI() { - int retval = func(PARAM(0), PARAM(1)); - RETURN(retval); -} - -template void WrapI_UIIU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapU_IUI() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_UU() { - int retval = func(PARAM(0), PARAM(1)); - RETURN(retval); -} - -template void WrapI_UFF() { - // Not sure about the float arguments. - int retval = func(PARAM(0), PARAMF(0), PARAMF(1)); - RETURN(retval); -} - -template void WrapI_UUU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_UUUI() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_UUUIIII() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); - RETURN(retval); -} - -template void WrapI_UUUU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_UUUUU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapI_V() { - u32 retval = func(Memory::GetPointer(PARAM(0))); - RETURN(retval); -} - -template void WrapU_I() { - u32 retval = func(PARAM(0)); - RETURN(retval); -} - -template void WrapU_IIU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_I() { - int retval = func(PARAM(0)); - RETURN(retval); -} - -template void WrapV_U() { - func(PARAM(0)); -} - -template void WrapV_I() { - func(PARAM(0)); -} - -template void WrapV_UU() { - func(PARAM(0), PARAM(1)); -} - -template void WrapV_II() { - func(PARAM(0), PARAM(1)); -} - -template void WrapV_UC() { - func(PARAM(0), Memory::GetCharPointer(PARAM(1))); -} - -template void WrapI_UC() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); - RETURN(retval); -} - -template void WrapI_UCI() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2)); - RETURN(retval); -} - -template void WrapU_UIIIII() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); - RETURN(retval); -} - -template void WrapU_UIIIU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapU_UIIIIII() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); - RETURN(retval); -} - -template void WrapU_UU() { - u32 retval = func(PARAM(0), PARAM(1)); - RETURN(retval); -} - -template void WrapU_UUI() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapU_UUII() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapU_CUUU() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapV_UIUII() { - func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); -} - -template void WrapU_UIUII() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapI_UIUII() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapU_UIUI() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_UIUI() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapU_UIU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapU_UIUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapU_UII() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapU_UIIU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_UIIUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapI_UUII() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_UUIII() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapV_UIII() { - func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); -} - -template void WrapV_UIIIII() { - func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); -} - -template void WrapV_UII() { - func(PARAM(0), PARAM(1), PARAM(2)); -} - -template void WrapU_IU() { - int retval = func(PARAM(0), PARAM(1)); - RETURN(retval); -} - -template void WrapI_IU() { - int retval = func(PARAM(0), PARAM(1)); - RETURN(retval); -} - -template void WrapI_UUI() { - int retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_UUIU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_II() { - int retval = func(PARAM(0), PARAM(1)); - RETURN(retval); -} - -template void WrapI_III() { - int retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_IUI() { - int retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_IIII() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_UIII() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_IIIUI() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapI_IUUII() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapI_ICIUU() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapI_IIU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapV_IU() { - func(PARAM(0), PARAM(1)); -} - -template void WrapV_UI() { - func(PARAM(0), PARAM(1)); -} +namespace Wrap { -template void WrapU_C() { - u32 retval = func(Memory::GetCharPointer(PARAM(0))); - RETURN(retval); -} +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Function wrappers that return type s32 -template void WrapU_CCCU() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), - Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), - PARAM(3)); - RETURN(retval); -} +namespace S32 { -template void WrapI_C() { - int retval = func(Memory::GetCharPointer(PARAM(0))); - RETURN(retval); +template void U32_U32_U32_U32() { + RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3))); } -template void WrapI_CU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); - RETURN(retval); -} - -template void WrapI_CUI() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_ICIU() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); - RETURN(retval); +template void U32_U32_U32_U32_U32() { + RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4))); } -template void WrapI_CIU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_CUU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_CUUU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), - PARAM(3)); - RETURN(retval); -} - -template void WrapI_CCII() { - int retval = func(Memory::GetCharPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_CUUIUU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), - PARAM(3), PARAM(4), PARAM(5)); - RETURN(retval); -} - -template void WrapI_CIIUII() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), - PARAM(3), PARAM(4), PARAM(5)); - RETURN(retval); -} - -template void WrapI_CIUUU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), - PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapI_CUUUUU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), - PARAM(3), PARAM(4), PARAM(5)); - RETURN(retval); -} - -template void WrapU_CU() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); - RETURN((u32) retval); -} - -template void WrapU_UC() { - u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); - RETURN(retval); -} - -template void WrapU_CUU() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); - RETURN((u32) retval); -} - -template void WrapU_III() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapU_II() { - u32 retval = func(PARAM(0), PARAM(1)); - RETURN(retval); -} - -template void WrapU_IIII() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapU_IUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapU_IUUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapU_IUUUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapU_UUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapV_IUU() { - func(PARAM(0), PARAM(1), PARAM(2)); -} - -template void WrapV_IIU() { - func(PARAM(0), PARAM(1), PARAM(2)); -} - -template void WrapV_UIU() { - func(PARAM(0), PARAM(1), PARAM(2)); -} - -template void WrapI_UIU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2)); +template void U32P_U32_U32_U32_U32_U32(){ + u32 param_1 = 0; + u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); + Core::g_app_core->SetReg(1, param_1); RETURN(retval); } -template void WrapV_IUUUU() { - func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); -} - -template void WrapV_UUU() { - func(PARAM(0), PARAM(1), PARAM(2)); -} - -template void WrapV_UUUU() { - func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); -} - -template void WrapV_CUIU() { - func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); -} - -template void WrapI_CUIU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); +template void S32P_U32P_S32_Bool_S64() { + s32 param_1 = 0; + s32 retval = func(¶m_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), + (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))); + Core::g_app_core->SetReg(1, (u32)param_1); RETURN(retval); } -template void WrapV_UCUIU() { - func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), - PARAM(4)); +// TODO(bunnei): Is this correct? Probably not +template void U32_U32_U32_U32_S64() { + RETURN(func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(4) << 32) | PARAM(0)))); } -template void WrapI_UCUIU() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), - PARAM(3), PARAM(4)); - RETURN(retval); +template void U32_S64() { + RETURN(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2)))); } -template void WrapV_CUIIU() { - func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), - PARAM(4)); +template void VoidP_VoidP_U32(){ + RETURN(func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2))); } -template void WrapI_CUIIU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), - PARAM(3), PARAM(4)); +template void S32P_U32(){ + s32 param_1 = 0; + u32 retval = func(¶m_1, PARAM(1)); + Core::g_app_core->SetReg(1, param_1); RETURN(retval); } -template void WrapU_UUUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); +template void U32_S32() { + RETURN(func(PARAM(0), (s32)PARAM(1))); } -template void WrapU_UCUU() { - u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); +template void U32P_U32(){ + u32 param_1 = 0; + u32 retval = func(¶m_1, PARAM(1)); + Core::g_app_core->SetReg(1, param_1); RETURN(retval); } -template void WrapU_UUUI() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); +template void U32() { + RETURN(func(PARAM(0))); } -template void WrapU_UUUIU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); +template void U32P() { + RETURN(func(Memory::GetPointer(PARAM(0)))); } -template void WrapU_UUUIUI() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); - RETURN(retval); +template void S64P_U32_VoidP_S32(){ + RETURN(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)), + (s32)PARAM(3))); } -template void WrapU_UUIU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); +template void U32P_CharP() { + u32 param_1 = 0; + u32 retval = func(¶m_1, Memory::GetCharPointer(PARAM(1))); + Core::g_app_core->SetReg(1, param_1); RETURN(retval); } -template void WrapU_UIII() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} +} // namespace S32 -template void WrapI_IUUUU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); -} +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Function wrappers that return type u32 -template void WrapI_IUUUUU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); - RETURN(retval); -} +namespace U32 { -template void WrapI_IUII() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} -template void WrapU_UUUUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - RETURN(retval); +template void Void() { + RETURN(func()); } -template void WrapV_UUUUU() { - func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); -} +} // namespace U32 -template void WrapU_CC() { - int retval = func(Memory::GetCharPointer(PARAM(0)), - Memory::GetCharPointer(PARAM(1))); - RETURN(retval); -} +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// Function wrappers that return type void -template void WrapV_C() { - func(Memory::GetCharPointer(PARAM(0))); -} +namespace Void { -template void WrapV_S64() { +template void S64() { func(((s64)PARAM(1) << 32) | PARAM(0)); } -template void WrapV_CI() { - func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); -} - -template void WrapU_CI() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); - RETURN(retval); -} - -template void WrapU_CII() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapU_CIUIU() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), - PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapU_CIUIUI() { - u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), - PARAM(3), PARAM(4), PARAM(5)); - RETURN(retval); -} - -template void WrapU_UUUUUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), - PARAM(5)); - RETURN(retval); -} - -template void WrapI_IUUU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_IUU() { - int retval = func(PARAM(0), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapU_UUUUUUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); - RETURN(retval); -} - -template void WrapI_UIUU() { - u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); - RETURN(retval); -} - -template void WrapI_IC() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); - RETURN(retval); -} - -template void WrapI_ICCUI() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), PARAM(3), PARAM(4)); - RETURN(retval); -} - -template void WrapI_ICCI() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), PARAM(3)); - RETURN(retval); -} - -template void WrapI_CII() { - int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); - RETURN(retval); -} - -template void WrapI_ICI() { - int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2)); - RETURN(retval); -} - -template void WrapI_IVVVVUI(){ - u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), Memory::GetPointer(PARAM(2)), Memory::GetPointer(PARAM(3)), Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) ); - RETURN(retval); -} - -template void WrapI_ICUVIII(){ - u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)), PARAM(4), PARAM(5), PARAM(6)); - RETURN(retval); -} - -template void WrapI_VU(){ - u32 param_1 = 0; - u32 retval = func(¶m_1, PARAM(1)); - Core::g_app_core->SetReg(1, param_1); - RETURN(retval); -} - -template void WrapI_VVU(){ - u32 retval = func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2)); - RETURN(retval); -} - -template void WrapI_VUVI(){ - u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)), PARAM(3)); - RETURN(retval); -} - -template void WrapI_VUUUUU(){ - u32 param_1 = 0; - u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); - Core::g_app_core->SetReg(1, param_1); - RETURN(retval); -} - -template void WrapI_US64() { - int retval = func(PARAM(0), (((u64)PARAM(3) << 32) | PARAM(2))); - RETURN(retval); +template void CharP() { + func(Memory::GetCharPointer(PARAM(0))); } -template void WrapI_VVUUS64() { - u32 param_1 = 0; - int retval = func(¶m_1, Memory::GetPointer(PARAM(1)), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0))); - Core::g_app_core->SetReg(1, param_1); - RETURN(retval); -} +} // namespace Void -// TODO(bunnei): Is this correct? Probably not -template void WrapI_UUUUS64() { - int retval = func(PARAM(5), PARAM(1), PARAM(2), PARAM(3), (((u64)PARAM(4) << 32) | PARAM(0))); - RETURN(retval); -} +} // namespace Wrap diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 76c6a0771..d964d062e 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -34,9 +34,7 @@ enum MapMemoryPermission { }; /// Map application or GSP heap memory -Result ControlMemory(void* _out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { - u32* out_addr = (u32*)_out_addr; - +Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", operation, addr0, addr1, size, permissions); @@ -76,8 +74,7 @@ Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherper } /// Connect to an OS service given the port name, returns the handle to the port to out -Result ConnectToPort(void* _out, const char* port_name) { - Handle* out = (Handle*)_out; +Result ConnectToPort(Handle* out, const char* port_name) { Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); DEBUG_LOG(SVC, "called port_name=%s", port_name); @@ -136,11 +133,9 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) { } /// Wait for the given handles to synchronize, timeout after the specified nanoseconds -Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wait_all, +Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all, s64 nano_seconds) { // TODO(bunnei): Do something with nano_seconds, currently ignoring this - s32* out = (s32*)_out; - Handle* handles = (Handle*)_handles; bool unlock_all = true; bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated @@ -148,7 +143,7 @@ Result WaitSynchronizationN(void* _out, void* _handles, u32 handle_count, u32 wa handle_count, (wait_all ? "true" : "false"), nano_seconds); // Iterate through each handle, synchronize kernel object - for (u32 i = 0; i < handle_count; i++) { + for (s32 i = 0; i < handle_count; i++) { bool wait = false; Kernel::Object* object = Kernel::g_object_pool.GetFast(handles[i]); @@ -200,18 +195,17 @@ void OutputDebugString(const char* string) { } /// Get resource limit -Result GetResourceLimit(void* _resource_limit, Handle process) { +Result GetResourceLimit(Handle* resource_limit, Handle process) { // With regards to proceess values: // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for // the current KThread. - Handle* resource_limit = (Handle*)_resource_limit; *resource_limit = 0xDEADBEEF; ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process); return 0; } /// Get resource limit current values -Result GetResourceLimitCurrentValues(void* _values, Handle resource_limit, void* names, +Result GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names, s32 name_count) { ERROR_LOG(SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%s, name_count=%d", resource_limit, names, name_count); @@ -255,8 +249,7 @@ u32 ExitThread() { } /// Gets the priority for the specified thread -Result GetThreadPriority(void* _priority, Handle handle) { - s32* priority = (s32*)_priority; +Result GetThreadPriority(s32* priority, Handle handle) { *priority = Kernel::GetThreadPriority(handle); return 0; } @@ -267,8 +260,7 @@ Result SetThreadPriority(Handle handle, s32 priority) { } /// Create a mutex -Result CreateMutex(void* _mutex, u32 initial_locked) { - Handle* mutex = (Handle*)_mutex; +Result CreateMutex(Handle* mutex, u32 initial_locked) { *mutex = Kernel::CreateMutex((initial_locked != 0)); DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", initial_locked ? "true" : "false", *mutex); @@ -284,20 +276,19 @@ Result ReleaseMutex(Handle handle) { } /// Get current thread ID -Result GetThreadId(void* thread_id, u32 thread) { +Result GetThreadId(u32* thread_id, Handle thread) { ERROR_LOG(SVC, "(UNIMPLEMENTED) called thread=0x%08X", thread); return 0; } /// Query memory -Result QueryMemory(void *_info, void *_out, u32 addr) { +Result QueryMemory(void* info, void* out, u32 addr) { ERROR_LOG(SVC, "(UNIMPLEMENTED) called addr=0x%08X", addr); return 0; } /// Create an event -Result CreateEvent(void* _event, u32 reset_type) { - Handle* evt = (Handle*)_event; +Result CreateEvent(Handle* evt, u32 reset_type) { *evt = Kernel::CreateEvent((ResetType)reset_type); DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type, *evt); @@ -305,8 +296,7 @@ Result CreateEvent(void* _event, u32 reset_type) { } /// Duplicates a kernel handle -Result DuplicateHandle(void* _out, Handle handle) { - Handle* out = (Handle*)_out; +Result DuplicateHandle(Handle* out, Handle handle) { DEBUG_LOG(SVC, "called handle=0x%08X", handle); // Translate kernel handles -> real handles @@ -342,132 +332,132 @@ void SleepThread(s64 nanoseconds) { } const HLE::FunctionDef SVC_Table[] = { - {0x00, nullptr, "Unknown"}, - {0x01, WrapI_VUUUUU, "ControlMemory"}, - {0x02, WrapI_VVU, "QueryMemory"}, - {0x03, nullptr, "ExitProcess"}, - {0x04, nullptr, "GetProcessAffinityMask"}, - {0x05, nullptr, "SetProcessAffinityMask"}, - {0x06, nullptr, "GetProcessIdealProcessor"}, - {0x07, nullptr, "SetProcessIdealProcessor"}, - {0x08, WrapI_UUUUU, "CreateThread"}, - {0x09, WrapU_V, "ExitThread"}, - {0x0A, WrapV_S64, "SleepThread"}, - {0x0B, WrapI_VU, "GetThreadPriority"}, - {0x0C, WrapI_UI, "SetThreadPriority"}, - {0x0D, nullptr, "GetThreadAffinityMask"}, - {0x0E, nullptr, "SetThreadAffinityMask"}, - {0x0F, nullptr, "GetThreadIdealProcessor"}, - {0x10, nullptr, "SetThreadIdealProcessor"}, - {0x11, nullptr, "GetCurrentProcessorNumber"}, - {0x12, nullptr, "Run"}, - {0x13, WrapI_VU, "CreateMutex"}, - {0x14, WrapI_U, "ReleaseMutex"}, - {0x15, nullptr, "CreateSemaphore"}, - {0x16, nullptr, "ReleaseSemaphore"}, - {0x17, WrapI_VU, "CreateEvent"}, - {0x18, WrapI_U, "SignalEvent"}, - {0x19, WrapI_U, "ClearEvent"}, - {0x1A, nullptr, "CreateTimer"}, - {0x1B, nullptr, "SetTimer"}, - {0x1C, nullptr, "CancelTimer"}, - {0x1D, nullptr, "ClearTimer"}, - {0x1E, nullptr, "CreateMemoryBlock"}, - {0x1F, WrapI_UUUU, "MapMemoryBlock"}, - {0x20, nullptr, "UnmapMemoryBlock"}, - {0x21, WrapI_V, "CreateAddressArbiter"}, - {0x22, WrapI_UUUUS64, "ArbitrateAddress"}, - {0x23, WrapI_U, "CloseHandle"}, - {0x24, WrapI_US64, "WaitSynchronization1"}, - {0x25, WrapI_VVUUS64, "WaitSynchronizationN"}, - {0x26, nullptr, "SignalAndWait"}, - {0x27, WrapI_VU, "DuplicateHandle"}, - {0x28, nullptr, "GetSystemTick"}, - {0x29, nullptr, "GetHandleInfo"}, - {0x2A, nullptr, "GetSystemInfo"}, - {0x2B, nullptr, "GetProcessInfo"}, - {0x2C, nullptr, "GetThreadInfo"}, - {0x2D, WrapI_VC, "ConnectToPort"}, - {0x2E, nullptr, "SendSyncRequest1"}, - {0x2F, nullptr, "SendSyncRequest2"}, - {0x30, nullptr, "SendSyncRequest3"}, - {0x31, nullptr, "SendSyncRequest4"}, - {0x32, WrapI_U, "SendSyncRequest"}, - {0x33, nullptr, "OpenProcess"}, - {0x34, nullptr, "OpenThread"}, - {0x35, nullptr, "GetProcessId"}, - {0x36, nullptr, "GetProcessIdOfThread"}, - {0x37, WrapI_VU, "GetThreadId"}, - {0x38, WrapI_VU, "GetResourceLimit"}, - {0x39, nullptr, "GetResourceLimitLimitValues"}, - {0x3A, WrapI_VUVI, "GetResourceLimitCurrentValues"}, - {0x3B, nullptr, "GetThreadContext"}, - {0x3C, nullptr, "Break"}, - {0x3D, WrapV_C, "OutputDebugString"}, - {0x3E, nullptr, "ControlPerformanceCounter"}, - {0x3F, nullptr, "Unknown"}, - {0x40, nullptr, "Unknown"}, - {0x41, nullptr, "Unknown"}, - {0x42, nullptr, "Unknown"}, - {0x43, nullptr, "Unknown"}, - {0x44, nullptr, "Unknown"}, - {0x45, nullptr, "Unknown"}, - {0x46, nullptr, "Unknown"}, - {0x47, nullptr, "CreatePort"}, - {0x48, nullptr, "CreateSessionToPort"}, - {0x49, nullptr, "CreateSession"}, - {0x4A, nullptr, "AcceptSession"}, - {0x4B, nullptr, "ReplyAndReceive1"}, - {0x4C, nullptr, "ReplyAndReceive2"}, - {0x4D, nullptr, "ReplyAndReceive3"}, - {0x4E, nullptr, "ReplyAndReceive4"}, - {0x4F, nullptr, "ReplyAndReceive"}, - {0x50, nullptr, "BindInterrupt"}, - {0x51, nullptr, "UnbindInterrupt"}, - {0x52, nullptr, "InvalidateProcessDataCache"}, - {0x53, nullptr, "StoreProcessDataCache"}, - {0x54, nullptr, "FlushProcessDataCache"}, - {0x55, nullptr, "StartInterProcessDma"}, - {0x56, nullptr, "StopDma"}, - {0x57, nullptr, "GetDmaState"}, - {0x58, nullptr, "RestartDma"}, - {0x59, nullptr, "Unknown"}, - {0x5A, nullptr, "Unknown"}, - {0x5B, nullptr, "Unknown"}, - {0x5C, nullptr, "Unknown"}, - {0x5D, nullptr, "Unknown"}, - {0x5E, nullptr, "Unknown"}, - {0x5F, nullptr, "Unknown"}, - {0x60, nullptr, "DebugActiveProcess"}, - {0x61, nullptr, "BreakDebugProcess"}, - {0x62, nullptr, "TerminateDebugProcess"}, - {0x63, nullptr, "GetProcessDebugEvent"}, - {0x64, nullptr, "ContinueDebugEvent"}, - {0x65, nullptr, "GetProcessList"}, - {0x66, nullptr, "GetThreadList"}, - {0x67, nullptr, "GetDebugThreadContext"}, - {0x68, nullptr, "SetDebugThreadContext"}, - {0x69, nullptr, "QueryDebugProcessMemory"}, - {0x6A, nullptr, "ReadProcessMemory"}, - {0x6B, nullptr, "WriteProcessMemory"}, - {0x6C, nullptr, "SetHardwareBreakPoint"}, - {0x6D, nullptr, "GetDebugThreadParam"}, - {0x6E, nullptr, "Unknown"}, - {0x6F, nullptr, "Unknown"}, - {0x70, nullptr, "ControlProcessMemory"}, - {0x71, nullptr, "MapProcessMemory"}, - {0x72, nullptr, "UnmapProcessMemory"}, - {0x73, nullptr, "Unknown"}, - {0x74, nullptr, "Unknown"}, - {0x75, nullptr, "Unknown"}, - {0x76, nullptr, "TerminateProcess"}, - {0x77, nullptr, "Unknown"}, - {0x78, nullptr, "CreateResourceLimit"}, - {0x79, nullptr, "Unknown"}, - {0x7A, nullptr, "Unknown"}, - {0x7B, nullptr, "Unknown"}, - {0x7C, nullptr, "KernelSetState"}, - {0x7D, nullptr, "QueryProcessMemory"}, + {0x00, nullptr, "Unknown"}, + {0x01, Wrap::S32::U32P_U32_U32_U32_U32_U32, "ControlMemory"}, + {0x02, Wrap::S32::VoidP_VoidP_U32, "QueryMemory"}, + {0x03, nullptr, "ExitProcess"}, + {0x04, nullptr, "GetProcessAffinityMask"}, + {0x05, nullptr, "SetProcessAffinityMask"}, + {0x06, nullptr, "GetProcessIdealProcessor"}, + {0x07, nullptr, "SetProcessIdealProcessor"}, + {0x08, Wrap::S32::U32_U32_U32_U32_U32, "CreateThread"}, + {0x09, Wrap::U32::Void, "ExitThread"}, + {0x0A, Wrap::Void::S64, "SleepThread"}, + {0x0B, Wrap::S32::S32P_U32, "GetThreadPriority"}, + {0x0C, Wrap::S32::U32_S32, "SetThreadPriority"}, + {0x0D, nullptr, "GetThreadAffinityMask"}, + {0x0E, nullptr, "SetThreadAffinityMask"}, + {0x0F, nullptr, "GetThreadIdealProcessor"}, + {0x10, nullptr, "SetThreadIdealProcessor"}, + {0x11, nullptr, "GetCurrentProcessorNumber"}, + {0x12, nullptr, "Run"}, + {0x13, Wrap::S32::U32P_U32, "CreateMutex"}, + {0x14, Wrap::S32::U32, "ReleaseMutex"}, + {0x15, nullptr, "CreateSemaphore"}, + {0x16, nullptr, "ReleaseSemaphore"}, + {0x17, Wrap::S32::U32P_U32, "CreateEvent"}, + {0x18, Wrap::S32::U32, "SignalEvent"}, + {0x19, Wrap::S32::U32, "ClearEvent"}, + {0x1A, nullptr, "CreateTimer"}, + {0x1B, nullptr, "SetTimer"}, + {0x1C, nullptr, "CancelTimer"}, + {0x1D, nullptr, "ClearTimer"}, + {0x1E, nullptr, "CreateMemoryBlock"}, + {0x1F, Wrap::S32::U32_U32_U32_U32, "MapMemoryBlock"}, + {0x20, nullptr, "UnmapMemoryBlock"}, + {0x21, Wrap::S32::U32P, "CreateAddressArbiter"}, + {0x22, Wrap::S32::U32_U32_U32_U32_S64, "ArbitrateAddress"}, + {0x23, Wrap::S32::U32, "CloseHandle"}, + {0x24, Wrap::S32::U32_S64, "WaitSynchronization1"}, + {0x25, Wrap::S32::S32P_U32P_S32_Bool_S64, "WaitSynchronizationN"}, + {0x26, nullptr, "SignalAndWait"}, + {0x27, Wrap::S32::U32P_U32, "DuplicateHandle"}, + {0x28, nullptr, "GetSystemTick"}, + {0x29, nullptr, "GetHandleInfo"}, + {0x2A, nullptr, "GetSystemInfo"}, + {0x2B, nullptr, "GetProcessInfo"}, + {0x2C, nullptr, "GetThreadInfo"}, + {0x2D, Wrap::S32::U32P_CharP, "ConnectToPort"}, + {0x2E, nullptr, "SendSyncRequest1"}, + {0x2F, nullptr, "SendSyncRequest2"}, + {0x30, nullptr, "SendSyncRequest3"}, + {0x31, nullptr, "SendSyncRequest4"}, + {0x32, Wrap::S32::U32, "SendSyncRequest"}, + {0x33, nullptr, "OpenProcess"}, + {0x34, nullptr, "OpenThread"}, + {0x35, nullptr, "GetProcessId"}, + {0x36, nullptr, "GetProcessIdOfThread"}, + {0x37, Wrap::S32::U32P_U32, "GetThreadId"}, + {0x38, Wrap::S32::U32P_U32, "GetResourceLimit"}, + {0x39, nullptr, "GetResourceLimitLimitValues"}, + {0x3A, Wrap::S32::S64P_U32_VoidP_S32, "GetResourceLimitCurrentValues"}, + {0x3B, nullptr, "GetThreadContext"}, + {0x3C, nullptr, "Break"}, + {0x3D, Wrap::Void::CharP, "OutputDebugString"}, + {0x3E, nullptr, "ControlPerformanceCounter"}, + {0x3F, nullptr, "Unknown"}, + {0x40, nullptr, "Unknown"}, + {0x41, nullptr, "Unknown"}, + {0x42, nullptr, "Unknown"}, + {0x43, nullptr, "Unknown"}, + {0x44, nullptr, "Unknown"}, + {0x45, nullptr, "Unknown"}, + {0x46, nullptr, "Unknown"}, + {0x47, nullptr, "CreatePort"}, + {0x48, nullptr, "CreateSessionToPort"}, + {0x49, nullptr, "CreateSession"}, + {0x4A, nullptr, "AcceptSession"}, + {0x4B, nullptr, "ReplyAndReceive1"}, + {0x4C, nullptr, "ReplyAndReceive2"}, + {0x4D, nullptr, "ReplyAndReceive3"}, + {0x4E, nullptr, "ReplyAndReceive4"}, + {0x4F, nullptr, "ReplyAndReceive"}, + {0x50, nullptr, "BindInterrupt"}, + {0x51, nullptr, "UnbindInterrupt"}, + {0x52, nullptr, "InvalidateProcessDataCache"}, + {0x53, nullptr, "StoreProcessDataCache"}, + {0x54, nullptr, "FlushProcessDataCache"}, + {0x55, nullptr, "StartInterProcessDma"}, + {0x56, nullptr, "StopDma"}, + {0x57, nullptr, "GetDmaState"}, + {0x58, nullptr, "RestartDma"}, + {0x59, nullptr, "Unknown"}, + {0x5A, nullptr, "Unknown"}, + {0x5B, nullptr, "Unknown"}, + {0x5C, nullptr, "Unknown"}, + {0x5D, nullptr, "Unknown"}, + {0x5E, nullptr, "Unknown"}, + {0x5F, nullptr, "Unknown"}, + {0x60, nullptr, "DebugActiveProcess"}, + {0x61, nullptr, "BreakDebugProcess"}, + {0x62, nullptr, "TerminateDebugProcess"}, + {0x63, nullptr, "GetProcessDebugEvent"}, + {0x64, nullptr, "ContinueDebugEvent"}, + {0x65, nullptr, "GetProcessList"}, + {0x66, nullptr, "GetThreadList"}, + {0x67, nullptr, "GetDebugThreadContext"}, + {0x68, nullptr, "SetDebugThreadContext"}, + {0x69, nullptr, "QueryDebugProcessMemory"}, + {0x6A, nullptr, "ReadProcessMemory"}, + {0x6B, nullptr, "WriteProcessMemory"}, + {0x6C, nullptr, "SetHardwareBreakPoint"}, + {0x6D, nullptr, "GetDebugThreadParam"}, + {0x6E, nullptr, "Unknown"}, + {0x6F, nullptr, "Unknown"}, + {0x70, nullptr, "ControlProcessMemory"}, + {0x71, nullptr, "MapProcessMemory"}, + {0x72, nullptr, "UnmapProcessMemory"}, + {0x73, nullptr, "Unknown"}, + {0x74, nullptr, "Unknown"}, + {0x75, nullptr, "Unknown"}, + {0x76, nullptr, "TerminateProcess"}, + {0x77, nullptr, "Unknown"}, + {0x78, nullptr, "CreateResourceLimit"}, + {0x79, nullptr, "Unknown"}, + {0x7A, nullptr, "Unknown"}, + {0x7B, nullptr, "Unknown"}, + {0x7C, nullptr, "KernelSetState"}, + {0x7D, nullptr, "QueryProcessMemory"}, }; void Register() { -- cgit v1.2.3