1
0
Fork 0
forked from suyu/suyu

core: Replace all instances of ResultCode with Result

This commit is contained in:
german77 2022-06-25 22:44:19 -05:00
parent abfd690601
commit a7d9be1384
140 changed files with 1133 additions and 1173 deletions

View file

@ -98,13 +98,13 @@ AudioRenderer::AudioRenderer(Core::Timing::CoreTiming& core_timing_, Core::Memor
AudioRenderer::~AudioRenderer() = default; AudioRenderer::~AudioRenderer() = default;
ResultCode AudioRenderer::Start() { Result AudioRenderer::Start() {
audio_out->StartStream(stream); audio_out->StartStream(stream);
ReleaseAndQueueBuffers(); ReleaseAndQueueBuffers();
return ResultSuccess; return ResultSuccess;
} }
ResultCode AudioRenderer::Stop() { Result AudioRenderer::Stop() {
audio_out->StopStream(stream); audio_out->StopStream(stream);
return ResultSuccess; return ResultSuccess;
} }
@ -125,7 +125,7 @@ Stream::State AudioRenderer::GetStreamState() const {
return stream->GetState(); return stream->GetState();
} }
ResultCode AudioRenderer::UpdateAudioRenderer(const std::vector<u8>& input_params, Result AudioRenderer::UpdateAudioRenderer(const std::vector<u8>& input_params,
std::vector<u8>& output_params) { std::vector<u8>& output_params) {
std::scoped_lock lock{mutex}; std::scoped_lock lock{mutex};
InfoUpdater info_updater{input_params, output_params, behavior_info}; InfoUpdater info_updater{input_params, output_params, behavior_info};

View file

@ -43,10 +43,10 @@ public:
Stream::ReleaseCallback&& release_callback, std::size_t instance_number); Stream::ReleaseCallback&& release_callback, std::size_t instance_number);
~AudioRenderer(); ~AudioRenderer();
[[nodiscard]] ResultCode UpdateAudioRenderer(const std::vector<u8>& input_params, [[nodiscard]] Result UpdateAudioRenderer(const std::vector<u8>& input_params,
std::vector<u8>& output_params); std::vector<u8>& output_params);
[[nodiscard]] ResultCode Start(); [[nodiscard]] Result Start();
[[nodiscard]] ResultCode Stop(); [[nodiscard]] Result Stop();
void QueueMixedBuffer(Buffer::Tag tag); void QueueMixedBuffer(Buffer::Tag tag);
void ReleaseAndQueueBuffers(); void ReleaseAndQueueBuffers();
[[nodiscard]] u32 GetSampleRate() const; [[nodiscard]] u32 GetSampleRate() const;

View file

