mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-13 15:19:11 +00:00
memory: Cleanups and refactors (#324)
* memory: Various fixes * Added (Partial) sceKernelBatchMap/sceKernelBatchMap2 * memory: Rename and implement batch unmap * memory: Remove uneeded assert * memory: Commonize free search routine * memory: Contains check is inclusive * memory: Address some alignment issues * clang format --------- Co-authored-by: raziel1000 <ckraziel@gmail.com>
This commit is contained in:
@@ -320,11 +320,15 @@ void Linker::InitTlsForThread(bool is_primary) {
|
||||
static constexpr size_t TlsAllocAlign = 0x20;
|
||||
const size_t total_tls_size = Common::AlignUp(static_tls_size, TlsAllocAlign) + TcbSize;
|
||||
|
||||
// If sceKernelMapNamedFlexibleMemory is being called from libkernel and addr = 0
|
||||
// it automatically places mappings in system reserved area instead of managed.
|
||||
static constexpr VAddr KernelAllocBase = 0x880000000ULL;
|
||||
|
||||
// The kernel module has a few different paths for TLS allocation.
|
||||
// For SDK < 1.7 it allocates both main and secondary thread blocks using libc mspace/malloc.
|
||||
// In games compiled with newer SDK, the main thread gets mapped from flexible memory,
|
||||
// with addr = 0, so system managed area. Here we will only implement the latter.
|
||||
void* addr_out{};
|
||||
void* addr_out{reinterpret_cast<void*>(KernelAllocBase)};
|
||||
if (is_primary) {
|
||||
const size_t tls_aligned = Common::AlignUp(total_tls_size, 16_KB);
|
||||
const int ret = Libraries::Kernel::sceKernelMapNamedFlexibleMemory(
|
||||
|
||||
Reference in New Issue
Block a user