commit
d9364eccac
|
@ -176,7 +176,9 @@ X_STATUS XThread::Create() {
|
||||||
uint32_t tls_size = 32; // Default 32 (is this OK?)
|
uint32_t tls_size = 32; // Default 32 (is this OK?)
|
||||||
if (module && module->xex_header()) {
|
if (module && module->xex_header()) {
|
||||||
const xe_xex2_header_t* header = module->xex_header();
|
const xe_xex2_header_t* header = module->xex_header();
|
||||||
tls_size = header->tls_info.slot_count * header->tls_info.data_size;
|
|
||||||
|
// FIXME: Is this correct?
|
||||||
|
tls_size = header->tls_info.data_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
tls_address_ = memory()->SystemHeapAlloc(tls_size);
|
tls_address_ = memory()->SystemHeapAlloc(tls_size);
|
||||||
|
@ -190,8 +192,7 @@ X_STATUS XThread::Create() {
|
||||||
const xe_xex2_header_t* header = module->xex_header();
|
const xe_xex2_header_t* header = module->xex_header();
|
||||||
|
|
||||||
// Copy in default TLS info.
|
// Copy in default TLS info.
|
||||||
// TODO(benvanik): is this correct?
|
memory()->Copy(tls_address_, header->tls_info.raw_data_address, header->tls_info.data_size);
|
||||||
memory()->Copy(tls_address_, header->tls_info.raw_data_address, tls_size);
|
|
||||||
} else {
|
} else {
|
||||||
memory()->Fill(tls_address_, tls_size, 0);
|
memory()->Fill(tls_address_, tls_size, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1325,31 +1325,41 @@ SHIM_CALL KeRemoveQueueDpc_shim(PPCContext* ppc_context,
|
||||||
xe::mutex global_list_mutex_;
|
xe::mutex global_list_mutex_;
|
||||||
|
|
||||||
// http://www.nirsoft.net/kernel_struct/vista/SLIST_HEADER.html
|
// http://www.nirsoft.net/kernel_struct/vista/SLIST_HEADER.html
|
||||||
SHIM_CALL InterlockedPopEntrySList_shim(PPCContext* ppc_context,
|
struct SLIST_HEADER {
|
||||||
KernelState* kernel_state) {
|
xe::be<uint32_t> next;
|
||||||
uint32_t plist_ptr = SHIM_GET_ARG_32(0);
|
xe::be<uint16_t> depth;
|
||||||
|
xe::be<uint16_t> sequence;
|
||||||
XELOGD("InterlockedPopEntrySList(%.8X)", plist_ptr);
|
};
|
||||||
|
|
||||||
|
pointer_result_t InterlockedPopEntrySList(pointer_t<SLIST_HEADER> plist_ptr) {
|
||||||
std::lock_guard<xe::mutex> lock(global_list_mutex_);
|
std::lock_guard<xe::mutex> lock(global_list_mutex_);
|
||||||
|
|
||||||
uint8_t* p = kernel_state->memory()->TranslateVirtual(plist_ptr);
|
uint32_t first = plist_ptr->next;
|
||||||
auto first = xe::load_and_swap<uint32_t>(p);
|
|
||||||
if (first == 0) {
|
if (first == 0) {
|
||||||
// List empty!
|
// List empty!
|
||||||
SHIM_SET_RETURN_32(0);
|
return 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* p2 = kernel_state->memory()->TranslateVirtual(first);
|
// Get the second element.
|
||||||
auto second = xe::load_and_swap<uint32_t>(p2);
|
uint8_t* p = kernel_memory()->TranslateVirtual(first);
|
||||||
|
auto second = xe::load_and_swap<uint32_t>(p);
|
||||||
|
|
||||||
// Now drop the first element
|
plist_ptr->next = second;
|
||||||
xe::store_and_swap<uint32_t>(p, second);
|
|
||||||
|
|
||||||
// Return the one we popped
|
// Return the one we popped
|
||||||
SHIM_SET_RETURN_32(first);
|
return first;
|
||||||
}
|
}
|
||||||
|
DECLARE_XBOXKRNL_EXPORT(InterlockedPopEntrySList, ExportTag::kImplemented);
|
||||||
|
|
||||||
|
pointer_result_t InterlockedFlushSList(pointer_t<SLIST_HEADER> plist_ptr) {
|
||||||
|
std::lock_guard<xe::mutex> lock(global_list_mutex_);
|
||||||
|
|
||||||
|
uint32_t next = plist_ptr->next;
|
||||||
|
plist_ptr->next = 0;
|
||||||
|
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
DECLARE_XBOXKRNL_EXPORT(InterlockedFlushSList, ExportTag::kImplemented);
|
||||||
|
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
@ -1426,6 +1436,4 @@ void xe::kernel::xboxkrnl::RegisterThreadingExports(
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", KeInitializeDpc, state);
|
SHIM_SET_MAPPING("xboxkrnl.exe", KeInitializeDpc, state);
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", KeInsertQueueDpc, state);
|
SHIM_SET_MAPPING("xboxkrnl.exe", KeInsertQueueDpc, state);
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", KeRemoveQueueDpc, state);
|
SHIM_SET_MAPPING("xboxkrnl.exe", KeRemoveQueueDpc, state);
|
||||||
|
|
||||||
SHIM_SET_MAPPING("xboxkrnl.exe", InterlockedPopEntrySList, state);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,8 +179,7 @@ int Memory::Initialize() {
|
||||||
heaps_.v00000000.AllocFixed(
|
heaps_.v00000000.AllocFixed(
|
||||||
0x00000000, 4096, 4096,
|
0x00000000, 4096, 4096,
|
||||||
kMemoryAllocationReserve | kMemoryAllocationCommit,
|
kMemoryAllocationReserve | kMemoryAllocationCommit,
|
||||||
// 0u);
|
kMemoryProtectNoAccess);
|
||||||
kMemoryProtectRead | kMemoryProtectWrite);
|
|
||||||
|
|
||||||
// GPU writeback.
|
// GPU writeback.
|
||||||
// 0xC... is physical, 0x7F... is virtual. We may need to overlay these.
|
// 0xC... is physical, 0x7F... is virtual. We may need to overlay these.
|
||||||
|
|
Loading…
Reference in New Issue