diff options
| author | 2015-05-08 21:20:37 -0400 | |
|---|---|---|
| committer | 2015-05-08 21:20:37 -0400 | |
| commit | 917ac23dfcab37c65e11e3413e397863bd4bc000 (patch) | |
| tree | 956ca5d1a4aad3383c4a3bfc9103476abe3f1987 /src/core/hle/kernel/process.h | |
| parent | Merge pull request #728 from lioncash/vars (diff) | |
| parent | Kernel: Remove unused g_main_thread variable (diff) | |
| download | yuzu-917ac23dfcab37c65e11e3413e397863bd4bc000.tar.gz yuzu-917ac23dfcab37c65e11e3413e397863bd4bc000.tar.xz yuzu-917ac23dfcab37c65e11e3413e397863bd4bc000.zip | |
Merge pull request #731 from yuriks/app-info
Kernel: Process class and ExHeader caps parsing
Diffstat (limited to 'src/core/hle/kernel/process.h')
| -rw-r--r-- | src/core/hle/kernel/process.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h new file mode 100644 index 000000000..88ed9a5a5 --- /dev/null +++ b/src/core/hle/kernel/process.h | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <bitset> | ||
| 8 | |||
| 9 | #include <boost/container/static_vector.hpp> | ||
| 10 | |||
| 11 | #include "common/bit_field.h" | ||
| 12 | #include "common/common_types.h" | ||
| 13 | |||
| 14 | #include "core/hle/kernel/kernel.h" | ||
| 15 | #include "core/hle/result.h" | ||
| 16 | |||
| 17 | namespace Kernel { | ||
| 18 | |||
| 19 | struct AddressMapping { | ||
| 20 | // Address and size must be page-aligned | ||
| 21 | VAddr address; | ||
| 22 | u32 size; | ||
| 23 | bool writable; | ||
| 24 | bool unk_flag; | ||
| 25 | }; | ||
| 26 | |||
| 27 | enum class MemoryRegion : u16 { | ||
| 28 | APPLICATION = 1, | ||
| 29 | SYSTEM = 2, | ||
| 30 | BASE = 3, | ||
| 31 | }; | ||
| 32 | |||
| 33 | union ProcessFlags { | ||
| 34 | u16 raw; | ||
| 35 | |||
| 36 | BitField< 0, 1, u16> allow_debug; ///< Allows other processes to attach to and debug this process. | ||
| 37 | BitField< 1, 1, u16> force_debug; ///< Allows this process to attach to processes even if they don't have allow_debug set. | ||
| 38 | BitField< 2, 1, u16> allow_nonalphanum; | ||
| 39 | BitField< 3, 1, u16> shared_page_writable; ///< Shared page is mapped with write permissions. | ||
| 40 | BitField< 4, 1, u16> privileged_priority; ///< Can use priority levels higher than 24. | ||
| 41 | BitField< 5, 1, u16> allow_main_args; | ||
| 42 | BitField< 6, 1, u16> shared_device_mem; | ||
| 43 | BitField< 7, 1, u16> runnable_on_sleep; | ||
| 44 | BitField< 8, 4, MemoryRegion> memory_region; ///< Default region for memory allocations for this process | ||
| 45 | BitField<12, 1, u16> loaded_high; ///< Application loaded high (not at 0x00100000). | ||
| 46 | }; | ||
| 47 | |||
| 48 | class Process final : public Object { | ||
| 49 | public: | ||
| 50 | static SharedPtr<Process> Create(std::string name, u64 program_id); | ||
| 51 | |||
| 52 | std::string GetTypeName() const override { return "Process"; } | ||
| 53 | std::string GetName() const override { return name; } | ||
| 54 | |||
| 55 | static const HandleType HANDLE_TYPE = HandleType::Process; | ||
| 56 | HandleType GetHandleType() const override { return HANDLE_TYPE; } | ||
| 57 | |||
| 58 | /// Name of the process | ||
| 59 | std::string name; | ||
| 60 | /// Title ID corresponding to the process | ||
| 61 | u64 program_id; | ||
| 62 | |||
| 63 | /// The process may only call SVCs which have the corresponding bit set. | ||
| 64 | std::bitset<0x80> svc_access_mask; | ||
| 65 | /// Maximum size of the handle table for the process. | ||
| 66 | unsigned int handle_table_size = 0x200; | ||
| 67 | /// Special memory ranges mapped into this processes address space. This is used to give | ||
| 68 | /// processes access to specific I/O regions and device memory. | ||
| 69 | boost::container::static_vector<AddressMapping, 8> address_mappings; | ||
| 70 | ProcessFlags flags; | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them | ||
| 74 | * to this process. | ||
| 75 | */ | ||
| 76 | void ParseKernelCaps(const u32* kernel_caps, size_t len); | ||
| 77 | |||
| 78 | /** | ||
| 79 | * Applies address space changes and launches the process main thread. | ||
| 80 | */ | ||
| 81 | void Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size); | ||
| 82 | |||
| 83 | private: | ||
| 84 | Process(); | ||
| 85 | ~Process() override; | ||
| 86 | }; | ||
| 87 | |||
| 88 | extern SharedPtr<Process> g_current_process; | ||
| 89 | |||
| 90 | } | ||