diff options
| author | 2015-07-09 22:52:15 -0300 | |
|---|---|---|
| committer | 2015-07-11 23:54:42 -0300 | |
| commit | 5c5cf2f8e000d1bf4fc12ff20351aa60367cb563 (patch) | |
| tree | 2b233263cff7c001506f660373e2364c8e702637 /src/core/hle/kernel/process.h | |
| parent | Memory: Fix unmapping of pages (diff) | |
| download | yuzu-5c5cf2f8e000d1bf4fc12ff20351aa60367cb563.tar.gz yuzu-5c5cf2f8e000d1bf4fc12ff20351aa60367cb563.tar.xz yuzu-5c5cf2f8e000d1bf4fc12ff20351aa60367cb563.zip | |
Core: Properly configure address space when loading a binary
The code now properly configures the process image to match the loaded
binary segments (code, rodata, data) instead of just blindly allocating
a large chunk of dummy memory.
Diffstat (limited to 'src/core/hle/kernel/process.h')
| -rw-r--r-- | src/core/hle/kernel/process.h | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 674f5093a..92fa0fa6f 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -47,23 +47,51 @@ union ProcessFlags { | |||
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | class ResourceLimit; | 49 | class ResourceLimit; |
| 50 | class VMManager; | ||
| 51 | |||
| 52 | struct CodeSet final : public Object { | ||
| 53 | static SharedPtr<CodeSet> Create(std::string name, u64 program_id); | ||
| 54 | |||
| 55 | std::string GetTypeName() const override { return "CodeSet"; } | ||
| 56 | std::string GetName() const override { return name; } | ||
| 57 | |||
| 58 | static const HandleType HANDLE_TYPE = HandleType::CodeSet; | ||
| 59 | HandleType GetHandleType() const override { return HANDLE_TYPE; } | ||
| 60 | |||
| 61 | /// Name of the process | ||
| 62 | std::string name; | ||
| 63 | /// Title ID corresponding to the process | ||
| 64 | u64 program_id; | ||
| 65 | |||
| 66 | std::shared_ptr<std::vector<u8>> memory; | ||
| 67 | |||
| 68 | struct Segment { | ||
| 69 | size_t offset = 0; | ||
| 70 | VAddr addr = 0; | ||
| 71 | u32 size = 0; | ||
| 72 | }; | ||
| 73 | |||
| 74 | Segment code, rodata, data; | ||
| 75 | VAddr entrypoint; | ||
| 76 | |||
| 77 | private: | ||
| 78 | CodeSet(); | ||
| 79 | ~CodeSet() override; | ||
| 80 | }; | ||
| 50 | 81 | ||
| 51 | class Process final : public Object { | 82 | class Process final : public Object { |
| 52 | public: | 83 | public: |
| 53 | static SharedPtr<Process> Create(std::string name, u64 program_id); | 84 | static SharedPtr<Process> Create(SharedPtr<CodeSet> code_set); |
| 54 | 85 | ||
| 55 | std::string GetTypeName() const override { return "Process"; } | 86 | std::string GetTypeName() const override { return "Process"; } |
| 56 | std::string GetName() const override { return name; } | 87 | std::string GetName() const override { return codeset->name; } |
| 57 | 88 | ||
| 58 | static const HandleType HANDLE_TYPE = HandleType::Process; | 89 | static const HandleType HANDLE_TYPE = HandleType::Process; |
| 59 | HandleType GetHandleType() const override { return HANDLE_TYPE; } | 90 | HandleType GetHandleType() const override { return HANDLE_TYPE; } |
| 60 | 91 | ||
| 61 | static u32 next_process_id; | 92 | static u32 next_process_id; |
| 62 | 93 | ||
| 63 | /// Name of the process | 94 | SharedPtr<CodeSet> codeset; |
| 64 | std::string name; | ||
| 65 | /// Title ID corresponding to the process | ||
| 66 | u64 program_id; | ||
| 67 | /// Resource limit descriptor for this process | 95 | /// Resource limit descriptor for this process |
| 68 | SharedPtr<ResourceLimit> resource_limit; | 96 | SharedPtr<ResourceLimit> resource_limit; |
| 69 | 97 | ||
| @@ -81,6 +109,7 @@ public: | |||
| 81 | 109 | ||
| 82 | /// Bitmask of the used TLS slots | 110 | /// Bitmask of the used TLS slots |
| 83 | std::bitset<300> used_tls_slots; | 111 | std::bitset<300> used_tls_slots; |
| 112 | std::unique_ptr<VMManager> address_space; | ||
| 84 | 113 | ||
| 85 | /** | 114 | /** |
| 86 | * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them | 115 | * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them |
| @@ -91,7 +120,7 @@ public: | |||
| 91 | /** | 120 | /** |
| 92 | * Applies address space changes and launches the process main thread. | 121 | * Applies address space changes and launches the process main thread. |
| 93 | */ | 122 | */ |
| 94 | void Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size); | 123 | void Run(s32 main_thread_priority, u32 stack_size); |
| 95 | 124 | ||
| 96 | private: | 125 | private: |
| 97 | Process(); | 126 | Process(); |