From e8dbc5cbb0401ac1cdcd8e2e8c0f9d29ef4c068b Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 29 Jan 2020 05:37:14 -0800 Subject: [PATCH] meso: makefile improvements, sysreg accessors --- .../include/mesosphere/arch/arm64/kern_cpu.hpp | 12 ++++++++++++ .../arch/arm64/kern_cpu_system_registers.hpp | 1 + .../include/mesosphere/kern_k_memory_layout.hpp | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp b/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp index af5dc71c..a1cf21ac 100644 --- a/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp +++ b/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp @@ -71,4 +71,16 @@ namespace ams::kern::arm64::cpu { EnsureInstructionConsistency(); } + ALWAYS_INLINE uintptr_t GetCoreLocalRegionAddress() { + register uintptr_t x18 asm("x18"); + __asm__ __volatile__("" : [x18]"=r"(x18)); + return x18; + } + + ALWAYS_INLINE void SetCoreLocalRegionAddress(uintptr_t value) { + register uintptr_t x18 asm("x18") = value; + __asm__ __volatile__("":: [x18]"r"(x18)); + SetTpidrEl1(value); + } + } diff --git a/libmesosphere/include/mesosphere/arch/arm64/kern_cpu_system_registers.hpp b/libmesosphere/include/mesosphere/arch/arm64/kern_cpu_system_registers.hpp index 408f0518..3debbfcf 100644 --- a/libmesosphere/include/mesosphere/arch/arm64/kern_cpu_system_registers.hpp +++ b/libmesosphere/include/mesosphere/arch/arm64/kern_cpu_system_registers.hpp @@ -39,6 +39,7 @@ namespace ams::kern::arm64::cpu { MESOSPHERE_CPU_DEFINE_SYSREG_ACCESSORS(TcrEl1, tcr_el1) MESOSPHERE_CPU_DEFINE_SYSREG_ACCESSORS(MairEl1, mair_el1) + MESOSPHERE_CPU_DEFINE_SYSREG_ACCESSORS(TpidrEl1, tpidr_el1) MESOSPHERE_CPU_DEFINE_SYSREG_ACCESSORS(VbarEl1, vbar_el1) diff --git a/libmesosphere/include/mesosphere/kern_k_memory_layout.hpp b/libmesosphere/include/mesosphere/kern_k_memory_layout.hpp index d1bd1d8f..020757b5 100644 --- a/libmesosphere/include/mesosphere/kern_k_memory_layout.hpp +++ b/libmesosphere/include/mesosphere/kern_k_memory_layout.hpp @@ -239,6 +239,15 @@ namespace ams::kern { MESOSPHERE_INIT_ABORT(); } + iterator FindFirstBlockByType(u32 type_id) { + for (auto it = this->begin(); it != this->end(); it++) { + if (it->GetType() == type_id) { + return it; + } + } + MESOSPHERE_INIT_ABORT(); + } + iterator FindFirstDerivedBlock(u32 type_id) { for (auto it = this->begin(); it != this->end(); it++) { if (it->IsDerivedFrom(type_id)) {