kern: implement SvcSignalToAddress, SvcWaitForAddress

This commit is contained in:
Michael Scire 2020-07-16 19:06:48 -07:00 committed by SciresM
parent a0cc22302c
commit 8d507aa5a1
7 changed files with 292 additions and 16 deletions

View file

@ -149,6 +149,26 @@ namespace ams::kern::arch::arm64::cpu {
return true;
}
ALWAYS_INLINE bool CanAccessAtomic(KProcessAddress addr, bool privileged = false) {
const uintptr_t va = GetInteger(addr);
u64 phys_addr;
if (privileged) {
__asm__ __volatile__("at s1e1w, %[va]" :: [va]"r"(va) : "memory");
} else {
__asm__ __volatile__("at s1e0w, %[va]" :: [va]"r"(va) : "memory");
}
InstructionMemoryBarrier();
u64 par = GetParEl1();
if (par & 0x1) {
return false;
}
return (par >> BITSIZEOF(par) - BITSIZEOF(u8)) == 0xFF;
}
/* Synchronization helpers. */
NOINLINE void SynchronizeAllCores();

View file

@ -39,6 +39,9 @@ namespace ams::kern::arch::arm64 {
static bool ClearMemoryAligned64Bit(void *dst, size_t size);
static bool ClearMemorySize32Bit(void *dst);
static bool UpdateIfEqualAtomic(s32 *out, s32 *address, s32 compare_value, s32 new_value);
static bool DecrementIfLessThanAtomic(s32 *out, s32 *address, s32 compare);
static bool StoreDataCache(uintptr_t start, uintptr_t end);
static bool FlushDataCache(uintptr_t start, uintptr_t end);
static bool InvalidateDataCache(uintptr_t start, uintptr_t end);