KfAcquireSpinLock/KfReleaesSpinLock.
This commit is contained in:
parent
28e7102a02
commit
6a02ae3768
|
@ -559,6 +559,49 @@ SHIM_CALL NtWaitForSingleObjectEx_shim(
|
|||
}
|
||||
|
||||
|
||||
uint32_t xeKfAcquireSpinLock(void* lock_ptr) {
|
||||
while (!xe_atomic_cas_32(0, 1, lock_ptr)) {
|
||||
// Spin!
|
||||
}
|
||||
// TODO(benvanik): set dispatch level.
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL KfAcquireSpinLock_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t lock_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
"KfAcquireSpinLock(%.8X)",
|
||||
lock_ptr);
|
||||
|
||||
uint32_t old_irql = xeKfAcquireSpinLock(SHIM_MEM_ADDR(lock_ptr));
|
||||
|
||||
SHIM_SET_RETURN(old_irql);
|
||||
}
|
||||
|
||||
|
||||
void xeKfReleaseSpinLock(void* lock_ptr, uint32_t old_irql) {
|
||||
// TODO(benvanik): reset dispatch level.
|
||||
xe_atomic_dec_32(lock_ptr);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL KfReleaseSpinLock_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t lock_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t old_irql = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"KfReleaseSpinLock(%.8X, %d)",
|
||||
lock_ptr,
|
||||
old_irql);
|
||||
|
||||
xeKfReleaseSpinLock(SHIM_MEM_ADDR(lock_ptr), old_irql);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
@ -586,4 +629,7 @@ void xe::kernel::xboxkrnl::RegisterThreadingExports(
|
|||
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", KeWaitForSingleObject, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", NtWaitForSingleObjectEx, state);
|
||||
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", KfAcquireSpinLock, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", KfReleaseSpinLock, state);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ X_STATUS xeKeWaitForSingleObject(
|
|||
void* object_ptr, uint32_t wait_reason, uint32_t processor_mode,
|
||||
uint32_t alertable, uint64_t* opt_timeout);
|
||||
|
||||
uint32_t xeKfAcquireSpinLock(void* lock_ptr);
|
||||
void xeKfReleaseSpinLock(void* lock_ptr, uint32_t old_irql);
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
|
|
Loading…
Reference in New Issue