@ -10,8 +10,8 @@
namespace AudioCommon { namespace AudioCommon {
namespace Audren { namespace Audren {
constexpr ResultCode ERR_INVALID_PARAMETERS{ErrorModule::Audio, 41}; constexpr Result ERR_INVALID_PARAMETERS{ErrorModule::Audio, 41};
constexpr ResultCode ERR_SPLITTER_SORT_FAILED{ErrorModule::Audio, 43}; constexpr Result ERR_SPLITTER_SORT_FAILED{ErrorModule::Audio, 43};
} // namespace Audren } // namespace Audren
constexpr u8 BASE_REVISION = '0'; constexpr u8 BASE_REVISION = '0';

View file

@ -285,9 +285,8 @@ bool InfoUpdater::UpdateSplitterInfo(SplitterContext& splitter_context) {
return true; return true;
} }
ResultCode InfoUpdater::UpdateMixes(MixContext& mix_context, std::size_t mix_buffer_count, Result InfoUpdater::UpdateMixes(MixContext& mix_context, std::size_t mix_buffer_count,
SplitterContext& splitter_context, SplitterContext& splitter_context, EffectContext& effect_context) {
EffectContext& effect_context) {
std::vector<MixInfo::InParams> mix_in_params; std::vector<MixInfo::InParams> mix_in_params;
if (!behavior_info.IsMixInParameterDirtyOnlyUpdateSupported()) { if (!behavior_info.IsMixInParameterDirtyOnlyUpdateSupported()) {

View file

@ -32,7 +32,7 @@ public:
VAddr audio_codec_dsp_addr); VAddr audio_codec_dsp_addr);
bool UpdateEffects(EffectContext& effect_context, bool is_active); bool UpdateEffects(EffectContext& effect_context, bool is_active);
bool UpdateSplitterInfo(SplitterContext& splitter_context); bool UpdateSplitterInfo(SplitterContext& splitter_context);
ResultCode UpdateMixes(MixContext& mix_context, std::size_t mix_buffer_count, Result UpdateMixes(MixContext& mix_context, std::size_t mix_buffer_count,
SplitterContext& splitter_context, EffectContext& effect_context); SplitterContext& splitter_context, EffectContext& effect_context);
bool UpdateSinks(SinkContext& sink_context); bool UpdateSinks(SinkContext& sink_context);
bool UpdatePerformanceBuffer(); bool UpdatePerformanceBuffer();

View file

@ -8,14 +8,14 @@
namespace FileSys { namespace FileSys {
constexpr ResultCode ERROR_PATH_NOT_FOUND{ErrorModule::FS, 1}; constexpr Result ERROR_PATH_NOT_FOUND{ErrorModule::FS, 1};
constexpr ResultCode ERROR_PATH_ALREADY_EXISTS{ErrorModule::FS, 2}; constexpr Result ERROR_PATH_ALREADY_EXISTS{ErrorModule::FS, 2};
constexpr ResultCode ERROR_ENTITY_NOT_FOUND{ErrorModule::FS, 1002}; constexpr Result ERROR_ENTITY_NOT_FOUND{ErrorModule::FS, 1002};
constexpr ResultCode ERROR_SD_CARD_NOT_FOUND{ErrorModule::FS, 2001}; constexpr Result ERROR_SD_CARD_NOT_FOUND{ErrorModule::FS, 2001};
constexpr ResultCode ERROR_OUT_OF_BOUNDS{ErrorModule::FS, 3005}; constexpr Result ERROR_OUT_OF_BOUNDS{ErrorModule::FS, 3005};
constexpr ResultCode ERROR_FAILED_MOUNT_ARCHIVE{ErrorModule::FS, 3223}; constexpr Result ERROR_FAILED_MOUNT_ARCHIVE{ErrorModule::FS, 3223};
constexpr ResultCode ERROR_INVALID_ARGUMENT{ErrorModule::FS, 6001}; constexpr Result ERROR_INVALID_ARGUMENT{ErrorModule::FS, 6001};
constexpr ResultCode ERROR_INVALID_OFFSET{ErrorModule::FS, 6061}; constexpr Result ERROR_INVALID_OFFSET{ErrorModule::FS, 6061};
constexpr ResultCode ERROR_INVALID_SIZE{ErrorModule::FS, 6062}; constexpr Result ERROR_INVALID_SIZE{ErrorModule::FS, 6062};
} // namespace FileSys } // namespace FileSys

View file

@ -8,12 +8,12 @@ namespace Core::Frontend {
ErrorApplet::~ErrorApplet() = default; ErrorApplet::~ErrorApplet() = default;
void DefaultErrorApplet::ShowError(ResultCode error, std::function<void()> finished) const { void DefaultErrorApplet::ShowError(Result error, std::function<void()> finished) const {
LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})", LOG_CRITICAL(Service_Fatal, "Application requested error display: {:04}-{:04} (raw={:08X})",
error.module.Value(), error.description.Value(), error.raw); error.module.Value(), error.description.Value(), error.raw);
} }
void DefaultErrorApplet::ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time, void DefaultErrorApplet::ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
std::function<void()> finished) const { std::function<void()> finished) const {
LOG_CRITICAL( LOG_CRITICAL(
Service_Fatal, Service_Fatal,
@ -21,7 +21,7 @@ void DefaultErrorApplet::ShowErrorWithTimestamp(ResultCode error, std::chrono::s
error.module.Value(), error.description.Value(), error.raw, time.count()); error.module.Value(), error.description.Value(), error.raw, time.count());
} }
void DefaultErrorApplet::ShowCustomErrorText(ResultCode error, std::string main_text, void DefaultErrorApplet::ShowCustomErrorText(Result error, std::string main_text,
std::string detail_text, std::string detail_text,
std::function<void()> finished) const { std::function<void()> finished) const {
LOG_CRITICAL(Service_Fatal, LOG_CRITICAL(Service_Fatal,

View file

@ -14,22 +14,22 @@ class ErrorApplet {
public: public:
virtual ~ErrorApplet(); virtual ~ErrorApplet();
virtual void ShowError(ResultCode error, std::function<void()> finished) const = 0; virtual void ShowError(Result error, std::function<void()> finished) const = 0;
virtual void ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time, virtual void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
std::function<void()> finished) const = 0; std::function<void()> finished) const = 0;
virtual void ShowCustomErrorText(ResultCode error, std::string dialog_text, virtual void ShowCustomErrorText(Result error, std::string dialog_text,
std::string fullscreen_text, std::string fullscreen_text,
std::function<void()> finished) const = 0; std::function<void()> finished) const = 0;
}; };
class DefaultErrorApplet final : public ErrorApplet { class DefaultErrorApplet final : public ErrorApplet {
public: public:
void ShowError(ResultCode error, std::function<void()> finished) const override; void ShowError(Result error, std::function<void()> finished) const override;
void ShowErrorWithTimestamp(ResultCode error, std::chrono::seconds time, void ShowErrorWithTimestamp(Result error, std::chrono::seconds time,
std::function<void()> finished) const override; std::function<void()> finished) const override;
void ShowCustomErrorText(ResultCode error, std::string main_text, std::string detail_text, void ShowCustomErrorText(Result error, std::string main_text, std::string detail_text,
std::function<void()> finished) const override; std::function<void()> finished) const override;
}; };

View file

@ -19,7 +19,7 @@
namespace IPC { namespace IPC {
constexpr ResultCode ERR_REMOTE_PROCESS_DEAD{ErrorModule::HIPC, 301}; constexpr Result ERR_REMOTE_PROCESS_DEAD{ErrorModule::HIPC, 301};
class RequestHelperBase { class RequestHelperBase {
protected: protected:
@ -176,7 +176,7 @@ public:
void PushImpl(float value); void PushImpl(float value);
void PushImpl(double value); void PushImpl(double value);
void PushImpl(bool value); void PushImpl(bool value);
void PushImpl(ResultCode value); void PushImpl(Result value);
template <typename T> template <typename T>
void Push(T value) { void Push(T value) {
@ -251,7 +251,7 @@ void ResponseBuilder::PushRaw(const T& value) {
index += (sizeof(T) + 3) / 4; // round up to word length index += (sizeof(T) + 3) / 4; // round up to word length
} }
inline void ResponseBuilder::PushImpl(ResultCode value) { inline void ResponseBuilder::PushImpl(Result value) {
// Result codes are actually 64-bit in the IPC buffer, but only the high part is discarded. // Result codes are actually 64-bit in the IPC buffer, but only the high part is discarded.
Push(value.raw); Push(value.raw);
Push<u32>(0); Push<u32>(0);
@ -481,8 +481,8 @@ inline bool RequestParser::Pop() {
} }
template <> template <>
inline ResultCode RequestParser::Pop() { inline Result RequestParser::Pop() {
return ResultCode{Pop<u32>()}; return Result{Pop<u32>()};
} }
template <typename T> template <typename T>

View file

@ -188,7 +188,7 @@ void HLERequestContext::ParseCommandBuffer(const KHandleTable& handle_table, u32
rp.Skip(1, false); // The command is actually an u64, but we don't use the high part. rp.Skip(1, false); // The command is actually an u64, but we don't use the high part.
} }
ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, Result HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table,
u32_le* src_cmdbuf) { u32_le* src_cmdbuf) {
ParseCommandBuffer(handle_table, src_cmdbuf, true); ParseCommandBuffer(handle_table, src_cmdbuf, true);
@ -202,7 +202,7 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTab
return ResultSuccess; return ResultSuccess;
} }
ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(KThread& requesting_thread) { Result HLERequestContext::WriteToOutgoingCommandBuffer(KThread& requesting_thread) {
auto current_offset = handles_offset; auto current_offset = handles_offset;
auto& owner_process = *requesting_thread.GetOwnerProcess(); auto& owner_process = *requesting_thread.GetOwnerProcess();
auto& handle_table = owner_process.GetHandleTable(); auto& handle_table = owner_process.GetHandleTable();

View file

@ -18,7 +18,7 @@
#include "core/hle/ipc.h" #include "core/hle/ipc.h"
#include "core/hle/kernel/svc_common.h" #include "core/hle/kernel/svc_common.h"
union ResultCode; union Result;
namespace Core::Memory { namespace Core::Memory {
class Memory; class Memory;
@ -71,9 +71,9 @@ public:
* it should be used to differentiate which client (As in ClientSession) we're answering to. * it should be used to differentiate which client (As in ClientSession) we're answering to.
* TODO(Subv): Use a wrapper structure to hold all the information relevant to * TODO(Subv): Use a wrapper structure to hold all the information relevant to
* this request (ServerSession, Originator thread, Translated command buffer, etc). * this request (ServerSession, Originator thread, Translated command buffer, etc).
* @returns ResultCode the result code of the translate operation. * @returns Result the result code of the translate operation.
*/ */
virtual ResultCode HandleSyncRequest(Kernel::KServerSession& session, virtual Result HandleSyncRequest(Kernel::KServerSession& session,
Kernel::HLERequestContext& context) = 0; Kernel::HLERequestContext& context) = 0;
/** /**
@ -212,11 +212,10 @@ public:
} }
/// Populates this context with data from the requesting process/thread. /// Populates this context with data from the requesting process/thread.
ResultCode PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, Result PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, u32_le* src_cmdbuf);
u32_le* src_cmdbuf);
/// Writes data from this context back to the requesting process/thread. /// Writes data from this context back to the requesting process/thread.
ResultCode WriteToOutgoingCommandBuffer(KThread& requesting_thread); Result WriteToOutgoingCommandBuffer(KThread& requesting_thread);
u32_le GetHipcCommand() const { u32_le GetHipcCommand() const {
return command; return command;

View file

@ -90,8 +90,7 @@ public:
explicit ThreadQueueImplForKAddressArbiter(KernelCore& kernel_, KAddressArbiter::ThreadTree* t) explicit ThreadQueueImplForKAddressArbiter(KernelCore& kernel_, KAddressArbiter::ThreadTree* t)
: KThreadQueue(kernel_), m_tree(t) {} : KThreadQueue(kernel_), m_tree(t) {}
void CancelWait(KThread* waiting_thread, ResultCode wait_result, void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
bool cancel_timer_task) override {
// If the thread is waiting on an address arbiter, remove it from the tree. // If the thread is waiting on an address arbiter, remove it from the tree.
if (waiting_thread->IsWaitingForAddressArbiter()) { if (waiting_thread->IsWaitingForAddressArbiter()) {
m_tree->erase(m_tree->iterator_to(*waiting_thread)); m_tree->erase(m_tree->iterator_to(*waiting_thread));
@ -108,7 +107,7 @@ private:
} // namespace } // namespace
ResultCode KAddressArbiter::Signal(VAddr addr, s32 count) { Result KAddressArbiter::Signal(VAddr addr, s32 count) {
// Perform signaling. // Perform signaling.
s32 num_waiters{}; s32 num_waiters{};
{ {
@ -131,7 +130,7 @@ ResultCode KAddressArbiter::Signal(VAddr addr, s32 count) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count) { Result KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count) {
// Perform signaling. // Perform signaling.
s32 num_waiters{}; s32 num_waiters{};
{ {
@ -164,7 +163,7 @@ ResultCode KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32
return ResultSuccess; return ResultSuccess;
} }
ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count) { Result KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count) {
// Perform signaling. // Perform signaling.
s32 num_waiters{}; s32 num_waiters{};
{ {
@ -232,7 +231,7 @@ ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32
return ResultSuccess; return ResultSuccess;
} }
ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout) { Result KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout) {
// Prepare to wait. // Prepare to wait.
KThread* cur_thread = GetCurrentThreadPointer(kernel); KThread* cur_thread = GetCurrentThreadPointer(kernel);
ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree)); ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree));
@ -285,7 +284,7 @@ ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement
return cur_thread->GetWaitResult(); return cur_thread->GetWaitResult();
} }
ResultCode KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { Result KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) {
// Prepare to wait. // Prepare to wait.
KThread* cur_thread = GetCurrentThreadPointer(kernel); KThread* cur_thread = GetCurrentThreadPointer(kernel);
ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree)); ThreadQueueImplForKAddressArbiter wait_queue(kernel, std::addressof(thread_tree));

View file

@ -8,7 +8,7 @@
#include "core/hle/kernel/k_condition_variable.h" #include "core/hle/kernel/k_condition_variable.h"
#include "core/hle/kernel/svc_types.h" #include "core/hle/kernel/svc_types.h"
union ResultCode; union Result;
namespace Core { namespace Core {
class System; class System;
@ -25,8 +25,7 @@ public:
explicit KAddressArbiter(Core::System& system_); explicit KAddressArbiter(Core::System& system_);
~KAddressArbiter(); ~KAddressArbiter();
[[nodiscard]] ResultCode SignalToAddress(VAddr addr, Svc::SignalType type, s32 value, [[nodiscard]] Result SignalToAddress(VAddr addr, Svc::SignalType type, s32 value, s32 count) {
s32 count) {
switch (type) { switch (type) {
case Svc::SignalType::Signal: case Svc::SignalType::Signal:
return Signal(addr, count); return Signal(addr, count);
@ -39,7 +38,7 @@ public:
return ResultUnknown; return ResultUnknown;
} }
[[nodiscard]] ResultCode WaitForAddress(VAddr addr, Svc::ArbitrationType type, s32 value, [[nodiscard]] Result WaitForAddress(VAddr addr, Svc::ArbitrationType type, s32 value,
s64 timeout) { s64 timeout) {
switch (type) { switch (type) {
case Svc::ArbitrationType::WaitIfLessThan: case Svc::ArbitrationType::WaitIfLessThan:
@ -54,11 +53,11 @@ public:
} }
private: private:
[[nodiscard]] ResultCode Signal(VAddr addr, s32 count); [[nodiscard]] Result Signal(VAddr addr, s32 count);
[[nodiscard]] ResultCode SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count); [[nodiscard]] Result SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 count);
[[nodiscard]] ResultCode SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count); [[nodiscard]] Result SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 value, s32 count);
[[nodiscard]] ResultCode WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout); [[nodiscard]] Result WaitIfLessThan(VAddr addr, s32 value, bool decrement, s64 timeout);
[[nodiscard]] ResultCode WaitIfEqual(VAddr addr, s32 value, s64 timeout); [[nodiscard]] Result WaitIfEqual(VAddr addr, s32 value, s64 timeout);
ThreadTree thread_tree; ThreadTree thread_tree;

View file

@ -59,7 +59,7 @@ bool KClientPort::IsSignaled() const {
return num_sessions < max_sessions; return num_sessions < max_sessions;
} }
ResultCode KClientPort::CreateSession(KClientSession** out, Result KClientPort::CreateSession(KClientSession** out,
std::shared_ptr<SessionRequestManager> session_manager) { std::shared_ptr<SessionRequestManager> session_manager) {
// Reserve a new session from the resource limit. // Reserve a new session from the resource limit.
KScopedResourceReservation session_reservation(kernel.CurrentProcess()->GetResourceLimit(), KScopedResourceReservation session_reservation(kernel.CurrentProcess()->GetResourceLimit(),

View file

@ -53,7 +53,7 @@ public:
void Destroy() override; void Destroy() override;
bool IsSignaled() const override; bool IsSignaled() const override;
ResultCode CreateSession(KClientSession** out, Result CreateSession(KClientSession** out,
std::shared_ptr<SessionRequestManager> session_manager = nullptr); std::shared_ptr<SessionRequestManager> session_manager = nullptr);
private: private:

View file

@ -21,7 +21,7 @@ void KClientSession::Destroy() {
void KClientSession::OnServerClosed() {} void KClientSession::OnServerClosed() {}
ResultCode KClientSession::SendSyncRequest(KThread* thread, Core::Memory::Memory& memory, Result KClientSession::SendSyncRequest(KThread* thread, Core::Memory::Memory& memory,
Core::Timing::CoreTiming& core_timing) { Core::Timing::CoreTiming& core_timing) {
// Signal the server session that new data is available // Signal the server session that new data is available
return parent->GetServerSession().HandleSyncRequest(thread, memory, core_timing); return parent->GetServerSession().HandleSyncRequest(thread, memory, core_timing);

View file

@ -9,7 +9,7 @@
#include "core/hle/kernel/slab_helpers.h" #include "core/hle/kernel/slab_helpers.h"
#include "core/hle/result.h" #include "core/hle/result.h"
union ResultCode; union Result;
namespace Core::Memory { namespace Core::Memory {
class Memory; class Memory;
@ -46,7 +46,7 @@ public:
return parent; return parent;
} }
ResultCode SendSyncRequest(KThread* thread, Core::Memory::Memory& memory, Result SendSyncRequest(KThread* thread, Core::Memory::Memory& memory,
Core::Timing::CoreTiming& core_timing); Core::Timing::CoreTiming& core_timing);
void OnServerClosed(); void OnServerClosed();

View file

@ -19,7 +19,7 @@ namespace Kernel {
KCodeMemory::KCodeMemory(KernelCore& kernel_) KCodeMemory::KCodeMemory(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel_}, m_lock(kernel_) {} : KAutoObjectWithSlabHeapAndContainer{kernel_}, m_lock(kernel_) {}
ResultCode KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) { Result KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr, size_t size) {
// Set members. // Set members.
m_owner = kernel.CurrentProcess(); m_owner = kernel.CurrentProcess();
@ -62,7 +62,7 @@ void KCodeMemory::Finalize() {
m_owner->Close(); m_owner->Close();
} }
ResultCode KCodeMemory::Map(VAddr address, size_t size) { Result KCodeMemory::Map(VAddr address, size_t size) {
// Validate the size. // Validate the size.
R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize); R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize);
@ -82,7 +82,7 @@ ResultCode KCodeMemory::Map(VAddr address, size_t size) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KCodeMemory::Unmap(VAddr address, size_t size) { Result KCodeMemory::Unmap(VAddr address, size_t size) {
// Validate the size. // Validate the size.
R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize); R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize);
@ -99,7 +99,7 @@ ResultCode KCodeMemory::Unmap(VAddr address, size_t size) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KCodeMemory::MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm) { Result KCodeMemory::MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm) {
// Validate the size. // Validate the size.
R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize); R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize);
@ -133,7 +133,7 @@ ResultCode KCodeMemory::MapToOwner(VAddr address, size_t size, Svc::MemoryPermis
return ResultSuccess; return ResultSuccess;
} }
ResultCode KCodeMemory::UnmapFromOwner(VAddr address, size_t size) { Result KCodeMemory::UnmapFromOwner(VAddr address, size_t size) {
// Validate the size. // Validate the size.
R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize); R_UNLESS(m_page_group.GetNumPages() == Common::DivideUp(size, PageSize), ResultInvalidSize);

View file

@ -29,13 +29,13 @@ class KCodeMemory final
public: public:
explicit KCodeMemory(KernelCore& kernel_); explicit KCodeMemory(KernelCore& kernel_);
ResultCode Initialize(Core::DeviceMemory& device_memory, VAddr address, size_t size); Result Initialize(Core::DeviceMemory& device_memory, VAddr address, size_t size);
void Finalize(); void Finalize();
ResultCode Map(VAddr address, size_t size); Result Map(VAddr address, size_t size);
ResultCode Unmap(VAddr address, size_t size); Result Unmap(VAddr address, size_t size);
ResultCode MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm); Result MapToOwner(VAddr address, size_t size, Svc::MemoryPermission perm);
ResultCode UnmapFromOwner(VAddr address, size_t size); Result UnmapFromOwner(VAddr address, size_t size);
bool IsInitialized() const { bool IsInitialized() const {
return m_is_initialized; return m_is_initialized;

View file

@ -61,8 +61,7 @@ public:
explicit ThreadQueueImplForKConditionVariableWaitForAddress(KernelCore& kernel_) explicit ThreadQueueImplForKConditionVariableWaitForAddress(KernelCore& kernel_)
: KThreadQueue(kernel_) {} : KThreadQueue(kernel_) {}
void CancelWait(KThread* waiting_thread, ResultCode wait_result, void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
bool cancel_timer_task) override {
// Remove the thread as a waiter from its owner. // Remove the thread as a waiter from its owner.
waiting_thread->GetLockOwner()->RemoveWaiter(waiting_thread); waiting_thread->GetLockOwner()->RemoveWaiter(waiting_thread);
@ -80,8 +79,7 @@ public:
KernelCore& kernel_, KConditionVariable::ThreadTree* t) KernelCore& kernel_, KConditionVariable::ThreadTree* t)
: KThreadQueue(kernel_), m_tree(t) {} : KThreadQueue(kernel_), m_tree(t) {}
void CancelWait(KThread* waiting_thread, ResultCode wait_result, void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
bool cancel_timer_task) override {
// Remove the thread as a waiter from its owner. // Remove the thread as a waiter from its owner.
if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) { if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) {
owner->RemoveWaiter(waiting_thread); owner->RemoveWaiter(waiting_thread);
@ -105,7 +103,7 @@ KConditionVariable::KConditionVariable(Core::System& system_)
KConditionVariable::~KConditionVariable() = default; KConditionVariable::~KConditionVariable() = default;
ResultCode KConditionVariable::SignalToAddress(VAddr addr) { Result KConditionVariable::SignalToAddress(VAddr addr) {
KThread* owner_thread = GetCurrentThreadPointer(kernel); KThread* owner_thread = GetCurrentThreadPointer(kernel);
// Signal the address. // Signal the address.
@ -126,7 +124,7 @@ ResultCode KConditionVariable::SignalToAddress(VAddr addr) {
} }
// Write the value to userspace. // Write the value to userspace.
ResultCode result{ResultSuccess}; Result result{ResultSuccess};
if (WriteToUser(system, addr, std::addressof(next_value))) [[likely]] { if (WriteToUser(system, addr, std::addressof(next_value))) [[likely]] {
result = ResultSuccess; result = ResultSuccess;
} else { } else {
@ -146,7 +144,7 @@ ResultCode KConditionVariable::SignalToAddress(VAddr addr) {
} }
} }
ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value) { Result KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 value) {
KThread* cur_thread = GetCurrentThreadPointer(kernel); KThread* cur_thread = GetCurrentThreadPointer(kernel);
ThreadQueueImplForKConditionVariableWaitForAddress wait_queue(kernel); ThreadQueueImplForKConditionVariableWaitForAddress wait_queue(kernel);
@ -261,7 +259,7 @@ void KConditionVariable::Signal(u64 cv_key, s32 count) {
} }
} }
ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) { Result KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) {
// Prepare to wait. // Prepare to wait.
KThread* cur_thread = GetCurrentThreadPointer(kernel); KThread* cur_thread = GetCurrentThreadPointer(kernel);
ThreadQueueImplForKConditionVariableWaitConditionVariable wait_queue( ThreadQueueImplForKConditionVariableWaitConditionVariable wait_queue(

View file

@ -25,12 +25,12 @@ public:
~KConditionVariable(); ~KConditionVariable();
// Arbitration // Arbitration
[[nodiscard]] ResultCode SignalToAddress(VAddr addr); [[nodiscard]] Result SignalToAddress(VAddr addr);
[[nodiscard]] ResultCode WaitForAddress(Handle handle, VAddr addr, u32 value); [[nodiscard]] Result WaitForAddress(Handle handle, VAddr addr, u32 value);
// Condition variable // Condition variable
void Signal(u64 cv_key, s32 count); void Signal(u64 cv_key, s32 count);
[[nodiscard]] ResultCode Wait(VAddr addr, u64 key, u32 value, s64 timeout); [[nodiscard]] Result Wait(VAddr addr, u64 key, u32 value, s64 timeout);
private: private:
void SignalImpl(KThread* thread); void SignalImpl(KThread* thread);

View file

@ -8,7 +8,7 @@ namespace Kernel {
KHandleTable::KHandleTable(KernelCore& kernel_) : kernel{kernel_} {} KHandleTable::KHandleTable(KernelCore& kernel_) : kernel{kernel_} {}
KHandleTable::~KHandleTable() = default; KHandleTable::~KHandleTable() = default;
ResultCode KHandleTable::Finalize() { Result KHandleTable::Finalize() {
// Get the table and clear our record of it. // Get the table and clear our record of it.
u16 saved_table_size = 0; u16 saved_table_size = 0;
{ {
@ -62,7 +62,7 @@ bool KHandleTable::Remove(Handle handle) {
return true; return true;
} }
ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj) { Result KHandleTable::Add(Handle* out_handle, KAutoObject* obj) {
KScopedDisableDispatch dd(kernel); KScopedDisableDispatch dd(kernel);
KScopedSpinLock lk(m_lock); KScopedSpinLock lk(m_lock);
@ -85,7 +85,7 @@ ResultCode KHandleTable::Add(Handle* out_handle, KAutoObject* obj) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KHandleTable::Reserve(Handle* out_handle) { Result KHandleTable::Reserve(Handle* out_handle) {
KScopedDisableDispatch dd(kernel); KScopedDisableDispatch dd(kernel);
KScopedSpinLock lk(m_lock); KScopedSpinLock lk(m_lock);

View file

@ -30,7 +30,7 @@ public:
explicit KHandleTable(KernelCore& kernel_); explicit KHandleTable(KernelCore& kernel_);
~KHandleTable(); ~KHandleTable();
ResultCode Initialize(s32 size) { Result Initialize(s32 size) {
R_UNLESS(size <= static_cast<s32>(MaxTableSize), ResultOutOfMemory); R_UNLESS(size <= static_cast<s32>(MaxTableSize), ResultOutOfMemory);
// Initialize all fields. // Initialize all fields.
@ -60,7 +60,7 @@ public:
return m_max_count; return m_max_count;
} }
ResultCode Finalize(); Result Finalize();
bool Remove(Handle handle); bool Remove(Handle handle);
template <typename T = KAutoObject> template <typename T = KAutoObject>
@ -100,10 +100,10 @@ public:
return this->template GetObjectWithoutPseudoHandle<T>(handle); return this->template GetObjectWithoutPseudoHandle<T>(handle);
} }
ResultCode Reserve(Handle* out_handle); Result Reserve(Handle* out_handle);
void Unreserve(Handle handle); void Unreserve(Handle handle);
ResultCode Add(Handle* out_handle, KAutoObject* obj); Result Add(Handle* out_handle, KAutoObject* obj);
void Register(Handle handle, KAutoObject* obj); void Register(Handle handle, KAutoObject* obj);
template <typename T> template <typename T>

View file

@ -17,8 +17,7 @@ public:
bool term) bool term)
: KThreadQueue(kernel_), m_wait_list(wl), m_allow_terminating_thread(term) {} : KThreadQueue(kernel_), m_wait_list(wl), m_allow_terminating_thread(term) {}
void CancelWait(KThread* waiting_thread, ResultCode wait_result, void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
bool cancel_timer_task) override {
// Only process waits if we're allowed to. // Only process waits if we're allowed to.
if (ResultTerminationRequested == wait_result && m_allow_terminating_thread) { if (ResultTerminationRequested == wait_result && m_allow_terminating_thread) {
return; return;

View file

@ -15,8 +15,7 @@ class ThreadQueueImplForKLightLock final : public KThreadQueue {
public: public:
explicit ThreadQueueImplForKLightLock(KernelCore& kernel_) : KThreadQueue(kernel_) {} explicit ThreadQueueImplForKLightLock(KernelCore& kernel_) : KThreadQueue(kernel_) {}
void CancelWait(KThread* waiting_thread, ResultCode wait_result, void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
bool cancel_timer_task) override {
// Remove the thread as a waiter from its owner. // Remove the thread as a waiter from its owner.
if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) { if (KThread* owner = waiting_thread->GetLockOwner(); owner != nullptr) {
owner->RemoveWaiter(waiting_thread); owner->RemoveWaiter(waiting_thread);

View file

@ -208,7 +208,7 @@ PAddr KMemoryManager::AllocateAndOpenContinuous(size_t num_pages, size_t align_p
return allocated_block; return allocated_block;
} }
ResultCode KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool, Result KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool,
Direction dir, bool random) { Direction dir, bool random) {
// Choose a heap based on our page size request. // Choose a heap based on our page size request.
const s32 heap_index = KPageHeap::GetBlockIndex(num_pages); const s32 heap_index = KPageHeap::GetBlockIndex(num_pages);
@ -257,7 +257,7 @@ ResultCode KMemoryManager::AllocatePageGroupImpl(KPageLinkedList* out, size_t nu
return ResultSuccess; return ResultSuccess;
} }
ResultCode KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option) { Result KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option) {
ASSERT(out != nullptr); ASSERT(out != nullptr);
ASSERT(out->GetNumPages() == 0); ASSERT(out->GetNumPages() == 0);
@ -293,8 +293,8 @@ ResultCode KMemoryManager::AllocateAndOpen(KPageLinkedList* out, size_t num_page
return ResultSuccess; return ResultSuccess;
} }
ResultCode KMemoryManager::AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, Result KMemoryManager::AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, u32 option,
u32 option, u64 process_id, u8 fill_pattern) { u64 process_id, u8 fill_pattern) {
ASSERT(out != nullptr); ASSERT(out != nullptr);
ASSERT(out->GetNumPages() == 0); ASSERT(out->GetNumPages() == 0);

View file

@ -65,8 +65,8 @@ public:
} }
PAddr AllocateAndOpenContinuous(size_t num_pages, size_t align_pages, u32 option); PAddr AllocateAndOpenContinuous(size_t num_pages, size_t align_pages, u32 option);
ResultCode AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option); Result AllocateAndOpen(KPageLinkedList* out, size_t num_pages, u32 option);
ResultCode AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, u32 option, Result AllocateAndOpenForProcess(KPageLinkedList* out, size_t num_pages, u32 option,
u64 process_id, u8 fill_pattern); u64 process_id, u8 fill_pattern);
static constexpr size_t MaxManagerCount = 10; static constexpr size_t MaxManagerCount = 10;
@ -262,8 +262,8 @@ private:
} }
} }
ResultCode AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool, Result AllocatePageGroupImpl(KPageLinkedList* out, size_t num_pages, Pool pool, Direction dir,
Direction dir, bool random); bool random);
private: private:
Core::System& system; Core::System& system;

View file

@ -72,7 +72,7 @@ public:
return this_node == nodes.end() && other_node == other.nodes.end(); return this_node == nodes.end() && other_node == other.nodes.end();
} }
ResultCode AddBlock(u64 address, u64 num_pages) { Result AddBlock(u64 address, u64 num_pages) {
if (!num_pages) { if (!num_pages) {
return ResultSuccess; return ResultSuccess;
} }

View file

@ -47,9 +47,9 @@ KPageTable::KPageTable(Core::System& system_)
KPageTable::~KPageTable() = default; KPageTable::~KPageTable() = default;
ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, Result KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr,
bool enable_aslr, VAddr code_addr, VAddr code_addr, std::size_t code_size,
std::size_t code_size, KMemoryManager::Pool pool) { KMemoryManager::Pool pool) {
const auto GetSpaceStart = [this](KAddressSpaceInfo::Type type) { const auto GetSpaceStart = [this](KAddressSpaceInfo::Type type) {
return KAddressSpaceInfo::GetAddressSpaceStart(address_space_width, type); return KAddressSpaceInfo::GetAddressSpaceStart(address_space_width, type);
@ -257,7 +257,7 @@ ResultCode KPageTable::InitializeForProcess(FileSys::ProgramAddressSpaceType as_
return InitializeMemoryLayout(start, end); return InitializeMemoryLayout(start, end);
} }
ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state, Result KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemoryState state,
KMemoryPermission perm) { KMemoryPermission perm) {
const u64 size{num_pages * PageSize}; const u64 size{num_pages * PageSize};
@ -283,7 +283,7 @@ ResultCode KPageTable::MapProcessCode(VAddr addr, std::size_t num_pages, KMemory
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size) { Result KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size) {
// Validate the mapping request. // Validate the mapping request.
R_UNLESS(this->CanContain(dst_address, size, KMemoryState::AliasCode), R_UNLESS(this->CanContain(dst_address, size, KMemoryState::AliasCode),
ResultInvalidMemoryRegion); ResultInvalidMemoryRegion);
@ -344,7 +344,7 @@ ResultCode KPageTable::MapCodeMemory(VAddr dst_address, VAddr src_address, std::
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size, Result KPageTable::UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size,
ICacheInvalidationStrategy icache_invalidation_strategy) { ICacheInvalidationStrategy icache_invalidation_strategy) {
// Validate the mapping request. // Validate the mapping request.
R_UNLESS(this->CanContain(dst_address, size, KMemoryState::AliasCode), R_UNLESS(this->CanContain(dst_address, size, KMemoryState::AliasCode),
@ -489,7 +489,7 @@ VAddr KPageTable::FindFreeArea(VAddr region_start, std::size_t region_num_pages,
return address; return address;
} }
ResultCode KPageTable::MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages) { Result KPageTable::MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages) {
ASSERT(this->IsLockedByCurrentThread()); ASSERT(this->IsLockedByCurrentThread());
const size_t size = num_pages * PageSize; const size_t size = num_pages * PageSize;
@ -630,8 +630,8 @@ bool KPageTable::IsValidPageGroup(const KPageLinkedList& pg_ll, VAddr addr, size
return cur_block_address == cur_addr && cur_block_pages == (cur_size / PageSize); return cur_block_address == cur_addr && cur_block_pages == (cur_size / PageSize);
} }
ResultCode KPageTable::UnmapProcessMemory(VAddr dst_addr, std::size_t size, Result KPageTable::UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table,
KPageTable& src_page_table, VAddr src_addr) { VAddr src_addr) {
KScopedLightLock lk(general_lock); KScopedLightLock lk(general_lock);
const std::size_t num_pages{size / PageSize}; const std::size_t num_pages{size / PageSize};
@ -660,7 +660,7 @@ ResultCode KPageTable::UnmapProcessMemory(VAddr dst_addr, std::size_t size,
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) { Result KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) {
// Lock the physical memory lock. // Lock the physical memory lock.
KScopedLightLock map_phys_mem_lk(map_physical_memory_lock); KScopedLightLock map_phys_mem_lk(map_physical_memory_lock);
@ -903,7 +903,7 @@ ResultCode KPageTable::MapPhysicalMemory(VAddr address, std::size_t size) {
} }
} }
ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) { Result KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) {
// Lock the physical memory lock. // Lock the physical memory lock.
KScopedLightLock map_phys_mem_lk(map_physical_memory_lock); KScopedLightLock map_phys_mem_lk(map_physical_memory_lock);
@ -1134,7 +1134,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { Result KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) {
KScopedLightLock lk(general_lock); KScopedLightLock lk(general_lock);
KMemoryState src_state{}; KMemoryState src_state{};
@ -1173,7 +1173,7 @@ ResultCode KPageTable::MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t siz
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) { Result KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size) {
KScopedLightLock lk(general_lock); KScopedLightLock lk(general_lock);
KMemoryState src_state{}; KMemoryState src_state{};
@ -1215,7 +1215,7 @@ ResultCode KPageTable::UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t s
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_list, Result KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_list,
KMemoryPermission perm) { KMemoryPermission perm) {
ASSERT(this->IsLockedByCurrentThread()); ASSERT(this->IsLockedByCurrentThread());
@ -1239,8 +1239,8 @@ ResultCode KPageTable::MapPages(VAddr addr, const KPageLinkedList& page_linked_l
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::MapPages(VAddr address, KPageLinkedList& page_linked_list, Result KPageTable::MapPages(VAddr address, KPageLinkedList& page_linked_list, KMemoryState state,
KMemoryState state, KMemoryPermission perm) { KMemoryPermission perm) {
// Check that the map is in range. // Check that the map is in range.
const std::size_t num_pages{page_linked_list.GetNumPages()}; const std::size_t num_pages{page_linked_list.GetNumPages()};
const std::size_t size{num_pages * PageSize}; const std::size_t size{num_pages * PageSize};
@ -1263,7 +1263,7 @@ ResultCode KPageTable::MapPages(VAddr address, KPageLinkedList& page_linked_list
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, Result KPageTable::MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment,
PAddr phys_addr, bool is_pa_valid, VAddr region_start, PAddr phys_addr, bool is_pa_valid, VAddr region_start,
std::size_t region_num_pages, KMemoryState state, std::size_t region_num_pages, KMemoryState state,
KMemoryPermission perm) { KMemoryPermission perm) {
@ -1303,7 +1303,7 @@ ResultCode KPageTable::MapPages(VAddr* out_addr, std::size_t num_pages, std::siz
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list) { Result KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list) {
ASSERT(this->IsLockedByCurrentThread()); ASSERT(this->IsLockedByCurrentThread());
VAddr cur_addr{addr}; VAddr cur_addr{addr};
@ -1321,8 +1321,7 @@ ResultCode KPageTable::UnmapPages(VAddr addr, const KPageLinkedList& page_linked
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, Result KPageTable::UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state) {
KMemoryState state) {
// Check that the unmap is in range. // Check that the unmap is in range.
const std::size_t num_pages{page_linked_list.GetNumPages()}; const std::size_t num_pages{page_linked_list.GetNumPages()};
const std::size_t size{num_pages * PageSize}; const std::size_t size{num_pages * PageSize};
@ -1345,7 +1344,7 @@ ResultCode KPageTable::UnmapPages(VAddr addr, KPageLinkedList& page_linked_list,
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state) { Result KPageTable::UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state) {
// Check that the unmap is in range. // Check that the unmap is in range.
const std::size_t size = num_pages * PageSize; const std::size_t size = num_pages * PageSize;
R_UNLESS(this->Contains(address, size), ResultInvalidCurrentMemory); R_UNLESS(this->Contains(address, size), ResultInvalidCurrentMemory);
@ -1369,7 +1368,7 @@ ResultCode KPageTable::UnmapPages(VAddr address, std::size_t num_pages, KMemoryS
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages, Result KPageTable::MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages,
KMemoryState state_mask, KMemoryState state, KMemoryState state_mask, KMemoryState state,
KMemoryPermission perm_mask, KMemoryPermission perm, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryAttribute attr_mask, KMemoryAttribute attr) { KMemoryAttribute attr_mask, KMemoryAttribute attr) {
@ -1394,7 +1393,7 @@ ResultCode KPageTable::MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address,
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::SetProcessMemoryPermission(VAddr addr, std::size_t size, Result KPageTable::SetProcessMemoryPermission(VAddr addr, std::size_t size,
Svc::MemoryPermission svc_perm) { Svc::MemoryPermission svc_perm) {
const size_t num_pages = size / PageSize; const size_t num_pages = size / PageSize;
@ -1467,7 +1466,7 @@ KMemoryInfo KPageTable::QueryInfo(VAddr addr) {
return QueryInfoImpl(addr); return QueryInfoImpl(addr);
} }
ResultCode KPageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm) { Result KPageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm) {
KScopedLightLock lk(general_lock); KScopedLightLock lk(general_lock);
KMemoryState state{}; KMemoryState state{};
@ -1485,7 +1484,7 @@ ResultCode KPageTable::ReserveTransferMemory(VAddr addr, std::size_t size, KMemo
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::ResetTransferMemory(VAddr addr, std::size_t size) { Result KPageTable::ResetTransferMemory(VAddr addr, std::size_t size) {
KScopedLightLock lk(general_lock); KScopedLightLock lk(general_lock);
KMemoryState state{}; KMemoryState state{};
@ -1500,7 +1499,7 @@ ResultCode KPageTable::ResetTransferMemory(VAddr addr, std::size_t size) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::SetMemoryPermission(VAddr addr, std::size_t size, Result KPageTable::SetMemoryPermission(VAddr addr, std::size_t size,
Svc::MemoryPermission svc_perm) { Svc::MemoryPermission svc_perm) {
const size_t num_pages = size / PageSize; const size_t num_pages = size / PageSize;
@ -1528,7 +1527,7 @@ ResultCode KPageTable::SetMemoryPermission(VAddr addr, std::size_t size,
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr) { Result KPageTable::SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr) {
const size_t num_pages = size / PageSize; const size_t num_pages = size / PageSize;
ASSERT((static_cast<KMemoryAttribute>(mask) | KMemoryAttribute::SetMask) == ASSERT((static_cast<KMemoryAttribute>(mask) | KMemoryAttribute::SetMask) ==
KMemoryAttribute::SetMask); KMemoryAttribute::SetMask);
@ -1563,7 +1562,7 @@ ResultCode KPageTable::SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::SetMaxHeapSize(std::size_t size) { Result KPageTable::SetMaxHeapSize(std::size_t size) {
// Lock the table. // Lock the table.
KScopedLightLock lk(general_lock); KScopedLightLock lk(general_lock);
@ -1575,7 +1574,7 @@ ResultCode KPageTable::SetMaxHeapSize(std::size_t size) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::SetHeapSize(VAddr* out, std::size_t size) { Result KPageTable::SetHeapSize(VAddr* out, std::size_t size) {
// Lock the physical memory mutex. // Lock the physical memory mutex.
KScopedLightLock map_phys_mem_lk(map_physical_memory_lock); KScopedLightLock map_phys_mem_lk(map_physical_memory_lock);
@ -1729,11 +1728,11 @@ ResultVal<VAddr> KPageTable::AllocateAndMapMemory(std::size_t needed_num_pages,
return addr; return addr;
} }
ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) { Result KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) {
KScopedLightLock lk(general_lock); KScopedLightLock lk(general_lock);
KMemoryPermission perm{}; KMemoryPermission perm{};
if (const ResultCode result{CheckMemoryState( if (const Result result{CheckMemoryState(
nullptr, &perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanChangeAttribute, nullptr, &perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanChangeAttribute,
KMemoryState::FlagCanChangeAttribute, KMemoryPermission::None, KMemoryPermission::None, KMemoryState::FlagCanChangeAttribute, KMemoryPermission::None, KMemoryPermission::None,
KMemoryAttribute::LockedAndIpcLocked, KMemoryAttribute::None, KMemoryAttribute::LockedAndIpcLocked, KMemoryAttribute::None,
@ -1752,11 +1751,11 @@ ResultCode KPageTable::LockForDeviceAddressSpace(VAddr addr, std::size_t size) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size) { Result KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size) {
KScopedLightLock lk(general_lock); KScopedLightLock lk(general_lock);
KMemoryPermission perm{}; KMemoryPermission perm{};
if (const ResultCode result{CheckMemoryState( if (const Result result{CheckMemoryState(
nullptr, &perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanChangeAttribute, nullptr, &perm, nullptr, nullptr, addr, size, KMemoryState::FlagCanChangeAttribute,
KMemoryState::FlagCanChangeAttribute, KMemoryPermission::None, KMemoryPermission::None, KMemoryState::FlagCanChangeAttribute, KMemoryPermission::None, KMemoryPermission::None,
KMemoryAttribute::LockedAndIpcLocked, KMemoryAttribute::None, KMemoryAttribute::LockedAndIpcLocked, KMemoryAttribute::None,
@ -1775,7 +1774,7 @@ ResultCode KPageTable::UnlockForDeviceAddressSpace(VAddr addr, std::size_t size)
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size) { Result KPageTable::LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size) {
return this->LockMemoryAndOpen( return this->LockMemoryAndOpen(
out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory, out, nullptr, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory,
KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All, KMemoryPermission::All, KMemoryPermission::UserReadWrite, KMemoryAttribute::All,
@ -1785,15 +1784,14 @@ ResultCode KPageTable::LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::
KMemoryAttribute::Locked); KMemoryAttribute::Locked);
} }
ResultCode KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, Result KPageTable::UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageLinkedList& pg) {
const KPageLinkedList& pg) {
return this->UnlockMemory( return this->UnlockMemory(
addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory, addr, size, KMemoryState::FlagCanCodeMemory, KMemoryState::FlagCanCodeMemory,
KMemoryPermission::None, KMemoryPermission::None, KMemoryAttribute::All, KMemoryPermission::None, KMemoryPermission::None, KMemoryAttribute::All,
KMemoryAttribute::Locked, KMemoryPermission::UserReadWrite, KMemoryAttribute::Locked, &pg); KMemoryAttribute::Locked, KMemoryPermission::UserReadWrite, KMemoryAttribute::Locked, &pg);
} }
ResultCode KPageTable::InitializeMemoryLayout(VAddr start, VAddr end) { Result KPageTable::InitializeMemoryLayout(VAddr start, VAddr end) {
block_manager = std::make_unique<KMemoryBlockManager>(start, end); block_manager = std::make_unique<KMemoryBlockManager>(start, end);
return ResultSuccess; return ResultSuccess;
@ -1837,7 +1835,7 @@ VAddr KPageTable::AllocateVirtualMemory(VAddr start, std::size_t region_num_page
IsKernel() ? 1 : 4); IsKernel() ? 1 : 4);
} }
ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group, Result KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group,
OperationType operation) { OperationType operation) {
ASSERT(this->IsLockedByCurrentThread()); ASSERT(this->IsLockedByCurrentThread());
@ -1862,7 +1860,7 @@ ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, const KPageLin
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm, Result KPageTable::Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm,
OperationType operation, PAddr map_addr) { OperationType operation, PAddr map_addr) {
ASSERT(this->IsLockedByCurrentThread()); ASSERT(this->IsLockedByCurrentThread());
@ -2005,7 +2003,7 @@ bool KPageTable::CanContain(VAddr addr, std::size_t size, KMemoryState state) co
} }
} }
ResultCode KPageTable::CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, Result KPageTable::CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask,
KMemoryState state, KMemoryPermission perm_mask, KMemoryState state, KMemoryPermission perm_mask,
KMemoryPermission perm, KMemoryAttribute attr_mask, KMemoryPermission perm, KMemoryAttribute attr_mask,
KMemoryAttribute attr) const { KMemoryAttribute attr) const {
@ -2017,11 +2015,10 @@ ResultCode KPageTable::CheckMemoryState(const KMemoryInfo& info, KMemoryState st
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr, Result KPageTable::CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr,
std::size_t size, KMemoryState state_mask, std::size_t size, KMemoryState state_mask,
KMemoryState state, KMemoryPermission perm_mask, KMemoryState state, KMemoryPermission perm_mask,
KMemoryPermission perm, KMemoryPermission perm, KMemoryAttribute attr_mask,
KMemoryAttribute attr_mask,
KMemoryAttribute attr) const { KMemoryAttribute attr) const {
ASSERT(this->IsLockedByCurrentThread()); ASSERT(this->IsLockedByCurrentThread());
@ -2060,7 +2057,7 @@ ResultCode KPageTable::CheckMemoryStateContiguous(std::size_t* out_blocks_needed
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm, Result KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
KMemoryAttribute* out_attr, std::size_t* out_blocks_needed, KMemoryAttribute* out_attr, std::size_t* out_blocks_needed,
VAddr addr, std::size_t size, KMemoryState state_mask, VAddr addr, std::size_t size, KMemoryState state_mask,
KMemoryState state, KMemoryPermission perm_mask, KMemoryState state, KMemoryPermission perm_mask,
@ -2122,7 +2119,7 @@ ResultCode KPageTable::CheckMemoryState(KMemoryState* out_state, KMemoryPermissi
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr, Result KPageTable::LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr,
size_t size, KMemoryState state_mask, KMemoryState state, size_t size, KMemoryState state_mask, KMemoryState state,
KMemoryPermission perm_mask, KMemoryPermission perm, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryAttribute attr_mask, KMemoryAttribute attr, KMemoryAttribute attr_mask, KMemoryAttribute attr,
@ -2180,7 +2177,7 @@ ResultCode KPageTable::LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_pad
return ResultSuccess; return ResultSuccess;
} }
ResultCode KPageTable::UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask, Result KPageTable::UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask,
KMemoryState state, KMemoryPermission perm_mask, KMemoryState state, KMemoryPermission perm_mask,
KMemoryPermission perm, KMemoryAttribute attr_mask, KMemoryPermission perm, KMemoryAttribute attr_mask,
KMemoryAttribute attr, KMemoryPermission new_perm, KMemoryAttribute attr, KMemoryPermission new_perm,

View file

@ -33,48 +33,46 @@ public:
explicit KPageTable(Core::System& system_); explicit KPageTable(Core::System& system_);
~KPageTable(); ~KPageTable();
ResultCode InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr, Result InitializeForProcess(FileSys::ProgramAddressSpaceType as_type, bool enable_aslr,
VAddr code_addr, std::size_t code_size, VAddr code_addr, std::size_t code_size, KMemoryManager::Pool pool);
KMemoryManager::Pool pool); Result MapProcessCode(VAddr addr, std::size_t pages_count, KMemoryState state,
ResultCode MapProcessCode(VAddr addr, std::size_t pages_count, KMemoryState state,
KMemoryPermission perm); KMemoryPermission perm);
ResultCode MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size); Result MapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size);
ResultCode UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size, Result UnmapCodeMemory(VAddr dst_address, VAddr src_address, std::size_t size,
ICacheInvalidationStrategy icache_invalidation_strategy); ICacheInvalidationStrategy icache_invalidation_strategy);
ResultCode UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table, Result UnmapProcessMemory(VAddr dst_addr, std::size_t size, KPageTable& src_page_table,
VAddr src_addr); VAddr src_addr);
ResultCode MapPhysicalMemory(VAddr addr, std::size_t size); Result MapPhysicalMemory(VAddr addr, std::size_t size);
ResultCode UnmapPhysicalMemory(VAddr addr, std::size_t size); Result UnmapPhysicalMemory(VAddr addr, std::size_t size);
ResultCode MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); Result MapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size);
ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size); Result UnmapMemory(VAddr dst_addr, VAddr src_addr, std::size_t size);
ResultCode MapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state, Result MapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state,
KMemoryPermission perm); KMemoryPermission perm);
ResultCode MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr,
PAddr phys_addr, KMemoryState state, KMemoryPermission perm) { KMemoryState state, KMemoryPermission perm) {
return this->MapPages(out_addr, num_pages, alignment, phys_addr, true, return this->MapPages(out_addr, num_pages, alignment, phys_addr, true,
this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize, this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize,
state, perm); state, perm);
} }
ResultCode UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state); Result UnmapPages(VAddr addr, KPageLinkedList& page_linked_list, KMemoryState state);
ResultCode UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state); Result UnmapPages(VAddr address, std::size_t num_pages, KMemoryState state);
ResultCode SetProcessMemoryPermission(VAddr addr, std::size_t size, Result SetProcessMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission svc_perm);
Svc::MemoryPermission svc_perm);
KMemoryInfo QueryInfo(VAddr addr); KMemoryInfo QueryInfo(VAddr addr);
ResultCode ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm); Result ReserveTransferMemory(VAddr addr, std::size_t size, KMemoryPermission perm);
ResultCode ResetTransferMemory(VAddr addr, std::size_t size); Result ResetTransferMemory(VAddr addr, std::size_t size);
ResultCode SetMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission perm); Result SetMemoryPermission(VAddr addr, std::size_t size, Svc::MemoryPermission perm);
ResultCode SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr); Result SetMemoryAttribute(VAddr addr, std::size_t size, u32 mask, u32 attr);
ResultCode SetMaxHeapSize(std::size_t size); Result SetMaxHeapSize(std::size_t size);
ResultCode SetHeapSize(VAddr* out, std::size_t size); Result SetHeapSize(VAddr* out, std::size_t size);
ResultVal<VAddr> AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align, ResultVal<VAddr> AllocateAndMapMemory(std::size_t needed_num_pages, std::size_t align,
bool is_map_only, VAddr region_start, bool is_map_only, VAddr region_start,
std::size_t region_num_pages, KMemoryState state, std::size_t region_num_pages, KMemoryState state,
KMemoryPermission perm, PAddr map_addr = 0); KMemoryPermission perm, PAddr map_addr = 0);
ResultCode LockForDeviceAddressSpace(VAddr addr, std::size_t size); Result LockForDeviceAddressSpace(VAddr addr, std::size_t size);
ResultCode UnlockForDeviceAddressSpace(VAddr addr, std::size_t size); Result UnlockForDeviceAddressSpace(VAddr addr, std::size_t size);
ResultCode LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size); Result LockForCodeMemory(KPageLinkedList* out, VAddr addr, std::size_t size);
ResultCode UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageLinkedList& pg); Result UnlockForCodeMemory(VAddr addr, std::size_t size, const KPageLinkedList& pg);
ResultCode MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages, Result MakeAndOpenPageGroup(KPageLinkedList* out, VAddr address, size_t num_pages,
KMemoryState state_mask, KMemoryState state, KMemoryState state_mask, KMemoryState state,
KMemoryPermission perm_mask, KMemoryPermission perm, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryAttribute attr_mask, KMemoryAttribute attr); KMemoryAttribute attr_mask, KMemoryAttribute attr);
@ -102,22 +100,21 @@ private:
KMemoryAttribute::IpcLocked | KMemoryAttribute::IpcLocked |
KMemoryAttribute::DeviceShared; KMemoryAttribute::DeviceShared;
ResultCode InitializeMemoryLayout(VAddr start, VAddr end); Result InitializeMemoryLayout(VAddr start, VAddr end);
ResultCode MapPages(VAddr addr, const KPageLinkedList& page_linked_list, Result MapPages(VAddr addr, const KPageLinkedList& page_linked_list, KMemoryPermission perm);
KMemoryPermission perm); Result MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, PAddr phys_addr,
ResultCode MapPages(VAddr* out_addr, std::size_t num_pages, std::size_t alignment, bool is_pa_valid, VAddr region_start, std::size_t region_num_pages,
PAddr phys_addr, bool is_pa_valid, VAddr region_start, KMemoryState state, KMemoryPermission perm);
std::size_t region_num_pages, KMemoryState state, KMemoryPermission perm); Result UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list);
ResultCode UnmapPages(VAddr addr, const KPageLinkedList& page_linked_list);
bool IsRegionMapped(VAddr address, u64 size); bool IsRegionMapped(VAddr address, u64 size);
bool IsRegionContiguous(VAddr addr, u64 size) const; bool IsRegionContiguous(VAddr addr, u64 size) const;
void AddRegionToPages(VAddr start, std::size_t num_pages, KPageLinkedList& page_linked_list); void AddRegionToPages(VAddr start, std::size_t num_pages, KPageLinkedList& page_linked_list);
KMemoryInfo QueryInfoImpl(VAddr addr); KMemoryInfo QueryInfoImpl(VAddr addr);
VAddr AllocateVirtualMemory(VAddr start, std::size_t region_num_pages, u64 needed_num_pages, VAddr AllocateVirtualMemory(VAddr start, std::size_t region_num_pages, u64 needed_num_pages,
std::size_t align); std::size_t align);
ResultCode Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group, Result Operate(VAddr addr, std::size_t num_pages, const KPageLinkedList& page_group,
OperationType operation); OperationType operation);
ResultCode Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm, Result Operate(VAddr addr, std::size_t num_pages, KMemoryPermission perm,
OperationType operation, PAddr map_addr = 0); OperationType operation, PAddr map_addr = 0);
VAddr GetRegionAddress(KMemoryState state) const; VAddr GetRegionAddress(KMemoryState state) const;
std::size_t GetRegionSize(KMemoryState state) const; std::size_t GetRegionSize(KMemoryState state) const;
@ -125,12 +122,11 @@ private:
VAddr FindFreeArea(VAddr region_start, std::size_t region_num_pages, std::size_t num_pages, VAddr FindFreeArea(VAddr region_start, std::size_t region_num_pages, std::size_t num_pages,
std::size_t alignment, std::size_t offset, std::size_t guard_pages); std::size_t alignment, std::size_t offset, std::size_t guard_pages);
ResultCode CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr, Result CheckMemoryStateContiguous(std::size_t* out_blocks_needed, VAddr addr, std::size_t size,
std::size_t size, KMemoryState state_mask, KMemoryState state_mask, KMemoryState state,
KMemoryState state, KMemoryPermission perm_mask, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryPermission perm, KMemoryAttribute attr_mask, KMemoryAttribute attr_mask, KMemoryAttribute attr) const;
KMemoryAttribute attr) const; Result CheckMemoryStateContiguous(VAddr addr, std::size_t size, KMemoryState state_mask,
ResultCode CheckMemoryStateContiguous(VAddr addr, std::size_t size, KMemoryState state_mask,
KMemoryState state, KMemoryPermission perm_mask, KMemoryState state, KMemoryPermission perm_mask,
KMemoryPermission perm, KMemoryAttribute attr_mask, KMemoryPermission perm, KMemoryAttribute attr_mask,
KMemoryAttribute attr) const { KMemoryAttribute attr) const {
@ -138,18 +134,16 @@ private:
perm, attr_mask, attr); perm, attr_mask, attr);
} }
ResultCode CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, Result CheckMemoryState(const KMemoryInfo& info, KMemoryState state_mask, KMemoryState state,
KMemoryState state, KMemoryPermission perm_mask, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryPermission perm, KMemoryAttribute attr_mask, KMemoryAttribute attr_mask, KMemoryAttribute attr) const;
KMemoryAttribute attr) const; Result CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm,
ResultCode CheckMemoryState(KMemoryState* out_state, KMemoryPermission* out_perm, KMemoryAttribute* out_attr, std::size_t* out_blocks_needed, VAddr addr,
KMemoryAttribute* out_attr, std::size_t* out_blocks_needed, std::size_t size, KMemoryState state_mask, KMemoryState state,
VAddr addr, std::size_t size, KMemoryState state_mask, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryState state, KMemoryPermission perm_mask, KMemoryAttribute attr_mask, KMemoryAttribute attr,
KMemoryPermission perm, KMemoryAttribute attr_mask,
KMemoryAttribute attr,
KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const; KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const;
ResultCode CheckMemoryState(std::size_t* out_blocks_needed, VAddr addr, std::size_t size, Result CheckMemoryState(std::size_t* out_blocks_needed, VAddr addr, std::size_t size,
KMemoryState state_mask, KMemoryState state, KMemoryState state_mask, KMemoryState state,
KMemoryPermission perm_mask, KMemoryPermission perm, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryAttribute attr_mask, KMemoryAttribute attr, KMemoryAttribute attr_mask, KMemoryAttribute attr,
@ -157,27 +151,26 @@ private:
return CheckMemoryState(nullptr, nullptr, nullptr, out_blocks_needed, addr, size, return CheckMemoryState(nullptr, nullptr, nullptr, out_blocks_needed, addr, size,
state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr); state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr);
} }
ResultCode CheckMemoryState(VAddr addr, std::size_t size, KMemoryState state_mask, Result CheckMemoryState(VAddr addr, std::size_t size, KMemoryState state_mask,
KMemoryState state, KMemoryPermission perm_mask, KMemoryState state, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryPermission perm, KMemoryAttribute attr_mask, KMemoryAttribute attr_mask, KMemoryAttribute attr,
KMemoryAttribute attr,
KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const { KMemoryAttribute ignore_attr = DefaultMemoryIgnoreAttr) const {
return this->CheckMemoryState(nullptr, addr, size, state_mask, state, perm_mask, perm, return this->CheckMemoryState(nullptr, addr, size, state_mask, state, perm_mask, perm,
attr_mask, attr, ignore_attr); attr_mask, attr, ignore_attr);
} }
ResultCode LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr, size_t size, Result LockMemoryAndOpen(KPageLinkedList* out_pg, PAddr* out_paddr, VAddr addr, size_t size,
KMemoryState state_mask, KMemoryState state, KMemoryState state_mask, KMemoryState state,
KMemoryPermission perm_mask, KMemoryPermission perm, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryAttribute attr_mask, KMemoryAttribute attr, KMemoryAttribute attr_mask, KMemoryAttribute attr,
KMemoryPermission new_perm, KMemoryAttribute lock_attr); KMemoryPermission new_perm, KMemoryAttribute lock_attr);
ResultCode UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask, KMemoryState state, Result UnlockMemory(VAddr addr, size_t size, KMemoryState state_mask, KMemoryState state,
KMemoryPermission perm_mask, KMemoryPermission perm, KMemoryPermission perm_mask, KMemoryPermission perm,
KMemoryAttribute attr_mask, KMemoryAttribute attr, KMemoryAttribute attr_mask, KMemoryAttribute attr,
KMemoryPermission new_perm, KMemoryAttribute lock_attr, KMemoryPermission new_perm, KMemoryAttribute lock_attr,
const KPageLinkedList* pg); const KPageLinkedList* pg);
ResultCode MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages); Result MakePageGroup(KPageLinkedList& pg, VAddr addr, size_t num_pages);
bool IsValidPageGroup(const KPageLinkedList& pg, VAddr addr, size_t num_pages); bool IsValidPageGroup(const KPageLinkedList& pg, VAddr addr, size_t num_pages);
bool IsLockedByCurrentThread() const { bool IsLockedByCurrentThread() const {

View file

@ -50,7 +50,7 @@ bool KPort::IsServerClosed() const {
return state == State::ServerClosed; return state == State::ServerClosed;
} }
ResultCode KPort::EnqueueSession(KServerSession* session) { Result KPort::EnqueueSession(KServerSession* session) {
KScopedSchedulerLock sl{kernel}; KScopedSchedulerLock sl{kernel};
R_UNLESS(state == State::Normal, ResultPortClosed); R_UNLESS(state == State::Normal, ResultPortClosed);

View file

@ -34,7 +34,7 @@ public:
bool IsServerClosed() const; bool IsServerClosed() const;
ResultCode EnqueueSession(KServerSession* session); Result EnqueueSession(KServerSession* session);
KClientPort& GetClientPort() { KClientPort& GetClientPort() {
return client; return client;

View file

@ -67,7 +67,7 @@ void SetupMainThread(Core::System& system, KProcess& owner_process, u32 priority
} }
} // Anonymous namespace } // Anonymous namespace
ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::string process_name, Result KProcess::Initialize(KProcess* process, Core::System& system, std::string process_name,
ProcessType type, KResourceLimit* res_limit) { ProcessType type, KResourceLimit* res_limit) {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
@ -219,7 +219,7 @@ void KProcess::UnpinThread(KThread* thread) {
KScheduler::SetSchedulerUpdateNeeded(kernel); KScheduler::SetSchedulerUpdateNeeded(kernel);
} }
ResultCode KProcess::AddSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr address, Result KProcess::AddSharedMemory(KSharedMemory* shmem, [[maybe_unused]] VAddr address,
[[maybe_unused]] size_t size) { [[maybe_unused]] size_t size) {
// Lock ourselves, to prevent concurrent access. // Lock ourselves, to prevent concurrent access.
KScopedLightLock lk(state_lock); KScopedLightLock lk(state_lock);
@ -284,7 +284,7 @@ void KProcess::UnregisterThread(KThread* thread) {
thread_list.remove(thread); thread_list.remove(thread);
} }
ResultCode KProcess::Reset() { Result KProcess::Reset() {
// Lock the process and the scheduler. // Lock the process and the scheduler.
KScopedLightLock lk(state_lock); KScopedLightLock lk(state_lock);
KScopedSchedulerLock sl{kernel}; KScopedSchedulerLock sl{kernel};
@ -298,7 +298,7 @@ ResultCode KProcess::Reset() {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KProcess::SetActivity(ProcessActivity activity) { Result KProcess::SetActivity(ProcessActivity activity) {
// Lock ourselves and the scheduler. // Lock ourselves and the scheduler.
KScopedLightLock lk{state_lock}; KScopedLightLock lk{state_lock};
KScopedLightLock list_lk{list_lock}; KScopedLightLock list_lk{list_lock};
@ -342,8 +342,7 @@ ResultCode KProcess::SetActivity(ProcessActivity activity) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, Result KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size) {
std::size_t code_size) {
program_id = metadata.GetTitleID(); program_id = metadata.GetTitleID();
ideal_core = metadata.GetMainThreadCore(); ideal_core = metadata.GetMainThreadCore();
is_64bit_process = metadata.Is64BitProgram(); is_64bit_process = metadata.Is64BitProgram();
@ -358,15 +357,15 @@ ResultCode KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata,
return ResultLimitReached; return ResultLimitReached;
} }
// Initialize proces address space // Initialize proces address space
if (const ResultCode result{ if (const Result result{page_table->InitializeForProcess(metadata.GetAddressSpaceType(), false,
page_table->InitializeForProcess(metadata.GetAddressSpaceType(), false, 0x8000000, 0x8000000, code_size,
code_size, KMemoryManager::Pool::Application)}; KMemoryManager::Pool::Application)};
result.IsError()) { result.IsError()) {
return result; return result;
} }
// Map process code region // Map process code region
if (const ResultCode result{page_table->MapProcessCode(page_table->GetCodeRegionStart(), if (const Result result{page_table->MapProcessCode(page_table->GetCodeRegionStart(),
code_size / PageSize, KMemoryState::Code, code_size / PageSize, KMemoryState::Code,
KMemoryPermission::None)}; KMemoryPermission::None)};
result.IsError()) { result.IsError()) {
@ -375,7 +374,7 @@ ResultCode KProcess::LoadFromMetadata(const FileSys::ProgramMetadata& metadata,
// Initialize process capabilities // Initialize process capabilities
const auto& caps{metadata.GetKernelCapabilities()}; const auto& caps{metadata.GetKernelCapabilities()};
if (const ResultCode result{ if (const Result result{
capabilities.InitializeForUserProcess(caps.data(), caps.size(), *page_table)}; capabilities.InitializeForUserProcess(caps.data(), caps.size(), *page_table)};
result.IsError()) { result.IsError()) {
return result; return result;
@ -482,7 +481,7 @@ void KProcess::Finalize() {
KAutoObjectWithSlabHeapAndContainer<KProcess, KWorkerTask>::Finalize(); KAutoObjectWithSlabHeapAndContainer<KProcess, KWorkerTask>::Finalize();
} }
ResultCode KProcess::CreateThreadLocalRegion(VAddr* out) { Result KProcess::CreateThreadLocalRegion(VAddr* out) {
KThreadLocalPage* tlp = nullptr; KThreadLocalPage* tlp = nullptr;
VAddr tlr = 0; VAddr tlr = 0;
@ -533,7 +532,7 @@ ResultCode KProcess::CreateThreadLocalRegion(VAddr* out) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KProcess::DeleteThreadLocalRegion(VAddr addr) { Result KProcess::DeleteThreadLocalRegion(VAddr addr) {
KThreadLocalPage* page_to_free = nullptr; KThreadLocalPage* page_to_free = nullptr;
// Release the region. // Release the region.
@ -664,7 +663,7 @@ void KProcess::ChangeStatus(ProcessStatus new_status) {
NotifyAvailable(); NotifyAvailable();
} }
ResultCode KProcess::AllocateMainThreadStack(std::size_t stack_size) { Result KProcess::AllocateMainThreadStack(std::size_t stack_size) {
ASSERT(stack_size); ASSERT(stack_size);
// The kernel always ensures that the given stack size is page aligned. // The kernel always ensures that the given stack size is page aligned.

View file

@ -110,7 +110,7 @@ public:
static constexpr std::size_t RANDOM_ENTROPY_SIZE = 4; static constexpr std::size_t RANDOM_ENTROPY_SIZE = 4;
static ResultCode Initialize(KProcess* process, Core::System& system, std::string process_name, static Result Initialize(KProcess* process, Core::System& system, std::string process_name,
ProcessType type, KResourceLimit* res_limit); ProcessType type, KResourceLimit* res_limit);
/// Gets a reference to the process' page table. /// Gets a reference to the process' page table.
@ -133,11 +133,11 @@ public:
return handle_table; return handle_table;
} }
ResultCode SignalToAddress(VAddr address) { Result SignalToAddress(VAddr address) {
return condition_var.SignalToAddress(address); return condition_var.SignalToAddress(address);
} }
ResultCode WaitForAddress(Handle handle, VAddr address, u32 tag) { Result WaitForAddress(Handle handle, VAddr address, u32 tag) {
return condition_var.WaitForAddress(handle, address, tag); return condition_var.WaitForAddress(handle, address, tag);
} }
@ -145,16 +145,15 @@ public:
return condition_var.Signal(cv_key, count); return condition_var.Signal(cv_key, count);
} }
ResultCode WaitConditionVariable(VAddr address, u64 cv_key, u32 tag, s64 ns) { Result WaitConditionVariable(VAddr address, u64 cv_key, u32 tag, s64 ns) {
return condition_var.Wait(address, cv_key, tag, ns); return condition_var.Wait(address, cv_key, tag, ns);
} }
ResultCode SignalAddressArbiter(VAddr address, Svc::SignalType signal_type, s32 value, Result SignalAddressArbiter(VAddr address, Svc::SignalType signal_type, s32 value, s32 count) {
s32 count) {
return address_arbiter.SignalToAddress(address, signal_type, value, count); return address_arbiter.SignalToAddress(address, signal_type, value, count);
} }
ResultCode WaitAddressArbiter(VAddr address, Svc::ArbitrationType arb_type, s32 value, Result WaitAddressArbiter(VAddr address, Svc::ArbitrationType arb_type, s32 value,
s64 timeout) { s64 timeout) {
return address_arbiter.WaitForAddress(address, arb_type, value, timeout); return address_arbiter.WaitForAddress(address, arb_type, value, timeout);
} }
@ -322,7 +321,7 @@ public:
/// @pre The process must be in a signaled state. If this is called on a /// @pre The process must be in a signaled state. If this is called on a
/// process instance that is not signaled, ERR_INVALID_STATE will be /// process instance that is not signaled, ERR_INVALID_STATE will be
/// returned. /// returned.
ResultCode Reset(); Result Reset();
/** /**
* Loads process-specifics configuration info with metadata provided * Loads process-specifics configuration info with metadata provided
@ -333,7 +332,7 @@ public:
* @returns ResultSuccess if all relevant metadata was able to be * @returns ResultSuccess if all relevant metadata was able to be
* loaded and parsed. Otherwise, an error code is returned. * loaded and parsed. Otherwise, an error code is returned.
*/ */
ResultCode LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size); Result LoadFromMetadata(const FileSys::ProgramMetadata& metadata, std::size_t code_size);
/** /**
* Starts the main application thread for this process. * Starts the main application thread for this process.
@ -367,7 +366,7 @@ public:
void DoWorkerTaskImpl(); void DoWorkerTaskImpl();
ResultCode SetActivity(ProcessActivity activity); Result SetActivity(ProcessActivity activity);
void PinCurrentThread(s32 core_id); void PinCurrentThread(s32 core_id);
void UnpinCurrentThread(s32 core_id); void UnpinCurrentThread(s32 core_id);
@ -377,17 +376,17 @@ public:
return state_lock; return state_lock;
} }
ResultCode AddSharedMemory(KSharedMemory* shmem, VAddr address, size_t size); Result AddSharedMemory(KSharedMemory* shmem, VAddr address, size_t size);
void RemoveSharedMemory(KSharedMemory* shmem, VAddr address, size_t size); void RemoveSharedMemory(KSharedMemory* shmem, VAddr address, size_t size);
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
// Thread-local storage management // Thread-local storage management
// Marks the next available region as used and returns the address of the slot. // Marks the next available region as used and returns the address of the slot.
[[nodiscard]] ResultCode CreateThreadLocalRegion(VAddr* out); [[nodiscard]] Result CreateThreadLocalRegion(VAddr* out);
// Frees a used TLS slot identified by the given address // Frees a used TLS slot identified by the given address
ResultCode DeleteThreadLocalRegion(VAddr addr); Result DeleteThreadLocalRegion(VAddr addr);
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
// Debug watchpoint management // Debug watchpoint management
@ -423,7 +422,7 @@ private:
void ChangeStatus(ProcessStatus new_status); void ChangeStatus(ProcessStatus new_status);
/// Allocates the main thread stack for the process, given the stack size in bytes. /// Allocates the main thread stack for the process, given the stack size in bytes.
ResultCode AllocateMainThreadStack(std::size_t stack_size); Result AllocateMainThreadStack(std::size_t stack_size);
/// Memory manager for this process /// Memory manager for this process
std::unique_ptr<KPageTable> page_table; std::unique_ptr<KPageTable> page_table;

View file

@ -27,7 +27,7 @@ void KReadableEvent::Destroy() {
} }
} }
ResultCode KReadableEvent::Signal() { Result KReadableEvent::Signal() {
KScopedSchedulerLock lk{kernel}; KScopedSchedulerLock lk{kernel};
if (!is_signaled) { if (!is_signaled) {
@ -38,13 +38,13 @@ ResultCode KReadableEvent::Signal() {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KReadableEvent::Clear() { Result KReadableEvent::Clear() {
Reset(); Reset();
return ResultSuccess; return ResultSuccess;
} }
ResultCode KReadableEvent::Reset() { Result KReadableEvent::Reset() {
KScopedSchedulerLock lk{kernel}; KScopedSchedulerLock lk{kernel};
if (!is_signaled) { if (!is_signaled) {

View file

@ -33,9 +33,9 @@ public:
bool IsSignaled() const override; bool IsSignaled() const override;
void Destroy() override; void Destroy() override;
ResultCode Signal(); Result Signal();
ResultCode Clear(); Result Clear();
ResultCode Reset(); Result Reset();
private: private:
bool is_signaled{}; bool is_signaled{};

View file

@ -73,7 +73,7 @@ s64 KResourceLimit::GetFreeValue(LimitableResource which) const {
return value; return value;
} }
ResultCode KResourceLimit::SetLimitValue(LimitableResource which, s64 value) { Result KResourceLimit::SetLimitValue(LimitableResource which, s64 value) {
const auto index = static_cast<std::size_t>(which); const auto index = static_cast<std::size_t>(which);
KScopedLightLock lk(lock); KScopedLightLock lk(lock);
R_UNLESS(current_values[index] <= value, ResultInvalidState); R_UNLESS(current_values[index] <= value, ResultInvalidState);

View file

@ -8,7 +8,7 @@
#include "core/hle/kernel/k_light_condition_variable.h" #include "core/hle/kernel/k_light_condition_variable.h"
#include "core/hle/kernel/k_light_lock.h" #include "core/hle/kernel/k_light_lock.h"
union ResultCode; union Result;
namespace Core::Timing { namespace Core::Timing {
class CoreTiming; class CoreTiming;
@ -46,7 +46,7 @@ public:
s64 GetPeakValue(LimitableResource which) const; s64 GetPeakValue(LimitableResource which) const;
s64 GetFreeValue(LimitableResource which) const; s64 GetFreeValue(LimitableResource which) const;
ResultCode SetLimitValue(LimitableResource which, s64 value); Result SetLimitValue(LimitableResource which, s64 value);
bool Reserve(LimitableResource which, s64 value); bool Reserve(LimitableResource which, s64 value);
bool Reserve(LimitableResource which, s64 value, s64 timeout); bool Reserve(LimitableResource which, s64 value, s64 timeout);

View file

@ -79,7 +79,7 @@ std::size_t KServerSession::NumDomainRequestHandlers() const {
return manager->DomainHandlerCount(); return manager->DomainHandlerCount();
} }
ResultCode KServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& context) { Result KServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& context) {
if (!context.HasDomainMessageHeader()) { if (!context.HasDomainMessageHeader()) {
return ResultSuccess; return ResultSuccess;
} }
@ -123,7 +123,7 @@ ResultCode KServerSession::HandleDomainSyncRequest(Kernel::HLERequestContext& co
return ResultSuccess; return ResultSuccess;
} }
ResultCode KServerSession::QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory) { Result KServerSession::QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory) {
u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))}; u32* cmd_buf{reinterpret_cast<u32*>(memory.GetPointer(thread->GetTLSAddress()))};
auto context = std::make_shared<HLERequestContext>(kernel, memory, this, thread); auto context = std::make_shared<HLERequestContext>(kernel, memory, this, thread);
@ -143,8 +143,8 @@ ResultCode KServerSession::QueueSyncRequest(KThread* thread, Core::Memory::Memor
return ResultSuccess; return ResultSuccess;
} }
ResultCode KServerSession::CompleteSyncRequest(HLERequestContext& context) { Result KServerSession::CompleteSyncRequest(HLERequestContext& context) {
ResultCode result = ResultSuccess; Result result = ResultSuccess;
// If the session has been converted to a domain, handle the domain request // If the session has been converted to a domain, handle the domain request
if (manager->HasSessionRequestHandler(context)) { if (manager->HasSessionRequestHandler(context)) {
@ -173,7 +173,7 @@ ResultCode KServerSession::CompleteSyncRequest(HLERequestContext& context) {
return result; return result;
} }
ResultCode KServerSession::HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory, Result KServerSession::HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory,
Core::Timing::CoreTiming& core_timing) { Core::Timing::CoreTiming& core_timing) {
return QueueSyncRequest(thread, memory); return QueueSyncRequest(thread, memory);
} }

View file

@ -73,9 +73,9 @@ public:
* @param memory Memory context to handle the sync request under. * @param memory Memory context to handle the sync request under.
* @param core_timing Core timing context to schedule the request event under. * @param core_timing Core timing context to schedule the request event under.
* *
* @returns ResultCode from the operation. * @returns Result from the operation.
*/ */
ResultCode HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory, Result HandleSyncRequest(KThread* thread, Core::Memory::Memory& memory,
Core::Timing::CoreTiming& core_timing); Core::Timing::CoreTiming& core_timing);
/// Adds a new domain request handler to the collection of request handlers within /// Adds a new domain request handler to the collection of request handlers within
@ -103,14 +103,14 @@ public:
private: private:
/// Queues a sync request from the emulated application. /// Queues a sync request from the emulated application.
ResultCode QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory); Result QueueSyncRequest(KThread* thread, Core::Memory::Memory& memory);
/// Completes a sync request from the emulated application. /// Completes a sync request from the emulated application.
ResultCode CompleteSyncRequest(HLERequestContext& context); Result CompleteSyncRequest(HLERequestContext& context);
/// Handles a SyncRequest to a domain, forwarding the request to the proper object or closing an /// Handles a SyncRequest to a domain, forwarding the request to the proper object or closing an
/// object handle. /// object handle.
ResultCode HandleDomainSyncRequest(Kernel::HLERequestContext& context); Result HandleDomainSyncRequest(Kernel::HLERequestContext& context);
/// This session's HLE request handlers /// This session's HLE request handlers
std::shared_ptr<SessionRequestManager> manager; std::shared_ptr<SessionRequestManager> manager;

View file

@ -18,12 +18,11 @@ KSharedMemory::~KSharedMemory() {
kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size); kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size);
} }
ResultCode KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
KPageLinkedList&& page_list_, KPageLinkedList&& page_list_,
Svc::MemoryPermission owner_permission_, Svc::MemoryPermission owner_permission_,
Svc::MemoryPermission user_permission_, Svc::MemoryPermission user_permission_, PAddr physical_address_,
PAddr physical_address_, std::size_t size_, std::size_t size_, std::string name_) {
std::string name_) {
// Set members. // Set members.
owner_process = owner_process_; owner_process = owner_process_;
device_memory = &device_memory_; device_memory = &device_memory_;
@ -67,7 +66,7 @@ void KSharedMemory::Finalize() {
KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize(); KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize();
} }
ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size, Result KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size,
Svc::MemoryPermission permissions) { Svc::MemoryPermission permissions) {
const u64 page_count{(map_size + PageSize - 1) / PageSize}; const u64 page_count{(map_size + PageSize - 1) / PageSize};
@ -86,7 +85,7 @@ ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size
ConvertToKMemoryPermission(permissions)); ConvertToKMemoryPermission(permissions));
} }
ResultCode KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) { Result KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) {
const u64 page_count{(unmap_size + PageSize - 1) / PageSize}; const u64 page_count{(unmap_size + PageSize - 1) / PageSize};
if (page_list.GetNumPages() != page_count) { if (page_list.GetNumPages() != page_count) {

View file

@ -26,7 +26,7 @@ public:
explicit KSharedMemory(KernelCore& kernel_); explicit KSharedMemory(KernelCore& kernel_);
~KSharedMemory() override; ~KSharedMemory() override;
ResultCode Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_, Result Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
KPageLinkedList&& page_list_, Svc::MemoryPermission owner_permission_, KPageLinkedList&& page_list_, Svc::MemoryPermission owner_permission_,
Svc::MemoryPermission user_permission_, PAddr physical_address_, Svc::MemoryPermission user_permission_, PAddr physical_address_,
std::size_t size_, std::string name_); std::size_t size_, std::string name_);
@ -38,7 +38,7 @@ public:
* @param map_size Size of the shared memory block to map * @param map_size Size of the shared memory block to map
* @param permissions Memory block map permissions (specified by SVC field) * @param permissions Memory block map permissions (specified by SVC field)
*/ */
ResultCode Map(KProcess& target_process, VAddr address, std::size_t map_size, Result Map(KProcess& target_process, VAddr address, std::size_t map_size,
Svc::MemoryPermission permissions); Svc::MemoryPermission permissions);
/** /**
@ -47,7 +47,7 @@ public:
* @param address Address in system memory to unmap shared memory block * @param address Address in system memory to unmap shared memory block
* @param unmap_size Size of the shared memory block to unmap * @param unmap_size Size of the shared memory block to unmap
*/ */
ResultCode Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size); Result Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size);
/** /**
* Gets a pointer to the shared memory block * Gets a pointer to the shared memory block

View file

@ -22,7 +22,7 @@ public:
: KThreadQueueWithoutEndWait(kernel_), m_objects(o), m_nodes(n), m_count(c) {} : KThreadQueueWithoutEndWait(kernel_), m_objects(o), m_nodes(n), m_count(c) {}
void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object, void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object,
ResultCode wait_result) override { Result wait_result) override {
// Determine the sync index, and unlink all nodes. // Determine the sync index, and unlink all nodes.
s32 sync_index = -1; s32 sync_index = -1;
for (auto i = 0; i < m_count; ++i) { for (auto i = 0; i < m_count; ++i) {
@ -45,8 +45,7 @@ public:
KThreadQueue::EndWait(waiting_thread, wait_result); KThreadQueue::EndWait(waiting_thread, wait_result);
} }
void CancelWait(KThread* waiting_thread, ResultCode wait_result, void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
bool cancel_timer_task) override {
// Remove all nodes from our list. // Remove all nodes from our list.
for (auto i = 0; i < m_count; ++i) { for (auto i = 0; i < m_count; ++i) {
m_objects[i]->UnlinkNode(std::addressof(m_nodes[i])); m_objects[i]->UnlinkNode(std::addressof(m_nodes[i]));
@ -72,7 +71,7 @@ void KSynchronizationObject::Finalize() {
KAutoObject::Finalize(); KAutoObject::Finalize();
} }
ResultCode KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index, Result KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index,
KSynchronizationObject** objects, const s32 num_objects, KSynchronizationObject** objects, const s32 num_objects,
s64 timeout) { s64 timeout) {
// Allocate space on stack for thread nodes. // Allocate space on stack for thread nodes.
@ -148,7 +147,7 @@ KSynchronizationObject::KSynchronizationObject(KernelCore& kernel_)
KSynchronizationObject::~KSynchronizationObject() = default; KSynchronizationObject::~KSynchronizationObject() = default;
void KSynchronizationObject::NotifyAvailable(ResultCode result) { void KSynchronizationObject::NotifyAvailable(Result result) {
KScopedSchedulerLock sl(kernel); KScopedSchedulerLock sl(kernel);
// If we're not signaled, we've nothing to notify. // If we're not signaled, we've nothing to notify.

View file

@ -24,7 +24,7 @@ public:
KThread* thread{}; KThread* thread{};
}; };
[[nodiscard]] static ResultCode Wait(KernelCore& kernel, s32* out_index, [[nodiscard]] static Result Wait(KernelCore& kernel, s32* out_index,
KSynchronizationObject** objects, const s32 num_objects, KSynchronizationObject** objects, const s32 num_objects,
s64 timeout); s64 timeout);
@ -72,7 +72,7 @@ protected:
virtual void OnFinalizeSynchronizationObject() {} virtual void OnFinalizeSynchronizationObject() {}
void NotifyAvailable(ResultCode result); void NotifyAvailable(Result result);
void NotifyAvailable() { void NotifyAvailable() {
return this->NotifyAvailable(ResultSuccess); return this->NotifyAvailable(ResultSuccess);
} }

View file

@ -80,8 +80,7 @@ public:
explicit ThreadQueueImplForKThreadSetProperty(KernelCore& kernel_, KThread::WaiterList* wl) explicit ThreadQueueImplForKThreadSetProperty(KernelCore& kernel_, KThread::WaiterList* wl)
: KThreadQueue(kernel_), m_wait_list(wl) {} : KThreadQueue(kernel_), m_wait_list(wl) {}
void CancelWait(KThread* waiting_thread, ResultCode wait_result, void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) override {
bool cancel_timer_task) override {
// Remove the thread from the wait list. // Remove the thread from the wait list.
m_wait_list->erase(m_wait_list->iterator_to(*waiting_thread)); m_wait_list->erase(m_wait_list->iterator_to(*waiting_thread));
@ -99,7 +98,7 @@ KThread::KThread(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel_}, activity_pause_lock{kernel_} {} : KAutoObjectWithSlabHeapAndContainer{kernel_}, activity_pause_lock{kernel_} {}
KThread::~KThread() = default; KThread::~KThread() = default;
ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio, Result KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio,
s32 virt_core, KProcess* owner, ThreadType type) { s32 virt_core, KProcess* owner, ThreadType type) {
// Assert parameters are valid. // Assert parameters are valid.
ASSERT((type == ThreadType::Main) || (type == ThreadType::Dummy) || ASSERT((type == ThreadType::Main) || (type == ThreadType::Dummy) ||
@ -245,7 +244,7 @@ ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_s
return ResultSuccess; return ResultSuccess;
} }
ResultCode KThread::InitializeThread(KThread* thread, KThreadFunction func, uintptr_t arg, Result KThread::InitializeThread(KThread* thread, KThreadFunction func, uintptr_t arg,
VAddr user_stack_top, s32 prio, s32 core, KProcess* owner, VAddr user_stack_top, s32 prio, s32 core, KProcess* owner,
ThreadType type, std::function<void(void*)>&& init_func, ThreadType type, std::function<void(void*)>&& init_func,
void* init_func_parameter) { void* init_func_parameter) {
@ -260,27 +259,26 @@ ResultCode KThread::InitializeThread(KThread* thread, KThreadFunction func, uint
return ResultSuccess; return ResultSuccess;
} }
ResultCode KThread::InitializeDummyThread(KThread* thread) { Result KThread::InitializeDummyThread(KThread* thread) {
return thread->Initialize({}, {}, {}, DummyThreadPriority, 3, {}, ThreadType::Dummy); return thread->Initialize({}, {}, {}, DummyThreadPriority, 3, {}, ThreadType::Dummy);
} }
ResultCode KThread::InitializeIdleThread(Core::System& system, KThread* thread, s32 virt_core) { Result KThread::InitializeIdleThread(Core::System& system, KThread* thread, s32 virt_core) {
return InitializeThread(thread, {}, {}, {}, IdleThreadPriority, virt_core, {}, ThreadType::Main, return InitializeThread(thread, {}, {}, {}, IdleThreadPriority, virt_core, {}, ThreadType::Main,
Core::CpuManager::GetIdleThreadStartFunc(), Core::CpuManager::GetIdleThreadStartFunc(),
system.GetCpuManager().GetStartFuncParameter()); system.GetCpuManager().GetStartFuncParameter());
} }
ResultCode KThread::InitializeHighPriorityThread(Core::System& system, KThread* thread, Result KThread::InitializeHighPriorityThread(Core::System& system, KThread* thread,
KThreadFunction func, uintptr_t arg, KThreadFunction func, uintptr_t arg, s32 virt_core) {
s32 virt_core) {
return InitializeThread(thread, func, arg, {}, {}, virt_core, nullptr, ThreadType::HighPriority, return InitializeThread(thread, func, arg, {}, {}, virt_core, nullptr, ThreadType::HighPriority,
Core::CpuManager::GetShutdownThreadStartFunc(), Core::CpuManager::GetShutdownThreadStartFunc(),
system.GetCpuManager().GetStartFuncParameter()); system.GetCpuManager().GetStartFuncParameter());
} }
ResultCode KThread::InitializeUserThread(Core::System& system, KThread* thread, Result KThread::InitializeUserThread(Core::System& system, KThread* thread, KThreadFunction func,
KThreadFunction func, uintptr_t arg, VAddr user_stack_top, uintptr_t arg, VAddr user_stack_top, s32 prio, s32 virt_core,
s32 prio, s32 virt_core, KProcess* owner) { KProcess* owner) {
system.Kernel().GlobalSchedulerContext().AddThread(thread); system.Kernel().GlobalSchedulerContext().AddThread(thread);
return InitializeThread(thread, func, arg, user_stack_top, prio, virt_core, owner, return InitializeThread(thread, func, arg, user_stack_top, prio, virt_core, owner,
ThreadType::User, Core::CpuManager::GetGuestThreadStartFunc(), ThreadType::User, Core::CpuManager::GetGuestThreadStartFunc(),
@ -523,7 +521,7 @@ void KThread::ClearInterruptFlag() {
memory.Write16(tls_address + offsetof(ThreadLocalRegion, interrupt_flag), 0); memory.Write16(tls_address + offsetof(ThreadLocalRegion, interrupt_flag), 0);
} }
ResultCode KThread::GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask) { Result KThread::GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask) {
KScopedSchedulerLock sl{kernel}; KScopedSchedulerLock sl{kernel};
// Get the virtual mask. // Get the virtual mask.
@ -533,7 +531,7 @@ ResultCode KThread::GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KThread::GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask) { Result KThread::GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask) {
KScopedSchedulerLock sl{kernel}; KScopedSchedulerLock sl{kernel};
ASSERT(num_core_migration_disables >= 0); ASSERT(num_core_migration_disables >= 0);
@ -549,7 +547,7 @@ ResultCode KThread::GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_m
return ResultSuccess; return ResultSuccess;
} }
ResultCode KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) { Result KThread::SetCoreMask(s32 core_id_, u64 v_affinity_mask) {
ASSERT(parent != nullptr); ASSERT(parent != nullptr);
ASSERT(v_affinity_mask != 0); ASSERT(v_affinity_mask != 0);
KScopedLightLock lk(activity_pause_lock); KScopedLightLock lk(activity_pause_lock);
@ -761,7 +759,7 @@ void KThread::WaitUntilSuspended() {
} }
} }
ResultCode KThread::SetActivity(Svc::ThreadActivity activity) { Result KThread::SetActivity(Svc::ThreadActivity activity) {
// Lock ourselves. // Lock ourselves.
KScopedLightLock lk(activity_pause_lock); KScopedLightLock lk(activity_pause_lock);
@ -834,7 +832,7 @@ ResultCode KThread::SetActivity(Svc::ThreadActivity activity) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KThread::GetThreadContext3(std::vector<u8>& out) { Result KThread::GetThreadContext3(std::vector<u8>& out) {
// Lock ourselves. // Lock ourselves.
KScopedLightLock lk{activity_pause_lock}; KScopedLightLock lk{activity_pause_lock};
@ -999,7 +997,7 @@ KThread* KThread::RemoveWaiterByKey(s32* out_num_waiters, VAddr key) {
return next_lock_owner; return next_lock_owner;
} }
ResultCode KThread::Run() { Result KThread::Run() {
while (true) { while (true) {
KScopedSchedulerLock lk{kernel}; KScopedSchedulerLock lk{kernel};
@ -1060,7 +1058,7 @@ void KThread::Exit() {
} }
} }
ResultCode KThread::Sleep(s64 timeout) { Result KThread::Sleep(s64 timeout) {
ASSERT(!kernel.GlobalSchedulerContext().IsLocked()); ASSERT(!kernel.GlobalSchedulerContext().IsLocked());
ASSERT(this == GetCurrentThreadPointer(kernel)); ASSERT(this == GetCurrentThreadPointer(kernel));
ASSERT(timeout > 0); ASSERT(timeout > 0);
@ -1116,7 +1114,7 @@ void KThread::BeginWait(KThreadQueue* queue) {
wait_queue = queue; wait_queue = queue;
} }
void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, ResultCode wait_result_) { void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, Result wait_result_) {
// Lock the scheduler. // Lock the scheduler.
KScopedSchedulerLock sl(kernel); KScopedSchedulerLock sl(kernel);
@ -1126,7 +1124,7 @@ void KThread::NotifyAvailable(KSynchronizationObject* signaled_object, ResultCod
} }
} }
void KThread::EndWait(ResultCode wait_result_) { void KThread::EndWait(Result wait_result_) {
// Lock the scheduler. // Lock the scheduler.
KScopedSchedulerLock sl(kernel); KScopedSchedulerLock sl(kernel);
@ -1145,7 +1143,7 @@ void KThread::EndWait(ResultCode wait_result_) {
} }
} }
void KThread::CancelWait(ResultCode wait_result_, bool cancel_timer_task) { void KThread::CancelWait(Result wait_result_, bool cancel_timer_task) {
// Lock the scheduler. // Lock the scheduler.
KScopedSchedulerLock sl(kernel); KScopedSchedulerLock sl(kernel);

View file

@ -176,7 +176,7 @@ public:
void SetBasePriority(s32 value); void SetBasePriority(s32 value);
[[nodiscard]] ResultCode Run(); [[nodiscard]] Result Run();
void Exit(); void Exit();
@ -218,11 +218,11 @@ public:
return synced_index; return synced_index;
} }
constexpr void SetWaitResult(ResultCode wait_res) { constexpr void SetWaitResult(Result wait_res) {
wait_result = wait_res; wait_result = wait_res;
} }
[[nodiscard]] constexpr ResultCode GetWaitResult() const { [[nodiscard]] constexpr Result GetWaitResult() const {
return wait_result; return wait_result;
} }
@ -345,15 +345,15 @@ public:
return physical_affinity_mask; return physical_affinity_mask;
} }
[[nodiscard]] ResultCode GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask); [[nodiscard]] Result GetCoreMask(s32* out_ideal_core, u64* out_affinity_mask);
[[nodiscard]] ResultCode GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask); [[nodiscard]] Result GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask);
[[nodiscard]] ResultCode SetCoreMask(s32 cpu_core_id, u64 v_affinity_mask); [[nodiscard]] Result SetCoreMask(s32 cpu_core_id, u64 v_affinity_mask);
[[nodiscard]] ResultCode SetActivity(Svc::ThreadActivity activity); [[nodiscard]] Result SetActivity(Svc::ThreadActivity activity);
[[nodiscard]] ResultCode Sleep(s64 timeout); [[nodiscard]] Result Sleep(s64 timeout);
[[nodiscard]] s64 GetYieldScheduleCount() const { [[nodiscard]] s64 GetYieldScheduleCount() const {
return schedule_count; return schedule_count;
@ -411,20 +411,19 @@ public:
static void PostDestroy(uintptr_t arg); static void PostDestroy(uintptr_t arg);
[[nodiscard]] static ResultCode InitializeDummyThread(KThread* thread); [[nodiscard]] static Result InitializeDummyThread(KThread* thread);
[[nodiscard]] static ResultCode InitializeIdleThread(Core::System& system, KThread* thread, [[nodiscard]] static Result InitializeIdleThread(Core::System& system, KThread* thread,
s32 virt_core); s32 virt_core);
[[nodiscard]] static ResultCode InitializeHighPriorityThread(Core::System& system, [[nodiscard]] static Result InitializeHighPriorityThread(Core::System& system, KThread* thread,
KThread* thread,
KThreadFunction func,
uintptr_t arg, s32 virt_core);
[[nodiscard]] static ResultCode InitializeUserThread(Core::System& system, KThread* thread,
KThreadFunction func, uintptr_t arg, KThreadFunction func, uintptr_t arg,
VAddr user_stack_top, s32 prio, s32 virt_core);
s32 virt_core, KProcess* owner);
[[nodiscard]] static Result InitializeUserThread(Core::System& system, KThread* thread,
KThreadFunction func, uintptr_t arg,
VAddr user_stack_top, s32 prio, s32 virt_core,
KProcess* owner);
public: public:
struct StackParameters { struct StackParameters {
@ -610,7 +609,7 @@ public:
void RemoveWaiter(KThread* thread); void RemoveWaiter(KThread* thread);
[[nodiscard]] ResultCode GetThreadContext3(std::vector<u8>& out); [[nodiscard]] Result GetThreadContext3(std::vector<u8>& out);
[[nodiscard]] KThread* RemoveWaiterByKey(s32* out_num_waiters, VAddr key); [[nodiscard]] KThread* RemoveWaiterByKey(s32* out_num_waiters, VAddr key);
@ -636,9 +635,9 @@ public:
} }
void BeginWait(KThreadQueue* queue); void BeginWait(KThreadQueue* queue);
void NotifyAvailable(KSynchronizationObject* signaled_object, ResultCode wait_result_); void NotifyAvailable(KSynchronizationObject* signaled_object, Result wait_result_);
void EndWait(ResultCode wait_result_); void EndWait(Result wait_result_);
void CancelWait(ResultCode wait_result_, bool cancel_timer_task); void CancelWait(Result wait_result_, bool cancel_timer_task);
[[nodiscard]] bool HasWaiters() const { [[nodiscard]] bool HasWaiters() const {
return !waiter_list.empty(); return !waiter_list.empty();
@ -724,10 +723,10 @@ private:
void FinishTermination(); void FinishTermination();
[[nodiscard]] ResultCode Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, [[nodiscard]] Result Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top,
s32 prio, s32 virt_core, KProcess* owner, ThreadType type); s32 prio, s32 virt_core, KProcess* owner, ThreadType type);
[[nodiscard]] static ResultCode InitializeThread(KThread* thread, KThreadFunction func, [[nodiscard]] static Result InitializeThread(KThread* thread, KThreadFunction func,
uintptr_t arg, VAddr user_stack_top, s32 prio, uintptr_t arg, VAddr user_stack_top, s32 prio,
s32 core, KProcess* owner, ThreadType type, s32 core, KProcess* owner, ThreadType type,
std::function<void(void*)>&& init_func, std::function<void(void*)>&& init_func,
@ -768,7 +767,7 @@ private:
u32 suspend_request_flags{}; u32 suspend_request_flags{};
u32 suspend_allowed_flags{}; u32 suspend_allowed_flags{};
s32 synced_index{}; s32 synced_index{};
ResultCode wait_result{ResultSuccess}; Result wait_result{ResultSuccess};
s32 base_priority{}; s32 base_priority{};
s32 physical_ideal_core_id{}; s32 physical_ideal_core_id{};
s32 virtual_ideal_core_id{}; s32 virtual_ideal_core_id{};

View file

@ -13,7 +13,7 @@
namespace Kernel { namespace Kernel {
ResultCode KThreadLocalPage::Initialize(KernelCore& kernel, KProcess* process) { Result KThreadLocalPage::Initialize(KernelCore& kernel, KProcess* process) {
// Set that this process owns us. // Set that this process owns us.
m_owner = process; m_owner = process;
m_kernel = &kernel; m_kernel = &kernel;
@ -35,7 +35,7 @@ ResultCode KThreadLocalPage::Initialize(KernelCore& kernel, KProcess* process) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode KThreadLocalPage::Finalize() { Result KThreadLocalPage::Finalize() {
// Get the physical address of the page. // Get the physical address of the page.
const PAddr phys_addr = m_owner->PageTable().GetPhysicalAddr(m_virt_addr); const PAddr phys_addr = m_owner->PageTable().GetPhysicalAddr(m_virt_addr);
ASSERT(phys_addr); ASSERT(phys_addr);

View file

@ -34,8 +34,8 @@ public:
return m_virt_addr; return m_virt_addr;
} }
ResultCode Initialize(KernelCore& kernel, KProcess* process); Result Initialize(KernelCore& kernel, KProcess* process);
ResultCode Finalize(); Result Finalize();
VAddr Reserve(); VAddr Reserve();
void Release(VAddr addr); void Release(VAddr addr);

View file

@ -9,9 +9,9 @@ namespace Kernel {
void KThreadQueue::NotifyAvailable([[maybe_unused]] KThread* waiting_thread, void KThreadQueue::NotifyAvailable([[maybe_unused]] KThread* waiting_thread,
[[maybe_unused]] KSynchronizationObject* signaled_object, [[maybe_unused]] KSynchronizationObject* signaled_object,
[[maybe_unused]] ResultCode wait_result) {} [[maybe_unused]] Result wait_result) {}
void KThreadQueue::EndWait(KThread* waiting_thread, ResultCode wait_result) { void KThreadQueue::EndWait(KThread* waiting_thread, Result wait_result) {
// Set the thread's wait result. // Set the thread's wait result.
waiting_thread->SetWaitResult(wait_result); waiting_thread->SetWaitResult(wait_result);
@ -25,8 +25,7 @@ void KThreadQueue::EndWait(KThread* waiting_thread, ResultCode wait_result) {
kernel.TimeManager().UnscheduleTimeEvent(waiting_thread); kernel.TimeManager().UnscheduleTimeEvent(waiting_thread);
} }
void KThreadQueue::CancelWait(KThread* waiting_thread, ResultCode wait_result, void KThreadQueue::CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) {
bool cancel_timer_task) {
// Set the thread's wait result. // Set the thread's wait result.
waiting_thread->SetWaitResult(wait_result); waiting_thread->SetWaitResult(wait_result);
@ -43,6 +42,6 @@ void KThreadQueue::CancelWait(KThread* waiting_thread, ResultCode wait_result,
} }
void KThreadQueueWithoutEndWait::EndWait([[maybe_unused]] KThread* waiting_thread, void KThreadQueueWithoutEndWait::EndWait([[maybe_unused]] KThread* waiting_thread,
[[maybe_unused]] ResultCode wait_result) {} [[maybe_unused]] Result wait_result) {}
} // namespace Kernel } // namespace Kernel

View file

@ -14,10 +14,9 @@ public:
virtual ~KThreadQueue() = default; virtual ~KThreadQueue() = default;
virtual void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object, virtual void NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object,
ResultCode wait_result); Result wait_result);
virtual void EndWait(KThread* waiting_thread, ResultCode wait_result); virtual void EndWait(KThread* waiting_thread, Result wait_result);
virtual void CancelWait(KThread* waiting_thread, ResultCode wait_result, virtual void CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task);
bool cancel_timer_task);
private: private:
KernelCore& kernel; KernelCore& kernel;
@ -28,7 +27,7 @@ class KThreadQueueWithoutEndWait : public KThreadQueue {
public: public:
explicit KThreadQueueWithoutEndWait(KernelCore& kernel_) : KThreadQueue(kernel_) {} explicit KThreadQueueWithoutEndWait(KernelCore& kernel_) : KThreadQueue(kernel_) {}
void EndWait(KThread* waiting_thread, ResultCode wait_result) override final; void EndWait(KThread* waiting_thread, Result wait_result) override final;
}; };
} // namespace Kernel } // namespace Kernel

View file

@ -13,7 +13,7 @@ KTransferMemory::KTransferMemory(KernelCore& kernel_)
KTransferMemory::~KTransferMemory() = default; KTransferMemory::~KTransferMemory() = default;
ResultCode KTransferMemory::Initialize(VAddr address_, std::size_t size_, Result KTransferMemory::Initialize(VAddr address_, std::size_t size_,
Svc::MemoryPermission owner_perm_) { Svc::MemoryPermission owner_perm_) {
// Set members. // Set members.
owner = kernel.CurrentProcess(); owner = kernel.CurrentProcess();

View file

@ -7,7 +7,7 @@
#include "core/hle/kernel/svc_types.h" #include "core/hle/kernel/svc_types.h"
#include "core/hle/result.h" #include "core/hle/result.h"
union ResultCode; union Result;
namespace Core::Memory { namespace Core::Memory {
class Memory; class Memory;
@ -26,7 +26,7 @@ public:
explicit KTransferMemory(KernelCore& kernel_); explicit KTransferMemory(KernelCore& kernel_);
~KTransferMemory() override; ~KTransferMemory() override;
ResultCode Initialize(VAddr address_, std::size_t size_, Svc::MemoryPermission owner_perm_); Result Initialize(VAddr address_, std::size_t size_, Svc::MemoryPermission owner_perm_);
void Finalize() override; void Finalize() override;

View file

@ -18,11 +18,11 @@ void KWritableEvent::Initialize(KEvent* parent_event_, std::string&& name_) {
parent->GetReadableEvent().Open(); parent->GetReadableEvent().Open();
} }
ResultCode KWritableEvent::Signal() { Result KWritableEvent::Signal() {
return parent->GetReadableEvent().Signal(); return parent->GetReadableEvent().Signal();
} }
ResultCode KWritableEvent::Clear() { Result KWritableEvent::Clear() {
return parent->GetReadableEvent().Clear(); return parent->GetReadableEvent().Clear();
} }

View file

@ -25,8 +25,8 @@ public:
static void PostDestroy([[maybe_unused]] uintptr_t arg) {} static void PostDestroy([[maybe_unused]] uintptr_t arg) {}
void Initialize(KEvent* parent_, std::string&& name_); void Initialize(KEvent* parent_, std::string&& name_);
ResultCode Signal(); Result Signal();
ResultCode Clear(); Result Clear();
KEvent* GetParent() const { KEvent* GetParent() const {
return parent; return parent;

View file

@ -68,7 +68,7 @@ u32 GetFlagBitOffset(CapabilityType type) {
} // Anonymous namespace } // Anonymous namespace
ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabilities, Result ProcessCapabilities::InitializeForKernelProcess(const u32* capabilities,
std::size_t num_capabilities, std::size_t num_capabilities,
KPageTable& page_table) { KPageTable& page_table) {
Clear(); Clear();
@ -81,7 +81,7 @@ ResultCode ProcessCapabilities::InitializeForKernelProcess(const u32* capabiliti
return ParseCapabilities(capabilities, num_capabilities, page_table); return ParseCapabilities(capabilities, num_capabilities, page_table);
} }
ResultCode ProcessCapabilities::InitializeForUserProcess(const u32* capabilities, Result ProcessCapabilities::InitializeForUserProcess(const u32* capabilities,
std::size_t num_capabilities, std::size_t num_capabilities,
KPageTable& page_table) { KPageTable& page_table) {
Clear(); Clear();
@ -107,8 +107,7 @@ void ProcessCapabilities::InitializeForMetadatalessProcess() {
can_force_debug = true; can_force_debug = true;
} }
ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities, Result ProcessCapabilities::ParseCapabilities(const u32* capabilities, std::size_t num_capabilities,
std::size_t num_capabilities,
KPageTable& page_table) { KPageTable& page_table) {
u32 set_flags = 0; u32 set_flags = 0;
u32 set_svc_bits = 0; u32 set_svc_bits = 0;
@ -155,8 +154,8 @@ ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities,
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, Result ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag,
u32 flag, KPageTable& page_table) { KPageTable& page_table) {
const auto type = GetCapabilityType(flag); const auto type = GetCapabilityType(flag);
if (type == CapabilityType::Unset) { if (type == CapabilityType::Unset) {
@ -224,7 +223,7 @@ void ProcessCapabilities::Clear() {
can_force_debug = false; can_force_debug = false;
} }
ResultCode ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) { Result ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) {
if (priority_mask != 0 || core_mask != 0) { if (priority_mask != 0 || core_mask != 0) {
LOG_ERROR(Kernel, "Core or priority mask are not zero! priority_mask={}, core_mask={}", LOG_ERROR(Kernel, "Core or priority mask are not zero! priority_mask={}, core_mask={}",
priority_mask, core_mask); priority_mask, core_mask);
@ -266,7 +265,7 @@ ResultCode ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags) { Result ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags) {
const u32 index = flags >> 29; const u32 index = flags >> 29;
const u32 svc_bit = 1U << index; const u32 svc_bit = 1U << index;
@ -290,23 +289,23 @@ ResultCode ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags)
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::HandleMapPhysicalFlags(u32 flags, u32 size_flags, Result ProcessCapabilities::HandleMapPhysicalFlags(u32 flags, u32 size_flags,
KPageTable& page_table) { KPageTable& page_table) {
// TODO(Lioncache): Implement once the memory manager can handle this. // TODO(Lioncache): Implement once the memory manager can handle this.
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::HandleMapIOFlags(u32 flags, KPageTable& page_table) { Result ProcessCapabilities::HandleMapIOFlags(u32 flags, KPageTable& page_table) {
// TODO(Lioncache): Implement once the memory manager can handle this. // TODO(Lioncache): Implement once the memory manager can handle this.
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::HandleMapRegionFlags(u32 flags, KPageTable& page_table) { Result ProcessCapabilities::HandleMapRegionFlags(u32 flags, KPageTable& page_table) {
// TODO(Lioncache): Implement once the memory manager can handle this. // TODO(Lioncache): Implement once the memory manager can handle this.
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::HandleInterruptFlags(u32 flags) { Result ProcessCapabilities::HandleInterruptFlags(u32 flags) {
constexpr u32 interrupt_ignore_value = 0x3FF; constexpr u32 interrupt_ignore_value = 0x3FF;
const u32 interrupt0 = (flags >> 12) & 0x3FF; const u32 interrupt0 = (flags >> 12) & 0x3FF;
const u32 interrupt1 = (flags >> 22) & 0x3FF; const u32 interrupt1 = (flags >> 22) & 0x3FF;
@ -333,7 +332,7 @@ ResultCode ProcessCapabilities::HandleInterruptFlags(u32 flags) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::HandleProgramTypeFlags(u32 flags) { Result ProcessCapabilities::HandleProgramTypeFlags(u32 flags) {
const u32 reserved = flags >> 17; const u32 reserved = flags >> 17;
if (reserved != 0) { if (reserved != 0) {
LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved); LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved);
@ -344,7 +343,7 @@ ResultCode ProcessCapabilities::HandleProgramTypeFlags(u32 flags) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::HandleKernelVersionFlags(u32 flags) { Result ProcessCapabilities::HandleKernelVersionFlags(u32 flags) {
// Yes, the internal member variable is checked in the actual kernel here. // Yes, the internal member variable is checked in the actual kernel here.
// This might look odd for options that are only allowed to be initialized // This might look odd for options that are only allowed to be initialized
// just once, however the kernel has a separate initialization function for // just once, however the kernel has a separate initialization function for
@ -364,7 +363,7 @@ ResultCode ProcessCapabilities::HandleKernelVersionFlags(u32 flags) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::HandleHandleTableFlags(u32 flags) { Result ProcessCapabilities::HandleHandleTableFlags(u32 flags) {
const u32 reserved = flags >> 26; const u32 reserved = flags >> 26;
if (reserved != 0) { if (reserved != 0) {
LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved); LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved);
@ -375,7 +374,7 @@ ResultCode ProcessCapabilities::HandleHandleTableFlags(u32 flags) {
return ResultSuccess; return ResultSuccess;
} }
ResultCode ProcessCapabilities::HandleDebugFlags(u32 flags) { Result ProcessCapabilities::HandleDebugFlags(u32 flags) {
const u32 reserved = flags >> 19; const u32 reserved = flags >> 19;
if (reserved != 0) { if (reserved != 0) {
LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved); LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved);

View file

@ -7,7 +7,7 @@
#include "common/common_types.h" #include "common/common_types.h"
union ResultCode; union Result;
namespace Kernel { namespace Kernel {
@ -86,7 +86,7 @@ public:
/// @returns ResultSuccess if this capabilities instance was able to be initialized, /// @returns ResultSuccess if this capabilities instance was able to be initialized,
/// otherwise, an error code upon failure. /// otherwise, an error code upon failure.
/// ///
ResultCode InitializeForKernelProcess(const u32* capabilities, std::size_t num_capabilities, Result InitializeForKernelProcess(const u32* capabilities, std::size_t num_capabilities,
KPageTable& page_table); KPageTable& page_table);
/// Initializes this process capabilities instance for a userland process. /// Initializes this process capabilities instance for a userland process.
@ -99,7 +99,7 @@ public:
/// @returns ResultSuccess if this capabilities instance was able to be initialized, /// @returns ResultSuccess if this capabilities instance was able to be initialized,
/// otherwise, an error code upon failure. /// otherwise, an error code upon failure.
/// ///
ResultCode InitializeForUserProcess(const u32* capabilities, std::size_t num_capabilities, Result InitializeForUserProcess(const u32* capabilities, std::size_t num_capabilities,
KPageTable& page_table); KPageTable& page_table);
/// Initializes this process capabilities instance for a process that does not /// Initializes this process capabilities instance for a process that does not
@ -185,7 +185,7 @@ private:
/// ///
/// @return ResultSuccess if no errors occur, otherwise an error code. /// @return ResultSuccess if no errors occur, otherwise an error code.
/// ///
ResultCode ParseCapabilities(const u32* capabilities, std::size_t num_capabilities, Result ParseCapabilities(const u32* capabilities, std::size_t num_capabilities,
KPageTable& page_table); KPageTable& page_table);
/// Attempts to parse a capability descriptor that is only represented by a /// Attempts to parse a capability descriptor that is only represented by a
@ -200,7 +200,7 @@ private:
/// ///
/// @return ResultSuccess if no errors occurred, otherwise an error code. /// @return ResultSuccess if no errors occurred, otherwise an error code.
/// ///
ResultCode ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag, Result ParseSingleFlagCapability(u32& set_flags, u32& set_svc_bits, u32 flag,
KPageTable& page_table); KPageTable& page_table);
/// Clears the internal state of this process capability instance. Necessary, /// Clears the internal state of this process capability instance. Necessary,
@ -219,34 +219,34 @@ private:
void Clear(); void Clear();
/// Handles flags related to the priority and core number capability flags. /// Handles flags related to the priority and core number capability flags.
ResultCode HandlePriorityCoreNumFlags(u32 flags); Result HandlePriorityCoreNumFlags(u32 flags);
/// Handles flags related to determining the allowable SVC mask. /// Handles flags related to determining the allowable SVC mask.
ResultCode HandleSyscallFlags(u32& set_svc_bits, u32 flags); Result HandleSyscallFlags(u32& set_svc_bits, u32 flags);
/// Handles flags related to mapping physical memory pages. /// Handles flags related to mapping physical memory pages.
ResultCode HandleMapPhysicalFlags(u32 flags, u32 size_flags, KPageTable& page_table); Result HandleMapPhysicalFlags(u32 flags, u32 size_flags, KPageTable& page_table);
/// Handles flags related to mapping IO pages. /// Handles flags related to mapping IO pages.
ResultCode HandleMapIOFlags(u32 flags, KPageTable& page_table); Result HandleMapIOFlags(u32 flags, KPageTable& page_table);
/// Handles flags related to mapping physical memory regions. /// Handles flags related to mapping physical memory regions.
ResultCode HandleMapRegionFlags(u32 flags, KPageTable& page_table); Result HandleMapRegionFlags(u32 flags, KPageTable& page_table);
/// Handles flags related to the interrupt capability flags. /// Handles flags related to the interrupt capability flags.
ResultCode HandleInterruptFlags(u32 flags); Result HandleInterruptFlags(u32 flags);
/// Handles flags related to the program type. /// Handles flags related to the program type.
ResultCode HandleProgramTypeFlags(u32 flags); Result HandleProgramTypeFlags(u32 flags);
/// Handles flags related to the handle table size. /// Handles flags related to the handle table size.
ResultCode HandleHandleTableFlags(u32 flags); Result HandleHandleTableFlags(u32 flags);
/// Handles flags related to the kernel version capability flags. /// Handles flags related to the kernel version capability flags.
ResultCode HandleKernelVersionFlags(u32 flags); Result HandleKernelVersionFlags(u32 flags);
/// Handles flags related to debug-specific capabilities. /// Handles flags related to debug-specific capabilities.
ResultCode HandleDebugFlags(u32 flags); Result HandleDebugFlags(u32 flags);
SyscallCapabilities svc_capabilities; SyscallCapabilities svc_capabilities;
InterruptCapabilities interrupt_capabilities; InterruptCapabilities interrupt_capabilities;

View file

@ -58,7 +58,7 @@ constexpr bool IsValidAddressRange(VAddr address, u64 size) {
// Helper function that performs the common sanity checks for svcMapMemory // Helper function that performs the common sanity checks for svcMapMemory
// and svcUnmapMemory. This is doable, as both functions perform their sanitizing // and svcUnmapMemory. This is doable, as both functions perform their sanitizing
// in the same order. // in the same order.
ResultCode MapUnmapMemorySanityChecks(const KPageTable& manager, VAddr dst_addr, VAddr src_addr, Result MapUnmapMemorySanityChecks(const KPageTable& manager, VAddr dst_addr, VAddr src_addr,
u64 size) { u64 size) {
if (!Common::Is4KBAligned(dst_addr)) { if (!Common::Is4KBAligned(dst_addr)) {
LOG_ERROR(Kernel_SVC, "Destination address is not aligned to 4KB, 0x{:016X}", dst_addr); LOG_ERROR(Kernel_SVC, "Destination address is not aligned to 4KB, 0x{:016X}", dst_addr);
@ -135,7 +135,7 @@ enum class ResourceLimitValueType {
} // Anonymous namespace } // Anonymous namespace
/// Set the process heap to a given Size. It can both extend and shrink the heap. /// Set the process heap to a given Size. It can both extend and shrink the heap.
static ResultCode SetHeapSize(Core::System& system, VAddr* out_address, u64 size) { static Result SetHeapSize(Core::System& system, VAddr* out_address, u64 size) {
LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", size); LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", size);
// Validate size. // Validate size.
@ -148,9 +148,9 @@ static ResultCode SetHeapSize(Core::System& system, VAddr* out_address, u64 size
return ResultSuccess; return ResultSuccess;
} }
static ResultCode SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size) { static Result SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_size) {
VAddr temp_heap_addr{}; VAddr temp_heap_addr{};
const ResultCode result{SetHeapSize(system, &temp_heap_addr, heap_size)}; const Result result{SetHeapSize(system, &temp_heap_addr, heap_size)};
*heap_addr = static_cast<u32>(temp_heap_addr); *heap_addr = static_cast<u32>(temp_heap_addr);
return result; return result;
} }
@ -166,7 +166,7 @@ constexpr bool IsValidSetMemoryPermission(MemoryPermission perm) {
} }
} }
static ResultCode SetMemoryPermission(Core::System& system, VAddr address, u64 size, static Result SetMemoryPermission(Core::System& system, VAddr address, u64 size,
MemoryPermission perm) { MemoryPermission perm) {
LOG_DEBUG(Kernel_SVC, "called, address=0x{:016X}, size=0x{:X}, perm=0x{:08X", address, size, LOG_DEBUG(Kernel_SVC, "called, address=0x{:016X}, size=0x{:X}, perm=0x{:08X", address, size,
perm); perm);
@ -188,7 +188,7 @@ static ResultCode SetMemoryPermission(Core::System& system, VAddr address, u64 s
return page_table.SetMemoryPermission(address, size, perm); return page_table.SetMemoryPermission(address, size, perm);
} }
static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask, static Result SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask,
u32 attr) { u32 attr) {
LOG_DEBUG(Kernel_SVC, LOG_DEBUG(Kernel_SVC,
"called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address, "called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address,
@ -213,19 +213,19 @@ static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 si
return page_table.SetMemoryAttribute(address, size, mask, attr); return page_table.SetMemoryAttribute(address, size, mask, attr);
} }
static ResultCode SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask, static Result SetMemoryAttribute32(Core::System& system, u32 address, u32 size, u32 mask,
u32 attr) { u32 attr) {
return SetMemoryAttribute(system, address, size, mask, attr); return SetMemoryAttribute(system, address, size, mask, attr);
} }
/// Maps a memory range into a different range. /// Maps a memory range into a different range.
static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { static Result MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
src_addr, size); src_addr, size);
auto& page_table{system.Kernel().CurrentProcess()->PageTable()}; auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
if (const ResultCode result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)}; if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
result.IsError()) { result.IsError()) {
return result; return result;
} }
@ -233,18 +233,18 @@ static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr
return page_table.MapMemory(dst_addr, src_addr, size); return page_table.MapMemory(dst_addr, src_addr, size);
} }
static ResultCode MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { static Result MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) {
return MapMemory(system, dst_addr, src_addr, size); return MapMemory(system, dst_addr, src_addr, size);
} }
/// Unmaps a region that was previously mapped with svcMapMemory /// Unmaps a region that was previously mapped with svcMapMemory
static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { static Result UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) {
LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr,
src_addr, size); src_addr, size);
auto& page_table{system.Kernel().CurrentProcess()->PageTable()}; auto& page_table{system.Kernel().CurrentProcess()->PageTable()};
if (const ResultCode result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)}; if (const Result result{MapUnmapMemorySanityChecks(page_table, dst_addr, src_addr, size)};
result.IsError()) { result.IsError()) {
return result; return result;
} }
@ -252,12 +252,12 @@ static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_ad
return page_table.UnmapMemory(dst_addr, src_addr, size); return page_table.UnmapMemory(dst_addr, src_addr, size);
} }
static ResultCode UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) { static Result UnmapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, u32 size) {
return UnmapMemory(system, dst_addr, src_addr, size); return UnmapMemory(system, dst_addr, src_addr, size);
} }
/// 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 ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_address) { static Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_name_address) {
auto& memory = system.Memory(); auto& memory = system.Memory();
if (!memory.IsValidVirtualAddress(port_name_address)) { if (!memory.IsValidVirtualAddress(port_name_address)) {
LOG_ERROR(Kernel_SVC, LOG_ERROR(Kernel_SVC,
@ -307,14 +307,14 @@ static ResultCode ConnectToNamedPort(Core::System& system, Handle* out, VAddr po
return ResultSuccess; return ResultSuccess;
} }
static ResultCode ConnectToNamedPort32(Core::System& system, Handle* out_handle, static Result ConnectToNamedPort32(Core::System& system, Handle* out_handle,
u32 port_name_address) { u32 port_name_address) {
return ConnectToNamedPort(system, out_handle, port_name_address); return ConnectToNamedPort(system, out_handle, port_name_address);
} }
/// Makes a blocking IPC call to an OS service. /// Makes a blocking IPC call to an OS service.
static ResultCode SendSyncRequest(Core::System& system, Handle handle) { static Result SendSyncRequest(Core::System& system, Handle handle) {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
// Create the wait queue. // Create the wait queue.
@ -339,12 +339,12 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) {
return GetCurrentThread(kernel).GetWaitResult(); return GetCurrentThread(kernel).GetWaitResult();
} }
static ResultCode SendSyncRequest32(Core::System& system, Handle handle) { static Result SendSyncRequest32(Core::System& system, Handle handle) {
return SendSyncRequest(system, handle); return SendSyncRequest(system, handle);
} }
/// Get the ID for the specified thread. /// Get the ID for the specified thread.
static ResultCode GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) { static Result GetThreadId(Core::System& system, u64* out_thread_id, Handle thread_handle) {
// Get the thread from its handle. // Get the thread from its handle.
KScopedAutoObject thread = KScopedAutoObject thread =
system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle); system.Kernel().CurrentProcess()->GetHandleTable().GetObject<KThread>(thread_handle);
@ -355,10 +355,10 @@ static ResultCode GetThreadId(Core::System& system, u64* out_thread_id, Handle t
return ResultSuccess; return ResultSuccess;
} }
static ResultCode GetThreadId32(Core::System& system, u32* out_thread_id_low, static Result GetThreadId32(Core::System& system, u32* out_thread_id_low, u32* out_thread_id_high,
u32* out_thread_id_high, Handle thread_handle) { Handle thread_handle) {
u64 out_thread_id{}; u64 out_thread_id{};
const ResultCode result{GetThreadId(system, &out_thread_id, thread_handle)}; const Result result{GetThreadId(system, &out_thread_id, thread_handle)};
*out_thread_id_low = static_cast<u32>(out_thread_id >> 32); *out_thread_id_low = static_cast<u32>(out_thread_id >> 32);
*out_thread_id_high = static_cast<u32>(out_thread_id & std::numeric_limits<u32>::max()); *out_thread_id_high = static_cast<u32>(out_thread_id & std::numeric_limits<u32>::max());
@ -367,7 +367,7 @@ static ResultCode GetThreadId32(Core::System& system, u32* out_thread_id_low,
} }
/// Gets the ID of the specified process or a specified thread's owning process. /// Gets the ID of the specified process or a specified thread's owning process.
static ResultCode GetProcessId(Core::System& system, u64* out_process_id, Handle handle) { static Result GetProcessId(Core::System& system, u64* out_process_id, Handle handle) {
LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle); LOG_DEBUG(Kernel_SVC, "called handle=0x{:08X}", handle);
// Get the object from the handle table. // Get the object from the handle table.
@ -398,7 +398,7 @@ static ResultCode GetProcessId(Core::System& system, u64* out_process_id, Handle
return ResultSuccess; return ResultSuccess;
} }
static ResultCode GetProcessId32(Core::System& system, u32* out_process_id_low, static Result GetProcessId32(Core::System& system, u32* out_process_id_low,
u32* out_process_id_high, Handle handle) { u32* out_process_id_high, Handle handle) {
u64 out_process_id{}; u64 out_process_id{};
const auto result = GetProcessId(system, &out_process_id, handle); const auto result = GetProcessId(system, &out_process_id, handle);
@ -408,7 +408,7 @@ static ResultCode GetProcessId32(Core::System& system, u32* out_process_id_low,
} }
/// 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 WaitSynchronization(Core::System& system, s32* index, VAddr handles_address, static Result WaitSynchronization(Core::System& system, s32* index, VAddr handles_address,
s32 num_handles, s64 nano_seconds) { s32 num_handles, s64 nano_seconds) {
LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, num_handles={}, nano_seconds={}", LOG_TRACE(Kernel_SVC, "called handles_address=0x{:X}, num_handles={}, nano_seconds={}",
handles_address, num_handles, nano_seconds); handles_address, num_handles, nano_seconds);
@ -444,14 +444,14 @@ static ResultCode WaitSynchronization(Core::System& system, s32* index, VAddr ha
nano_seconds); nano_seconds);
} }
static ResultCode WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address, static Result WaitSynchronization32(Core::System& system, u32 timeout_low, u32 handles_address,
s32 num_handles, u32 timeout_high, s32* index) { s32 num_handles, u32 timeout_high, s32* index) {
const s64 nano_seconds{(static_cast<s64>(timeout_high) << 32) | static_cast<s64>(timeout_low)}; const s64 nano_seconds{(static_cast<s64>(timeout_high) << 32) | static_cast<s64>(timeout_low)};
return WaitSynchronization(system, index, handles_address, num_handles, nano_seconds); return WaitSynchronization(system, index, handles_address, num_handles, nano_seconds);
} }
/// Resumes a thread waiting on WaitSynchronization /// Resumes a thread waiting on WaitSynchronization
static ResultCode CancelSynchronization(Core::System& system, Handle handle) { static Result CancelSynchronization(Core::System& system, Handle handle) {
LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle); LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle);
// Get the thread from its handle. // Get the thread from its handle.
@ -464,13 +464,12 @@ static ResultCode CancelSynchronization(Core::System& system, Handle handle) {
return ResultSuccess; return ResultSuccess;
} }
static ResultCode CancelSynchronization32(Core::System& system, Handle handle) { static Result CancelSynchronization32(Core::System& system, Handle handle) {
return CancelSynchronization(system, handle); return CancelSynchronization(system, handle);
} }
/// Attempts to locks a mutex /// Attempts to locks a mutex
static ResultCode ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address, static Result ArbitrateLock(Core::System& system, Handle thread_handle, VAddr address, u32 tag) {
u32 tag) {
LOG_TRACE(Kernel_SVC, "called thread_handle=0x{:08X}, address=0x{:X}, tag=0x{:08X}", LOG_TRACE(Kernel_SVC, "called thread_handle=0x{:08X}, address=0x{:X}, tag=0x{:08X}",
thread_handle, address, tag); thread_handle, address, tag);
@ -488,13 +487,12 @@ static ResultCode ArbitrateLock(Core::System& system, Handle thread_handle, VAdd
return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag); return system.Kernel().CurrentProcess()->WaitForAddress(thread_handle, address, tag);
} }
static ResultCode ArbitrateLock32(Core::System& system, Handle thread_handle, u32 address, static Result ArbitrateLock32(Core::System& system, Handle thread_handle, u32 address, u32 tag) {
u32 tag) {
return ArbitrateLock(system, thread_handle, address, tag); return ArbitrateLock(system, thread_handle, address, tag);
} }
/// Unlock a mutex /// Unlock a mutex
static ResultCode ArbitrateUnlock(Core::System& system, VAddr address) { static Result ArbitrateUnlock(Core::System& system, VAddr address) {
LOG_TRACE(Kernel_SVC, "called address=0x{:X}", address); LOG_TRACE(Kernel_SVC, "called address=0x{:X}", address);
// Validate the input address. // Validate the input address.
@ -512,7 +510,7 @@ static ResultCode ArbitrateUnlock(Core::System& system, VAddr address) {
return system.Kernel().CurrentProcess()->SignalToAddress(address); return system.Kernel().CurrentProcess()->SignalToAddress(address);
} }
static ResultCode ArbitrateUnlock32(Core::System& system, u32 address) { static Result ArbitrateUnlock32(Core::System& system, u32 address) {
return ArbitrateUnlock(system, address); return ArbitrateUnlock(system, address);
} }
@ -655,7 +653,7 @@ static void OutputDebugString32(Core::System& system, u32 address, u32 len) {
} }
/// Gets system/memory information for the current process /// Gets system/memory information for the current process
static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, static Result GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle,
u64 info_sub_id) { u64 info_sub_id) {
LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
info_sub_id, handle); info_sub_id, handle);
@ -919,12 +917,12 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle
} }
} }
static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low, static Result GetInfo32(Core::System& system, u32* result_low, u32* result_high, u32 sub_id_low,
u32 info_id, u32 handle, u32 sub_id_high) { u32 info_id, u32 handle, u32 sub_id_high) {
const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)}; const u64 sub_id{u64{sub_id_low} | (u64{sub_id_high} << 32)};
u64 res_value{}; u64 res_value{};
const ResultCode result{GetInfo(system, &res_value, info_id, handle, sub_id)}; const Result result{GetInfo(system, &res_value, info_id, handle, sub_id)};
*result_high = static_cast<u32>(res_value >> 32); *result_high = static_cast<u32>(res_value >> 32);
*result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max()); *result_low = static_cast<u32>(res_value & std::numeric_limits<u32>::max());
@ -932,7 +930,7 @@ static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_h
} }
/// Maps memory at a desired address /// Maps memory at a desired address
static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { static Result MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
if (!Common::Is4KBAligned(addr)) { if (!Common::Is4KBAligned(addr)) {
@ -980,12 +978,12 @@ static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size)
return page_table.MapPhysicalMemory(addr, size); return page_table.MapPhysicalMemory(addr, size);
} }
static ResultCode MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { static Result MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) {
return MapPhysicalMemory(system, addr, size); return MapPhysicalMemory(system, addr, size);
} }
/// Unmaps memory previously mapped via MapPhysicalMemory /// Unmaps memory previously mapped via MapPhysicalMemory
static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { static Result UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) {
LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size);
if (!Common::Is4KBAligned(addr)) { if (!Common::Is4KBAligned(addr)) {
@ -1033,12 +1031,12 @@ static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size
return page_table.UnmapPhysicalMemory(addr, size); return page_table.UnmapPhysicalMemory(addr, size);
} }
static ResultCode UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) { static Result UnmapPhysicalMemory32(Core::System& system, u32 addr, u32 size) {
return UnmapPhysicalMemory(system, addr, size); return UnmapPhysicalMemory(system, addr, size);
} }
/// Sets the thread activity /// Sets the thread activity
static ResultCode SetThreadActivity(Core::System& system, Handle thread_handle, static Result SetThreadActivity(Core::System& system, Handle thread_handle,
ThreadActivity thread_activity) { ThreadActivity thread_activity) {
LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", thread_handle, LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", thread_handle,
thread_activity); thread_activity);
@ -1064,13 +1062,13 @@ static ResultCode SetThreadActivity(Core::System& system, Handle thread_handle,
return ResultSuccess; return ResultSuccess;
} }
static ResultCode SetThreadActivity32(Core::System& system, Handle thread_handle, static Result SetThreadActivity32(Core::System& system, Handle thread_handle,
Svc::ThreadActivity thread_activity) { Svc::ThreadActivity thread_activity) {
return SetThreadActivity(system, thread_handle, thread_activity); return SetThreadActivity(system, thread_handle, thread_activity);
} }
/// Gets the thread context /// Gets the thread context
static ResultCode GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) { static Result GetThreadContext(Core::System& system, VAddr out_context, Handle thread_handle) {
LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context, LOG_DEBUG(Kernel_SVC, "called, out_context=0x{:08X}, thread_handle=0x{:X}", out_context,
thread_handle); thread_handle);
@ -1127,12 +1125,12 @@ static ResultCode GetThreadContext(Core::System& system, VAddr out_context, Hand
return ResultSuccess; return ResultSuccess;
} }
static ResultCode GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) { static Result GetThreadContext32(Core::System& system, u32 out_context, Handle thread_handle) {
return GetThreadContext(system, out_context, thread_handle); return GetThreadContext(system, out_context, thread_handle);
} }
/// Gets the priority for the specified thread /// Gets the priority for the specified thread
static ResultCode GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) { static Result GetThreadPriority(Core::System& system, u32* out_priority, Handle handle) {
LOG_TRACE(Kernel_SVC, "called"); LOG_TRACE(Kernel_SVC, "called");
// Get the thread from its handle. // Get the thread from its handle.
@ -1145,12 +1143,12 @@ static ResultCode GetThreadPriority(Core::System& system, u32* out_priority, Han
return ResultSuccess; return ResultSuccess;
} }
static ResultCode GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) { static Result GetThreadPriority32(Core::System& system, u32* out_priority, Handle handle) {
return GetThreadPriority(system, out_priority, handle); return GetThreadPriority(system, out_priority, handle);
} }
/// Sets the priority for the specified thread /// Sets the priority for the specified thread
static ResultCode SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) { static Result SetThreadPriority(Core::System& system, Handle thread_handle, u32 priority) {
// Get the current process. // Get the current process.
KProcess& process = *system.Kernel().CurrentProcess(); KProcess& process = *system.Kernel().CurrentProcess();
@ -1168,7 +1166,7 @@ static ResultCode SetThreadPriority(Core::System& system, Handle thread_handle,
return ResultSuccess; return ResultSuccess;
} }
static ResultCode SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) { static Result SetThreadPriority32(Core::System& system, Handle thread_handle, u32 priority) {
return SetThreadPriority(system, thread_handle, priority); return SetThreadPriority(system, thread_handle, priority);
} }
@ -1228,8 +1226,8 @@ constexpr bool IsValidUnmapFromOwnerCodeMemoryPermission(Svc::MemoryPermission p
} // Anonymous namespace } // Anonymous namespace
static ResultCode MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, static Result MapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, u64 size,
u64 size, Svc::MemoryPermission map_perm) { Svc::MemoryPermission map_perm) {
LOG_TRACE(Kernel_SVC, LOG_TRACE(Kernel_SVC,
"called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", "called, shared_memory_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}",
shmem_handle, address, size, map_perm); shmem_handle, address, size, map_perm);
@ -1269,12 +1267,12 @@ static ResultCode MapSharedMemory(Core::System& system, Handle shmem_handle, VAd
return ResultSuccess; return ResultSuccess;
} }
static ResultCode MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, static Result MapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, u32 size,
u32 size, Svc::MemoryPermission map_perm) { Svc::MemoryPermission map_perm) {
return MapSharedMemory(system, shmem_handle, address, size, map_perm); return MapSharedMemory(system, shmem_handle, address, size, map_perm);
} }
static ResultCode UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address, static Result UnmapSharedMemory(Core::System& system, Handle shmem_handle, VAddr address,
u64 size) { u64 size) {
// Validate the address/size. // Validate the address/size.
R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress); R_UNLESS(Common::IsAligned(address, PageSize), ResultInvalidAddress);
@ -1302,13 +1300,13 @@ static ResultCode UnmapSharedMemory(Core::System& system, Handle shmem_handle, V
return ResultSuccess; return ResultSuccess;
} }
static ResultCode UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address, static Result UnmapSharedMemory32(Core::System& system, Handle shmem_handle, u32 address,
u32 size) { u32 size) {
return UnmapSharedMemory(system, shmem_handle, address, size); return UnmapSharedMemory(system, shmem_handle, address, size);
} }
static ResultCode SetProcessMemoryPermission(Core::System& system, Handle process_handle, static Result SetProcessMemoryPermission(Core::System& system, Handle process_handle, VAddr address,
VAddr address, u64 size, Svc::MemoryPermission perm) { u64 size, Svc::MemoryPermission perm) {
LOG_TRACE(Kernel_SVC, LOG_TRACE(Kernel_SVC,
"called, process_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}", "called, process_handle=0x{:X}, addr=0x{:X}, size=0x{:X}, permissions=0x{:08X}",
process_handle, address, size, perm); process_handle, address, size, perm);
@ -1337,7 +1335,7 @@ static ResultCode SetProcessMemoryPermission(Core::System& system, Handle proces
return page_table.SetProcessMemoryPermission(address, size, perm); return page_table.SetProcessMemoryPermission(address, size, perm);
} }
static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, static Result MapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle,
VAddr src_address, u64 size) { VAddr src_address, u64 size) {
LOG_TRACE(Kernel_SVC, LOG_TRACE(Kernel_SVC,
"called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}",
@ -1380,7 +1378,7 @@ static ResultCode MapProcessMemory(Core::System& system, VAddr dst_address, Hand
return ResultSuccess; return ResultSuccess;
} }
static ResultCode UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle, static Result UnmapProcessMemory(Core::System& system, VAddr dst_address, Handle process_handle,
VAddr src_address, u64 size) { VAddr src_address, u64 size) {
LOG_TRACE(Kernel_SVC, LOG_TRACE(Kernel_SVC,
"called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}", "called, dst_address=0x{:X}, process_handle=0x{:X}, src_address=0x{:X}, size=0x{:X}",
@ -1415,7 +1413,7 @@ static ResultCode UnmapProcessMemory(Core::System& system, VAddr dst_address, Ha
return ResultSuccess; return ResultSuccess;
} }
static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) { static Result CreateCodeMemory(Core::System& system, Handle* out, VAddr address, size_t size) {
LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, size=0x{:X}", address, size); LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, size=0x{:X}", address, size);
// Get kernel instance. // Get kernel instance.
@ -1450,11 +1448,11 @@ static ResultCode CreateCodeMemory(Core::System& system, Handle* out, VAddr addr
return ResultSuccess; return ResultSuccess;
} }
static ResultCode CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) { static Result CreateCodeMemory32(Core::System& system, Handle* out, u32 address, u32 size) {
return CreateCodeMemory(system, out, address, size); return CreateCodeMemory(system, out, address, size);
} }
static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation, static Result ControlCodeMemory(Core::System& system, Handle code_memory_handle, u32 operation,
VAddr address, size_t size, Svc::MemoryPermission perm) { VAddr address, size_t size, Svc::MemoryPermission perm) {
LOG_TRACE(Kernel_SVC, LOG_TRACE(Kernel_SVC,
@ -1533,15 +1531,13 @@ static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_han
return ResultSuccess; return ResultSuccess;
} }
static ResultCode ControlCodeMemory32(Core::System& system, Handle code_memory_handle, static Result ControlCodeMemory32(Core::System& system, Handle code_memory_handle, u32 operation,
u32 operation, u64 address, u64 size, u64 address, u64 size, Svc::MemoryPermission perm) {
Svc::MemoryPermission perm) {
return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm); return ControlCodeMemory(system, code_memory_handle, operation, address, size, perm);
} }
static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, static Result QueryProcessMemory(Core::System& system, VAddr memory_info_address,
VAddr page_info_address, Handle process_handle, VAddr page_info_address, Handle process_handle, VAddr address) {
VAddr address) {
LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle);
@ -1569,8 +1565,8 @@ static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_add
return ResultSuccess; return ResultSuccess;
} }
static ResultCode QueryMemory(Core::System& system, VAddr memory_info_address, static Result QueryMemory(Core::System& system, VAddr memory_info_address, VAddr page_info_address,
VAddr page_info_address, VAddr query_address) { VAddr query_address) {
LOG_TRACE(Kernel_SVC, LOG_TRACE(Kernel_SVC,
"called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, " "called, memory_info_address=0x{:016X}, page_info_address=0x{:016X}, "
"query_address=0x{:016X}", "query_address=0x{:016X}",
@ -1580,12 +1576,12 @@ static ResultCode QueryMemory(Core::System& system, VAddr memory_info_address,
query_address); query_address);
} }
static ResultCode QueryMemory32(Core::System& system, u32 memory_info_address, static Result QueryMemory32(Core::System& system, u32 memory_info_address, u32 page_info_address,
u32 page_info_address, u32 query_address) { u32 query_address) {
return QueryMemory(system, memory_info_address, page_info_address, query_address); return QueryMemory(system, memory_info_address, page_info_address, query_address);
} }
static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address, static Result MapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address,
u64 src_address, u64 size) { u64 src_address, u64 size) {
LOG_DEBUG(Kernel_SVC, LOG_DEBUG(Kernel_SVC,
"called. process_handle=0x{:08X}, dst_address=0x{:016X}, " "called. process_handle=0x{:08X}, dst_address=0x{:016X}, "
@ -1653,8 +1649,8 @@ static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_hand
return page_table.MapCodeMemory(dst_address, src_address, size); return page_table.MapCodeMemory(dst_address, src_address, size);
} }
static ResultCode UnmapProcessCodeMemory(Core::System& system, Handle process_handle, static Result UnmapProcessCodeMemory(Core::System& system, Handle process_handle, u64 dst_address,
u64 dst_address, u64 src_address, u64 size) { u64 src_address, u64 size) {
LOG_DEBUG(Kernel_SVC, LOG_DEBUG(Kernel_SVC,
"called. process_handle=0x{:08X}, dst_address=0x{:016X}, src_address=0x{:016X}, " "called. process_handle=0x{:08X}, dst_address=0x{:016X}, src_address=0x{:016X}, "
"size=0x{:016X}", "size=0x{:016X}",
@ -1746,7 +1742,7 @@ constexpr bool IsValidVirtualCoreId(int32_t core_id) {
} // Anonymous namespace } // Anonymous namespace
/// Creates a new thread /// Creates a new thread
static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg, static Result CreateThread(Core::System& system, Handle* out_handle, VAddr entry_point, u64 arg,
VAddr stack_bottom, u32 priority, s32 core_id) { VAddr stack_bottom, u32 priority, s32 core_id) {
LOG_DEBUG(Kernel_SVC, LOG_DEBUG(Kernel_SVC,
"called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, " "called entry_point=0x{:08X}, arg=0x{:08X}, stack_bottom=0x{:08X}, "
@ -1818,13 +1814,13 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e
return ResultSuccess; return ResultSuccess;
} }
static ResultCode CreateThread32(Core::System& system, Handle* out_handle, u32 priority, static Result CreateThread32(Core::System& system, Handle* out_handle, u32 priority,
u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) { u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) {
return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id); return CreateThread(system, out_handle, entry_point, arg, stack_top, priority, processor_id);
} }
/// Starts the thread for the provided handle /// Starts the thread for the provided handle
static ResultCode StartThread(Core::System& system, Handle thread_handle) { static Result StartThread(Core::System& system, Handle thread_handle) {
LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle); LOG_DEBUG(Kernel_SVC, "called thread=0x{:08X}", thread_handle);
// Get the thread from its handle. // Get the thread from its handle.
@ -1842,7 +1838,7 @@ static ResultCode StartThread(Core::System& system, Handle thread_handle) {
return ResultSuccess; return ResultSuccess;
} }
static ResultCode StartThread32(Core::System& system, Handle thread_handle) { static Result StartThread32(Core::System& system, Handle thread_handle) {
return StartThread(system, thread_handle); return StartThread(system, thread_handle);
} }
@ -1893,8 +1889,8 @@ static void SleepThread32(Core::System& system, u32 nanoseconds_low, u32 nanosec
} }
/// Wait process wide key atomic /// Wait process wide key atomic
static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_key, static Result WaitProcessWideKeyAtomic(Core::System& system, VAddr address, VAddr cv_key, u32 tag,
u32 tag, s64 timeout_ns) { s64 timeout_ns) {
LOG_TRACE(Kernel_SVC, "called address={:X}, cv_key={:X}, tag=0x{:08X}, timeout_ns={}", address, LOG_TRACE(Kernel_SVC, "called address={:X}, cv_key={:X}, tag=0x{:08X}, timeout_ns={}", address,
cv_key, tag, timeout_ns); cv_key, tag, timeout_ns);
@ -1929,7 +1925,7 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr address,
address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout); address, Common::AlignDown(cv_key, sizeof(u32)), tag, timeout);
} }
static ResultCode WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag, static Result WaitProcessWideKeyAtomic32(Core::System& system, u32 address, u32 cv_key, u32 tag,
u32 timeout_ns_low, u32 timeout_ns_high) { u32 timeout_ns_low, u32 timeout_ns_high) {
const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); const auto timeout_ns = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32));
return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns); return WaitProcessWideKeyAtomic(system, address, cv_key, tag, timeout_ns);
@ -1975,7 +1971,7 @@ constexpr bool IsValidArbitrationType(Svc::ArbitrationType type) {
} // namespace } // namespace
// Wait for an address (via Address Arbiter) // Wait for an address (via Address Arbiter)
static ResultCode WaitForAddress(Core::System& system, VAddr address, Svc::ArbitrationType arb_type, static Result WaitForAddress(Core::System& system, VAddr address, Svc::ArbitrationType arb_type,
s32 value, s64 timeout_ns) { s32 value, s64 timeout_ns) {
LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, arb_type=0x{:X}, value=0x{:X}, timeout_ns={}", LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, arb_type=0x{:X}, value=0x{:X}, timeout_ns={}",
address, arb_type, value, timeout_ns); address, arb_type, value, timeout_ns);
@ -2013,14 +2009,14 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, Svc::Arbit
return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout); return system.Kernel().CurrentProcess()->WaitAddressArbiter(address, arb_type, value, timeout);
} }
static ResultCode WaitForAddress32(Core::System& system, u32 address, Svc::ArbitrationType arb_type, static Result WaitForAddress32(Core::System& system, u32 address, Svc::ArbitrationType arb_type,
s32 value, u32 timeout_ns_low, u32 timeout_ns_high) { s32 value, u32 timeout_ns_low, u32 timeout_ns_high) {
const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32)); const auto timeout = static_cast<s64>(timeout_ns_low | (u64{timeout_ns_high} << 32));
return WaitForAddress(system, address, arb_type, value, timeout); return WaitForAddress(system, address, arb_type, value, timeout);
} }
// Signals to an address (via Address Arbiter) // Signals to an address (via Address Arbiter)
static ResultCode SignalToAddress(Core::System& system, VAddr address, Svc::SignalType signal_type, static Result SignalToAddress(Core::System& system, VAddr address, Svc::SignalType signal_type,
s32 value, s32 count) { s32 value, s32 count) {
LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, signal_type=0x{:X}, value=0x{:X}, count=0x{:X}", LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, signal_type=0x{:X}, value=0x{:X}, count=0x{:X}",
address, signal_type, value, count); address, signal_type, value, count);
@ -2062,7 +2058,7 @@ static void SynchronizePreemptionState(Core::System& system) {
} }
} }
static ResultCode SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type, static Result SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type,
s32 value, s32 count) { s32 value, s32 count) {
return SignalToAddress(system, address, signal_type, value, count); return SignalToAddress(system, address, signal_type, value, count);
} }
@ -2101,7 +2097,7 @@ static void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high)
} }
/// Close a handle /// Close a handle
static ResultCode CloseHandle(Core::System& system, Handle handle) { static Result CloseHandle(Core::System& system, Handle handle) {
LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle); LOG_TRACE(Kernel_SVC, "Closing handle 0x{:08X}", handle);
// Remove the handle. // Remove the handle.
@ -2111,12 +2107,12 @@ static ResultCode CloseHandle(Core::System& system, Handle handle) {
return ResultSuccess; return ResultSuccess;
} }
static ResultCode CloseHandle32(Core::System& system, Handle handle) { static Result CloseHandle32(Core::System& system, Handle handle) {
return CloseHandle(system, handle); return CloseHandle(system, handle);
} }
/// Clears the signaled state of an event or process. /// Clears the signaled state of an event or process.
static ResultCode ResetSignal(Core::System& system, Handle handle) { static Result ResetSignal(Core::System& system, Handle handle) {
LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle);
// Get the current handle table. // Get the current handle table.
@ -2143,7 +2139,7 @@ static ResultCode ResetSignal(Core::System& system, Handle handle) {
return ResultInvalidHandle; return ResultInvalidHandle;
} }
static ResultCode ResetSignal32(Core::System& system, Handle handle) { static Result ResetSignal32(Core::System& system, Handle handle) {
return ResetSignal(system, handle); return ResetSignal(system, handle);
} }
@ -2163,7 +2159,7 @@ constexpr bool IsValidTransferMemoryPermission(MemoryPermission perm) {
} // Anonymous namespace } // Anonymous namespace
/// Creates a TransferMemory object /// Creates a TransferMemory object
static ResultCode CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u64 size, static Result CreateTransferMemory(Core::System& system, Handle* out, VAddr address, u64 size,
MemoryPermission map_perm) { MemoryPermission map_perm) {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
@ -2210,12 +2206,12 @@ static ResultCode CreateTransferMemory(Core::System& system, Handle* out, VAddr
return ResultSuccess; return ResultSuccess;
} }
static ResultCode CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size, static Result CreateTransferMemory32(Core::System& system, Handle* out, u32 address, u32 size,
MemoryPermission map_perm) { MemoryPermission map_perm) {
return CreateTransferMemory(system, out, address, size, map_perm); return CreateTransferMemory(system, out, address, size, map_perm);
} }
static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id, static Result GetThreadCoreMask(Core::System& system, Handle thread_handle, s32* out_core_id,
u64* out_affinity_mask) { u64* out_affinity_mask) {
LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle); LOG_TRACE(Kernel_SVC, "called, handle=0x{:08X}", thread_handle);
@ -2230,7 +2226,7 @@ static ResultCode GetThreadCoreMask(Core::System& system, Handle thread_handle,
return ResultSuccess; return ResultSuccess;
} }
static ResultCode GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id, static Result GetThreadCoreMask32(Core::System& system, Handle thread_handle, s32* out_core_id,
u32* out_affinity_mask_low, u32* out_affinity_mask_high) { u32* out_affinity_mask_low, u32* out_affinity_mask_high) {
u64 out_affinity_mask{}; u64 out_affinity_mask{};
const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask); const auto result = GetThreadCoreMask(system, thread_handle, out_core_id, &out_affinity_mask);
@ -2239,7 +2235,7 @@ static ResultCode GetThreadCoreMask32(Core::System& system, Handle thread_handle
return result; return result;
} }
static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id, static Result SetThreadCoreMask(Core::System& system, Handle thread_handle, s32 core_id,
u64 affinity_mask) { u64 affinity_mask) {
// Determine the core id/affinity mask. // Determine the core id/affinity mask.
if (core_id == IdealCoreUseProcessValue) { if (core_id == IdealCoreUseProcessValue) {
@ -2271,13 +2267,13 @@ static ResultCode SetThreadCoreMask(Core::System& system, Handle thread_handle,
return ResultSuccess; return ResultSuccess;
} }
static ResultCode SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id, static Result SetThreadCoreMask32(Core::System& system, Handle thread_handle, s32 core_id,
u32 affinity_mask_low, u32 affinity_mask_high) { u32 affinity_mask_low, u32 affinity_mask_high) {
const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32); const auto affinity_mask = u64{affinity_mask_low} | (u64{affinity_mask_high} << 32);
return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask); return SetThreadCoreMask(system, thread_handle, core_id, affinity_mask);
} }
static ResultCode SignalEvent(Core::System& system, Handle event_handle) { static Result SignalEvent(Core::System& system, Handle event_handle) {
LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); LOG_DEBUG(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
// Get the current handle table. // Get the current handle table.
@ -2290,11 +2286,11 @@ static ResultCode SignalEvent(Core::System& system, Handle event_handle) {
return writable_event->Signal(); return writable_event->Signal();
} }
static ResultCode SignalEvent32(Core::System& system, Handle event_handle) { static Result SignalEvent32(Core::System& system, Handle event_handle) {
return SignalEvent(system, event_handle); return SignalEvent(system, event_handle);
} }
static ResultCode ClearEvent(Core::System& system, Handle event_handle) { static Result ClearEvent(Core::System& system, Handle event_handle) {
LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle); LOG_TRACE(Kernel_SVC, "called, event_handle=0x{:08X}", event_handle);
// Get the current handle table. // Get the current handle table.
@ -2321,11 +2317,11 @@ static ResultCode ClearEvent(Core::System& system, Handle event_handle) {
return ResultInvalidHandle; return ResultInvalidHandle;
} }
static ResultCode ClearEvent32(Core::System& system, Handle event_handle) { static Result ClearEvent32(Core::System& system, Handle event_handle) {
return ClearEvent(system, event_handle); return ClearEvent(system, event_handle);
} }
static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) { static Result CreateEvent(Core::System& system, Handle* out_write, Handle* out_read) {
LOG_DEBUG(Kernel_SVC, "called"); LOG_DEBUG(Kernel_SVC, "called");
// Get the kernel reference and handle table. // Get the kernel reference and handle table.
@ -2370,11 +2366,11 @@ static ResultCode CreateEvent(Core::System& system, Handle* out_write, Handle* o
return ResultSuccess; return ResultSuccess;
} }
static ResultCode CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) { static Result CreateEvent32(Core::System& system, Handle* out_write, Handle* out_read) {
return CreateEvent(system, out_write, out_read); return CreateEvent(system, out_write, out_read);
} }
static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) { static Result GetProcessInfo(Core::System& system, u64* out, Handle process_handle, u32 type) {
LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type); LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, type=0x{:X}", process_handle, type);
// This function currently only allows retrieving a process' status. // This function currently only allows retrieving a process' status.
@ -2400,7 +2396,7 @@ static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_
return ResultSuccess; return ResultSuccess;
} }
static ResultCode CreateResourceLimit(Core::System& system, Handle* out_handle) { static Result CreateResourceLimit(Core::System& system, Handle* out_handle) {
LOG_DEBUG(Kernel_SVC, "called"); LOG_DEBUG(Kernel_SVC, "called");
// Create a new resource limit. // Create a new resource limit.
@ -2423,9 +2419,8 @@ static ResultCode CreateResourceLimit(Core::System& system, Handle* out_handle)
return ResultSuccess; return ResultSuccess;
} }
static ResultCode GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value, static Result GetResourceLimitLimitValue(Core::System& system, u64* out_limit_value,
Handle resource_limit_handle, Handle resource_limit_handle, LimitableResource which) {
LimitableResource which) {
LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle,
which); which);
@ -2444,9 +2439,8 @@ static ResultCode GetResourceLimitLimitValue(Core::System& system, u64* out_limi
return ResultSuccess; return ResultSuccess;
} }
static ResultCode GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value, static Result GetResourceLimitCurrentValue(Core::System& system, u64* out_current_value,
Handle resource_limit_handle, Handle resource_limit_handle, LimitableResource which) {
LimitableResource which) {
LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle, LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}", resource_limit_handle,
which); which);
@ -2465,7 +2459,7 @@ static ResultCode GetResourceLimitCurrentValue(Core::System& system, u64* out_cu
return ResultSuccess; return ResultSuccess;
} }
static ResultCode SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle, static Result SetResourceLimitLimitValue(Core::System& system, Handle resource_limit_handle,
LimitableResource which, u64 limit_value) { LimitableResource which, u64 limit_value) {
LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}", LOG_DEBUG(Kernel_SVC, "called, resource_limit_handle={:08X}, which={}, limit_value={}",
resource_limit_handle, which, limit_value); resource_limit_handle, which, limit_value);
@ -2485,8 +2479,8 @@ static ResultCode SetResourceLimitLimitValue(Core::System& system, Handle resour
return ResultSuccess; return ResultSuccess;
} }
static ResultCode GetProcessList(Core::System& system, u32* out_num_processes, static Result GetProcessList(Core::System& system, u32* out_num_processes, VAddr out_process_ids,
VAddr out_process_ids, u32 out_process_ids_size) { u32 out_process_ids_size) {
LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}", LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}",
out_process_ids, out_process_ids_size); out_process_ids, out_process_ids_size);
@ -2522,7 +2516,7 @@ static ResultCode GetProcessList(Core::System& system, u32* out_num_processes,
return ResultSuccess; return ResultSuccess;
} }
static ResultCode GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids, static Result GetThreadList(Core::System& system, u32* out_num_threads, VAddr out_thread_ids,
u32 out_thread_ids_size, Handle debug_handle) { u32 out_thread_ids_size, Handle debug_handle) {
// TODO: Handle this case when debug events are supported. // TODO: Handle this case when debug events are supported.
UNIMPLEMENTED_IF(debug_handle != InvalidHandle); UNIMPLEMENTED_IF(debug_handle != InvalidHandle);
@ -2562,9 +2556,9 @@ static ResultCode GetThreadList(Core::System& system, u32* out_num_threads, VAdd
return ResultSuccess; return ResultSuccess;
} }
static ResultCode FlushProcessDataCache32([[maybe_unused]] Core::System& system, static Result FlushProcessDataCache32([[maybe_unused]] Core::System& system,
[[maybe_unused]] Handle handle, [[maybe_unused]] Handle handle, [[maybe_unused]] u32 address,
[[maybe_unused]] u32 address, [[maybe_unused]] u32 size) { [[maybe_unused]] u32 size) {
// Note(Blinkhawk): For emulation purposes of the data cache this is mostly a no-op, // Note(Blinkhawk): For emulation purposes of the data cache this is mostly a no-op,
// as all emulation is done in the same cache level in host architecture, thus data cache // as all emulation is done in the same cache level in host architecture, thus data cache
// does not need flushing. // does not need flushing.

View file

@ -9,34 +9,34 @@ namespace Kernel {
// Confirmed Switch kernel error codes // Confirmed Switch kernel error codes
constexpr ResultCode ResultOutOfSessions{ErrorModule::Kernel, 7}; constexpr Result ResultOutOfSessions{ErrorModule::Kernel, 7};
constexpr ResultCode ResultInvalidArgument{ErrorModule::Kernel, 14}; constexpr Result ResultInvalidArgument{ErrorModule::Kernel, 14};
constexpr ResultCode ResultNoSynchronizationObject{ErrorModule::Kernel, 57}; constexpr Result ResultNoSynchronizationObject{ErrorModule::Kernel, 57};
constexpr ResultCode ResultTerminationRequested{ErrorModule::Kernel, 59}; constexpr Result ResultTerminationRequested{ErrorModule::Kernel, 59};
constexpr ResultCode ResultInvalidSize{ErrorModule::Kernel, 101}; constexpr Result ResultInvalidSize{ErrorModule::Kernel, 101};
constexpr ResultCode ResultInvalidAddress{ErrorModule::Kernel, 102}; constexpr Result ResultInvalidAddress{ErrorModule::Kernel, 102};
constexpr ResultCode ResultOutOfResource{ErrorModule::Kernel, 103}; constexpr Result ResultOutOfResource{ErrorModule::Kernel, 103};
constexpr ResultCode ResultOutOfMemory{ErrorModule::Kernel, 104}; constexpr Result ResultOutOfMemory{ErrorModule::Kernel, 104};
constexpr ResultCode ResultOutOfHandles{ErrorModule::Kernel, 105}; constexpr Result ResultOutOfHandles{ErrorModule::Kernel, 105};
constexpr ResultCode ResultInvalidCurrentMemory{ErrorModule::Kernel, 106}; constexpr Result ResultInvalidCurrentMemory{ErrorModule::Kernel, 106};
constexpr ResultCode ResultInvalidNewMemoryPermission{ErrorModule::Kernel, 108}; constexpr Result ResultInvalidNewMemoryPermission{ErrorModule::Kernel, 108};
constexpr ResultCode ResultInvalidMemoryRegion{ErrorModule::Kernel, 110}; constexpr Result ResultInvalidMemoryRegion{ErrorModule::Kernel, 110};
constexpr ResultCode ResultInvalidPriority{ErrorModule::Kernel, 112}; constexpr Result ResultInvalidPriority{ErrorModule::Kernel, 112};
constexpr ResultCode ResultInvalidCoreId{ErrorModule::Kernel, 113}; constexpr Result ResultInvalidCoreId{ErrorModule::Kernel, 113};
constexpr ResultCode ResultInvalidHandle{ErrorModule::Kernel, 114}; constexpr Result ResultInvalidHandle{ErrorModule::Kernel, 114};
constexpr ResultCode ResultInvalidPointer{ErrorModule::Kernel, 115}; constexpr Result ResultInvalidPointer{ErrorModule::Kernel, 115};
constexpr ResultCode ResultInvalidCombination{ErrorModule::Kernel, 116}; constexpr Result ResultInvalidCombination{ErrorModule::Kernel, 116};
constexpr ResultCode ResultTimedOut{ErrorModule::Kernel, 117}; constexpr Result ResultTimedOut{ErrorModule::Kernel, 117};
constexpr ResultCode ResultCancelled{ErrorModule::Kernel, 118}; constexpr Result ResultCancelled{ErrorModule::Kernel, 118};
constexpr ResultCode ResultOutOfRange{ErrorModule::Kernel, 119}; constexpr Result ResultOutOfRange{ErrorModule::Kernel, 119};
constexpr ResultCode ResultInvalidEnumValue{ErrorModule::Kernel, 120}; constexpr Result ResultInvalidEnumValue{ErrorModule::Kernel, 120};
constexpr ResultCode ResultNotFound{ErrorModule::Kernel, 121}; constexpr Result ResultNotFound{ErrorModule::Kernel, 121};
constexpr ResultCode ResultBusy{ErrorModule::Kernel, 122}; constexpr Result ResultBusy{ErrorModule::Kernel, 122};
constexpr ResultCode ResultSessionClosed{ErrorModule::Kernel, 123}; constexpr Result ResultSessionClosed{ErrorModule::Kernel, 123};
constexpr ResultCode ResultInvalidState{ErrorModule::Kernel, 125}; constexpr Result ResultInvalidState{ErrorModule::Kernel, 125};
constexpr ResultCode ResultReservedUsed{ErrorModule::Kernel, 126}; constexpr Result ResultReservedUsed{ErrorModule::Kernel, 126};
constexpr ResultCode ResultPortClosed{ErrorModule::Kernel, 131}; constexpr Result ResultPortClosed{ErrorModule::Kernel, 131};
constexpr ResultCode ResultLimitReached{ErrorModule::Kernel, 132}; constexpr Result ResultLimitReached{ErrorModule::Kernel, 132};
constexpr ResultCode ResultInvalidId{ErrorModule::Kernel, 519}; constexpr Result ResultInvalidId{ErrorModule::Kernel, 519};
} // namespace Kernel } // namespace Kernel

View file

@ -33,24 +33,24 @@ static inline void FuncReturn32(Core::System& system, u32 result) {
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type ResultCode // Function wrappers that return type Result
template <ResultCode func(Core::System&, u64)> template <Result func(Core::System&, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, Param(system, 0)).raw); FuncReturn(system, func(system, Param(system, 0)).raw);
} }
template <ResultCode func(Core::System&, u64, u64)> template <Result func(Core::System&, u64, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, Param(system, 0), Param(system, 1)).raw); FuncReturn(system, func(system, Param(system, 0), Param(system, 1)).raw);
} }
template <ResultCode func(Core::System&, u32)> template <Result func(Core::System&, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw); FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw);
} }
template <ResultCode func(Core::System&, u32, u32)> template <Result func(Core::System&, u32, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn( FuncReturn(
system, system,
@ -58,14 +58,14 @@ void SvcWrap64(Core::System& system) {
} }
// Used by SetThreadActivity // Used by SetThreadActivity
template <ResultCode func(Core::System&, Handle, Svc::ThreadActivity)> template <Result func(Core::System&, Handle, Svc::ThreadActivity)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)),
static_cast<Svc::ThreadActivity>(Param(system, 1))) static_cast<Svc::ThreadActivity>(Param(system, 1)))
.raw); .raw);
} }
template <ResultCode func(Core::System&, u32, u64, u64, u64)> template <Result func(Core::System&, u32, u64, u64, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1), FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1),
Param(system, 2), Param(system, 3)) Param(system, 2), Param(system, 3))
@ -73,7 +73,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by MapProcessMemory and UnmapProcessMemory // Used by MapProcessMemory and UnmapProcessMemory
template <ResultCode func(Core::System&, u64, u32, u64, u64)> template <Result func(Core::System&, u64, u32, u64, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1)), FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1)),
Param(system, 2), Param(system, 3)) Param(system, 2), Param(system, 3))
@ -81,7 +81,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by ControlCodeMemory // Used by ControlCodeMemory
template <ResultCode func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> template <Result func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)),
static_cast<u32>(Param(system, 1)), Param(system, 2), Param(system, 3), static_cast<u32>(Param(system, 1)), Param(system, 2), Param(system, 3),
@ -89,7 +89,7 @@ void SvcWrap64(Core::System& system) {
.raw); .raw);
} }
template <ResultCode func(Core::System&, u32*)> template <Result func(Core::System&, u32*)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u32 param = 0; u32 param = 0;
const u32 retval = func(system, &param).raw; const u32 retval = func(system, &param).raw;
@ -97,7 +97,7 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u32*, u32)> template <Result func(Core::System&, u32*, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1))).raw; const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1))).raw;
@ -105,7 +105,7 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u32*, u32*)> template <Result func(Core::System&, u32*, u32*)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
u32 param_2 = 0; u32 param_2 = 0;
@ -118,7 +118,7 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u32*, u64)> template <Result func(Core::System&, u32*, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
const u32 retval = func(system, &param_1, Param(system, 1)).raw; const u32 retval = func(system, &param_1, Param(system, 1)).raw;
@ -126,7 +126,7 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u32*, u64, u32)> template <Result func(Core::System&, u32*, u64, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
const u32 retval = const u32 retval =
@ -136,7 +136,7 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u64*, u32)> template <Result func(Core::System&, u64*, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u64 param_1 = 0; u64 param_1 = 0;
const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1))).raw; const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1))).raw;
@ -145,12 +145,12 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u64, u32)> template <Result func(Core::System&, u64, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1))).raw); FuncReturn(system, func(system, Param(system, 0), static_cast<u32>(Param(system, 1))).raw);
} }
template <ResultCode func(Core::System&, u64*, u64)> template <Result func(Core::System&, u64*, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u64 param_1 = 0; u64 param_1 = 0;
const u32 retval = func(system, &param_1, Param(system, 1)).raw; const u32 retval = func(system, &param_1, Param(system, 1)).raw;
@ -159,7 +159,7 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u64*, u32, u32)> template <Result func(Core::System&, u64*, u32, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u64 param_1 = 0; u64 param_1 = 0;
const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1)), const u32 retval = func(system, &param_1, static_cast<u32>(Param(system, 1)),
@ -171,7 +171,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by GetResourceLimitLimitValue. // Used by GetResourceLimitLimitValue.
template <ResultCode func(Core::System&, u64*, Handle, LimitableResource)> template <Result func(Core::System&, u64*, Handle, LimitableResource)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u64 param_1 = 0; u64 param_1 = 0;
const u32 retval = func(system, &param_1, static_cast<Handle>(Param(system, 1)), const u32 retval = func(system, &param_1, static_cast<Handle>(Param(system, 1)),
@ -182,13 +182,13 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u32, u64)> template <Result func(Core::System&, u32, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1)).raw); FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1)).raw);
} }
// Used by SetResourceLimitLimitValue // Used by SetResourceLimitLimitValue
template <ResultCode func(Core::System&, Handle, LimitableResource, u64)> template <Result func(Core::System&, Handle, LimitableResource, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)),
static_cast<LimitableResource>(Param(system, 1)), Param(system, 2)) static_cast<LimitableResource>(Param(system, 1)), Param(system, 2))
@ -196,7 +196,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by SetThreadCoreMask // Used by SetThreadCoreMask
template <ResultCode func(Core::System&, Handle, s32, u64)> template <Result func(Core::System&, Handle, s32, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)),
static_cast<s32>(Param(system, 1)), Param(system, 2)) static_cast<s32>(Param(system, 1)), Param(system, 2))
@ -204,44 +204,44 @@ void SvcWrap64(Core::System& system) {
} }
// Used by GetThreadCoreMask // Used by GetThreadCoreMask
template <ResultCode func(Core::System&, Handle, s32*, u64*)> template <Result func(Core::System&, Handle, s32*, u64*)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
s32 param_1 = 0; s32 param_1 = 0;
u64 param_2 = 0; u64 param_2 = 0;
const ResultCode retval = func(system, static_cast<u32>(Param(system, 2)), &param_1, &param_2); const Result retval = func(system, static_cast<u32>(Param(system, 2)), &param_1, &param_2);
system.CurrentArmInterface().SetReg(1, param_1); system.CurrentArmInterface().SetReg(1, param_1);
system.CurrentArmInterface().SetReg(2, param_2); system.CurrentArmInterface().SetReg(2, param_2);
FuncReturn(system, retval.raw); FuncReturn(system, retval.raw);
} }
template <ResultCode func(Core::System&, u64, u64, u32, u32)> template <Result func(Core::System&, u64, u64, u32, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, Param(system, 0), Param(system, 1), FuncReturn(system, func(system, Param(system, 0), Param(system, 1),
static_cast<u32>(Param(system, 2)), static_cast<u32>(Param(system, 3))) static_cast<u32>(Param(system, 2)), static_cast<u32>(Param(system, 3)))
.raw); .raw);
} }
template <ResultCode func(Core::System&, u64, u64, u32, u64)> template <Result func(Core::System&, u64, u64, u32, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, Param(system, 0), Param(system, 1), FuncReturn(system, func(system, Param(system, 0), Param(system, 1),
static_cast<u32>(Param(system, 2)), Param(system, 3)) static_cast<u32>(Param(system, 2)), Param(system, 3))
.raw); .raw);
} }
template <ResultCode func(Core::System&, u32, u64, u32)> template <Result func(Core::System&, u32, u64, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1), FuncReturn(system, func(system, static_cast<u32>(Param(system, 0)), Param(system, 1),
static_cast<u32>(Param(system, 2))) static_cast<u32>(Param(system, 2)))
.raw); .raw);
} }
template <ResultCode func(Core::System&, u64, u64, u64)> template <Result func(Core::System&, u64, u64, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, Param(system, 0), Param(system, 1), Param(system, 2)).raw); FuncReturn(system, func(system, Param(system, 0), Param(system, 1), Param(system, 2)).raw);
} }
template <ResultCode func(Core::System&, u64, u64, u32)> template <Result func(Core::System&, u64, u64, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn( FuncReturn(
system, system,
@ -249,7 +249,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by SetMemoryPermission // Used by SetMemoryPermission
template <ResultCode func(Core::System&, u64, u64, Svc::MemoryPermission)> template <Result func(Core::System&, u64, u64, Svc::MemoryPermission)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, Param(system, 0), Param(system, 1), FuncReturn(system, func(system, Param(system, 0), Param(system, 1),
static_cast<Svc::MemoryPermission>(Param(system, 2))) static_cast<Svc::MemoryPermission>(Param(system, 2)))
@ -257,14 +257,14 @@ void SvcWrap64(Core::System& system) {
} }
// Used by MapSharedMemory // Used by MapSharedMemory
template <ResultCode func(Core::System&, Handle, u64, u64, Svc::MemoryPermission)> template <Result func(Core::System&, Handle, u64, u64, Svc::MemoryPermission)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), Param(system, 1), FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)), Param(system, 1),
Param(system, 2), static_cast<Svc::MemoryPermission>(Param(system, 3))) Param(system, 2), static_cast<Svc::MemoryPermission>(Param(system, 3)))
.raw); .raw);
} }
template <ResultCode func(Core::System&, u32, u64, u64)> template <Result func(Core::System&, u32, u64, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn( FuncReturn(
system, system,
@ -272,7 +272,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by WaitSynchronization // Used by WaitSynchronization
template <ResultCode func(Core::System&, s32*, u64, s32, s64)> template <Result func(Core::System&, s32*, u64, s32, s64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
s32 param_1 = 0; s32 param_1 = 0;
const u32 retval = func(system, &param_1, Param(system, 1), static_cast<s32>(Param(system, 2)), const u32 retval = func(system, &param_1, Param(system, 1), static_cast<s32>(Param(system, 2)),
@ -283,7 +283,7 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u64, u64, u32, s64)> template <Result func(Core::System&, u64, u64, u32, s64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, Param(system, 0), Param(system, 1), FuncReturn(system, func(system, Param(system, 0), Param(system, 1),
static_cast<u32>(Param(system, 2)), static_cast<s64>(Param(system, 3))) static_cast<u32>(Param(system, 2)), static_cast<s64>(Param(system, 3)))
@ -291,7 +291,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by GetInfo // Used by GetInfo
template <ResultCode func(Core::System&, u64*, u64, Handle, u64)> template <Result func(Core::System&, u64*, u64, Handle, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u64 param_1 = 0; u64 param_1 = 0;
const u32 retval = func(system, &param_1, Param(system, 1), const u32 retval = func(system, &param_1, Param(system, 1),
@ -302,7 +302,7 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, u32*, u64, u64, u64, u32, s32)> template <Result func(Core::System&, u32*, u64, u64, u64, u32, s32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2), Param(system, 3), const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2), Param(system, 3),
@ -314,7 +314,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by CreateTransferMemory // Used by CreateTransferMemory
template <ResultCode func(Core::System&, Handle*, u64, u64, Svc::MemoryPermission)> template <Result func(Core::System&, Handle*, u64, u64, Svc::MemoryPermission)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2), const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2),
@ -326,7 +326,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by CreateCodeMemory // Used by CreateCodeMemory
template <ResultCode func(Core::System&, Handle*, u64, u64)> template <Result func(Core::System&, Handle*, u64, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2)).raw; const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2)).raw;
@ -335,7 +335,7 @@ void SvcWrap64(Core::System& system) {
FuncReturn(system, retval); FuncReturn(system, retval);
} }
template <ResultCode func(Core::System&, Handle*, u64, u32, u32)> template <Result func(Core::System&, Handle*, u64, u32, u32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
const u32 retval = func(system, &param_1, Param(system, 1), static_cast<u32>(Param(system, 2)), const u32 retval = func(system, &param_1, Param(system, 1), static_cast<u32>(Param(system, 2)),
@ -347,7 +347,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by WaitForAddress // Used by WaitForAddress
template <ResultCode func(Core::System&, u64, Svc::ArbitrationType, s32, s64)> template <Result func(Core::System&, u64, Svc::ArbitrationType, s32, s64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, FuncReturn(system,
func(system, Param(system, 0), static_cast<Svc::ArbitrationType>(Param(system, 1)), func(system, Param(system, 0), static_cast<Svc::ArbitrationType>(Param(system, 1)),
@ -356,7 +356,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by SignalToAddress // Used by SignalToAddress
template <ResultCode func(Core::System&, u64, Svc::SignalType, s32, s32)> template <Result func(Core::System&, u64, Svc::SignalType, s32, s32)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
FuncReturn(system, FuncReturn(system,
func(system, Param(system, 0), static_cast<Svc::SignalType>(Param(system, 1)), func(system, Param(system, 0), static_cast<Svc::SignalType>(Param(system, 1)),
@ -425,7 +425,7 @@ void SvcWrap64(Core::System& system) {
} }
// Used by QueryMemory32, ArbitrateLock32 // Used by QueryMemory32, ArbitrateLock32
template <ResultCode func(Core::System&, u32, u32, u32)> template <Result func(Core::System&, u32, u32, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
FuncReturn32(system, FuncReturn32(system,
func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2)).raw); func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2)).raw);
@ -456,7 +456,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by CreateThread32 // Used by CreateThread32
template <ResultCode func(Core::System&, Handle*, u32, u32, u32, u32, s32)> template <Result func(Core::System&, Handle*, u32, u32, u32, u32, s32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
Handle param_1 = 0; Handle param_1 = 0;
@ -469,7 +469,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by GetInfo32 // Used by GetInfo32
template <ResultCode func(Core::System&, u32*, u32*, u32, u32, u32, u32)> template <Result func(Core::System&, u32*, u32*, u32, u32, u32, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
u32 param_2 = 0; u32 param_2 = 0;
@ -484,7 +484,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by GetThreadPriority32, ConnectToNamedPort32 // Used by GetThreadPriority32, ConnectToNamedPort32
template <ResultCode func(Core::System&, u32*, u32)> template <Result func(Core::System&, u32*, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
const u32 retval = func(system, &param_1, Param32(system, 1)).raw; const u32 retval = func(system, &param_1, Param32(system, 1)).raw;
@ -493,7 +493,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by GetThreadId32 // Used by GetThreadId32
template <ResultCode func(Core::System&, u32*, u32*, u32)> template <Result func(Core::System&, u32*, u32*, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
u32 param_2 = 0; u32 param_2 = 0;
@ -516,7 +516,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by CreateEvent32 // Used by CreateEvent32
template <ResultCode func(Core::System&, Handle*, Handle*)> template <Result func(Core::System&, Handle*, Handle*)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
Handle param_1 = 0; Handle param_1 = 0;
Handle param_2 = 0; Handle param_2 = 0;
@ -528,7 +528,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by GetThreadId32 // Used by GetThreadId32
template <ResultCode func(Core::System&, Handle, u32*, u32*, u32*)> template <Result func(Core::System&, Handle, u32*, u32*, u32*)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
u32 param_1 = 0; u32 param_1 = 0;
u32 param_2 = 0; u32 param_2 = 0;
@ -542,7 +542,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by GetThreadCoreMask32 // Used by GetThreadCoreMask32
template <ResultCode func(Core::System&, Handle, s32*, u32*, u32*)> template <Result func(Core::System&, Handle, s32*, u32*, u32*)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
s32 param_1 = 0; s32 param_1 = 0;
u32 param_2 = 0; u32 param_2 = 0;
@ -562,7 +562,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by SetThreadActivity32 // Used by SetThreadActivity32
template <ResultCode func(Core::System&, Handle, Svc::ThreadActivity)> template <Result func(Core::System&, Handle, Svc::ThreadActivity)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
const u32 retval = func(system, static_cast<Handle>(Param(system, 0)), const u32 retval = func(system, static_cast<Handle>(Param(system, 0)),
static_cast<Svc::ThreadActivity>(Param(system, 1))) static_cast<Svc::ThreadActivity>(Param(system, 1)))
@ -571,7 +571,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by SetThreadPriority32 // Used by SetThreadPriority32
template <ResultCode func(Core::System&, Handle, u32)> template <Result func(Core::System&, Handle, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
const u32 retval = const u32 retval =
func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1))).raw; func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1))).raw;
@ -579,7 +579,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by SetMemoryAttribute32 // Used by SetMemoryAttribute32
template <ResultCode func(Core::System&, Handle, u32, u32, u32)> template <Result func(Core::System&, Handle, u32, u32, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
const u32 retval = const u32 retval =
func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1)), func(system, static_cast<Handle>(Param(system, 0)), static_cast<u32>(Param(system, 1)),
@ -589,7 +589,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by MapSharedMemory32 // Used by MapSharedMemory32
template <ResultCode func(Core::System&, Handle, u32, u32, Svc::MemoryPermission)> template <Result func(Core::System&, Handle, u32, u32, Svc::MemoryPermission)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
const u32 retval = func(system, static_cast<Handle>(Param(system, 0)), const u32 retval = func(system, static_cast<Handle>(Param(system, 0)),
static_cast<u32>(Param(system, 1)), static_cast<u32>(Param(system, 2)), static_cast<u32>(Param(system, 1)), static_cast<u32>(Param(system, 2)),
@ -599,7 +599,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by SetThreadCoreMask32 // Used by SetThreadCoreMask32
template <ResultCode func(Core::System&, Handle, s32, u32, u32)> template <Result func(Core::System&, Handle, s32, u32, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
const u32 retval = const u32 retval =
func(system, static_cast<Handle>(Param(system, 0)), static_cast<s32>(Param(system, 1)), func(system, static_cast<Handle>(Param(system, 0)), static_cast<s32>(Param(system, 1)),
@ -609,7 +609,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by WaitProcessWideKeyAtomic32 // Used by WaitProcessWideKeyAtomic32
template <ResultCode func(Core::System&, u32, u32, Handle, u32, u32)> template <Result func(Core::System&, u32, u32, Handle, u32, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
const u32 retval = const u32 retval =
func(system, static_cast<u32>(Param(system, 0)), static_cast<u32>(Param(system, 1)), func(system, static_cast<u32>(Param(system, 0)), static_cast<u32>(Param(system, 1)),
@ -620,7 +620,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by WaitForAddress32 // Used by WaitForAddress32
template <ResultCode func(Core::System&, u32, Svc::ArbitrationType, s32, u32, u32)> template <Result func(Core::System&, u32, Svc::ArbitrationType, s32, u32, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
const u32 retval = func(system, static_cast<u32>(Param(system, 0)), const u32 retval = func(system, static_cast<u32>(Param(system, 0)),
static_cast<Svc::ArbitrationType>(Param(system, 1)), static_cast<Svc::ArbitrationType>(Param(system, 1)),
@ -631,7 +631,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by SignalToAddress32 // Used by SignalToAddress32
template <ResultCode func(Core::System&, u32, Svc::SignalType, s32, s32)> template <Result func(Core::System&, u32, Svc::SignalType, s32, s32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
const u32 retval = func(system, static_cast<u32>(Param(system, 0)), const u32 retval = func(system, static_cast<u32>(Param(system, 0)),
static_cast<Svc::SignalType>(Param(system, 1)), static_cast<Svc::SignalType>(Param(system, 1)),
@ -641,13 +641,13 @@ void SvcWrap32(Core::System& system) {
} }
// Used by SendSyncRequest32, ArbitrateUnlock32 // Used by SendSyncRequest32, ArbitrateUnlock32
template <ResultCode func(Core::System&, u32)> template <Result func(Core::System&, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw); FuncReturn(system, func(system, static_cast<u32>(Param(system, 0))).raw);
} }
// Used by CreateTransferMemory32 // Used by CreateTransferMemory32
template <ResultCode func(Core::System&, Handle*, u32, u32, Svc::MemoryPermission)> template <Result func(Core::System&, Handle*, u32, u32, Svc::MemoryPermission)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
Handle handle = 0; Handle handle = 0;
const u32 retval = func(system, &handle, Param32(system, 1), Param32(system, 2), const u32 retval = func(system, &handle, Param32(system, 1), Param32(system, 2),
@ -658,7 +658,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by WaitSynchronization32 // Used by WaitSynchronization32
template <ResultCode func(Core::System&, u32, u32, s32, u32, s32*)> template <Result func(Core::System&, u32, u32, s32, u32, s32*)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
s32 param_1 = 0; s32 param_1 = 0;
const u32 retval = func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2), const u32 retval = func(system, Param32(system, 0), Param32(system, 1), Param32(system, 2),
@ -669,7 +669,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by CreateCodeMemory32 // Used by CreateCodeMemory32
template <ResultCode func(Core::System&, Handle*, u32, u32)> template <Result func(Core::System&, Handle*, u32, u32)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
Handle handle = 0; Handle handle = 0;
@ -680,7 +680,7 @@ void SvcWrap32(Core::System& system) {
} }
// Used by ControlCodeMemory32 // Used by ControlCodeMemory32
template <ResultCode func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)> template <Result func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)>
void SvcWrap32(Core::System& system) { void SvcWrap32(Core::System& system) {
const u32 retval = const u32 retval =
func(system, Param32(system, 0), Param32(system, 1), Param(system, 2), Param(system, 4), func(system, Param32(system, 0), Param32(system, 1), Param(system, 2), Param(system, 4),

View file

@ -112,15 +112,15 @@ enum class ErrorModule : u32 {
}; };
/// Encapsulates a Horizon OS error code, allowing it to be separated into its constituent fields. /// Encapsulates a Horizon OS error code, allowing it to be separated into its constituent fields.
union ResultCode { union Result {
u32 raw; u32 raw;
BitField<0, 9, ErrorModule> module; BitField<0, 9, ErrorModule> module;
BitField<9, 13, u32> description; BitField<9, 13, u32> description;
constexpr explicit ResultCode(u32 raw_) : raw(raw_) {} constexpr explicit Result(u32 raw_) : raw(raw_) {}
constexpr ResultCode(ErrorModule module_, u32 description_) constexpr Result(ErrorModule module_, u32 description_)
: raw(module.FormatValue(module_) | description.FormatValue(description_)) {} : raw(module.FormatValue(module_) | description.FormatValue(description_)) {}
[[nodiscard]] constexpr bool IsSuccess() const { [[nodiscard]] constexpr bool IsSuccess() const {
@ -132,18 +132,18 @@ union ResultCode {
} }
}; };
[[nodiscard]] constexpr bool operator==(const ResultCode& a, const ResultCode& b) { [[nodiscard]] constexpr bool operator==(const Result& a, const Result& b) {
return a.raw == b.raw; return a.raw == b.raw;
} }
[[nodiscard]] constexpr bool operator!=(const ResultCode& a, const ResultCode& b) { [[nodiscard]] constexpr bool operator!=(const Result& a, const Result& b) {
return !operator==(a, b); return !operator==(a, b);
} }
// Convenience functions for creating some common kinds of errors: // Convenience functions for creating some common kinds of errors:
/// The default success `ResultCode`. /// The default success `Result`.
constexpr ResultCode ResultSuccess(0); constexpr Result ResultSuccess(0);
/** /**
* Placeholder result code used for unknown error codes. * Placeholder result code used for unknown error codes.
@ -151,24 +151,24 @@ constexpr ResultCode ResultSuccess(0);
* @note This should only be used when a particular error code * @note This should only be used when a particular error code
* is not known yet. * is not known yet.
*/ */
constexpr ResultCode ResultUnknown(UINT32_MAX); constexpr Result ResultUnknown(UINT32_MAX);
/** /**
* A ResultRange defines an inclusive range of error descriptions within an error module. * A ResultRange defines an inclusive range of error descriptions within an error module.
* This can be used to check whether the description of a given ResultCode falls within the range. * This can be used to check whether the description of a given Result falls within the range.
* The conversion function returns a ResultCode with its description set to description_start. * The conversion function returns a Result with its description set to description_start.
* *
* An example of how it could be used: * An example of how it could be used:
* \code * \code
* constexpr ResultRange ResultCommonError{ErrorModule::Common, 0, 9999}; * constexpr ResultRange ResultCommonError{ErrorModule::Common, 0, 9999};
* *
* ResultCode Example(int value) { * Result Example(int value) {
* const ResultCode result = OtherExample(value); * const Result result = OtherExample(value);
* *
* // This will only evaluate to true if result.module is ErrorModule::Common and * // This will only evaluate to true if result.module is ErrorModule::Common and
* // result.description is in between 0 and 9999 inclusive. * // result.description is in between 0 and 9999 inclusive.
* if (ResultCommonError.Includes(result)) { * if (ResultCommonError.Includes(result)) {
* // This returns ResultCode{ErrorModule::Common, 0}; * // This returns Result{ErrorModule::Common, 0};
* return ResultCommonError; * return ResultCommonError;
* } * }
* *
@ -181,22 +181,22 @@ public:
consteval ResultRange(ErrorModule module, u32 description_start, u32 description_end_) consteval ResultRange(ErrorModule module, u32 description_start, u32 description_end_)
: code{module, description_start}, description_end{description_end_} {} : code{module, description_start}, description_end{description_end_} {}
[[nodiscard]] constexpr operator ResultCode() const { [[nodiscard]] constexpr operator Result() const {
return code; return code;
} }
[[nodiscard]] constexpr bool Includes(ResultCode other) const { [[nodiscard]] constexpr bool Includes(Result other) const {
return code.module == other.module && code.description <= other.description && return code.module == other.module && code.description <= other.description &&
other.description <= description_end; other.description <= description_end;
} }
private: private:
ResultCode code; Result code;
u32 description_end; u32 description_end;
}; };
/** /**
* This is an optional value type. It holds a `ResultCode` and, if that code is ResultSuccess, it * This is an optional value type. It holds a `Result` and, if that code is ResultSuccess, it
* also holds a result of type `T`. If the code is an error code (not ResultSuccess), then trying * also holds a result of type `T`. If the code is an error code (not ResultSuccess), then trying
* to access the inner value with operator* is undefined behavior and will assert with Unwrap(). * to access the inner value with operator* is undefined behavior and will assert with Unwrap().
* Users of this class must be cognizant to check the status of the ResultVal with operator bool(), * Users of this class must be cognizant to check the status of the ResultVal with operator bool(),
@ -207,7 +207,7 @@ private:
* ResultVal<int> Frobnicate(float strength) { * ResultVal<int> Frobnicate(float strength) {
* if (strength < 0.f || strength > 1.0f) { * if (strength < 0.f || strength > 1.0f) {
* // Can't frobnicate too weakly or too strongly * // Can't frobnicate too weakly or too strongly
* return ResultCode{ErrorModule::Common, 1}; * return Result{ErrorModule::Common, 1};
* } else { * } else {
* // Frobnicated! Give caller a cookie * // Frobnicated! Give caller a cookie
* return 42; * return 42;
@ -230,7 +230,7 @@ class ResultVal {
public: public:
constexpr ResultVal() : expected{} {} constexpr ResultVal() : expected{} {}
constexpr ResultVal(ResultCode code) : expected{Common::Unexpected(code)} {} constexpr ResultVal(Result code) : expected{Common::Unexpected(code)} {}
constexpr ResultVal(ResultRange range) : expected{Common::Unexpected(range)} {} constexpr ResultVal(ResultRange range) : expected{Common::Unexpected(range)} {}
@ -252,7 +252,7 @@ public:
return expected.has_value(); return expected.has_value();
} }
[[nodiscard]] constexpr ResultCode Code() const { [[nodiscard]] constexpr Result Code() const {
return expected.has_value() ? ResultSuccess : expected.error(); return expected.has_value() ? ResultSuccess : expected.error();
} }
@ -320,7 +320,7 @@ public:
private: private:
// TODO (Morph): Replace this with C++23 std::expected. // TODO (Morph): Replace this with C++23 std::expected.
Common::Expected<T, ResultCode> expected; Common::Expected<T, Result> expected;
}; };
/** /**
@ -337,7 +337,7 @@ private:
target = std::move(*CONCAT2(check_result_L, __LINE__)) target = std::move(*CONCAT2(check_result_L, __LINE__))
/** /**
* Analogous to CASCADE_RESULT, but for a bare ResultCode. The code will be propagated if * Analogous to CASCADE_RESULT, but for a bare Result. The code will be propagated if
* non-success, or discarded otherwise. * non-success, or discarded otherwise.
*/ */
#define CASCADE_CODE(source) \ #define CASCADE_CODE(source) \

