ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

kdlock.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Kernel
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            ntoskrnl/kd64/kdlock.c
00005  * PURPOSE:         KD64 Port Lock and Breakin Support
00006  * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
00007  */
00008 
00009 /* INCLUDES ******************************************************************/
00010 
00011 #include <ntoskrnl.h>
00012 #define NDEBUG
00013 #include <debug.h>
00014 
00015 /* PRIVATE FUNCTIONS *********************************************************/
00016 
00017 VOID
00018 NTAPI
00019 KdpPortLock(VOID)
00020 {
00021     /* Acquire the lock */
00022     KiAcquireSpinLock(&KdpDebuggerLock);
00023 }
00024 
00025 VOID
00026 NTAPI
00027 KdpPortUnlock(VOID)
00028 {
00029     /* Release the lock */
00030     KiReleaseSpinLock(&KdpDebuggerLock);
00031 }
00032 
00033 BOOLEAN
00034 NTAPI
00035 KdpPollBreakInWithPortLock(VOID)
00036 {
00037     BOOLEAN DoBreak = FALSE;
00038 
00039     /* First make sure that KD is enabled */
00040     if (KdDebuggerEnabled)
00041     {
00042         /* Check if a CTRL-C is in the queue */
00043         if (KdpContext.KdpControlCPending)
00044         {
00045             /* Set it and prepare for break */
00046             DoBreak = TRUE;
00047             KdpContext.KdpControlCPending = FALSE;
00048         }
00049         else
00050         {
00051             /* Now get a packet */
00052             if (KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN,
00053                                 NULL,
00054                                 NULL,
00055                                 NULL,
00056                                 NULL) == KdPacketReceived)
00057             {
00058                 /* Successful breakin */
00059                 DoBreak = TRUE;
00060             }
00061         }
00062     }
00063 
00064     /* Tell the caller to do a break */
00065     return DoBreak;
00066 }
00067 
00068 /* PUBLIC FUNCTIONS **********************************************************/
00069 
00070 /*
00071  * @implemented
00072  */
00073 BOOLEAN
00074 NTAPI
00075 KdPollBreakIn(VOID)
00076 {
00077     BOOLEAN DoBreak = FALSE, Enable;
00078 
00079     /* First make sure that KD is enabled */
00080     if (KdDebuggerEnabled)
00081     {
00082         /* Disable interrupts */
00083         Enable = KeDisableInterrupts();
00084 
00085         /* Check if a CTRL-C is in the queue */
00086         if (KdpContext.KdpControlCPending)
00087         {
00088             /* Set it and prepare for break */
00089             KdpControlCPressed = TRUE;
00090             DoBreak = TRUE;
00091             KdpContext.KdpControlCPending = FALSE;
00092         }
00093         else
00094         {
00095             /* Try to acquire the lock */
00096             if (KeTryToAcquireSpinLockAtDpcLevel(&KdpDebuggerLock))
00097             {
00098                 /* Now get a packet */
00099                 if (KdReceivePacket(PACKET_TYPE_KD_POLL_BREAKIN,
00100                                     NULL,
00101                                     NULL,
00102                                     NULL,
00103                                     NULL) == KdPacketReceived)
00104                 {
00105                     /* Successful breakin */
00106                     DoBreak = TRUE;
00107                     KdpControlCPressed = TRUE;
00108                 }
00109 
00110                 /* Let go of the port */
00111                 KdpPortUnlock();
00112             }
00113         }
00114 
00115         /* Re-enable interrupts if they were enabled previously */
00116         if (Enable) _enable();
00117     }
00118 
00119     /* Tell the caller to do a break */
00120     return DoBreak;
00121 }

Generated on Fri May 25 2012 04:35:50 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.