3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
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.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_POWERPC_KE_H
20 #define __NTOSKRNL_INCLUDE_INTERNAL_POWERPC_KE_H
22 #include <ndk/powerpc/ketypes.h>
25 #pragma GCC system_header
28 /* Possible values for KTHREAD's NpxState */
29 #define NPX_STATE_INVALID 0x01
30 #define NPX_STATE_VALID 0x02
31 #define NPX_STATE_DIRTY 0x04
35 typedef struct _KIRQ_TRAPFRAME
37 } KIRQ_TRAPFRAME
, *PKIRQ_TRAPFRAME
;
39 extern ULONG KePPCCacheAlignment
;
43 KiInitializeGdt(struct _KPCR
* Pcr
);
45 KiPPCApplicationProcessorInitializeTSS(VOID
);
47 KiPPCBootInitializeTSS(VOID
);
49 KiGdtPrepareForApplicationProcessorInit(ULONG Id
);
51 KiPPCInitializeLdt(VOID
);
53 KiPPCSetProcessorFeatures(VOID
);
54 ULONG
KeAllocateGdtSelector(ULONG Desc
[2]);
55 VOID
KeFreeGdtSelector(ULONG Entry
);
60 #define LOCK "isync ; "
66 static inline LONG
KePPCTestAndClearBit(ULONG BitPos
, volatile PULONG Addr
)
68 ULONG OldValue
, NewValue
;
70 __asm__
__volatile__ ("lwarx %0,0,%1"
71 : "=r" (OldValue
), "=r" (*Addr
)
75 NewValue
= OldValue
& ~(1<<BitPos
);
77 __asm__
__volatile__ ("stwcx. %0,0,%3\n\t"
82 : "=r" (NewValue
), "=r" (OldValue
)
83 : "w" (NewValue
), "w" (*Addr
)
86 return NewValue
& (1 << BitPos
);
89 static inline LONG
KePPCTestAndSetBit(ULONG BitPos
, volatile PULONG Addr
)
91 ULONG OldValue
, NewValue
;
93 __asm__
__volatile__ ("lwarx %0,0,%1"
94 : "=r" (OldValue
), "=r" (*Addr
)
98 NewValue
= OldValue
| (1<<BitPos
);
100 __asm__
__volatile__ ("stwcx. %0,0,%3\n\t"
105 : "=r" (NewValue
), "=r" (OldValue
)
106 : "w" (NewValue
), "w" (*Addr
)
109 return NewValue
& (1 << BitPos
);
112 #define KePPCRdmsr(msr,val1,val2) __asm__ __volatile__("mfmsr 2")
114 #define KePPCWrmsr(msr,val1,val2) __asm__ __volatile__("mtmsr 3")
117 #define KePPCDisableInterrupts() \
118 __asm__ __volatile__("mfmsr 0\n\t" \
123 #define KePPCEnableInterrupts() \
124 __asm__ __volatile__("mfmsr 0\n\t" \
125 "lis 8,0x8000@ha\n\t" \
129 #define KePPCHaltProcessor() ;
131 #define KeArchEraseFlags()
132 #define KeArchDisableInterrupts() KePPCDisableInterrupts()
134 static __inline
struct _KPRCB
* KeGetCurrentPrcb(
137 return (struct _KPRCB
*)__readfsdword(0x20);
140 __inline
struct _KPCR
* NTHALAPI
KeGetCurrentKPCR(
143 return (struct _KPCR
*)__readfsdword(0x1c);
146 __inline KIRQL NTHALAPI
KeGetCurrentIrql(
149 return ((KIPCR
*)KeGetCurrentKPCR())->CurrentIrql
;
154 KePPCInitThreadWithContext(
156 PKSYSTEM_ROUTINE SystemRoutine
,
157 PKSTART_ROUTINE StartRoutine
,
163 KeApplicationProcessorInitDispatcher(
168 KeCreateApplicationProcessorIdleThread(
171 VOID
KePPCHaltProcessor();
173 #ifdef _NTOSKRNL_ /* FIXME: Move flags above to NDK instead of here */
176 KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine
,
177 PKSTART_ROUTINE StartRoutine
,
180 KTRAP_FRAME TrapFrame
);
185 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_POWERPC_KE_H */