ReactOS 0.4.15-dev-7842-g558ab78
kdx64.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for kdx64.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define UNIMPLEMENTED   KdpDprintf("%s is unimplemented\n", __FUNCTION__)
 

Functions

VOID NTAPI KdpGetStateChange (IN PDBGKD_MANIPULATE_STATE64 State, IN PCONTEXT Context)
 
VOID NTAPI KdpSetContextState (IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange, IN PCONTEXT Context)
 
NTSTATUS NTAPI KdpSysReadMsr (IN ULONG Msr, OUT PLARGE_INTEGER MsrValue)
 
NTSTATUS NTAPI KdpSysWriteMsr (IN ULONG Msr, IN PLARGE_INTEGER MsrValue)
 
NTSTATUS NTAPI KdpSysReadBusData (IN ULONG BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length, OUT PULONG ActualLength)
 
NTSTATUS NTAPI KdpSysWriteBusData (IN ULONG BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length, OUT PULONG ActualLength)
 
NTSTATUS NTAPI KdpSysReadControlSpace (IN ULONG Processor, IN ULONG64 BaseAddress, IN PVOID Buffer, IN ULONG Length, OUT PULONG ActualLength)
 
NTSTATUS NTAPI KdpSysWriteControlSpace (IN ULONG Processor, IN ULONG64 BaseAddress, IN PVOID Buffer, IN ULONG Length, OUT PULONG ActualLength)
 
NTSTATUS NTAPI KdpSysReadIoSpace (IN ULONG InterfaceType, IN ULONG BusNumber, IN ULONG AddressSpace, IN ULONG64 IoAddress, OUT PVOID DataValue, IN ULONG DataSize, OUT PULONG ActualDataSize)
 
NTSTATUS NTAPI KdpSysWriteIoSpace (IN ULONG InterfaceType, IN ULONG BusNumber, IN ULONG AddressSpace, IN ULONG64 IoAddress, IN PVOID DataValue, IN ULONG DataSize, OUT PULONG ActualDataSize)
 
NTSTATUS NTAPI KdpSysCheckLowMemory (IN ULONG Flags)
 
NTSTATUS NTAPI KdpAllowDisable (VOID)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file kdx64.c.

◆ UNIMPLEMENTED

#define UNIMPLEMENTED   KdpDprintf("%s is unimplemented\n", __FUNCTION__)

Definition at line 16 of file kdx64.c.

Function Documentation

◆ KdpAllowDisable()

NTSTATUS NTAPI KdpAllowDisable ( VOID  )

Definition at line 364 of file kdx64.c.

365{
368}
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145

◆ KdpGetStateChange()

VOID NTAPI KdpGetStateChange ( IN PDBGKD_MANIPULATE_STATE64  State,
IN PCONTEXT  Context 
)

Definition at line 22 of file kdx64.c.

24{
25 PKPRCB Prcb;
26 ULONG i;
27
28 /* Check for success */
29 if (NT_SUCCESS(State->u.Continue2.ContinueStatus))
30 {
31 /* Check if we're tracing */
32 if (State->u.Continue2.ControlSet.TraceFlag)
33 {
34 /* Enable TF */
35 Context->EFlags |= EFLAGS_TF;
36 }
37 else
38 {
39 /* Remove it */
40 Context->EFlags &= ~EFLAGS_TF;
41 }
42
43 /* Loop all processors */
44 for (i = 0; i < KeNumberProcessors; i++)
45 {
46 /* Get the PRCB and update DR7 and DR6 */
47 Prcb = KiProcessorBlock[i];
49 State->u.Continue2.ControlSet.Dr7;
51 }
52
53 /* Check if we have new symbol information */
54 if (State->u.Continue2.ControlSet.CurrentSymbolStart != 1)
55 {
56 /* Update it */
58 State->u.Continue2.ControlSet.CurrentSymbolStart;
59 KdpCurrentSymbolEnd= State->u.Continue2.ControlSet.CurrentSymbolEnd;
60 }
61 }
62}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG_PTR KdpCurrentSymbolEnd
Definition: kd64.h:580
ULONG_PTR KdpCurrentSymbolStart
Definition: kddata.c:105
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
#define EFLAGS_TF
Definition: ketypes.h:186
PKPRCB KiProcessorBlock[]
Definition: krnlinit.c:32
KPROCESSOR_STATE ProcessorState
Definition: ketypes.h:649
KSPECIAL_REGISTERS SpecialRegisters
Definition: ketypes.h:600
ULONG64 KernelDr7
Definition: ketypes.h:575
ULONG64 KernelDr6
Definition: ketypes.h:574
uint32_t ULONG
Definition: typedefs.h:59

