Merge branch 'master' into d3d12
This commit is contained in:
commit
9709a230fb
|
@ -35,6 +35,12 @@ X_RESULT XLiveBaseApp::DispatchMessageSync(uint32_t message,
|
|||
xe::store_and_swap<uint32_t>(buffer + 0, 1); // ?
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
case 0x00058006: {
|
||||
assert_true(!buffer_length || buffer_length == 4);
|
||||
XELOGD("XLiveBaseGetNatType(%.8X)", buffer_ptr);
|
||||
xe::store_and_swap<uint32_t>(buffer + 0, 1); // XONLINE_NAT_OPEN
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
case 0x00058020: {
|
||||
// 0x00058004 is called right before this.
|
||||
// We should create a XamEnumerate-able empty list here, but I'm not
|
||||
|
|
|
@ -350,7 +350,7 @@ dword_result_t NetDll_WSAWaitForMultipleEvents(dword_t num_events,
|
|||
|
||||
X_STATUS result = 0;
|
||||
do {
|
||||
result = xboxkrnl::NtWaitForMultipleObjectsEx(
|
||||
result = xboxkrnl::xeNtWaitForMultipleObjectsEx(
|
||||
num_events, events, wait_all, 1, alertable,
|
||||
timeout != -1 ? &timeout_wait : nullptr);
|
||||
} while (result == X_STATUS_ALERTED);
|
||||
|
@ -384,7 +384,7 @@ dword_result_t NetDll_WSACloseEvent(dword_t event_handle) {
|
|||
DECLARE_XAM_EXPORT1(NetDll_WSACloseEvent, kNetworking, kImplemented);
|
||||
|
||||
dword_result_t NetDll_WSAResetEvent(dword_t event_handle) {
|
||||
X_STATUS result = xboxkrnl::NtClearEvent(event_handle);
|
||||
X_STATUS result = xboxkrnl::xeNtClearEvent(event_handle);
|
||||
if (XFAILED(result)) {
|
||||
uint32_t error = xboxkrnl::RtlNtStatusToDosError(result);
|
||||
XThread::SetLastError(error);
|
||||
|
@ -395,7 +395,7 @@ dword_result_t NetDll_WSAResetEvent(dword_t event_handle) {
|
|||
DECLARE_XAM_EXPORT1(NetDll_WSAResetEvent, kNetworking, kImplemented);
|
||||
|
||||
dword_result_t NetDll_WSASetEvent(dword_t event_handle) {
|
||||
X_STATUS result = xboxkrnl::NtSetEvent(event_handle, nullptr);
|
||||
X_STATUS result = xboxkrnl::xeNtSetEvent(event_handle, nullptr);
|
||||
if (XFAILED(result)) {
|
||||
uint32_t error = xboxkrnl::RtlNtStatusToDosError(result);
|
||||
XThread::SetLastError(error);
|
||||
|
|
|
@ -416,8 +416,8 @@ void RtlEnterCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
|||
|
||||
if (xe::atomic_inc(&cs->lock_count) != 0) {
|
||||
// Create a full waiter.
|
||||
KeWaitForSingleObject(reinterpret_cast<void*>(cs.host_address()), 8, 0, 0,
|
||||
nullptr);
|
||||
xeKeWaitForSingleObject(reinterpret_cast<void*>(cs.host_address()), 8, 0, 0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
assert_true(cs->owning_thread == 0);
|
||||
|
@ -465,7 +465,7 @@ void RtlLeaveCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
|||
cs->owning_thread = 0;
|
||||
if (xe::atomic_dec(&cs->lock_count) != -1) {
|
||||
// There were waiters - wake one of them.
|
||||
KeSetEvent(reinterpret_cast<X_KEVENT*>(cs.host_address()), 1, 0);
|
||||
xeKeSetEvent(reinterpret_cast<X_KEVENT*>(cs.host_address()), 1, 0);
|
||||
}
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(RtlLeaveCriticalSection, kNone, kImplemented,
|
||||
|
|
|
@ -373,7 +373,7 @@ void KeInitializeEvent(pointer_t<X_KEVENT> event_ptr, dword_t event_type,
|
|||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeInitializeEvent, kThreading, kImplemented);
|
||||
|
||||
uint32_t keSetEvent(X_KEVENT* event_ptr, uint32_t increment, uint32_t wait) {
|
||||
uint32_t xeKeSetEvent(X_KEVENT* event_ptr, uint32_t increment, uint32_t wait) {
|
||||
auto ev = XObject::GetNativeObject<XEvent>(kernel_state(), event_ptr);
|
||||
if (!ev) {
|
||||
assert_always();
|
||||
|
@ -385,7 +385,7 @@ uint32_t keSetEvent(X_KEVENT* event_ptr, uint32_t increment, uint32_t wait) {
|
|||
|
||||
dword_result_t KeSetEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
dword_t wait) {
|
||||
return keSetEvent(event_ptr, increment, wait);
|
||||
return xeKeSetEvent(event_ptr, increment, wait);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeSetEvent, kThreading, kImplemented, kHighFrequency);
|
||||
|
||||
|
@ -446,7 +446,7 @@ dword_result_t NtCreateEvent(lpdword_t handle_ptr,
|
|||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCreateEvent, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtSetEvent(dword_t handle, lpdword_t previous_state_ptr) {
|
||||
uint32_t xeNtSetEvent(uint32_t handle, xe::be<uint32_t>* previous_state_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto ev = kernel_state()->object_table()->LookupObject<XEvent>(handle);
|
||||
|
@ -461,6 +461,10 @@ dword_result_t NtSetEvent(dword_t handle, lpdword_t previous_state_ptr) {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t NtSetEvent(dword_t handle, lpdword_t previous_state_ptr) {
|
||||
return xeNtSetEvent(handle, previous_state_ptr);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtSetEvent, kThreading, kImplemented, kHighFrequency);
|
||||
|
||||
dword_result_t NtPulseEvent(dword_t handle, lpdword_t previous_state_ptr) {
|
||||
|
@ -481,7 +485,7 @@ dword_result_t NtPulseEvent(dword_t handle, lpdword_t previous_state_ptr) {
|
|||
DECLARE_XBOXKRNL_EXPORT2(NtPulseEvent, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t NtClearEvent(dword_t handle) {
|
||||
uint32_t xeNtClearEvent(uint32_t handle) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto ev = kernel_state()->object_table()->LookupObject<XEvent>(handle);
|
||||
|
@ -493,6 +497,8 @@ dword_result_t NtClearEvent(dword_t handle) {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t NtClearEvent(dword_t handle) { return xeNtClearEvent(handle); }
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtClearEvent, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
|
@ -512,8 +518,8 @@ void KeInitializeSemaphore(pointer_t<X_KSEMAPHORE> semaphore_ptr, dword_t count,
|
|||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeInitializeSemaphore, kThreading, kImplemented);
|
||||
|
||||
uint32_t keReleaseSemaphore(X_KSEMAPHORE* semaphore_ptr, uint32_t increment,
|
||||
uint32_t adjustment, uint32_t wait) {
|
||||
uint32_t xeKeReleaseSemaphore(X_KSEMAPHORE* semaphore_ptr, uint32_t increment,
|
||||
uint32_t adjustment, uint32_t wait) {
|
||||
auto sem =
|
||||
XObject::GetNativeObject<XSemaphore>(kernel_state(), semaphore_ptr);
|
||||
if (!sem) {
|
||||
|
@ -530,7 +536,7 @@ uint32_t keReleaseSemaphore(X_KSEMAPHORE* semaphore_ptr, uint32_t increment,
|
|||
dword_result_t KeReleaseSemaphore(pointer_t<X_KSEMAPHORE> semaphore_ptr,
|
||||
dword_t increment, dword_t adjustment,
|
||||
dword_t wait) {
|
||||
return keReleaseSemaphore(semaphore_ptr, increment, adjustment, wait);
|
||||
return xeKeReleaseSemaphore(semaphore_ptr, increment, adjustment, wait);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeReleaseSemaphore, kThreading, kImplemented);
|
||||
|
||||
|
@ -728,9 +734,9 @@ dword_result_t NtCancelTimer(dword_t timer_handle,
|
|||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCancelTimer, kThreading, kImplemented);
|
||||
|
||||
uint32_t keWaitForSingleObject(void* object_ptr, uint32_t wait_reason,
|
||||
uint32_t processor_mode, uint32_t alertable,
|
||||
uint64_t* timeout) {
|
||||
uint32_t xeKeWaitForSingleObject(void* object_ptr, uint32_t wait_reason,
|
||||
uint32_t processor_mode, uint32_t alertable,
|
||||
uint64_t* timeout) {
|
||||
auto object = XObject::GetNativeObject<XObject>(kernel_state(), object_ptr);
|
||||
|
||||
if (!object) {
|
||||
|
@ -749,8 +755,8 @@ dword_result_t KeWaitForSingleObject(lpvoid_t object_ptr, dword_t wait_reason,
|
|||
dword_t processor_mode, dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint64_t>(*timeout_ptr) : 0u;
|
||||
return keWaitForSingleObject(object_ptr, wait_reason, processor_mode,
|
||||
alertable, &timeout);
|
||||
return xeKeWaitForSingleObject(object_ptr, wait_reason, processor_mode,
|
||||
alertable, &timeout);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT3(KeWaitForSingleObject, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
@ -808,10 +814,10 @@ dword_result_t KeWaitForMultipleObjects(dword_t count, lpdword_t objects_ptr,
|
|||
DECLARE_XBOXKRNL_EXPORT3(KeWaitForMultipleObjects, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t NtWaitForMultipleObjectsEx(dword_t count, lpdword_t handles,
|
||||
dword_t wait_type, dword_t wait_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
uint32_t xeNtWaitForMultipleObjectsEx(uint32_t count, xe::be<uint32_t>* handles,
|
||||
uint32_t wait_type, uint32_t wait_mode,
|
||||
uint32_t alertable,
|
||||
uint64_t* timeout_ptr) {
|
||||
assert_true(wait_type <= 1);
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
|
@ -826,13 +832,21 @@ dword_result_t NtWaitForMultipleObjectsEx(dword_t count, lpdword_t handles,
|
|||
objects.push_back(std::move(object));
|
||||
}
|
||||
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint64_t>(*timeout_ptr) : 0u;
|
||||
result = XObject::WaitMultiple(
|
||||
count, reinterpret_cast<XObject**>(objects.data()), wait_type, 6,
|
||||
wait_mode, alertable, timeout_ptr ? &timeout : nullptr);
|
||||
result =
|
||||
XObject::WaitMultiple(count, reinterpret_cast<XObject**>(objects.data()),
|
||||
wait_type, 6, wait_mode, alertable, timeout_ptr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t NtWaitForMultipleObjectsEx(dword_t count, lpdword_t handles,
|
||||
dword_t wait_type, dword_t wait_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint64_t>(*timeout_ptr) : 0u;
|
||||
return xeNtWaitForMultipleObjectsEx(count, handles, wait_type, wait_mode,
|
||||
alertable, &timeout);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT3(NtWaitForMultipleObjectsEx, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
|
@ -860,7 +874,7 @@ dword_result_t NtSignalAndWaitForSingleObjectEx(dword_t signal_handle,
|
|||
DECLARE_XBOXKRNL_EXPORT3(NtSignalAndWaitForSingleObjectEx, kThreading,
|
||||
kImplemented, kBlocking, kHighFrequency);
|
||||
|
||||
uint32_t keKfAcquireSpinLock(uint32_t* lock) {
|
||||
uint32_t xeKeKfAcquireSpinLock(uint32_t* lock) {
|
||||
// XELOGD(
|
||||
// "KfAcquireSpinLock(%.8X)",
|
||||
// lock_ptr);
|
||||
|
@ -881,12 +895,12 @@ uint32_t keKfAcquireSpinLock(uint32_t* lock) {
|
|||
|
||||
dword_result_t KfAcquireSpinLock(lpdword_t lock_ptr) {
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
return keKfAcquireSpinLock(lock);
|
||||
return xeKeKfAcquireSpinLock(lock);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT3(KfAcquireSpinLock, kThreading, kImplemented, kBlocking,
|
||||
kHighFrequency);
|
||||
|
||||
void keKfReleaseSpinLock(uint32_t* lock, dword_t old_irql) {
|
||||
void xeKeKfReleaseSpinLock(uint32_t* lock, dword_t old_irql) {
|
||||
// Restore IRQL.
|
||||
XThread* thread = XThread::GetCurrentThread();
|
||||
thread->LowerIrql(old_irql);
|
||||
|
@ -897,7 +911,7 @@ void keKfReleaseSpinLock(uint32_t* lock, dword_t old_irql) {
|
|||
|
||||
void KfReleaseSpinLock(lpdword_t lock_ptr, dword_t old_irql) {
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
keKfReleaseSpinLock(lock, old_irql);
|
||||
xeKeKfReleaseSpinLock(lock, old_irql);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KfReleaseSpinLock, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
@ -1130,26 +1144,26 @@ void ExInitializeReadWriteLock(pointer_t<X_ERWLOCK> lock_ptr) {
|
|||
DECLARE_XBOXKRNL_EXPORT1(ExInitializeReadWriteLock, kThreading, kImplemented);
|
||||
|
||||
void ExAcquireReadWriteLockExclusive(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = keKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
lock_ptr->lock_count++;
|
||||
keKfReleaseSpinLock(&lock_ptr->spin_lock, old_irql);
|
||||
xeKeKfReleaseSpinLock(&lock_ptr->spin_lock, old_irql);
|
||||
|
||||
if (!lock_ptr->lock_count) {
|
||||
return;
|
||||
}
|
||||
|
||||
lock_ptr->writers_waiting_count++;
|
||||
keWaitForSingleObject(&lock_ptr->writer_event, 0, 0, 0, nullptr);
|
||||
xeKeWaitForSingleObject(&lock_ptr->writer_event, 0, 0, 0, nullptr);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT4(ExAcquireReadWriteLockExclusive, kThreading,
|
||||
kImplemented, kBlocking, kHighFrequency, kSketchy);
|
||||
|
||||
void ExReleaseReadWriteLock(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = keKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
lock_ptr->lock_count--;
|
||||
|
||||
if (lock_ptr->lock_count < 0) {
|
||||
keKfReleaseSpinLock(&lock_ptr->spin_lock, old_irql);
|
||||
xeKeKfReleaseSpinLock(&lock_ptr->spin_lock, old_irql);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1158,17 +1172,17 @@ void ExReleaseReadWriteLock(pointer_t<X_ERWLOCK> lock_ptr) {
|
|||
if (readers_waiting_count) {
|
||||
lock_ptr->readers_waiting_count = 0;
|
||||
lock_ptr->readers_entry_count = readers_waiting_count;
|
||||
keKfReleaseSpinLock(&lock_ptr->spin_lock, old_irql);
|
||||
keReleaseSemaphore(&lock_ptr->reader_semaphore, 1, readers_waiting_count,
|
||||
0);
|
||||
xeKeKfReleaseSpinLock(&lock_ptr->spin_lock, old_irql);
|
||||
xeKeReleaseSemaphore(&lock_ptr->reader_semaphore, 1,
|
||||
readers_waiting_count, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto count = lock_ptr->readers_entry_count--;
|
||||
keKfReleaseSpinLock(&lock_ptr->spin_lock, old_irql);
|
||||
xeKeKfReleaseSpinLock(&lock_ptr->spin_lock, old_irql);
|
||||
if (!count) {
|
||||
keSetEvent(&lock_ptr->writer_event, 1, 0);
|
||||
xeKeSetEvent(&lock_ptr->writer_event, 1, 0);
|
||||
}
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(ExReleaseReadWriteLock, kThreading, kImplemented,
|
||||
|
|
|
@ -19,19 +19,18 @@ struct X_KEVENT;
|
|||
|
||||
namespace xboxkrnl {
|
||||
|
||||
dword_result_t NtSetEvent(dword_t handle, lpdword_t previous_state_ptr);
|
||||
dword_result_t NtClearEvent(dword_t handle);
|
||||
uint32_t xeNtSetEvent(uint32_t handle, xe::be<uint32_t>* previous_state_ptr);
|
||||
uint32_t xeNtClearEvent(uint32_t handle);
|
||||
|
||||
dword_result_t NtWaitForMultipleObjectsEx(dword_t count, lpdword_t handles,
|
||||
dword_t wait_type, dword_t wait_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr);
|
||||
uint32_t xeNtWaitForMultipleObjectsEx(uint32_t count, xe::be<uint32_t>* handles,
|
||||
uint32_t wait_type, uint32_t wait_mode,
|
||||
uint32_t alertable,
|
||||
uint64_t* timeout_ptr);
|
||||
|
||||
dword_result_t KeWaitForSingleObject(lpvoid_t object_ptr, dword_t wait_reason,
|
||||
dword_t processor_mode, dword_t alertable,
|
||||
lpqword_t timeout_ptr);
|
||||
dword_result_t KeSetEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
dword_t wait);
|
||||
uint32_t xeKeWaitForSingleObject(void* object_ptr, uint32_t wait_reason,
|
||||
uint32_t processor_mode, uint32_t alertable,
|
||||
uint64_t* timeout_ptr);
|
||||
uint32_t xeKeSetEvent(X_KEVENT* event_ptr, uint32_t increment, uint32_t wait);
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
|
|
Loading…
Reference in New Issue