View file

@ -28,11 +28,11 @@
namespace Service::Account { namespace Service::Account {
constexpr ResultCode ERR_INVALID_USER_ID{ErrorModule::Account, 20}; constexpr Result ERR_INVALID_USER_ID{ErrorModule::Account, 20};
constexpr ResultCode ERR_INVALID_APPLICATION_ID{ErrorModule::Account, 22}; constexpr Result ERR_INVALID_APPLICATION_ID{ErrorModule::Account, 22};
constexpr ResultCode ERR_INVALID_BUFFER{ErrorModule::Account, 30}; constexpr Result ERR_INVALID_BUFFER{ErrorModule::Account, 30};
constexpr ResultCode ERR_INVALID_BUFFER_SIZE{ErrorModule::Account, 31}; constexpr Result ERR_INVALID_BUFFER_SIZE{ErrorModule::Account, 31};
constexpr ResultCode ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100}; constexpr Result ERR_FAILED_SAVE_DATA{ErrorModule::Account, 100};
// Thumbnails are hard coded to be at least this size // Thumbnails are hard coded to be at least this size
constexpr std::size_t THUMBNAIL_SIZE = 0x24000; constexpr std::size_t THUMBNAIL_SIZE = 0x24000;
@ -505,7 +505,7 @@ protected:
void Cancel() override {} void Cancel() override {}
ResultCode GetResult() const override { Result GetResult() const override {
return ResultSuccess; return ResultSuccess;
} }
}; };
@ -747,7 +747,7 @@ void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestCo
rb.Push(InitializeApplicationInfoBase()); rb.Push(InitializeApplicationInfoBase());
} }
ResultCode Module::Interface::InitializeApplicationInfoBase() { Result Module::Interface::InitializeApplicationInfoBase() {
if (application_info) { if (application_info) {
LOG_ERROR(Service_ACC, "Application already initialized"); LOG_ERROR(Service_ACC, "Application already initialized");
return ERR_ACCOUNTINFO_ALREADY_INITIALIZED; return ERR_ACCOUNTINFO_ALREADY_INITIALIZED;

View file

@ -41,7 +41,7 @@ public:
void StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx); void StoreSaveDataThumbnailSystem(Kernel::HLERequestContext& ctx);
private: private:
ResultCode InitializeApplicationInfoBase(); Result InitializeApplicationInfoBase();
void StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, const Common::UUID& uuid, void StoreSaveDataThumbnail(Kernel::HLERequestContext& ctx, const Common::UUID& uuid,
const u64 tid); const u64 tid);

View file

@ -26,7 +26,7 @@ public:
protected: protected:
virtual bool IsComplete() const = 0; virtual bool IsComplete() const = 0;
virtual void Cancel() = 0; virtual void Cancel() = 0;
virtual ResultCode GetResult() const = 0; virtual Result GetResult() const = 0;
void MarkComplete(); void MarkComplete();

View file

@ -7,7 +7,7 @@
namespace Service::Account { namespace Service::Account {
constexpr ResultCode ERR_ACCOUNTINFO_BAD_APPLICATION{ErrorModule::Account, 22}; constexpr Result ERR_ACCOUNTINFO_BAD_APPLICATION{ErrorModule::Account, 22};
constexpr ResultCode ERR_ACCOUNTINFO_ALREADY_INITIALIZED{ErrorModule::Account, 41}; constexpr Result ERR_ACCOUNTINFO_ALREADY_INITIALIZED{ErrorModule::Account, 41};
} // namespace Service::Account } // namespace Service::Account

View file

@ -33,9 +33,9 @@ struct ProfileDataRaw {
static_assert(sizeof(ProfileDataRaw) == 0x650, "ProfileDataRaw has incorrect size."); static_assert(sizeof(ProfileDataRaw) == 0x650, "ProfileDataRaw has incorrect size.");
// TODO(ogniK): Get actual error codes // TODO(ogniK): Get actual error codes
constexpr ResultCode ERROR_TOO_MANY_USERS(ErrorModule::Account, u32(-1)); constexpr Result ERROR_TOO_MANY_USERS(ErrorModule::Account, u32(-1));
constexpr ResultCode ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, u32(-2)); constexpr Result ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, u32(-2));
constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20); constexpr Result ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20);
constexpr char ACC_SAVE_AVATORS_BASE_PATH[] = "system/save/8000000000000010/su/avators"; constexpr char ACC_SAVE_AVATORS_BASE_PATH[] = "system/save/8000000000000010/su/avators";
@ -87,7 +87,7 @@ bool ProfileManager::RemoveProfileAtIndex(std::size_t index) {
} }
/// Helper function to register a user to the system /// Helper function to register a user to the system
ResultCode ProfileManager::AddUser(const ProfileInfo& user) { Result ProfileManager::AddUser(const ProfileInfo& user) {
if (!AddToProfiles(user)) { if (!AddToProfiles(user)) {
return ERROR_TOO_MANY_USERS; return ERROR_TOO_MANY_USERS;
} }
@ -96,7 +96,7 @@ ResultCode ProfileManager::AddUser(const ProfileInfo& user) {
/// Create a new user on the system. If the uuid of the user already exists, the user is not /// Create a new user on the system. If the uuid of the user already exists, the user is not
/// created. /// created.
ResultCode ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& username) { Result ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& username) {
if (user_count == MAX_USERS) { if (user_count == MAX_USERS) {
return ERROR_TOO_MANY_USERS; return ERROR_TOO_MANY_USERS;
} }
@ -123,7 +123,7 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& usern
/// Creates a new user on the system. This function allows a much simpler method of registration /// Creates a new user on the system. This function allows a much simpler method of registration
/// specifically by allowing an std::string for the username. This is required specifically since /// specifically by allowing an std::string for the username. This is required specifically since
/// we're loading a string straight from the config /// we're loading a string straight from the config
ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username) { Result ProfileManager::CreateNewUser(UUID uuid, const std::string& username) {
ProfileUsername username_output{}; ProfileUsername username_output{};
if (username.size() > username_output.size()) { if (username.size() > username_output.size()) {

View file

@ -64,9 +64,9 @@ public:
ProfileManager(); ProfileManager();
~ProfileManager(); ~ProfileManager();
ResultCode AddUser(const ProfileInfo& user); Result AddUser(const ProfileInfo& user);
ResultCode CreateNewUser(Common::UUID uuid, const ProfileUsername& username); Result CreateNewUser(Common::UUID uuid, const ProfileUsername& username);
ResultCode CreateNewUser(Common::UUID uuid, const std::string& username); Result CreateNewUser(Common::UUID uuid, const std::string& username);
std::optional<Common::UUID> GetUser(std::size_t index) const; std::optional<Common::UUID> GetUser(std::size_t index) const;
std::optional<std::size_t> GetUserIndex(const Common::UUID& uuid) const; std::optional<std::size_t> GetUserIndex(const Common::UUID& uuid) const;
std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const; std::optional<std::size_t> GetUserIndex(const ProfileInfo& user) const;

View file

@ -40,9 +40,9 @@
namespace Service::AM { namespace Service::AM {
constexpr ResultCode ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 2}; constexpr Result ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 2};
constexpr ResultCode ERR_NO_MESSAGES{ErrorModule::AM, 3}; constexpr Result ERR_NO_MESSAGES{ErrorModule::AM, 3};
constexpr ResultCode ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 503}; constexpr Result ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 503};
enum class LaunchParameterKind : u32 { enum class LaunchParameterKind : u32 {
ApplicationSpecific = 1, ApplicationSpecific = 1,
@ -365,7 +365,7 @@ void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) {
// Entry and exit of fatal sections must be balanced. // Entry and exit of fatal sections must be balanced.
if (num_fatal_sections_entered == 0) { if (num_fatal_sections_entered == 0) {
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultCode{ErrorModule::AM, 512}); rb.Push(Result{ErrorModule::AM, 512});
return; return;
} }

View file

@ -20,9 +20,9 @@
namespace Service::AM::Applets { namespace Service::AM::Applets {
// This error code (0x183ACA) is thrown when the applet fails to initialize. // This error code (0x183ACA) is thrown when the applet fails to initialize.
[[maybe_unused]] constexpr ResultCode ERR_CONTROLLER_APPLET_3101{ErrorModule::HID, 3101}; [[maybe_unused]] constexpr Result ERR_CONTROLLER_APPLET_3101{ErrorModule::HID, 3101};
// This error code (0x183CCA) is thrown when the u32 result in ControllerSupportResultInfo is 2. // This error code (0x183CCA) is thrown when the u32 result in ControllerSupportResultInfo is 2.
[[maybe_unused]] constexpr ResultCode ERR_CONTROLLER_APPLET_3102{ErrorModule::HID, 3102}; [[maybe_unused]] constexpr Result ERR_CONTROLLER_APPLET_3102{ErrorModule::HID, 3102};
static Core::Frontend::ControllerParameters ConvertToFrontendParameters( static Core::Frontend::ControllerParameters ConvertToFrontendParameters(
ControllerSupportArgPrivate private_arg, ControllerSupportArgHeader header, bool enable_text, ControllerSupportArgPrivate private_arg, ControllerSupportArgHeader header, bool enable_text,
@ -173,7 +173,7 @@ bool Controller::TransactionComplete() const {
return complete; return complete;
} }
ResultCode Controller::GetStatus() const { Result Controller::GetStatus() const {
return status; return status;
} }

View file

@ -126,7 +126,7 @@ public:
void Initialize() override; void Initialize() override;
bool TransactionComplete() const override; bool TransactionComplete() const override;
ResultCode GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
@ -143,7 +143,7 @@ private:
ControllerUpdateFirmwareArg controller_update_arg; ControllerUpdateFirmwareArg controller_update_arg;
ControllerKeyRemappingArg controller_key_remapping_arg; ControllerKeyRemappingArg controller_key_remapping_arg;
bool complete{false}; bool complete{false};
ResultCode status{ResultSuccess}; Result status{ResultSuccess};
bool is_single_mode{false}; bool is_single_mode{false};
std::vector<u8> out_data; std::vector<u8> out_data;
}; };

View file

@ -25,15 +25,15 @@ struct ErrorCode {
}; };
} }
static constexpr ErrorCode FromResultCode(ResultCode result) { static constexpr ErrorCode FromResult(Result result) {
return { return {
.error_category{2000 + static_cast<u32>(result.module.Value())}, .error_category{2000 + static_cast<u32>(result.module.Value())},
.error_number{result.description.Value()}, .error_number{result.description.Value()},
}; };
} }
constexpr ResultCode ToResultCode() const { constexpr Result ToResult() const {
return ResultCode{static_cast<ErrorModule>(error_category - 2000), error_number}; return Result{static_cast<ErrorModule>(error_category - 2000), error_number};
} }
}; };
static_assert(sizeof(ErrorCode) == 0x8, "ErrorCode has incorrect size."); static_assert(sizeof(ErrorCode) == 0x8, "ErrorCode has incorrect size.");
@ -97,8 +97,8 @@ void CopyArgumentData(const std::vector<u8>& data, T& variable) {
std::memcpy(&variable, data.data(), sizeof(T)); std::memcpy(&variable, data.data(), sizeof(T));
} }
ResultCode Decode64BitError(u64 error) { Result Decode64BitError(u64 error) {
return ErrorCode::FromU64(error).ToResultCode(); return ErrorCode::FromU64(error).ToResult();
} }
} // Anonymous namespace } // Anonymous namespace
@ -127,16 +127,16 @@ void Error::Initialize() {
if (args->error.use_64bit_error_code) { if (args->error.use_64bit_error_code) {
error_code = Decode64BitError(args->error.error_code_64); error_code = Decode64BitError(args->error.error_code_64);
} else { } else {
error_code = ResultCode(args->error.error_code_32); error_code = Result(args->error.error_code_32);
} }
break; break;
case ErrorAppletMode::ShowSystemError: case ErrorAppletMode::ShowSystemError:
CopyArgumentData(data, args->system_error); CopyArgumentData(data, args->system_error);
error_code = ResultCode(Decode64BitError(args->system_error.error_code_64)); error_code = Result(Decode64BitError(args->system_error.error_code_64));
break; break;
case ErrorAppletMode::ShowApplicationError: case ErrorAppletMode::ShowApplicationError:
CopyArgumentData(data, args->application_error); CopyArgumentData(data, args->application_error);
error_code = ResultCode(args->application_error.error_code); error_code = Result(args->application_error.error_code);
break; break;
case ErrorAppletMode::ShowErrorRecord: case ErrorAppletMode::ShowErrorRecord:
CopyArgumentData(data, args->error_record); CopyArgumentData(data, args->error_record);
@ -151,7 +151,7 @@ bool Error::TransactionComplete() const {
return complete; return complete;
} }
ResultCode Error::GetStatus() const { Result Error::GetStatus() const {
return ResultSuccess; return ResultSuccess;
} }