◆ KdpSetContextState()

VOID NTAPI KdpSetContextState ( IN PDBGKD_ANY_WAIT_STATE_CHANGE  WaitStateChange,
IN PCONTEXT  Context 
)

Definition at line 66 of file kdx64.c.

68{
69 PKPRCB Prcb = KeGetCurrentPrcb();
70
71 /* Copy i386 specific debug registers */
72 WaitStateChange->ControlReport.Dr6 = Prcb->ProcessorState.SpecialRegisters.
73 KernelDr6;
74 WaitStateChange->ControlReport.Dr7 = Prcb->ProcessorState.SpecialRegisters.
75 KernelDr7;
76
77 /* Copy i386 specific segments */
78 WaitStateChange->ControlReport.SegCs = (USHORT)Context->SegCs;
79 WaitStateChange->ControlReport.SegDs = (USHORT)Context->SegDs;
80 WaitStateChange->ControlReport.SegEs = (USHORT)Context->SegEs;
81 WaitStateChange->ControlReport.SegFs = (USHORT)Context->SegFs;
82
83 /* Copy EFlags */
84 WaitStateChange->ControlReport.EFlags = Context->EFlags;
85
86 /* Set Report Flags */
87 WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_SEGS;
88 if (WaitStateChange->ControlReport.SegCs == KGDT64_R0_CODE)
89 {
90 WaitStateChange->ControlReport.ReportFlags |= REPORT_STANDARD_CS;
91 }
92}
#define KGDT64_R0_CODE
Definition: ketypes.h:133
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1148
unsigned short USHORT
Definition: pedump.c:61
#define REPORT_INCLUDES_SEGS
Definition: windbgkd.h:147
#define REPORT_STANDARD_CS
Definition: windbgkd.h:148

◆ KdpSysCheckLowMemory()

NTSTATUS NTAPI KdpSysCheckLowMemory ( IN ULONG  Flags)

Definition at line 356 of file kdx64.c.

357{
359 return STATUS_UNSUCCESSFUL;
360}
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

◆ KdpSysReadBusData()

NTSTATUS NTAPI KdpSysReadBusData ( IN ULONG  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN ULONG  Offset,
IN PVOID  Buffer,
IN ULONG  Length,
OUT PULONG  ActualLength 
)

Definition at line 134 of file kdx64.c.

141{
143 return STATUS_UNSUCCESSFUL;
144}

◆ KdpSysReadControlSpace()

NTSTATUS NTAPI KdpSysReadControlSpace ( IN ULONG  Processor,
IN ULONG64  BaseAddress,
IN PVOID  Buffer,
IN ULONG  Length,
OUT PULONG  ActualLength 
)

Definition at line 162 of file kdx64.c.

