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
;
96 /* Try to acquire the lock */
97 KeRaiseIrql(HIGH_LEVEL
, &OldIrql
);
98 if (KeTryToAcquireSpinLockAtDpcLevel(&KdpDebuggerLock
))
100 /* Now get a packet */
101 if (KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN
,
105 NULL
) == KdPacketReceived
)
107 /* Successful breakin */
109 KdpControlCPressed
= TRUE
;
112 /* Let go of the port */
115 KeLowerIrql(OldIrql
);
118 /* Re-enable interrupts */
119 KeRestoreInterrupts(Enable
);
122 /* Tell the caller to do a break */