mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
mesosphere: hard enforcement of TODOs
This commit is contained in:
parent
919b8124dc
commit
4b6b06fcaa
14 changed files with 57 additions and 53 deletions
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <mesosphere/kern_panic.hpp>
|
||||
#include <mesosphere/svc/kern_svc_results.hpp>
|
||||
|
||||
namespace ams::kern {
|
||||
|
||||
|
@ -36,3 +34,5 @@ namespace ams::kern {
|
|||
#define MESOSPHERE_ENABLE_ASSERTIONS
|
||||
#define MESOSPHERE_ENABLE_DEBUG_PRINT
|
||||
#endif
|
||||
|
||||
#include <mesosphere/svc/kern_svc_results.hpp>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <mesosphere/kern_common.hpp>
|
||||
#include <mesosphere/kern_select_cpu.hpp>
|
||||
#include <mesosphere/kern_slab_helpers.hpp>
|
||||
#include <mesosphere/kern_k_synchronization_object.hpp>
|
||||
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <mesosphere/kern_common.hpp>
|
||||
|
||||
#ifdef ATMOSPHERE_ARCH_ARM64
|
||||
#include <mesosphere/arch/arm64/kern_cpu.hpp>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace ams::kern::arm64 {
|
|||
void SupervisorModeThreadStarter();
|
||||
|
||||
void OnThreadStart() {
|
||||
/* TODO: Implement this. */
|
||||
MESOSPHERE_TODO_IMPLEMENT();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace ams::kern {
|
||||
|
||||
void KProcess::SetPreemptionState() {
|
||||
/* TODO */
|
||||
MESOSPHERE_TODO_IMPLEMENT();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -23,10 +23,10 @@ namespace ams::kern {
|
|||
const uintptr_t stack_bottom = stack_top - PageSize;
|
||||
|
||||
KPhysicalAddress stack_paddr = Null<KPhysicalAddress>;
|
||||
/* 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<KProcessAddress>;
|
||||
{
|
||||
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<KProcess *>(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");
|
||||
}
|
||||
|
|
|
@ -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<KPhysicalAddress>;
|
||||
/* 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));
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue