diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/handle_table.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/handle_table.h | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.h | 9 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 29 |
5 files changed, 37 insertions, 11 deletions
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 1bf79b692..c8acde5b1 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp | |||
| @@ -42,9 +42,10 @@ ResultVal<Handle> HandleTable::Create(SharedPtr<Object> obj) { | |||
| 42 | u16 generation = next_generation++; | 42 | u16 generation = next_generation++; |
| 43 | 43 | ||
| 44 | // Overflow count so it fits in the 15 bits dedicated to the generation in the handle. | 44 | // Overflow count so it fits in the 15 bits dedicated to the generation in the handle. |
| 45 | // CTR-OS doesn't use generation 0, so skip straight to 1. | 45 | // Horizon OS uses zero to represent an invalid handle, so skip to 1. |
| 46 | if (next_generation >= (1 << 15)) | 46 | if (next_generation >= (1 << 15)) { |
| 47 | next_generation = 1; | 47 | next_generation = 1; |
| 48 | } | ||
| 48 | 49 | ||
| 49 | generations[slot] = generation; | 50 | generations[slot] = generation; |
| 50 | objects[slot] = std::move(obj); | 51 | objects[slot] = std::move(obj); |
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index e3f3e3fb8..6b7927fd8 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| 14 | 14 | ||
| 15 | enum KernelHandle : Handle { | 15 | enum KernelHandle : Handle { |
| 16 | InvalidHandle = 0, | ||
| 16 | CurrentThread = 0xFFFF8000, | 17 | CurrentThread = 0xFFFF8000, |
| 17 | CurrentProcess = 0xFFFF8001, | 18 | CurrentProcess = 0xFFFF8001, |
| 18 | }; | 19 | }; |
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 7ca538401..4ecb8c926 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -44,6 +44,10 @@ SharedPtr<Process> Process::Create(KernelCore& kernel, std::string&& name) { | |||
| 44 | return process; | 44 | return process; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | SharedPtr<ResourceLimit> Process::GetResourceLimit() const { | ||
| 48 | return resource_limit; | ||
| 49 | } | ||
| 50 | |||
| 47 | void Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata) { | 51 | void Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata) { |
| 48 | program_id = metadata.GetTitleID(); | 52 | program_id = metadata.GetTitleID(); |
| 49 | is_64bit_process = metadata.Is64BitProgram(); | 53 | is_64bit_process = metadata.Is64BitProgram(); |
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index ada845c7f..49345aa66 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -171,14 +171,7 @@ public: | |||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | /// Gets the resource limit descriptor for this process | 173 | /// Gets the resource limit descriptor for this process |
| 174 | ResourceLimit& GetResourceLimit() { | 174 | SharedPtr<ResourceLimit> GetResourceLimit() const; |
| 175 | return *resource_limit; | ||
| 176 | } | ||
| 177 | |||
| 178 | /// Gets the resource limit descriptor for this process | ||
| 179 | const ResourceLimit& GetResourceLimit() const { | ||
| 180 | return *resource_limit; | ||
| 181 | } | ||
| 182 | 175 | ||
| 183 | /// Gets the default CPU ID for this process | 176 | /// Gets the default CPU ID for this process |
| 184 | u8 GetDefaultProcessorID() const { | 177 | u8 GetDefaultProcessorID() const { |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 948989b31..b022a7bc5 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -663,7 +663,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 663 | TotalMemoryUsage = 6, | 663 | TotalMemoryUsage = 6, |
| 664 | TotalHeapUsage = 7, | 664 | TotalHeapUsage = 7, |
| 665 | IsCurrentProcessBeingDebugged = 8, | 665 | IsCurrentProcessBeingDebugged = 8, |
| 666 | ResourceHandleLimit = 9, | 666 | RegisterResourceLimit = 9, |
| 667 | IdleTickCount = 10, | 667 | IdleTickCount = 10, |
| 668 | RandomEntropy = 11, | 668 | RandomEntropy = 11, |
| 669 | PerformanceCounter = 0xF0000002, | 669 | PerformanceCounter = 0xF0000002, |
| @@ -787,6 +787,33 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 787 | *result = 0; | 787 | *result = 0; |
| 788 | return RESULT_SUCCESS; | 788 | return RESULT_SUCCESS; |
| 789 | 789 | ||
| 790 | case GetInfoType::RegisterResourceLimit: { | ||
| 791 | if (handle != 0) { | ||
| 792 | return ERR_INVALID_HANDLE; | ||
| 793 | } | ||
| 794 | |||
| 795 | if (info_sub_id != 0) { | ||
| 796 | return ERR_INVALID_COMBINATION; | ||
| 797 | } | ||
| 798 | |||
| 799 | Process* const current_process = Core::CurrentProcess(); | ||
| 800 | HandleTable& handle_table = current_process->GetHandleTable(); | ||
| 801 | const auto resource_limit = current_process->GetResourceLimit(); | ||
| 802 | if (!resource_limit) { | ||
| 803 | *result = KernelHandle::InvalidHandle; | ||
| 804 | // Yes, the kernel considers this a successful operation. | ||
| 805 | return RESULT_SUCCESS; | ||
| 806 | } | ||
| 807 | |||
| 808 | const auto table_result = handle_table.Create(resource_limit); | ||
| 809 | if (table_result.Failed()) { | ||
| 810 | return table_result.Code(); | ||
| 811 | } | ||
| 812 | |||
| 813 | *result = *table_result; | ||
| 814 | return RESULT_SUCCESS; | ||
| 815 | } | ||
| 816 | |||
| 790 | case GetInfoType::RandomEntropy: | 817 | case GetInfoType::RandomEntropy: |
| 791 | if (handle != 0) { | 818 | if (handle != 0) { |
| 792 | LOG_ERROR(Kernel_SVC, "Process Handle is non zero, expected 0 result but got {:016X}", | 819 | LOG_ERROR(Kernel_SVC, "Process Handle is non zero, expected 0 result but got {:016X}", |