From 2e23abe83def82dd06eb478e965dcc51c6c095c5 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 19 Feb 2020 21:21:44 -0800 Subject: [PATCH] kern: implement user thread start, el0 code now runs --- .../arch/arm64/kern_k_page_table_entry.hpp | 2 +- .../include/mesosphere/kern_k_capabilities.hpp | 1 - .../source/arch/arm64/kern_k_thread_context.cpp | 15 ++++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libmesosphere/include/mesosphere/arch/arm64/kern_k_page_table_entry.hpp b/libmesosphere/include/mesosphere/arch/arm64/kern_k_page_table_entry.hpp index a5ae4222..09d7df97 100644 --- a/libmesosphere/include/mesosphere/arch/arm64/kern_k_page_table_entry.hpp +++ b/libmesosphere/include/mesosphere/arch/arm64/kern_k_page_table_entry.hpp @@ -145,7 +145,7 @@ namespace ams::kern::arch::arm64 { constexpr ALWAYS_INLINE decltype(auto) SetAccessFlag(AccessFlag f) { this->SetBitsDirect(10, 1, f); return *this; } constexpr ALWAYS_INLINE decltype(auto) SetShareable(Shareable s) { this->SetBitsDirect(8, 2, s); return *this; } constexpr ALWAYS_INLINE decltype(auto) SetReadOnly(bool en) { this->SetBit(7, en); return *this; } - constexpr ALWAYS_INLINE decltype(auto) SetUserAccessible(bool en) { this->SetBit(7, en); return *this; } + constexpr ALWAYS_INLINE decltype(auto) SetUserAccessible(bool en) { this->SetBit(6, en); return *this; } constexpr ALWAYS_INLINE decltype(auto) SetPageAttribute(PageAttribute a) { this->SetBitsDirect(2, 3, a); return *this; } constexpr ALWAYS_INLINE u64 GetEntryTemplate() const { diff --git a/libmesosphere/include/mesosphere/kern_k_capabilities.hpp b/libmesosphere/include/mesosphere/kern_k_capabilities.hpp index 54390cf8..851fad45 100644 --- a/libmesosphere/include/mesosphere/kern_k_capabilities.hpp +++ b/libmesosphere/include/mesosphere/kern_k_capabilities.hpp @@ -222,7 +222,6 @@ namespace ams::kern { } bool SetSvcAllowed(u32 id) { - constexpr size_t BitsPerWord = BITSIZEOF(this->svc_access_flags[0]); if (id < BITSIZEOF(this->svc_access_flags)) { SetSvcAllowedImpl(this->svc_access_flags, id); return true; diff --git a/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp b/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp index 1abd5dc3..67a18aee 100644 --- a/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp +++ b/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp @@ -22,7 +22,20 @@ namespace ams::kern::arch::arm64 { void SupervisorModeThreadStarter(); void OnThreadStart() { - MESOSPHERE_TODO_IMPLEMENT(); + MESOSPHERE_ASSERT(!KInterruptManager::AreInterruptsEnabled()); + /* Send KDebug event for this thread's creation. */ + { + KScopedInterruptEnable ei; + /* TODO */ + } + + /* Handle any pending dpc. */ + while (GetCurrentThread().HasDpc()) { + KDpcManager::HandleDpc(); + } + + /* Clear our status as in an exception handler */ + GetCurrentThread().ClearInExceptionHandler(); } namespace {