2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/kd64/amd64/kdsup.c
5 * PURPOSE: KD support routines for AMD64
6 * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
9 /* INCLUDES *****************************************************************/
16 #define UNIMPLEMENTED KdpDprintf("%s is unimplemented\n", __FUNCTION__)
18 /* FUNCTIONS *****************************************************************/
22 KdpSysGetVersion(IN PDBGKD_GET_VERSION64 Version
)
24 /* Copy the version block */
25 RtlCopyMemory(Version
, &KdVersionBlock
, sizeof(DBGKD_GET_VERSION64
));
30 KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State
,
36 /* Check for success */
37 if (NT_SUCCESS(State
->u
.Continue2
.ContinueStatus
))
39 /* Check if we're tracing */
40 if (State
->u
.Continue2
.ControlSet
.TraceFlag
)
43 Context
->EFlags
|= EFLAGS_TF
;
48 Context
->EFlags
&= ~EFLAGS_TF
;
51 /* Loop all processors */
52 for (i
= 0; i
< KeNumberProcessors
; i
++)
54 /* Get the PRCB and update DR7 and DR6 */
55 Prcb
= KiProcessorBlock
[i
];
56 Prcb
->ProcessorState
.SpecialRegisters
.KernelDr7
=
57 State
->u
.Continue2
.ControlSet
.Dr7
;
58 Prcb
->ProcessorState
.SpecialRegisters
.KernelDr6
= 0;
61 /* Check if we have new symbol information */
62 if (State
->u
.Continue2
.ControlSet
.CurrentSymbolStart
!= 1)
65 KdpCurrentSymbolStart
=
66 State
->u
.Continue2
.ControlSet
.CurrentSymbolStart
;
67 KdpCurrentSymbolEnd
= State
->u
.Continue2
.ControlSet
.CurrentSymbolEnd
;
74 KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange
,
77 PKPRCB Prcb
= KeGetCurrentPrcb();
79 /* Copy i386 specific debug registers */
80 WaitStateChange
->ControlReport
.Dr6
= Prcb
->ProcessorState
.SpecialRegisters
.
82 WaitStateChange
->ControlReport
.Dr7
= Prcb
->ProcessorState
.SpecialRegisters
.
85 /* Copy i386 specific segments */
86 WaitStateChange
->ControlReport
.SegCs
= (USHORT
)Context
->SegCs
;
87 WaitStateChange
->ControlReport
.SegDs
= (USHORT
)Context
->SegDs
;
88 WaitStateChange
->ControlReport
.SegEs
= (USHORT
)Context
->SegEs
;
89 WaitStateChange
->ControlReport
.SegFs
= (USHORT
)Context
->SegFs
;
92 WaitStateChange
->ControlReport
.EFlags
= Context
->EFlags
;
94 /* Set Report Flags */
95 WaitStateChange
->ControlReport
.ReportFlags
= REPORT_INCLUDES_SEGS
;
96 if (WaitStateChange
->ControlReport
.SegCs
== KGDT_64_R0_CODE
)
98 WaitStateChange
->ControlReport
.ReportFlags
|= REPORT_STANDARD_CS
;
104 KdpSysReadMsr(IN ULONG Msr
,
105 OUT PLARGE_INTEGER MsrValue
)
107 MsrValue
->QuadPart
= __readmsr(Msr
);
108 return STATUS_SUCCESS
;
113 KdpSysWriteMsr(IN ULONG Msr
,
114 IN PLARGE_INTEGER MsrValue
)
116 __writemsr(Msr
, MsrValue
->QuadPart
);
117 return STATUS_SUCCESS
;
122 KdpSysReadBusData(IN ULONG BusDataType
,
128 OUT PULONG ActualLength
)
132 return STATUS_UNSUCCESSFUL
;
137 KdpSysWriteBusData(IN ULONG BusDataType
,
143 OUT PULONG ActualLength
)
147 return STATUS_UNSUCCESSFUL
;
152 KdpSysReadControlSpace(IN ULONG Processor
,
153 IN ULONG64 BaseAddress
,
156 OUT PULONG ActualLength
)
161 if ((ULONG
)BaseAddress
<= 2)
163 PKPRCB Prcb
= KiProcessorBlock
[Processor
];
164 PKIPCR Pcr
= CONTAINING_RECORD(Prcb
, KIPCR
, Prcb
);
166 switch ((ULONG_PTR
)BaseAddress
)
169 /* Copy a pointer to the Pcr */
171 RealLength
= sizeof(PVOID
);
175 /* Copy a pointer to the Prcb */
176 ControlStart
= &Prcb
;
177 RealLength
= sizeof(PVOID
);
181 /* Copy SpecialRegisters */
182 ControlStart
= &Prcb
->ProcessorState
.SpecialRegisters
;
183 RealLength
= sizeof(KSPECIAL_REGISTERS
);
192 if (RealLength
< Length
) Length
= RealLength
;
194 /* Copy the memory */
195 RtlCopyMemory(Buffer
, ControlStart
, Length
);
196 *ActualLength
= Length
;
199 return STATUS_SUCCESS
;
203 /* Invalid request */
205 return STATUS_UNSUCCESSFUL
;
211 KdpSysWriteControlSpace(IN ULONG Processor
,
212 IN ULONG64 BaseAddress
,
215 OUT PULONG ActualLength
)
219 return STATUS_UNSUCCESSFUL
;
224 KdpSysReadIoSpace(IN ULONG InterfaceType
,
226 IN ULONG AddressSpace
,
227 IN ULONG64 IoAddress
,
230 OUT PULONG ActualDataSize
)
234 return STATUS_UNSUCCESSFUL
;
239 KdpSysWriteIoSpace(IN ULONG InterfaceType
,
241 IN ULONG AddressSpace
,
242 IN ULONG64 IoAddress
,
245 OUT PULONG ActualDataSize
)
249 return STATUS_UNSUCCESSFUL
;
254 KdpSysCheckLowMemory(IN ULONG Flags
)
258 return STATUS_UNSUCCESSFUL
;