2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/kd64/i386/kdapi-i386.c
5 * PURPOSE: KD64 i386 Support
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES ******************************************************************/
15 /* PRIVATE FUNCTIONS *********************************************************/
19 KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange
,
22 PKPRCB Prcb
= KeGetCurrentPrcb();
24 /* Copy i386 specific debug registers */
25 WaitStateChange
->ControlReport
.Dr6
= Prcb
->ProcessorState
.SpecialRegisters
.
27 WaitStateChange
->ControlReport
.Dr7
= Prcb
->ProcessorState
.SpecialRegisters
.
30 /* Copy i386 specific segments */
31 WaitStateChange
->ControlReport
.SegCs
= (USHORT
)Context
->SegCs
;
32 WaitStateChange
->ControlReport
.SegDs
= (USHORT
)Context
->SegDs
;
33 WaitStateChange
->ControlReport
.SegEs
= (USHORT
)Context
->SegEs
;
34 WaitStateChange
->ControlReport
.SegFs
= (USHORT
)Context
->SegFs
;
37 WaitStateChange
->ControlReport
.EFlags
= Context
->EFlags
;
39 /* Set Report Flags */
40 WaitStateChange
->ControlReport
.ReportFlags
= REPORT_INCLUDES_SEGS
;
41 if (WaitStateChange
->ControlReport
.SegCs
== KGDT_64_R0_CODE
)
43 WaitStateChange
->ControlReport
.ReportFlags
= REPORT_INCLUDES_CS
;
49 KdpTrap(IN PKTRAP_FRAME TrapFrame
,
50 IN PKEXCEPTION_FRAME ExceptionFrame
,
51 IN PEXCEPTION_RECORD ExceptionRecord
,
52 IN PCONTEXT ContextRecord
,
53 IN KPROCESSOR_MODE PreviousMode
,
54 IN BOOLEAN SecondChanceException
)
56 BOOLEAN Unload
= FALSE
;
58 BOOLEAN Status
= FALSE
;
61 * Check if we got a STATUS_BREAKPOINT with a SubID for Print, Prompt or
62 * Load/Unload symbols.
64 if ((ExceptionRecord
->ExceptionCode
== STATUS_BREAKPOINT
) &&
65 (ExceptionRecord
->ExceptionInformation
[0] != BREAKPOINT_BREAK
))
68 Rip
= ContextRecord
->Rip
;
70 /* Check what kind of operation was requested from us */
71 switch (ExceptionRecord
->ExceptionInformation
[0])
74 case BREAKPOINT_PRINT
:
76 /* Call the worker routine */
77 Rax
= KdpPrint(ContextRecord
->R8
, // ComponentId
78 ContextRecord
->R9
, // ComponentMask
79 (LPSTR
)ExceptionRecord
->ExceptionInformation
[1], // String
80 (ULONG
)ExceptionRecord
->ExceptionInformation
[2], // Length
86 /* Update the return value for the caller */
87 ContextRecord
->Rax
= Rax
;
91 case BREAKPOINT_PROMPT
:
93 /* Call the worker routine */
98 /* Update the return value for the caller */
99 ContextRecord
->Rax
= Rax
;
102 /* DbgUnloadSymbols */
103 case BREAKPOINT_UNLOAD_SYMBOLS
:
105 /* Drop into the load case below, with the unload parameter */
109 case BREAKPOINT_LOAD_SYMBOLS
:
111 /* Call the worker routine */
112 KdpSymbol((PVOID
)ExceptionRecord
->ExceptionInformation
[1],
113 (PVOID
)ExceptionRecord
->ExceptionInformation
[2],
122 /* DbgCommandString*/
123 case BREAKPOINT_COMMAND_STRING
:
125 /* Call the worker routine */
129 /* Anything else, do nothing */
137 * If EIP was not updated, we'll increment it ourselves so execution
138 * continues past the breakpoint.
140 if (ContextRecord
->Rip
== Rip
) ContextRecord
->Rip
++;
144 /* Call the worker routine */
145 Status
= KdpReport(TrapFrame
,
150 SecondChanceException
);
153 /* Return TRUE or FALSE to caller */