Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

kdlock.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1992 Microsoft Corporation 00004 00005 Module Name: 00006 00007 kdlock.c 00008 00009 Abstract: 00010 00011 This module contains code to synchronize the usage of the port 00012 used by the kernel debugger. 00013 00014 Author: 00015 00016 Bryan M. Willman (bryanwi) 24-Sep-90 00017 00018 Revision History: 00019 00020 --*/ 00021 00022 #include "kdp.h" 00023 00024 00025 VOID 00026 KdpPortLock( 00027 VOID 00028 ) 00029 00030 /*++ 00031 00032 Routine Description: 00033 00034 Acquire the spinlock for the debug port. 00035 00036 Note that user must call this explicitly, the get/put routines 00037 do NOT make any use of the lock. 00038 00039 CALLER MUST HAVE SET PROPER IRQL BEFORE CALLING US. 00040 00041 We use KiAcquireSpinLock and NOT Ke... because our IRQL may 00042 be above DISPATCH_LEVEL. 00043 00044 Arguments: 00045 00046 None. 00047 00048 Return value: 00049 00050 None. 00051 00052 --*/ 00053 00054 { 00055 KiAcquireSpinLock(&KdpDebuggerLock); 00056 } 00057 00058 00059 VOID 00060 KdpPortUnlock( 00061 VOID 00062 ) 00063 00064 /*++ 00065 00066 Routine Description: 00067 00068 Release the spinlock for the debug port. 00069 00070 Note that user must call this explicitly, the get/put routines 00071 do NOT make any use of the lock. 00072 00073 CALLER MUST HAVE SET PROPER IRQL BEFORE CALLING US. 00074 00075 We use KiReleaseSpinLock and NOT Ke... because our IRQL may 00076 be above DISPATCH_LEVEL. 00077 00078 Arguments: 00079 00080 None. 00081 00082 Return value: 00083 00084 None. 00085 00086 --*/ 00087 00088 { 00089 KiReleaseSpinLock(&KdpDebuggerLock); 00090 } 00091 00092 BOOLEAN 00093 KdPollBreakIn( 00094 VOID 00095 ) 00096 00097 /*++ 00098 00099 Routine Description: 00100 00101 This procedure raises IRQL to high_level, seizes the Debug port 00102 spinlock, and checks to see if a breakin packet is pending. 00103 If a packet is present, return TRUE, else FALSE. 00104 00105 A packet is present if: 00106 00107 There is a valid character which matches BREAK_CHAR. 00108 00109 N.B. Interrupts must be OFF around this call 00110 00111 Return Value: 00112 00113 TRUE if breakin sequence present, caller should execute int-3. 00114 FALSE if no breakin seen. 00115 00116 --*/ 00117 00118 { 00119 BOOLEAN BreakIn; 00120 BOOLEAN Enable; 00121 UCHAR Input; 00122 KIRQL OldIrql; 00123 ULONG Status; 00124 00125 // 00126 // If the debugger is enabled, see if a breakin by the kernel 00127 // debugger is pending. 00128 // 00129 00130 BreakIn = FALSE; 00131 if (KdDebuggerEnabled != FALSE) { 00132 Enable = KiDisableInterrupts(); 00133 #ifndef _X86_ 00134 KeRaiseIrql(HIGH_LEVEL, &OldIrql); 00135 #endif 00136 if (KdpControlCPending != FALSE) { 00137 KdpControlCPressed = TRUE; 00138 BreakIn = TRUE; 00139 KdpControlCPending = FALSE; 00140 00141 } else { 00142 if (KiTryToAcquireSpinLock(&KdpDebuggerLock) != FALSE) { 00143 Status = KdPortPollByte(&Input); 00144 if ((Status == CP_GET_SUCCESS) && 00145 (Input == BREAKIN_PACKET_BYTE)) { 00146 BreakIn = TRUE; 00147 KdpControlCPressed = TRUE; 00148 } 00149 00150 KdpPortUnlock(); 00151 } 00152 } 00153 00154 #ifndef _X86_ 00155 KeLowerIrql(OldIrql); 00156 #endif 00157 KiRestoreInterrupts(Enable); 00158 } 00159 00160 return BreakIn; 00161 } 00162 00163 00164 BOOLEAN 00165 KdpPollBreakInWithPortLock( 00166 VOID 00167 ) 00168 00169 /*++ 00170 00171 Routine Description: 00172 00173 This procedure same as KdPollBreakIn, but assumes the caller 00174 already holds the port lock. Returns TRUE if a breakin packet 00175 is pending. 00176 00177 A packet is present if: 00178 00179 There is a valid character which matches BREAK_CHAR. 00180 00181 N.B. Interrupts must be OFF around this call 00182 00183 Return Value: 00184 00185 TRUE if breakin sequence present, caller should execute int-3. 00186 FALSE if no breakin seen. 00187 00188 --*/ 00189 00190 { 00191 00192 BOOLEAN BreakIn; 00193 BOOLEAN Enable; 00194 UCHAR Input; 00195 ULONG Status; 00196 00197 // 00198 // If the debugger is enabled, see if a breakin by the kernel 00199 // debugger is pending. 00200 // 00201 00202 BreakIn = FALSE; 00203 if (KdDebuggerEnabled != FALSE) { 00204 if (KdpControlCPending != FALSE) { 00205 BreakIn = TRUE; 00206 KdpControlCPending = FALSE; 00207 00208 } else { 00209 Status = KdPortPollByte(&Input); 00210 if ((Status == CP_GET_SUCCESS) && 00211 (Input == BREAKIN_PACKET_BYTE)) { 00212 BreakIn = TRUE; 00213 } 00214 } 00215 } 00216 00217 return BreakIn; 00218 }

Generated on Sat May 15 19:40:34 2004 for test by doxygen 1.3.7