View file

@ -31,7 +31,7 @@ public:
void Initialize() override; void Initialize() override;
bool TransactionComplete() const override; bool TransactionComplete() const override;
ResultCode GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
@ -41,7 +41,7 @@ private:
union ErrorArguments; union ErrorArguments;
const Core::Frontend::ErrorApplet& frontend; const Core::Frontend::ErrorApplet& frontend;
ResultCode error_code = ResultSuccess; Result error_code = ResultSuccess;
ErrorAppletMode mode = ErrorAppletMode::ShowError; ErrorAppletMode mode = ErrorAppletMode::ShowError;
std::unique_ptr<ErrorArguments> args; std::unique_ptr<ErrorArguments> args;

View file

@ -13,7 +13,7 @@
namespace Service::AM::Applets { namespace Service::AM::Applets {
constexpr ResultCode ERROR_INVALID_PIN{ErrorModule::PCTL, 221}; constexpr Result ERROR_INVALID_PIN{ErrorModule::PCTL, 221};
static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix) { static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix) {
std::shared_ptr<IStorage> storage = broker.PopNormalDataToApplet(); std::shared_ptr<IStorage> storage = broker.PopNormalDataToApplet();
@ -71,7 +71,7 @@ bool Auth::TransactionComplete() const {
return complete; return complete;
} }
ResultCode Auth::GetStatus() const { Result Auth::GetStatus() const {
return successful ? ResultSuccess : ERROR_INVALID_PIN; return successful ? ResultSuccess : ERROR_INVALID_PIN;
} }
@ -136,7 +136,7 @@ void Auth::AuthFinished(bool is_successful) {
successful = is_successful; successful = is_successful;
struct Return { struct Return {
ResultCode result_code; Result result_code;
}; };
static_assert(sizeof(Return) == 0x4, "Return (AuthApplet) has incorrect size."); static_assert(sizeof(Return) == 0x4, "Return (AuthApplet) has incorrect size.");
@ -170,7 +170,7 @@ bool PhotoViewer::TransactionComplete() const {
return complete; return complete;
} }
ResultCode PhotoViewer::GetStatus() const { Result PhotoViewer::GetStatus() const {
return ResultSuccess; return ResultSuccess;
} }
@ -223,7 +223,7 @@ bool StubApplet::TransactionComplete() const {
return true; return true;
} }
ResultCode StubApplet::GetStatus() const { Result StubApplet::GetStatus() const {
LOG_WARNING(Service_AM, "called (STUBBED)"); LOG_WARNING(Service_AM, "called (STUBBED)");
return ResultSuccess; return ResultSuccess;
} }

