KeAcquireSpinLockAtRaisedIrql/etc.

This commit is contained in:
Ben Vanik 2014-01-11 21:38:56 -08:00
parent dc496e8102
commit 27d4938cc2
1 changed files with 43 additions and 9 deletions

View File

@ -1264,6 +1264,37 @@ SHIM_CALL KfReleaseSpinLock_shim(
} }
SHIM_CALL KeAcquireSpinLockAtRaisedIrql_shim(
PPCContext* ppc_state, KernelState* state) {
uint32_t lock_ptr = SHIM_GET_ARG_32(0);
XELOGD(
"KeAcquireSpinLockAtRaisedIrql(%.8X)",
lock_ptr);
// Lock.
void* lock = SHIM_MEM_ADDR(lock_ptr);
while (!xe_atomic_cas_32(0, 1, lock)) {
// Spin!
// TODO(benvanik): error on deadlock?
}
}
SHIM_CALL KeReleaseSpinLockFromRaisedIrql_shim(
PPCContext* ppc_state, KernelState* state) {
uint32_t lock_ptr = SHIM_GET_ARG_32(0);
XELOGD(
"KeReleaseSpinLockFromRaisedIrql(%.8X)",
lock_ptr);
// Unlock.
void* lock = SHIM_MEM_ADDR(lock_ptr);
xe_atomic_dec_32(lock);
}
void xeKeEnterCriticalRegion() { void xeKeEnterCriticalRegion() {
XThread::EnterCriticalRegion(); XThread::EnterCriticalRegion();
} }
@ -1345,6 +1376,9 @@ void xe::kernel::xboxkrnl::RegisterThreadingExports(
SHIM_SET_MAPPING("xboxkrnl.exe", KfAcquireSpinLock, state); SHIM_SET_MAPPING("xboxkrnl.exe", KfAcquireSpinLock, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KfReleaseSpinLock, state); SHIM_SET_MAPPING("xboxkrnl.exe", KfReleaseSpinLock, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeAcquireSpinLockAtRaisedIrql, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeReleaseSpinLockFromRaisedIrql, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeEnterCriticalRegion, state); SHIM_SET_MAPPING("xboxkrnl.exe", KeEnterCriticalRegion, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeLeaveCriticalRegion, state); SHIM_SET_MAPPING("xboxkrnl.exe", KeLeaveCriticalRegion, state);
} }