1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2025-01-17 14:51:31 +00:00

kern: fix bugs in interrupt permittance, DpcManager init

This commit is contained in:
Michael Scire 2020-07-22 18:03:12 -07:00 committed by SciresM
parent afe7e41de8
commit eecf59dd00
5 changed files with 3 additions and 14 deletions

View file

@ -233,7 +233,7 @@ namespace ams::kern {
bool SetInterruptPermitted(u32 id) {
constexpr size_t BitsPerWord = BITSIZEOF(this->irq_access_flags[0]);
if (id < BITSIZEOF(this->irq_access_flags)) {
this->irq_access_flags[id / BitsPerWord] = (1ul << (id % BitsPerWord));
this->irq_access_flags[id / BitsPerWord] |= (1ul << (id % BitsPerWord));
return true;
} else {
return false;

View file

@ -431,8 +431,6 @@ namespace ams::kern::board::nintendo::nx {
/* Get the function id for the current call. */
u64 function_id = args->r[0];
MESOSPHERE_LOG("CallSecureMonitor(%lx, %lx, %lx, %lx, %lx, %lx, %lx, %lx);\n", args->r[0], args->r[1], args->r[2], args->r[3], args->r[4], args->r[5], args->r[6], args->r[7]);
/* We'll need to map in pages if arguments are pointers. Prepare page groups to do so. */
auto &page_table = GetCurrentProcess().GetPageTable();
auto *bim = page_table.GetBlockInfoManager();
@ -455,10 +453,8 @@ namespace ams::kern::board::nintendo::nx {
KPhysicalAddress phys_addr = page_table.GetHeapPhysicalAddress(it->GetAddress());
args->r[reg_id] = GetInteger(phys_addr) | (GetInteger(virt_addr) & (PageSize - 1));
MESOSPHERE_LOG("Mapped arg %zu\n", reg_id);
} else {
/* If we couldn't map, we should clear the address. */
MESOSPHERE_LOG("Failed to map arg %zu\n", reg_id);
args->r[reg_id] = 0;
}
}
@ -467,8 +463,6 @@ namespace ams::kern::board::nintendo::nx {
/* Invoke the secure monitor. */
smc::CallSecureMonitorFromUser(args);
MESOSPHERE_LOG("Secure Monitor Returned: (%lx, %lx, %lx, %lx, %lx, %lx, %lx, %lx);\n", args->r[0], args->r[1], args->r[2], args->r[3], args->r[4], args->r[5], args->r[6], args->r[7]);
/* Make sure that we close any pages that we opened. */
for (size_t i = 0; i < MaxMappedRegisters; i++) {
page_groups[i].Close();

View file

@ -126,9 +126,9 @@ namespace ams::kern {
/* Launch the new thread. */
g_preemption_priorities[core_id] = priority;
if (core_id == cpu::NumCores - 1) {
MESOSPHERE_R_ABORT_UNLESS(KThread::InitializeKernelThread(new_thread, DpcManagerNormalThreadFunction, 0, DpcManagerThreadPriority, core_id));
} else {
MESOSPHERE_R_ABORT_UNLESS(KThread::InitializeKernelThread(new_thread, DpcManagerPreemptionThreadFunction, 0, DpcManagerThreadPriority, core_id));
} else {
MESOSPHERE_R_ABORT_UNLESS(KThread::InitializeKernelThread(new_thread, DpcManagerNormalThreadFunction, 0, DpcManagerThreadPriority, core_id));
}
/* Register the new thread. */

View file

@ -30,7 +30,6 @@ namespace ams::kern::svc {
R_UNLESS(!IsKernelAddress(address), svc::ResultInvalidCurrentMemory());
R_UNLESS(util::IsAligned(address, sizeof(u32)), svc::ResultInvalidAddress());
MESOSPHERE_LOG("%lx: ArbitrateLock(%08x, %lx, %08x)\n", GetCurrentThread().GetId(), thread_handle, address, tag);
return GetCurrentProcess().WaitForAddress(thread_handle, address, tag);
}
@ -39,7 +38,6 @@ namespace ams::kern::svc {
R_UNLESS(!IsKernelAddress(address), svc::ResultInvalidCurrentMemory());
R_UNLESS(util::IsAligned(address, sizeof(u32)), svc::ResultInvalidAddress());
MESOSPHERE_LOG("%lx: ArbitrateUnlock(%lx)\n", GetCurrentThread().GetId(), address);
return GetCurrentProcess().SignalToAddress(address);
}

View file

@ -22,9 +22,6 @@ namespace ams::kern::svc {
namespace {
Result MapMemory(uintptr_t dst_address, uintptr_t src_address, size_t size) {
/* Log the call parameters for debugging. */
MESOSPHERE_LOG("MapMemory(%zx, %zx, %zx)\n", dst_address, src_address, size);
/* Validate that addresses are page aligned. */
R_UNLESS(util::IsAligned(dst_address, PageSize), svc::ResultInvalidAddress());
R_UNLESS(util::IsAligned(src_address, PageSize), svc::ResultInvalidAddress());