reactos/ntoskrnl/include/internal/arm/intrin_i.h

222 lines
3.9 KiB
C
Raw Normal View History

#pragma once
FORCEINLINE
VOID
- Implement support for reading and writing physical memory for KD. The implementation uses a reserved mapping page to map the target physical address to. On x86 this page is located at virtual address 0xFFBFF000, and the PTE for this page is the last PTE of the nonpaged pool's PDE. Other architectures may need to reserve the PTE elsewhere. - The physical memory support relies on several Mm variables and structures to be properly set up. Add a new flag, MiDbgReadyForPhysical, and set it when the debugger support can handle physical memory requests. - Protect this page with a Memory Area to make the old Mm keep its dirty hands off it. - Does not support I/O space or cache flags yet. - Add generic KeInvalidateTlbEntry to invalidate a single TLB entry for a given address instead of flushing the whole TLB. Used by the debugger physical memory support as invalidating the whole TLB for every map and unmap of its debug PTE would incur significant overhead for large copies. Replace direct usage of __invlpg() with this in x86 code too. - Fix incorrect cache flag check and set in KdpRead/WritePhysicalmemory for write combined requests. The debugger's Uncached flag was checked instead of the Write Combined flag, and the debuggers Write Combine number (0x3) was set instead of Mm's flag (0x20). - Fix implementation of MmIsAddressValid (at least for x86; other architectures will need more checks). Just check the Address' PDE and PTE valid bits instead of using Memory Areas. - Add missing ASSERTs to ensure the Memory Areas for paged pool, the PCR page, and the Shared User Data page are created. - Add missing Memory Area for the 2 pages HAL currently uses for its own mappings on x86 -- previously, those pages could have been allocated by other parts of the OS, which would have resulted in serious corruptions. svn path=/trunk/; revision=43960
2009-11-04 22:40:18 +00:00
KeArmHaltProcessor(VOID)
{
//
// Enter Wait-For-Interrupt Mode
//
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c0, 4" : : "r"(0) : "cc");
#endif
}
FORCEINLINE
ARM_CONTROL_REGISTER
KeArmControlRegisterGet(VOID)
{
ARM_CONTROL_REGISTER Value;
#ifdef _MSC_VER
Value.AsUlong = 0;
#else
__asm__ __volatile__ ("mrc p15, 0, %0, c1, c0, 0" : "=r"(Value.AsUlong) : : "cc");
#endif
return Value;
}
FORCEINLINE
ARM_ID_CODE_REGISTER
KeArmIdCodeRegisterGet(VOID)
{
ARM_ID_CODE_REGISTER Value;
#ifdef _MSC_VER
Value.AsUlong = 0;
#else
__asm__ __volatile__ ("mrc p15, 0, %0, c0, c0, 0" : "=r"(Value.AsUlong) : : "cc");
#endif
return Value;
}
FORCEINLINE
ULONG
KeArmFaultStatusRegisterGet(VOID)
{
ULONG Value;
#ifdef _MSC_VER
Value = 0;
#else
__asm__ __volatile__ ("mrc p15, 0, %0, c5, c0, 0" : "=r"(Value) : : "cc");
#endif
return Value;
}
FORCEINLINE
ULONG
KeArmInstructionFaultStatusRegisterGet(VOID)
{
ULONG Value;
#ifdef _MSC_VER
Value = 0;
#else
__asm__ __volatile__ ("mrc p15, 0, %0, c5, c0, 1" : "=r"(Value) : : "cc");
#endif
return Value;
}
FORCEINLINE
ULONG
KeArmFaultAddressRegisterGet(VOID)
{
ULONG Value;
#ifdef _MSC_VER
Value = 0;
#else
__asm__ __volatile__ ("mrc p15, 0, %0, c6, c0, 0" : "=r"(Value) : : "cc");
#endif
return Value;
}
FORCEINLINE
ARM_LOCKDOWN_REGISTER
KeArmLockdownRegisterGet(VOID)
{
ARM_LOCKDOWN_REGISTER Value;
#ifdef _MSC_VER
Value.AsUlong = 0;
#else
__asm__ __volatile__ ("mrc p15, 0, %0, c10, c0, 0" : "=r"(Value.AsUlong) : : "cc");
#endif
return Value;
}
FORCEINLINE
ARM_TTB_REGISTER
KeArmTranslationTableRegisterGet(VOID)
{
ARM_TTB_REGISTER Value;
#ifdef _MSC_VER
Value.AsUlong = 0;
#else
__asm__ __volatile__ ("mrc p15, 0, %0, c2, c0, 0" : "=r"(Value.AsUlong) : : "cc");
#endif
return Value;
}
FORCEINLINE
ARM_CACHE_REGISTER
KeArmCacheRegisterGet(VOID)
{
ARM_CACHE_REGISTER Value;
#ifdef _MSC_VER
Value.AsUlong = 0;
#else
__asm__ __volatile__ ("mrc p15, 0, %0, c0, c0, 1" : "=r"(Value.AsUlong) : : "cc");
#endif
return Value;
}
FORCEINLINE
ARM_STATUS_REGISTER
KeArmStatusRegisterGet(VOID)
{
ARM_STATUS_REGISTER Value;
#ifdef _MSC_VER
Value.AsUlong = _ReadStatusReg(0);
#else
__asm__ __volatile__ ("mrs %0, cpsr" : "=r"(Value.AsUlong) : : "cc");
#endif
return Value;
}
FORCEINLINE
VOID
KeArmControlRegisterSet(IN ARM_CONTROL_REGISTER ControlRegister)
{
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c1, c0, 0" : : "r"(ControlRegister.AsUlong) : "cc");
#endif
}
FORCEINLINE
VOID
KeArmTranslationTableRegisterSet(IN ARM_TTB_REGISTER Ttb)
{
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c2, c0, 0" : : "r"(Ttb.AsUlong) : "cc");
#endif
}
FORCEINLINE
VOID
KeArmDomainRegisterSet(IN ARM_DOMAIN_REGISTER DomainRegister)
{
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c3, c0, 0" : : "r"(DomainRegister.AsUlong) : "cc");
#endif
}
FORCEINLINE
VOID
KeArmLockdownRegisterSet(IN ARM_LOCKDOWN_REGISTER LockdownRegister)
{
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c10, c0, 0" : : "r"(LockdownRegister.AsUlong) : "cc");
#endif
}
FORCEINLINE
VOID
KeArmFlushTlb(VOID)
{
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c8, c7, 0" : : "r"(0) : "cc");
#endif
}
FORCEINLINE
VOID
KeArmInvalidateTlbEntry(IN PVOID Address)
{
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c8, c7, 1" : : "r"(Address) : "cc");
#endif
}
FORCEINLINE
VOID
KeArmInvalidateAllCaches(VOID)
{
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c7, 0" : : "r"(0) : "cc");
#endif
}
FORCEINLINE
VOID
KeArmFlushIcache(VOID)
{
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 0" : : "r"(0) : "cc");
#endif
}
FORCEINLINE
VOID
KeArmWaitForInterrupt(VOID)
{
#ifdef _MSC_VER
#else
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c0, 4" : : "r"(0) : "cc");
#endif
}