summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.h
diff options
context:
space:
mode:
authorGravatar bunnei2018-12-27 11:15:34 -0500
committerGravatar GitHub2018-12-27 11:15:34 -0500
commit795335af0f37ce25da3c3ca8eeab62c50f87d366 (patch)
tree48bde2f34a4e9c87dc96f83bfbeeeee96b72b9e6 /src/core/hle/kernel/process.h
parentMerge pull request #1892 from Tinob/master (diff)
parentkernel/process: Hook up the process capability parser to the process itself (diff)
downloadyuzu-795335af0f37ce25da3c3ca8eeab62c50f87d366.tar.gz
yuzu-795335af0f37ce25da3c3ca8eeab62c50f87d366.tar.xz
yuzu-795335af0f37ce25da3c3ca8eeab62c50f87d366.zip
Merge pull request #1928 from lioncash/caps
kernel: Handle kernel capability descriptors
Diffstat (limited to 'src/core/hle/kernel/process.h')
-rw-r--r--src/core/hle/kernel/process.h58
1 files changed, 13 insertions, 45 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index 7da367251..2c0b20f9e 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -11,9 +11,9 @@
11#include <string> 11#include <string>
12#include <vector> 12#include <vector>
13#include <boost/container/static_vector.hpp> 13#include <boost/container/static_vector.hpp>
14#include "common/bit_field.h"
15#include "common/common_types.h" 14#include "common/common_types.h"
16#include "core/hle/kernel/handle_table.h" 15#include "core/hle/kernel/handle_table.h"
16#include "core/hle/kernel/process_capability.h"
17#include "core/hle/kernel/thread.h" 17#include "core/hle/kernel/thread.h"
18#include "core/hle/kernel/vm_manager.h" 18#include "core/hle/kernel/vm_manager.h"
19#include "core/hle/kernel/wait_object.h" 19#include "core/hle/kernel/wait_object.h"
@@ -42,24 +42,6 @@ enum class MemoryRegion : u16 {
42 BASE = 3, 42 BASE = 3,
43}; 43};
44 44
45union ProcessFlags {
46 u16 raw;
47
48 BitField<0, 1, u16>
49 allow_debug; ///< Allows other processes to attach to and debug this process.
50 BitField<1, 1, u16> force_debug; ///< Allows this process to attach to processes even if they
51 /// don't have allow_debug set.
52 BitField<2, 1, u16> allow_nonalphanum;
53 BitField<3, 1, u16> shared_page_writable; ///< Shared page is mapped with write permissions.
54 BitField<4, 1, u16> privileged_priority; ///< Can use priority levels higher than 24.
55 BitField<5, 1, u16> allow_main_args;
56 BitField<6, 1, u16> shared_device_mem;
57 BitField<7, 1, u16> runnable_on_sleep;
58 BitField<8, 4, MemoryRegion>
59 memory_region; ///< Default region for memory allocations for this process
60 BitField<12, 1, u16> loaded_high; ///< Application loaded high (not at 0x00100000).
61};
62
63/** 45/**
64 * Indicates the status of a Process instance. 46 * Indicates the status of a Process instance.
65 * 47 *
@@ -192,13 +174,13 @@ public:
192 } 174 }
193 175
194 /// Gets the bitmask of allowed CPUs that this process' threads can run on. 176 /// Gets the bitmask of allowed CPUs that this process' threads can run on.
195 u32 GetAllowedProcessorMask() const { 177 u64 GetAllowedProcessorMask() const {
196 return allowed_processor_mask; 178 return capabilities.GetCoreMask();
197 } 179 }
198 180
199 /// Gets the bitmask of allowed thread priorities. 181 /// Gets the bitmask of allowed thread priorities.
200 u32 GetAllowedThreadPriorityMask() const { 182 u64 GetAllowedThreadPriorityMask() const {
201 return allowed_thread_priority_mask; 183 return capabilities.GetPriorityMask();
202 } 184 }
203 185
204 u32 IsVirtualMemoryEnabled() const { 186 u32 IsVirtualMemoryEnabled() const {
@@ -239,15 +221,12 @@ public:
239 * Loads process-specifics configuration info with metadata provided 221 * Loads process-specifics configuration info with metadata provided
240 * by an executable. 222 * by an executable.
241 * 223 *
242 * @param metadata The provided metadata to load process specific info. 224 * @param metadata The provided metadata to load process specific info from.
243 */ 225 *
244 void LoadFromMetadata(const FileSys::ProgramMetadata& metadata); 226 * @returns RESULT_SUCCESS if all relevant metadata was able to be
245 227 * loaded and parsed. Otherwise, an error code is returned.
246 /**
247 * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them
248 * to this process.
249 */ 228 */
250 void ParseKernelCaps(const u32* kernel_caps, std::size_t len); 229 ResultCode LoadFromMetadata(const FileSys::ProgramMetadata& metadata);
251 230
252 /** 231 /**
253 * Applies address space changes and launches the process main thread. 232 * Applies address space changes and launches the process main thread.
@@ -308,22 +287,8 @@ private:
308 /// Resource limit descriptor for this process 287 /// Resource limit descriptor for this process
309 SharedPtr<ResourceLimit> resource_limit; 288 SharedPtr<ResourceLimit> resource_limit;
310 289
311 /// The process may only call SVCs which have the corresponding bit set.
312 std::bitset<0x80> svc_access_mask;
313 /// Maximum size of the handle table for the process.
314 u32 handle_table_size = 0x200;
315 /// Special memory ranges mapped into this processes address space. This is used to give
316 /// processes access to specific I/O regions and device memory.
317 boost::container::static_vector<AddressMapping, 8> address_mappings;
318 ProcessFlags flags;
319 /// Kernel compatibility version for this process
320 u16 kernel_version = 0;
321 /// The default CPU for this process, threads are scheduled on this cpu by default. 290 /// The default CPU for this process, threads are scheduled on this cpu by default.
322 u8 ideal_processor = 0; 291 u8 ideal_processor = 0;
323 /// Bitmask of allowed CPUs that this process' threads can run on. TODO(Subv): Actually parse
324 /// this value from the process header.
325 u32 allowed_processor_mask = THREADPROCESSORID_DEFAULT_MASK;
326 u32 allowed_thread_priority_mask = 0xFFFFFFFF;
327 u32 is_virtual_address_memory_enabled = 0; 292 u32 is_virtual_address_memory_enabled = 0;
328 293
329 /// The Thread Local Storage area is allocated as processes create threads, 294 /// The Thread Local Storage area is allocated as processes create threads,
@@ -333,6 +298,9 @@ private:
333 /// This vector will grow as more pages are allocated for new threads. 298 /// This vector will grow as more pages are allocated for new threads.
334 std::vector<std::bitset<8>> tls_slots; 299 std::vector<std::bitset<8>> tls_slots;
335 300
301 /// Contains the parsed process capability descriptors.
302 ProcessCapabilities capabilities;
303
336 /// Whether or not this process is AArch64, or AArch32. 304 /// Whether or not this process is AArch64, or AArch32.
337 /// By default, we currently assume this is true, unless otherwise 305 /// By default, we currently assume this is true, unless otherwise
338 /// specified by metadata provided to the process during loading. 306 /// specified by metadata provided to the process during loading.