2014-04-11 05:28:28 +05:30
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 11:08:14 +05:30
|
|
|
// Licensed under GPLv2 or any later version
|
2014-11-19 14:19:13 +05:30
|
|
|
// Refer to the license.txt file included.
|
2014-04-11 05:28:28 +05:30
|
|
|
|
2014-04-12 04:14:21 +05:30
|
|
|
#include <map>
|
2014-05-19 03:22:02 +05:30
|
|
|
|
2014-08-17 23:58:36 +05:30
|
|
|
#include "common/string_util.h"
|
2014-05-19 03:22:02 +05:30
|
|
|
#include "common/symbols.h"
|
2014-04-12 04:14:21 +05:30
|
|
|
|
2014-12-22 12:00:09 +05:30
|
|
|
#include "core/arm/arm_interface.h"
|
2014-04-18 08:35:31 +05:30
|
|
|
#include "core/mem_map.h"
|
|
|
|
|
2014-07-07 08:45:40 +05:30
|
|
|
#include "core/hle/kernel/address_arbiter.h"
|
2014-05-28 08:11:09 +05:30
|
|
|
#include "core/hle/kernel/event.h"
|
2014-05-21 08:27:54 +05:30
|
|
|
#include "core/hle/kernel/mutex.h"
|
2014-12-04 05:19:51 +05:30
|
|
|
#include "core/hle/kernel/semaphore.h"
|
2014-07-05 10:29:58 +05:30
|
|
|
#include "core/hle/kernel/shared_memory.h"
|
2014-05-17 23:17:44 +05:30
|
|
|
#include "core/hle/kernel/thread.h"
|
2014-12-05 01:15:47 +05:30
|
|
|
#include "core/hle/kernel/timer.h"
|
2014-05-17 23:17:44 +05:30
|
|
|
|
2014-04-11 05:28:28 +05:30
|
|
|
#include "core/hle/function_wrappers.h"
|
2014-10-23 08:50:01 +05:30
|
|
|
#include "core/hle/result.h"
|
2014-04-13 07:25:36 +05:30
|
|
|
#include "core/hle/service/service.h"
|
2014-04-11 05:28:28 +05:30
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2014-05-21 03:58:38 +05:30
|
|
|
// Namespace SVC
|
2014-04-11 05:28:28 +05:30
|
|
|
|
2014-12-29 18:25:30 +05:30
|
|
|
using Kernel::SharedPtr;
|
2015-01-23 11:14:52 +05:30
|
|
|
using Kernel::ERR_INVALID_HANDLE;
|
2014-12-29 18:25:30 +05:30
|
|
|
|
2014-05-21 03:58:38 +05:30
|
|
|
namespace SVC {
|
2014-04-11 08:56:12 +05:30
|
|
|
|
2015-01-30 23:37:04 +05:30
|
|
|
const ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel,
|
|
|
|
ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
|
|
|
|
const ResultCode ERR_PORT_NAME_TOO_LONG(ErrorDescription(30), ErrorModule::OS,
|
|
|
|
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E0181E
|
|
|
|
|
2015-01-22 04:57:01 +05:30
|
|
|
/// An invalid result code that is meant to be overwritten when a thread resumes from waiting
|
|
|
|
const ResultCode RESULT_INVALID(0xDEADC0DE);
|
|
|
|
|
2014-04-25 09:26:06 +05:30
|
|
|
enum ControlMemoryOperation {
|
|
|
|
MEMORY_OPERATION_HEAP = 0x00000003,
|
|
|
|
MEMORY_OPERATION_GSP_HEAP = 0x00010003,
|
|
|
|
};
|
|
|
|
|
2014-04-18 08:35:31 +05:30
|
|
|
/// Map application or GSP heap memory
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_TRACE(Kernel_SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X",
|
2014-05-07 09:04:20 +05:30
|
|
|
operation, addr0, addr1, size, permissions);
|
|
|
|
|
2014-04-18 08:35:31 +05:30
|
|
|
switch (operation) {
|
|
|
|
|
2014-04-25 09:26:06 +05:30
|
|
|
// Map normal heap memory
|
|
|
|
case MEMORY_OPERATION_HEAP:
|
2014-06-02 06:18:29 +05:30
|
|
|
*out_addr = Memory::MapBlock_Heap(size, operation, permissions);
|
2014-04-25 09:26:06 +05:30
|
|
|
break;
|
|
|
|
|
|
|
|
// Map GSP heap memory
|
|
|
|
case MEMORY_OPERATION_GSP_HEAP:
|
2014-11-23 09:05:45 +05:30
|
|
|
*out_addr = Memory::MapBlock_HeapLinear(size, operation, permissions);
|
2014-04-18 08:35:31 +05:30
|
|
|
break;
|
|
|
|
|
|
|
|
// Unknown ControlMemory operation
|
|
|
|
default:
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_ERROR(Kernel_SVC, "unknown operation=0x%08X", operation);
|
2014-04-18 08:35:31 +05:30
|
|
|
}
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-04-25 09:26:06 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Maps a memory block to specified address
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) {
|
2015-01-11 11:13:29 +05:30
|
|
|
using Kernel::SharedMemory;
|
|
|
|
using Kernel::MemoryPermission;
|
|
|
|
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d",
|
2014-07-05 10:29:58 +05:30
|
|
|
handle, addr, permissions, other_permissions);
|
2014-07-05 19:52:03 +05:30
|
|
|
|
2015-01-11 11:13:29 +05:30
|
|
|
SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle);
|
|
|
|
if (shared_memory == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2015-01-11 11:13:29 +05:30
|
|
|
|
|
|
|
MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions);
|
2014-07-05 19:52:03 +05:30
|
|
|
switch (permissions_type) {
|
2015-01-11 11:13:29 +05:30
|
|
|
case MemoryPermission::Read:
|
|
|
|
case MemoryPermission::Write:
|
|
|
|
case MemoryPermission::ReadWrite:
|
|
|
|
case MemoryPermission::Execute:
|
|
|
|
case MemoryPermission::ReadExecute:
|
|
|
|
case MemoryPermission::WriteExecute:
|
|
|
|
case MemoryPermission::ReadWriteExecute:
|
|
|
|
case MemoryPermission::DontCare:
|
|
|
|
shared_memory->Map(addr, permissions_type,
|
|
|
|
static_cast<MemoryPermission>(other_permissions));
|
2014-04-25 09:26:06 +05:30
|
|
|
break;
|
|
|
|
default:
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions);
|
2014-04-25 09:26:06 +05:30
|
|
|
}
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-04-18 08:35:31 +05:30
|
|
|
}
|
|
|
|
|
2014-04-13 07:25:36 +05:30
|
|
|
/// Connect to an OS service given the port name, returns the handle to the port to out
|
2015-01-30 23:37:04 +05:30
|
|
|
static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) {
|
|
|
|
if (port_name == nullptr)
|
|
|
|
return ERR_NOT_FOUND;
|
|
|
|
if (std::strlen(port_name) > 11)
|
|
|
|
return ERR_PORT_NAME_TOO_LONG;
|
2014-06-02 06:18:29 +05:30
|
|
|
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name);
|
2014-06-02 06:18:29 +05:30
|
|
|
|
2015-01-30 23:37:04 +05:30
|
|
|
auto it = Service::g_kernel_named_ports.find(port_name);
|
|
|
|
if (it == Service::g_kernel_named_ports.end()) {
|
|
|
|
LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name);
|
|
|
|
return ERR_NOT_FOUND;
|
|
|
|
}
|
2014-06-02 06:18:29 +05:30
|
|
|
|
2015-01-30 23:37:04 +05:30
|
|
|
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(it->second));
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-04-13 07:25:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Synchronize to an OS service
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode SendSyncRequest(Handle handle) {
|
2014-12-29 18:25:30 +05:30
|
|
|
SharedPtr<Kernel::Session> session = Kernel::g_handle_table.Get<Kernel::Session>(handle);
|
2014-12-14 11:00:11 +05:30
|
|
|
if (session == nullptr) {
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2014-10-23 08:50:01 +05:30
|
|
|
}
|
2014-05-27 07:42:46 +05:30
|
|
|
|
2014-12-14 11:00:11 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str());
|
2014-05-27 07:42:46 +05:30
|
|
|
|
2015-01-23 11:06:58 +05:30
|
|
|
return session->SyncRequest().Code();
|
2014-04-11 05:28:28 +05:30
|
|
|
}
|
|
|
|
|
2014-04-17 06:11:33 +05:30
|
|
|
/// Close a handle
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode CloseHandle(Handle handle) {
|
2014-04-17 06:11:33 +05:30
|
|
|
// ImplementMe
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called handle=0x%08X", handle);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-04-17 06:11:33 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Wait for a handle to synchronize, timeout after the specified nanoseconds
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
|
2015-01-19 01:03:11 +05:30
|
|
|
auto object = Kernel::g_handle_table.GetWaitObject(handle);
|
2014-12-21 17:34:08 +05:30
|
|
|
if (object == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2014-05-28 08:11:09 +05:30
|
|
|
|
2014-12-29 18:25:30 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle,
|
|
|
|
object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds);
|
2014-06-06 08:05:36 +05:30
|
|
|
|
|
|
|
// Check for next thread to schedule
|
2015-01-21 04:46:45 +05:30
|
|
|
if (object->ShouldWait()) {
|
2015-01-18 23:55:51 +05:30
|
|
|
|
|
|
|
object->AddWaitingThread(Kernel::GetCurrentThread());
|
2015-01-21 07:23:52 +05:30
|
|
|
Kernel::WaitCurrentThread_WaitSynchronization(object, false, false);
|
2015-01-18 23:55:51 +05:30
|
|
|
|
2015-01-10 22:04:50 +05:30
|
|
|
// Create an event to wake the thread up after the specified nanosecond delay has passed
|
2015-01-31 06:37:54 +05:30
|
|
|
Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds);
|
2015-01-17 12:33:44 +05:30
|
|
|
|
2014-06-02 07:12:50 +05:30
|
|
|
HLE::Reschedule(__func__);
|
2015-01-22 04:57:01 +05:30
|
|
|
|
|
|
|
// NOTE: output of this SVC will be set later depending on how the thread resumes
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_INVALID;
|
2014-05-28 08:11:09 +05:30
|
|
|
}
|
|
|
|
|
2015-01-22 04:57:01 +05:30
|
|
|
object->Acquire();
|
|
|
|
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-18 09:07:25 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all, s64 nano_seconds) {
|
2015-01-18 11:57:46 +05:30
|
|
|
bool wait_thread = !wait_all;
|
2015-01-17 12:33:44 +05:30
|
|
|
int handle_index = 0;
|
2014-05-23 05:02:45 +05:30
|
|
|
|
2015-01-18 12:46:54 +05:30
|
|
|
// Check if 'handles' is invalid
|
2015-01-18 00:34:54 +05:30
|
|
|
if (handles == nullptr)
|
2015-01-23 11:06:58 +05:30
|
|
|
return ResultCode(ErrorDescription::InvalidPointer, ErrorModule::Kernel, ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
2015-01-18 00:34:54 +05:30
|
|
|
|
2015-01-18 12:46:54 +05:30
|
|
|
// NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If
|
|
|
|
// this happens, the running application will crash.
|
|
|
|
_assert_msg_(Kernel, out != nullptr, "invalid output pointer specified!");
|
|
|
|
|
|
|
|
// Check if 'handle_count' is invalid
|
2015-01-17 23:05:55 +05:30
|
|
|
if (handle_count < 0)
|
2015-01-23 11:06:58 +05:30
|
|
|
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
2015-01-17 23:05:55 +05:30
|
|
|
|
2015-01-18 12:46:54 +05:30
|
|
|
// If 'handle_count' is non-zero, iterate through each handle and wait the current thread if
|
|
|
|
// necessary
|
2015-01-17 23:05:55 +05:30
|
|
|
if (handle_count != 0) {
|
2015-01-18 11:57:46 +05:30
|
|
|
bool selected = false; // True once an object has been selected
|
|
|
|
for (int i = 0; i < handle_count; ++i) {
|
2015-01-19 01:03:11 +05:30
|
|
|
auto object = Kernel::g_handle_table.GetWaitObject(handles[i]);
|
2015-01-17 22:47:36 +05:30
|
|
|
if (object == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2014-05-28 08:11:09 +05:30
|
|
|
|
2015-01-18 12:46:54 +05:30
|
|
|
// Check if the current thread should wait on this object...
|
2015-01-21 04:46:45 +05:30
|
|
|
if (object->ShouldWait()) {
|
2015-01-18 23:55:51 +05:30
|
|
|
|
2015-01-18 11:57:46 +05:30
|
|
|
// Check we are waiting on all objects...
|
|
|
|
if (wait_all)
|
|
|
|
// Wait the thread
|
|
|
|
wait_thread = true;
|
|
|
|
} else {
|
|
|
|
// Do not wait on this object, check if this object should be selected...
|
|
|
|
if (!wait_all && !selected) {
|
|
|
|
// Do not wait the thread
|
|
|
|
wait_thread = false;
|
|
|
|
handle_index = i;
|
|
|
|
selected = true;
|
|
|
|
}
|
|
|
|
}
|
2015-01-17 22:47:36 +05:30
|
|
|
}
|
2015-01-17 23:05:55 +05:30
|
|
|
} else {
|
2015-01-18 12:46:54 +05:30
|
|
|
// If no handles were passed in, put the thread to sleep only when 'wait_all' is false
|
|
|
|
// NOTE: This should deadlock the current thread if no timeout was specified
|
2015-01-17 22:47:36 +05:30
|
|
|
if (!wait_all) {
|
|
|
|
wait_thread = true;
|
2015-01-21 07:23:52 +05:30
|
|
|
Kernel::WaitCurrentThread_WaitSynchronization(nullptr, true, wait_all);
|
2015-01-17 22:47:36 +05:30
|
|
|
}
|
2014-05-28 08:11:09 +05:30
|
|
|
}
|
|
|
|
|
2015-01-18 12:46:54 +05:30
|
|
|
// If thread should wait, then set its state to waiting and then reschedule...
|
2015-01-18 11:57:46 +05:30
|
|
|
if (wait_thread) {
|
2015-01-18 23:55:51 +05:30
|
|
|
|
|
|
|
// Actually wait the current thread on each object if we decided to wait...
|
|
|
|
for (int i = 0; i < handle_count; ++i) {
|
|
|
|
auto object = Kernel::g_handle_table.GetWaitObject(handles[i]);
|
|
|
|
object->AddWaitingThread(Kernel::GetCurrentThread());
|
2015-01-21 07:23:52 +05:30
|
|
|
Kernel::WaitCurrentThread_WaitSynchronization(object, true, wait_all);
|
2015-01-18 23:55:51 +05:30
|
|
|
}
|
|
|
|
|
2015-01-17 12:33:44 +05:30
|
|
|
// Create an event to wake the thread up after the specified nanosecond delay has passed
|
2015-01-31 06:37:54 +05:30
|
|
|
Kernel::GetCurrentThread()->WakeAfterDelay(nano_seconds);
|
2015-01-17 12:33:44 +05:30
|
|
|
|
|
|
|
HLE::Reschedule(__func__);
|
|
|
|
|
|
|
|
// NOTE: output of this SVC will be set later depending on how the thread resumes
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_INVALID;
|
2014-05-19 03:22:02 +05:30
|
|
|
}
|
2014-05-28 08:11:09 +05:30
|
|
|
|
2015-01-17 12:33:44 +05:30
|
|
|
// Acquire objects if we did not wait...
|
|
|
|
for (int i = 0; i < handle_count; ++i) {
|
|
|
|
auto object = Kernel::g_handle_table.GetWaitObject(handles[i]);
|
|
|
|
|
|
|
|
// Acquire the object if it is not waiting...
|
|
|
|
if (!object->ShouldWait()) {
|
|
|
|
object->Acquire();
|
|
|
|
|
|
|
|
// If this was the first non-waiting object and 'wait_all' is false, don't acquire
|
|
|
|
// any other objects
|
|
|
|
if (!wait_all)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(bunnei): If 'wait_all' is true, this is probably wrong. However, real hardware does
|
|
|
|
// not seem to set it to any meaningful value.
|
|
|
|
*out = wait_all ? 0 : handle_index;
|
2014-05-28 08:11:09 +05:30
|
|
|
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-04-17 06:11:33 +05:30
|
|
|
}
|
|
|
|
|
2014-05-02 04:20:36 +05:30
|
|
|
/// Create an address arbiter (to allocate access to shared resources)
|
2015-01-23 11:30:39 +05:30
|
|
|
static ResultCode CreateAddressArbiter(Handle* out_handle) {
|
2015-01-11 22:16:49 +05:30
|
|
|
using Kernel::AddressArbiter;
|
|
|
|
|
2015-01-23 11:30:39 +05:30
|
|
|
CASCADE_RESULT(SharedPtr<AddressArbiter> arbiter, AddressArbiter::Create());
|
|
|
|
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(arbiter)));
|
|
|
|
LOG_TRACE(Kernel_SVC, "returned handle=0x%08X", *out_handle);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-02 04:20:36 +05:30
|
|
|
}
|
|
|
|
|
2014-05-30 05:54:51 +05:30
|
|
|
/// Arbitrate address
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, s64 nanoseconds) {
|
2015-01-11 22:16:49 +05:30
|
|
|
using Kernel::AddressArbiter;
|
|
|
|
|
|
|
|
LOG_TRACE(Kernel_SVC, "called handle=0x%08X, address=0x%08X, type=0x%08X, value=0x%08X", handle,
|
2014-11-26 11:05:20 +05:30
|
|
|
address, type, value);
|
2015-01-11 22:16:49 +05:30
|
|
|
|
|
|
|
SharedPtr<AddressArbiter> arbiter = Kernel::g_handle_table.Get<AddressArbiter>(handle);
|
|
|
|
if (arbiter == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2015-01-11 22:16:49 +05:30
|
|
|
|
|
|
|
return arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type),
|
2015-01-23 11:06:58 +05:30
|
|
|
address, value, nanoseconds);
|
2014-05-30 05:54:51 +05:30
|
|
|
}
|
|
|
|
|
2014-05-02 04:20:36 +05:30
|
|
|
/// Used to output a message on a debug hardware unit - does nothing on a retail unit
|
2014-11-17 09:28:39 +05:30
|
|
|
static void OutputDebugString(const char* string) {
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_DEBUG(Debug_Emulated, "%s", string);
|
2014-05-07 09:04:20 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Get resource limit
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode GetResourceLimit(Handle* resource_limit, Handle process) {
|
2014-05-07 09:04:20 +05:30
|
|
|
// With regards to proceess values:
|
2014-11-19 14:19:13 +05:30
|
|
|
// 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for
|
2014-05-07 09:04:20 +05:30
|
|
|
// the current KThread.
|
2014-06-02 06:18:29 +05:30
|
|
|
*resource_limit = 0xDEADBEEF;
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called process=0x%08X", process);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-07 09:04:20 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Get resource limit current values
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names,
|
2014-05-30 08:56:58 +05:30
|
|
|
s32 name_count) {
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%s, name_count=%d",
|
2014-05-07 09:04:20 +05:30
|
|
|
resource_limit, names, name_count);
|
|
|
|
Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-02 04:20:36 +05:30
|
|
|
}
|
|
|
|
|
2014-05-21 08:27:54 +05:30
|
|
|
/// Creates a new thread
|
2015-01-23 11:30:39 +05:30
|
|
|
static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 processor_id) {
|
2014-12-29 18:25:30 +05:30
|
|
|
using Kernel::Thread;
|
|
|
|
|
2014-05-17 23:17:44 +05:30
|
|
|
std::string name;
|
2014-05-16 03:55:56 +05:30
|
|
|
if (Symbols::HasSymbol(entry_point)) {
|
|
|
|
TSymbol symbol = Symbols::GetSymbol(entry_point);
|
2014-05-17 23:17:44 +05:30
|
|
|
name = symbol.name;
|
2014-05-16 03:55:56 +05:30
|
|
|
} else {
|
2014-09-08 00:20:43 +05:30
|
|
|
name = Common::StringFromFormat("unknown-%08x", entry_point);
|
2014-05-14 07:28:26 +05:30
|
|
|
}
|
2014-05-17 23:17:44 +05:30
|
|
|
|
2015-01-23 11:30:39 +05:30
|
|
|
CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create(
|
|
|
|
name, entry_point, priority, arg, processor_id, stack_top, Kernel::DEFAULT_STACK_SIZE));
|
|
|
|
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(thread)));
|
2014-05-22 07:11:40 +05:30
|
|
|
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, "
|
2014-11-19 14:19:13 +05:30
|
|
|
"threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point,
|
2015-01-23 11:30:39 +05:30
|
|
|
name.c_str(), arg, stack_top, priority, processor_id, *out_handle);
|
2014-11-19 14:19:13 +05:30
|
|
|
|
2015-01-07 11:37:29 +05:30
|
|
|
if (THREADPROCESSORID_1 == processor_id) {
|
|
|
|
LOG_WARNING(Kernel_SVC,
|
|
|
|
"thread designated for system CPU core (UNIMPLEMENTED) will be run with app core scheduling");
|
|
|
|
}
|
|
|
|
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-14 07:28:26 +05:30
|
|
|
}
|
|
|
|
|
2014-06-06 08:05:36 +05:30
|
|
|
/// Called when a thread exits
|
2014-12-22 18:37:22 +05:30
|
|
|
static void ExitThread() {
|
|
|
|
LOG_TRACE(Kernel_SVC, "called, pc=0x%08X", Core::g_app_core->GetPC());
|
2014-06-06 08:05:36 +05:30
|
|
|
|
2014-12-22 18:37:22 +05:30
|
|
|
Kernel::GetCurrentThread()->Stop(__func__);
|
2014-06-06 08:05:36 +05:30
|
|
|
HLE::Reschedule(__func__);
|
|
|
|
}
|
|
|
|
|
2014-06-02 07:42:54 +05:30
|
|
|
/// Gets the priority for the specified thread
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode GetThreadPriority(s32* priority, Handle handle) {
|
2014-12-29 18:25:30 +05:30
|
|
|
const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
|
2014-12-22 18:37:22 +05:30
|
|
|
if (thread == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2014-12-22 18:37:22 +05:30
|
|
|
|
|
|
|
*priority = thread->GetPriority();
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-06-02 07:42:54 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Sets the priority for the specified thread
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode SetThreadPriority(Handle handle, s32 priority) {
|
2014-12-29 18:25:30 +05:30
|
|
|
SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
|
2014-12-22 18:37:22 +05:30
|
|
|
if (thread == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2014-12-22 18:37:22 +05:30
|
|
|
|
|
|
|
thread->SetPriority(priority);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-06-02 07:42:54 +05:30
|
|
|
}
|
|
|
|
|
2014-05-21 08:27:54 +05:30
|
|
|
/// Create a mutex
|
2015-01-23 11:30:39 +05:30
|
|
|
static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) {
|
2015-01-23 06:42:19 +05:30
|
|
|
using Kernel::Mutex;
|
|
|
|
|
2015-01-23 11:30:39 +05:30
|
|
|
CASCADE_RESULT(SharedPtr<Mutex> mutex, Mutex::Create(initial_locked != 0));
|
|
|
|
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(mutex)));
|
2015-01-23 06:42:19 +05:30
|
|
|
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X",
|
2015-01-23 11:30:39 +05:30
|
|
|
initial_locked ? "true" : "false", *out_handle);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-14 07:28:26 +05:30
|
|
|
}
|
|
|
|
|
2014-05-21 08:27:54 +05:30
|
|
|
/// Release a mutex
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode ReleaseMutex(Handle handle) {
|
2015-01-23 06:42:19 +05:30
|
|
|
using Kernel::Mutex;
|
|
|
|
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle);
|
2015-01-23 06:42:19 +05:30
|
|
|
|
|
|
|
SharedPtr<Mutex> mutex = Kernel::g_handle_table.Get<Mutex>(handle);
|
|
|
|
if (mutex == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2015-01-23 06:42:19 +05:30
|
|
|
|
|
|
|
mutex->Release();
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-14 07:28:26 +05:30
|
|
|
}
|
|
|
|
|
2014-12-04 09:52:06 +05:30
|
|
|
/// Get the ID for the specified thread.
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode GetThreadId(u32* thread_id, Handle handle) {
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle);
|
2014-12-22 18:37:22 +05:30
|
|
|
|
2014-12-29 18:25:30 +05:30
|
|
|
const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
|
2014-12-22 18:37:22 +05:30
|
|
|
if (thread == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2014-12-22 18:37:22 +05:30
|
|
|
|
|
|
|
*thread_id = thread->GetThreadId();
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-16 05:47:30 +05:30
|
|
|
}
|
|
|
|
|
2014-12-04 05:19:51 +05:30
|
|
|
/// Creates a semaphore
|
2015-01-23 11:30:39 +05:30
|
|
|
static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_count) {
|
2015-01-11 21:23:11 +05:30
|
|
|
using Kernel::Semaphore;
|
|
|
|
|
2015-01-23 11:30:39 +05:30
|
|
|
CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count));
|
|
|
|
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(semaphore)));
|
2015-01-11 21:23:11 +05:30
|
|
|
|
2014-12-14 00:13:01 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X",
|
2015-01-23 11:30:39 +05:30
|
|
|
initial_count, max_count, *out_handle);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-12-04 22:10:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Releases a certain number of slots in a semaphore
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) {
|
2015-01-11 21:23:11 +05:30
|
|
|
using Kernel::Semaphore;
|
|
|
|
|
|
|
|
LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle);
|
|
|
|
|
|
|
|
SharedPtr<Semaphore> semaphore = Kernel::g_handle_table.Get<Semaphore>(handle);
|
|
|
|
if (semaphore == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2015-01-11 21:23:11 +05:30
|
|
|
|
2015-01-23 11:30:39 +05:30
|
|
|
CASCADE_RESULT(*count, semaphore->Release(release_count));
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-12-04 05:19:51 +05:30
|
|
|
}
|
|
|
|
|
2014-05-21 08:27:54 +05:30
|
|
|
/// Query memory
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode QueryMemory(void* info, void* out, u32 addr) {
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called addr=0x%08X", addr);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-16 05:47:30 +05:30
|
|
|
}
|
|
|
|
|
2014-05-21 08:27:54 +05:30
|
|
|
/// Create an event
|
2015-01-23 11:30:39 +05:30
|
|
|
static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
|
|
|
|
CASCADE_RESULT(auto evt, Kernel::Event::Create(static_cast<ResetType>(reset_type)));
|
|
|
|
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(evt)));
|
|
|
|
|
|
|
|
LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X",
|
|
|
|
reset_type, *out_handle);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-19 03:22:02 +05:30
|
|
|
}
|
|
|
|
|
2014-05-27 06:25:48 +05:30
|
|
|
/// Duplicates a kernel handle
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode DuplicateHandle(Handle* out, Handle handle) {
|
2014-12-21 17:34:08 +05:30
|
|
|
ResultVal<Handle> out_h = Kernel::g_handle_table.Duplicate(handle);
|
|
|
|
if (out_h.Succeeded()) {
|
|
|
|
*out = *out_h;
|
|
|
|
LOG_TRACE(Kernel_SVC, "duplicated 0x%08X to 0x%08X", handle, *out);
|
2014-06-02 07:42:54 +05:30
|
|
|
}
|
2015-01-23 11:06:58 +05:30
|
|
|
return out_h.Code();
|
2014-05-27 06:25:48 +05:30
|
|
|
}
|
|
|
|
|
2014-06-06 08:05:36 +05:30
|
|
|
/// Signals an event
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode SignalEvent(Handle handle) {
|
2015-01-23 10:41:25 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle);
|
|
|
|
|
|
|
|
auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle);
|
|
|
|
if (evt == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2015-01-23 10:41:25 +05:30
|
|
|
|
|
|
|
evt->Signal();
|
2015-01-19 04:31:58 +05:30
|
|
|
HLE::Reschedule(__func__);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-06-06 08:05:36 +05:30
|
|
|
}
|
|
|
|
|
2014-05-30 05:54:51 +05:30
|
|
|
/// Clears an event
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode ClearEvent(Handle handle) {
|
2015-01-23 10:41:25 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle);
|
|
|
|
|
|
|
|
auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle);
|
|
|
|
if (evt == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2015-01-23 10:41:25 +05:30
|
|
|
|
|
|
|
evt->Clear();
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-05-30 05:54:51 +05:30
|
|
|
}
|
|
|
|
|
2014-12-05 01:15:47 +05:30
|
|
|
/// Creates a timer
|
2015-01-23 11:30:39 +05:30
|
|
|
static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
|
2015-01-23 09:49:33 +05:30
|
|
|
using Kernel::Timer;
|
|
|
|
|
2015-01-23 11:30:39 +05:30
|
|
|
CASCADE_RESULT(auto timer, Timer::Create(static_cast<ResetType>(reset_type)));
|
|
|
|
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(timer)));
|
2015-01-23 09:49:33 +05:30
|
|
|
|
2015-01-23 11:30:39 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X",
|
|
|
|
reset_type, *out_handle);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-12-05 01:15:47 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Clears a timer
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode ClearTimer(Handle handle) {
|
2015-01-23 09:49:33 +05:30
|
|
|
using Kernel::Timer;
|
|
|
|
|
2014-12-05 01:15:47 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
|
2015-01-23 09:49:33 +05:30
|
|
|
|
|
|
|
SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
|
|
|
|
if (timer == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2015-01-23 09:49:33 +05:30
|
|
|
|
|
|
|
timer->Clear();
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-12-05 01:15:47 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Starts a timer
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) {
|
2015-01-23 09:49:33 +05:30
|
|
|
using Kernel::Timer;
|
|
|
|
|
2014-12-05 01:15:47 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
|
2015-01-23 09:49:33 +05:30
|
|
|
|
|
|
|
SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
|
|
|
|
if (timer == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2015-01-23 09:49:33 +05:30
|
|
|
|
|
|
|
timer->Set(initial, interval);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-12-05 01:15:47 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/// Cancels a timer
|
2015-01-23 11:06:58 +05:30
|
|
|
static ResultCode CancelTimer(Handle handle) {
|
2015-01-23 09:49:33 +05:30
|
|
|
using Kernel::Timer;
|
|
|
|
|
2014-12-05 01:15:47 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
|
2015-01-23 09:49:33 +05:30
|
|
|
|
|
|
|
SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
|
|
|
|
if (timer == nullptr)
|
2015-01-23 11:14:52 +05:30
|
|
|
return ERR_INVALID_HANDLE;
|
2015-01-23 09:49:33 +05:30
|
|
|
|
|
|
|
timer->Cancel();
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-12-05 01:15:47 +05:30
|
|
|
}
|
|
|
|
|
2014-06-01 20:07:19 +05:30
|
|
|
/// Sleep the current thread
|
2014-11-17 09:28:39 +05:30
|
|
|
static void SleepThread(s64 nanoseconds) {
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_TRACE(Kernel_SVC, "called nanoseconds=%lld", nanoseconds);
|
2014-11-26 11:04:14 +05:30
|
|
|
|
2014-12-20 13:02:19 +05:30
|
|
|
// Sleep current thread and check for next thread to schedule
|
2015-01-19 00:26:40 +05:30
|
|
|
Kernel::WaitCurrentThread_Sleep();
|
2015-01-08 03:10:08 +05:30
|
|
|
|
|
|
|
// Create an event to wake the thread up after the specified nanosecond delay has passed
|
2015-01-31 06:37:54 +05:30
|
|
|
Kernel::GetCurrentThread()->WakeAfterDelay(nanoseconds);
|
2015-01-08 03:10:08 +05:30
|
|
|
|
2014-11-26 11:04:14 +05:30
|
|
|
HLE::Reschedule(__func__);
|
2014-06-01 20:07:19 +05:30
|
|
|
}
|
|
|
|
|
2014-08-15 05:31:02 +05:30
|
|
|
/// This returns the total CPU ticks elapsed since the CPU was powered-on
|
2014-11-17 09:28:39 +05:30
|
|
|
static s64 GetSystemTick() {
|
2014-08-15 05:31:02 +05:30
|
|
|
return (s64)Core::g_app_core->GetTicks();
|
|
|
|
}
|
|
|
|
|
2014-12-09 10:22:27 +05:30
|
|
|
/// Creates a memory block at the specified address with the specified permissions and size
|
2015-01-23 11:30:39 +05:30
|
|
|
static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission,
|
2015-01-11 11:13:29 +05:30
|
|
|
u32 other_permission) {
|
|
|
|
using Kernel::SharedMemory;
|
2014-12-09 10:22:27 +05:30
|
|
|
// TODO(Subv): Implement this function
|
|
|
|
|
2015-01-23 11:30:39 +05:30
|
|
|
CASCADE_RESULT(auto shared_memory, SharedMemory::Create());
|
|
|
|
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(shared_memory)));
|
2015-01-11 11:13:29 +05:30
|
|
|
|
2014-12-09 10:22:27 +05:30
|
|
|
LOG_WARNING(Kernel_SVC, "(STUBBED) called addr=0x%08X", addr);
|
2015-01-23 11:06:58 +05:30
|
|
|
return RESULT_SUCCESS;
|
2014-12-09 10:22:27 +05:30
|
|
|
}
|
|
|
|
|
2014-05-21 03:58:38 +05:30
|
|
|
const HLE::FunctionDef SVC_Table[] = {
|
2014-06-10 08:00:39 +05:30
|
|
|
{0x00, nullptr, "Unknown"},
|
|
|
|
{0x01, HLE::Wrap<ControlMemory>, "ControlMemory"},
|
|
|
|
{0x02, HLE::Wrap<QueryMemory>, "QueryMemory"},
|
|
|
|
{0x03, nullptr, "ExitProcess"},
|
|
|
|
{0x04, nullptr, "GetProcessAffinityMask"},
|
|
|
|
{0x05, nullptr, "SetProcessAffinityMask"},
|
|
|
|
{0x06, nullptr, "GetProcessIdealProcessor"},
|
|
|
|
{0x07, nullptr, "SetProcessIdealProcessor"},
|
|
|
|
{0x08, HLE::Wrap<CreateThread>, "CreateThread"},
|
2014-12-22 18:37:22 +05:30
|
|
|
{0x09, ExitThread, "ExitThread"},
|
2014-06-10 08:00:39 +05:30
|
|
|
{0x0A, HLE::Wrap<SleepThread>, "SleepThread"},
|
|
|
|
{0x0B, HLE::Wrap<GetThreadPriority>, "GetThreadPriority"},
|
|
|
|
{0x0C, HLE::Wrap<SetThreadPriority>, "SetThreadPriority"},
|
|
|
|
{0x0D, nullptr, "GetThreadAffinityMask"},
|
|
|
|
{0x0E, nullptr, "SetThreadAffinityMask"},
|
|
|
|
{0x0F, nullptr, "GetThreadIdealProcessor"},
|
|
|
|
{0x10, nullptr, "SetThreadIdealProcessor"},
|
|
|
|
{0x11, nullptr, "GetCurrentProcessorNumber"},
|
|
|
|
{0x12, nullptr, "Run"},
|
|
|
|
{0x13, HLE::Wrap<CreateMutex>, "CreateMutex"},
|
|
|
|
{0x14, HLE::Wrap<ReleaseMutex>, "ReleaseMutex"},
|
2014-12-04 05:19:51 +05:30
|
|
|
{0x15, HLE::Wrap<CreateSemaphore>, "CreateSemaphore"},
|
2014-12-04 22:10:36 +05:30
|
|
|
{0x16, HLE::Wrap<ReleaseSemaphore>, "ReleaseSemaphore"},
|
2014-06-10 08:00:39 +05:30
|
|
|
{0x17, HLE::Wrap<CreateEvent>, "CreateEvent"},
|
|
|
|
{0x18, HLE::Wrap<SignalEvent>, "SignalEvent"},
|
|
|
|
{0x19, HLE::Wrap<ClearEvent>, "ClearEvent"},
|
2014-12-05 01:15:47 +05:30
|
|
|
{0x1A, HLE::Wrap<CreateTimer>, "CreateTimer"},
|
|
|
|
{0x1B, HLE::Wrap<SetTimer>, "SetTimer"},
|
|
|
|
{0x1C, HLE::Wrap<CancelTimer>, "CancelTimer"},
|
|
|
|
{0x1D, HLE::Wrap<ClearTimer>, "ClearTimer"},
|
2014-12-09 10:22:27 +05:30
|
|
|
{0x1E, HLE::Wrap<CreateMemoryBlock>, "CreateMemoryBlock"},
|
2014-06-10 08:00:39 +05:30
|
|
|
{0x1F, HLE::Wrap<MapMemoryBlock>, "MapMemoryBlock"},
|
|
|
|
{0x20, nullptr, "UnmapMemoryBlock"},
|
|
|
|
{0x21, HLE::Wrap<CreateAddressArbiter>, "CreateAddressArbiter"},
|
|
|
|
{0x22, HLE::Wrap<ArbitrateAddress>, "ArbitrateAddress"},
|
|
|
|
{0x23, HLE::Wrap<CloseHandle>, "CloseHandle"},
|
|
|
|
{0x24, HLE::Wrap<WaitSynchronization1>, "WaitSynchronization1"},
|
|
|
|
{0x25, HLE::Wrap<WaitSynchronizationN>, "WaitSynchronizationN"},
|
|
|
|
{0x26, nullptr, "SignalAndWait"},
|
|
|
|
{0x27, HLE::Wrap<DuplicateHandle>, "DuplicateHandle"},
|
2014-08-15 05:31:02 +05:30
|
|
|
{0x28, HLE::Wrap<GetSystemTick>, "GetSystemTick"},
|
2014-06-10 08:00:39 +05:30
|
|
|
{0x29, nullptr, "GetHandleInfo"},
|
|
|
|
{0x2A, nullptr, "GetSystemInfo"},
|
|
|
|
{0x2B, nullptr, "GetProcessInfo"},
|
|
|
|
{0x2C, nullptr, "GetThreadInfo"},
|
|
|
|
{0x2D, HLE::Wrap<ConnectToPort>, "ConnectToPort"},
|
|
|
|
{0x2E, nullptr, "SendSyncRequest1"},
|
|
|
|
{0x2F, nullptr, "SendSyncRequest2"},
|
|
|
|
{0x30, nullptr, "SendSyncRequest3"},
|
|
|
|
{0x31, nullptr, "SendSyncRequest4"},
|
|
|
|
{0x32, HLE::Wrap<SendSyncRequest>, "SendSyncRequest"},
|
|
|
|
{0x33, nullptr, "OpenProcess"},
|
|
|
|
{0x34, nullptr, "OpenThread"},
|
|
|
|
{0x35, nullptr, "GetProcessId"},
|
|
|
|
{0x36, nullptr, "GetProcessIdOfThread"},
|
|
|
|
{0x37, HLE::Wrap<GetThreadId>, "GetThreadId"},
|
|
|
|
{0x38, HLE::Wrap<GetResourceLimit>, "GetResourceLimit"},
|
|
|
|
{0x39, nullptr, "GetResourceLimitLimitValues"},
|
|
|
|
{0x3A, HLE::Wrap<GetResourceLimitCurrentValues>, "GetResourceLimitCurrentValues"},
|
|
|
|
{0x3B, nullptr, "GetThreadContext"},
|
|
|
|
{0x3C, nullptr, "Break"},
|
|
|
|
{0x3D, HLE::Wrap<OutputDebugString>, "OutputDebugString"},
|
|
|
|
{0x3E, nullptr, "ControlPerformanceCounter"},
|
|
|
|
{0x3F, nullptr, "Unknown"},
|
|
|
|
{0x40, nullptr, "Unknown"},
|
|
|
|
{0x41, nullptr, "Unknown"},
|
|
|
|
{0x42, nullptr, "Unknown"},
|
|
|
|
{0x43, nullptr, "Unknown"},
|
|
|
|
{0x44, nullptr, "Unknown"},
|
|
|
|
{0x45, nullptr, "Unknown"},
|
|
|
|
{0x46, nullptr, "Unknown"},
|
|
|
|
{0x47, nullptr, "CreatePort"},
|
|
|
|
{0x48, nullptr, "CreateSessionToPort"},
|
|
|
|
{0x49, nullptr, "CreateSession"},
|
|
|
|
{0x4A, nullptr, "AcceptSession"},
|
|
|
|
{0x4B, nullptr, "ReplyAndReceive1"},
|
|
|
|
{0x4C, nullptr, "ReplyAndReceive2"},
|
|
|
|
{0x4D, nullptr, "ReplyAndReceive3"},
|
|
|
|
{0x4E, nullptr, "ReplyAndReceive4"},
|
|
|
|
{0x4F, nullptr, "ReplyAndReceive"},
|
|
|
|
{0x50, nullptr, "BindInterrupt"},
|
|
|
|
{0x51, nullptr, "UnbindInterrupt"},
|
|
|
|
{0x52, nullptr, "InvalidateProcessDataCache"},
|
|
|
|
{0x53, nullptr, "StoreProcessDataCache"},
|
|
|
|
{0x54, nullptr, "FlushProcessDataCache"},
|
|
|
|
{0x55, nullptr, "StartInterProcessDma"},
|
|
|
|
{0x56, nullptr, "StopDma"},
|
|
|
|
{0x57, nullptr, "GetDmaState"},
|
|
|
|
{0x58, nullptr, "RestartDma"},
|
|
|
|
{0x59, nullptr, "Unknown"},
|
|
|
|
{0x5A, nullptr, "Unknown"},
|
|
|
|
{0x5B, nullptr, "Unknown"},
|
|
|
|
{0x5C, nullptr, "Unknown"},
|
|
|
|
{0x5D, nullptr, "Unknown"},
|
|
|
|
{0x5E, nullptr, "Unknown"},
|
|
|
|
{0x5F, nullptr, "Unknown"},
|
|
|
|
{0x60, nullptr, "DebugActiveProcess"},
|
|
|
|
{0x61, nullptr, "BreakDebugProcess"},
|
|
|
|
{0x62, nullptr, "TerminateDebugProcess"},
|
|
|
|
{0x63, nullptr, "GetProcessDebugEvent"},
|
|
|
|
{0x64, nullptr, "ContinueDebugEvent"},
|
|
|
|
{0x65, nullptr, "GetProcessList"},
|
|
|
|
{0x66, nullptr, "GetThreadList"},
|
|
|
|
{0x67, nullptr, "GetDebugThreadContext"},
|
|
|
|
{0x68, nullptr, "SetDebugThreadContext"},
|
|
|
|
{0x69, nullptr, "QueryDebugProcessMemory"},
|
|
|
|
{0x6A, nullptr, "ReadProcessMemory"},
|
|
|
|
{0x6B, nullptr, "WriteProcessMemory"},
|
|
|
|
{0x6C, nullptr, "SetHardwareBreakPoint"},
|
|
|
|
{0x6D, nullptr, "GetDebugThreadParam"},
|
|
|
|
{0x6E, nullptr, "Unknown"},
|
|
|
|
{0x6F, nullptr, "Unknown"},
|
|
|
|
{0x70, nullptr, "ControlProcessMemory"},
|
|
|
|
{0x71, nullptr, "MapProcessMemory"},
|
|
|
|
{0x72, nullptr, "UnmapProcessMemory"},
|
2015-01-05 06:04:52 +05:30
|
|
|
{0x73, nullptr, "CreateCodeSet"},
|
|
|
|
{0x74, nullptr, "RandomStub"},
|
|
|
|
{0x75, nullptr, "CreateProcess"},
|
2014-06-10 08:00:39 +05:30
|
|
|
{0x76, nullptr, "TerminateProcess"},
|
2015-01-05 06:04:52 +05:30
|
|
|
{0x77, nullptr, "SetProcessResourceLimits"},
|
2014-06-10 08:00:39 +05:30
|
|
|
{0x78, nullptr, "CreateResourceLimit"},
|
2015-01-05 06:04:52 +05:30
|
|
|
{0x79, nullptr, "SetResourceLimitValues"},
|
|
|
|
{0x7A, nullptr, "AddCodeSegment"},
|
|
|
|
{0x7B, nullptr, "Backdoor"},
|
2014-06-10 08:00:39 +05:30
|
|
|
{0x7C, nullptr, "KernelSetState"},
|
|
|
|
{0x7D, nullptr, "QueryProcessMemory"},
|
2014-04-11 05:28:28 +05:30
|
|
|
};
|
|
|
|
|
2014-04-12 04:14:21 +05:30
|
|
|
void Register() {
|
2014-05-21 03:58:38 +05:30
|
|
|
HLE::RegisterModule("SVC_Table", ARRAY_SIZE(SVC_Table), SVC_Table);
|
2014-04-11 05:28:28 +05:30
|
|
|
}
|
2014-04-12 04:14:21 +05:30
|
|
|
|
|
|
|
} // namespace
|