diff --git a/libraries/libmesosphere/include/mesosphere/kern_common.hpp b/libraries/libmesosphere/include/mesosphere/kern_common.hpp index 90402fd74..db9679f6b 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_common.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_common.hpp @@ -15,8 +15,6 @@ */ #pragma once #include -#include -#include namespace ams::kern { @@ -36,3 +34,5 @@ namespace ams::kern { #define MESOSPHERE_ENABLE_ASSERTIONS #define MESOSPHERE_ENABLE_DEBUG_PRINT #endif + +#include diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp index 967ae19b5..33e38bc5b 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp @@ -14,6 +14,7 @@ * along with this program. If not, see . */ #pragma once +#include #include #include #include @@ -27,12 +28,12 @@ namespace ams::kern { MESOSPHERE_AUTOOBJECT_TRAITS(KProcess, KSynchronizationObject); /* TODO: This is a placeholder definition. */ public: - constexpr ALWAYS_INLINE u64 GetCoreMask() const { /* TODO */ return 0; } - constexpr ALWAYS_INLINE u64 GetPriorityMask() const { /* TODO */ return 0; } + u64 GetCoreMask() const { MESOSPHERE_TODO_IMPLEMENT(); } + u64 GetPriorityMask() const { MESOSPHERE_TODO_IMPLEMENT();} - constexpr ALWAYS_INLINE bool Is64Bit() const { /* TODO */ return true; } + bool Is64Bit() const { MESOSPHERE_TODO_IMPLEMENT(); } - ALWAYS_INLINE KThread *GetPreemptionStatePinnedThread(s32 core_id) { /* TODO */ return nullptr; } + KThread *GetPreemptionStatePinnedThread(s32 core_id) { MESOSPHERE_TODO_IMPLEMENT(); } void SetPreemptionState(); }; diff --git a/libraries/libmesosphere/include/mesosphere/kern_panic.hpp b/libraries/libmesosphere/include/mesosphere/kern_panic.hpp index 02f607500..3bcdd4f24 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_panic.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_panic.hpp @@ -52,6 +52,9 @@ namespace ams::kern { #define MESOSPHERE_ASSERT_THIS() #endif +#define MESOSPHERE_TODO(arg) ({ constexpr const char *__mesosphere_todo = arg; MESOSPHERE_PANIC("TODO (%s): %s", __PRETTY_FUNCTION__, __mesosphere_todo); }) +#define MESOSPHERE_TODO_IMPLEMENT() MESOSPHERE_TODO("Implement") + #define MESOSPHERE_ABORT() MESOSPHERE_PANIC("Abort()"); #define MESOSPHERE_INIT_ABORT() do { /* ... */ } while (true) diff --git a/libraries/libmesosphere/include/mesosphere/kern_select_cpu.hpp b/libraries/libmesosphere/include/mesosphere/kern_select_cpu.hpp index 6c3ac104b..aec84c580 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_select_cpu.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_select_cpu.hpp @@ -14,6 +14,7 @@ * along with this program. If not, see . */ #pragma once +#include #ifdef ATMOSPHERE_ARCH_ARM64 #include diff --git a/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp b/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp index 1ab3d0d6e..0ae846a34 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_exception_handlers.cpp @@ -55,25 +55,26 @@ namespace ams::kern::arm64 { break; default: { - /* TODO: Get memory state. */ + MESOSPHERE_TODO("Get memory state."); /* If state is KMemoryState_Code and the user can't read it, set should_process_user_exception = true; */ } break; } if (should_process_user_exception) { - /* TODO: Process the user exception. */ + MESOSPHERE_TODO("Process the user exception."); } { - /* TODO: Process for KDebug. */ + MESOSPHERE_TODO("Process for KDebug."); - MESOSPHERE_RELEASE_LOG("Exception occurred. %016lx\n", 0ul /* TODO: cur_process->GetProgramId() */); + MESOSPHERE_TODO("cur_process->GetProgramId()"); + MESOSPHERE_RELEASE_LOG("Exception occurred. %016lx\n", 0ul); - /* TODO: if (!svc::ResultNotHandled::Includes(res)) { debug process } */ + MESOSPHERE_TODO("if (!svc::ResultNotHandled::Includes(res)) { debug process }."); } - /* TODO: cur_process->Exit(); */ + MESOSPHERE_TODO("cur_process->Exit();"); (void)cur_process; } diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp index c1fec3e51..f52a6d53f 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp @@ -85,7 +85,7 @@ namespace ams::kern::arm64 { /* If the task isn't the dummy task, we should add it to the queue. */ if (task != GetDummyInterruptTask()) { - /* TODO: Kernel::GetInterruptTaskManager().Enqueue(task); */ + MESOSPHERE_TODO("Kernel::GetInterruptTaskManager().Enqueue(task);"); } return true; diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp index 4cc2c828f..08bf99918 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp @@ -22,7 +22,7 @@ namespace ams::kern::arm64 { void SupervisorModeThreadStarter(); void OnThreadStart() { - /* TODO: Implement this. */ + MESOSPHERE_TODO_IMPLEMENT(); } namespace { diff --git a/libraries/libmesosphere/source/kern_k_light_lock.cpp b/libraries/libmesosphere/source/kern_k_light_lock.cpp index b77bcf888..7e8fdcc66 100644 --- a/libraries/libmesosphere/source/kern_k_light_lock.cpp +++ b/libraries/libmesosphere/source/kern_k_light_lock.cpp @@ -18,11 +18,11 @@ namespace ams::kern { void KLightLock::LockSlowPath(uintptr_t owner, uintptr_t cur_thread) { - /* TODO: Implement (requires KThread, KScheduler) */ + MESOSPHERE_TODO_IMPLEMENT(); } void KLightLock::UnlockSlowPath(uintptr_t cur_thread) { - /* TODO: Implement (requires KThread, KScheduler) */ + MESOSPHERE_TODO_IMPLEMENT(); } } diff --git a/libraries/libmesosphere/source/kern_k_process.cpp b/libraries/libmesosphere/source/kern_k_process.cpp index 127fe2915..703904b30 100644 --- a/libraries/libmesosphere/source/kern_k_process.cpp +++ b/libraries/libmesosphere/source/kern_k_process.cpp @@ -18,7 +18,7 @@ namespace ams::kern { void KProcess::SetPreemptionState() { - /* TODO */ + MESOSPHERE_TODO_IMPLEMENT(); } } diff --git a/libraries/libmesosphere/source/kern_k_scheduler.cpp b/libraries/libmesosphere/source/kern_k_scheduler.cpp index 5e4d18733..4bd37ed57 100644 --- a/libraries/libmesosphere/source/kern_k_scheduler.cpp +++ b/libraries/libmesosphere/source/kern_k_scheduler.cpp @@ -34,7 +34,7 @@ namespace ams::kern { ALWAYS_INLINE void IncrementScheduledCount(KThread *thread) { if (KProcess *parent = thread->GetOwnerProcess(); parent != nullptr) { - /* TODO: parent->IncrementScheduledCount(); */ + MESOSPHERE_TODO("parent->IncrementScheduledCount();"); } } @@ -66,7 +66,7 @@ namespace ams::kern { void KScheduler::Activate() { MESOSPHERE_ASSERT(GetCurrentThread().GetDisableDispatchCount() == 1); - this->state.should_count_idle = false /* TODO: Retrieve from KSystemControl. */; + this->state.should_count_idle = KTargetSystem::IsDebugMode(); this->is_active = true; RescheduleCurrentCore(); } @@ -230,7 +230,7 @@ namespace ams::kern { const s64 tick_diff = cur_tick - prev_tick; cur_thread->AddCpuTime(tick_diff); if (cur_process != nullptr) { - /* TODO: cur_process->AddCpuTime(tick_diff); */ + MESOSPHERE_TODO("cur_process->AddCpuTime(tick_diff);"); } this->last_context_switch_time = cur_tick; @@ -248,7 +248,7 @@ namespace ams::kern { /* Switch the current process, if we're switching processes. */ if (KProcess *next_process = next_thread->GetOwnerProcess(); next_process != cur_process) { - /* TODO: KProcess::Switch */ + MESOSPHERE_TODO("KProcess::Switch"); } /* Set the new Thread Local region. */ diff --git a/libraries/libmesosphere/source/kern_k_synchronization_object.cpp b/libraries/libmesosphere/source/kern_k_synchronization_object.cpp index 54bd488b4..97cc58ffb 100644 --- a/libraries/libmesosphere/source/kern_k_synchronization_object.cpp +++ b/libraries/libmesosphere/source/kern_k_synchronization_object.cpp @@ -20,15 +20,13 @@ namespace ams::kern { void NotifyAvailable() { MESOSPHERE_ASSERT_THIS(); - /* TODO: Implement this. */ - MESOSPHERE_ABORT(); + MESOSPHERE_TODO_IMPLEMENT(); } void NotifyAbort(Result abort_reason) { MESOSPHERE_ASSERT_THIS(); - /* TODO: Implement this. */ - MESOSPHERE_ABORT(); + MESOSPHERE_TODO_IMPLEMENT(); } void KSynchronizationObject::Finalize() { @@ -41,7 +39,7 @@ namespace ams::kern { void KSynchronizationObject::DebugWaiters() { MESOSPHERE_ASSERT_THIS(); - /* TODO: Do useful debug operation here. */ + MESOSPHERE_TODO("Do useful debug operation here."); } KSynchronizationObject::iterator KSynchronizationObject::AddWaiterThread(KThread *thread) { diff --git a/libraries/libmesosphere/source/kern_k_thread.cpp b/libraries/libmesosphere/source/kern_k_thread.cpp index 42bb0c428..fc2ec73ac 100644 --- a/libraries/libmesosphere/source/kern_k_thread.cpp +++ b/libraries/libmesosphere/source/kern_k_thread.cpp @@ -23,10 +23,10 @@ namespace ams::kern { const uintptr_t stack_bottom = stack_top - PageSize; KPhysicalAddress stack_paddr = Null; - /* TODO: MESOSPHERE_ABORT_UNLESS(Kernel::GetSupervisorPageTable().GetPhysicalAddress(&stack_paddr, stack_bottom)); */ + MESOSPHERE_TODO("MESOSPHERE_ABORT_UNLESS(Kernel::GetSupervisorPageTable().GetPhysicalAddress(&stack_paddr, stack_bottom));"); (void)stack_bottom; - /* TODO: MESOSPHERE_R_ABORT_UNLESS(Kernel::GetSupervisorPageTable().Unmap(...) */ + MESOSPHERE_TODO("MESOSPHERE_R_ABORT_UNLESS(Kernel::GetSupervisorPageTable().Unmap(...);"); (void)stack_paddr; /* Free the stack page. */ @@ -149,8 +149,8 @@ namespace ams::kern { /* Setup the TLS, if needed. */ if (type == ThreadType_User) { - /* TODO: R_TRY(owner->CreateThreadLocalRegion(&this->tls_address)); */ - /* TODO: this->tls_heap_address = owner->GetThreadLocalRegionAddress(this->tls_address); */ + MESOSPHERE_TODO("R_TRY(owner->CreateThreadLocalRegion(&this->tls_address));"); + MESOSPHERE_TODO("this->tls_heap_address = owner->GetThreadLocalRegionAddress(this->tls_address);"); std::memset(this->tls_heap_address, 0, ams::svc::ThreadLocalRegionSize); } @@ -158,7 +158,7 @@ namespace ams::kern { if (owner != nullptr) { this->parent = owner; this->parent->Open(); - /* TODO: this->parent->IncrementThreadCount(); */ + MESOSPHERE_TODO("this->parent->IncrementThreadCount();"); } /* Initialize thread context. */ @@ -171,7 +171,7 @@ namespace ams::kern { /* Setup the stack parameters. */ StackParameters &sp = this->GetStackParameters(); if (this->parent != nullptr) { - /* TODO: this->parent->CopySvcPermissionTo(pos.svc_permission); */ + MESOSPHERE_TODO("this->parent->CopySvcPermissionTo(sp.svc_permission);"); } sp.context = std::addressof(this->thread_context); sp.disable_count = 1; @@ -185,8 +185,8 @@ namespace ams::kern { /* Register ourselves with our parent process. */ if (this->parent != nullptr) { - /* TODO: this->parent->RegisterThread(this); */ - /* TODO: if (this->parent->IsSuspended()) { this->RequestSuspend(SuspendType_Process); } */ + MESOSPHERE_TODO("this->parent->RegisterThread(this);"); + MESOSPHERE_TODO("if (this->parent->IsSuspended()) { this->RequestSuspend(SuspendType_Process);"); } return ResultSuccess(); @@ -205,7 +205,7 @@ namespace ams::kern { KProcessAddress stack_top = Null; { auto page_guard = SCOPE_GUARD { KPageBuffer::Free(page); }; - /* TODO: R_TRY(Kernel::GetSupervisorPageTable().Map); ... */ + MESOSPHERE_TODO("R_TRY(Kernel::GetSupervisorPageTable().Map); ..."); (void)(stack_region); page_guard.Cancel(); } @@ -222,16 +222,16 @@ namespace ams::kern { KProcess *owner = reinterpret_cast(arg & ~1ul); const bool resource_limit_release_hint = (arg & 1); if (owner != nullptr) { - /* TODO: Release from owner resource limit. */ + MESOSPHERE_TODO("Release from owner resource limit."); (void)(resource_limit_release_hint); owner->Close(); } else { - /* TODO: Release from system resource limit. */ + MESOSPHERE_TODO("Release from system resource limit."); } } void KThread::Finalize() { - /* TODO */ + MESOSPHERE_TODO_IMPLEMENT(); } bool KThread::IsSignaled() const { @@ -239,11 +239,11 @@ namespace ams::kern { } void KThread::OnTimer() { - /* TODO */ + MESOSPHERE_TODO_IMPLEMENT(); } void KThread::DoWorkerTask() { - /* TODO */ + MESOSPHERE_TODO_IMPLEMENT(); } Result KThread::SetPriorityToIdle() { @@ -335,7 +335,7 @@ namespace ams::kern { void KThread::Exit() { MESOSPHERE_ASSERT_THIS(); - /* TODO */ + MESOSPHERE_TODO_IMPLEMENT(); MESOSPHERE_PANIC("KThread::Exit() would return"); } diff --git a/libraries/libmesosphere/source/kern_k_thread_local_page.cpp b/libraries/libmesosphere/source/kern_k_thread_local_page.cpp index efc5a3099..e19e4d4d9 100644 --- a/libraries/libmesosphere/source/kern_k_thread_local_page.cpp +++ b/libraries/libmesosphere/source/kern_k_thread_local_page.cpp @@ -29,7 +29,7 @@ namespace ams::kern { auto page_buf_guard = SCOPE_GUARD { KPageBuffer::Free(page_buf); }; /* Map the address in. */ - /* TODO: R_TRY(this->owner->GetPageTable().Map(...)); */ + MESOSPHERE_TODO("R_TRY(this->owner->GetPageTable().Map(...));"); /* We succeeded. */ page_buf_guard.Cancel(); @@ -41,10 +41,10 @@ namespace ams::kern { /* Get the physical address of the page. */ KPhysicalAddress phys_addr = Null; - /* TODO: MESOSPHERE_ABORT_UNLESS(this->owner->GetPageTable().GetPhysicalAddress(&phys_addr, this->GetAddress())); */ + MESOSPHERE_TODO("MESOSPHERE_ABORT_UNLESS(this->owner->GetPageTable().GetPhysicalAddress(&phys_addr, this->GetAddress()));"); /* Unmap the page. */ - /* TODO: R_TRY(this->owner->GetPageTable().Unmap(...); */ + MESOSPHERE_TODO("R_TRY(this->owner->GetPageTable().Unmap(...);"); /* Free the page. */ KPageBuffer::Free(KPageBuffer::FromPhysicalAddress(phys_addr)); diff --git a/libraries/libmesosphere/source/kern_main.cpp b/libraries/libmesosphere/source/kern_main.cpp index cd007dee2..f54f76492 100644 --- a/libraries/libmesosphere/source/kern_main.cpp +++ b/libraries/libmesosphere/source/kern_main.cpp @@ -71,13 +71,13 @@ namespace ams::kern { /* Initialize the supervisor page table for each core. */ DoOnEachCoreInOrder(core_id, [=]() ALWAYS_INLINE_LAMBDA { - /* TODO: KPageTable::Initialize(); */ - /* TODO: Kernel::GetSupervisorPageTable().Initialize(); */ + MESOSPHERE_TODO("KPageTable::Initialize();"); + MESOSPHERE_TODO("Kernel::GetSupervisorPageTable().Initialize();"); }); /* Set ttbr0 for each core. */ DoOnEachCoreInOrder(core_id, [=]() ALWAYS_INLINE_LAMBDA { - /* TODO: SetTtbr0(); */ + MESOSPHERE_TODO("SetTtbr0();"); }); /* NOTE: Kernel calls on each core a nullsub here on retail kernel. */ @@ -86,7 +86,7 @@ namespace ams::kern { DoOnEachCoreInOrder(core_id, [=]() ALWAYS_INLINE_LAMBDA { KThread::Register(std::addressof(Kernel::GetMainThread(core_id))); KThread::Register(std::addressof(Kernel::GetIdleThread(core_id))); - /* TODO: Kernel::GetInterruptTaskManager().Initialize(); */ + MESOSPHERE_TODO("Kernel::GetInterruptTaskManager().Initialize();"); }); /* Activate the scheduler and enable interrupts. */ @@ -104,18 +104,18 @@ namespace ams::kern { /* Perform more core-0 specific initialization. */ if (core_id == 0) { - /* TODO: Initialize KWorkerThreadManager */ + MESOSPHERE_TODO("Initialize KWorkerThreadManager"); - /* TODO: KSystemControl::InitializeSleepManagerAndAppletSecureMemory(); */ + MESOSPHERE_TODO("KSystemControl::InitializeSleepManagerAndAppletSecureMemory();"); - /* TODO: KDeviceAddressSpace::Initialize(); */ + MESOSPHERE_TODO("KDeviceAddressSpace::Initialize();"); - /* TODO: CreateAndRunInitialProcesses(); */ + MESOSPHERE_TODO("CreateAndRunInitialProcesses();"); /* We're done initializing! */ Kernel::SetState(Kernel::State::Initialized); - /* TODO: KThread::ResumeThreadsSuspendedForInit(); */ + MESOSPHERE_TODO("KThread::ResumeThreadsSuspendedForInit();"); } cpu::SynchronizeAllCores();