87f48fde67a015df54e3790f981315191d8077be
[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 IMAGE_FILE_MACHINE_ARCHITECTURE IMAGE_FILE_MACHINE_POWERPC
39
40 //#define KD_BREAKPOINT_TYPE
41 //#define KD_BREAKPOINT_SIZE
42 //#define KD_BREAKPOINT_VALUE
43
44 //
45 // Macros for getting and setting special purpose registers in portable code
46 //
47 #define KeGetContextPc(Context) \
48 ((Context)->Dr0)
49
50 #define KeSetContextPc(Context, ProgramCounter) \
51 ((Context)->Dr0 = (ProgramCounter))
52
53 #define KeGetTrapFramePc(TrapFrame) \
54 ((TrapFrame)->Dr0)
55
56 #define KeGetContextReturnRegister(Context) \
57 ((Context)->Gpr3)
58
59 #define KeSetContextReturnRegister(Context, ReturnValue) \
60 ((Context)->Gpr3 = (ReturnValue))
61
62 //
63 // Returns the Interrupt State from a Trap Frame.
64 // ON = TRUE, OFF = FALSE
65 //
66 //#define KeGetTrapFrameInterruptState(TrapFrame) \
67
68 #define KePPCRdmsr(msr,val1,val2) __asm__ __volatile__("mfmsr 3")
69
70 #define KePPCWrmsr(msr,val1,val2) __asm__ __volatile__("mtmsr 3")
71
72 #define PPC_MIN_CACHE_LINE_SIZE 32
73
74 FORCEINLINE struct _KPCR * NTHALAPI KeGetCurrentKPCR(
75 VOID)
76 {
77 return (struct _KPCR *)__readfsdword(0x1c);
78 }
79
80 FORCEINLINE
81 VOID
82 KeFlushProcessTb(VOID)
83 {
84 /* Flush the TLB */
85 __asm__("sync\n\tisync\n\t");
86 }
87
88 FORCEINLINE
89 PRKTHREAD
90 KeGetCurrentThread(VOID)
91 {
92 /* Return the current thread */
93 return KeGetCurrentPrcb()->CurrentThread;
94 }
95
96 FORCEINLINE
97 VOID
98 KiRundownThread(IN PKTHREAD Thread)
99 {
100 /* FIXME */
101 }
102
103 #ifdef _NTOSKRNL_ /* FIXME: Move flags above to NDK instead of here */
104 VOID
105 NTAPI
106 KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine,
107 PKSTART_ROUTINE StartRoutine,
108 PVOID StartContext,
109 BOOLEAN UserThread,
110 KTRAP_FRAME TrapFrame);
111 #endif
112
113 #endif /* __ASM__ */
114
115 /* EOF */