citra-emu
/
citra
Archived
1
0
Fork 0

core: Remove HLE module, consolidate code & various cleanups.

This commit is contained in:
bunnei 2016-12-16 00:37:38 -05:00
parent 232ef55c1a
commit 4fc8b8229e
19 changed files with 94 additions and 107 deletions

View File

@ -31,7 +31,6 @@ set(SRCS
file_sys/savedata_archive.cpp file_sys/savedata_archive.cpp
gdbstub/gdbstub.cpp gdbstub/gdbstub.cpp
hle/config_mem.cpp hle/config_mem.cpp
hle/hle.cpp
hle/applets/applet.cpp hle/applets/applet.cpp
hle/applets/erreula.cpp hle/applets/erreula.cpp
hle/applets/mii_selector.cpp hle/applets/mii_selector.cpp
@ -195,7 +194,6 @@ set(HEADERS
gdbstub/gdbstub.h gdbstub/gdbstub.h
hle/config_mem.h hle/config_mem.h
hle/function_wrappers.h hle/function_wrappers.h
hle/hle.h
hle/ipc.h hle/ipc.h
hle/applets/applet.h hle/applets/applet.h
hle/applets/erreula.h hle/applets/erreula.h

View File

@ -12,10 +12,10 @@
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/gdbstub/gdbstub.h" #include "core/gdbstub/gdbstub.h"
#include "core/hle/hle.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory.h" #include "core/hle/kernel/memory.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
#include "core/hle/service/service.h"
#include "core/hw/hw.h" #include "core/hw/hw.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"
#include "core/settings.h" #include "core/settings.h"
@ -51,15 +51,13 @@ System::ResultStatus System::RunLoop(int tight_loop) {
LOG_TRACE(Core_ARM11, "Idling"); LOG_TRACE(Core_ARM11, "Idling");
CoreTiming::Idle(); CoreTiming::Idle();
CoreTiming::Advance(); CoreTiming::Advance();
HLE::Reschedule(__func__); PrepareReschedule();
} else { } else {
app_core->Run(tight_loop); app_core->Run(tight_loop);
} }
HW::Update(); HW::Update();
if (HLE::IsReschedulePending()) { Reschedule();
Kernel::Reschedule();
}
return ResultStatus::Success; return ResultStatus::Success;
} }
@ -110,6 +108,20 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file
return ResultStatus::Success; return ResultStatus::Success;
} }
void System::PrepareReschedule() {
app_core->PrepareReschedule();
reschedule_pending = true;
}
void System::Reschedule() {
if (!reschedule_pending) {
return;
}
reschedule_pending = false;
Kernel::Reschedule();
}
System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
if (app_core) { if (app_core) {
app_core.reset(); app_core.reset();
@ -126,7 +138,7 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
CoreTiming::Init(); CoreTiming::Init();
HW::Init(); HW::Init();
Kernel::Init(system_mode); Kernel::Init(system_mode);
HLE::Init(); Service::Init();
AudioCore::Init(); AudioCore::Init();
GDBStub::Init(); GDBStub::Init();
@ -143,7 +155,7 @@ void System::Shutdown() {
GDBStub::Shutdown(); GDBStub::Shutdown();
AudioCore::Shutdown(); AudioCore::Shutdown();
VideoCore::Shutdown(); VideoCore::Shutdown();
HLE::Shutdown(); Service::Shutdown();
Kernel::Shutdown(); Kernel::Shutdown();
HW::Shutdown(); HW::Shutdown();
CoreTiming::Shutdown(); CoreTiming::Shutdown();

View File

@ -52,17 +52,6 @@ public:
ErrorVideoCore, ///< Error in the video core ErrorVideoCore, ///< Error in the video core
}; };
/**
* Initialize the emulated system.
* @param emu_window Pointer to the host-system window used for video output and keyboard input.
* @param system_mode The system mode.
* @return ResultStatus code, indicating if the operation succeeded.
*/
ResultStatus Init(EmuWindow* emu_window, u32 system_mode);
/// Start the core
void Start();
/** /**
* Run the core CPU loop * Run the core CPU loop
* This function runs the core for the specified number of CPU instructions before trying to update * This function runs the core for the specified number of CPU instructions before trying to update
@ -101,6 +90,9 @@ public:
return app_core != nullptr; return app_core != nullptr;
} }
/// Prepare the core emulation for a reschedule
void PrepareReschedule();
/** /**
* Gets a reference to the emulated AppCore CPU. * Gets a reference to the emulated AppCore CPU.
* @returns A reference to the emulated AppCore CPU. * @returns A reference to the emulated AppCore CPU.
@ -110,12 +102,26 @@ public:
} }
private: private:
/**
* Initialize the emulated system.
* @param emu_window Pointer to the host-system window used for video output and keyboard input.
* @param system_mode The system mode.
* @return ResultStatus code, indicating if the operation succeeded.
*/
ResultStatus Init(EmuWindow* emu_window, u32 system_mode);
/// Reschedule the core emulation
void Reschedule();
/// AppLoader used to load the current executing application /// AppLoader used to load the current executing application
std::unique_ptr<Loader::AppLoader> app_loader; std::unique_ptr<Loader::AppLoader> app_loader;
///< ARM11 application core ///< ARM11 application core
std::unique_ptr<ARM_Interface> app_core; std::unique_ptr<ARM_Interface> app_core;
/// When true, signals that a reschedule should happen
bool reschedule_pending{};
static System s_instance; static System s_instance;
}; };

