kern: implement SvcUnmapMemory, more of SvcGetInfo

This commit is contained in:
Michael Scire 2020-05-29 00:57:25 -07:00
parent faad5609b9
commit 1a0696f8a3
14 changed files with 231 additions and 37 deletions

View file

@ -514,7 +514,8 @@ namespace ams::svc::codegen::impl {
private:
using Traits = FunctionTraits<Function>;
public:
using Impl = KernelSvcWrapperHelperImpl<_SvcAbiType, _UserAbiType, _KernelAbiType, typename Traits::ReturnType, typename Traits::ArgsType>;
using Impl = KernelSvcWrapperHelperImpl<_SvcAbiType, _UserAbiType, _KernelAbiType, typename Traits::ReturnType, typename Traits::ArgsType>;
using ReturnType = typename Traits::ReturnType;
static constexpr bool IsAarch64Kernel = std::is_same<_KernelAbiType, Aarch64Lp64Abi>::value;
static constexpr bool IsAarch32Kernel = std::is_same<_KernelAbiType, Aarch32Ilp32Abi>::value;
@ -525,17 +526,16 @@ namespace ams::svc::codegen::impl {
static constexpr auto BeforeMetaCode = Impl::OptimizedBeforeMetaCode;
static constexpr auto AfterMetaCode = Impl::OptimizedAfterMetaCode;
/* Set omit-frame-pointer to prevent GCC from emitting MOV X29, SP instructions. */
#pragma GCC push_options
#pragma GCC optimize ("omit-frame-pointer")
static ALWAYS_INLINE void WrapSvcFunction() {
static ALWAYS_INLINE ReturnType WrapSvcFunction() {
/* Generate appropriate assembly. */
GenerateCodeForMetaCode<CodeGenerator, BeforeMetaCode>();
ON_SCOPE_EXIT { GenerateCodeForMetaCode<CodeGenerator, AfterMetaCode>(); };
return reinterpret_cast<void (*)()>(Function)();
return reinterpret_cast<ReturnType (*)()>(Function)();
}
#pragma GCC pop_options

View file

@ -20,7 +20,7 @@ namespace ams::svc::codegen {
#if defined(ATMOSPHERE_ARCH_ARM64) || defined(ATMOSPHERE_ARCH_ARM)
template<auto Function64, auto Function64From32>
template<auto &Function64, auto &Function64From32>
class KernelSvcWrapper {
private:
/* TODO: using Aarch32 = */
@ -32,11 +32,22 @@ namespace ams::svc::codegen {
#pragma GCC optimize ("omit-frame-pointer")
static ALWAYS_INLINE void Call64() {
Aarch64::WrapSvcFunction();
if constexpr (std::is_same<typename Aarch64::ReturnType, void>::value) {
Aarch64::WrapSvcFunction();
} else {
const auto &res = Aarch64::WrapSvcFunction();
__asm__ __volatile__("" :: [res]"r"(res));
}
}
static ALWAYS_INLINE void Call64From32() {
Aarch64From32::WrapSvcFunction();
if constexpr (std::is_same<typename Aarch64::ReturnType, void>::value) {
Aarch64From32::WrapSvcFunction();
} else {
const auto &res = Aarch64From32::WrapSvcFunction();
__asm__ __volatile__("" :: [res]"r"(res));
}
}
#pragma GCC pop_options