summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-08-03 05:37:44 +0200
committerLioncash <mathew1800@gmail.com>2018-08-03 17:22:47 +0200
commit26de4bb521b1ace7af76eff4f6956cb23ac0d58c (patch)
tree904a93d00abf5bde2742499fb3d60a3aa1521820 /src/core/hle/kernel/thread.cpp
parentMerge pull request #892 from lioncash/global (diff)
downloadyuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.gz
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.bz2
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.lz
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.xz
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.tar.zst
yuzu-26de4bb521b1ace7af76eff4f6956cb23ac0d58c.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/thread.cpp33
1 files changed, 2 insertions, 31 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index cdb8120f2..ea9554cbb 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -20,7 +20,6 @@
#include "core/core_timing_util.h"
#include "core/hle/kernel/errors.h"
#include "core/hle/kernel/handle_table.h"
-#include "core/hle/kernel/memory.h"
#include "core/hle/kernel/object.h"
#include "core/hle/kernel/process.h"
#include "core/hle/kernel/thread.h"
@@ -81,8 +80,8 @@ void Thread::Stop() {
wait_objects.clear();
// Mark the TLS slot in the thread's page as free.
- u64 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE;
- u64 tls_slot =
+ const u64 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE;
+ const u64 tls_slot =
((tls_address - Memory::TLS_AREA_VADDR) % Memory::PAGE_SIZE) / Memory::TLS_ENTRY_SIZE;
Core::CurrentProcess()->tls_slots[tls_page].reset(tls_slot);
}
@@ -336,38 +335,10 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
auto& tls_slots = owner_process->tls_slots;
auto [available_page, available_slot, needs_allocation] = GetFreeThreadLocalSlot(tls_slots);
-
if (needs_allocation) {
- // There are no already-allocated pages with free slots, lets allocate a new one.
- // TLS pages are allocated from the BASE region in the linear heap.
- MemoryRegionInfo* memory_region = GetMemoryRegion(MemoryRegion::BASE);
- auto& linheap_memory = memory_region->linear_heap_memory;
-
- if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) {
- LOG_ERROR(Kernel_SVC,
- "Not enough space in region to allocate a new TLS page for thread");
- return ERR_OUT_OF_MEMORY;
- }
-
- size_t offset = linheap_memory->size();
-
- // Allocate some memory from the end of the linear heap for this region.
- linheap_memory->insert(linheap_memory->end(), Memory::PAGE_SIZE, 0);
- memory_region->used += Memory::PAGE_SIZE;
- owner_process->linear_heap_used += Memory::PAGE_SIZE;
-
tls_slots.emplace_back(0); // The page is completely available at the start
available_page = tls_slots.size() - 1;
available_slot = 0; // Use the first slot in the new page
-
- auto& vm_manager = owner_process->vm_manager;
- vm_manager.RefreshMemoryBlockMappings(linheap_memory.get());
-
- // Map the page to the current process' address space.
- // TODO(Subv): Find the correct MemoryState for this region.
- vm_manager.MapMemoryBlock(Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE,
- linheap_memory, offset, Memory::PAGE_SIZE,
- MemoryState::ThreadLocal);
}
// Mark the slot as used