View file

@ -25,7 +25,7 @@ public:
void Initialize() override; void Initialize() override;
bool TransactionComplete() const override; bool TransactionComplete() const override;
ResultCode GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
@ -56,7 +56,7 @@ public:
void Initialize() override; void Initialize() override;
bool TransactionComplete() const override; bool TransactionComplete() const override;
ResultCode GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
@ -77,7 +77,7 @@ public:
void Initialize() override; void Initialize() override;
bool TransactionComplete() const override; bool TransactionComplete() const override;
ResultCode GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;

View file

@ -62,7 +62,7 @@ bool MiiEdit::TransactionComplete() const {
return is_complete; return is_complete;
} }
ResultCode MiiEdit::GetStatus() const { Result MiiEdit::GetStatus() const {
return ResultSuccess; return ResultSuccess;
} }

View file

@ -22,7 +22,7 @@ public:
void Initialize() override; void Initialize() override;
bool TransactionComplete() const override; bool TransactionComplete() const override;
ResultCode GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;

View file

@ -12,7 +12,7 @@
namespace Service::AM::Applets { namespace Service::AM::Applets {
constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; constexpr Result ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1};
ProfileSelect::ProfileSelect(Core::System& system_, LibraryAppletMode applet_mode_, ProfileSelect::ProfileSelect(Core::System& system_, LibraryAppletMode applet_mode_,
const Core::Frontend::ProfileSelectApplet& frontend_) const Core::Frontend::ProfileSelectApplet& frontend_)
@ -39,7 +39,7 @@ bool ProfileSelect::TransactionComplete() const {
return complete; return complete;
} }
ResultCode ProfileSelect::GetStatus() const { Result ProfileSelect::GetStatus() const {
return status; return status;
} }

