diff --git a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp index af5dc71ca..a1cf21ac2 100644 --- a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu.hpp +++ b/libraries/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/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu_system_registers.hpp b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu_system_registers.hpp index 408f0518e..3debbfcff 100644 --- a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_cpu_system_registers.hpp +++ b/libraries/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/libraries/libmesosphere/include/mesosphere/kern_k_memory_layout.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_memory_layout.hpp index d1bd1d8f3..020757b5d 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_memory_layout.hpp +++ b/libraries/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)) { diff --git a/mesosphere/Makefile b/mesosphere/Makefile index f511441d1..5a02471ac 100644 --- a/mesosphere/Makefile +++ b/mesosphere/Makefile @@ -1,5 +1,5 @@ -TARGETS := kernel kernel_ldr -CLEAN_TARGETS := $(foreach target,$(TARGETS),$(target)-clean) +TARGETS := kernel.bin kernel_ldr.bin +CLEAN_TARGETS := $(foreach target,$(TARGETS),$(target:.bin=)-clean) SUBFOLDERS := $(MODULES) @@ -12,10 +12,15 @@ mesosphere.bin: $(TARGETS) @python build_mesosphere.py @echo "Built mesosphere.bin..." -$(TARGETS): - $(MAKE) -C $@ +$(TARGETS): check_libmeso + $(MAKE) -C $(@:.bin=) + @cp $(@:.bin=)/$(@) $(@) + +check_libmeso: + @$(MAKE) --no-print-directory -C ../libraries/libmesosphere $(CLEAN_TARGETS): $(MAKE) -C $(@:-clean=) clean + @rm -f $(@:-clean=).bin -.PHONY: all clean $(TARGETS) $(CLEAN_TARGETS) +.PHONY: all clean $(CLEAN_TARGETS)