2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/kd64/kdlock.c
5 * PURPOSE: KD64 Port Lock and Breakin Support
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES ******************************************************************/
15 /* PRIVATE FUNCTIONS *********************************************************/
21 /* Acquire the lock */
22 KiAcquireSpinLock(&KdpDebuggerLock
);
29 /* Release the lock */
30 KiReleaseSpinLock(&KdpDebuggerLock
);
35 KdpPollBreakInWithPortLock(VOID
)
37 BOOLEAN DoBreak
= FALSE
;
39 /* First make sure that KD is enabled */
40 if (KdDebuggerEnabled
)
42 /* Check if a CTRL-C is in the queue */
43 if (KdpContext
.KdpControlCPending
)
45 /* Set it and prepare for break */
47 KdpContext
.KdpControlCPending
= FALSE
;
51 /* Now get a packet */
52 if (KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN
,
56 NULL
) == KdPacketReceived
)
58 /* Successful breakin */
64 /* Tell the caller to do a break */
68 /* PUBLIC FUNCTIONS **********************************************************/
77 BOOLEAN DoBreak
= FALSE
, Enable
;
79 /* First make sure that KD is enabled */
80 if (KdDebuggerEnabled
)
82 /* Disable interrupts */
83 Enable
= KeDisableInterrupts();
85 /* Check if a CTRL-C is in the queue */
86 if (KdpContext
.KdpControlCPending
)
88 /* Set it and prepare for break */
89 KdpControlCPressed
= TRUE
;
91 KdpContext
.KdpControlCPending
= FALSE
;
95 /* Try to acquire the lock */
96 if (KeTryToAcquireSpinLockAtDpcLevel(&KdpDebuggerLock
))
98 /* Now get a packet */
99 if (KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN
,
103 NULL
) == KdPacketReceived
)
105 /* Successful breakin */
107 KdpControlCPressed
= TRUE
;
110 /* Let go of the port */
115 /* Re-enable interrupts if they were enabled previously */
116 if (Enable
) _enable();
119 /* Tell the caller to do a break */