ReactOS 0.4.15-dev-7924-g5949c20
exintrin.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: ntoskrnl/ex/exintrin.c
5 * PURPOSE: Exported kernel functions which are now intrinsics
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <ntoskrnl.h>
12#define NDEBUG
13#include <debug.h>
14
15#undef InterlockedIncrement
16#undef InterlockedDecrement
17#undef InterlockedCompareExchange
18#undef InterlockedExchangeAdd
19#undef InterlockedExchange
20
21//
22// HAL Port to Inlined Port
23//
24#define H2I(Port) PtrToUshort(Port)
25
26/* FUNCTIONS ******************************************************************/
27
28/*
29 * @implemented
30 */
31LONG
34{
35 //
36 // Call the intrinsic
37 //
39}
40
41/*
42 * @implemented
43 */
44LONG
47{
48 //
49 // Call the intrinsic
50 //
52}
53
54/*
55 * @implemented
56 */
57LONG
60 IN LONG Exchange,
61 IN LONG Comperand)
62{
63 //
64 // Call the intrinsic
65 //
66 return _InterlockedCompareExchange(Destination, Exchange, Comperand);
67}
68
69/*
70 * @implemented
71 */
72LONG
76{
77 //
78 // Call the intrinsic
79 //
81}
82
83/*
84 * @implemented
85 */
86LONG
90{
91 //
92 // Call the intrinsic
93 //
95}
96
97/*
98 * @implemented
99 */
100VOID
101NTAPI
105{
106 ULONG_PTR Last, Current = (ULONG_PTR)Address;
107 PAGED_CODE();
108
109 /* Only probe if we have a valid length */
110 if (Length != 0)
111 {
112 /* Sanity check */
113 ASSERT((Alignment == 1) ||
114 (Alignment == 2) ||
115 (Alignment == 4) ||
116 (Alignment == 8) ||
117 (Alignment == 16));
118
119 /* Check the alignment */
120 if ((Current & (Alignment - 1)) != 0)
121 {
122 /* Incorrect alignment */
124 }
125
126 /* Get the end address */
127 Last = Current + Length - 1;
128 if ((Last < Current) || (Last >= (ULONG_PTR)MmUserProbeAddress))
129 {
130 /* Raise an access violation */
132 }
133
134 /* ProbeForRead doesn't check if memory pages are readable! */
135 }
136}
137
138/*
139 * @implemented
140 */
141VOID
142NTAPI
146{
147 ULONG_PTR Last, Current = (ULONG_PTR)Address;
148 PAGED_CODE();
149
150 /* Only probe if we have a valid length */
151 if (Length != 0)
152 {
153 /* Sanity check */
154 ASSERT((Alignment == 1) ||
155 (Alignment == 2) ||
156 (Alignment == 4) ||
157 (Alignment == 8) ||
158 (Alignment == 16));
159
160 /* Check the alignment */
161 if ((Current & (Alignment - 1)) != 0)
162 {
163 /* Incorrect alignment */
165 }
166
167 /* Get the end address */
168 Last = Current + Length - 1;
169 if ((Last < Current) || (Last >= (ULONG_PTR)MmUserProbeAddress))
170 {
171 /* Raise an access violation */
173 }
174
175 /* Round down to the last page */
176 Last = PAGE_ROUND_DOWN(Last) + PAGE_SIZE;
177 do
178 {
179 /* Attempt a write */
180 *(volatile CHAR*)Current = *(volatile CHAR*)Current;
181
182 /* Go to the next address */
183 Current = PAGE_ROUND_DOWN(Current) + PAGE_SIZE;
184 } while (Current != Last);
185 }
186}
#define PAGED_CODE()
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedExchange
Definition: armddk.h:54
#define InterlockedDecrement
Definition: armddk.h:52
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
IN OUT PLONG Addend
Definition: CrNtStubs.h:25
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:46
VOID NTAPI ExRaiseAccessViolation(VOID)
Definition: harderr.c:308
VOID NTAPI ExRaiseDatatypeMisalignment(VOID)
Definition: harderr.c:330
#define InterlockedExchangeAdd
Definition: interlocked.h:181
#define InterlockedCompareExchange
Definition: interlocked.h:104
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
long __cdecl _InterlockedCompareExchange(_Interlocked_operand_ long volatile *_Destination, long _Exchange, long _Comparand)
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
#define ASSERT(a)
Definition: mode.c:44
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3004
#define FASTCALL
Definition: nt_native.h:50
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
ULONG MmUserProbeAddress
Definition: init.c:50
#define CONST
Definition: pedump.c:81
long LONG
Definition: pedump.c:60
static WCHAR Address[46]
Definition: ping.c:68
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
char CHAR
Definition: xmlstorage.h:175