From cdeeecf0807d0005356f30db0f7164c5891a9245 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 17 Jul 2015 23:19:16 -0300 Subject: Kernel: Properly implement ControlMemory FREE and COMMIT --- src/core/hle/kernel/process.h | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/core/hle/kernel/process.h') diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 83d3aceae..567d5df18 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -15,6 +15,7 @@ #include "common/common_types.h" #include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/vm_manager.h" namespace Kernel { @@ -48,7 +49,6 @@ union ProcessFlags { }; class ResourceLimit; -class VMManager; struct CodeSet final : public Object { static SharedPtr Create(std::string name, u64 program_id); @@ -108,10 +108,6 @@ public: /// The id of this process u32 process_id = next_process_id++; - /// Bitmask of the used TLS slots - std::bitset<300> used_tls_slots; - std::unique_ptr address_space; - /** * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them * to this process. @@ -123,6 +119,31 @@ public: */ void Run(s32 main_thread_priority, u32 stack_size); + + /////////////////////////////////////////////////////////////////////////////////////////////// + // Memory Management + + VMManager vm_manager; + + // Memory used to back the allocations in the regular heap. A single vector is used to cover + // the entire virtual address space extents that bound the allocations, including any holes. + // This makes deallocation and reallocation of holes fast and keeps process memory contiguous + // in the emulator address space, allowing Memory::GetPointer to be reasonably safe. + std::shared_ptr> heap_memory; + // The left/right bounds of the address space covered by heap_memory. + VAddr heap_start = 0, heap_end = 0; + + std::shared_ptr> linear_heap_memory; + + /// Bitmask of the used TLS slots + std::bitset<300> used_tls_slots; + + ResultVal HeapAllocate(VAddr target, u32 size, VMAPermission perms); + ResultCode HeapFree(VAddr target, u32 size); + + ResultVal LinearAllocate(VAddr target, u32 size, VMAPermission perms); + ResultCode LinearFree(VAddr target, u32 size); + private: Process(); ~Process() override; -- cgit v1.2.3 From a12a30c9e0c059f87649a1f87b76003ee44efe73 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 19 Jul 2015 15:18:57 -0300 Subject: Process: Store kernel compatibility version during loading --- src/core/hle/kernel/process.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/hle/kernel/process.h') diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 567d5df18..5c7de9044 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -104,6 +104,8 @@ public: /// processes access to specific I/O regions and device memory. boost::container::static_vector address_mappings; ProcessFlags flags; + /// Kernel compatibility version for this process + u16 kernel_version = 0; /// The id of this process u32 process_id = next_process_id++; -- cgit v1.2.3 From 74d4bc0af1d2f22105bf3c00efcb85613d59cc19 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 5 Aug 2015 21:26:52 -0300 Subject: Kernel: Add more infrastructure to support different memory layouts This adds some structures necessary to support multiple memory regions in the future. It also adds support for different system memory types and the new linear heap mapping at 0x30000000. --- src/core/hle/kernel/process.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/core/hle/kernel/process.h') diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 5c7de9044..7c3a78b9e 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -49,6 +49,7 @@ union ProcessFlags { }; class ResourceLimit; +struct MemoryRegionInfo; struct CodeSet final : public Object { static SharedPtr Create(std::string name, u64 program_id); @@ -135,11 +136,14 @@ public: // The left/right bounds of the address space covered by heap_memory. VAddr heap_start = 0, heap_end = 0; - std::shared_ptr> linear_heap_memory; + MemoryRegionInfo* memory_region = nullptr; /// Bitmask of the used TLS slots std::bitset<300> used_tls_slots; + VAddr GetLinearHeapBase() const; + VAddr GetLinearHeapLimit() const; + ResultVal HeapAllocate(VAddr target, u32 size, VMAPermission perms); ResultCode HeapFree(VAddr target, u32 size); -- cgit v1.2.3 From 14eca982f4da2bfd4d2c105bc33722e88e59da5f Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 5 Aug 2015 21:39:53 -0300 Subject: Kernel: Implement svcGetProcessInfo in a basic way This also adds some basic memory usage accounting. These two types are used by Super Smash Bros. during startup. --- src/core/hle/kernel/process.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/hle/kernel/process.h') diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 7c3a78b9e..60e17f251 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -136,6 +136,8 @@ public: // The left/right bounds of the address space covered by heap_memory. VAddr heap_start = 0, heap_end = 0; + u32 heap_used = 0, linear_heap_used = 0, misc_memory_used = 0; + MemoryRegionInfo* memory_region = nullptr; /// Bitmask of the used TLS slots -- cgit v1.2.3