mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-24 19:54:22 -04:00
kern: clean up majority of TODOs
This commit is contained in:
parent
bea550ebce
commit
e1f3bb10a5
30 changed files with 112 additions and 85 deletions
|
@ -26,7 +26,7 @@ namespace ams::kern::arch::arm64 {
|
|||
/* Send KDebug event for this thread's creation. */
|
||||
{
|
||||
KScopedInterruptEnable ei;
|
||||
/* TODO */
|
||||
KDebug::OnDebugEvent(ams::svc::DebugEvent_CreateThread, GetCurrentThread().GetId(), GetInteger(GetCurrentThread().GetThreadLocalRegionAddress()), GetCurrentThread().GetEntrypoint());
|
||||
}
|
||||
|
||||
/* Handle any pending dpc. */
|
||||
|
@ -263,4 +263,8 @@ namespace ams::kern::arch::arm64 {
|
|||
out->fpsr = t_ctx->GetFpsr();
|
||||
}
|
||||
|
||||
void KThreadContext::OnThreadTerminating(const KThread *thread) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -129,8 +129,7 @@ namespace ams::kern::init {
|
|||
|
||||
/* NOTE: This can't be used right now because we don't have all these types implemented. */
|
||||
/* Once we do, uncomment the following and stop using the hardcoded size. */
|
||||
/* TODO: FOREACH_SLAB_TYPE(ADD_SLAB_SIZE) */
|
||||
size = 0x647000;
|
||||
FOREACH_SLAB_TYPE(ADD_SLAB_SIZE)
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ namespace ams::kern {
|
|||
}
|
||||
|
||||
bool KClientPort::IsSignaled() const {
|
||||
/* TODO: Check preconditions later. */
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
return this->num_sessions < this->max_sessions;
|
||||
}
|
||||
|
|
|
@ -305,7 +305,7 @@ namespace ams::kern {
|
|||
this->old_process_state = this->process->SetDebugObject(this);
|
||||
|
||||
/* Send an event for our attaching to the process. */
|
||||
this->PushDebugEvent(ams::svc::DebugEvent_AttachProcess);
|
||||
this->PushDebugEvent(ams::svc::DebugEvent_CreateProcess);
|
||||
|
||||
/* Send events for attaching to each thread in the process. */
|
||||
{
|
||||
|
@ -320,7 +320,7 @@ namespace ams::kern {
|
|||
it->SetDebugAttached();
|
||||
|
||||
/* Send the event. */
|
||||
this->PushDebugEvent(ams::svc::DebugEvent_AttachThread, it->GetId(), GetInteger(it->GetThreadLocalRegionAddress()), it->GetEntrypoint());
|
||||
this->PushDebugEvent(ams::svc::DebugEvent_CreateThread, it->GetId(), GetInteger(it->GetThreadLocalRegionAddress()), it->GetEntrypoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -561,12 +561,12 @@ namespace ams::kern {
|
|||
|
||||
/* Set event specific fields. */
|
||||
switch (event) {
|
||||
case ams::svc::DebugEvent_AttachProcess:
|
||||
case ams::svc::DebugEvent_CreateProcess:
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
break;
|
||||
case ams::svc::DebugEvent_AttachThread:
|
||||
case ams::svc::DebugEvent_CreateThread:
|
||||
{
|
||||
/* Set the thread id. */
|
||||
info->thread_id = param0;
|
||||
|
@ -584,7 +584,7 @@ namespace ams::kern {
|
|||
|
||||
/* Clear the thread id and flags. */
|
||||
info->thread_id = 0;
|
||||
info->flags = 0 /* TODO: enum this in ams::svc */;
|
||||
info->flags = 0;
|
||||
}
|
||||
break;
|
||||
case ams::svc::DebugEvent_ExitThread:
|
||||
|
@ -720,21 +720,21 @@ namespace ams::kern {
|
|||
|
||||
/* Set event specific fields. */
|
||||
switch (info->event) {
|
||||
case ams::svc::DebugEvent_AttachProcess:
|
||||
case ams::svc::DebugEvent_CreateProcess:
|
||||
{
|
||||
out->info.attach_process.program_id = process->GetProgramId();
|
||||
out->info.attach_process.process_id = process->GetId();
|
||||
out->info.attach_process.flags = process->GetCreateProcessFlags();
|
||||
out->info.attach_process.user_exception_context_address = GetInteger(process->GetProcessLocalRegionAddress());
|
||||
out->info.create_process.program_id = process->GetProgramId();
|
||||
out->info.create_process.process_id = process->GetId();
|
||||
out->info.create_process.flags = process->GetCreateProcessFlags();
|
||||
out->info.create_process.user_exception_context_address = GetInteger(process->GetProcessLocalRegionAddress());
|
||||
|
||||
std::memcpy(out->info.attach_process.name, process->GetName(), sizeof(out->info.attach_process.name));
|
||||
std::memcpy(out->info.create_process.name, process->GetName(), sizeof(out->info.create_process.name));
|
||||
}
|
||||
break;
|
||||
case ams::svc::DebugEvent_AttachThread:
|
||||
case ams::svc::DebugEvent_CreateThread:
|
||||
{
|
||||
out->info.attach_thread.thread_id = info->info.create_thread.thread_id;
|
||||
out->info.attach_thread.tls_address = info->info.create_thread.tls_address;
|
||||
out->info.attach_thread.entrypoint = info->info.create_thread.entrypoint;
|
||||
out->info.create_thread.thread_id = info->info.create_thread.thread_id;
|
||||
out->info.create_thread.tls_address = info->info.create_thread.tls_address;
|
||||
out->info.create_thread.entrypoint = info->info.create_thread.entrypoint;
|
||||
}
|
||||
break;
|
||||
case ams::svc::DebugEvent_ExitProcess:
|
||||
|
@ -882,8 +882,8 @@ namespace ams::kern {
|
|||
/* Get the current process. */
|
||||
KProcess *process = GetCurrentProcessPointer();
|
||||
|
||||
/* If the event is AttachThread and we've already attached, there's nothing to do. */
|
||||
if (event == ams::svc::DebugEvent_AttachThread) {
|
||||
/* If the event is CreateThread and we've already attached, there's nothing to do. */
|
||||
if (event == ams::svc::DebugEvent_CreateThread) {
|
||||
R_SUCCEED_IF(GetCurrentThread().IsAttachedToDebugger());
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ namespace ams::kern {
|
|||
constexpr size_t CoreLocalRegionSize = PageSize * (1 + cpu::NumCores);
|
||||
constexpr size_t CoreLocalRegionSizeWithGuards = CoreLocalRegionSize + 2 * PageSize;
|
||||
constexpr size_t CoreLocalRegionBoundsAlign = 1_GB;
|
||||
/* TODO: static_assert(CoreLocalRegionSize == sizeof(KCoreLocalRegion)); */
|
||||
static_assert(CoreLocalRegionSize == sizeof(KCoreLocalRegion));
|
||||
|
||||
KVirtualAddress GetCoreLocalRegionVirtualAddress() {
|
||||
while (true) {
|
||||
|
|
|
@ -999,8 +999,8 @@ namespace ams::kern {
|
|||
if (address == Null<KProcessAddress>) {
|
||||
/* NOTE: Nintendo does not account for guard pages here. */
|
||||
/* This may theoretically cause an offset to be chosen that cannot be mapped. */
|
||||
/* TODO: Should we account for guard pages? */
|
||||
const size_t offset_pages = KSystemControl::GenerateRandomRange(0, region_num_pages - num_pages);
|
||||
/* We will account for guard pages. */
|
||||
const size_t offset_pages = KSystemControl::GenerateRandomRange(0, region_num_pages - num_pages - guard_pages);
|
||||
address = this->memory_block_manager.FindFreeArea(region_start + offset_pages * PageSize, region_num_pages - offset_pages, num_pages, alignment, offset, guard_pages);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,9 @@ namespace ams::kern {
|
|||
}
|
||||
if (this->state.should_count_idle) {
|
||||
if (AMS_LIKELY(highest_thread != nullptr)) {
|
||||
/* TODO: Set parent process's idle count if it exists. */
|
||||
if (KProcess *process = highest_thread->GetOwnerProcess(); process != nullptr) {
|
||||
process->SetRunningThread(this->core_id, highest_thread, this->state.idle_count);
|
||||
}
|
||||
} else {
|
||||
this->state.idle_count++;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@ namespace ams::kern {
|
|||
}
|
||||
|
||||
bool KServerPort::IsSignaled() const {
|
||||
/* TODO: Check preconditions later. */
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
if (this->IsLight()) {
|
||||
return !this->light_session_list.empty();
|
||||
|
|
|
@ -32,6 +32,19 @@ namespace ams::kern {
|
|||
void KSynchronizationObject::Finalize() {
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
|
||||
/* If auditing, ensure that the object has no waiters. */
|
||||
#if defined(MESOSPHERE_BUILD_FOR_AUDITING)
|
||||
{
|
||||
KScopedSchedulerLock sl;
|
||||
|
||||
auto end = this->end();
|
||||
for (auto it = this->begin(); it != end; ++it) {
|
||||
KThread *thread = std::addressof(*it);
|
||||
MESOSPHERE_LOG("KSynchronizationObject::Finalize(%p) with %p (id=%ld) waiting.\n", this, thread, thread->GetId());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
this->OnFinalizeSynchronizationObject();
|
||||
KAutoObject::Finalize();
|
||||
}
|
||||
|
@ -39,7 +52,33 @@ namespace ams::kern {
|
|||
void KSynchronizationObject::DebugWaiters() {
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
|
||||
MESOSPHERE_TODO("Do useful debug operation here.");
|
||||
/* If debugging, dump the list of waiters. */
|
||||
#if defined(MESOSPHERE_BUILD_FOR_DEBUGGING)
|
||||
{
|
||||
KScopedSchedulerLock sl;
|
||||
|
||||
MESOSPHERE_RELEASE_LOG("Threads waiting on %p:\n", this);
|
||||
|
||||
bool has_waiters = false;
|
||||
auto end = this->end();
|
||||
for (auto it = this->begin(); it != end; ++it) {
|
||||
KThread *thread = std::addressof(*it);
|
||||
|
||||
if (KProcess *process = thread->GetOwnerProcess(); process != nullptr) {
|
||||
MESOSPHERE_RELEASE_LOG(" %p tid=%ld pid=%ld (%s)\n", thread, thread->GetId(), process->GetId(), process->GetName());
|
||||
} else {
|
||||
MESOSPHERE_RELEASE_LOG(" %p tid=%ld (Kernel)\n", thread, thread->GetId());
|
||||
}
|
||||
|
||||
has_waiters = true;
|
||||
}
|
||||
|
||||
/* If we didn't have any waiters, print so. */
|
||||
if (!has_waiters) {
|
||||
MESOSPHERE_RELEASE_LOG(" None\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
KSynchronizationObject::iterator KSynchronizationObject::RegisterWaitingThread(KThread *thread) {
|
||||
|
|
|
@ -344,7 +344,8 @@ namespace ams::kern {
|
|||
this->signaled = true;
|
||||
this->NotifyAvailable();
|
||||
|
||||
/* TODO: On Thread Termination handler */
|
||||
/* Call the on thread termination handler. */
|
||||
KThreadContext::OnThreadTerminating(this);
|
||||
|
||||
/* Clear previous thread in KScheduler. */
|
||||
KScheduler::ClearPreviousThread(this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue