summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/process_capability.cpp24
-rw-r--r--src/core/hle/kernel/process_capability.h24
2 files changed, 25 insertions, 23 deletions
diff --git a/src/core/hle/kernel/process_capability.cpp b/src/core/hle/kernel/process_capability.cpp
index 583e35b79..48e5ae682 100644
--- a/src/core/hle/kernel/process_capability.cpp
+++ b/src/core/hle/kernel/process_capability.cpp
@@ -5,8 +5,8 @@
5#include "common/bit_util.h" 5#include "common/bit_util.h"
6#include "core/hle/kernel/errors.h" 6#include "core/hle/kernel/errors.h"
7#include "core/hle/kernel/handle_table.h" 7#include "core/hle/kernel/handle_table.h"
8#include "core/hle/kernel/memory/page_table.h"
8#include "core/hle/kernel/process_capability.h" 9#include "core/hle/kernel/process_capability.h"
9#include "core/hle/kernel/vm_manager.h"
10 10
11namespace Kernel { 11namespace Kernel {
12namespace { 12namespace {
@@ -66,7 +66,7 @@ u32 GetFlagBitOffset(CapabilityType type) {
66 66
67ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabilities, 67ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabilities,
68 std::size_t num_capabilities, 68 std::size_t num_capabilities,
69 VMManager& vm_manager) { 69 Memory::PageTable& page_table) {
70 Clear(); 70 Clear();
71 71
72 // Allow all cores and priorities. 72 // Allow all cores and priorities.
@@ -74,15 +74,15 @@ ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabiliti
74 priority_mask = 0xFFFFFFFFFFFFFFFF; 74 priority_mask = 0xFFFFFFFFFFFFFFFF;
75 kernel_version = PackedKernelVersion; 75 kernel_version = PackedKernelVersion;
76 76
77 return ParseCapabilities(capabilities, num_capabilities, vm_manager); 77 return ParseCapabilities(capabilities, num_capabilities, page_table);
78} 78}
79 79
80ResultCode ProcessCapabilities::InitializeForUserProcess(const u32* capabilities, 80ResultCode ProcessCapabilities::InitializeForUserProcess(const u32* capabilities,
81 std::size_t num_capabilities, 81 std::size_t num_capabilities,
82 VMManager& vm_manager) { 82 Memory::PageTable& page_table) {
83 Clear(); 83 Clear();
84 84
85 return ParseCapabilities(capabilities, num_capabilities, vm_manager); 85 return ParseCapabilities(capabilities, num_capabilities, page_table);
86} 86}
87 87
88void ProcessCapabilities::InitializeForMetadatalessProcess() { 88void ProcessCapabilities::InitializeForMetadatalessProcess() {
@@ -105,7 +105,7 @@ void ProcessCapabilities::InitializeForMetadatalessProcess() {
105 105
106ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities, 106ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities,
107 std::size_t num_capabilities, 107 std::size_t num_capabilities,
108 VMManager& vm_manager) { 108 Memory::PageTable& page_table) {
109 u32 set_flags = 0; 109 u32 set_flags = 0;
110 u32 set_svc_bits = 0; 110 u32 set_svc_bits = 0;
111 111
@@ -127,13 +127,13 @@ ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities,
127 return ERR_INVALID_COMBINATION; 127 return ERR_INVALID_COMBINATION;
128 } 128 }
129 129
130 const auto result = HandleMapPhysicalFlags(descriptor, size_flags, vm_manager); 130 const auto result = HandleMapPhysicalFlags(descriptor, size_flags, page_table);
131 if (result.IsError()) { 131 if (result.IsError()) {
132 return result; 132 return result;
133 } 133 }
134 } else { 134 } else {
135 const auto result = 135 const auto result =
136 ParseSingleFlagCapability(set_flags, set_svc_bits, descriptor, vm_manager); 136 ParseSingleFlagCapability(set_flags, set_svc_bits, descriptor, page_table);
137 if (result.IsError()) { 137 if (result.IsError()) {
138 return result; 138 return result;
139 } 139 }
@@ -144,7 +144,7 @@ ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities,
144} 144}
145 145
146ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, 146ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits,
147 u32 flag, VMManager& vm_manager) { 147 u32 flag, Memory::PageTable& page_table) {
148 const auto type = GetCapabilityType(flag); 148 const auto type = GetCapabilityType(flag);
149 149
150 if (type == CapabilityType::Unset) { 150 if (type == CapabilityType::Unset) {
@@ -172,7 +172,7 @@ ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& s
172 case CapabilityType::Syscall: 172 case CapabilityType::Syscall:
173 return HandleSyscallFlags(set_svc_bits, flag); 173 return HandleSyscallFlags(set_svc_bits, flag);
174 case CapabilityType::MapIO: 174 case CapabilityType::MapIO:
175 return HandleMapIOFlags(flag, vm_manager); 175 return HandleMapIOFlags(flag, page_table);
176 case CapabilityType::Interrupt: 176 case CapabilityType::Interrupt:
177 return HandleInterruptFlags(flag); 177 return HandleInterruptFlags(flag);
178 case CapabilityType::ProgramType: 178 case CapabilityType::ProgramType:
@@ -269,12 +269,12 @@ ResultCode ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags)
269} 269}
270 270
271ResultCode ProcessCapabilities::HandleMapPhysicalFlags(u32 flags, u32 size_flags, 271ResultCode ProcessCapabilities::HandleMapPhysicalFlags(u32 flags, u32 size_flags,
272 VMManager& vm_manager) { 272 Memory::PageTable& page_table) {
273 // TODO(Lioncache): Implement once the memory manager can handle this. 273 // TODO(Lioncache): Implement once the memory manager can handle this.
274 return RESULT_SUCCESS; 274 return RESULT_SUCCESS;
275} 275}
276 276
277ResultCode ProcessCapabilities::HandleMapIOFlags(u32 flags, VMManager& vm_manager) { 277ResultCode ProcessCapabilities::HandleMapIOFlags(u32 flags, Memory::PageTable& page_table) {
278 // TODO(Lioncache): Implement once the memory manager can handle this. 278 // TODO(Lioncache): Implement once the memory manager can handle this.
279 return RESULT_SUCCESS; 279 return RESULT_SUCCESS;
280} 280}
diff --git a/src/core/hle/kernel/process_capability.h b/src/core/hle/kernel/process_capability.h
index 5cdd80747..ea9d12c16 100644
--- a/src/core/hle/kernel/process_capability.h
+++ b/src/core/hle/kernel/process_capability.h
@@ -12,7 +12,9 @@ union ResultCode;
12 12
13namespace Kernel { 13namespace Kernel {
14 14
15class VMManager; 15namespace Memory {
16class PageTable;
17}
16 18
17/// The possible types of programs that may be indicated 19/// The possible types of programs that may be indicated
18/// by the program type capability descriptor. 20/// by the program type capability descriptor.
@@ -81,27 +83,27 @@ public:
81 /// 83 ///
82 /// @param capabilities The capabilities to parse 84 /// @param capabilities The capabilities to parse
83 /// @param num_capabilities The number of capabilities to parse. 85 /// @param num_capabilities The number of capabilities to parse.
84 /// @param vm_manager The memory manager to use for handling any mapping-related 86 /// @param page_table The memory manager to use for handling any mapping-related
85 /// operations (such as mapping IO memory, etc). 87 /// operations (such as mapping IO memory, etc).
86 /// 88 ///
87 /// @returns RESULT_SUCCESS if this capabilities instance was able to be initialized, 89 /// @returns RESULT_SUCCESS if this capabilities instance was able to be initialized,
88 /// otherwise, an error code upon failure. 90 /// otherwise, an error code upon failure.
89 /// 91 ///
90 ResultCode InitializeForKernelProcess(const u32* capabilities, std::size_t num_capabilities, 92 ResultCode InitializeForKernelProcess(const u32* capabilities, std::size_t num_capabilities,
91 VMManager& vm_manager); 93 Memory::PageTable& page_table);
92 94
93 /// Initializes this process capabilities instance for a userland process. 95 /// Initializes this process capabilities instance for a userland process.
94 /// 96 ///
95 /// @param capabilities The capabilities to parse. 97 /// @param capabilities The capabilities to parse.
96 /// @param num_capabilities The total number of capabilities to parse. 98 /// @param num_capabilities The total number of capabilities to parse.
97 /// @param vm_manager The memory manager to use for handling any mapping-related 99 /// @param page_table The memory manager to use for handling any mapping-related
98 /// operations (such as mapping IO memory, etc). 100 /// operations (such as mapping IO memory, etc).
99 /// 101 ///
100 /// @returns RESULT_SUCCESS if this capabilities instance was able to be initialized, 102 /// @returns RESULT_SUCCESS if this capabilities instance was able to be initialized,
101 /// otherwise, an error code upon failure. 103 /// otherwise, an error code upon failure.
102 /// 104 ///
103 ResultCode InitializeForUserProcess(const u32* capabilities, std::size_t num_capabilities, 105 ResultCode InitializeForUserProcess(const u32* capabilities, std::size_t num_capabilities,
104 VMManager& vm_manager); 106 Memory::PageTable& page_table);
105 107
106 /// Initializes this process capabilities instance for a process that does not 108 /// Initializes this process capabilities instance for a process that does not
107 /// have any metadata to parse. 109 /// have any metadata to parse.
@@ -181,13 +183,13 @@ private:
181 /// 183 ///
182 /// @param capabilities The sequence of capability descriptors to parse. 184 /// @param capabilities The sequence of capability descriptors to parse.
183 /// @param num_capabilities The number of descriptors within the given sequence. 185 /// @param num_capabilities The number of descriptors within the given sequence.
184 /// @param vm_manager The memory manager that will perform any memory 186 /// @param page_table The memory manager that will perform any memory
185 /// mapping if necessary. 187 /// mapping if necessary.
186 /// 188 ///
187 /// @return RESULT_SUCCESS if no errors occur, otherwise an error code. 189 /// @return RESULT_SUCCESS if no errors occur, otherwise an error code.
188 /// 190 ///
189 ResultCode ParseCapabilities(const u32* capabilities, std::size_t num_capabilities, 191 ResultCode ParseCapabilities(const u32* capabilities, std::size_t num_capabilities,
190 VMManager& vm_manager); 192 Memory::PageTable& page_table);
191 193
192 /// Attempts to parse a capability descriptor that is only represented by a 194 /// Attempts to parse a capability descriptor that is only represented by a
193 /// single flag set. 195 /// single flag set.
@@ -196,13 +198,13 @@ private:
196 /// flags being initialized more than once when they shouldn't be. 198 /// flags being initialized more than once when they shouldn't be.
197 /// @param set_svc_bits Running set of bits representing the allowed supervisor calls mask. 199 /// @param set_svc_bits Running set of bits representing the allowed supervisor calls mask.
198 /// @param flag The flag to attempt to parse. 200 /// @param flag The flag to attempt to parse.
199 /// @param vm_manager The memory manager that will perform any memory 201 /// @param page_table The memory manager that will perform any memory
200 /// mapping if necessary. 202 /// mapping if necessary.
201 /// 203 ///
202 /// @return RESULT_SUCCESS if no errors occurred, otherwise an error code. 204 /// @return RESULT_SUCCESS if no errors occurred, otherwise an error code.
203 /// 205 ///
204 ResultCode ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag, 206 ResultCode ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag,
205 VMManager& vm_manager); 207 Memory::PageTable& page_table);
206 208
207 /// Clears the internal state of this process capability instance. Necessary, 209 /// Clears the internal state of this process capability instance. Necessary,
208 /// to have a sane starting point due to us allowing running executables without 210 /// to have a sane starting point due to us allowing running executables without
@@ -226,10 +228,10 @@ private:
226 ResultCode HandleSyscallFlags(u32& set_svc_bits, u32 flags); 228 ResultCode HandleSyscallFlags(u32& set_svc_bits, u32 flags);
227 229
228 /// Handles flags related to mapping physical memory pages. 230 /// Handles flags related to mapping physical memory pages.
229 ResultCode HandleMapPhysicalFlags(u32 flags, u32 size_flags, VMManager& vm_manager); 231 ResultCode HandleMapPhysicalFlags(u32 flags, u32 size_flags, Memory::PageTable& page_table);
230 232
231 /// Handles flags related to mapping IO pages. 233 /// Handles flags related to mapping IO pages.
232 ResultCode HandleMapIOFlags(u32 flags, VMManager& vm_manager); 234 ResultCode HandleMapIOFlags(u32 flags, Memory::PageTable& page_table);
233 235
234 /// Handles flags related to the interrupt capability flags. 236 /// Handles flags related to the interrupt capability flags.
235 ResultCode HandleInterruptFlags(u32 flags); 237 ResultCode HandleInterruptFlags(u32 flags);