diff options
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 9bf886256..654ee2bf6 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "core/hle/kernel/event.h" | 17 | #include "core/hle/kernel/event.h" |
| 18 | #include "core/hle/kernel/mutex.h" | 18 | #include "core/hle/kernel/mutex.h" |
| 19 | #include "core/hle/kernel/process.h" | 19 | #include "core/hle/kernel/process.h" |
| 20 | #include "core/hle/kernel/resource_limit.h" | ||
| 20 | #include "core/hle/kernel/semaphore.h" | 21 | #include "core/hle/kernel/semaphore.h" |
| 21 | #include "core/hle/kernel/shared_memory.h" | 22 | #include "core/hle/kernel/shared_memory.h" |
| 22 | #include "core/hle/kernel/thread.h" | 23 | #include "core/hle/kernel/thread.h" |
| @@ -301,21 +302,47 @@ static void OutputDebugString(const char* string) { | |||
| 301 | } | 302 | } |
| 302 | 303 | ||
| 303 | /// Get resource limit | 304 | /// Get resource limit |
| 304 | static ResultCode GetResourceLimit(Handle* resource_limit, Handle process) { | 305 | static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle) { |
| 305 | // With regards to proceess values: | 306 | LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); |
| 306 | // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for | 307 | |
| 307 | // the current KThread. | 308 | SharedPtr<Kernel::Process> process = Kernel::g_handle_table.Get<Kernel::Process>(process_handle); |
| 308 | *resource_limit = 0xDEADBEEF; | 309 | if (process == nullptr) |
| 309 | LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called process=0x%08X", process); | 310 | return ERR_INVALID_HANDLE; |
| 311 | |||
| 312 | CASCADE_RESULT(*resource_limit, Kernel::g_handle_table.Create(process->resource_limit)); | ||
| 313 | |||
| 310 | return RESULT_SUCCESS; | 314 | return RESULT_SUCCESS; |
| 311 | } | 315 | } |
| 312 | 316 | ||
| 313 | /// Get resource limit current values | 317 | /// Get resource limit current values |
| 314 | static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names, | 318 | static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit_handle, u32* names, |
| 319 | s32 name_count) { | ||
| 320 | LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", | ||
| 321 | resource_limit_handle, names, name_count); | ||
| 322 | |||
| 323 | SharedPtr<Kernel::ResourceLimit> resource_limit = Kernel::g_handle_table.Get<Kernel::ResourceLimit>(resource_limit_handle); | ||
| 324 | if (resource_limit == nullptr) | ||
| 325 | return ERR_INVALID_HANDLE; | ||
| 326 | |||
| 327 | for (unsigned int i = 0; i < name_count; ++i) | ||
| 328 | values[i] = resource_limit->GetCurrentResourceValue(names[i]); | ||
| 329 | |||
| 330 | return RESULT_SUCCESS; | ||
| 331 | } | ||
| 332 | |||
| 333 | /// Get resource limit max values | ||
| 334 | static ResultCode GetResourceLimitLimitValues(s64* values, Handle resource_limit_handle, u32* names, | ||
| 315 | s32 name_count) { | 335 | s32 name_count) { |
| 316 | LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%p, name_count=%d", | 336 | LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", |
| 317 | resource_limit, names, name_count); | 337 | resource_limit_handle, names, name_count); |
| 318 | values[0] = 0; // Normmatt: Set used memory to 0 for now | 338 | |
| 339 | SharedPtr<Kernel::ResourceLimit> resource_limit = Kernel::g_handle_table.Get<Kernel::ResourceLimit>(resource_limit_handle); | ||
| 340 | if (resource_limit == nullptr) | ||
| 341 | return ERR_INVALID_HANDLE; | ||
| 342 | |||
| 343 | for (unsigned int i = 0; i < name_count; ++i) | ||
| 344 | values[i] = resource_limit->GetMaxResourceValue(names[i]); | ||
| 345 | |||
| 319 | return RESULT_SUCCESS; | 346 | return RESULT_SUCCESS; |
| 320 | } | 347 | } |
| 321 | 348 | ||
| @@ -707,7 +734,7 @@ static const FunctionDef SVC_Table[] = { | |||
| 707 | {0x36, HLE::Wrap<GetProcessIdOfThread>, "GetProcessIdOfThread"}, | 734 | {0x36, HLE::Wrap<GetProcessIdOfThread>, "GetProcessIdOfThread"}, |
| 708 | {0x37, HLE::Wrap<GetThreadId>, "GetThreadId"}, | 735 | {0x37, HLE::Wrap<GetThreadId>, "GetThreadId"}, |
| 709 | {0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"}, | 736 | {0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"}, |
| 710 | {0x39, nullptr, "GetResourceLimitLimitValues"}, | 737 | {0x39, HLE::Wrap<GetResourceLimitLimitValues>, "GetResourceLimitLimitValues"}, |
| 711 | {0x3A, HLE::Wrap<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"}, | 738 | {0x3A, HLE::Wrap<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"}, |
| 712 | {0x3B, nullptr, "GetThreadContext"}, | 739 | {0x3B, nullptr, "GetThreadContext"}, |
| 713 | {0x3C, nullptr, "Break"}, | 740 | {0x3C, nullptr, "Break"}, |