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
,
58 /* Successful breakin */
64 /* Tell the caller to do a break */
68 /* PUBLIC FUNCTIONS **********************************************************/
77 BOOLEAN DoBreak
= FALSE
;
80 /* First make sure that KD is enabled */
81 if (KdDebuggerEnabled
)
83 /* Disable interrupts */
84 Ke386SaveFlags(Flags
);
85 //Flags = __getcallerseflags();
88 /* Check if a CTRL-C is in the queue */
89 if (KdpContext
.KdpControlCPending
)
91 /* Set it and prepare for break */
92 KdpControlCPressed
= TRUE
;
94 KdpContext
.KdpControlCPending
= FALSE
;
98 /* Try to acquire the lock */
99 if (KeTryToAcquireSpinLockAtDpcLevel(&KdpDebuggerLock
))
101 /* Now get a packet */
102 if (!KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN
,
108 /* Successful breakin */
110 KdpControlCPressed
= TRUE
;
113 /* Let go of the port */
118 /* Re-enable interrupts if they were disabled */
119 if (Flags
& EFLAGS_INTERRUPT_MASK
) _enable();
122 /* Tell the caller to do a break */