From 968c337d224e3db4624a4ff69cb9813f7e072313 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Fri, 16 Aug 2019 09:47:28 +0300 Subject: [PATCH] [APU] Temp XMA context allocation region workaround --- src/xenia/apu/xma_decoder.cc | 7 +++++-- src/xenia/memory.cc | 4 +++- src/xenia/memory.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xenia/apu/xma_decoder.cc b/src/xenia/apu/xma_decoder.cc index 05777051a..7971384f8 100644 --- a/src/xenia/apu/xma_decoder.cc +++ b/src/xenia/apu/xma_decoder.cc @@ -105,8 +105,11 @@ X_STATUS XmaDecoder::Setup(kernel::KernelState* kernel_state) { reinterpret_cast(MMIOWriteRegisterThunk)); // Setup XMA context data. - context_data_first_ptr_ = memory()->SystemHeapAlloc( - sizeof(XMA_CONTEXT_DATA) * kContextCount, 256, kSystemHeapPhysical); + // TODO(Triang3l): Find out what address is used on a real console and why it + // doesn't work when allocated in 4 KB pages. + context_data_first_ptr_ = + memory()->SystemHeapAlloc(sizeof(XMA_CONTEXT_DATA) * kContextCount, 256, + kSystemHeapPhysical | kSystemHeapLargePages); context_data_last_ptr_ = context_data_first_ptr_ + (sizeof(XMA_CONTEXT_DATA) * kContextCount - 1); register_file_[XE_XMA_REG_CONTEXT_ARRAY_ADDRESS].u32 = diff --git a/src/xenia/memory.cc b/src/xenia/memory.cc index d69783bfe..1ee387981 100644 --- a/src/xenia/memory.cc +++ b/src/xenia/memory.cc @@ -507,7 +507,9 @@ uint32_t Memory::SystemHeapAlloc(uint32_t size, uint32_t alignment, uint32_t system_heap_flags) { // TODO(benvanik): lightweight pool. bool is_physical = !!(system_heap_flags & kSystemHeapPhysical); - auto heap = LookupHeapByType(is_physical, 4096); + auto heap = LookupHeapByType( + is_physical, + (system_heap_flags & kSystemHeapLargePages) ? (64 * 1024) : 4096); uint32_t address; if (!heap->Alloc(size, alignment, kMemoryAllocationReserve | kMemoryAllocationCommit, diff --git a/src/xenia/memory.h b/src/xenia/memory.h index 4d76e5490..601773882 100644 --- a/src/xenia/memory.h +++ b/src/xenia/memory.h @@ -31,6 +31,7 @@ class Memory; enum SystemHeapFlag : uint32_t { kSystemHeapVirtual = 1 << 0, kSystemHeapPhysical = 1 << 1, + kSystemHeapLargePages = 1 << 2, kSystemHeapDefault = kSystemHeapVirtual, };