Changeset 32453 in vbox
- Timestamp:
- Sep 13, 2010 2:46:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/nt/spinlock-r0drv-nt.cpp
r29254 r32453 45 45 46 46 /******************************************************************************* 47 * Defined Constants And Macros * 48 *******************************************************************************/ 49 /** Apply the NoIrq hack if defined. */ 50 //#define RTSPINLOCK_NT_HACK_NOIRQ 51 52 #ifdef RTSPINLOCK_NT_HACK_NOIRQ 53 /** Indicates that the spinlock is taken. */ 54 # define RTSPINLOCK_NT_HACK_NOIRQ_TAKEN UINT32(0x00c0ffee) 55 /** Indicates that the spinlock is taken. */ 56 # define RTSPINLOCK_NT_HACK_NOIRQ_FREE UINT32(0xfe0000fe) 57 #endif 58 59 60 /******************************************************************************* 47 61 * Structures and Typedefs * 48 62 *******************************************************************************/ … … 54 68 /** Spinlock magic value (RTSPINLOCK_MAGIC). */ 55 69 uint32_t volatile u32Magic; 70 #ifdef RTSPINLOCK_NT_HACK_NOIRQ 71 /** Spinlock hack. */ 72 uint32_t volatile u32Hack; 73 #endif 56 74 /** The NT spinlock structure. */ 57 75 KSPIN_LOCK Spinlock; … … 74 92 */ 75 93 pSpinlockInt->u32Magic = RTSPINLOCK_MAGIC; 94 #ifdef RTSPINLOCK_NT_HACK_NOIRQ 95 pSpinlockInt->u32Hack = RTSPINLOCK_NT_HACK_NOIRQ; 96 #endif 76 97 KeInitializeSpinLock(&pSpinlockInt->Spinlock); 77 98 Assert(sizeof(KIRQL) == sizeof(unsigned char)); 99 AssertCompile(sizeof(KIRQL) == sizeof(unsigned char)); 78 100 79 101 *pSpinlock = pSpinlockInt; … … 107 129 AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pSpinlockInt->u32Magic)); 108 130 131 #ifndef RTSPINLOCK_NT_HACK_NOIRQ 109 132 KeAcquireSpinLock(&pSpinlockInt->Spinlock, &pTmp->uchIrqL); 110 133 pTmp->uFlags = ASMGetFlags(); 111 134 ASMIntDisable(); 135 #else 136 pTmp->uchIrqL = KeGetCurrentIrql(); 137 if (pTmp->uchIrqL < DISPATCH_LEVEL) 138 { 139 KeRaiseIrql(DISPATCH_LEVEL, &pTmp->uchIrqL); 140 Assert(pTmp->uchIrqL < DISPATCH_LEVEL); 141 } 142 pTmp->uFlags = ASMGetFlags(); 143 ASMIntDisable(); 144 if (!ASMAtomicCmpXchgU32(&pSpinlockInt->u32Hack, RTSPINLOCK_NT_HACK_NOIRQ_TAKEN, RTSPINLOCK_NT_HACK_NOIRQ_FREE)) 145 { 146 while (!ASMAtomicCmpXchgU32(&pSpinlockInt->u32Hack, RTSPINLOCK_NT_HACK_NOIRQ_TAKEN, RTSPINLOCK_NT_HACK_NOIRQ_FREE)) 147 ASMNopPause(); 148 } 149 #endif 112 150 } 113 151 … … 118 156 AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC, ("magic=%#x\n", pSpinlockInt->u32Magic)); 119 157 158 #ifndef RTSPINLOCK_NT_HACK_NOIRQ 120 159 ASMSetFlags(pTmp->uFlags); 121 160 KeReleaseSpinLock(&pSpinlockInt->Spinlock, pTmp->uchIrqL); 161 #else 162 Assert(pSpinlockInt->u32Hack == RTSPINLOCK_NT_HACK_NOIRQ_TAKEN); 163 ASMAtomicWriteU32(&pSpinlockInt->u32Hack, RTSPINLOCK_NT_HACK_NOIRQ_FREE); 164 ASMSetFlags(pTmp->uFlags); 165 if (pTmp->uchIrqL < DISPATCH_LEVEL) 166 KeLowerIrql(pTmp->uchIrqL); 167 #endif 122 168 } 123 169
Note:
See TracChangeset
for help on using the changeset viewer.