View file

@ -39,7 +39,7 @@ public:
void Initialize() override; void Initialize() override;
bool TransactionComplete() const override; bool TransactionComplete() const override;
ResultCode GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
@ -50,7 +50,7 @@ private:
UserSelectionConfig config; UserSelectionConfig config;
bool complete = false; bool complete = false;
ResultCode status = ResultSuccess; Result status = ResultSuccess;
std::vector<u8> final_data; std::vector<u8> final_data;
Core::System& system; Core::System& system;
}; };

View file

@ -80,7 +80,7 @@ bool SoftwareKeyboard::TransactionComplete() const {
return complete; return complete;
} }
ResultCode SoftwareKeyboard::GetStatus() const { Result SoftwareKeyboard::GetStatus() const {
return status; return status;
} }

View file

@ -28,7 +28,7 @@ public:
void Initialize() override; void Initialize() override;
bool TransactionComplete() const override; bool TransactionComplete() const override;
ResultCode GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
@ -180,7 +180,7 @@ private:
bool is_background{false}; bool is_background{false};
bool complete{false}; bool complete{false};
ResultCode status{ResultSuccess}; Result status{ResultSuccess};
}; };
} // namespace Service::AM::Applets } // namespace Service::AM::Applets

View file

@ -288,7 +288,7 @@ bool WebBrowser::TransactionComplete() const {
return complete; return complete;
} }
ResultCode WebBrowser::GetStatus() const { Result WebBrowser::GetStatus() const {
return status; return status;
} }

