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

133 lines
3.2 KiB
C
Raw Normal View History

/*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include <ndk/powerpc/ketypes.h>
/* Possible values for KTHREAD's NpxState */
#define KPCR_BASE 0xff000000
#define NPX_STATE_INVALID 0x01
#define NPX_STATE_VALID 0x02
#define NPX_STATE_DIRTY 0x04
#ifndef __ASM__
typedef struct _KIRQ_TRAPFRAME
{
} KIRQ_TRAPFRAME, *PKIRQ_TRAPFRAME;
extern ULONG KePPCCacheAlignment;
//#define KD_BREAKPOINT_TYPE
//#define KD_BREAKPOINT_SIZE
//#define KD_BREAKPOINT_VALUE
//
// 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
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)->Dr0)
#define KeSetContextPc(Context, ProgramCounter) \
((Context)->Dr0 = (ProgramCounter))
#define KeGetTrapFramePc(TrapFrame) \
((TrapFrame)->Dr0)
#define KeGetContextReturnRegister(Context) \
((Context)->Gpr3)
#define KeSetContextReturnRegister(Context, ReturnValue) \
((Context)->Gpr3 = (ReturnValue))
//
// Returns the Interrupt State from a Trap Frame.
// ON = TRUE, OFF = FALSE
//
//#define KeGetTrapFrameInterruptState(TrapFrame) \
#define KePPCRdmsr(msr,val1,val2) __asm__ __volatile__("mfmsr 3")
#define KePPCWrmsr(msr,val1,val2) __asm__ __volatile__("mtmsr 3")
#define PPC_MIN_CACHE_LINE_SIZE 32
FORCEINLINE struct _KPCR * NTHALAPI KeGetCurrentKPCR(
VOID)
{
return (struct _KPCR *)__readfsdword(0x1c);
}
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)
{
/* Flush the TLB */
__asm__("sync\n\tisync\n\t");
}
FORCEINLINE
VOID
KeSweepICache(IN PVOID BaseAddress,
IN SIZE_T FlushSize)
{
//
// Always sweep the whole cache
//
UNREFERENCED_PARAMETER(BaseAddress);
UNREFERENCED_PARAMETER(FlushSize);
__asm__ __volatile__("tlbsync");
}
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
PRKTHREAD
KeGetCurrentThread(VOID)
{
/* Return the current thread */
return KeGetCurrentPrcb()->CurrentThread;
}
FORCEINLINE
VOID
KiRundownThread(IN PKTHREAD Thread)
{
/* FIXME */
}
#ifdef _NTOSKRNL_ /* FIXME: Move flags above to NDK instead of here */
VOID
NTAPI
KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine,
PKSTART_ROUTINE StartRoutine,
PVOID StartContext,
BOOLEAN UserThread,
KTRAP_FRAME TrapFrame);
#endif
#endif /* __ASM__ */
/* EOF */