167{
168 PVOID ControlStart;
170 PKIPCR Pcr = CONTAINING_RECORD(Prcb, KIPCR, Prcb);
171
172 switch (BaseAddress)
173 {
175 /* Copy a pointer to the Pcr */
176 ControlStart = &Pcr;
177 *ActualLength = sizeof(PVOID);
178 break;
179
181 /* Copy a pointer to the Prcb */
182 ControlStart = &Prcb;
183 *ActualLength = sizeof(PVOID);
184 break;
185
187 /* Copy SpecialRegisters */
188 ControlStart = &Prcb->ProcessorState.SpecialRegisters;
189 *ActualLength = sizeof(KSPECIAL_REGISTERS);
190 break;
191
193 /* Copy a pointer to the current Thread */
194 ControlStart = &Prcb->CurrentThread;
195 *ActualLength = sizeof(PVOID);
196 break;
197
198 default:
199 *ActualLength = 0;
200 ASSERT(FALSE);
201 return STATUS_UNSUCCESSFUL;
202 }
203
204 /* Copy the memory */
205 RtlCopyMemory(Buffer, ControlStart, min(Length, *ActualLength));
206
207 /* Finish up */
208 return STATUS_SUCCESS;
209}
Definition: bufpool.h:45
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
#define min(a, b)
Definition: monoChain.cc:55
struct _KSPECIAL_REGISTERS KSPECIAL_REGISTERS
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _KTHREAD * CurrentThread
Definition: ketypes.h:636
void * PVOID
Definition: typedefs.h:50
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define AMD64_DEBUG_CONTROL_SPACE_KPRCB
Definition: windbgkd.h:204
#define AMD64_DEBUG_CONTROL_SPACE_KSPECIAL
Definition: windbgkd.h:205
#define AMD64_DEBUG_CONTROL_SPACE_KPCR
Definition: windbgkd.h:203
#define AMD64_DEBUG_CONTROL_SPACE_KTHREAD
Definition: windbgkd.h:206
_In_ UCHAR Processor
Definition: kefuncs.h:670

◆ KdpSysReadIoSpace()

NTSTATUS NTAPI KdpSysReadIoSpace ( IN ULONG  InterfaceType,
IN ULONG  BusNumber,
IN ULONG  AddressSpace,
IN ULONG64  IoAddress,
OUT PVOID  DataValue,
IN ULONG  DataSize,
OUT PULONG  ActualDataSize 
)

Definition at line 244 of file kdx64.c.

251{
252 /* Verify parameters */
253 if (InterfaceType != Isa || BusNumber != 0 || AddressSpace != 1)
254 {
255 /* No data was read */
256 *ActualDataSize = 0;
258 }
259
260 /* Check for correct alignment */
261 if ((IoAddress & (DataSize - 1)))
262 {
263 /* Invalid alignment */
264 *ActualDataSize = 0;
266 }
267
268 switch (DataSize)
269 {
270 case sizeof(UCHAR):
271 /* Read one UCHAR */
272 *(PUCHAR)DataValue = READ_PORT_UCHAR((PUCHAR)IoAddress);
273 break;
274
275 case sizeof(USHORT):
276 /* Read one USHORT */
277 *(PUSHORT)DataValue = READ_PORT_USHORT((PUSHORT)IoAddress);
278 break;
279
280 case sizeof(ULONG):
281 /* Read one ULONG */
282 *(PULONG)DataValue = READ_PORT_ULONG((PULONG)IoAddress);
283 break;
284
285 default:
286 /* Invalid data size */
287 *ActualDataSize = 0;
289 }
290
291 /* Return the size of the data */
292 *ActualDataSize = DataSize;
293
294 /* Success! */
295 return STATUS_SUCCESS;
296}
ULONG NTAPI READ_PORT_ULONG(IN PULONG Port)
Definition: portio.c:70
USHORT NTAPI READ_PORT_USHORT(IN PUSHORT Port)
Definition: portio.c:63
@ Isa
Definition: hwresource.cpp:138
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
uint32_t * PULONG
Definition: typedefs.h:59
uint16_t * PUSHORT
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ KdpSysReadMsr()

NTSTATUS NTAPI KdpSysReadMsr ( IN ULONG  Msr,
OUT PLARGE_INTEGER  MsrValue 
)

Definition at line 96 of file kdx64.c.

98{
99 /* Use SEH to protect from invalid MSRs */
101 {
102 MsrValue->QuadPart = __readmsr(Msr);
103 }
105 {
107 }
108 _SEH2_END;
109
110 return STATUS_SUCCESS;
111}
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PPC_QUAL unsigned long long __readmsr()
Definition: intrin_ppc.h:741
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136

