Various fixes and utilties.
This commit is contained in:
@@ -333,6 +333,15 @@ X_STATUS XThread::PlatformExit(int exit_code) {
|
||||
#endif // WIN32
|
||||
|
||||
void XThread::Execute() {
|
||||
XELOGKERNEL("XThread::Execute thid %d (handle=%.8X, '%s', native=%.8X)",
|
||||
thread_id_, handle(), name_.c_str(),
|
||||
poly::threading::current_thread_id());
|
||||
|
||||
// All threads get a mandatory sleep. This is to deal with some buggy
|
||||
// games that are assuming the 360 is so slow to create threads that they
|
||||
// have time to initialize shared structures AFTER CreateThread (RR).
|
||||
poly::threading::Sleep(std::chrono::milliseconds::duration(100));
|
||||
|
||||
// If a XapiThreadStartup value is present, we use that as a trampoline.
|
||||
// Otherwise, we are a raw thread.
|
||||
if (creation_params_.xapi_thread_startup) {
|
||||
|
||||
@@ -94,6 +94,8 @@ SHIM_CALL NtAllocateVirtualMemory_shim(PPCContext* ppc_state,
|
||||
return;
|
||||
}
|
||||
|
||||
XELOGD("NtAllocateVirtualMemory = %.8X", addr);
|
||||
|
||||
// Stash back.
|
||||
// Maybe set X_STATUS_ALREADY_COMMITTED if MEM_COMMIT?
|
||||
SHIM_SET_MEM_32(base_addr_ptr, addr);
|
||||
@@ -249,6 +251,7 @@ SHIM_CALL MmAllocatePhysicalMemoryEx_shim(PPCContext* ppc_state,
|
||||
SHIM_SET_RETURN_32(0);
|
||||
return;
|
||||
}
|
||||
XELOGD("MmAllocatePhysicalMemoryEx = %.8X", base_address);
|
||||
|
||||
// Move the address into the right range.
|
||||
// if (protect_bits & X_MEM_LARGE_PAGES) {
|
||||
@@ -260,7 +263,7 @@ SHIM_CALL MmAllocatePhysicalMemoryEx_shim(PPCContext* ppc_state,
|
||||
//}
|
||||
base_address += 0xA0000000;
|
||||
|
||||
SHIM_SET_RETURN_32(base_address);
|
||||
SHIM_SET_RETURN_64(base_address);
|
||||
}
|
||||
|
||||
SHIM_CALL MmFreePhysicalMemory_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
@@ -381,7 +384,7 @@ SHIM_CALL MmGetPhysicalAddress_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
base_address |= 0xE0000000;
|
||||
}*/
|
||||
|
||||
SHIM_SET_RETURN_32(base_address);
|
||||
SHIM_SET_RETURN_64(base_address);
|
||||
}
|
||||
|
||||
SHIM_CALL MmMapIoSpace_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
@@ -399,7 +402,7 @@ SHIM_CALL MmMapIoSpace_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
assert_true(size == 0x40);
|
||||
assert_true(flags == 0x404);
|
||||
|
||||
SHIM_SET_RETURN_32(src_address);
|
||||
SHIM_SET_RETURN_64(src_address);
|
||||
}
|
||||
|
||||
SHIM_CALL ExAllocatePoolTypeWithTag_shim(PPCContext* ppc_state,
|
||||
@@ -420,7 +423,7 @@ SHIM_CALL ExAllocatePoolTypeWithTag_shim(PPCContext* ppc_state,
|
||||
|
||||
uint32_t addr = state->memory()->SystemHeapAlloc(adjusted_size, alignment);
|
||||
|
||||
SHIM_SET_RETURN_32(addr);
|
||||
SHIM_SET_RETURN_64(addr);
|
||||
}
|
||||
|
||||
SHIM_CALL ExFreePool_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
|
||||
@@ -565,7 +565,7 @@ spin:
|
||||
// All out of spin waits, create a full waiter.
|
||||
// TODO(benvanik): contention - do a real wait!
|
||||
// XELOGE("RtlEnterCriticalSection tried to really lock!");
|
||||
spin_wait_remaining = 1; // HACK: spin forever
|
||||
spin_wait_remaining = 0; // HACK: spin forever
|
||||
Sleep(1);
|
||||
goto spin;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ SHIM_CALL ExCreateThread_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
stack_size, thread_id_ptr, xapi_thread_startup, start_address,
|
||||
start_context, creation_flags);
|
||||
|
||||
// http://jafile.com/uploads/scoop/main.cpp.txt
|
||||
// DWORD
|
||||
// LPHANDLE Handle,
|
||||
// DWORD StackSize,
|
||||
|
||||
@@ -356,7 +356,20 @@ SHIM_CALL VdIsHSIOTrainingSucceeded_shim(PPCContext* ppc_state,
|
||||
}
|
||||
|
||||
SHIM_CALL VdPersistDisplay_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD("VdPersistDisplay(?)");
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t unk1_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk2 = SHIM_GET_ARG_32(2);
|
||||
uint32_t unk3 = SHIM_GET_ARG_32(3);
|
||||
uint32_t unk4 = SHIM_GET_ARG_32(4);
|
||||
uint32_t unk5 = SHIM_GET_ARG_32(5);
|
||||
uint32_t unk6 = SHIM_GET_ARG_32(6);
|
||||
uint32_t unk7 = SHIM_GET_ARG_32(7);
|
||||
|
||||
XELOGD("VdPersistDisplay(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
unk0, unk1_ptr, unk2, unk3, unk4, unk5, unk6, unk7);
|
||||
|
||||
// unk1_ptr needs to be populated with a pointer passed to
|
||||
// MmFreePhysicalMemory(1, *unk1_ptr).
|
||||
|
||||
// ?
|
||||
SHIM_SET_RETURN_64(1);
|
||||
|
||||
Reference in New Issue
Block a user