View file

@ -32,7 +32,7 @@ public:
void Initialize() override; void Initialize() override;
bool TransactionComplete() const override; bool TransactionComplete() const override;
ResultCode GetStatus() const override; Result GetStatus() const override;
void ExecuteInteractive() override; void ExecuteInteractive() override;
void Execute() override; void Execute() override;
@ -66,7 +66,7 @@ private:
const Core::Frontend::WebBrowserApplet& frontend; const Core::Frontend::WebBrowserApplet& frontend;
bool complete{false}; bool complete{false};
ResultCode status{ResultSuccess}; Result status{ResultSuccess};
WebAppletVersion web_applet_version{}; WebAppletVersion web_applet_version{};
WebArgHeader web_arg_header{}; WebArgHeader web_arg_header{};

View file

@ -9,7 +9,7 @@
#include "common/swap.h" #include "common/swap.h"
#include "core/hle/service/kernel_helpers.h" #include "core/hle/service/kernel_helpers.h"
union ResultCode; union Result;
namespace Core { namespace Core {
class System; class System;
@ -138,7 +138,7 @@ public:
virtual void Initialize(); virtual void Initialize();
virtual bool TransactionComplete() const = 0; virtual bool TransactionComplete() const = 0;
virtual ResultCode GetStatus() const = 0; virtual Result GetStatus() const = 0;
virtual void ExecuteInteractive() = 0; virtual void ExecuteInteractive() = 0;
virtual void Execute() = 0; virtual void Execute() = 0;

View file

@ -7,8 +7,8 @@
namespace Service::Audio { namespace Service::Audio {
constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::Audio, 2}; constexpr Result ERR_OPERATION_FAILED{ErrorModule::Audio, 2};
constexpr ResultCode ERR_BUFFER_COUNT_EXCEEDED{ErrorModule::Audio, 8}; constexpr Result ERR_BUFFER_COUNT_EXCEEDED{ErrorModule::Audio, 8};
constexpr ResultCode ERR_NOT_SUPPORTED{ErrorModule::Audio, 513}; constexpr Result ERR_NOT_SUPPORTED{ErrorModule::Audio, 513};
} // namespace Service::Audio } // namespace Service::Audio

View file

@ -74,7 +74,7 @@ void ProgressServiceBackend::CommitDirectory(std::string_view dir_name) {
SignalUpdate(); SignalUpdate();
} }
void ProgressServiceBackend::FinishDownload(ResultCode result) { void ProgressServiceBackend::FinishDownload(Result result) {
impl.total_downloaded_bytes = impl.total_bytes; impl.total_downloaded_bytes = impl.total_bytes;
impl.status = DeliveryCacheProgressImpl::Status::Done; impl.status = DeliveryCacheProgressImpl::Status::Done;
impl.result = result; impl.result = result;

View file

@ -49,7 +49,7 @@ struct DeliveryCacheProgressImpl {
}; };
Status status; Status status;
ResultCode result = ResultSuccess; Result result = ResultSuccess;
DirectoryName current_directory; DirectoryName current_directory;
FileName current_file; FileName current_file;
s64 current_downloaded_bytes; ///< Bytes downloaded on current file. s64 current_downloaded_bytes; ///< Bytes downloaded on current file.
@ -90,7 +90,7 @@ public:
void CommitDirectory(std::string_view dir_name); void CommitDirectory(std::string_view dir_name);
// Notifies the application that the operation completed with result code result. // Notifies the application that the operation completed with result code result.
void FinishDownload(ResultCode result); void FinishDownload(Result result);
private: private:
explicit ProgressServiceBackend(Core::System& system, std::string_view event_name); explicit ProgressServiceBackend(Core::System& system, std::string_view event_name);

View file

@ -18,15 +18,15 @@
namespace Service::BCAT { namespace Service::BCAT {
constexpr ResultCode ERROR_INVALID_ARGUMENT{ErrorModule::BCAT, 1}; constexpr Result ERROR_INVALID_ARGUMENT{ErrorModule::BCAT, 1};
constexpr ResultCode ERROR_FAILED_OPEN_ENTITY{ErrorModule::BCAT, 2}; constexpr Result ERROR_FAILED_OPEN_ENTITY{ErrorModule::BCAT, 2};
constexpr ResultCode ERROR_ENTITY_ALREADY_OPEN{ErrorModule::BCAT, 6}; constexpr Result ERROR_ENTITY_ALREADY_OPEN{ErrorModule::BCAT, 6};
constexpr ResultCode ERROR_NO_OPEN_ENTITY{ErrorModule::BCAT, 7}; constexpr Result ERROR_NO_OPEN_ENTITY{ErrorModule::BCAT, 7};
// The command to clear the delivery cache just calls fs IFileSystem DeleteFile on all of the files // The command to clear the delivery cache just calls fs IFileSystem DeleteFile on all of the files
// and if any of them have a non-zero result it just forwards that result. This is the FS error code // and if any of them have a non-zero result it just forwards that result. This is the FS error code
// for permission denied, which is the closest approximation of this scenario. // for permission denied, which is the closest approximation of this scenario.
constexpr ResultCode ERROR_FAILED_CLEAR_CACHE{ErrorModule::FS, 6400}; constexpr Result ERROR_FAILED_CLEAR_CACHE{ErrorModule::FS, 6400};
using BCATDigest = std::array<u8, 0x10>; using BCATDigest = std::array<u8, 0x10>;

View file

@ -8,8 +8,8 @@
namespace Service::ES { namespace Service::ES {
constexpr ResultCode ERROR_INVALID_ARGUMENT{ErrorModule::ETicket, 2}; constexpr Result ERROR_INVALID_ARGUMENT{ErrorModule::ETicket, 2};
constexpr ResultCode ERROR_INVALID_RIGHTS_ID{ErrorModule::ETicket, 3}; constexpr Result ERROR_INVALID_RIGHTS_ID{ErrorModule::ETicket, 3};
class ETicket final : public ServiceFramework<ETicket> { class ETicket final : public ServiceFramework<ETicket> {
public: public:

View file

@ -62,8 +62,7 @@ enum class FatalType : u32 {
ErrorScreen = 2, ErrorScreen = 2,
}; };
static void GenerateErrorReport(Core::System& system, ResultCode error_code, static void GenerateErrorReport(Core::System& system, Result error_code, const FatalInfo& info) {
const FatalInfo& info) {
const auto title_id = system.GetCurrentProcessProgramID(); const auto title_id = system.GetCurrentProcessProgramID();
std::string crash_report = fmt::format( std::string crash_report = fmt::format(
"Yuzu {}-{} crash report\n" "Yuzu {}-{} crash report\n"
@ -106,7 +105,7 @@ static void GenerateErrorReport(Core::System& system, ResultCode error_code,
info.backtrace_size, info.ArchAsString(), info.unk10); info.backtrace_size, info.ArchAsString(), info.unk10);
} }
static void ThrowFatalError(Core::System& system, ResultCode error_code, FatalType fatal_type, static void ThrowFatalError(Core::System& system, Result error_code, FatalType fatal_type,
const FatalInfo& info) { const FatalInfo& info) {
LOG_ERROR(Service_Fatal, "Threw fatal error type {} with error code 0x{:X}", fatal_type, LOG_ERROR(Service_Fatal, "Threw fatal error type {} with error code 0x{:X}", fatal_type,
error_code.raw); error_code.raw);
@ -129,7 +128,7 @@ static void ThrowFatalError(Core::System& system, ResultCode error_code, FatalTy
void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) { void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_Fatal, "called"); LOG_ERROR(Service_Fatal, "called");
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
const auto error_code = rp.Pop<ResultCode>(); const auto error_code = rp.Pop<Result>();
ThrowFatalError(system, error_code, FatalType::ErrorScreen, {}); ThrowFatalError(system, error_code, FatalType::ErrorScreen, {});
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
@ -139,7 +138,7 @@ void Module::Interface::ThrowFatal(Kernel::HLERequestContext& ctx) {
void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) { void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_Fatal, "called"); LOG_ERROR(Service_Fatal, "called");
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
const auto error_code = rp.Pop<ResultCode>(); const auto error_code = rp.Pop<Result>();
const auto fatal_type = rp.PopEnum<FatalType>(); const auto fatal_type = rp.PopEnum<FatalType>();
ThrowFatalError(system, error_code, fatal_type, ThrowFatalError(system, error_code, fatal_type,
@ -151,7 +150,7 @@ void Module::Interface::ThrowFatalWithPolicy(Kernel::HLERequestContext& ctx) {
void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx) { void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_Fatal, "called"); LOG_ERROR(Service_Fatal, "called");
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
const auto error_code = rp.Pop<ResultCode>(); const auto error_code = rp.Pop<Result>();
const auto fatal_type = rp.PopEnum<FatalType>(); const auto fatal_type = rp.PopEnum<FatalType>();
const auto fatal_info = ctx.ReadBuffer(); const auto fatal_info = ctx.ReadBuffer();
FatalInfo info{}; FatalInfo info{};

View file

@ -49,7 +49,7 @@ std::string VfsDirectoryServiceWrapper::GetName() const {
return backing->GetName(); return backing->GetName();
} }
ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const { Result VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const {
std::string path(Common::FS::SanitizePath(path_)); std::string path(Common::FS::SanitizePath(path_));
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
if (dir == nullptr) { if (dir == nullptr) {
@ -73,7 +73,7 @@ ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64
return ResultSuccess; return ResultSuccess;
} }
ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const { Result VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const {
std::string path(Common::FS::SanitizePath(path_)); std::string path(Common::FS::SanitizePath(path_));
if (path.empty()) { if (path.empty()) {
// TODO(DarkLordZach): Why do games call this and what should it do? Works as is but... // TODO(DarkLordZach): Why do games call this and what should it do? Works as is but...
@ -92,7 +92,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) cons
return ResultSuccess; return ResultSuccess;
} }
ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const { Result VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const {
std::string path(Common::FS::SanitizePath(path_)); std::string path(Common::FS::SanitizePath(path_));
// NOTE: This is inaccurate behavior. CreateDirectory is not recursive. // NOTE: This is inaccurate behavior. CreateDirectory is not recursive.
@ -116,7 +116,7 @@ ResultCode VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_)
return ResultSuccess; return ResultSuccess;
} }
ResultCode VfsDirectoryServiceWrapper::DeleteDirectory(const std::string& path_) const { Result VfsDirectoryServiceWrapper::DeleteDirectory(const std::string& path_) const {
std::string path(Common::FS::SanitizePath(path_)); std::string path(Common::FS::SanitizePath(path_));
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
if (!dir->DeleteSubdirectory(Common::FS::GetFilename(path))) { if (!dir->DeleteSubdirectory(Common::FS::GetFilename(path))) {
@ -126,7 +126,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteDirectory(const std::string& path_)
return ResultSuccess; return ResultSuccess;
} }
ResultCode VfsDirectoryServiceWrapper::DeleteDirectoryRecursively(const std::string& path_) const { Result VfsDirectoryServiceWrapper::DeleteDirectoryRecursively(const std::string& path_) const {
std::string path(Common::FS::SanitizePath(path_)); std::string path(Common::FS::SanitizePath(path_));
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
if (!dir->DeleteSubdirectoryRecursive(Common::FS::GetFilename(path))) { if (!dir->DeleteSubdirectoryRecursive(Common::FS::GetFilename(path))) {
@ -136,7 +136,7 @@ ResultCode VfsDirectoryServiceWrapper::DeleteDirectoryRecursively(const std::str
return ResultSuccess; return ResultSuccess;
} }
ResultCode VfsDirectoryServiceWrapper::CleanDirectoryRecursively(const std::string& path) const { Result VfsDirectoryServiceWrapper::CleanDirectoryRecursively(const std::string& path) const {
const std::string sanitized_path(Common::FS::SanitizePath(path)); const std::string sanitized_path(Common::FS::SanitizePath(path));
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(sanitized_path)); auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(sanitized_path));
@ -148,7 +148,7 @@ ResultCode VfsDirectoryServiceWrapper::CleanDirectoryRecursively(const std::stri
return ResultSuccess; return ResultSuccess;
} }
ResultCode VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_, Result VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_,
const std::string& dest_path_) const { const std::string& dest_path_) const {
std::string src_path(Common::FS::SanitizePath(src_path_)); std::string src_path(Common::FS::SanitizePath(src_path_));
std::string dest_path(Common::FS::SanitizePath(dest_path_)); std::string dest_path(Common::FS::SanitizePath(dest_path_));
@ -183,7 +183,7 @@ ResultCode VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_,
return ResultSuccess; return ResultSuccess;
} }
ResultCode VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_path_, Result VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_path_,
const std::string& dest_path_) const { const std::string& dest_path_) const {
std::string src_path(Common::FS::SanitizePath(src_path_)); std::string src_path(Common::FS::SanitizePath(src_path_));
std::string dest_path(Common::FS::SanitizePath(dest_path_)); std::string dest_path(Common::FS::SanitizePath(dest_path_));
@ -273,28 +273,27 @@ FileSystemController::FileSystemController(Core::System& system_) : system{syste
FileSystemController::~FileSystemController() = default; FileSystemController::~FileSystemController() = default;
ResultCode FileSystemController::RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory) { Result FileSystemController::RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory) {
romfs_factory = std::move(factory); romfs_factory = std::move(factory);
LOG_DEBUG(Service_FS, "Registered RomFS"); LOG_DEBUG(Service_FS, "Registered RomFS");
return ResultSuccess; return ResultSuccess;
} }
ResultCode FileSystemController::RegisterSaveData( Result FileSystemController::RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory) {
std::unique_ptr<FileSys::SaveDataFactory>&& factory) {
ASSERT_MSG(save_data_factory == nullptr, "Tried to register a second save data"); ASSERT_MSG(save_data_factory == nullptr, "Tried to register a second save data");
save_data_factory = std::move(factory); save_data_factory = std::move(factory);
LOG_DEBUG(Service_FS, "Registered save data"); LOG_DEBUG(Service_FS, "Registered save data");
return ResultSuccess; return ResultSuccess;
} }
ResultCode FileSystemController::RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory) { Result FileSystemController::RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory) {
ASSERT_MSG(sdmc_factory == nullptr, "Tried to register a second SDMC"); ASSERT_MSG(sdmc_factory == nullptr, "Tried to register a second SDMC");
sdmc_factory = std::move(factory); sdmc_factory = std::move(factory);
LOG_DEBUG(Service_FS, "Registered SDMC"); LOG_DEBUG(Service_FS, "Registered SDMC");
return ResultSuccess; return ResultSuccess;
} }
ResultCode FileSystemController::RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory) { Result FileSystemController::RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory) {
ASSERT_MSG(bis_factory == nullptr, "Tried to register a second BIS"); ASSERT_MSG(bis_factory == nullptr, "Tried to register a second BIS");
bis_factory = std::move(factory); bis_factory = std::move(factory);
LOG_DEBUG(Service_FS, "Registered BIS"); LOG_DEBUG(Service_FS, "Registered BIS");

View file

@ -58,10 +58,10 @@ public:
explicit FileSystemController(Core::System& system_); explicit FileSystemController(Core::System& system_);
~FileSystemController(); ~FileSystemController();
ResultCode RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory); Result RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory);
ResultCode RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory); Result RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory);
ResultCode RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory); Result RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory);
ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory); Result RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory);
void SetPackedUpdate(FileSys::VirtualFile update_raw); void SetPackedUpdate(FileSys::VirtualFile update_raw);
ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() const; ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() const;
@ -141,7 +141,7 @@ private:
void InstallInterfaces(Core::System& system); void InstallInterfaces(Core::System& system);
// A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of // A class that wraps a VfsDirectory with methods that return ResultVal and Result instead of
// pointers and booleans. This makes using a VfsDirectory with switch services much easier and // pointers and booleans. This makes using a VfsDirectory with switch services much easier and
// avoids repetitive code. // avoids repetitive code.
class VfsDirectoryServiceWrapper { class VfsDirectoryServiceWrapper {
@ -160,35 +160,35 @@ public:
* @param size The size of the new file, filled with zeroes * @param size The size of the new file, filled with zeroes
* @return Result of the operation * @return Result of the operation
*/ */
ResultCode CreateFile(const std::string& path, u64 size) const; Result CreateFile(const std::string& path, u64 size) const;
/** /**
* Delete a file specified by its path * Delete a file specified by its path
* @param path Path relative to the archive * @param path Path relative to the archive
* @return Result of the operation * @return Result of the operation
*/ */
ResultCode DeleteFile(const std::string& path) const; Result DeleteFile(const std::string& path) const;
/** /**
* Create a directory specified by its path * Create a directory specified by its path
* @param path Path relative to the archive * @param path Path relative to the archive
* @return Result of the operation * @return Result of the operation
*/ */
ResultCode CreateDirectory(const std::string& path) const; Result CreateDirectory(const std::string& path) const;
/** /**
* Delete a directory specified by its path * Delete a directory specified by its path
* @param path Path relative to the archive * @param path Path relative to the archive
* @return Result of the operation * @return Result of the operation
*/ */
ResultCode DeleteDirectory(const std::string& path) const; Result DeleteDirectory(const std::string& path) const;
/** /**
* Delete a directory specified by its path and anything under it * Delete a directory specified by its path and anything under it
* @param path Path relative to the archive * @param path Path relative to the archive
* @return Result of the operation * @return Result of the operation
*/ */
ResultCode DeleteDirectoryRecursively(const std::string& path) const; Result DeleteDirectoryRecursively(const std::string& path) const;
/** /**
* Cleans the specified directory. This is similar to DeleteDirectoryRecursively, * Cleans the specified directory. This is similar to DeleteDirectoryRecursively,
@ -200,7 +200,7 @@ public:
* *
* @return Result of the operation. * @return Result of the operation.
*/ */
ResultCode CleanDirectoryRecursively(const std::string& path) const; Result CleanDirectoryRecursively(const std::string& path) const;
/** /**
* Rename a File specified by its path * Rename a File specified by its path
@ -208,7 +208,7 @@ public:
* @param dest_path Destination path relative to the archive * @param dest_path Destination path relative to the archive
* @return Result of the operation * @return Result of the operation
*/ */
ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const; Result RenameFile(const std::string& src_path, const std::string& dest_path) const;
/** /**
* Rename a Directory specified by its path * Rename a Directory specified by its path
@ -216,7 +216,7 @@ public:
* @param dest_path Destination path relative to the archive * @param dest_path Destination path relative to the archive
* @return Result of the operation * @return Result of the operation
*/ */
ResultCode RenameDirectory(const std::string& src_path, const std::string& dest_path) const; Result RenameDirectory(const std::string& src_path, const std::string& dest_path) const;
/** /**
* Open a file specified by its path, using the specified mode * Open a file specified by its path, using the specified mode

View file

@ -7,5 +7,5 @@
namespace Service::Friend { namespace Service::Friend {
constexpr ResultCode ERR_NO_NOTIFICATIONS{ErrorModule::Account, 15}; constexpr Result ERR_NO_NOTIFICATIONS{ErrorModule::Account, 15};
} }

View file

@ -153,7 +153,7 @@ class IRegistrar final : public ServiceFramework<IRegistrar> {
friend class ARP_W; friend class ARP_W;
public: public:
using IssuerFn = std::function<ResultCode(u64, ApplicationLaunchProperty, std::vector<u8>)>; using IssuerFn = std::function<Result(u64, ApplicationLaunchProperty, std::vector<u8>)>;
explicit IRegistrar(Core::System& system_, IssuerFn&& issuer) explicit IRegistrar(Core::System& system_, IssuerFn&& issuer)
: ServiceFramework{system_, "IRegistrar"}, issue_process_id{std::move(issuer)} { : ServiceFramework{system_, "IRegistrar"}, issue_process_id{std::move(issuer)} {

View file

@ -7,9 +7,9 @@
namespace Service::Glue { namespace Service::Glue {
constexpr ResultCode ERR_INVALID_RESOURCE{ErrorModule::ARP, 30}; constexpr Result ERR_INVALID_RESOURCE{ErrorModule::ARP, 30};
constexpr ResultCode ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 31}; constexpr Result ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 31};
constexpr ResultCode ERR_INVALID_ACCESS{ErrorModule::ARP, 42}; constexpr Result ERR_INVALID_ACCESS{ErrorModule::ARP, 42};
constexpr ResultCode ERR_NOT_REGISTERED{ErrorModule::ARP, 102}; constexpr Result ERR_NOT_REGISTERED{ErrorModule::ARP, 102};
} // namespace Service::Glue } // namespace Service::Glue

View file

@ -41,7 +41,7 @@ ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
return iter->second.control; return iter->second.control;
} }
ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch, Result ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
std::vector<u8> control) { std::vector<u8> control) {
if (title_id == 0) { if (title_id == 0) {
return ERR_INVALID_PROCESS_ID; return ERR_INVALID_PROCESS_ID;
@ -56,7 +56,7 @@ ResultCode ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
return ResultSuccess; return ResultSuccess;
} }
ResultCode ARPManager::Unregister(u64 title_id) { Result ARPManager::Unregister(u64 title_id) {
if (title_id == 0) { if (title_id == 0) {
return ERR_INVALID_PROCESS_ID; return ERR_INVALID_PROCESS_ID;
} }

View file

@ -42,12 +42,12 @@ public:
// Adds a new entry to the internal database with the provided parameters, returning // Adds a new entry to the internal database with the provided parameters, returning
// ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister // ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister
// step, and ERR_INVALID_PROCESS_ID if the title ID is 0. // step, and ERR_INVALID_PROCESS_ID if the title ID is 0.
ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control); Result Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
// Removes the registration for the provided title ID from the database, returning // Removes the registration for the provided title ID from the database, returning
// ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the // ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the
// title ID is 0. // title ID is 0.
ResultCode Unregister(u64 title_id); Result Unregister(u64 title_id);
// Removes all entries from the database, always succeeds. Should only be used when resetting // Removes all entries from the database, always succeeds. Should only be used when resetting
// system state. // system state.

View file

@ -56,7 +56,7 @@ bool Controller_NPad::IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle
return npad_id && npad_type && device_index; return npad_id && npad_type && device_index;
} }
ResultCode Controller_NPad::VerifyValidSixAxisSensorHandle( Result Controller_NPad::VerifyValidSixAxisSensorHandle(
const Core::HID::SixAxisSensorHandle& device_handle) { const Core::HID::SixAxisSensorHandle& device_handle) {
const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id)); const auto npad_id = IsNpadIdValid(static_cast<Core::HID::NpadIdType>(device_handle.npad_id));
if (!npad_id) { if (!npad_id) {
@ -720,7 +720,7 @@ Controller_NPad::NpadCommunicationMode Controller_NPad::GetNpadCommunicationMode
return communication_mode; return communication_mode;
} }
ResultCode Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id, Result Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id,
NpadJoyDeviceType npad_device_type, NpadJoyDeviceType npad_device_type,
NpadJoyAssignmentMode assignment_mode) { NpadJoyAssignmentMode assignment_mode) {
if (!IsNpadIdValid(npad_id)) { if (!IsNpadIdValid(npad_id)) {
@ -984,7 +984,7 @@ void Controller_NPad::UpdateControllerAt(Core::HID::NpadStyleIndex type,
InitNewlyAddedController(npad_id); InitNewlyAddedController(npad_id);
} }
ResultCode Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) { Result Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) {
if (!IsNpadIdValid(npad_id)) { if (!IsNpadIdValid(npad_id)) {
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
return InvalidNpadId; return InvalidNpadId;
@ -1032,7 +1032,7 @@ ResultCode Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) {
WriteEmptyEntry(shared_memory); WriteEmptyEntry(shared_memory);
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::SetGyroscopeZeroDriftMode( Result Controller_NPad::SetGyroscopeZeroDriftMode(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, GyroscopeZeroDriftMode drift_mode) { const Core::HID::SixAxisSensorHandle& sixaxis_handle, GyroscopeZeroDriftMode drift_mode) {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
if (is_valid.IsError()) { if (is_valid.IsError()) {
@ -1046,7 +1046,7 @@ ResultCode Controller_NPad::SetGyroscopeZeroDriftMode(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::GetGyroscopeZeroDriftMode( Result Controller_NPad::GetGyroscopeZeroDriftMode(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, const Core::HID::SixAxisSensorHandle& sixaxis_handle,
GyroscopeZeroDriftMode& drift_mode) const { GyroscopeZeroDriftMode& drift_mode) const {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@ -1061,8 +1061,8 @@ ResultCode Controller_NPad::GetGyroscopeZeroDriftMode(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::IsSixAxisSensorAtRest( Result Controller_NPad::IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_at_rest) const { bool& is_at_rest) const {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
if (is_valid.IsError()) { if (is_valid.IsError()) {
LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw); LOG_ERROR(Service_HID, "Invalid handle, error_code={}", is_valid.raw);
@ -1074,7 +1074,7 @@ ResultCode Controller_NPad::IsSixAxisSensorAtRest(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor( Result Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const { const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
if (is_valid.IsError()) { if (is_valid.IsError()) {
@ -1087,7 +1087,7 @@ ResultCode Controller_NPad::IsFirmwareUpdateAvailableForSixAxisSensor(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::EnableSixAxisSensorUnalteredPassthrough( Result Controller_NPad::EnableSixAxisSensorUnalteredPassthrough(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled) { const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled) {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
if (is_valid.IsError()) { if (is_valid.IsError()) {
@ -1100,7 +1100,7 @@ ResultCode Controller_NPad::EnableSixAxisSensorUnalteredPassthrough(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::IsSixAxisSensorUnalteredPassthroughEnabled( Result Controller_NPad::IsSixAxisSensorUnalteredPassthroughEnabled(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const { const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
if (is_valid.IsError()) { if (is_valid.IsError()) {
@ -1113,7 +1113,7 @@ ResultCode Controller_NPad::IsSixAxisSensorUnalteredPassthroughEnabled(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::LoadSixAxisSensorCalibrationParameter( Result Controller_NPad::LoadSixAxisSensorCalibrationParameter(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, const Core::HID::SixAxisSensorHandle& sixaxis_handle,
Core::HID::SixAxisSensorCalibrationParameter& calibration) const { Core::HID::SixAxisSensorCalibrationParameter& calibration) const {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@ -1128,7 +1128,7 @@ ResultCode Controller_NPad::LoadSixAxisSensorCalibrationParameter(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::GetSixAxisSensorIcInformation( Result Controller_NPad::GetSixAxisSensorIcInformation(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, const Core::HID::SixAxisSensorHandle& sixaxis_handle,
Core::HID::SixAxisSensorIcInformation& ic_information) const { Core::HID::SixAxisSensorIcInformation& ic_information) const {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@ -1143,7 +1143,7 @@ ResultCode Controller_NPad::GetSixAxisSensorIcInformation(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::ResetIsSixAxisSensorDeviceNewlyAssigned( Result Controller_NPad::ResetIsSixAxisSensorDeviceNewlyAssigned(
const Core::HID::SixAxisSensorHandle& sixaxis_handle) { const Core::HID::SixAxisSensorHandle& sixaxis_handle) {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
if (is_valid.IsError()) { if (is_valid.IsError()) {
@ -1157,7 +1157,7 @@ ResultCode Controller_NPad::ResetIsSixAxisSensorDeviceNewlyAssigned(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, Result Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
bool sixaxis_status) { bool sixaxis_status) {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
if (is_valid.IsError()) { if (is_valid.IsError()) {
@ -1170,7 +1170,7 @@ ResultCode Controller_NPad::SetSixAxisEnabled(const Core::HID::SixAxisSensorHand
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::IsSixAxisSensorFusionEnabled( Result Controller_NPad::IsSixAxisSensorFusionEnabled(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_fusion_enabled) const { const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_fusion_enabled) const {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
if (is_valid.IsError()) { if (is_valid.IsError()) {
@ -1183,7 +1183,7 @@ ResultCode Controller_NPad::IsSixAxisSensorFusionEnabled(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::SetSixAxisFusionEnabled( Result Controller_NPad::SetSixAxisFusionEnabled(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_fusion_enabled) { const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_fusion_enabled) {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
if (is_valid.IsError()) { if (is_valid.IsError()) {
@ -1197,7 +1197,7 @@ ResultCode Controller_NPad::SetSixAxisFusionEnabled(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::SetSixAxisFusionParameters( Result Controller_NPad::SetSixAxisFusionParameters(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, const Core::HID::SixAxisSensorHandle& sixaxis_handle,
Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters) { Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters) {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@ -1217,7 +1217,7 @@ ResultCode Controller_NPad::SetSixAxisFusionParameters(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::GetSixAxisFusionParameters( Result Controller_NPad::GetSixAxisFusionParameters(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, const Core::HID::SixAxisSensorHandle& sixaxis_handle,
Core::HID::SixAxisSensorFusionParameters& parameters) const { Core::HID::SixAxisSensorFusionParameters& parameters) const {
const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle); const auto is_valid = VerifyValidSixAxisSensorHandle(sixaxis_handle);
@ -1232,7 +1232,7 @@ ResultCode Controller_NPad::GetSixAxisFusionParameters(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1, Result Controller_NPad::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1,
Core::HID::NpadIdType npad_id_2) { Core::HID::NpadIdType npad_id_2) {
if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) { if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) {
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1, LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1,
@ -1304,7 +1304,7 @@ void Controller_NPad::StopLRAssignmentMode() {
is_in_lr_assignment_mode = false; is_in_lr_assignment_mode = false;
} }
ResultCode Controller_NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Result Controller_NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1,
Core::HID::NpadIdType npad_id_2) { Core::HID::NpadIdType npad_id_2) {
if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) { if (!IsNpadIdValid(npad_id_1) || !IsNpadIdValid(npad_id_2)) {
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1, LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id_1:{}, npad_id_2:{}", npad_id_1,
@ -1336,7 +1336,7 @@ ResultCode Controller_NPad::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1,
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::GetLedPattern(Core::HID::NpadIdType npad_id, Result Controller_NPad::GetLedPattern(Core::HID::NpadIdType npad_id,
Core::HID::LedPattern& pattern) const { Core::HID::LedPattern& pattern) const {
if (!IsNpadIdValid(npad_id)) { if (!IsNpadIdValid(npad_id)) {
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
@ -1347,8 +1347,8 @@ ResultCode Controller_NPad::GetLedPattern(Core::HID::NpadIdType npad_id,
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::IsUnintendedHomeButtonInputProtectionEnabled( Result Controller_NPad::IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id,
Core::HID::NpadIdType npad_id, bool& is_valid) const { bool& is_valid) const {
if (!IsNpadIdValid(npad_id)) { if (!IsNpadIdValid(npad_id)) {
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);
return InvalidNpadId; return InvalidNpadId;
@ -1358,7 +1358,7 @@ ResultCode Controller_NPad::IsUnintendedHomeButtonInputProtectionEnabled(
return ResultSuccess; return ResultSuccess;
} }
ResultCode Controller_NPad::SetUnintendedHomeButtonInputProtectionEnabled( Result Controller_NPad::SetUnintendedHomeButtonInputProtectionEnabled(
bool is_protection_enabled, Core::HID::NpadIdType npad_id) { bool is_protection_enabled, Core::HID::NpadIdType npad_id) {
if (!IsNpadIdValid(npad_id)) { if (!IsNpadIdValid(npad_id)) {
LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id);

View file

@ -29,7 +29,7 @@ namespace Service::KernelHelpers {
class ServiceContext; class ServiceContext;
} // namespace Service::KernelHelpers } // namespace Service::KernelHelpers
union ResultCode; union Result;
namespace Service::HID { namespace Service::HID {
@ -107,7 +107,7 @@ public:
void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_); void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_);
NpadCommunicationMode GetNpadCommunicationMode() const; NpadCommunicationMode GetNpadCommunicationMode() const;
ResultCode SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyDeviceType npad_device_type, Result SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyDeviceType npad_device_type,
NpadJoyAssignmentMode assignment_mode); NpadJoyAssignmentMode assignment_mode);
bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index, bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index,
@ -141,44 +141,43 @@ public:
void UpdateControllerAt(Core::HID::NpadStyleIndex controller, Core::HID::NpadIdType npad_id, void UpdateControllerAt(Core::HID::NpadStyleIndex controller, Core::HID::NpadIdType npad_id,
bool connected); bool connected);
ResultCode DisconnectNpad(Core::HID::NpadIdType npad_id); Result DisconnectNpad(Core::HID::NpadIdType npad_id);
ResultCode SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle, Result SetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
GyroscopeZeroDriftMode drift_mode); GyroscopeZeroDriftMode drift_mode);
ResultCode GetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle, Result GetGyroscopeZeroDriftMode(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
GyroscopeZeroDriftMode& drift_mode) const; GyroscopeZeroDriftMode& drift_mode) const;
ResultCode IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle, Result IsSixAxisSensorAtRest(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
bool& is_at_rest) const; bool& is_at_rest) const;
ResultCode IsFirmwareUpdateAvailableForSixAxisSensor( Result IsFirmwareUpdateAvailableForSixAxisSensor(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const; const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_firmware_available) const;
ResultCode EnableSixAxisSensorUnalteredPassthrough( Result EnableSixAxisSensorUnalteredPassthrough(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled); const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool is_enabled);
ResultCode IsSixAxisSensorUnalteredPassthroughEnabled( Result IsSixAxisSensorUnalteredPassthroughEnabled(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const; const Core::HID::SixAxisSensorHandle& sixaxis_handle, bool& is_enabled) const;
ResultCode LoadSixAxisSensorCalibrationParameter( Result LoadSixAxisSensorCalibrationParameter(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, const Core::HID::SixAxisSensorHandle& sixaxis_handle,
Core::HID::SixAxisSensorCalibrationParameter& calibration) const; Core::HID::SixAxisSensorCalibrationParameter& calibration) const;
ResultCode GetSixAxisSensorIcInformation( Result GetSixAxisSensorIcInformation(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, const Core::HID::SixAxisSensorHandle& sixaxis_handle,
Core::HID::SixAxisSensorIcInformation& ic_information) const; Core::HID::SixAxisSensorIcInformation& ic_information) const;
ResultCode ResetIsSixAxisSensorDeviceNewlyAssigned( Result ResetIsSixAxisSensorDeviceNewlyAssigned(
const Core::HID::SixAxisSensorHandle& sixaxis_handle); const Core::HID::SixAxisSensorHandle& sixaxis_handle);
ResultCode SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, Result SetSixAxisEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
bool sixaxis_status); bool sixaxis_status);
ResultCode IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, Result IsSixAxisSensorFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
bool& is_fusion_enabled) const; bool& is_fusion_enabled) const;
ResultCode SetSixAxisFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle, Result SetSixAxisFusionEnabled(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
bool is_fusion_enabled); bool is_fusion_enabled);
ResultCode SetSixAxisFusionParameters( Result SetSixAxisFusionParameters(
const Core::HID::SixAxisSensorHandle& sixaxis_handle, const Core::HID::SixAxisSensorHandle& sixaxis_handle,
Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters); Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters);
ResultCode GetSixAxisFusionParameters( Result GetSixAxisFusionParameters(const Core::HID::SixAxisSensorHandle& sixaxis_handle,
const Core::HID::SixAxisSensorHandle& sixaxis_handle,
Core::HID::SixAxisSensorFusionParameters& parameters) const; Core::HID::SixAxisSensorFusionParameters& parameters) const;
ResultCode GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const; Result GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const;
ResultCode IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id, Result IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id,
bool& is_enabled) const; bool& is_enabled) const;
ResultCode SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled, Result SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled,
Core::HID::NpadIdType npad_id); Core::HID::NpadIdType npad_id);
void SetAnalogStickUseCenterClamp(bool use_center_clamp); void SetAnalogStickUseCenterClamp(bool use_center_clamp);
void ClearAllConnectedControllers(); void ClearAllConnectedControllers();
@ -186,11 +185,11 @@ public:
void ConnectAllDisconnectedControllers(); void ConnectAllDisconnectedControllers();
void ClearAllControllers(); void ClearAllControllers();
ResultCode MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1, Result MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1,
Core::HID::NpadIdType npad_id_2); Core::HID::NpadIdType npad_id_2);
void StartLRAssignmentMode(); void StartLRAssignmentMode();
void StopLRAssignmentMode(); void StopLRAssignmentMode();
ResultCode SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2); Result SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2);
// Logical OR for all buttons presses on all controllers // Logical OR for all buttons presses on all controllers
// Specifically for cheat engine and other features. // Specifically for cheat engine and other features.
@ -198,7 +197,7 @@ public:
static bool IsNpadIdValid(Core::HID::NpadIdType npad_id); static bool IsNpadIdValid(Core::HID::NpadIdType npad_id);
static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle); static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle);
static ResultCode VerifyValidSixAxisSensorHandle( static Result VerifyValidSixAxisSensorHandle(
const Core::HID::SixAxisSensorHandle& device_handle); const Core::HID::SixAxisSensorHandle& device_handle);
private: private:

View file

@ -7,12 +7,12 @@
namespace Service::HID { namespace Service::HID {
constexpr ResultCode NpadInvalidHandle{ErrorModule::HID, 100}; constexpr Result NpadInvalidHandle{ErrorModule::HID, 100};
constexpr ResultCode NpadDeviceIndexOutOfRange{ErrorModule::HID, 107}; constexpr Result NpadDeviceIndexOutOfRange{ErrorModule::HID, 107};
constexpr ResultCode InvalidSixAxisFusionRange{ErrorModule::HID, 423}; constexpr Result InvalidSixAxisFusionRange{ErrorModule::HID, 423};
constexpr ResultCode NpadIsDualJoycon{ErrorModule::HID, 601}; constexpr Result NpadIsDualJoycon{ErrorModule::HID, 601};
constexpr ResultCode NpadIsSameType{ErrorModule::HID, 602}; constexpr Result NpadIsSameType{ErrorModule::HID, 602};
constexpr ResultCode InvalidNpadId{ErrorModule::HID, 709}; constexpr Result InvalidNpadId{ErrorModule::HID, 709};
constexpr ResultCode NpadNotConnected{ErrorModule::HID, 710}; constexpr Result NpadNotConnected{ErrorModule::HID, 710};
} // namespace Service::HID } // namespace Service::HID

View file

@ -71,7 +71,7 @@ private:
struct HidbusStatusManagerEntry { struct HidbusStatusManagerEntry {
u8 is_connected{}; u8 is_connected{};
INSERT_PADDING_BYTES(0x3); INSERT_PADDING_BYTES(0x3);
ResultCode is_connected_result{0}; Result is_connected_result{0};
u8 is_enabled{}; u8 is_enabled{};
u8 is_in_focus{}; u8 is_in_focus{};
u8 is_polling_mode{}; u8 is_polling_mode{};

View file

@ -26,7 +26,7 @@ enum class JoyPollingMode : u32 {
}; };
struct DataAccessorHeader { struct DataAccessorHeader {
ResultCode result{ResultUnknown}; Result result{ResultUnknown};
INSERT_PADDING_WORDS(0x1); INSERT_PADDING_WORDS(0x1);
std::array<u8, 0x18> unused{}; std::array<u8, 0x18> unused{};
u64 latest_entry{}; u64 latest_entry{};

Some files were not shown because too many files have changed in this diff Show more