◆ KdpSysWriteBusData()

NTSTATUS NTAPI KdpSysWriteBusData ( IN ULONG  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN ULONG  Offset,
IN PVOID  Buffer,
IN ULONG  Length,
OUT PULONG  ActualLength 
)

Definition at line 148 of file kdx64.c.

155{
157 return STATUS_UNSUCCESSFUL;
158}

◆ KdpSysWriteControlSpace()

NTSTATUS NTAPI KdpSysWriteControlSpace ( IN ULONG  Processor,
IN ULONG64  BaseAddress,
IN PVOID  Buffer,
IN ULONG  Length,
OUT PULONG  ActualLength 
)

Definition at line 213 of file kdx64.c.

218{
219 PVOID ControlStart;
221
222 switch (BaseAddress)
223 {
225 /* Copy SpecialRegisters */
226 ControlStart = &Prcb->ProcessorState.SpecialRegisters;
227 *ActualLength = sizeof(KSPECIAL_REGISTERS);
228 break;
229
230 default:
231 *ActualLength = 0;
232 ASSERT(FALSE);
233 return STATUS_UNSUCCESSFUL;
234 }
235
236 /* Copy the memory */
237 RtlCopyMemory(ControlStart, Buffer, min(Length, *ActualLength));
238
239 return STATUS_SUCCESS;
240}

◆ KdpSysWriteIoSpace()

NTSTATUS NTAPI KdpSysWriteIoSpace ( IN ULONG  InterfaceType,
IN ULONG  BusNumber,
IN ULONG  AddressSpace,
IN ULONG64  IoAddress,
IN PVOID  DataValue,
IN ULONG  DataSize,
OUT PULONG  ActualDataSize 
)

Definition at line 300 of file kdx64.c.

307{
308 /* Verify parameters */
309 if (InterfaceType != Isa || BusNumber != 0 || AddressSpace != 1)
310 {
311 /* No data was written */
312 *ActualDataSize = 0;
314 }
315
316 /* Check for correct alignment */
317 if ((IoAddress & (DataSize - 1)))
318 {
319 /* Invalid alignment */
320 *ActualDataSize = 0;
322 }
323
324 switch (DataSize)
325 {
326 case sizeof(UCHAR):
327 /* Write one UCHAR */
328 WRITE_PORT_UCHAR((PUCHAR)IoAddress, *(PUCHAR)DataValue);
329 break;
330
331 case sizeof(USHORT):
332 /* Write one USHORT */
333 WRITE_PORT_USHORT((PUSHORT)IoAddress, *(PUSHORT)DataValue);
334 break;
335
336 case sizeof(ULONG):
337 /* Write one ULONG */
338 WRITE_PORT_ULONG((PULONG)IoAddress, *(PULONG)DataValue);
339 break;
340
341 default:
342 /* Invalid data size */
343 *ActualDataSize = 0;
345 }
346
347 /* Return the size of the data */
348 *ActualDataSize = DataSize;
349
350 /* Success! */
351 return STATUS_SUCCESS;
352}
VOID NTAPI WRITE_PORT_USHORT(IN PUSHORT Port, IN USHORT Value)
Definition: portio.c:115
VOID NTAPI WRITE_PORT_ULONG(IN PULONG Port, IN ULONG Value)
Definition: portio.c:123
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21

◆ KdpSysWriteMsr()

NTSTATUS NTAPI KdpSysWriteMsr ( IN ULONG  Msr,
IN PLARGE_INTEGER  MsrValue 
)

Definition at line 115 of file kdx64.c.

117{
118 /* Use SEH to protect from invalid MSRs */
120 {
121 __writemsr(Msr, MsrValue->QuadPart);
122 }
124 {
126 }
127 _SEH2_END;
128
129 return STATUS_SUCCESS;
130}
PPC_QUAL void __writemsr(const unsigned long Value)
Definition: intrin_ppc.h:748