diff options
| author | 2015-05-08 16:51:48 -0300 | |
|---|---|---|
| committer | 2015-05-08 22:11:44 -0300 | |
| commit | 2af30d465fa4e9c3421f01b557141673eb0a2115 (patch) | |
| tree | ebbbbee64f504163feddf312a6844a58c5c5052a /src/core/hle/kernel/process.cpp | |
| parent | Common: Add BIT macro (diff) | |
| download | yuzu-2af30d465fa4e9c3421f01b557141673eb0a2115.tar.gz yuzu-2af30d465fa4e9c3421f01b557141673eb0a2115.tar.xz yuzu-2af30d465fa4e9c3421f01b557141673eb0a2115.zip | |
Process: Support parsing of exheader kernel caps
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 73 |
1 files changed, 70 insertions, 3 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 734d6f3ef..3aa4d8784 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -3,24 +3,91 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "common/common_funcs.h" | ||
| 7 | #include "common/logging/log.h" | ||
| 6 | 8 | ||
| 7 | #include "core/hle/kernel/process.h" | 9 | #include "core/hle/kernel/process.h" |
| 8 | #include "core/hle/kernel/thread.h" | 10 | #include "core/hle/kernel/thread.h" |
| 11 | #include "core/mem_map.h" | ||
| 9 | 12 | ||
| 10 | namespace Kernel { | 13 | namespace Kernel { |
| 11 | 14 | ||
| 12 | SharedPtr<Process> Process::Create(std::string name, u64 program_id) { | 15 | SharedPtr<Process> Process::Create(std::string name, u64 program_id) { |
| 13 | SharedPtr<Process> process(new Process); | 16 | SharedPtr<Process> process(new Process); |
| 14 | 17 | ||
| 15 | process->svc_access_mask.set(); | ||
| 16 | process->name = std::move(name); | 18 | process->name = std::move(name); |
| 17 | process->program_id = program_id; | 19 | process->program_id = program_id; |
| 18 | 20 | ||
| 19 | return process; | 21 | return process; |
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | void Process::ParseKernelCaps(const u32 * kernel_caps, size_t len) { | 24 | void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) { |
| 23 | //UNIMPLEMENTED(); | 25 | for (int i = 0; i < len; ++i) { |
| 26 | u32 descriptor = kernel_caps[i]; | ||
| 27 | u32 type = descriptor >> 20; | ||
| 28 | |||
| 29 | if (descriptor == 0xFFFFFFFF) { | ||
| 30 | // Unused descriptor entry | ||
| 31 | continue; | ||
| 32 | } else if ((type & 0xF00) == 0xE00) { // 0x0FFF | ||
| 33 | // Allowed interrupts list | ||
| 34 | LOG_WARNING(Loader, "ExHeader allowed interrupts list ignored"); | ||
| 35 | } else if ((type & 0xF80) == 0xF00) { // 0x07FF | ||
| 36 | // Allowed syscalls mask | ||
| 37 | unsigned int index = ((descriptor >> 24) & 7) * 24; | ||
| 38 | u32 bits = descriptor & 0xFFFFFF; | ||
| 39 | |||
| 40 | while (bits && index < svc_access_mask.size()) { | ||
| 41 | svc_access_mask.set(index, bits & 1); | ||
| 42 | ++index; bits >>= 1; | ||
| 43 | } | ||
| 44 | } else if ((type & 0xFF0) == 0xFE0) { // 0x00FF | ||
| 45 | // Handle table size | ||
| 46 | handle_table_size = descriptor & 0x3FF; | ||
| 47 | } else if ((type & 0xFF8) == 0xFF0) { // 0x007F | ||
| 48 | // Misc. flags | ||
| 49 | bool allow_debug = descriptor & BIT(0); | ||
| 50 | bool force_debug = descriptor & BIT(1); | ||
| 51 | bool allow_nonalphanum = descriptor & BIT(2); | ||
| 52 | shared_page_writable = descriptor & BIT(3); | ||
| 53 | privileged_priority = descriptor & BIT(4); | ||
| 54 | bool allow_main_args = descriptor & BIT(5); | ||
| 55 | bool shared_device_mem = descriptor & BIT(6); | ||
| 56 | bool runnable_on_sleep = descriptor & BIT(7); | ||
| 57 | loaded_high = descriptor & BIT(12); | ||
| 58 | memory_region = MemoryRegion((descriptor >> 8) & 0xF); | ||
| 59 | } else if ((type & 0xFFE) == 0xFF8) { // 0x001F | ||
| 60 | // Mapped memory range | ||
| 61 | if (i+1 >= len || ((kernel_caps[i+1] >> 20) & 0xFFE) != 0xFF8) { | ||
| 62 | LOG_WARNING(Loader, "Incomplete exheader memory range descriptor ignored."); | ||
| 63 | continue; | ||
| 64 | } | ||
| 65 | u32 end_desc = kernel_caps[i+1]; | ||
| 66 | ++i; // Skip over the second descriptor on the next iteration | ||
| 67 | |||
| 68 | StaticAddressMapping mapping; | ||
| 69 | mapping.address = descriptor << 12; | ||
| 70 | mapping.size = (end_desc << 12) - mapping.address; | ||
| 71 | mapping.writable = descriptor & BIT(20); | ||
| 72 | mapping.unk_flag = end_desc & BIT(20); | ||
| 73 | |||
| 74 | static_address_mappings.push_back(mapping); | ||
| 75 | } else if ((type & 0xFFF) == 0xFFE) { // 0x000F | ||
| 76 | // Mapped memory page | ||
| 77 | StaticAddressMapping mapping; | ||
| 78 | mapping.address = descriptor << 12; | ||
| 79 | mapping.size = Memory::PAGE_SIZE; | ||
| 80 | mapping.writable = true; // TODO: Not sure if correct | ||
| 81 | mapping.unk_flag = false; | ||
| 82 | } else if ((type & 0xFE0) == 0xFC0) { // 0x01FF | ||
| 83 | // Kernel version | ||
| 84 | int minor = descriptor & 0xFF; | ||
| 85 | int major = (descriptor >> 8) & 0xFF; | ||
| 86 | LOG_INFO(Loader, "ExHeader kernel version ignored: %d.%d", major, minor); | ||
| 87 | } else { | ||
| 88 | LOG_ERROR(Loader, "Unhandled kernel caps descriptor: 0x%08X", descriptor); | ||
| 89 | } | ||
| 90 | } | ||
| 24 | } | 91 | } |
| 25 | 92 | ||
| 26 | void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) { | 93 | void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) { |