[CMAKE]
[reactos.git] / ntoskrnl / include / internal / powerpc / ke.h
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 {
34 } KIRQ_TRAPFRAME, *PKIRQ_TRAPFRAME;
35
36 extern ULONG KePPCCacheAlignment;
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
78 FORCEINLINE struct _KPCR * NTHALAPI KeGetCurrentKPCR(
79 VOID)
80 {
81 return (struct _KPCR *)__readfsdword(0x1c);
82 }
83
84 FORCEINLINE
85 VOID
86 KeFlushProcessTb(VOID)
87 {
88 /* Flush the TLB */
89 __asm__("sync\n\tisync\n\t");
90 }
91
92 FORCEINLINE
93 PRKTHREAD
94 KeGetCurrentThread(VOID)
95 {
96 /* Return the current thread */
97 return KeGetCurrentPrcb()->CurrentThread;
98 }
99
100 FORCEINLINE
101 VOID
102 KiRundownThread(IN PKTHREAD Thread)
103 {
104 /* FIXME */
105 }
106
107 #ifdef _NTOSKRNL_ /* FIXME: Move flags above to NDK instead of here */
108 VOID
109 NTAPI
110 KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine,
111 PKSTART_ROUTINE StartRoutine,
112 PVOID StartContext,
113 BOOLEAN UserThread,
114 KTRAP_FRAME TrapFrame);
115 #endif
116
117 #endif /* __ASM__ */
118
119 /* EOF */