ReactOS  0.4.14-dev-854-gb9426a3
ke.h
Go to the documentation of this file.
1 /*
2  * ReactOS kernel
3  * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #pragma once
21 
22 #include <ndk/powerpc/ketypes.h>
23 
24 /* Possible values for KTHREAD's NpxState */
25 #define KPCR_BASE 0xff000000
26 #define NPX_STATE_INVALID 0x01
27 #define NPX_STATE_VALID 0x02
28 #define NPX_STATE_DIRTY 0x04
29 
30 #ifndef __ASM__
31 
32 typedef struct _KIRQ_TRAPFRAME
33 {
35 
37 
38 //#define KD_BREAKPOINT_TYPE
39 //#define KD_BREAKPOINT_SIZE
40 //#define KD_BREAKPOINT_VALUE
41 
42 //
43 // Macro to get the second level cache size field name which differs between
44 // CISC and RISC architectures, as the former has unified I/D cache
45 //
46 #define KiGetSecondLevelDCacheSize() ((PKIPCR)KeGetPcr())->SecondLevelDcacheSize
47 
48 //
49 // Macros for getting and setting special purpose registers in portable code
50 //
51 #define KeGetContextPc(Context) \
52  ((Context)->Dr0)
53 
54 #define KeSetContextPc(Context, ProgramCounter) \
55  ((Context)->Dr0 = (ProgramCounter))
56 
57 #define KeGetTrapFramePc(TrapFrame) \
58  ((TrapFrame)->Dr0)
59 
60 #define KeGetContextReturnRegister(Context) \
61  ((Context)->Gpr3)
62 
63 #define KeSetContextReturnRegister(Context, ReturnValue) \
64  ((Context)->Gpr3 = (ReturnValue))
65 
66 //
67 // Returns the Interrupt State from a Trap Frame.
68 // ON = TRUE, OFF = FALSE
69 //
70 //#define KeGetTrapFrameInterruptState(TrapFrame) \
71 
72 #define KePPCRdmsr(msr,val1,val2) __asm__ __volatile__("mfmsr 3")
73 
74 #define KePPCWrmsr(msr,val1,val2) __asm__ __volatile__("mtmsr 3")
75 
76 #define PPC_MIN_CACHE_LINE_SIZE 32
77 
79  VOID)
80 {
81  return (struct _KPCR *)__readfsdword(0x1c);
82 }
83 
85 VOID
87 {
88  /* Flush the TLB */
89  __asm__("sync\n\tisync\n\t");
90 }
91 
93 VOID
95  IN SIZE_T FlushSize)
96 {
97  //
98  // Always sweep the whole cache
99  //
101  UNREFERENCED_PARAMETER(FlushSize);
102  __asm__ __volatile__("tlbsync");
103 }
104 
106 PRKTHREAD
108 {
109  /* Return the current thread */
110  return KeGetCurrentPrcb()->CurrentThread;
111 }
112 
114 VOID
116 {
117  /* FIXME */
118 }
119 
120 #ifdef _NTOSKRNL_ /* FIXME: Move flags above to NDK instead of here */
121 VOID
122 NTAPI
123 KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine,
125  PVOID StartContext,
126  BOOLEAN UserThread,
127  KTRAP_FRAME TrapFrame);
128 #endif
129 
130 #endif /* __ASM__ */
131 
132 /* EOF */
#define IN
Definition: typedefs.h:38
#define NTHALAPI
Definition: ntoskrnl.h:40
_In_ ULONG _In_opt_ POBJECT_ATTRIBUTES _In_opt_ HANDLE _Out_opt_ PCLIENT_ID _In_ PKSTART_ROUTINE StartRoutine
Definition: psfuncs.h:87
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
Definition: ke.h:289
FORCEINLINE struct _KPCR *NTHALAPI KeGetCurrentKPCR(VOID)
Definition: ke.h:78
VOID(NTAPI * PKSYSTEM_ROUTINE)(PKSTART_ROUTINE StartRoutine, PVOID StartContext)
Definition: ketypes.h:625
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
KSTART_ROUTINE * PKSTART_ROUTINE
Definition: ketypes.h:487
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
FORCEINLINE PRKTHREAD KeGetCurrentThread(VOID)
Definition: ke.h:284
unsigned char BOOLEAN
struct _KIRQ_TRAPFRAME * PKIRQ_TRAPFRAME
#define FORCEINLINE
Definition: ntbasedef.h:221
PPC_QUAL unsigned long __readfsdword(const unsigned long Offset)
Definition: intrin_ppc.h:382
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
ULONG_PTR SIZE_T
Definition: typedefs.h:78
FORCEINLINE VOID KiRundownThread(IN PKTHREAD Thread)
Definition: ke.h:230
FORCEINLINE VOID KeFlushProcessTb(VOID)
Definition: ke.h:209
VOID NTAPI KiThreadStartup(VOID)
Definition: thrdini.c:63
ULONG KePPCCacheAlignment
unsigned int ULONG
Definition: retypes.h:1
struct _KIRQ_TRAPFRAME KIRQ_TRAPFRAME
FORCEINLINE VOID KeSweepICache(IN PVOID BaseAddress, IN SIZE_T FlushSize)
Definition: ke.h:217