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

182 lines
3.3 KiB
C
Raw Normal View History

#pragma once
#include "intrin_i.h"
#define KiServiceExit2 KiExceptionExit
#define SYNCH_LEVEL DISPATCH_LEVEL
#define PCR ((KPCR * const)KIP0PCRADDRESS)
//
//Lockdown TLB entries
//
#define PCR_ENTRY 0
#define PDR_ENTRY 2
Mega KD64 revival patch: KD64 - Fix some 64-bit issues and some x86 specificness. - Sub out some KdpTrap cases more properly. - Implement support for .crash and .reboot. Does not seem to work currently because of weird issues. - Implement KdpDprintf to send strings directly to the debugger from inside of KD64. Use it in KdEnterDebugger instead of DbgPrint so we won't try to enter the debugger recursively. - Implement KdUpdateDataBlock to set the KeUserCallbackDispatcher pointer in the debugger block after its address is retrieved from ntdll. - Don't assume breakpoints are 1 byte long in portable code -- use KD_BREAKPOINT_SIZE and define it per architecture. - KdpStub: KdEnableDebugger returns NTSTATUS, not TRUE/FALSE. Other - wdbgexts.h: Properly define CURRENT_KD_SECONDARY_VERSION for AMD64. - Make PsNtosImageBase pointer-sized as it should be. - Change the definition of KDSTATUS so it is guaranteed to be 32-bit. - Fix a critical bug in KiRestoreProcessorControlState: it didn't clear the busy flag in the TSS before reloading the task register, resulting in a GPF if we tried to reload the same register. - Add macros for getting and setting special purpose registers (the Program Counter and the "return register") in portable code instead of using #ifdef every time. Do likewise for setting IMAGE_FILE_MACHINE_XXX, using a new IMAGE_FILE_MACHINE_ARCHITECTURE macro. - Don't refer to the Program Counter as "Eip" in portable code. - Define DBG_STATUS_CONTROL_C for assembly code and use it in KeUpdateSystemTime. svn path=/trunk/; revision=43283
2009-10-04 16:53:15 +00:00
//
// BKPT is 4 bytes long
//
#define KD_BREAKPOINT_TYPE ULONG
#define KD_BREAKPOINT_SIZE sizeof(ULONG)
#define KD_BREAKPOINT_VALUE 0xDEFE
Mega KD64 revival patch: KD64 - Fix some 64-bit issues and some x86 specificness. - Sub out some KdpTrap cases more properly. - Implement support for .crash and .reboot. Does not seem to work currently because of weird issues. - Implement KdpDprintf to send strings directly to the debugger from inside of KD64. Use it in KdEnterDebugger instead of DbgPrint so we won't try to enter the debugger recursively. - Implement KdUpdateDataBlock to set the KeUserCallbackDispatcher pointer in the debugger block after its address is retrieved from ntdll. - Don't assume breakpoints are 1 byte long in portable code -- use KD_BREAKPOINT_SIZE and define it per architecture. - KdpStub: KdEnableDebugger returns NTSTATUS, not TRUE/FALSE. Other - wdbgexts.h: Properly define CURRENT_KD_SECONDARY_VERSION for AMD64. - Make PsNtosImageBase pointer-sized as it should be. - Change the definition of KDSTATUS so it is guaranteed to be 32-bit. - Fix a critical bug in KiRestoreProcessorControlState: it didn't clear the busy flag in the TSS before reloading the task register, resulting in a GPF if we tried to reload the same register. - Add macros for getting and setting special purpose registers (the Program Counter and the "return register") in portable code instead of using #ifdef every time. Do likewise for setting IMAGE_FILE_MACHINE_XXX, using a new IMAGE_FILE_MACHINE_ARCHITECTURE macro. - Don't refer to the Program Counter as "Eip" in portable code. - Define DBG_STATUS_CONTROL_C for assembly code and use it in KeUpdateSystemTime. svn path=/trunk/; revision=43283
2009-10-04 16:53:15 +00:00
//
// Maximum IRQs
//
#define MAXIMUM_VECTOR 16
Mega KD64 revival patch: KD64 - Fix some 64-bit issues and some x86 specificness. - Sub out some KdpTrap cases more properly. - Implement support for .crash and .reboot. Does not seem to work currently because of weird issues. - Implement KdpDprintf to send strings directly to the debugger from inside of KD64. Use it in KdEnterDebugger instead of DbgPrint so we won't try to enter the debugger recursively. - Implement KdUpdateDataBlock to set the KeUserCallbackDispatcher pointer in the debugger block after its address is retrieved from ntdll. - Don't assume breakpoints are 1 byte long in portable code -- use KD_BREAKPOINT_SIZE and define it per architecture. - KdpStub: KdEnableDebugger returns NTSTATUS, not TRUE/FALSE. Other - wdbgexts.h: Properly define CURRENT_KD_SECONDARY_VERSION for AMD64. - Make PsNtosImageBase pointer-sized as it should be. - Change the definition of KDSTATUS so it is guaranteed to be 32-bit. - Fix a critical bug in KiRestoreProcessorControlState: it didn't clear the busy flag in the TSS before reloading the task register, resulting in a GPF if we tried to reload the same register. - Add macros for getting and setting special purpose registers (the Program Counter and the "return register") in portable code instead of using #ifdef every time. Do likewise for setting IMAGE_FILE_MACHINE_XXX, using a new IMAGE_FILE_MACHINE_ARCHITECTURE macro. - Don't refer to the Program Counter as "Eip" in portable code. - Define DBG_STATUS_CONTROL_C for assembly code and use it in KeUpdateSystemTime. svn path=/trunk/; revision=43283
2009-10-04 16:53:15 +00:00
//
// Macros for getting and setting special purpose registers in portable code
//
#define KeGetContextPc(Context) \
((Context)->Pc)
#define KeSetContextPc(Context, ProgramCounter) \
((Context)->Pc = (ProgramCounter))
#define KeGetTrapFramePc(TrapFrame) \
((TrapFrame)->Pc)
#define KeGetContextReturnRegister(Context) \
((Context)->R0)
#define KeSetContextReturnRegister(Context, ReturnValue) \
((Context)->R0 = (ReturnValue))
//
// Macro to get trap and exception frame from a thread stack
//
#define KeGetTrapFrame(Thread) \
(PKTRAP_FRAME)((ULONG_PTR)((Thread)->InitialStack) - \
sizeof(KTRAP_FRAME))
#define KeGetExceptionFrame(Thread) \
(PKEXCEPTION_FRAME)((ULONG_PTR)KeGetTrapFrame(Thread) - \
sizeof(KEXCEPTION_FRAME))
//
// Macro to get context switches from the PRCB
// All architectures but x86 have it in the PRCB's KeContextSwitches
//
#define KeGetContextSwitches(Prcb) \
(Prcb)->KeContextSwitches
//
// Macro to get the second level cache size field name which differs between
// CISC and RISC architectures, as the former has unified I/D cache
//
#define KiGetSecondLevelDCacheSize() ((PKIPCR)KeGetPcr())->SecondLevelDcacheSize
//
// Returns the Interrupt State from a Trap Frame.
// ON = TRUE, OFF = FALSE
//
#define KeGetTrapFrameInterruptState(TrapFrame) 0
FORCEINLINE
BOOLEAN
KeDisableInterrupts(VOID)
{
ARM_STATUS_REGISTER Flags;
//
// Get current interrupt state and disable interrupts
//
Flags = KeArmStatusRegisterGet();
_disable();
//
// Return previous interrupt state
//
return Flags.IrqDisable;
}
FORCEINLINE
VOID
KeRestoreInterrupts(BOOLEAN WereEnabled)
{
if (WereEnabled) _enable();
}
- 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
//
// Invalidates the TLB entry for a specified address
//
FORCEINLINE
VOID
KeInvalidateTlbEntry(IN PVOID Address)
{
/* Invalidate the TLB entry for this address */
KeArmInvalidateTlbEntry(Address);
}
Merge from amd64 branch: [NTOSKRNL] 44415 Move architecture specific inline functions in into the respective headers. [FREELDR] 39639 Fix 2 small typos. 40247 Fix a number of ULONG / ULONG_PTR issues, remove LoadReactOSSetup2 for non-x86 builds. 40324 Fix switching from long mode to real mode, by jumping into a compatibility segment first. 43566 move wlmemory.c into arch specific folder. add wlmemory.c and ntsetup.c for amd64 (stubbed) 43574 Enable winldr style boot for amd64 43598 Split wlmemory into portable and arch specific code. Partly implement amd64 version. 43600 Fix a bug. 43601 Move definition of KIP0PCRADDRESS into arch specific header. Implement WinLdrSetupForNt for amd64. Fix mapping of PCR and KI_USER_SHARED_DATA. Don't enable paging again on amd64. Fix WinLdrSetProcessorContext to take a ULONG_PTR not ULONG for Pcr and Tss 43602 Round up to pages when updating LoaderPagesSpanned to avoid a bug when the last memory region is not mapped. 43604 Add MempIsPageMapped for debugging puposes. Map pages for kernel, too in amd64 version of MempSetupPaging. 43605 Include the intrinsics from the kernel. Set segement selectors 43757 Pass pointer to debugprint function to the kernel in LoaderBlock->u.I386.CommonDataArea. Comment out __lldt 43775 Fixed build with MinGW-w64 4.4.3 44065 Use LoaderMemoryData instead of LoaderSpecialMemory for page tables 44095 Use the kernel mode address for the gdt/idt 44123 Fix a typo 44144 Share some more inline functions between the kernel and freeldr. Use __ltr instead of Ke386SetTr. refactor KiInitializeTss. Update some Mm constants. Halfplement KeFlushEntireTb. Clean the mapping of page 0 in KiSystemStartup, as long as we don't clean mappings in freeldr. Fix a bug in KiPageFault, where ebp was used instead of rbp. Refactor MmArmInitSystem and related. 44205 Improve the code in wlmemory.c, no real functional change. 44426 remove unused variables. 44530 Don't include i386/ke.h from ntoskrnl. 44540 Detect if this is a amd64 CPU before attempting to boot. (Basil Gello) svn path=/trunk/; revision=44669
2009-12-20 13:30:35 +00:00
FORCEINLINE
VOID
KeFlushProcessTb(VOID)
{
KeArmFlushTlb();
Merge from amd64 branch: [NTOSKRNL] 44415 Move architecture specific inline functions in into the respective headers. [FREELDR] 39639 Fix 2 small typos. 40247 Fix a number of ULONG / ULONG_PTR issues, remove LoadReactOSSetup2 for non-x86 builds. 40324 Fix switching from long mode to real mode, by jumping into a compatibility segment first. 43566 move wlmemory.c into arch specific folder. add wlmemory.c and ntsetup.c for amd64 (stubbed) 43574 Enable winldr style boot for amd64 43598 Split wlmemory into portable and arch specific code. Partly implement amd64 version. 43600 Fix a bug. 43601 Move definition of KIP0PCRADDRESS into arch specific header. Implement WinLdrSetupForNt for amd64. Fix mapping of PCR and KI_USER_SHARED_DATA. Don't enable paging again on amd64. Fix WinLdrSetProcessorContext to take a ULONG_PTR not ULONG for Pcr and Tss 43602 Round up to pages when updating LoaderPagesSpanned to avoid a bug when the last memory region is not mapped. 43604 Add MempIsPageMapped for debugging puposes. Map pages for kernel, too in amd64 version of MempSetupPaging. 43605 Include the intrinsics from the kernel. Set segement selectors 43757 Pass pointer to debugprint function to the kernel in LoaderBlock->u.I386.CommonDataArea. Comment out __lldt 43775 Fixed build with MinGW-w64 4.4.3 44065 Use LoaderMemoryData instead of LoaderSpecialMemory for page tables 44095 Use the kernel mode address for the gdt/idt 44123 Fix a typo 44144 Share some more inline functions between the kernel and freeldr. Use __ltr instead of Ke386SetTr. refactor KiInitializeTss. Update some Mm constants. Halfplement KeFlushEntireTb. Clean the mapping of page 0 in KiSystemStartup, as long as we don't clean mappings in freeldr. Fix a bug in KiPageFault, where ebp was used instead of rbp. Refactor MmArmInitSystem and related. 44205 Improve the code in wlmemory.c, no real functional change. 44426 remove unused variables. 44530 Don't include i386/ke.h from ntoskrnl. 44540 Detect if this is a amd64 CPU before attempting to boot. (Basil Gello) svn path=/trunk/; revision=44669
2009-12-20 13:30:35 +00:00
}
FORCEINLINE
VOID
KeSweepICache(IN PVOID BaseAddress,
IN SIZE_T FlushSize)
{
//
// Always sweep the whole cache
//
UNREFERENCED_PARAMETER(BaseAddress);
UNREFERENCED_PARAMETER(FlushSize);
_MoveToCoprocessor(0, CP15_ICIALLU);
}
Merge from amd64 branch: [NTOSKRNL] 44415 Move architecture specific inline functions in into the respective headers. [FREELDR] 39639 Fix 2 small typos. 40247 Fix a number of ULONG / ULONG_PTR issues, remove LoadReactOSSetup2 for non-x86 builds. 40324 Fix switching from long mode to real mode, by jumping into a compatibility segment first. 43566 move wlmemory.c into arch specific folder. add wlmemory.c and ntsetup.c for amd64 (stubbed) 43574 Enable winldr style boot for amd64 43598 Split wlmemory into portable and arch specific code. Partly implement amd64 version. 43600 Fix a bug. 43601 Move definition of KIP0PCRADDRESS into arch specific header. Implement WinLdrSetupForNt for amd64. Fix mapping of PCR and KI_USER_SHARED_DATA. Don't enable paging again on amd64. Fix WinLdrSetProcessorContext to take a ULONG_PTR not ULONG for Pcr and Tss 43602 Round up to pages when updating LoaderPagesSpanned to avoid a bug when the last memory region is not mapped. 43604 Add MempIsPageMapped for debugging puposes. Map pages for kernel, too in amd64 version of MempSetupPaging. 43605 Include the intrinsics from the kernel. Set segement selectors 43757 Pass pointer to debugprint function to the kernel in LoaderBlock->u.I386.CommonDataArea. Comment out __lldt 43775 Fixed build with MinGW-w64 4.4.3 44065 Use LoaderMemoryData instead of LoaderSpecialMemory for page tables 44095 Use the kernel mode address for the gdt/idt 44123 Fix a typo 44144 Share some more inline functions between the kernel and freeldr. Use __ltr instead of Ke386SetTr. refactor KiInitializeTss. Update some Mm constants. Halfplement KeFlushEntireTb. Clean the mapping of page 0 in KiSystemStartup, as long as we don't clean mappings in freeldr. Fix a bug in KiPageFault, where ebp was used instead of rbp. Refactor MmArmInitSystem and related. 44205 Improve the code in wlmemory.c, no real functional change. 44426 remove unused variables. 44530 Don't include i386/ke.h from ntoskrnl. 44540 Detect if this is a amd64 CPU before attempting to boot. (Basil Gello) svn path=/trunk/; revision=44669
2009-12-20 13:30:35 +00:00
FORCEINLINE
VOID
KiRundownThread(IN PKTHREAD Thread)
{
/* FIXME */
}
VOID
KiPassiveRelease(
VOID
);
VOID
KiSystemService(IN PKTHREAD Thread,
IN PKTRAP_FRAME TrapFrame,
IN ULONG Instruction);
VOID
KiApcInterrupt(
VOID
);
#include "mm.h"
VOID
KeFlushTb(
VOID
);
//
// Cache clean and flush
//
VOID
HalSweepDcache(
VOID
);
VOID
HalSweepIcache(
VOID
);
#define Ki386PerfEnd()
#define KiEndInterrupt(x,y)
#define KiGetLinkedTrapFrame(x) \
(PKTRAP_FRAME)((x)->TrapFrame)
#define KiGetPreviousMode(tf) \
((tf->Cpsr & CPSRM_MASK) == CPSRM_USER) ? UserMode: KernelMode