View File

@ -142,10 +142,10 @@ std::string GetExtSaveDataPath(const std::string& mount_point, const Path& path)
std::string GetExtDataContainerPath(const std::string& mount_point, bool shared) { std::string GetExtDataContainerPath(const std::string& mount_point, bool shared) {
if (shared) if (shared)
return Common::StringFromFormat("%sdata/%s/extdata/", mount_point.c_str(), return Common::StringFromFormat("%sdata/%s/extdata/", mount_point.c_str(),
SYSTEM_ID.c_str()); SYSTEM_ID);
return Common::StringFromFormat("%sNintendo 3DS/%s/%s/extdata/", mount_point.c_str(), return Common::StringFromFormat("%sNintendo 3DS/%s/%s/extdata/", mount_point.c_str(),
SYSTEM_ID.c_str(), SDCARD_ID.c_str()); SYSTEM_ID, SDCARD_ID);
} }
Path ConstructExtDataBinaryPath(u32 media_type, u32 high, u32 low) { Path ConstructExtDataBinaryPath(u32 media_type, u32 high, u32 low) {

View File

@ -19,7 +19,7 @@
namespace FileSys { namespace FileSys {
static std::string GetNCCHContainerPath(const std::string& nand_directory) { static std::string GetNCCHContainerPath(const std::string& nand_directory) {
return Common::StringFromFormat("%s%s/title/", nand_directory.c_str(), SYSTEM_ID.c_str()); return Common::StringFromFormat("%s%s/title/", nand_directory.c_str(), SYSTEM_ID);
} }
static std::string GetNCCHPath(const std::string& mount_point, u32 high, u32 low) { static std::string GetNCCHPath(const std::string& mount_point, u32 high, u32 low) {

View File

@ -18,7 +18,7 @@ namespace {
std::string GetSaveDataContainerPath(const std::string& sdmc_directory) { std::string GetSaveDataContainerPath(const std::string& sdmc_directory) {
return Common::StringFromFormat("%sNintendo 3DS/%s/%s/title/", sdmc_directory.c_str(), return Common::StringFromFormat("%sNintendo 3DS/%s/%s/title/", sdmc_directory.c_str(),
SYSTEM_ID.c_str(), SDCARD_ID.c_str()); SYSTEM_ID, SDCARD_ID);
} }
std::string GetSaveDataPath(const std::string& mount_location, u64 program_id) { std::string GetSaveDataPath(const std::string& mount_location, u64 program_id) {

View File

@ -26,7 +26,7 @@ std::string GetSystemSaveDataPath(const std::string& mount_point, const Path& pa
} }
std::string GetSystemSaveDataContainerPath(const std::string& mount_point) { std::string GetSystemSaveDataContainerPath(const std::string& mount_point) {
return Common::StringFromFormat("%sdata/%s/sysdata/", mount_point.c_str(), SYSTEM_ID.c_str()); return Common::StringFromFormat("%sdata/%s/sysdata/", mount_point.c_str(), SYSTEM_ID);
} }
Path ConstructSystemSaveDataBinaryPath(u32 high, u32 low) { Path ConstructSystemSaveDataBinaryPath(u32 high, u32 low) {

View File

@ -7,7 +7,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "core/arm/arm_interface.h" #include "core/arm/arm_interface.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/hle.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/result.h" #include "core/hle/result.h"
#include "core/hle/svc.h" #include "core/hle/svc.h"
#include "core/memory.h" #include "core/memory.h"
@ -64,7 +64,7 @@ void Wrap() {
template <ResultCode func(s32*, u32*, s32, bool, s64)> template <ResultCode func(s32*, u32*, s32, bool, s64)>
void Wrap() { void Wrap() {
s32 param_1 = 0; s32 param_1 = 0;
s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), s32 retval = func(&param_1, (Kernel::Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
(PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))) (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)))
.raw; .raw;
@ -110,7 +110,7 @@ void Wrap() {
FuncReturn(retval); FuncReturn(retval);
} }
template <ResultCode func(MemoryInfo*, PageInfo*, Handle, u32)> template <ResultCode func(MemoryInfo*, PageInfo*, Kernel::Handle, u32)>
void Wrap() { void Wrap() {
MemoryInfo memory_info = {}; MemoryInfo memory_info = {};
PageInfo page_info = {}; PageInfo page_info = {};
@ -205,7 +205,7 @@ void Wrap() {
FuncReturn(func(PARAM(0), param1, param2).raw); FuncReturn(func(PARAM(0), param1, param2).raw);
} }
template <ResultCode func(s64*, Handle, u32)> template <ResultCode func(s64*, Kernel::Handle, u32)>
void Wrap() { void Wrap() {
s64 param_1 = 0; s64 param_1 = 0;
u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw; u32 retval = func(&param_1, PARAM(1), PARAM(2)).raw;
@ -214,15 +214,15 @@ void Wrap() {
FuncReturn(retval); FuncReturn(retval);
} }
template <ResultCode func(Handle, u32)> template <ResultCode func(Kernel::Handle, u32)>
void Wrap() { void Wrap() {
FuncReturn(func(PARAM(0), PARAM(1)).raw); FuncReturn(func(PARAM(0), PARAM(1)).raw);
} }
template <ResultCode func(Handle*, Handle*, const char*, u32)> template <ResultCode func(Kernel::Handle*, Kernel::Handle*, const char*, u32)>
void Wrap() { void Wrap() {
Handle param_1 = 0; Kernel::Handle param_1 = 0;
Handle param_2 = 0; Kernel::Handle param_2 = 0;
u32 retval = func(&param_1, &param_2, u32 retval = func(&param_1, &param_2,
reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3)) reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3))
.raw; .raw;

View File

@ -1,23 +0,0 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "common/common_types.h"
typedef u32 Handle;
typedef s32 Result;
const Handle INVALID_HANDLE = 0;
namespace HLE {
void Reschedule(const char* reason);
bool IsReschedulePending();
void DoneRescheduling();
void Init();
void Shutdown();
} // namespace

View File

@ -4,7 +4,6 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/hle/hle.h"
#include "core/hle/kernel/address_arbiter.h" #include "core/hle/kernel/address_arbiter.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
#include "core/memory.h" #include "core/memory.h"

View File

@ -11,11 +11,12 @@
#include <vector> #include <vector>
#include <boost/smart_ptr/intrusive_ptr.hpp> #include <boost/smart_ptr/intrusive_ptr.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/hle.h"
#include "core/hle/result.h" #include "core/hle/result.h"
namespace Kernel { namespace Kernel {
using Handle = u32;
class Thread; class Thread;
// TODO: Verify code // TODO: Verify code

View File

@ -14,7 +14,6 @@
#include "core/arm/skyeye_common/armstate.h" #include "core/arm/skyeye_common/armstate.h"
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/hle.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory.h" #include "core/hle/kernel/memory.h"
#include "core/hle/kernel/mutex.h" #include "core/hle/kernel/mutex.h"
@ -330,7 +329,7 @@ void Thread::ResumeFromWait() {
ready_queue.push_back(current_priority, this); ready_queue.push_back(current_priority, this);
status = THREADSTATUS_READY; status = THREADSTATUS_READY;
HLE::Reschedule(__func__); Core::System::GetInstance().PrepareReschedule();
} }
/** /**
@ -545,8 +544,6 @@ void Reschedule() {
Thread* cur = GetCurrentThread(); Thread* cur = GetCurrentThread();
Thread* next = PopNextReadyThread(); Thread* next = PopNextReadyThread();
HLE::DoneRescheduling();
if (cur && next) { if (cur && next) {
LOG_TRACE(Kernel, "context switch %u -> %u", cur->GetObjectId(), next->GetObjectId()); LOG_TRACE(Kernel, "context switch %u -> %u", cur->GetObjectId(), next->GetObjectId());
} else if (cur) { } else if (cur) {

View File

@ -11,7 +11,6 @@
#include <boost/container/flat_set.hpp> #include <boost/container/flat_set.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/hle.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/result.h" #include "core/hle/result.h"

View File

@ -4,7 +4,6 @@
#include <cstring> #include <cstring>
#include "common/alignment.h" #include "common/alignment.h"
#include "core/hle/hle.h"
#include "core/hle/kernel/mutex.h" #include "core/hle/kernel/mutex.h"
#include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/csnd_snd.h" #include "core/hle/service/csnd_snd.h"

View File

@ -23,7 +23,6 @@
#include "core/file_sys/archive_systemsavedata.h" #include "core/file_sys/archive_systemsavedata.h"
#include "core/file_sys/directory_backend.h" #include "core/file_sys/directory_backend.h"
#include "core/file_sys/file_backend.h" #include "core/file_sys/file_backend.h"
#include "core/hle/hle.h"
#include "core/hle/kernel/client_session.h" #include "core/hle/kernel/client_session.h"
#include "core/hle/result.h" #include "core/hle/result.h"
#include "core/hle/service/fs/archive.h" #include "core/hle/service/fs/archive.h"
@ -46,9 +45,7 @@ struct hash<Service::FS::ArchiveIdCode> {
}; };
} }
/// TODO(Subv): Confirm length of these strings static constexpr Kernel::Handle INVALID_HANDLE{};
const std::string SYSTEM_ID = "00000000000000000000000000000000";
const std::string SDCARD_ID = "00000000000000000000000000000000";
namespace Service { namespace Service {
namespace FS { namespace FS {

View File

@ -17,9 +17,9 @@ class FileBackend;
} }
/// The unique system identifier hash, also known as ID0 /// The unique system identifier hash, also known as ID0
extern const std::string SYSTEM_ID; static constexpr char SYSTEM_ID[]{ "00000000000000000000000000000000" };
/// The scrambled SD card CID, also known as ID1 /// The scrambled SD card CID, also known as ID1
extern const std::string SDCARD_ID; static constexpr char SDCARD_ID[]{ "00000000000000000000000000000000" };
namespace Service { namespace Service {
namespace FS { namespace FS {

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/ir/ir.h" #include "core/hle/service/ir/ir.h"
#include "core/hle/service/ir/ir_rst.h" #include "core/hle/service/ir/ir_rst.h"
@ -36,7 +37,7 @@ void InitializeIrNopShared(Interface* self) {
u32 send_buff_size = cmd_buff[4]; u32 send_buff_size = cmd_buff[4];
u32 unk2 = cmd_buff[5]; u32 unk2 = cmd_buff[5];
u8 baud_rate = cmd_buff[6] & 0xFF; u8 baud_rate = cmd_buff[6] & 0xFF;
Handle handle = cmd_buff[8]; Kernel::Handle handle = cmd_buff[8];
if (Kernel::g_handle_table.IsValid(handle)) { if (Kernel::g_handle_table.IsValid(handle)) {
transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle); transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle);

View File

@ -4,6 +4,7 @@
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/mic_u.h" #include "core/hle/service/mic_u.h"
@ -50,7 +51,7 @@ static bool audio_buffer_loop;
static void MapSharedMem(Interface* self) { static void MapSharedMem(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
u32 size = cmd_buff[1]; u32 size = cmd_buff[1];
Handle mem_handle = cmd_buff[3]; Kernel::Handle mem_handle = cmd_buff[3];
shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(mem_handle); shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(mem_handle);
if (shared_memory) { if (shared_memory) {
shared_memory->name = "MIC_U:shared_memory"; shared_memory->name = "MIC_U:shared_memory";

View File

@ -166,7 +166,7 @@ static ResultCode ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 add
} }
/// Maps a memory block to specified address /// Maps a memory block to specified address
static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { static ResultCode MapMemoryBlock(Kernel::Handle handle, u32 addr, u32 permissions, u32 other_permissions) {
using Kernel::SharedMemory; using Kernel::SharedMemory;
using Kernel::MemoryPermission; using Kernel::MemoryPermission;
@ -198,7 +198,7 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o
ErrorSummary::InvalidArgument, ErrorLevel::Usage); ErrorSummary::InvalidArgument, ErrorLevel::Usage);
} }
static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) { static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) {
using Kernel::SharedMemory; using Kernel::SharedMemory;
LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X", handle, addr); LOG_TRACE(Kernel_SVC, "called memblock=0x%08X, addr=0x%08X", handle, addr);
@ -213,7 +213,7 @@ static ResultCode UnmapMemoryBlock(Handle handle, u32 addr) {
} }
/// Connect to an OS service given the port name, returns the handle to the port to out /// Connect to an OS service given the port name, returns the handle to the port to out
static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) { static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) {
if (port_name == nullptr) if (port_name == nullptr)
return ERR_NOT_FOUND; return ERR_NOT_FOUND;
if (std::strlen(port_name) > 11) if (std::strlen(port_name) > 11)
@ -238,7 +238,7 @@ static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) {
} }
/// Makes a blocking IPC call to an OS service. /// Makes a blocking IPC call to an OS service.
static ResultCode SendSyncRequest(Handle handle) { static ResultCode SendSyncRequest(Kernel::Handle handle) {
SharedPtr<Kernel::ClientSession> session = SharedPtr<Kernel::ClientSession> session =
Kernel::g_handle_table.Get<Kernel::ClientSession>(handle); Kernel::g_handle_table.Get<Kernel::ClientSession>(handle);
if (session == nullptr) { if (session == nullptr) {
@ -253,13 +253,13 @@ static ResultCode SendSyncRequest(Handle handle) {
} }
/// Close a handle /// Close a handle
static ResultCode CloseHandle(Handle handle) { static ResultCode CloseHandle(Kernel::Handle handle) {
LOG_TRACE(Kernel_SVC, "Closing handle 0x%08X", handle); LOG_TRACE(Kernel_SVC, "Closing handle 0x%08X", handle);
return Kernel::g_handle_table.Close(handle); return Kernel::g_handle_table.Close(handle);
} }
/// Wait for a handle to synchronize, timeout after the specified nanoseconds /// Wait for a handle to synchronize, timeout after the specified nanoseconds
static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) { static ResultCode WaitSynchronization1(Kernel::Handle handle, s64 nano_seconds) {
auto object = Kernel::g_handle_table.GetWaitObject(handle); auto object = Kernel::g_handle_table.GetWaitObject(handle);
Kernel::Thread* thread = Kernel::GetCurrentThread(); Kernel::Thread* thread = Kernel::GetCurrentThread();
@ -295,7 +295,7 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
} }
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds /// Wait for the given handles to synchronize, timeout after the specified nanoseconds
static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wait_all, static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 handle_count, bool wait_all,
s64 nano_seconds) { s64 nano_seconds) {
Kernel::Thread* thread = Kernel::GetCurrentThread(); Kernel::Thread* thread = Kernel::GetCurrentThread();
@ -423,7 +423,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
} }
/// Create an address arbiter (to allocate access to shared resources) /// Create an address arbiter (to allocate access to shared resources)
static ResultCode CreateAddressArbiter(Handle* out_handle) { static ResultCode CreateAddressArbiter(Kernel::Handle* out_handle) {
using Kernel::AddressArbiter; using Kernel::AddressArbiter;
SharedPtr<AddressArbiter> arbiter = AddressArbiter::Create(); SharedPtr<AddressArbiter> arbiter = AddressArbiter::Create();
@ -433,7 +433,7 @@ static ResultCode CreateAddressArbiter(Handle* out_handle) {
} }
/// Arbitrate address /// Arbitrate address
static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 value, static ResultCode ArbitrateAddress(Kernel::Handle handle, u32 address, u32 type, u32 value,
s64 nanoseconds) { s64 nanoseconds) {
using Kernel::AddressArbiter; using Kernel::AddressArbiter;
@ -476,7 +476,7 @@ static void OutputDebugString(const char* string) {
} }
/// Get resource limit /// Get resource limit
static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle) { static ResultCode GetResourceLimit(Kernel::Handle* resource_limit, Kernel::Handle process_handle) {
LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle);
SharedPtr<Kernel::Process> process = SharedPtr<Kernel::Process> process =
@ -490,7 +490,7 @@ static ResultCode GetResourceLimit(Handle* resource_limit, Handle process_handle
} }
/// Get resource limit current values /// Get resource limit current values
static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit_handle, static ResultCode GetResourceLimitCurrentValues(s64* values, Kernel::Handle resource_limit_handle,
u32* names, u32 name_count) { u32* names, u32 name_count) {
LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d",
resource_limit_handle, names, name_count); resource_limit_handle, names, name_count);
@ -507,7 +507,7 @@ static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_lim
} }
/// Get resource limit max values /// Get resource limit max values
static ResultCode GetResourceLimitLimitValues(s64* values, Handle resource_limit_handle, u32* names, static ResultCode GetResourceLimitLimitValues(s64* values, Kernel::Handle resource_limit_handle, u32* names,
u32 name_count) { u32 name_count) {
LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d", LOG_TRACE(Kernel_SVC, "called resource_limit=%08X, names=%p, name_count=%d",
resource_limit_handle, names, name_count); resource_limit_handle, names, name_count);
@ -524,7 +524,7 @@ static ResultCode GetResourceLimitLimitValues(s64* values, Handle resource_limit
} }
/// Creates a new thread /// Creates a new thread
static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point, u32 arg, static ResultCode CreateThread(Kernel::Handle* out_handle, s32 priority, u32 entry_point, u32 arg,
u32 stack_top, s32 processor_id) { u32 stack_top, s32 processor_id) {
using Kernel::Thread; using Kernel::Thread;
@ -588,7 +588,7 @@ static void ExitThread() {
} }
/// Gets the priority for the specified thread /// Gets the priority for the specified thread
static ResultCode GetThreadPriority(s32* priority, Handle handle) { static ResultCode GetThreadPriority(s32* priority, Kernel::Handle handle) {
const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
if (thread == nullptr) if (thread == nullptr)
return ERR_INVALID_HANDLE; return ERR_INVALID_HANDLE;
@ -598,7 +598,7 @@ static ResultCode GetThreadPriority(s32* priority, Handle handle) {
} }
/// Sets the priority for the specified thread /// Sets the priority for the specified thread
static ResultCode SetThreadPriority(Handle handle, s32 priority) { static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) {
SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
if (thread == nullptr) if (thread == nullptr)
return ERR_INVALID_HANDLE; return ERR_INVALID_HANDLE;
@ -608,7 +608,7 @@ static ResultCode SetThreadPriority(Handle handle, s32 priority) {
} }
/// Create a mutex /// Create a mutex
static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) { static ResultCode CreateMutex(Kernel::Handle* out_handle, u32 initial_locked) {
using Kernel::Mutex; using Kernel::Mutex;
SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0); SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0);
@ -622,7 +622,7 @@ static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) {
} }
/// Release a mutex /// Release a mutex
static ResultCode ReleaseMutex(Handle handle) { static ResultCode ReleaseMutex(Kernel::Handle handle) {
using Kernel::Mutex; using Kernel::Mutex;
LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle); LOG_TRACE(Kernel_SVC, "called handle=0x%08X", handle);
@ -637,7 +637,7 @@ static ResultCode ReleaseMutex(Handle handle) {
} }
/// Get the ID of the specified process /// Get the ID of the specified process
static ResultCode GetProcessId(u32* process_id, Handle process_handle) { static ResultCode GetProcessId(u32* process_id, Kernel::Handle process_handle) {
LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle); LOG_TRACE(Kernel_SVC, "called process=0x%08X", process_handle);
const SharedPtr<Kernel::Process> process = const SharedPtr<Kernel::Process> process =
@ -650,7 +650,7 @@ static ResultCode GetProcessId(u32* process_id, Handle process_handle) {
} }
/// Get the ID of the process that owns the specified thread /// Get the ID of the process that owns the specified thread
static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) { static ResultCode GetProcessIdOfThread(u32* process_id, Kernel::Handle thread_handle) {
LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle); LOG_TRACE(Kernel_SVC, "called thread=0x%08X", thread_handle);
const SharedPtr<Kernel::Thread> thread = const SharedPtr<Kernel::Thread> thread =
@ -667,7 +667,7 @@ static ResultCode GetProcessIdOfThread(u32* process_id, Handle thread_handle) {
} }
/// Get the ID for the specified thread. /// Get the ID for the specified thread.
static ResultCode GetThreadId(u32* thread_id, Handle handle) { static ResultCode GetThreadId(u32* thread_id, Kernel::Handle handle) {
LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle); LOG_TRACE(Kernel_SVC, "called thread=0x%08X", handle);
const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
@ -679,7 +679,7 @@ static ResultCode GetThreadId(u32* thread_id, Handle handle) {
} }
/// Creates a semaphore /// Creates a semaphore
static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max_count) { static ResultCode CreateSemaphore(Kernel::Handle* out_handle, s32 initial_count, s32 max_count) {
using Kernel::Semaphore; using Kernel::Semaphore;
CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count)); CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count));
@ -692,7 +692,7 @@ static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max
} }
/// Releases a certain number of slots in a semaphore /// Releases a certain number of slots in a semaphore
static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) { static ResultCode ReleaseSemaphore(s32* count, Kernel::Handle handle, s32 release_count) {
using Kernel::Semaphore; using Kernel::Semaphore;
LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle); LOG_TRACE(Kernel_SVC, "called release_count=%d, handle=0x%08X", release_count, handle);
@ -708,7 +708,7 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count)
/// Query process memory /// Query process memory
static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info, static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_info,
Handle process_handle, u32 addr) { Kernel::Handle process_handle, u32 addr) {
using Kernel::Process; using Kernel::Process;
Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle); Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle);
if (process == nullptr) if (process == nullptr)
@ -736,7 +736,7 @@ static ResultCode QueryMemory(MemoryInfo* memory_info, PageInfo* page_info, u32
} }
/// Create an event /// Create an event
static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) { static ResultCode CreateEvent(Kernel::Handle* out_handle, u32 reset_type) {
using Kernel::Event; using Kernel::Event;
SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type)); SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type));
@ -749,14 +749,14 @@ static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
} }
/// Duplicates a kernel handle /// Duplicates a kernel handle
static ResultCode DuplicateHandle(Handle* out, Handle handle) { static ResultCode DuplicateHandle(Kernel::Handle* out, Kernel::Handle handle) {
CASCADE_RESULT(*out, Kernel::g_handle_table.Duplicate(handle)); CASCADE_RESULT(*out, Kernel::g_handle_table.Duplicate(handle));
LOG_TRACE(Kernel_SVC, "duplicated 0x%08X to 0x%08X", handle, *out); LOG_TRACE(Kernel_SVC, "duplicated 0x%08X to 0x%08X", handle, *out);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
/// Signals an event /// Signals an event
static ResultCode SignalEvent(Handle handle) { static ResultCode SignalEvent(Kernel::Handle handle) {
using Kernel::Event; using Kernel::Event;
LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle);
@ -770,7 +770,7 @@ static ResultCode SignalEvent(Handle handle) {
} }
/// Clears an event /// Clears an event
static ResultCode ClearEvent(Handle handle) { static ResultCode ClearEvent(Kernel::Handle handle) {
using Kernel::Event; using Kernel::Event;
LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle); LOG_TRACE(Kernel_SVC, "called event=0x%08X", handle);
@ -783,7 +783,7 @@ static ResultCode ClearEvent(Handle handle) {
} }
/// Creates a timer /// Creates a timer
static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) { static ResultCode CreateTimer(Kernel::Handle* out_handle, u32 reset_type) {
using Kernel::Timer; using Kernel::Timer;
SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type)); SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type));
@ -796,7 +796,7 @@ static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
} }
/// Clears a timer /// Clears a timer
static ResultCode ClearTimer(Handle handle) { static ResultCode ClearTimer(Kernel::Handle handle) {
using Kernel::Timer; using Kernel::Timer;
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
@ -810,7 +810,7 @@ static ResultCode ClearTimer(Handle handle) {
} }
/// Starts a timer /// Starts a timer
static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) { static ResultCode SetTimer(Kernel::Handle handle, s64 initial, s64 interval) {
using Kernel::Timer; using Kernel::Timer;
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
@ -825,7 +825,7 @@ static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) {
} }
/// Cancels a timer /// Cancels a timer
static ResultCode CancelTimer(Handle handle) { static ResultCode CancelTimer(Kernel::Handle handle) {
using Kernel::Timer; using Kernel::Timer;
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle); LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
@ -860,7 +860,7 @@ static s64 GetSystemTick() {
} }
/// Creates a memory block at the specified address with the specified permissions and size /// Creates a memory block at the specified address with the specified permissions and size
static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 my_permission, static ResultCode CreateMemoryBlock(Kernel::Handle* out_handle, u32 addr, u32 size, u32 my_permission,
u32 other_permission) { u32 other_permission) {
using Kernel::SharedMemory; using Kernel::SharedMemory;
@ -912,7 +912,7 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
static ResultCode CreatePort(Handle* server_port, Handle* client_port, const char* name, static ResultCode CreatePort(Kernel::Handle* server_port, Kernel::Handle* client_port, const char* name,
u32 max_sessions) { u32 max_sessions) {
// TODO(Subv): Implement named ports. // TODO(Subv): Implement named ports.
ASSERT_MSG(name == nullptr, "Named ports are currently unimplemented"); ASSERT_MSG(name == nullptr, "Named ports are currently unimplemented");
@ -978,7 +978,7 @@ static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) { static ResultCode GetProcessInfo(s64* out, Kernel::Handle process_handle, u32 type) {
LOG_TRACE(Kernel_SVC, "called process=0x%08X type=%u", process_handle, type); LOG_TRACE(Kernel_SVC, "called process=0x%08X type=%u", process_handle, type);
using Kernel::Process; using Kernel::Process;
@ -1185,7 +1185,7 @@ void CallSVC(u32 immediate) {
if (info->func) { if (info->func) {
info->func(); info->func();
// TODO(Subv): Not all service functions should cause a reschedule in all cases. // TODO(Subv): Not all service functions should cause a reschedule in all cases.
HLE::Reschedule(__func__); Core::System::GetInstance().PrepareReschedule();
} else { } else {
LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name); LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name);
} }