From e9f1a534dff810c066ef6e0b99d888bb1d34b951 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sat, 1 Aug 2020 08:13:54 +0200 Subject: [PATCH] [Kernel/Thread] Changed default stack location --- src/xenia/kernel/xthread.cc | 12 ++++++------ src/xenia/kernel/xthread.h | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/xenia/kernel/xthread.cc b/src/xenia/kernel/xthread.cc index 871a50820..e11a94296 100644 --- a/src/xenia/kernel/xthread.cc +++ b/src/xenia/kernel/xthread.cc @@ -226,7 +226,7 @@ void XThread::InitializeGuestObject() { } bool XThread::AllocateStack(uint32_t size) { - auto heap = memory()->LookupHeap(0x40000000); + auto heap = memory()->LookupHeap(kStackAddressRangeBegin); auto alignment = heap->page_size(); auto padding = heap->page_size() * 2; // Guard page size * 2 @@ -234,10 +234,10 @@ bool XThread::AllocateStack(uint32_t size) { auto actual_size = size + padding; uint32_t address = 0; - if (!heap->AllocRange(0x40000000, 0x7F000000, actual_size, alignment, - kMemoryAllocationReserve | kMemoryAllocationCommit, - kMemoryProtectRead | kMemoryProtectWrite, false, - &address)) { + if (!heap->AllocRange( + kStackAddressRangeBegin, kStackAddressRangeEnd, actual_size, + alignment, kMemoryAllocationReserve | kMemoryAllocationCommit, + kMemoryProtectRead | kMemoryProtectWrite, false, &address)) { return false; } @@ -258,7 +258,7 @@ bool XThread::AllocateStack(uint32_t size) { void XThread::FreeStack() { if (stack_alloc_base_) { - auto heap = memory()->LookupHeap(0x40000000); + auto heap = memory()->LookupHeap(kStackAddressRangeBegin); heap->Release(stack_alloc_base_); stack_alloc_base_ = 0; diff --git a/src/xenia/kernel/xthread.h b/src/xenia/kernel/xthread.h index c6bb7cb6c..9eef807b2 100644 --- a/src/xenia/kernel/xthread.h +++ b/src/xenia/kernel/xthread.h @@ -149,6 +149,9 @@ class XThread : public XObject, public cpu::Thread { public: static const XObject::Type kObjectType = XObject::Type::Thread; + static constexpr uint32_t kStackAddressRangeBegin = 0x70000000; + static constexpr uint32_t kStackAddressRangeEnd = 0x7F000000; + struct CreationParams { uint32_t stack_size; uint32_t xapi_thread_startup;