kernel: Update to use atmosphere macros and correct Result (#7242)

* kernel: Switch to atmosphere style macros

* code: Rename ResultCode to Result

* code: Result constants are lower case

* Address review comments

* core: Remove CASCADE_CODE

* R_TRY replaces completely

* core: Run clang format
This commit is contained in:
GPUCode 2023-12-31 19:01:40 +02:00 committed by GitHub
parent 811303ea54
commit 5a7f615da1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
132 changed files with 2807 additions and 2995 deletions

View file

@ -26,8 +26,8 @@ static Core::TimingEventType* applet_update_event = nullptr;
/// The interval at which the Applet update callback will be called, 16.6ms
static const u64 applet_update_interval_us = 16666;
ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
const std::shared_ptr<Service::APT::AppletManager>& manager) {
Result Applet::Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
const std::shared_ptr<Service::APT::AppletManager>& manager) {
switch (id) {
case Service::APT::AppletId::SoftwareKeyboard1:
case Service::APT::AppletId::SoftwareKeyboard2:
@ -48,8 +48,8 @@ ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId pare
default:
LOG_ERROR(Service_APT, "Could not create applet {}", id);
// TODO(Subv): Find the right error code
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet,
ErrorSummary::NotSupported, ErrorLevel::Permanent);
return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported,
ErrorLevel::Permanent);
}
Service::APT::AppletAttributes attributes;
@ -66,7 +66,7 @@ ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId pare
// Schedule the update event
Core::System::GetInstance().CoreTiming().ScheduleEvent(
usToCycles(applet_update_interval_us), applet_update_event, static_cast<u64>(id));
return RESULT_SUCCESS;
return ResultSuccess;
}
std::shared_ptr<Applet> Applet::Get(Service::APT::AppletId id) {
@ -104,10 +104,10 @@ bool Applet::IsActive() const {
return is_active;
}
ResultCode Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
Result Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
switch (parameter.signal) {
case Service::APT::SignalType::Wakeup: {
ResultCode result = Start(parameter);
Result result = Start(parameter);
if (!result.IsError()) {
is_active = true;
}

View file

@ -20,10 +20,10 @@ public:
* @param id Id of the applet to create.
* @param parent Id of the applet's parent.
* @param preload Whether the applet is being preloaded.
* @returns ResultCode Whether the operation was successful or not.
* @returns Result Whether the operation was successful or not.
*/
static ResultCode Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
const std::shared_ptr<Service::APT::AppletManager>& manager);
static Result Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
const std::shared_ptr<Service::APT::AppletManager>& manager);
/**
* Retrieves the Applet instance identified by the specified id.
@ -35,9 +35,9 @@ public:
/**
* Handles a parameter from the application.
* @param parameter Parameter data to handle.
* @returns ResultCode Whether the operation was successful or not.
* @returns Result Whether the operation was successful or not.
*/
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter);
Result ReceiveParameter(const Service::APT::MessageParameter& parameter);
/**
* Whether the applet is currently running.
@ -62,22 +62,22 @@ protected:
/**
* Handles a parameter from the application.
* @param parameter Parameter data to handle.
* @returns ResultCode Whether the operation was successful or not.
* @returns Result Whether the operation was successful or not.
*/
virtual ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) = 0;
virtual Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) = 0;
/**
* Handles the Applet start event, triggered from the application.
* @param parameter Parameter data to handle.
* @returns ResultCode Whether the operation was successful or not.
* @returns Result Whether the operation was successful or not.
*/
virtual ResultCode Start(const Service::APT::MessageParameter& parameter) = 0;
virtual Result Start(const Service::APT::MessageParameter& parameter) = 0;
/**
* Sends the LibAppletClosing signal to the application,
* along with the relevant data buffers.
*/
virtual ResultCode Finalize() = 0;
virtual Result Finalize() = 0;
Service::APT::AppletId id; ///< Id of this Applet
Service::APT::AppletId parent; ///< Id of this Applet's parent

View file

@ -9,12 +9,12 @@
namespace HLE::Applets {
ResultCode ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
Result ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
if (parameter.signal != Service::APT::SignalType::Request) {
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
UNIMPLEMENTED();
// TODO(Subv): Find the right error code
return ResultCode(-1);
return ResultUnknown;
}
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
@ -40,10 +40,10 @@ ResultCode ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& p
.object = framebuffer_memory,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) {
Result ErrEula::Start(const Service::APT::MessageParameter& parameter) {
startup_param = parameter.buffer;
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
@ -52,14 +52,14 @@ ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) {
// Let the application know that we're closing.
Finalize();
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode ErrEula::Finalize() {
Result ErrEula::Finalize() {
std::vector<u8> buffer(startup_param.size());
std::fill(buffer.begin(), buffer.end(), 0);
CloseApplet(nullptr, buffer);
return RESULT_SUCCESS;
return ResultSuccess;
}
void ErrEula::Update() {}

View file

@ -15,9 +15,9 @@ public:
std::weak_ptr<Service::APT::AppletManager> manager)
: Applet(id, parent, preload, std::move(manager)) {}
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
ResultCode Start(const Service::APT::MessageParameter& parameter) override;
ResultCode Finalize() override;
Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
Result Start(const Service::APT::MessageParameter& parameter) override;
Result Finalize() override;
void Update() override;
private:

View file

@ -17,12 +17,12 @@
namespace HLE::Applets {
ResultCode MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
Result MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
if (parameter.signal != Service::APT::SignalType::Request) {
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
UNIMPLEMENTED();
// TODO(Subv): Find the right error code
return ResultCode(-1);
return ResultUnknown;
}
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
@ -47,10 +47,10 @@ ResultCode MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParamete
.object = framebuffer_memory,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode MiiSelector::Start(const Service::APT::MessageParameter& parameter) {
Result MiiSelector::Start(const Service::APT::MessageParameter& parameter) {
ASSERT_MSG(parameter.buffer.size() == sizeof(config),
"The size of the parameter (MiiConfig) is wrong");
@ -63,7 +63,7 @@ ResultCode MiiSelector::Start(const Service::APT::MessageParameter& parameter) {
MiiSelectorConfig frontend_config = ToFrontendConfig(config);
frontend_applet->Setup(frontend_config);
return RESULT_SUCCESS;
return ResultSuccess;
}
void MiiSelector::Update() {
@ -78,11 +78,11 @@ void MiiSelector::Update() {
Finalize();
}
ResultCode MiiSelector::Finalize() {
Result MiiSelector::Finalize() {
std::vector<u8> buffer(sizeof(MiiResult));
std::memcpy(buffer.data(), &result, buffer.size());
CloseApplet(nullptr, buffer);
return RESULT_SUCCESS;
return ResultSuccess;
}
MiiResult MiiSelector::GetStandardMiiResult() {

View file

@ -66,9 +66,9 @@ public:
std::weak_ptr<Service::APT::AppletManager> manager)
: Applet(id, parent, preload, std::move(manager)) {}
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
ResultCode Start(const Service::APT::MessageParameter& parameter) override;
ResultCode Finalize() override;
Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
Result Start(const Service::APT::MessageParameter& parameter) override;
Result Finalize() override;
void Update() override;
static MiiResult GetStandardMiiResult();

View file

@ -9,12 +9,12 @@
namespace HLE::Applets {
ResultCode Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
Result Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
if (parameter.signal != Service::APT::SignalType::Request) {
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
UNIMPLEMENTED();
// TODO(Subv): Find the right error code
return ResultCode(-1);
return ResultUnknown;
}
// The Request message contains a buffer with the size of the framebuffer shared
@ -40,10 +40,10 @@ ResultCode Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& para
.object = framebuffer_memory,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) {
Result Mint::Start(const Service::APT::MessageParameter& parameter) {
startup_param = parameter.buffer;
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
@ -52,14 +52,14 @@ ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) {
// Let the application know that we're closing
Finalize();
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode Mint::Finalize() {
Result Mint::Finalize() {
std::vector<u8> buffer(startup_param.size());
std::fill(buffer.begin(), buffer.end(), 0);
CloseApplet(nullptr, buffer);
return RESULT_SUCCESS;
return ResultSuccess;
}
void Mint::Update() {}

View file

@ -15,9 +15,9 @@ public:
std::weak_ptr<Service::APT::AppletManager> manager)
: Applet(id, parent, preload, std::move(manager)) {}
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
ResultCode Start(const Service::APT::MessageParameter& parameter) override;
ResultCode Finalize() override;
Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
Result Start(const Service::APT::MessageParameter& parameter) override;
Result Finalize() override;
void Update() override;
private:

View file

@ -19,7 +19,7 @@
namespace HLE::Applets {
ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter const& parameter) {
Result SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter const& parameter) {
switch (parameter.signal) {
case Service::APT::SignalType::Request: {
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
@ -44,7 +44,7 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
.object = framebuffer_memory,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
case Service::APT::SignalType::Message: {
@ -58,7 +58,7 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
case SoftwareKeyboardCallbackResult::OK:
// Finish execution
Finalize();
return RESULT_SUCCESS;
return ResultSuccess;
case SoftwareKeyboardCallbackResult::Close:
// Let the frontend display error and quit
@ -66,14 +66,14 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
config.return_code = SoftwareKeyboardResult::BannedInput;
config.text_offset = config.text_length = 0;
Finalize();
return RESULT_SUCCESS;
return ResultSuccess;
case SoftwareKeyboardCallbackResult::Continue:
// Let the frontend display error and get input again
// The input will be sent for validation again on next Update().
frontend_applet->ShowError(Common::UTF16BufferToUTF8(config.callback_msg));
frontend_applet->Execute(ToFrontendConfig(config));
return RESULT_SUCCESS;
return ResultSuccess;
default:
UNREACHABLE();
@ -84,12 +84,12 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
UNIMPLEMENTED();
// TODO(Subv): Find the right error code
return ResultCode(-1);
return ResultUnknown;
}
}
}
ResultCode SoftwareKeyboard::Start(Service::APT::MessageParameter const& parameter) {
Result SoftwareKeyboard::Start(Service::APT::MessageParameter const& parameter) {
ASSERT_MSG(parameter.buffer.size() == sizeof(config),
"The size of the parameter (SoftwareKeyboardConfig) is wrong");
@ -104,7 +104,7 @@ ResultCode SoftwareKeyboard::Start(Service::APT::MessageParameter const& paramet
frontend_applet->Execute(ToFrontendConfig(config));
return RESULT_SUCCESS;
return ResultSuccess;
}
void SoftwareKeyboard::Update() {
@ -166,12 +166,12 @@ void SoftwareKeyboard::DrawScreenKeyboard() {
// TODO(Subv): Draw the HLE keyboard, for now just do nothing
}
ResultCode SoftwareKeyboard::Finalize() {
Result SoftwareKeyboard::Finalize() {
std::vector<u8> buffer(sizeof(SoftwareKeyboardConfig));
std::memcpy(buffer.data(), &config, buffer.size());
CloseApplet(nullptr, buffer);
text_memory = nullptr;
return RESULT_SUCCESS;
return ResultSuccess;
}
Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig(

View file

@ -179,9 +179,9 @@ public:
std::weak_ptr<Service::APT::AppletManager> manager)
: Applet(id, parent, preload, std::move(manager)) {}
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
ResultCode Start(const Service::APT::MessageParameter& parameter) override;
ResultCode Finalize() override;
Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
Result Start(const Service::APT::MessageParameter& parameter) override;
Result Finalize() override;
void Update() override;
/**

View file

@ -20,8 +20,8 @@ constexpr std::size_t MAX_STATIC_BUFFERS = 16;
// These errors are commonly returned by invalid IPC translations, so alias them here for
// convenience.
// TODO(yuriks): These will probably go away once translation is implemented inside the kernel.
using Kernel::ERR_INVALID_BUFFER_DESCRIPTOR;
constexpr auto ERR_INVALID_HANDLE = Kernel::ERR_INVALID_HANDLE_OS;
using Kernel::ResultInvalidBufferDescriptor;
constexpr auto ResultInvalidHandle = Kernel::ResultInvalidHandleOs;
enum DescriptorType : u32 {
// Buffer related descriptors types (mask : 0x0F)

View file

@ -161,7 +161,7 @@ inline void RequestBuilder::Push(bool value) {
}
template <>
inline void RequestBuilder::Push(ResultCode value) {
inline void RequestBuilder::Push(Result value) {
Push(value.raw);
}
@ -371,8 +371,8 @@ inline bool RequestParser::Pop() {
}
template <>
inline ResultCode RequestParser::Pop() {
return ResultCode{Pop<u32>()};
inline Result RequestParser::Pop() {
return Result{Pop<u32>()};
}
template <typename T>

View file

@ -108,8 +108,8 @@ void AddressArbiter::WakeUp(ThreadWakeupReason reason, std::shared_ptr<Thread> t
waiting_threads.end());
};
ResultCode AddressArbiter::ArbitrateAddress(std::shared_ptr<Thread> thread, ArbitrationType type,
VAddr address, s32 value, u64 nanoseconds) {
Result AddressArbiter::ArbitrateAddress(std::shared_ptr<Thread> thread, ArbitrationType type,
VAddr address, s32 value, u64 nanoseconds) {
switch (type) {
// Signal thread(s) waiting for arbitrate address...
@ -171,17 +171,16 @@ ResultCode AddressArbiter::ArbitrateAddress(std::shared_ptr<Thread> thread, Arbi
default:
LOG_ERROR(Kernel, "unknown type={}", type);
return ERR_INVALID_ENUM_VALUE_FND;
return ResultInvalidEnumValueFnd;
}
// The calls that use a timeout seem to always return a Timeout error even if they did not put
// the thread to sleep
if (type == ArbitrationType::WaitIfLessThanWithTimeout ||
type == ArbitrationType::DecrementAndWaitIfLessThanWithTimeout) {
return RESULT_TIMEOUT;
return ResultTimeout;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
} // namespace Kernel

View file

@ -55,8 +55,8 @@ public:
std::shared_ptr<ResourceLimit> resource_limit;
std::string name; ///< Name of address arbiter object (optional)
ResultCode ArbitrateAddress(std::shared_ptr<Thread> thread, ArbitrationType type, VAddr address,
s32 value, u64 nanoseconds);
Result ArbitrateAddress(std::shared_ptr<Thread> thread, ArbitrationType type, VAddr address,
s32 value, u64 nanoseconds);
class Callback;

View file

@ -20,32 +20,31 @@ namespace Kernel {
ClientPort::ClientPort(KernelSystem& kernel) : Object(kernel), kernel(kernel) {}
ClientPort::~ClientPort() = default;
ResultVal<std::shared_ptr<ClientSession>> ClientPort::Connect() {
Result ClientPort::Connect(std::shared_ptr<ClientSession>* out_client_session) {
// Note: Threads do not wait for the server endpoint to call
// AcceptSession before returning from this call.
if (active_sessions >= max_sessions) {
return ERR_MAX_CONNECTIONS_REACHED;
}
R_UNLESS(active_sessions < max_sessions, ResultMaxConnectionsReached);
active_sessions++;
// Create a new session pair, let the created sessions inherit the parent port's HLE handler.
auto [server, client] = kernel.CreateSessionPair(server_port->GetName(), SharedFrom(this));
if (server_port->hle_handler)
if (server_port->hle_handler) {
server_port->hle_handler->ClientConnected(server);
else
} else {
server_port->pending_sessions.push_back(server);
}
// Wake the threads waiting on the ServerPort
server_port->WakeupAllWaitingThreads();
return client;
*out_client_session = client;
return ResultSuccess;
}
void ClientPort::ConnectionClosed() {
ASSERT(active_sessions > 0);
--active_sessions;
}

View file

@ -46,7 +46,7 @@ public:
* waiting on it to awake.
* @returns ClientSession The client endpoint of the created Session pair, or error code.
*/
ResultVal<std::shared_ptr<ClientSession>> Connect();
Result Connect(std::shared_ptr<ClientSession>* out_client_session);
/**
* Signifies that a previously active connection has been closed,

View file

@ -44,11 +44,10 @@ ClientSession::~ClientSession() {
}
}
ResultCode ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread) {
Result ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread) {
// Keep ServerSession alive until we're done working with it.
std::shared_ptr<ServerSession> server = SharedFrom(parent->server);
if (server == nullptr)
return ERR_SESSION_CLOSED_BY_REMOTE;
R_UNLESS(server, ResultSessionClosed);
// Signal the server session that new data is available
return server->HandleSyncRequest(std::move(thread));

View file

@ -42,9 +42,9 @@ public:
/**
* Sends an SyncRequest from the current emulated thread.
* @param thread Thread that initiated the request.
* @return ResultCode of the operation.
* @return Result of the operation.
*/
ResultCode SendSyncRequest(std::shared_ptr<Thread> thread);
Result SendSyncRequest(std::shared_ptr<Thread> thread);
std::string name; ///< Name of client port (optional)

View file

@ -31,85 +31,83 @@ enum {
// WARNING: The kernel is quite inconsistent in it's usage of errors code. Make sure to always
// double check that the code matches before re-using the constant.
constexpr ResultCode ERR_OUT_OF_HANDLES(ErrCodes::OutOfHandles, ErrorModule::Kernel,
ErrorSummary::OutOfResource,
ErrorLevel::Permanent); // 0xD8600413
constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(ErrCodes::SessionClosedByRemote, ErrorModule::OS,
ErrorSummary::Canceled,
ErrorLevel::Status); // 0xC920181A
constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrCodes::PortNameTooLong, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E0181E
constexpr ResultCode ERR_WRONG_PERMISSION(ErrCodes::WrongPermission, ErrorModule::OS,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
constexpr ResultCode ERR_INVALID_BUFFER_DESCRIPTOR(ErrCodes::InvalidBufferDescriptor,
ErrorModule::OS, ErrorSummary::WrongArgument,
ErrorLevel::Permanent);
constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(ErrCodes::MaxConnectionsReached, ErrorModule::OS,
ErrorSummary::WouldBlock,
ErrorLevel::Temporary); // 0xD0401834
constexpr ResultCode ERR_NOT_AUTHORIZED(ErrorDescription::NotAuthorized, ErrorModule::OS,
ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9001BEA
constexpr ResultCode ERR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007ED
constexpr ResultCode ERR_INVALID_ENUM_VALUE_FND(ErrorDescription::InvalidEnumValue,
ErrorModule::FND, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E093ED
constexpr ResultCode ERR_INVALID_COMBINATION(ErrorDescription::InvalidCombination, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BEE
constexpr ResultCode ERR_INVALID_COMBINATION_KERNEL(ErrorDescription::InvalidCombination,
ErrorModule::Kernel,
ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD90007EE
constexpr ResultCode ERR_MISALIGNED_ADDRESS(ErrorDescription::MisalignedAddress, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF1
constexpr ResultCode ERR_MISALIGNED_SIZE(ErrorDescription::MisalignedSize, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF2
constexpr ResultCode ERR_OUT_OF_MEMORY(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
ErrorSummary::OutOfResource,
ErrorLevel::Permanent); // 0xD86007F3
/// Returned when out of heap or linear heap memory when allocating
constexpr ResultCode ERR_OUT_OF_HEAP_MEMORY(ErrorDescription::OutOfMemory, ErrorModule::OS,
ErrorSummary::OutOfResource,
ErrorLevel::Status); // 0xC860180A
constexpr ResultCode ERR_NOT_IMPLEMENTED(ErrorDescription::NotImplemented, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF4
constexpr ResultCode ERR_INVALID_ADDRESS(ErrorDescription::InvalidAddress, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF5
constexpr ResultCode ERR_INVALID_ADDRESS_STATE(ErrorDescription::InvalidAddress, ErrorModule::OS,
ErrorSummary::InvalidState,
ErrorLevel::Usage); // 0xE0A01BF5
constexpr ResultCode ERR_INVALID_POINTER(ErrorDescription::InvalidPointer, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007F6
constexpr ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007F7
/// Alternate code returned instead of ERR_INVALID_HANDLE in some code paths.
constexpr ResultCode ERR_INVALID_HANDLE_OS(ErrorDescription::InvalidHandle, ErrorModule::OS,
ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9001BF7
constexpr ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel,
ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
constexpr ResultCode ERR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BFD
constexpr ResultCode ERR_OUT_OF_RANGE_KERNEL(ErrorDescription::OutOfRange, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007FD
constexpr ResultCode RESULT_TIMEOUT(ErrorDescription::Timeout, ErrorModule::OS,
ErrorSummary::StatusChanged, ErrorLevel::Info);
/// Returned when Accept() is called on a port with no sessions to be accepted.
constexpr ResultCode ERR_NO_PENDING_SESSIONS(ErrCodes::NoPendingSessions, ErrorModule::OS,
constexpr Result ResultOutOfHandles(ErrCodes::OutOfHandles, ErrorModule::Kernel,
ErrorSummary::OutOfResource,
ErrorLevel::Permanent); // 0xD8600413
constexpr Result ResultSessionClosed(ErrCodes::SessionClosedByRemote, ErrorModule::OS,
ErrorSummary::Canceled,
ErrorLevel::Status); // 0xC920181A
constexpr Result ResultPortNameTooLong(ErrCodes::PortNameTooLong, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E0181E
constexpr Result ResultWrongPermission(ErrCodes::WrongPermission, ErrorModule::OS,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
constexpr Result ResultInvalidBufferDescriptor(ErrCodes::InvalidBufferDescriptor, ErrorModule::OS,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
constexpr Result ResultMaxConnectionsReached(ErrCodes::MaxConnectionsReached, ErrorModule::OS,
ErrorSummary::WouldBlock,
ErrorLevel::Permanent); // 0xD8401823
ErrorLevel::Temporary); // 0xD0401834
constexpr Result ResultNotAuthorized(ErrorDescription::NotAuthorized, ErrorModule::OS,
ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9001BEA
constexpr Result ResultInvalidEnumValue(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007ED
constexpr Result ResultInvalidEnumValueFnd(ErrorDescription::InvalidEnumValue, ErrorModule::FND,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E093ED
constexpr Result ResultInvalidCombination(ErrorDescription::InvalidCombination, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BEE
constexpr Result ResultInvalidCombinationKernel(ErrorDescription::InvalidCombination,
ErrorModule::Kernel, ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD90007EE
constexpr Result ResultMisalignedAddress(ErrorDescription::MisalignedAddress, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF1
constexpr Result ResultMisalignedSize(ErrorDescription::MisalignedSize, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF2
constexpr Result ResultOutOfMemory(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
ErrorSummary::OutOfResource,
ErrorLevel::Permanent); // 0xD86007F3
/// Returned when out of heap or linear heap memory when allocating
constexpr Result ResultOutOfHeapMemory(ErrorDescription::OutOfMemory, ErrorModule::OS,
ErrorSummary::OutOfResource,
ErrorLevel::Status); // 0xC860180A
constexpr Result ResultNotImplemented(ErrorDescription::NotImplemented, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF4
constexpr Result ResultInvalidAddress(ErrorDescription::InvalidAddress, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BF5
constexpr Result ResultInvalidAddressState(ErrorDescription::InvalidAddress, ErrorModule::OS,
ErrorSummary::InvalidState,
ErrorLevel::Usage); // 0xE0A01BF5
constexpr Result ResultInvalidPointer(ErrorDescription::InvalidPointer, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007F6
constexpr Result ResultInvalidHandle(ErrorDescription::InvalidHandle, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007F7
/// Alternate code returned instead of ResultInvalidHandle in some code paths.
constexpr Result ResultInvalidHandleOs(ErrorDescription::InvalidHandle, ErrorModule::OS,
ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9001BF7
constexpr Result ResultNotFound(ErrorDescription::NotFound, ErrorModule::Kernel,
ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
constexpr Result ResultOutOfRange(ErrorDescription::OutOfRange, ErrorModule::OS,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E01BFD
constexpr Result ResultOutOfRangeKernel(ErrorDescription::OutOfRange, ErrorModule::Kernel,
ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E007FD
constexpr Result ResultTimeout(ErrorDescription::Timeout, ErrorModule::OS,
ErrorSummary::StatusChanged, ErrorLevel::Info);
/// Returned when Accept() is called on a port with no sessions to be accepted.
constexpr Result ResultNoPendingSessions(ErrCodes::NoPendingSessions, ErrorModule::OS,
ErrorSummary::WouldBlock,
ErrorLevel::Permanent); // 0xD8401823
} // namespace Kernel

View file

@ -36,8 +36,9 @@ bool Event::ShouldWait(const Thread* thread) const {
void Event::Acquire(Thread* thread) {
ASSERT_MSG(!ShouldWait(thread), "object unavailable!");
if (reset_type == ResetType::OneShot)
if (reset_type == ResetType::OneShot) {
signaled = false;
}
}
void Event::Signal() {
@ -52,8 +53,9 @@ void Event::Clear() {
void Event::WakeupAllWaitingThreads() {
WaitObject::WakeupAllWaitingThreads();
if (reset_type == ResetType::Pulse)
if (reset_type == ResetType::Pulse) {
signaled = false;
}
}
} // namespace Kernel

View file

@ -28,56 +28,48 @@ HandleTable::HandleTable(KernelSystem& kernel) : kernel(kernel) {
HandleTable::~HandleTable() = default;
ResultVal<Handle> HandleTable::Create(std::shared_ptr<Object> obj) {
Result HandleTable::Create(Handle* out_handle, std::shared_ptr<Object> obj) {
DEBUG_ASSERT(obj != nullptr);
u16 slot = next_free_slot;
if (slot >= generations.size()) {
LOG_ERROR(Kernel, "Unable to allocate Handle, too many slots in use.");
return ERR_OUT_OF_HANDLES;
}
R_UNLESS(slot < generations.size(), ResultOutOfHandles);
next_free_slot = generations[slot];
u16 generation = next_generation++;
// Overflow count so it fits in the 15 bits dedicated to the generation in the handle.
// CTR-OS doesn't use generation 0, so skip straight to 1.
if (next_generation >= (1 << 15))
if (next_generation >= (1 << 15)) {
next_generation = 1;
}
generations[slot] = generation;
objects[slot] = std::move(obj);
Handle handle = generation | (slot << 15);
return handle;
*out_handle = generation | (slot << 15);
return ResultSuccess;
}
ResultVal<Handle> HandleTable::Duplicate(Handle handle) {
Result HandleTable::Duplicate(Handle* out_handle, Handle handle) {
std::shared_ptr<Object> object = GetGeneric(handle);
if (object == nullptr) {
LOG_ERROR(Kernel, "Tried to duplicate invalid handle: {:08X}", handle);
return ERR_INVALID_HANDLE;
}
return Create(std::move(object));
R_UNLESS(object, ResultInvalidHandle);
return Create(out_handle, std::move(object));
}
ResultCode HandleTable::Close(Handle handle) {
if (!IsValid(handle))
return ERR_INVALID_HANDLE;
u16 slot = GetSlot(handle);
Result HandleTable::Close(Handle handle) {
R_UNLESS(IsValid(handle), ResultInvalidHandle);
const u16 slot = GetSlot(handle);
objects[slot] = nullptr;
generations[slot] = next_free_slot;
next_free_slot = slot;
return RESULT_SUCCESS;
return ResultSuccess;
}
bool HandleTable::IsValid(Handle handle) const {
std::size_t slot = GetSlot(handle);
u16 generation = GetGeneration(handle);
const u16 slot = GetSlot(handle);
const u16 generation = GetGeneration(handle);
return slot < MAX_COUNT && objects[slot] != nullptr && generations[slot] == generation;
}

View file

@ -51,24 +51,24 @@ public:
/**
* Allocates a handle for the given object.
* @return The created Handle or one of the following errors:
* - `ERR_OUT_OF_HANDLES`: the maximum number of handles has been exceeded.
* - `ResultOutOfHandles`: the maximum number of handles has been exceeded.
*/
ResultVal<Handle> Create(std::shared_ptr<Object> obj);
Result Create(Handle* out_handle, std::shared_ptr<Object> obj);
/**
* Returns a new handle that points to the same object as the passed in handle.
* @return The duplicated Handle or one of the following errors:
* - `ERR_INVALID_HANDLE`: an invalid handle was passed in.
* - `ResultInvalidHandle`: an invalid handle was passed in.
* - Any errors returned by `Create()`.
*/
ResultVal<Handle> Duplicate(Handle handle);
Result Duplicate(Handle* out_handle, Handle handle);
/**
* Closes a handle, removing it from the table and decreasing the object's ref-count.
* @return `RESULT_SUCCESS` or one of the following errors:
* - `ERR_INVALID_HANDLE`: an invalid handle was passed in.
* @return `ResultSuccess` or one of the following errors:
* - `ResultInvalidHandle`: an invalid handle was passed in.
*/
ResultCode Close(Handle handle);
Result Close(Handle handle);
/// Checks if a handle is valid and points to an existing object.
bool IsValid(Handle handle) const;

View file

@ -126,8 +126,8 @@ void HLERequestContext::AddStaticBuffer(u8 buffer_id, std::vector<u8> data) {
static_buffers[buffer_id] = std::move(data);
}
ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(
const u32_le* src_cmdbuf, std::shared_ptr<Process> src_process_) {
Result HLERequestContext::PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf,
std::shared_ptr<Process> src_process_) {
auto& src_process = *src_process_;
IPC::Header header{src_cmdbuf[0]};
@ -203,11 +203,11 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(
std::move(translated_cmdbuf));
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf,
Process& dst_process) const {
Result HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf,
Process& dst_process) const {
IPC::Header header{cmd_buf[0]};
std::size_t untranslated_size = 1u + header.normal_params_size;
@ -239,7 +239,7 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf,
Handle handle = 0;
if (object != nullptr) {
// TODO(yuriks): Figure out the proper error handling for if this fails
handle = dst_process.handle_table.Create(object).Unwrap();
R_ASSERT(dst_process.handle_table.Create(std::addressof(handle), object));
}
dst_cmdbuf[i++] = handle;
}
@ -281,7 +281,7 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf,
std::move(translated_cmdbuf));
}
return RESULT_SUCCESS;
return ResultSuccess;
}
MappedBuffer& HLERequestContext::GetMappedBuffer(u32 id_from_cmdbuf) {

View file

@ -363,10 +363,10 @@ public:
MappedBuffer& GetMappedBuffer(u32 id_from_cmdbuf);
/// Populates this context with data from the requesting process/thread.
ResultCode PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf,
std::shared_ptr<Process> src_process);
Result PopulateFromIncomingCommandBuffer(const u32_le* src_cmdbuf,
std::shared_ptr<Process> src_process);
/// Writes data from this context back to the requesting process/thread.
ResultCode WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, Process& dst_process) const;
Result WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, Process& dst_process) const;
/// Reports an unimplemented function.
void ReportUnimplemented() const;

View file

@ -18,12 +18,11 @@
namespace Kernel {
ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory,
std::shared_ptr<Thread> src_thread,
std::shared_ptr<Thread> dst_thread, VAddr src_address,
VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context,
bool reply) {
Result TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory,
std::shared_ptr<Thread> src_thread,
std::shared_ptr<Thread> dst_thread, VAddr src_address,
VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context, bool reply) {
auto src_process = src_thread->owner_process.lock();
auto dst_process = dst_thread->owner_process.lock();
ASSERT(src_process && dst_process);
@ -60,8 +59,8 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy
// Note: The real kernel does not check that the number of handles fits into the command
// buffer before writing them, only after finishing.
if (i + num_handles > command_size) {
return ResultCode(ErrCodes::CommandTooLarge, ErrorModule::OS,
ErrorSummary::InvalidState, ErrorLevel::Status);
return Result(ErrCodes::CommandTooLarge, ErrorModule::OS,
ErrorSummary::InvalidState, ErrorLevel::Status);
}
for (u32 j = 0; j < num_handles; ++j) {
@ -88,8 +87,8 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy
continue;
}
auto result = dst_process->handle_table.Create(std::move(object));
cmd_buf[i++] = result.ValueOr(0);
R_ASSERT(dst_process->handle_table.Create(std::addressof(cmd_buf[i++]),
std::move(object)));
}
break;
}
@ -180,10 +179,10 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy
next_vma.meminfo_state == MemoryState::Reserved);
// Unmap the buffer and guard pages from the source process
ResultCode result =
Result result =
src_process->vm_manager.UnmapRange(page_start - Memory::CITRA_PAGE_SIZE,
(num_pages + 2) * Memory::CITRA_PAGE_SIZE);
ASSERT(result == RESULT_SUCCESS);
ASSERT(result == ResultSuccess);
mapped_buffer_context.erase(found);
@ -216,11 +215,11 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy
ASSERT(dst_process->vm_manager.ChangeMemoryState(
low_guard_address, Memory::CITRA_PAGE_SIZE, Kernel::MemoryState::Shared,
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Reserved,
Kernel::VMAPermission::None) == RESULT_SUCCESS);
Kernel::VMAPermission::None) == ResultSuccess);
ASSERT(dst_process->vm_manager.ChangeMemoryState(
high_guard_address, Memory::CITRA_PAGE_SIZE, Kernel::MemoryState::Shared,
Kernel::VMAPermission::ReadWrite, Kernel::MemoryState::Reserved,
Kernel::VMAPermission::None) == RESULT_SUCCESS);
Kernel::VMAPermission::None) == ResultSuccess);
// Get proper mapped buffer address and store it in the cmd buffer.
target_address += Memory::CITRA_PAGE_SIZE;
@ -249,6 +248,6 @@ ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySy
memory.WriteBlock(*dst_process, dst_address, cmd_buf.data(), command_size * sizeof(u32));
return RESULT_SUCCESS;
return ResultSuccess;
}
} // namespace Kernel

View file

@ -40,10 +40,9 @@ private:
};
/// Performs IPC command buffer translation from one process to another.
ResultCode TranslateCommandBuffer(KernelSystem& system, Memory::MemorySystem& memory,
std::shared_ptr<Thread> src_thread,
std::shared_ptr<Thread> dst_thread, VAddr src_address,
VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context,
bool reply);
Result TranslateCommandBuffer(KernelSystem& system, Memory::MemorySystem& memory,
std::shared_ptr<Thread> src_thread,
std::shared_ptr<Thread> dst_thread, VAddr src_address,
VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context, bool reply);
} // namespace Kernel

View file

@ -66,7 +66,7 @@ void Mutex::Acquire(Thread* thread) {
lock_count++;
}
ResultCode Mutex::Release(Thread* thread) {
Result Mutex::Release(Thread* thread) {
// We can only release the mutex if it's held by the calling thread.
if (thread != holding_thread.get()) {
if (holding_thread) {
@ -75,15 +75,15 @@ ResultCode Mutex::Release(Thread* thread) {
"Tried to release a mutex (owned by thread id {}) from a different thread id {}",
holding_thread->thread_id, thread->thread_id);
}
return ResultCode(ErrCodes::WrongLockingThread, ErrorModule::Kernel,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
return Result(ErrCodes::WrongLockingThread, ErrorModule::Kernel,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
}
// Note: It should not be possible for the situation where the mutex has a holding thread with a
// zero lock count to occur. The real kernel still checks for this, so we do too.
if (lock_count <= 0)
return ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::Kernel,
ErrorSummary::InvalidState, ErrorLevel::Permanent);
return Result(ErrorDescription::InvalidResultValue, ErrorModule::Kernel,
ErrorSummary::InvalidState, ErrorLevel::Permanent);
lock_count--;
@ -96,7 +96,7 @@ ResultCode Mutex::Release(Thread* thread) {
kernel.PrepareReschedule();
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void Mutex::AddWaitingThread(std::shared_ptr<Thread> thread) {

View file

@ -60,7 +60,7 @@ public:
* @param thread Thread that wants to release the mutex.
* @returns The result code of the operation.
*/
ResultCode Release(Thread* thread);
Result Release(Thread* thread);
private:
KernelSystem& kernel;

View file

@ -192,9 +192,12 @@ void Process::Run(s32 main_thread_priority, u32 stack_size) {
return;
}
VAddr out_addr{};
auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions,
MemoryState memory_state) {
HeapAllocate(segment.addr, segment.size, permissions, memory_state, true);
HeapAllocate(std::addressof(out_addr), segment.addr, segment.size, permissions,
memory_state, true);
kernel.memory.WriteBlock(*this, segment.addr, codeset->memory.data() + segment.offset,
segment.size);
};
@ -205,8 +208,8 @@ void Process::Run(s32 main_thread_priority, u32 stack_size) {
MapSegment(codeset->DataSegment(), VMAPermission::ReadWrite, MemoryState::Private);
// Allocate and map stack
HeapAllocate(Memory::HEAP_VADDR_END - stack_size, stack_size, VMAPermission::ReadWrite,
MemoryState::Locked, true);
HeapAllocate(std::addressof(out_addr), Memory::HEAP_VADDR_END - stack_size, stack_size,
VMAPermission::ReadWrite, MemoryState::Locked, true);
// Map special address mappings
kernel.MapSharedPages(vm_manager);
@ -246,14 +249,14 @@ VAddr Process::GetLinearHeapLimit() const {
return GetLinearHeapBase() + memory_region->size;
}
ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission perms,
MemoryState memory_state, bool skip_range_check) {
Result Process::HeapAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms,
MemoryState memory_state, bool skip_range_check) {
LOG_DEBUG(Kernel, "Allocate heap target={:08X}, size={:08X}", target, size);
if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END ||
target + size < target) {
if (!skip_range_check) {
LOG_ERROR(Kernel, "Invalid heap address");
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
}
{
@ -261,13 +264,13 @@ ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission per
if (vma->second.type != VMAType::Free ||
vma->second.base + vma->second.size < target + size) {
LOG_ERROR(Kernel, "Trying to allocate already allocated memory");
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
}
auto allocated_fcram = memory_region->HeapAllocate(size);
if (allocated_fcram.empty()) {
LOG_ERROR(Kernel, "Not enough space");
return ERR_OUT_OF_HEAP_MEMORY;
return ResultOutOfHeapMemory;
}
// Maps heap block by block
@ -290,20 +293,19 @@ ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission per
memory_used += size;
resource_limit->Reserve(ResourceLimitType::Commit, size);
return target;
*out_addr = target;
return ResultSuccess;
}
ResultCode Process::HeapFree(VAddr target, u32 size) {
Result Process::HeapFree(VAddr target, u32 size) {
LOG_DEBUG(Kernel, "Free heap target={:08X}, size={:08X}", target, size);
if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END ||
target + size < target) {
LOG_ERROR(Kernel, "Invalid heap address");
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
if (size == 0) {
return RESULT_SUCCESS;
}
R_SUCCEED_IF(size == 0);
// Free heaps block by block
CASCADE_RESULT(auto backing_blocks, vm_manager.GetBackingBlocksForRange(target, size));
@ -313,23 +315,23 @@ ResultCode Process::HeapFree(VAddr target, u32 size) {
holding_memory -= MemoryRegionInfo::Interval(backing_offset, backing_offset + block_size);
}
ResultCode result = vm_manager.UnmapRange(target, size);
Result result = vm_manager.UnmapRange(target, size);
ASSERT(result.IsSuccess());
memory_used -= size;
resource_limit->Release(ResourceLimitType::Commit, size);
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission perms) {
Result Process::LinearAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms) {
LOG_DEBUG(Kernel, "Allocate linear heap target={:08X}, size={:08X}", target, size);
u32 physical_offset;
if (target == 0) {
auto offset = memory_region->LinearAllocate(size);
if (!offset) {
LOG_ERROR(Kernel, "Not enough space");
return ERR_OUT_OF_HEAP_MEMORY;
return ResultOutOfHeapMemory;
}
physical_offset = *offset;
target = physical_offset + GetLinearHeapAreaAddress();
@ -337,7 +339,7 @@ ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission p
if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() ||
target + size < target) {
LOG_ERROR(Kernel, "Invalid linear heap address");
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
// Kernel would crash/return error when target doesn't meet some requirement.
@ -350,7 +352,7 @@ ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission p
physical_offset = target - GetLinearHeapAreaAddress(); // relative to FCRAM
if (!memory_region->LinearAllocate(physical_offset, size)) {
LOG_ERROR(Kernel, "Trying to allocate already allocated memory");
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
}
@ -366,26 +368,20 @@ ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission p
resource_limit->Reserve(ResourceLimitType::Commit, size);
LOG_DEBUG(Kernel, "Allocated at target={:08X}", target);
return target;
*out_addr = target;
return ResultSuccess;
}
ResultCode Process::LinearFree(VAddr target, u32 size) {
Result Process::LinearFree(VAddr target, u32 size) {
LOG_DEBUG(Kernel, "Free linear heap target={:08X}, size={:08X}", target, size);
if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() ||
target + size < target) {
LOG_ERROR(Kernel, "Invalid linear heap address");
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
if (size == 0) {
return RESULT_SUCCESS;
}
ResultCode result = vm_manager.UnmapRange(target, size);
if (result.IsError()) {
LOG_ERROR(Kernel, "Trying to free already freed memory");
return result;
}
R_SUCCEED_IF(size == 0);
R_TRY(vm_manager.UnmapRange(target, size));
u32 physical_offset = target - GetLinearHeapAreaAddress(); // relative to FCRAM
memory_region->Free(physical_offset, size);
@ -394,7 +390,7 @@ ResultCode Process::LinearFree(VAddr target, u32 size) {
memory_used -= size;
resource_limit->Release(ResourceLimitType::Commit, size);
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultVal<VAddr> Process::AllocateThreadLocalStorage() {
@ -435,7 +431,7 @@ ResultVal<VAddr> Process::AllocateThreadLocalStorage() {
if (!offset) {
LOG_ERROR(Kernel_SVC,
"Not enough space in BASE linear region to allocate a new TLS page");
return ERR_OUT_OF_MEMORY;
return ResultOutOfMemory;
}
holding_tls_memory +=
@ -467,14 +463,13 @@ ResultVal<VAddr> Process::AllocateThreadLocalStorage() {
return tls_address;
}
ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perms,
bool privileged) {
Result Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged) {
LOG_DEBUG(Kernel, "Map memory target={:08X}, source={:08X}, size={:08X}, perms={:08X}", target,
source, size, perms);
if (!privileged && (source < Memory::HEAP_VADDR || source + size > Memory::HEAP_VADDR_END ||
source + size < source)) {
LOG_ERROR(Kernel, "Invalid source address");
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
// TODO(wwylele): check target address range. Is it also restricted to heap region?
@ -489,17 +484,17 @@ ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perm
VMAPermission::ReadWrite,
MemoryState::AliasCode, perms);
} else {
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
} else {
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
}
auto vma = vm_manager.FindVMA(target);
if (vma->second.type != VMAType::Free || vma->second.base + vma->second.size < target + size) {
LOG_ERROR(Kernel, "Trying to map to already allocated memory");
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
MemoryState source_state = privileged ? MemoryState::Locked : MemoryState::Aliased;
@ -507,8 +502,8 @@ ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perm
VMAPermission source_perm = privileged ? VMAPermission::None : VMAPermission::ReadWrite;
// Mark source region as Aliased
CASCADE_CODE(vm_manager.ChangeMemoryState(source, size, MemoryState::Private,
VMAPermission::ReadWrite, source_state, source_perm));
R_TRY(vm_manager.ChangeMemoryState(source, size, MemoryState::Private, VMAPermission::ReadWrite,
source_state, source_perm));
CASCADE_RESULT(auto backing_blocks, vm_manager.GetBackingBlocksForRange(source, size));
VAddr interval_target = target;
@ -520,16 +515,15 @@ ResultCode Process::Map(VAddr target, VAddr source, u32 size, VMAPermission perm
interval_target += block_size;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms,
bool privileged) {
Result Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged) {
LOG_DEBUG(Kernel, "Unmap memory target={:08X}, source={:08X}, size={:08X}, perms={:08X}",
target, source, size, perms);
if (!privileged && (source < Memory::HEAP_VADDR || source + size > Memory::HEAP_VADDR_END ||
source + size < source)) {
LOG_ERROR(Kernel, "Invalid source address");
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
// TODO(wwylele): check target address range. Is it also restricted to heap region?
@ -543,10 +537,10 @@ ResultCode Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission pe
VMAPermission::None, MemoryState::Private,
perms);
} else {
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
} else {
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
}
@ -555,13 +549,13 @@ ResultCode Process::Unmap(VAddr target, VAddr source, u32 size, VMAPermission pe
MemoryState source_state = privileged ? MemoryState::Locked : MemoryState::Aliased;
CASCADE_CODE(vm_manager.UnmapRange(target, size));
R_TRY(vm_manager.UnmapRange(target, size));
// Change back source region state. Note that the permission is reprotected according to param
CASCADE_CODE(vm_manager.ChangeMemoryState(source, size, source_state, VMAPermission::None,
MemoryState::Private, perms));
R_TRY(vm_manager.ChangeMemoryState(source, size, source_state, VMAPermission::None,
MemoryState::Private, perms));
return RESULT_SUCCESS;
return ResultSuccess;
}
void Process::FreeAllMemory() {

View file

@ -231,20 +231,19 @@ public:
VAddr GetLinearHeapBase() const;
VAddr GetLinearHeapLimit() const;
ResultVal<VAddr> HeapAllocate(VAddr target, u32 size, VMAPermission perms,
MemoryState memory_state = MemoryState::Private,
bool skip_range_check = false);
ResultCode HeapFree(VAddr target, u32 size);
Result HeapAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms,
MemoryState memory_state = MemoryState::Private,
bool skip_range_check = false);
Result HeapFree(VAddr target, u32 size);
ResultVal<VAddr> LinearAllocate(VAddr target, u32 size, VMAPermission perms);
ResultCode LinearFree(VAddr target, u32 size);
Result LinearAllocate(VAddr* out_addr, VAddr target, u32 size, VMAPermission perms);
Result LinearFree(VAddr target, u32 size);
ResultVal<VAddr> AllocateThreadLocalStorage();
ResultCode Map(VAddr target, VAddr source, u32 size, VMAPermission perms,
bool privileged = false);
ResultCode Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms,
bool privileged = false);
Result Map(VAddr target, VAddr source, u32 size, VMAPermission perms, bool privileged = false);
Result Unmap(VAddr target, VAddr source, u32 size, VMAPermission perms,
bool privileged = false);
private:
void FreeAllMemory();

View file

@ -26,9 +26,7 @@ ResultVal<std::shared_ptr<Semaphore>> KernelSystem::CreateSemaphore(s32 initial_
s32 max_count,
std::string name) {
if (initial_count > max_count) {
return ERR_INVALID_COMBINATION_KERNEL;
}
R_UNLESS(initial_count <= max_count, ResultInvalidCombinationKernel);
// When the semaphore is created, some slots are reserved for other threads,
// and the rest is reserved for the caller thread
@ -44,21 +42,20 @@ bool Semaphore::ShouldWait(const Thread* thread) const {
}
void Semaphore::Acquire(Thread* thread) {
if (available_count <= 0)
if (available_count <= 0) {
return;
}
--available_count;
}
ResultVal<s32> Semaphore::Release(s32 release_count) {
if (max_count - available_count < release_count)
return ERR_OUT_OF_RANGE_KERNEL;
Result Semaphore::Release(s32* out_count, s32 release_count) {
R_UNLESS(max_count >= release_count + available_count, ResultOutOfRangeKernel);
s32 previous_count = available_count;
*out_count = available_count;
available_count += release_count;
WakeupAllWaitingThreads();
return previous_count;
return ResultSuccess;
}
} // namespace Kernel

View file

@ -47,7 +47,7 @@ public:
* @param release_count The number of slots to release
* @return The number of free slots the semaphore had before this call
*/
ResultVal<s32> Release(s32 release_count);
Result Release(s32* out_count, s32 release_count);
private:
friend class boost::serialization::access;

View file

@ -24,14 +24,12 @@ namespace Kernel {
ServerPort::ServerPort(KernelSystem& kernel) : WaitObject(kernel) {}
ServerPort::~ServerPort() {}
ResultVal<std::shared_ptr<ServerSession>> ServerPort::Accept() {
if (pending_sessions.empty()) {
return ERR_NO_PENDING_SESSIONS;
}
Result ServerPort::Accept(std::shared_ptr<ServerSession>* out_server_session) {
R_UNLESS(!pending_sessions.empty(), ResultNoPendingSessions);
auto session = std::move(pending_sessions.back());
*out_server_session = std::move(pending_sessions.back());
pending_sessions.pop_back();
return session;
return ResultSuccess;
}
bool ServerPort::ShouldWait(const Thread* thread) const {

View file

@ -39,9 +39,9 @@ public:
/**
* Accepts a pending incoming connection on this port. If there are no pending sessions, will
* return ERR_NO_PENDING_SESSIONS.
* return ResultNoPendingSessions.
*/
ResultVal<std::shared_ptr<ServerSession>> Accept();
Result Accept(std::shared_ptr<ServerSession>* out_server_session);
/**
* Sets the HLE handler template for the port. ServerSessions crated by connecting to this port

View file

@ -77,7 +77,7 @@ void ServerSession::Acquire(Thread* thread) {
pending_requesting_threads.pop_back();
}
ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) {
Result ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) {
// The ServerSession received a sync request, this means that there's new data available
// from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or
// similar.
@ -136,7 +136,7 @@ ResultCode ServerSession::HandleSyncRequest(std::shared_ptr<Thread> thread) {
// If this ServerSession does not have an HLE implementation, just wake up the threads waiting
// on it.
WakeupAllWaitingThreads();
return RESULT_SUCCESS;
return ResultSuccess;
}
KernelSystem::SessionPair KernelSystem::CreateSessionPair(const std::string& name,

View file

@ -66,9 +66,9 @@ public:
/**
* Handle a sync request from the emulated application.
* @param thread Thread that initiated the request.
* @returns ResultCode from the operation.
* @returns Result from the operation.
*/
ResultCode HandleSyncRequest(std::shared_ptr<Thread> thread);
Result HandleSyncRequest(std::shared_ptr<Thread> thread);
bool ShouldWait(const Thread* thread) const override;

View file

@ -67,9 +67,9 @@ ResultVal<std::shared_ptr<SharedMemory>> KernelSystem::CreateSharedMemory(
auto& vm_manager = owner_process->vm_manager;
// The memory is already available and mapped in the owner process.
CASCADE_CODE(vm_manager.ChangeMemoryState(address, size, MemoryState::Private,
VMAPermission::ReadWrite, MemoryState::Locked,
SharedMemory::ConvertPermissions(permissions)));
R_TRY(vm_manager.ChangeMemoryState(address, size, MemoryState::Private,
VMAPermission::ReadWrite, MemoryState::Locked,
SharedMemory::ConvertPermissions(permissions)));
auto backing_blocks = vm_manager.GetBackingBlocksForRange(address, size);
ASSERT(backing_blocks.Succeeded()); // should success after verifying memory state above
@ -107,29 +107,29 @@ std::shared_ptr<SharedMemory> KernelSystem::CreateSharedMemoryForApplet(
return shared_memory;
}
ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermission permissions,
MemoryPermission other_permissions) {
Result SharedMemory::Map(Process& target_process, VAddr address, MemoryPermission permissions,
MemoryPermission other_permissions) {
MemoryPermission own_other_permissions =
&target_process == owner_process.lock().get() ? this->permissions : this->other_permissions;
// Automatically allocated memory blocks can only be mapped with other_permissions = DontCare
if (base_address == 0 && other_permissions != MemoryPermission::DontCare) {
return ERR_INVALID_COMBINATION;
return ResultInvalidCombination;
}
// Error out if the requested permissions don't match what the creator process allows.
if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) {
LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match",
GetObjectId(), address, name);
return ERR_INVALID_COMBINATION;
return ResultInvalidCombination;
}
// Heap-backed memory blocks can not be mapped with other_permissions = DontCare
if (base_address != 0 && other_permissions == MemoryPermission::DontCare) {
LOG_ERROR(Kernel, "cannot map id={}, address=0x{08X} name={}, permissions don't match",
GetObjectId(), address, name);
return ERR_INVALID_COMBINATION;
return ResultInvalidCombination;
}
// Error out if the provided permissions are not compatible with what the creator process needs.
@ -137,12 +137,12 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi
static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) {
LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, permissions don't match",
GetObjectId(), address, name);
return ERR_WRONG_PERMISSION;
return ResultWrongPermission;
}
// TODO(Subv): Check for the Shared Device Mem flag in the creator process.
/*if (was_created_with_shared_device_mem && address != 0) {
return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
return Result(ErrorDescription::InvalidCombination, ErrorModule::OS,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
}*/
@ -153,7 +153,7 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi
if (address < Memory::HEAP_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) {
LOG_ERROR(Kernel, "cannot map id={}, address=0x{:08X} name={}, invalid address",
GetObjectId(), address, name);
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
}
@ -174,7 +174,7 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi
Kernel,
"cannot map id={}, address=0x{:08X} name={}, mapping to already allocated memory",
GetObjectId(), address, name);
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
}
@ -188,10 +188,10 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi
interval_target += interval.second;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode SharedMemory::Unmap(Process& target_process, VAddr address) {
Result SharedMemory::Unmap(Process& target_process, VAddr address) {
// TODO(Subv): Verify what happens if the application tries to unmap an address that is not
// mapped to a SharedMemory.
return target_process.vm_manager.UnmapRange(address, size);

View file

@ -61,8 +61,8 @@ public:
* @param permissions Memory block map permissions (specified by SVC field)
* @param other_permissions Memory block map other permissions (specified by SVC field)
*/
ResultCode Map(Process& target_process, VAddr address, MemoryPermission permissions,
MemoryPermission other_permissions);
Result Map(Process& target_process, VAddr address, MemoryPermission permissions,
MemoryPermission other_permissions);
/**
* Unmaps a shared memory block from the specified address in system memory
@ -70,7 +70,7 @@ public:
* @param address Address in system memory where the shared memory block is mapped
* @return Result code of the unmap operation
*/
ResultCode Unmap(Process& target_process, VAddr address);
Result Unmap(Process& target_process, VAddr address);
/**
* Gets a pointer to the shared memory block

File diff suppressed because it is too large Load diff

View file

@ -281,21 +281,21 @@ private:
};
template <typename SVCT>
struct WrapPass<SVCT, ResultCode /*empty for T, Ts...*/> {
struct WrapPass<SVCT, Result /*empty for T, Ts...*/> {
// Call function R(Context::svc)(Us...) and transfer the return value to registers
template <typename... Us>
static void Call(Context& context, SVCT svc, Us... u) {
static_assert(std::is_same_v<SVCT, ResultCode (Context::*)(Us...)>);
if constexpr (std::is_void_v<ResultCode>) {
static_assert(std::is_same_v<SVCT, Result (Context::*)(Us...)>);
if constexpr (std::is_void_v<Result>) {
(context.*svc)(u...);
} else {
ResultCode r = (context.*svc)(u...);
Result r = (context.*svc)(u...);
if (r.IsError()) {
LOG_ERROR(Kernel_SVC, "level={} summary={} module={} description={}",
r.level.ExtractValue(r.raw), r.summary.ExtractValue(r.raw),
r.module.ExtractValue(r.raw), r.description.ExtractValue(r.raw));
}
SetParam<INDEX_RETURN, ResultCode, ResultCode, Us...>(context, r);
SetParam<INDEX_RETURN, Result, Result, Us...>(context, r);
}
}
};

View file

@ -332,20 +332,20 @@ ResultVal<std::shared_ptr<Thread>> KernelSystem::CreateThread(
// Check if priority is in ranged. Lowest priority -> highest priority id.
if (priority > ThreadPrioLowest) {
LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority);
return ERR_OUT_OF_RANGE;
return ResultOutOfRange;
}
if (processor_id > ThreadProcessorIdMax) {
LOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id);
return ERR_OUT_OF_RANGE_KERNEL;
return ResultOutOfRangeKernel;
}
// TODO(yuriks): Other checks, returning 0xD9001BEA
if (!memory.IsValidVirtualAddress(*owner_process, entry_point)) {
LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:08x}", name, entry_point);
// TODO: Verify error
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
return Result(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
}
auto thread = std::make_shared<Thread>(*this, processor_id);
@ -445,7 +445,7 @@ void ThreadManager::Reschedule() {
SwitchContext(next);
}
void Thread::SetWaitSynchronizationResult(ResultCode result) {
void Thread::SetWaitSynchronizationResult(Result result) {
context.cpu_registers[0] = result.raw;
}

View file

@ -243,7 +243,7 @@ public:
* Sets the result after the thread awakens (from either WaitSynchronization SVC)
* @param result Value to set to the returned result
*/
void SetWaitSynchronizationResult(ResultCode result);
void SetWaitSynchronizationResult(Result result);
/**
* Sets the output parameter value after the thread awakens (from WaitSynchronizationN SVC only)

View file

@ -83,8 +83,8 @@ ResultVal<VAddr> VMManager::MapBackingMemoryToBase(VAddr base, u32 region_size,
// Do not try to allocate the block if there are no available addresses within the desired
// region.
if (vma_handle == vma_map.end() || target + size > base + region_size) {
return ResultCode(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
ErrorSummary::OutOfResource, ErrorLevel::Permanent);
return Result(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
ErrorSummary::OutOfResource, ErrorLevel::Permanent);
}
auto result = MapBackingMemory(target, memory, size, state);
@ -114,11 +114,11 @@ ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, Memory
return MergeAdjacent(vma_handle);
}
ResultCode VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state,
VMAPermission expected_perms, MemoryState new_state,
VMAPermission new_perms) {
Result VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state,
VMAPermission expected_perms, MemoryState new_state,
VMAPermission new_perms) {
if (is_locked) {
return RESULT_SUCCESS;
return ResultSuccess;
}
VAddr target_end = target + size;
@ -126,16 +126,16 @@ ResultCode VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expe
VMAIter i_end = vma_map.lower_bound(target_end);
if (begin_vma == vma_map.end())
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
for (auto i = begin_vma; i != i_end; ++i) {
auto& vma = i->second;
if (vma.meminfo_state != expected_state) {
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
u32 perms = static_cast<u32>(expected_perms);
if ((static_cast<u32>(vma.permissions) & perms) != perms) {
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
}
@ -151,7 +151,7 @@ ResultCode VMManager::ChangeMemoryState(VAddr target, u32 size, MemoryState expe
vma = std::next(MergeAdjacent(vma));
}
return RESULT_SUCCESS;
return ResultSuccess;
}
VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) {
@ -168,7 +168,7 @@ VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) {
return MergeAdjacent(vma_handle);
}
ResultCode VMManager::UnmapRange(VAddr target, u32 size) {
Result VMManager::UnmapRange(VAddr target, u32 size) {
ASSERT(!is_locked);
CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size));
@ -182,7 +182,7 @@ ResultCode VMManager::UnmapRange(VAddr target, u32 size) {
}
ASSERT(FindVMA(target)->second.size >= size);
return RESULT_SUCCESS;
return ResultSuccess;
}
VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission new_perms) {
@ -197,7 +197,7 @@ VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission ne
return MergeAdjacent(iter);
}
ResultCode VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_perms) {
Result VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_perms) {
ASSERT(!is_locked);
CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size));
@ -210,7 +210,7 @@ ResultCode VMManager::ReprotectRange(VAddr target, u32 size, VMAPermission new_p
vma = std::next(StripIterConstness(Reprotect(vma, new_perms)));
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void VMManager::LogLayout(Common::Log::Level log_level) const {
@ -242,13 +242,13 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u32 size) {
VMAIter vma_handle = StripIterConstness(FindVMA(base));
if (vma_handle == vma_map.end()) {
// Target address is outside the range managed by the kernel
return ERR_INVALID_ADDRESS;
return ResultInvalidAddress;
}
const VirtualMemoryArea& vma = vma_handle->second;
if (vma.type != VMAType::Free) {
// Region is already allocated
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
const VAddr start_in_vma = base - vma.base;
@ -256,7 +256,7 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u32 size) {
if (end_in_vma > vma.size) {
// Requested allocation doesn't fit inside VMA
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
if (end_in_vma != vma.size) {
@ -284,7 +284,7 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u32 size) {
const VMAIter i_end = vma_map.lower_bound(target_end);
if (std::any_of(begin_vma, i_end,
[](const auto& entry) { return entry.second.type == VMAType::Free; })) {
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
if (target != begin_vma->second.base) {
@ -367,7 +367,7 @@ ResultVal<std::vector<std::pair<MemoryRef, u32>>> VMManager::GetBackingBlocksFor
auto vma = FindVMA(interval_target);
if (vma->second.type != VMAType::BackingMemory) {
LOG_ERROR(Kernel, "Trying to use already freed memory");
return ERR_INVALID_ADDRESS_STATE;
return ResultInvalidAddressState;
}
VAddr interval_end = std::min(address + size, vma->second.base + vma->second.size);

View file

@ -165,18 +165,18 @@ public:
* @param new_state New MemoryState for the range.
* @param new_perms New VMAPermission for the range.
*/
ResultCode ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state,
VMAPermission expected_perms, MemoryState new_state,
VMAPermission new_perms);
Result ChangeMemoryState(VAddr target, u32 size, MemoryState expected_state,
VMAPermission expected_perms, MemoryState new_state,
VMAPermission new_perms);
/// Unmaps a range of addresses, splitting VMAs as necessary.
ResultCode UnmapRange(VAddr target, u32 size);
Result UnmapRange(VAddr target, u32 size);
/// Changes the permissions of the given VMA.
VMAHandle Reprotect(VMAHandle vma, VMAPermission new_perms);
/// Changes the permissions of a range of addresses, splitting VMAs as necessary.
ResultCode ReprotectRange(VAddr target, u32 size, VMAPermission new_perms);
Result ReprotectRange(VAddr target, u32 size, VMAPermission new_perms);
/// Dumps the address space layout to the log, for debugging
void LogLayout(Common::Log::Level log_level) const;

View file

@ -192,7 +192,7 @@ enum class ErrorLevel : u32 {
};
/// Encapsulates a CTR-OS error code, allowing it to be separated into its constituent fields.
union ResultCode {
union Result {
u32 raw;
BitField<0, 10, u32> description;
@ -205,18 +205,18 @@ union ResultCode {
// error
BitField<31, 1, u32> is_error;
constexpr explicit ResultCode(u32 raw) : raw(raw) {}
constexpr explicit Result(u32 raw) : raw(raw) {}
constexpr ResultCode(ErrorDescription description, ErrorModule module, ErrorSummary summary,
ErrorLevel level)
: ResultCode(static_cast<u32>(description), module, summary, level) {}
constexpr Result(ErrorDescription description, ErrorModule module, ErrorSummary summary,
ErrorLevel level)
: Result(static_cast<u32>(description), module, summary, level) {}
constexpr ResultCode(u32 description_, ErrorModule module_, ErrorSummary summary_,
ErrorLevel level_)
constexpr Result(u32 description_, ErrorModule module_, ErrorSummary summary_,
ErrorLevel level_)
: raw(description.FormatValue(description_) | module.FormatValue(module_) |
summary.FormatValue(summary_) | level.FormatValue(level_)) {}
constexpr ResultCode& operator=(const ResultCode& o) = default;
constexpr Result& operator=(const Result& o) = default;
constexpr bool IsSuccess() const {
return is_error.ExtractValue(raw) == 0;
@ -234,23 +234,23 @@ private:
friend class boost::serialization::access;
};
constexpr bool operator==(const ResultCode& a, const ResultCode& b) {
constexpr bool operator==(const Result& a, const Result& b) {
return a.raw == b.raw;
}
constexpr bool operator!=(const ResultCode& a, const ResultCode& b) {
constexpr bool operator!=(const Result& a, const Result& b) {
return a.raw != b.raw;
}
// Convenience functions for creating some common kinds of errors:
/// The default success `ResultCode`.
constexpr ResultCode RESULT_SUCCESS(0);
/// The default success `Result`.
constexpr Result ResultSuccess(0);
/// Might be returned instead of a dummy success for unimplemented APIs.
constexpr ResultCode UnimplementedFunction(ErrorModule module) {
return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported,
ErrorLevel::Permanent);
constexpr Result UnimplementedFunction(ErrorModule module) {
return Result(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported,
ErrorLevel::Permanent);
}
/**
@ -259,10 +259,10 @@ constexpr ResultCode UnimplementedFunction(ErrorModule module) {
* @note This should only be used when a particular error code
* is not known yet.
*/
constexpr ResultCode RESULT_UNKNOWN(UINT32_MAX);
constexpr Result ResultUnknown(std::numeric_limits<u32>::max());
/**
* 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
* 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(),
@ -273,7 +273,7 @@ constexpr ResultCode RESULT_UNKNOWN(UINT32_MAX);
* ResultVal<int> Frobnicate(float strength) {
* if (strength < 0.f || strength > 1.0f) {
* // Can't frobnicate too weakly or too strongly
* return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Common,
* return Result(ErrorDescription::OutOfRange, ErrorModule::Common,
* ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
* } else {
* // Frobnicated! Give caller a cookie
@ -297,7 +297,7 @@ class ResultVal {
public:
constexpr ResultVal() : expected{} {}
constexpr ResultVal(ResultCode code) : expected{Common::Unexpected(code)} {}
constexpr ResultVal(Result code) : expected{Common::Unexpected(code)} {}
template <typename U>
constexpr ResultVal(U&& val) : expected{std::forward<U>(val)} {}
@ -317,8 +317,8 @@ public:
return expected.has_value();
}
[[nodiscard]] constexpr ResultCode Code() const {
return expected.has_value() ? RESULT_SUCCESS : expected.error();
[[nodiscard]] constexpr Result Code() const {
return expected.has_value() ? ResultSuccess : expected.error();
}
[[nodiscard]] constexpr bool Succeeded() const {
@ -385,7 +385,7 @@ public:
private:
// TODO: Replace this with std::expected once it is standardized in the STL.
Common::Expected<T, ResultCode> expected;
Common::Expected<T, Result> expected;
};
/**
@ -400,11 +400,28 @@ private:
return CONCAT2(check_result_L, __LINE__).Code(); \
target = std::move(*CONCAT2(check_result_L, __LINE__))
/**
* Analogous to CASCADE_RESULT, but for a bare ResultCode. The code will be propagated if
* non-success, or discarded otherwise.
*/
#define CASCADE_CODE(source) \
auto CONCAT2(check_result_L, __LINE__) = source; \
if (CONCAT2(check_result_L, __LINE__).IsError()) \
return CONCAT2(check_result_L, __LINE__);
#define R_SUCCEEDED(res) (static_cast<Result>(res).IsSuccess())
#define R_FAILED(res) (static_cast<Result>(res).IsError())
/// Evaluates a boolean expression, and returns a result unless that expression is true.
#define R_UNLESS(expr, res) \
{ \
if (!(expr)) { \
return (res); \
} \
}
/// Evaluates an expression that returns a result, and returns the result if it would fail.
#define R_TRY(res_expr) \
{ \
const auto _tmp_r_try_rc = (res_expr); \
if (R_FAILED(_tmp_r_try_rc)) { \
return (_tmp_r_try_rc); \
} \
}
/// Evaluates a boolean expression, and succeeds if that expression is true.
#define R_SUCCEED_IF(expr) R_UNLESS(!(expr), ResultSuccess)
/// Evaluates a boolean expression, and asserts if that expression is false.
#define R_ASSERT(expr) ASSERT(R_SUCCEEDED(expr))

View file

@ -28,7 +28,7 @@ void Module::Interface::CreateDefaultConfig(Kernel::HLERequestContext& ctx) {
std::memcpy(buffer.data(), &ac->default_config, buffer.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0);
LOG_WARNING(Service_AC, "(STUBBED) called");
@ -48,7 +48,7 @@ void Module::Interface::ConnectAsync(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_AC, "(STUBBED) called");
}
@ -58,7 +58,7 @@ void Module::Interface::GetConnectResult(Kernel::HLERequestContext& ctx) {
rp.Skip(2, false); // ProcessId descriptor
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::Interface::CloseAsync(Kernel::HLERequestContext& ctx) {
@ -79,7 +79,7 @@ void Module::Interface::CloseAsync(Kernel::HLERequestContext& ctx) {
ac->ac_connected = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::Interface::GetCloseResult(Kernel::HLERequestContext& ctx) {
@ -87,7 +87,7 @@ void Module::Interface::GetCloseResult(Kernel::HLERequestContext& ctx) {
rp.Skip(2, false); // ProcessId descriptor
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_AC, "(STUBBED) called");
}
@ -102,7 +102,7 @@ void Module::Interface::GetWifiStatus(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(can_reach_internet ? (Settings::values.is_new_3ds
? WifiStatus::STATUS_CONNECTED_N3DS
: WifiStatus::STATUS_CONNECTED_O3DS)
@ -114,7 +114,7 @@ void Module::Interface::GetInfraPriority(Kernel::HLERequestContext& ctx) {
[[maybe_unused]] const std::vector<u8>& ac_config = rp.PopStaticBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // Infra Priority, default 0
LOG_WARNING(Service_AC, "(STUBBED) called");
@ -131,7 +131,7 @@ void Module::Interface::SetRequestEulaVersion(Kernel::HLERequestContext& ctx) {
// TODO(Subv): Copy over the input ACConfig to the stored ACConfig.
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(ac_config), 0);
LOG_WARNING(Service_AC, "(STUBBED) called, major={}, minor={}", major, minor);
@ -147,7 +147,7 @@ void Module::Interface::RegisterDisconnectEvent(Kernel::HLERequestContext& ctx)
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_AC, "(STUBBED) called");
}
@ -157,7 +157,7 @@ void Module::Interface::GetConnectingProxyEnable(Kernel::HLERequestContext& ctx)
constexpr bool proxy_enabled = false;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(proxy_enabled);
LOG_WARNING(Service_AC, "(STUBBED) called");
@ -170,7 +170,7 @@ void Module::Interface::IsConnected(Kernel::HLERequestContext& ctx) {
u32 unk_param = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ac->ac_connected);
LOG_WARNING(Service_AC, "(STUBBED) called unk=0x{:08X} descriptor=0x{:08X} param=0x{:08X}", unk,
@ -186,7 +186,7 @@ void Module::Interface::SetClientVersion(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_AC, "(STUBBED) called, version: 0x{:08X}", version);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
Module::Interface::Interface(std::shared_ptr<Module> ac, const char* name, u32 max_session)

View file

@ -28,7 +28,7 @@ void Module::Interface::Initialize(Kernel::HLERequestContext& ctx) {
sdk_version, shared_memory_size, caller_pid);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::Interface::GetAccountDataBlock(Kernel::HLERequestContext& ctx) {
@ -42,7 +42,7 @@ void Module::Interface::GetAccountDataBlock(Kernel::HLERequestContext& ctx) {
size, block_id);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void InstallInterfaces(Core::System& system) {

View file

@ -93,7 +93,7 @@ ResultVal<std::size_t> CIAFile::Read(u64 offset, std::size_t length, u8* buffer)
return length;
}
ResultCode CIAFile::WriteTicket() {
Result CIAFile::WriteTicket() {
auto load_result = container.LoadTicket(data, container.GetTicketOffset());
if (load_result != Loader::ResultStatus::Success) {
LOG_ERROR(Service_AM, "Could not read ticket from CIA.");
@ -105,10 +105,10 @@ ResultCode CIAFile::WriteTicket() {
// TODO: Write out .tik files to nand?
install_state = CIAInstallState::TicketLoaded;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CIAFile::WriteTitleMetadata() {
Result CIAFile::WriteTitleMetadata() {
auto load_result = container.LoadTitleMetadata(data, container.GetTitleMetadataOffset());
if (load_result != Loader::ResultStatus::Success) {
LOG_ERROR(Service_AM, "Could not read title metadata from CIA.");
@ -138,7 +138,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
if (tmd.Save(tmd_path) != Loader::ResultStatus::Success) {
LOG_ERROR(Service_AM, "Failed to install title metadata file from CIA.");
// TODO: Correct result code.
return FileSys::ERROR_FILE_NOT_FOUND;
return FileSys::ResultFileNotFound;
}
// Create any other .app folders which may not exist yet
@ -158,7 +158,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
if (!file.IsOpen()) {
LOG_ERROR(Service_AM, "Could not open output file '{}' for content {}.", path, i);
// TODO: Correct error code.
return FileSys::ERROR_FILE_NOT_FOUND;
return FileSys::ResultFileNotFound;
}
}
@ -173,7 +173,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
} else {
LOG_ERROR(Service_AM, "Could not read title key from ticket for encrypted CIA.");
// TODO: Correct error code.
return FileSys::ERROR_FILE_NOT_FOUND;
return FileSys::ResultFileNotFound;
}
} else {
LOG_INFO(Service_AM,
@ -182,7 +182,7 @@ ResultCode CIAFile::WriteTitleMetadata() {
install_state = CIAInstallState::TMDLoaded;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultVal<std::size_t> CIAFile::WriteContentData(u64 offset, std::size_t length, const u8* buffer) {
@ -772,7 +772,7 @@ void Module::Interface::GetNumPrograms(Kernel::HLERequestContext& ctx) {
u32 media_type = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(am->am_title_list[media_type].size()));
}
@ -789,8 +789,8 @@ void Module::Interface::FindDLCContentInfos(Kernel::HLERequestContext& ctx) {
u32 tid_high = static_cast<u32>(title_id >> 32);
if (tid_high != TID_HIGH_DLC) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage));
rb.Push(Result(ErrCodes::InvalidTIDInList, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Usage));
rb.PushMappedBuffer(content_requested_in);
rb.PushMappedBuffer(content_info_out);
return;
@ -836,7 +836,7 @@ void Module::Interface::FindDLCContentInfos(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(content_requested_in);
rb.PushMappedBuffer(content_info_out);
}
@ -854,8 +854,8 @@ void Module::Interface::ListDLCContentInfos(Kernel::HLERequestContext& ctx) {
u32 tid_high = static_cast<u32>(title_id >> 32);
if (tid_high != TID_HIGH_DLC) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage));
rb.Push(Result(ErrCodes::InvalidTIDInList, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Usage));
rb.Push<u32>(0);
rb.PushMappedBuffer(content_info_out);
return;
@ -889,7 +889,7 @@ void Module::Interface::ListDLCContentInfos(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(copied);
rb.PushMappedBuffer(content_info_out);
}
@ -902,7 +902,7 @@ void Module::Interface::DeleteContents(Kernel::HLERequestContext& ctx) {
auto& content_ids_in = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(content_ids_in);
LOG_WARNING(Service_AM, "(STUBBED) media_type={}, title_id=0x{:016x}, content_count={}",
media_type, title_id, content_count);
@ -929,14 +929,13 @@ void Module::Interface::GetProgramList(Kernel::HLERequestContext& ctx) {
title_ids_output.Write(am->am_title_list[media_type].data(), 0, copied * sizeof(u64));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(copied);
rb.PushMappedBuffer(title_ids_output);
}
ResultCode GetTitleInfoFromList(std::span<const u64> title_id_list,
Service::FS::MediaType media_type,
Kernel::MappedBuffer& title_info_out) {
Result GetTitleInfoFromList(std::span<const u64> title_id_list, Service::FS::MediaType media_type,
Kernel::MappedBuffer& title_info_out) {
std::size_t write_offset = 0;
for (u32 i = 0; i < title_id_list.size(); i++) {
std::string tmd_path = GetTitleMetadataPath(media_type, title_id_list[i]);
@ -952,14 +951,14 @@ ResultCode GetTitleInfoFromList(std::span<const u64> title_id_list,
title_info.version = tmd.GetTitleVersion();
title_info.type = tmd.GetTitleType();
} else {
return ResultCode(ErrorDescription::NotFound, ErrorModule::AM,
ErrorSummary::InvalidState, ErrorLevel::Permanent);
return Result(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
}
title_info_out.Write(&title_info, write_offset, sizeof(TitleInfo));
write_offset += sizeof(TitleInfo);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void Module::Interface::GetProgramInfos(Kernel::HLERequestContext& ctx) {
@ -973,7 +972,7 @@ void Module::Interface::GetProgramInfos(Kernel::HLERequestContext& ctx) {
std::vector<u64> title_id_list(title_count);
title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64));
ResultCode result = GetTitleInfoFromList(title_id_list, media_type, title_info_out);
Result result = GetTitleInfoFromList(title_id_list, media_type, title_info_out);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(result);
@ -994,21 +993,21 @@ void Module::Interface::DeleteUserProgram(Kernel::HLERequestContext& ctx) {
u8 variation = static_cast<u8>(title_id & 0xFF);
if (category & CATEGORY_SYSTEM || category & CATEGORY_DLP || variation & VARIATION_SYSTEM) {
LOG_ERROR(Service_AM, "Trying to uninstall system app");
rb.Push(ResultCode(ErrCodes::TryingToUninstallSystemApp, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage));
rb.Push(Result(ErrCodes::TryingToUninstallSystemApp, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage));
return;
}
LOG_INFO(Service_AM, "Deleting title 0x{:016x}", title_id);
std::string path = GetTitlePath(media_type, title_id);
if (!FileUtil::Exists(path)) {
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
LOG_ERROR(Service_AM, "Title not found");
return;
}
bool success = FileUtil::DeleteDirRecursively(path);
am->ScanForAllTitles();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
if (!success)
LOG_ERROR(Service_AM, "FileUtil::DeleteDirRecursively unexpectedly failed");
}
@ -1021,8 +1020,8 @@ void Module::Interface::GetProductCode(Kernel::HLERequestContext& ctx) {
if (!FileUtil::Exists(path)) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
} else {
struct ProductCode {
u8 code[0x10];
@ -1034,7 +1033,7 @@ void Module::Interface::GetProductCode(Kernel::HLERequestContext& ctx) {
FileSys::NCCHContainer ncch(path);
ncch.Load();
std::memcpy(&product_code.code, &ncch.ncch_header.product_code, 0x10);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(product_code);
}
}
@ -1050,14 +1049,14 @@ void Module::Interface::GetDLCTitleInfos(Kernel::HLERequestContext& ctx) {
std::vector<u64> title_id_list(title_count);
title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64));
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
// Validate that DLC TIDs were passed in
for (u32 i = 0; i < title_count; i++) {
u32 tid_high = static_cast<u32>(title_id_list[i] >> 32);
if (tid_high != TID_HIGH_DLC) {
result = ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
result = Result(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
break;
}
}
@ -1083,14 +1082,14 @@ void Module::Interface::GetPatchTitleInfos(Kernel::HLERequestContext& ctx) {
std::vector<u64> title_id_list(title_count);
title_id_list_buffer.Read(title_id_list.data(), 0, title_count * sizeof(u64));
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
// Validate that update TIDs were passed in
for (u32 i = 0; i < title_count; i++) {
u32 tid_high = static_cast<u32>(title_id_list[i] >> 32);
if (tid_high != TID_HIGH_UPDATE) {
result = ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
result = Result(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
break;
}
}
@ -1124,7 +1123,7 @@ void Module::Interface::ListDataTitleTicketInfos(Kernel::HLERequestContext& ctx)
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ticket_count);
rb.PushMappedBuffer(ticket_info_out);
@ -1142,14 +1141,14 @@ void Module::Interface::GetDLCContentInfoCount(Kernel::HLERequestContext& ctx) {
u32 tid_high = static_cast<u32>(title_id >> 32);
if (tid_high != TID_HIGH_DLC) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(ResultCode(ErrCodes::InvalidTID, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Usage));
rb.Push(Result(ErrCodes::InvalidTID, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Usage));
rb.Push<u32>(0);
return;
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
std::string tmd_path = GetTitleMetadataPath(media_type, title_id);
@ -1168,7 +1167,7 @@ void Module::Interface::DeleteTicket(Kernel::HLERequestContext& ctx) {
u64 title_id = rp.Pop<u64>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_AM, "(STUBBED) called title_id=0x{:016x}", title_id);
}
@ -1181,7 +1180,7 @@ void Module::Interface::GetNumTickets(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ticket_count);
LOG_WARNING(Service_AM, "(STUBBED) called ticket_count=0x{:08x}", ticket_count);
}
@ -1202,7 +1201,7 @@ void Module::Interface::GetTicketList(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(tickets_written);
rb.PushMappedBuffer(ticket_tids_out);
LOG_WARNING(Service_AM, "(STUBBED) ticket_list_count=0x{:08x}, ticket_index=0x{:08x}",
@ -1216,7 +1215,7 @@ void Module::Interface::NeedsCleanup(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "(STUBBED) media_type=0x{:02x}", media_type);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<bool>(false);
}
@ -1227,7 +1226,7 @@ void Module::Interface::DoCleanup(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_AM, "(STUBBED) called, media_type={:#02x}", media_type);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::Interface::QueryAvailableTitleDatabase(Kernel::HLERequestContext& ctx) {
@ -1235,7 +1234,7 @@ void Module::Interface::QueryAvailableTitleDatabase(Kernel::HLERequestContext& c
u8 media_type = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(true);
LOG_WARNING(Service_AM, "(STUBBED) media_type={}", media_type);
@ -1247,7 +1246,7 @@ void Module::Interface::GetPersonalizedTicketInfoList(Kernel::HLERequestContext&
[[maybe_unused]] auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(0);
LOG_WARNING(Service_AM, "(STUBBED) called, ticket_count={}", ticket_count);
@ -1259,7 +1258,7 @@ void Module::Interface::GetNumImportTitleContextsFiltered(Kernel::HLERequestCont
u8 filter = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(0);
LOG_WARNING(Service_AM, "(STUBBED) called, media_type={}, filter={}", media_type, filter);
@ -1273,7 +1272,7 @@ void Module::Interface::GetImportTitleContextListFiltered(Kernel::HLERequestCont
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(0);
rb.PushMappedBuffer(buffer);
@ -1291,7 +1290,7 @@ void Module::Interface::CheckContentRights(Kernel::HLERequestContext& ctx) {
FileUtil::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(has_rights);
LOG_WARNING(Service_AM, "(STUBBED) tid={:016x}, content_index={}", tid, content_index);
@ -1307,7 +1306,7 @@ void Module::Interface::CheckContentRightsIgnorePlatform(Kernel::HLERequestConte
FileUtil::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(has_rights);
LOG_WARNING(Service_AM, "(STUBBED) tid={:016x}, content_index={}", tid, content_index);
@ -1319,8 +1318,8 @@ void Module::Interface::BeginImportProgram(Kernel::HLERequestContext& ctx) {
if (am->cia_installing) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
return;
}
@ -1333,7 +1332,7 @@ void Module::Interface::BeginImportProgram(Kernel::HLERequestContext& ctx) {
am->cia_installing = true;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.PushCopyObjects(file->Connect());
LOG_WARNING(Service_AM, "(STUBBED) media_type={}", media_type);
@ -1344,8 +1343,8 @@ void Module::Interface::BeginImportProgramTemporarily(Kernel::HLERequestContext&
if (am->cia_installing) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::CIACurrentlyInstalling, ErrorModule::AM,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
return;
}
@ -1360,7 +1359,7 @@ void Module::Interface::BeginImportProgramTemporarily(Kernel::HLERequestContext&
am->cia_installing = true;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.PushCopyObjects(file->Connect());
LOG_WARNING(Service_AM, "(STUBBED)");
@ -1374,7 +1373,7 @@ void Module::Interface::EndImportProgram(Kernel::HLERequestContext& ctx) {
am->cia_installing = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::Interface::EndImportProgramWithoutCommit(Kernel::HLERequestContext& ctx) {
@ -1387,7 +1386,7 @@ void Module::Interface::EndImportProgramWithoutCommit(Kernel::HLERequestContext&
am->cia_installing = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::Interface::CommitImportPrograms(Kernel::HLERequestContext& ctx) {
@ -1402,7 +1401,7 @@ void Module::Interface::CommitImportPrograms(Kernel::HLERequestContext& ctx) {
am->ScanForAllTitles();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
}
@ -1445,14 +1444,14 @@ ResultVal<std::unique_ptr<AMFileWrapper>> GetFileFromSession(
if (file_session->parent == nullptr) {
LOG_WARNING(Service_AM, "Invalid file handle!");
return Kernel::ERR_INVALID_HANDLE;
return Kernel::ResultInvalidHandle;
}
std::shared_ptr<Kernel::ServerSession> server =
Kernel::SharedFrom(file_session->parent->server);
if (server == nullptr) {
LOG_WARNING(Service_AM, "File handle ServerSession disconnected!");
return Kernel::ERR_SESSION_CLOSED_BY_REMOTE;
return Kernel::ResultSessionClosed;
}
if (server->hle_handler != nullptr) {
@ -1468,13 +1467,13 @@ ResultVal<std::unique_ptr<AMFileWrapper>> GetFileFromSession(
}
LOG_ERROR(Service_AM, "Failed to cast handle to FSFile!");
return Kernel::ERR_INVALID_HANDLE;
return Kernel::ResultInvalidHandle;
}
// Probably the best bet if someone is LLEing the fs service is to just have them LLE AM
// while they're at it, so not implemented.
LOG_ERROR(Service_AM, "Given file handle does not have an HLE handler!");
return Kernel::ERR_NOT_IMPLEMENTED;
return Kernel::ResultNotImplemented;
}
void Module::Interface::GetProgramInfoFromCia(Kernel::HLERequestContext& ctx) {
@ -1492,8 +1491,8 @@ void Module::Interface::GetProgramInfoFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
return;
}
@ -1510,7 +1509,7 @@ void Module::Interface::GetProgramInfoFromCia(Kernel::HLERequestContext& ctx) {
title_info.type = tmd.GetTitleType();
IPC::RequestBuilder rb = rp.MakeBuilder(8, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<TitleInfo>(title_info);
}
@ -1533,8 +1532,8 @@ void Module::Interface::GetSystemMenuDataFromCia(Kernel::HLERequestContext& ctx)
FileSys::CIAContainer container;
if (container.Load(*file) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
rb.PushMappedBuffer(output_buffer);
return;
}
@ -1545,8 +1544,8 @@ void Module::Interface::GetSystemMenuDataFromCia(Kernel::HLERequestContext& ctx)
temp.size(), temp.data());
if (read_result.Failed() || *read_result != temp.size()) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
rb.PushMappedBuffer(output_buffer);
return;
}
@ -1554,7 +1553,7 @@ void Module::Interface::GetSystemMenuDataFromCia(Kernel::HLERequestContext& ctx)
output_buffer.Write(temp.data(), 0, temp.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(output_buffer);
}
@ -1572,8 +1571,8 @@ void Module::Interface::GetDependencyListFromCia(Kernel::HLERequestContext& ctx)
FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
return;
}
@ -1581,7 +1580,7 @@ void Module::Interface::GetDependencyListFromCia(Kernel::HLERequestContext& ctx)
std::memcpy(buffer.data(), container.GetDependencies().data(), buffer.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0);
}
@ -1599,13 +1598,13 @@ void Module::Interface::GetTransferSizeFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
return;
}
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(container.GetMetadataOffset());
}
@ -1623,13 +1622,13 @@ void Module::Interface::GetCoreVersionFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
return;
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(container.GetCoreVersion());
}
@ -1648,8 +1647,8 @@ void Module::Interface::GetRequiredSizeFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container;
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
return;
}
@ -1657,11 +1656,11 @@ void Module::Interface::GetRequiredSizeFromCia(Kernel::HLERequestContext& ctx) {
// on some mediatypes. Since this is more of a required install size we'll report
// what Citra needs, but it would be good to be more accurate here.
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(container.GetTitleMetadata().GetContentSizeByIndex(FileSys::TMDContentIndex::Main));
}
ResultCode UninstallProgram(const FS::MediaType media_type, const u64 title_id) {
Result UninstallProgram(const FS::MediaType media_type, const u64 title_id) {
// Use the content folder so we don't delete the user's save data.
const auto path = GetTitlePath(media_type, title_id) + "content/";
if (!FileUtil::Exists(path)) {
@ -1673,7 +1672,7 @@ ResultCode UninstallProgram(const FS::MediaType media_type, const u64 title_id)
return {ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState,
ErrorLevel::Permanent};
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void Module::Interface::DeleteProgram(Kernel::HLERequestContext& ctx) {
@ -1694,7 +1693,7 @@ void Module::Interface::GetSystemUpdaterMutex(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(am->system_updater_mutex);
}
@ -1713,13 +1712,13 @@ void Module::Interface::GetMetaSizeFromCia(Kernel::HLERequestContext& ctx) {
if (container.Load(*file_res.Unwrap()) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
return;
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(container.GetMetadataSize());
}
@ -1744,8 +1743,8 @@ void Module::Interface::GetMetaDataFromCia(Kernel::HLERequestContext& ctx) {
FileSys::CIAContainer container;
if (container.Load(*file) != Loader::ResultStatus::Success) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
rb.PushMappedBuffer(output_buffer);
return;
}
@ -1755,14 +1754,14 @@ void Module::Interface::GetMetaDataFromCia(Kernel::HLERequestContext& ctx) {
auto read_result = file->Read(container.GetMetadataOffset(), output_size, temp.data());
if (read_result.Failed() || *read_result != output_size) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidCIAHeader, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidCIAHeader, ErrorModule::AM, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent));
return;
}
output_buffer.Write(temp.data(), 0, output_size);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(output_buffer);
}
@ -1774,7 +1773,7 @@ void Module::Interface::BeginImportTicket(Kernel::HLERequestContext& ctx) {
FileSys::Path{});
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.PushCopyObjects(file->Connect());
LOG_WARNING(Service_AM, "(STUBBED) called");
@ -1785,7 +1784,7 @@ void Module::Interface::EndImportTicket(Kernel::HLERequestContext& ctx) {
[[maybe_unused]] const auto ticket = rp.PopObject<Kernel::ClientSession>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_AM, "(STUBBED) called");
}

View file

@ -84,8 +84,8 @@ public:
~CIAFile();
ResultVal<std::size_t> Read(u64 offset, std::size_t length, u8* buffer) const override;
ResultCode WriteTicket();
ResultCode WriteTitleMetadata();
Result WriteTicket();
Result WriteTitleMetadata();
ResultVal<std::size_t> WriteContentData(u64 offset, std::size_t length, const u8* buffer);
ResultVal<std::size_t> Write(u64 offset, std::size_t length, bool flush,
const u8* buffer) override;
@ -203,7 +203,7 @@ std::string GetMediaTitlePath(Service::FS::MediaType media_type);
* @param title_id the title ID to uninstall
* @return result of the uninstall operation
*/
ResultCode UninstallProgram(const FS::MediaType media_type, const u64 title_id);
Result UninstallProgram(const FS::MediaType media_type, const u64 title_id);
class Module final {
public:

View file

@ -261,7 +261,7 @@ void AppletManager::CancelAndSendParameter(const MessageParameter& parameter) {
}
}
ResultCode AppletManager::SendParameter(const MessageParameter& parameter) {
Result AppletManager::SendParameter(const MessageParameter& parameter) {
// A new parameter can not be sent if the previous one hasn't been consumed yet
if (next_parameter) {
LOG_WARNING(Service_APT, "Parameter from {:03X} to {:03X} blocked by pending parameter.",
@ -271,18 +271,18 @@ ResultCode AppletManager::SendParameter(const MessageParameter& parameter) {
}
CancelAndSendParameter(parameter);
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultVal<MessageParameter> AppletManager::GlanceParameter(AppletId app_id) {
if (!next_parameter) {
return ResultCode(ErrorDescription::NoData, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status);
return Result(ErrorDescription::NoData, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status);
}
if (next_parameter->destination_id != app_id) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
}
auto parameter = *next_parameter;
@ -348,8 +348,8 @@ ResultVal<AppletManager::InitializeResult> AppletManager::Initialize(AppletId ap
auto slot_data = GetAppletSlot(slot);
if (slot_data->registered) {
LOG_WARNING(Service_APT, "Applet attempted to register in occupied slot {:02X}", slot);
return ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet,
ErrorSummary::InvalidState, ErrorLevel::Status);
return Result(ErrorDescription::AlreadyExists, ErrorModule::Applet,
ErrorSummary::InvalidState, ErrorLevel::Status);
}
LOG_DEBUG(Service_APT, "Initializing applet with ID {:03X} and attributes {:08X}.", app_id,
@ -377,7 +377,7 @@ ResultVal<AppletManager::InitializeResult> AppletManager::Initialize(AppletId ap
return InitializeResult{slot_data->notification_event, slot_data->parameter_event};
}
ResultCode AppletManager::Enable(AppletAttributes attributes) {
Result AppletManager::Enable(AppletAttributes attributes) {
auto slot = GetAppletSlotFromAttributes(attributes);
if (slot == AppletSlot::Error) {
LOG_WARNING(Service_APT,
@ -406,10 +406,10 @@ ResultCode AppletManager::Enable(AppletAttributes attributes) {
delayed_parameter.reset();
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::Finalize(AppletId app_id) {
Result AppletManager::Finalize(AppletId app_id) {
auto slot = GetAppletSlotFromId(app_id);
if (slot == AppletSlot::Error) {
return {ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
@ -430,7 +430,7 @@ ResultCode AppletManager::Finalize(AppletId app_id) {
active_slot = GetAppletSlotFromPos(AppletPos::System);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
u32 AppletManager::CountRegisteredApplet() {
@ -446,14 +446,14 @@ bool AppletManager::IsRegistered(AppletId app_id) {
ResultVal<AppletAttributes> AppletManager::GetAttribute(AppletId app_id) {
auto slot = GetAppletSlotFromId(app_id);
if (slot == AppletSlot::Error) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
}
auto slot_data = GetAppletSlot(slot);
if (!slot_data->registered) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
}
return slot_data->attributes;
@ -470,17 +470,17 @@ ResultVal<Notification> AppletManager::InquireNotification(AppletId app_id) {
}
}
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
}
ResultCode AppletManager::SendNotification(Notification notification) {
Result AppletManager::SendNotification(Notification notification) {
if (active_slot != AppletSlot::Error) {
const auto slot_data = GetAppletSlot(active_slot);
if (slot_data->registered) {
slot_data->notification = notification;
slot_data->notification_event->Signal();
return RESULT_SUCCESS;
return ResultSuccess;
}
}
@ -497,7 +497,7 @@ void AppletManager::SendNotificationToAll(Notification notification) {
}
}
ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) {
Result AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) {
// The real APT service returns an error if there's a pending APT parameter when this function
// is called.
if (next_parameter) {
@ -519,14 +519,14 @@ ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) {
auto process =
NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id, cfg->GetRegionValue()));
if (process) {
return RESULT_SUCCESS;
return ResultSuccess;
}
// If we weren't able to load the native applet title, try to fallback to an HLE implementation.
auto applet = HLE::Applets::Applet::Get(applet_id);
if (applet) {
LOG_WARNING(Service_APT, "applet has already been started id={:03X}", applet_id);
return RESULT_SUCCESS;
return ResultSuccess;
} else {
auto parent = GetAppletSlotId(last_library_launcher_slot);
LOG_DEBUG(Service_APT, "Creating HLE applet {:03X} with parent {:03X}", applet_id, parent);
@ -534,7 +534,7 @@ ResultCode AppletManager::PrepareToStartLibraryApplet(AppletId applet_id) {
}
}
ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) {
Result AppletManager::PreloadLibraryApplet(AppletId applet_id) {
if (GetAppletSlot(AppletSlot::LibraryApplet)->registered) {
return {ErrorDescription::AlreadyExists, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status};
@ -547,14 +547,14 @@ ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) {
auto process =
NS::LaunchTitle(FS::MediaType::NAND, GetTitleIdForApplet(applet_id, cfg->GetRegionValue()));
if (process) {
return RESULT_SUCCESS;
return ResultSuccess;
}
// If we weren't able to load the native applet title, try to fallback to an HLE implementation.
auto applet = HLE::Applets::Applet::Get(applet_id);
if (applet) {
LOG_WARNING(Service_APT, "applet has already been started id={:08X}", applet_id);
return RESULT_SUCCESS;
return ResultSuccess;
} else {
auto parent = GetAppletSlotId(last_library_launcher_slot);
LOG_DEBUG(Service_APT, "Creating HLE applet {:03X} with parent {:03X}", applet_id, parent);
@ -562,15 +562,14 @@ ResultCode AppletManager::PreloadLibraryApplet(AppletId applet_id) {
}
}
ResultCode AppletManager::FinishPreloadingLibraryApplet(AppletId applet_id) {
Result AppletManager::FinishPreloadingLibraryApplet(AppletId applet_id) {
// TODO(Subv): This function should fail depending on the applet preparation state.
GetAppletSlot(AppletSlot::LibraryApplet)->loaded = true;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::StartLibraryApplet(AppletId applet_id,
std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
Result AppletManager::StartLibraryApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
active_slot = AppletSlot::LibraryApplet;
auto send_res = SendParameter({
@ -585,11 +584,10 @@ ResultCode AppletManager::StartLibraryApplet(AppletId applet_id,
return send_res;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiting,
bool jump_home) {
Result AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiting, bool jump_home) {
if (next_parameter) {
return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status};
@ -604,11 +602,11 @@ ResultCode AppletManager::PrepareToCloseLibraryApplet(bool not_pause, bool exiti
else
library_applet_closing_command = SignalType::WakeupByExit;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::CloseLibraryApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
Result AppletManager::CloseLibraryApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
auto slot = GetAppletSlot(AppletSlot::LibraryApplet);
auto destination_id = GetAppletSlotId(last_library_launcher_slot);
@ -630,10 +628,10 @@ ResultCode AppletManager::CloseLibraryApplet(std::shared_ptr<Kernel::Object> obj
SendParameter(param);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::CancelLibraryApplet(bool app_exiting) {
Result AppletManager::CancelLibraryApplet(bool app_exiting) {
if (next_parameter) {
return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status};
@ -652,8 +650,8 @@ ResultCode AppletManager::CancelLibraryApplet(bool app_exiting) {
});
}
ResultCode AppletManager::SendDspSleep(AppletId from_applet_id,
std::shared_ptr<Kernel::Object> object) {
Result AppletManager::SendDspSleep(AppletId from_applet_id,
std::shared_ptr<Kernel::Object> object) {
auto lib_slot = GetAppletSlotFromPos(AppletPos::Library);
auto lib_app_id =
lib_slot != AppletSlot::Error ? GetAppletSlot(lib_slot)->applet_id : AppletId::None;
@ -681,11 +679,11 @@ ResultCode AppletManager::SendDspSleep(AppletId from_applet_id,
});
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::SendDspWakeUp(AppletId from_applet_id,
std::shared_ptr<Kernel::Object> object) {
Result AppletManager::SendDspWakeUp(AppletId from_applet_id,
std::shared_ptr<Kernel::Object> object) {
auto lib_slot = GetAppletSlotFromPos(AppletPos::Library);
auto lib_app_id =
lib_slot != AppletSlot::Error ? GetAppletSlot(lib_slot)->applet_id : AppletId::None;
@ -714,10 +712,10 @@ ResultCode AppletManager::SendDspWakeUp(AppletId from_applet_id,
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::PrepareToStartSystemApplet(AppletId applet_id) {
Result AppletManager::PrepareToStartSystemApplet(AppletId applet_id) {
// The real APT service returns an error if there's a pending APT parameter when this function
// is called.
if (next_parameter) {
@ -726,12 +724,11 @@ ResultCode AppletManager::PrepareToStartSystemApplet(AppletId applet_id) {
}
last_system_launcher_slot = active_slot;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::StartSystemApplet(AppletId applet_id,
std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
Result AppletManager::StartSystemApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
auto source_applet_id = AppletId::None;
if (last_system_launcher_slot != AppletSlot::Error) {
const auto slot_data = GetAppletSlot(last_system_launcher_slot);
@ -769,20 +766,20 @@ ResultCode AppletManager::StartSystemApplet(AppletId applet_id,
.buffer = buffer,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::PrepareToCloseSystemApplet() {
Result AppletManager::PrepareToCloseSystemApplet() {
if (next_parameter) {
return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status};
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::CloseSystemApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
Result AppletManager::CloseSystemApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
ASSERT_MSG(active_slot == AppletSlot::HomeMenu || active_slot == AppletSlot::SystemApplet,
"Attempting to close a system applet from a non-system applet.");
@ -806,10 +803,10 @@ ResultCode AppletManager::CloseSystemApplet(std::shared_ptr<Kernel::Object> obje
}
// TODO: Terminate the running applet title
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::OrderToCloseSystemApplet() {
Result AppletManager::OrderToCloseSystemApplet() {
if (active_slot == AppletSlot::Error) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status};
@ -843,10 +840,10 @@ ResultCode AppletManager::OrderToCloseSystemApplet() {
.signal = SignalType::WakeupByCancel,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::PrepareToJumpToHomeMenu() {
Result AppletManager::PrepareToJumpToHomeMenu() {
if (next_parameter) {
return {ErrCodes::ParameterPresent, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status};
@ -860,11 +857,11 @@ ResultCode AppletManager::PrepareToJumpToHomeMenu() {
EnsureHomeMenuLoaded();
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::JumpToHomeMenu(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
Result AppletManager::JumpToHomeMenu(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
if (last_jump_to_home_slot != AppletSlot::Error) {
auto slot_data = GetAppletSlot(last_jump_to_home_slot);
if (slot_data->applet_id != AppletId::None) {
@ -910,10 +907,10 @@ ResultCode AppletManager::JumpToHomeMenu(std::shared_ptr<Kernel::Object> object,
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::PrepareToLeaveHomeMenu() {
Result AppletManager::PrepareToLeaveHomeMenu() {
if (!GetAppletSlot(AppletSlot::Application)->registered) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status};
@ -924,11 +921,11 @@ ResultCode AppletManager::PrepareToLeaveHomeMenu() {
ErrorLevel::Status};
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::LeaveHomeMenu(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
Result AppletManager::LeaveHomeMenu(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
active_slot = AppletSlot::Application;
SendParameter({
@ -939,10 +936,10 @@ ResultCode AppletManager::LeaveHomeMenu(std::shared_ptr<Kernel::Object> object,
.buffer = buffer,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::OrderToCloseApplication() {
Result AppletManager::OrderToCloseApplication() {
if (active_slot == AppletSlot::Error) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status};
@ -964,10 +961,10 @@ ResultCode AppletManager::OrderToCloseApplication() {
.signal = SignalType::WakeupByCancel,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::PrepareToCloseApplication(bool return_to_sys) {
Result AppletManager::PrepareToCloseApplication(bool return_to_sys) {
if (active_slot == AppletSlot::Error) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status};
@ -1015,11 +1012,11 @@ ResultCode AppletManager::PrepareToCloseApplication(bool return_to_sys) {
// EnsureHomeMenuLoaded();
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::CloseApplication(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
Result AppletManager::CloseApplication(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
ordered_to_close_application = false;
application_cancelled = false;
@ -1044,7 +1041,7 @@ ResultCode AppletManager::CloseApplication(std::shared_ptr<Kernel::Object> objec
}
// TODO: Terminate the application process.
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultVal<AppletManager::AppletManInfo> AppletManager::GetAppletManInfo(
@ -1079,14 +1076,14 @@ ResultVal<AppletManager::AppletManInfo> AppletManager::GetAppletManInfo(
ResultVal<AppletManager::AppletInfo> AppletManager::GetAppletInfo(AppletId app_id) {
auto slot = GetAppletSlotFromId(app_id);
if (slot == AppletSlot::Error) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
}
auto slot_data = GetAppletSlot(slot);
if (!slot_data->registered) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
ErrorLevel::Status);
}
auto media_type = Service::AM::GetTitleMediaType(slot_data->title_id);
@ -1102,14 +1099,13 @@ ResultVal<AppletManager::AppletInfo> AppletManager::GetAppletInfo(AppletId app_i
ResultVal<Service::FS::MediaType> AppletManager::Unknown54(u32 in_param) {
auto slot_data = GetAppletSlot(AppletSlot::Application);
if (slot_data->applet_id == AppletId::None) {
return ResultCode{ErrCodes::AppNotRunning, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Permanent};
return Result{ErrCodes::AppNotRunning, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Permanent};
}
if (in_param >= 0x80) {
// TODO: Add error description name when the parameter is known.
return ResultCode{10, ErrorModule::Applet, ErrorSummary::InvalidArgument,
ErrorLevel::Usage};
return Result{10, ErrorModule::Applet, ErrorSummary::InvalidArgument, ErrorLevel::Usage};
}
// TODO: Figure out what this logic is actually for.
@ -1154,8 +1150,8 @@ ApplicationRunningMode AppletManager::GetApplicationRunningMode() {
}
}
ResultCode AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type,
ApplicationJumpFlags flags) {
Result AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type,
ApplicationJumpFlags flags) {
// A running application can not launch another application directly because the applet state
// for the Application slot is already in use. The way this is implemented in hardware is to
// launch the Home Menu and tell it to launch our desired application.
@ -1180,10 +1176,10 @@ ResultCode AppletManager::PrepareToDoApplicationJump(u64 title_id, FS::MediaType
// Note: The real console uses the Home Menu to perform the application jump, therefore the menu
// needs to be running. The real APT module starts the Home Menu here if it's not already
// running, we don't have to do this. See `EnsureHomeMenuLoaded` for launching the Home Menu.
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::DoApplicationJump(const DeliverArg& arg) {
Result AppletManager::DoApplicationJump(const DeliverArg& arg) {
// Note: The real console uses the Home Menu to perform the application jump, it goes
// OldApplication->Home Menu->NewApplication. We do not need to use the Home Menu to do this so
// we launch the new application directly. In the real APT service, the Home Menu must be
@ -1212,7 +1208,7 @@ ResultCode AppletManager::DoApplicationJump(const DeliverArg& arg) {
});
// TODO: APT terminates the application here, usually it will exit itself properly though.
return RESULT_SUCCESS;
return ResultSuccess;
} else {
// Otherwise, work around the missing home menu by launching the title directly.
@ -1227,16 +1223,16 @@ ResultCode AppletManager::DoApplicationJump(const DeliverArg& arg) {
LOG_CRITICAL(Service_APT, "Failed to launch title during application jump, exiting.");
system.RequestShutdown();
}
return RESULT_SUCCESS;
return ResultSuccess;
*/
NS::RebootToTitle(system, app_jump_parameters.next_media_type,
app_jump_parameters.next_title_id);
return RESULT_SUCCESS;
return ResultSuccess;
}
}
ResultCode AppletManager::PrepareToStartApplication(u64 title_id, FS::MediaType media_type) {
Result AppletManager::PrepareToStartApplication(u64 title_id, FS::MediaType media_type) {
if (active_slot == AppletSlot::Error ||
GetAppletSlot(active_slot)->attributes.applet_pos != AppletPos::System) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
@ -1259,11 +1255,11 @@ ResultCode AppletManager::PrepareToStartApplication(u64 title_id, FS::MediaType
capture_buffer_info.reset();
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::StartApplication(const std::vector<u8>& parameter,
const std::vector<u8>& hmac, bool paused) {
Result AppletManager::StartApplication(const std::vector<u8>& parameter,
const std::vector<u8>& hmac, bool paused) {
// The delivery argument is always unconditionally set.
deliver_arg.emplace(DeliverArg{parameter, hmac});
@ -1295,11 +1291,11 @@ ResultCode AppletManager::StartApplication(const std::vector<u8>& parameter,
return WakeupApplication(nullptr, {});
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::WakeupApplication(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
Result AppletManager::WakeupApplication(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer) {
// Send a Wakeup signal via the apt parameter to the application once it registers itself.
// The real APT service does this by spin waiting on another thread until the application is
// registered.
@ -1311,10 +1307,10 @@ ResultCode AppletManager::WakeupApplication(std::shared_ptr<Kernel::Object> obje
.buffer = buffer,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode AppletManager::CancelApplication() {
Result AppletManager::CancelApplication() {
auto application_slot_data = GetAppletSlot(AppletSlot::Application);
if (application_slot_data->applet_id == AppletId::None) {
return {ErrCodes::InvalidAppletSlot, ErrorModule::Applet, ErrorSummary::InvalidState,
@ -1330,7 +1326,7 @@ ResultCode AppletManager::CancelApplication() {
.signal = SignalType::WakeupByCancel,
});
return RESULT_SUCCESS;
return ResultSuccess;
}
void AppletManager::SendApplicationParameterAfterRegistration(const MessageParameter& parameter) {

View file

@ -264,7 +264,7 @@ public:
*/
void CancelAndSendParameter(const MessageParameter& parameter);
ResultCode SendParameter(const MessageParameter& parameter);
Result SendParameter(const MessageParameter& parameter);
ResultVal<MessageParameter> GlanceParameter(AppletId app_id);
ResultVal<MessageParameter> ReceiveParameter(AppletId app_id);
bool CancelParameter(bool check_sender, AppletId sender_appid, bool check_receiver,
@ -283,51 +283,48 @@ public:
};
ResultVal<InitializeResult> Initialize(AppletId app_id, AppletAttributes attributes);
ResultCode Enable(AppletAttributes attributes);
ResultCode Finalize(AppletId app_id);
Result Enable(AppletAttributes attributes);
Result Finalize(AppletId app_id);
u32 CountRegisteredApplet();
bool IsRegistered(AppletId app_id);
ResultVal<AppletAttributes> GetAttribute(AppletId app_id);
ResultVal<Notification> InquireNotification(AppletId app_id);
ResultCode SendNotification(Notification notification);
Result SendNotification(Notification notification);
void SendNotificationToAll(Notification notification);
ResultCode PrepareToStartLibraryApplet(AppletId applet_id);
ResultCode PreloadLibraryApplet(AppletId applet_id);
ResultCode FinishPreloadingLibraryApplet(AppletId applet_id);
ResultCode StartLibraryApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode PrepareToCloseLibraryApplet(bool not_pause, bool exiting, bool jump_home);
ResultCode CloseLibraryApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode CancelLibraryApplet(bool app_exiting);
ResultCode SendDspSleep(AppletId from_applet_id, std::shared_ptr<Kernel::Object> object);
ResultCode SendDspWakeUp(AppletId from_applet_id, std::shared_ptr<Kernel::Object> object);
ResultCode PrepareToStartSystemApplet(AppletId applet_id);
ResultCode StartSystemApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode PrepareToCloseSystemApplet();
ResultCode CloseSystemApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode OrderToCloseSystemApplet();
ResultCode PrepareToJumpToHomeMenu();
ResultCode JumpToHomeMenu(std::shared_ptr<Kernel::Object> object,
Result PrepareToStartLibraryApplet(AppletId applet_id);
Result PreloadLibraryApplet(AppletId applet_id);
Result FinishPreloadingLibraryApplet(AppletId applet_id);
Result StartLibraryApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode PrepareToLeaveHomeMenu();
ResultCode LeaveHomeMenu(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result PrepareToCloseLibraryApplet(bool not_pause, bool exiting, bool jump_home);
Result CloseLibraryApplet(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
Result CancelLibraryApplet(bool app_exiting);
ResultCode OrderToCloseApplication();
ResultCode PrepareToCloseApplication(bool return_to_sys);
ResultCode CloseApplication(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
Result SendDspSleep(AppletId from_applet_id, std::shared_ptr<Kernel::Object> object);
Result SendDspWakeUp(AppletId from_applet_id, std::shared_ptr<Kernel::Object> object);
ResultCode PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type,
ApplicationJumpFlags flags);
ResultCode DoApplicationJump(const DeliverArg& arg);
Result PrepareToStartSystemApplet(AppletId applet_id);
Result StartSystemApplet(AppletId applet_id, std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
Result PrepareToCloseSystemApplet();
Result CloseSystemApplet(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result OrderToCloseSystemApplet();
Result PrepareToJumpToHomeMenu();
Result JumpToHomeMenu(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result PrepareToLeaveHomeMenu();
Result LeaveHomeMenu(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result OrderToCloseApplication();
Result PrepareToCloseApplication(bool return_to_sys);
Result CloseApplication(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result PrepareToDoApplicationJump(u64 title_id, FS::MediaType media_type,
ApplicationJumpFlags flags);
Result DoApplicationJump(const DeliverArg& arg);
boost::optional<DeliverArg> ReceiveDeliverArg() {
auto arg = deliver_arg;
@ -369,12 +366,11 @@ public:
std::memcpy(&capture_buffer_info.get(), buffer.data(), sizeof(CaptureBufferInfo));
}
ResultCode PrepareToStartApplication(u64 title_id, FS::MediaType media_type);
ResultCode StartApplication(const std::vector<u8>& parameter, const std::vector<u8>& hmac,
bool paused);
ResultCode WakeupApplication(std::shared_ptr<Kernel::Object> object,
const std::vector<u8>& buffer);
ResultCode CancelApplication();
Result PrepareToStartApplication(u64 title_id, FS::MediaType media_type);
Result StartApplication(const std::vector<u8>& parameter, const std::vector<u8>& hmac,
bool paused);
Result WakeupApplication(std::shared_ptr<Kernel::Object> object, const std::vector<u8>& buffer);
Result CancelApplication();
struct AppletManInfo {
AppletPos active_applet_pos;

View file

@ -70,7 +70,7 @@ void Module::NSInterface::SetWirelessRebootInfo(Kernel::HLERequestContext& ctx)
apt->wireless_reboot_info = std::move(buffer);
auto rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_APT, "called size={}", size);
}
@ -83,7 +83,7 @@ void Module::NSInterface::ShutdownAsync(Kernel::HLERequestContext& ctx) {
apt->system.RequestShutdown();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::NSInterface::RebootSystem(Kernel::HLERequestContext& ctx) {
@ -107,7 +107,7 @@ void Module::NSInterface::RebootSystem(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::NSInterface::RebootSystemClean(Kernel::HLERequestContext& ctx) {
@ -118,7 +118,7 @@ void Module::NSInterface::RebootSystemClean(Kernel::HLERequestContext& ctx) {
apt->system.RequestReset();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::APTInterface::Initialize(Kernel::HLERequestContext& ctx) {
@ -134,7 +134,7 @@ void Module::APTInterface::Initialize(Kernel::HLERequestContext& ctx) {
rb.Push(result.Code());
} else {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 3);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(result->notification_event, result->parameter_event);
}
}
@ -314,7 +314,7 @@ void Module::APTInterface::GetSharedFont(Kernel::HLERequestContext& ctx) {
apt->shared_font_relocated = true;
}
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
// Since the SharedMemory interface doesn't provide the address at which the memory was
// allocated, the real APT service calculates this address by scanning the entire address space
// (using svcQueryMemory) and searches for an allocation of the same size as the Shared Font.
@ -329,7 +329,7 @@ void Module::APTInterface::GetWirelessRebootInfo(Kernel::HLERequestContext& ctx)
LOG_WARNING(Service_APT, "called size={:08X}", size);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(apt->wireless_reboot_info, 0);
}
@ -338,7 +338,7 @@ void Module::APTInterface::NotifyToWait(Kernel::HLERequestContext& ctx) {
const auto app_id = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
LOG_WARNING(Service_APT, "(STUBBED) app_id={}", app_id);
}
@ -359,7 +359,7 @@ void Module::APTInterface::GetLockHandle(Kernel::HLERequestContext& ctx) {
rb.Push(result.Code());
} else {
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(result->corrected_attributes);
rb.Push<u32>(result->state);
rb.PushCopyObjects(result->lock);
@ -398,7 +398,7 @@ void Module::APTInterface::GetAppletManInfo(Kernel::HLERequestContext& ctx) {
rb.Push(info.Code());
} else {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(info->active_applet_pos);
rb.PushEnum(info->requested_applet_id);
rb.PushEnum(info->home_menu_applet_id);
@ -412,7 +412,7 @@ void Module::APTInterface::CountRegisteredApplet(Kernel::HLERequestContext& ctx)
LOG_DEBUG(Service_APT, "called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(apt->applet_manager->CountRegisteredApplet());
}
@ -421,7 +421,7 @@ void Module::APTInterface::IsRegistered(Kernel::HLERequestContext& ctx) {
const auto app_id = rp.PopEnum<AppletId>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(apt->applet_manager->IsRegistered(app_id));
LOG_DEBUG(Service_APT, "called app_id={:#010X}", app_id);
@ -439,7 +439,7 @@ void Module::APTInterface::GetAttribute(Kernel::HLERequestContext& ctx) {
rb.Push(applet_attr.Code());
} else {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(applet_attr.Unwrap().raw);
}
}
@ -456,7 +456,7 @@ void Module::APTInterface::InquireNotification(Kernel::HLERequestContext& ctx) {
rb.Push(notification.Code());
} else {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(static_cast<u32>(notification.Unwrap()));
}
}
@ -502,7 +502,7 @@ void Module::APTInterface::ReceiveParameter(Kernel::HLERequestContext& ctx) {
buffer_size); // APT always push a buffer with the maximum size
IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.PushEnum(next_parameter->sender_id);
rb.PushEnum(next_parameter->signal); // Signal type
rb.Push(size); // Parameter buffer size
@ -528,7 +528,7 @@ void Module::APTInterface::GlanceParameter(Kernel::HLERequestContext& ctx) {
buffer_size); // APT always push a buffer with the maximum size
IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.PushEnum(next_parameter->sender_id);
rb.PushEnum(next_parameter->signal); // Signal type
rb.Push(size); // Parameter buffer size
@ -550,7 +550,7 @@ void Module::APTInterface::CancelParameter(Kernel::HLERequestContext& ctx) {
check_sender, sender_appid, check_receiver, receiver_appid);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(apt->applet_manager->CancelParameter(check_sender, sender_appid, check_receiver,
receiver_appid));
}
@ -564,7 +564,7 @@ void Module::APTInterface::PrepareToDoApplicationJump(Kernel::HLERequestContext&
LOG_INFO(Service_APT, "called title_id={:016X}, media_type={:#01X}, flags={:#08X}", title_id,
media_type, flags);
ResultCode result = apt->applet_manager->PrepareToDoApplicationJump(
Result result = apt->applet_manager->PrepareToDoApplicationJump(
title_id, static_cast<FS::MediaType>(media_type), flags);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
@ -592,7 +592,7 @@ void Module::APTInterface::GetProgramIdOnApplicationJump(Kernel::HLERequestConte
const auto parameters = apt->applet_manager->GetApplicationJumpParameters();
IPC::RequestBuilder rb = rp.MakeBuilder(7, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u64>(parameters.current_title_id);
rb.Push(static_cast<u8>(parameters.current_media_type));
rb.Push<u64>(parameters.next_title_id);
@ -611,7 +611,7 @@ void Module::APTInterface::SendDeliverArg(Kernel::HLERequestContext& ctx) {
apt->applet_manager->SetDeliverArg(DeliverArg{param, hmac});
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::APTInterface::ReceiveDeliverArg(Kernel::HLERequestContext& ctx) {
@ -626,7 +626,7 @@ void Module::APTInterface::ReceiveDeliverArg(Kernel::HLERequestContext& ctx) {
arg.hmac.resize(std::min<std::size_t>(hmac_size, 0x20));
IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(arg.source_program_id);
rb.Push<u8>(1);
rb.PushStaticBuffer(std::move(arg.param), 0);
@ -702,8 +702,8 @@ void Module::APTInterface::AppletUtility(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(RESULT_SUCCESS); // Utility function result
rb.Push(ResultSuccess); // No error
rb.Push(ResultSuccess); // Utility function result
rb.PushStaticBuffer(out, 0);
}
@ -720,7 +720,7 @@ void Module::APTInterface::SetAppCpuTimeLimit(Kernel::HLERequestContext& ctx) {
apt->cpu_percent = value;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
}
void Module::APTInterface::GetAppCpuTimeLimit(Kernel::HLERequestContext& ctx) {
@ -733,7 +733,7 @@ void Module::APTInterface::GetAppCpuTimeLimit(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(apt->cpu_percent);
}
@ -767,8 +767,8 @@ void Module::APTInterface::PrepareToStartNewestHomeMenu(Kernel::HLERequestContex
// This command must return an error when called, otherwise the Home Menu will try to reboot the
// system.
rb.Push(ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet,
ErrorSummary::InvalidState, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::AlreadyExists, ErrorModule::Applet, ErrorSummary::InvalidState,
ErrorLevel::Status));
}
void Module::APTInterface::PreloadLibraryApplet(Kernel::HLERequestContext& ctx) {
@ -944,7 +944,7 @@ void Module::APTInterface::ReplySleepQuery(Kernel::HLERequestContext& ctx) {
from_app_id, reply_value);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::APTInterface::ReplySleepNotificationComplete(Kernel::HLERequestContext& ctx) {
@ -954,7 +954,7 @@ void Module::APTInterface::ReplySleepNotificationComplete(Kernel::HLERequestCont
LOG_WARNING(Service_APT, "(STUBBED) called, from_app_id={:08X}", from_app_id);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::APTInterface::PrepareToJumpToHomeMenu(Kernel::HLERequestContext& ctx) {
@ -1010,7 +1010,7 @@ void Module::APTInterface::LoadSysMenuArg(Kernel::HLERequestContext& ctx) {
std::copy_n(apt->sys_menu_arg_buffer.cbegin(), size, buffer.begin());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0);
}
@ -1025,7 +1025,7 @@ void Module::APTInterface::StoreSysMenuArg(Kernel::HLERequestContext& ctx) {
std::copy_n(buffer.cbegin(), size, apt->sys_menu_arg_buffer.begin());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::APTInterface::SendCaptureBufferInfo(Kernel::HLERequestContext& ctx) {
@ -1038,7 +1038,7 @@ void Module::APTInterface::SendCaptureBufferInfo(Kernel::HLERequestContext& ctx)
apt->applet_manager->SendCaptureBufferInfo(buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::APTInterface::ReceiveCaptureBufferInfo(Kernel::HLERequestContext& ctx) {
@ -1052,7 +1052,7 @@ void Module::APTInterface::ReceiveCaptureBufferInfo(Kernel::HLERequestContext& c
screen_capture_buffer.resize(size);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(real_size);
rb.PushStaticBuffer(std::move(screen_capture_buffer), 0);
}
@ -1068,7 +1068,7 @@ void Module::APTInterface::GetCaptureInfo(Kernel::HLERequestContext& ctx) {
screen_capture_buffer.resize(size);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(real_size);
rb.PushStaticBuffer(std::move(screen_capture_buffer), 0);
}
@ -1085,7 +1085,7 @@ void Module::APTInterface::Unknown54(Kernel::HLERequestContext& ctx) {
rb.Push(media_type.Code());
} else {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(media_type.Unwrap());
}
}
@ -1099,7 +1099,7 @@ void Module::APTInterface::SetScreenCapturePostPermission(Kernel::HLERequestCont
apt->screen_capture_post_permission = static_cast<ScreencapPostPermission>(permission & 0xF);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
}
void Module::APTInterface::GetScreenCapturePostPermission(Kernel::HLERequestContext& ctx) {
@ -1108,7 +1108,7 @@ void Module::APTInterface::GetScreenCapturePostPermission(Kernel::HLERequestCont
LOG_DEBUG(Service_APT, "called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS); // No error
rb.Push(ResultSuccess); // No error
rb.Push(static_cast<u32>(apt->screen_capture_post_permission));
}
@ -1131,7 +1131,7 @@ void Module::APTInterface::GetProgramId(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_APT, "called process_id={}", process_id);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
auto fs_user =
Core::System::GetInstance().ServiceManager().GetService<Service::FS::FS_USER>("fs:USER");
@ -1161,7 +1161,7 @@ void Module::APTInterface::GetProgramInfo(Kernel::HLERequestContext& ctx) {
// TODO: Proper error code
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN);
rb.Push(ResultUnknown);
return;
}
@ -1171,7 +1171,7 @@ void Module::APTInterface::GetProgramInfo(Kernel::HLERequestContext& ctx) {
// TODO: Proper error code
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN);
rb.Push(ResultUnknown);
return;
}
@ -1181,12 +1181,12 @@ void Module::APTInterface::GetProgramInfo(Kernel::HLERequestContext& ctx) {
// TODO: Proper error code
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN);
rb.Push(ResultUnknown);
return;
}
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(static_cast<u8>(memory_mode.first.value()));
rb.Push(core_version.first.value());
}
@ -1203,7 +1203,7 @@ void Module::APTInterface::GetAppletInfo(Kernel::HLERequestContext& ctx) {
rb.Push(info.Code());
} else {
IPC::RequestBuilder rb = rp.MakeBuilder(7, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(info->title_id);
rb.Push(static_cast<u8>(info->media_type));
rb.Push(info->registered);
@ -1248,7 +1248,7 @@ void Module::APTInterface::GetStartupArgument(Kernel::HLERequestContext& ctx) {
param.resize(std::min(parameter_size, max_parameter_size));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(exists);
rb.PushStaticBuffer(std::move(param), 0);
}
@ -1292,7 +1292,7 @@ void Module::APTInterface::Wrap(Kernel::HLERequestContext& ctx) {
output.Write(cipher.data(), nonce_size, cipher.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
// Unmap buffer
rb.PushMappedBuffer(input);
rb.PushMappedBuffer(output);
@ -1338,11 +1338,11 @@ void Module::APTInterface::Unwrap(Kernel::HLERequestContext& ctx) {
output.Write(nonce.data(), nonce_offset, nonce_size);
output.Write(pdata.data() + nonce_offset, nonce_offset + nonce_size,
pdata.size() - nonce_offset);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_APT, "Failed to decrypt data");
rb.Push(ResultCode(static_cast<ErrorDescription>(1), ErrorModule::PS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
rb.Push(Result(static_cast<ErrorDescription>(1), ErrorModule::PS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
}
// Unmap buffer
@ -1366,7 +1366,7 @@ void Module::APTInterface::Reboot(Kernel::HLERequestContext& ctx) {
NS::RebootToTitle(apt->system, media_type, title_id);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::APTInterface::HardwareResetAsync(Kernel::HLERequestContext& ctx) {
@ -1377,7 +1377,7 @@ void Module::APTInterface::HardwareResetAsync(Kernel::HLERequestContext& ctx) {
apt->system.RequestReset();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::APTInterface::GetTargetPlatform(Kernel::HLERequestContext& ctx) {
@ -1386,7 +1386,7 @@ void Module::APTInterface::GetTargetPlatform(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_APT, "called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(apt->applet_manager->GetTargetPlatform());
}
@ -1405,7 +1405,7 @@ void Module::APTInterface::GetApplicationRunningMode(Kernel::HLERequestContext&
LOG_DEBUG(Service_APT, "called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(apt->applet_manager->GetApplicationRunningMode());
}
@ -1425,7 +1425,7 @@ void Module::APTInterface::IsStandardMemoryLayout(Kernel::HLERequestContext& ctx
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(is_standard);
}
@ -1439,7 +1439,7 @@ void Module::APTInterface::IsTitleAllowed(Kernel::HLERequestContext& ctx) {
// We allow all titles to be launched, so this function is a no-op
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(true);
}

View file

@ -43,7 +43,7 @@ std::shared_ptr<OnlineService> Module::Interface::GetSessionService(
// TODO: Error code for uninitialized session.
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN);
rb.Push(ResultUnknown);
return nullptr;
}
return session_data->online_service;
@ -80,7 +80,7 @@ void Module::Interface::SetStorageInfo(Kernel::HLERequestContext& ctx) {
const u8 extdata_type = rp.Pop<u8>(); /// 0 = NAND, 1 = SD
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS,
"(STUBBED) extdata_id={:#018x}, boss_size={:#010x}, extdata_type={:#04x}",
@ -91,7 +91,7 @@ void Module::Interface::UnregisterStorage(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) called");
}
@ -100,7 +100,7 @@ void Module::Interface::GetStorageInfo(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0);
LOG_WARNING(Service_BOSS, "(STUBBED) called");
@ -112,7 +112,7 @@ void Module::Interface::RegisterPrivateRootCa(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED)");
@ -126,7 +126,7 @@ void Module::Interface::RegisterPrivateClientCert(Kernel::HLERequestContext& ctx
auto& buffer2 = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer1);
rb.PushMappedBuffer(buffer2);
@ -138,7 +138,7 @@ void Module::Interface::GetNewArrivalFlag(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(boss->new_arrival_flag);
LOG_WARNING(Service_BOSS, "(STUBBED) new_arrival_flag={}", boss->new_arrival_flag);
@ -149,7 +149,7 @@ void Module::Interface::RegisterNewArrivalEvent(Kernel::HLERequestContext& ctx)
[[maybe_unused]] const auto event = rp.PopObject<Kernel::Event>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED)");
}
@ -159,7 +159,7 @@ void Module::Interface::SetOptoutFlag(Kernel::HLERequestContext& ctx) {
boss->output_flag = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "output_flag={}", boss->output_flag);
}
@ -168,7 +168,7 @@ void Module::Interface::GetOptoutFlag(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(boss->output_flag);
LOG_WARNING(Service_BOSS, "output_flag={}", boss->output_flag);
@ -188,7 +188,7 @@ void Module::Interface::RegisterTask(Kernel::HLERequestContext& ctx) {
online_service->RegisterTask(size, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_DEBUG(Service_BOSS, "called, size={:#010x}, unk_param2={:#04x}, unk_param3={:#04x}", size,
@ -221,7 +221,7 @@ void Module::Interface::ReconfigureTask(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#04x}", size, unk_param2);
@ -237,7 +237,7 @@ void Module::Interface::GetTaskIdList(Kernel::HLERequestContext& ctx) {
online_service->GetTaskIdList();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_BOSS, "called");
}
@ -248,7 +248,7 @@ void Module::Interface::GetStepIdList(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -269,7 +269,7 @@ void Module::Interface::GetNsDataIdList(Kernel::HLERequestContext& ctx) {
const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(entries_count); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer);
@ -295,7 +295,7 @@ void Module::Interface::GetNsDataIdList1(Kernel::HLERequestContext& ctx) {
const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(entries_count); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer);
@ -321,7 +321,7 @@ void Module::Interface::GetNsDataIdList2(Kernel::HLERequestContext& ctx) {
const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(entries_count); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer);
@ -347,7 +347,7 @@ void Module::Interface::GetNsDataIdList3(Kernel::HLERequestContext& ctx) {
const u16 entries_count = online_service->GetNsDataIdList(filter, max_entries, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(entries_count); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer);
@ -383,7 +383,7 @@ void Module::Interface::SendPropertyHandle(Kernel::HLERequestContext& ctx) {
[[maybe_unused]] const std::shared_ptr<Kernel::Object> object = rp.PopGenericObject();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) property_id={:#06x}", property_id);
}
@ -415,7 +415,7 @@ void Module::Interface::UpdateTaskInterval(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#06x}", size, unk_param2);
@ -431,7 +431,7 @@ void Module::Interface::UpdateTaskCount(Kernel::HLERequestContext& ctx) {
buffer.Read(task_id.data(), 0, size);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#010x}, task_id={}", size,
@ -444,7 +444,7 @@ void Module::Interface::GetTaskInterval(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 ( 32bit value)
rb.PushMappedBuffer(buffer);
@ -460,7 +460,7 @@ void Module::Interface::GetTaskCount(Kernel::HLERequestContext& ctx) {
buffer.Read(task_id.data(), 0, size);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 ( 32bit value)
rb.PushMappedBuffer(buffer);
@ -477,7 +477,7 @@ void Module::Interface::GetTaskServiceStatus(Kernel::HLERequestContext& ctx) {
constexpr u8 task_service_status = 1;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(task_service_status);
rb.PushMappedBuffer(buffer);
@ -490,7 +490,7 @@ void Module::Interface::StartTask(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -502,7 +502,7 @@ void Module::Interface::StartTaskImmediate(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -514,7 +514,7 @@ void Module::Interface::CancelTask(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -524,7 +524,7 @@ void Module::Interface::GetTaskFinishHandle(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects<Kernel::Event>(boss->task_finish_event);
LOG_WARNING(Service_BOSS, "(STUBBED) called");
@ -537,7 +537,7 @@ void Module::Interface::GetTaskState(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(4, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(0); /// TaskStatus
rb.Push<u32>(0); /// Current state value for task PropertyID 0x4
rb.Push<u8>(0); /// unknown, usually 0
@ -552,7 +552,7 @@ void Module::Interface::GetTaskResult(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(4, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(0); // stub 0 (8 bit value)
rb.Push<u32>(0); // stub 0 (32 bit value)
rb.Push<u8>(0); // stub 0 (8 bit value)
@ -567,7 +567,7 @@ void Module::Interface::GetTaskCommErrorCode(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(4, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 (32 bit value)
rb.Push<u32>(0); // stub 0 (32 bit value)
rb.Push<u8>(0); // stub 0 (8 bit value)
@ -584,7 +584,7 @@ void Module::Interface::GetTaskStatus(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(0); // stub 0 (8 bit value)
rb.PushMappedBuffer(buffer);
@ -599,7 +599,7 @@ void Module::Interface::GetTaskError(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(0); // stub 0 (8 bit value)
rb.PushMappedBuffer(buffer);
@ -613,7 +613,7 @@ void Module::Interface::GetTaskInfo(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#04x}", size, unk_param2);
@ -624,7 +624,7 @@ void Module::Interface::DeleteNsData(Kernel::HLERequestContext& ctx) {
const u32 ns_data_id = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) ns_data_id={:#010x}", ns_data_id);
}
@ -684,7 +684,7 @@ void Module::Interface::SetNsDataAdditionalInfo(Kernel::HLERequestContext& ctx)
const u32 unk_param2 = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}, unk_param2={:#010x}", unk_param1,
unk_param2);
@ -695,7 +695,7 @@ void Module::Interface::GetNsDataAdditionalInfo(Kernel::HLERequestContext& ctx)
const u32 unk_param1 = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 (32bit value)
LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}", unk_param1);
@ -707,7 +707,7 @@ void Module::Interface::SetNsDataNewFlag(Kernel::HLERequestContext& ctx) {
boss->ns_data_new_flag = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}, ns_data_new_flag={:#04x}", unk_param1,
boss->ns_data_new_flag);
@ -718,7 +718,7 @@ void Module::Interface::GetNsDataNewFlag(Kernel::HLERequestContext& ctx) {
const u32 unk_param1 = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(boss->ns_data_new_flag);
LOG_WARNING(Service_BOSS, "(STUBBED) unk_param1={:#010x}, ns_data_new_flag={:#04x}", unk_param1,
@ -738,12 +738,12 @@ void Module::Interface::GetNsDataLastUpdate(Kernel::HLERequestContext& ctx) {
if (!entry.has_value()) {
// TODO: Proper error code.
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_UNKNOWN);
rb.Push(ResultUnknown);
return;
}
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0);
rb.Push<u32>(entry->header.download_date); // return the download date from the ns data
@ -755,7 +755,7 @@ void Module::Interface::GetErrorCode(Kernel::HLERequestContext& ctx) {
const u8 input = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); /// output value
LOG_WARNING(Service_BOSS, "(STUBBED) input={:#010x}", input);
@ -770,7 +770,7 @@ void Module::Interface::RegisterStorageEntry(Kernel::HLERequestContext& ctx) {
const u8 unk_param5 = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS,
"(STUBBED) unk_param1={:#010x}, unk_param2={:#010x}, unk_param3={:#010x}, "
@ -782,7 +782,7 @@ void Module::Interface::GetStorageEntryInfo(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 (32bit value)
rb.Push<u16>(0); // stub 0 (16bit value)
@ -797,7 +797,7 @@ void Module::Interface::SetStorageOption(Kernel::HLERequestContext& ctx) {
const u16 unk_param4 = rp.Pop<u16>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS,
"(STUBBED) unk_param1={:#04x}, unk_param2={:#010x}, "
@ -809,7 +809,7 @@ void Module::Interface::GetStorageOption(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // stub 0 (32bit value)
rb.Push<u8>(0); // stub 0 (8bit value)
rb.Push<u16>(0); // stub 0 (16bit value)
@ -824,7 +824,7 @@ void Module::Interface::StartBgImmediate(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}", size);
@ -836,7 +836,7 @@ void Module::Interface::GetTaskProperty0(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(0); /// current state of PropertyID 0x0 stub 0 (8bit value)
rb.PushMappedBuffer(buffer);
@ -851,7 +851,7 @@ void Module::Interface::RegisterImmediateTask(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) size={:#010x}, unk_param2={:#04x}, unk_param3={:#04x}",
@ -866,7 +866,7 @@ void Module::Interface::SetTaskQuery(Kernel::HLERequestContext& ctx) {
auto& buffer2 = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer1);
rb.PushMappedBuffer(buffer2);
@ -882,7 +882,7 @@ void Module::Interface::GetTaskQuery(Kernel::HLERequestContext& ctx) {
auto& buffer2 = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer1);
rb.PushMappedBuffer(buffer2);
@ -896,7 +896,7 @@ void Module::Interface::InitializeSessionPrivileged(Kernel::HLERequestContext& c
rp.PopPID();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) programID={:#018x}", programID);
}
@ -906,7 +906,7 @@ void Module::Interface::GetAppNewFlag(Kernel::HLERequestContext& ctx) {
const u64 programID = rp.Pop<u64>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(0); // 0 = nothing new, 1 = new content
LOG_WARNING(Service_BOSS, "(STUBBED) programID={:#018x}", programID);
@ -922,7 +922,7 @@ void Module::Interface::GetNsDataIdListPrivileged(Kernel::HLERequestContext& ctx
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(0); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer);
@ -943,7 +943,7 @@ void Module::Interface::GetNsDataIdListPrivileged1(Kernel::HLERequestContext& ct
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(0); /// Actual number of output entries
rb.Push<u16>(0); /// Last word-index copied to output in the internal NsDataId list.
rb.PushMappedBuffer(buffer);
@ -961,7 +961,7 @@ void Module::Interface::SendPropertyPrivileged(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS, "(STUBBED) property_id={:#06x}, size={:#010x}", property_id, size);
@ -973,7 +973,7 @@ void Module::Interface::DeleteNsDataPrivileged(Kernel::HLERequestContext& ctx) {
const u32 ns_data_id = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_BOSS, "(STUBBED) programID={:#018x}, ns_data_id={:#010x}", programID,
ns_data_id);
@ -988,7 +988,7 @@ void Module::Interface::GetNsDataHeaderInfoPrivileged(Kernel::HLERequestContext&
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_BOSS,
@ -1005,7 +1005,7 @@ void Module::Interface::ReadNsDataPrivileged(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(size); /// Should be actual read size
rb.Push<u32>(0); /// unknown
rb.PushMappedBuffer(buffer);
@ -1022,7 +1022,7 @@ void Module::Interface::SetNsDataNewFlagPrivileged(Kernel::HLERequestContext& ct
boss->ns_data_new_flag_privileged = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(
Service_BOSS,
@ -1036,7 +1036,7 @@ void Module::Interface::GetNsDataNewFlagPrivileged(Kernel::HLERequestContext& ct
const u32 unk_param1 = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(boss->ns_data_new_flag_privileged);
LOG_WARNING(

View file

@ -38,7 +38,7 @@ void BossTaskProperties::serialize(Archive& ar, const unsigned int) {
}
SERIALIZE_IMPL(BossTaskProperties)
ResultCode OnlineService::InitializeSession(u64 init_program_id) {
Result OnlineService::InitializeSession(u64 init_program_id) {
// The BOSS service uses three databases:
// BOSS_A: Archive? A list of program ids and some properties that are keyed on program
// BOSS_SS: Saved Strings? Includes the url and the other string properties, and also some other
@ -65,7 +65,7 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
std::unique_ptr<FileSys::ArchiveBackend> boss_system_save_data_archive;
if (archive_result.Succeeded()) {
boss_system_save_data_archive = std::move(archive_result).Unwrap();
} else if (archive_result.Code() == FileSys::ERROR_NOT_FOUND) {
} else if (archive_result.Code() == FileSys::ResultNotFound) {
// If the archive didn't exist, create the files inside
systemsavedata_factory.Format(archive_path, FileSys::ArchiveFormatInfo(), 0);
@ -74,13 +74,13 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
if (!create_archive_result.Succeeded()) {
LOG_ERROR(Service_BOSS, "Could not open BOSS savedata");
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
boss_system_save_data_archive = std::move(create_archive_result).Unwrap();
} else {
LOG_ERROR(Service_BOSS, "Could not open BOSS savedata");
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
FileSys::Mode open_mode = {};
@ -94,7 +94,7 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
boss_system_save_data_archive->OpenFile(FileSys::Path("/BOSS_SS.db"), open_mode);
if (!boss_sv_result.Succeeded() || !boss_ss_result.Succeeded()) {
LOG_ERROR(Service_BOSS, "Could not open BOSS database.");
return RESULT_SUCCESS;
return ResultSuccess;
}
auto boss_sv = std::move(boss_sv_result).Unwrap();
@ -103,7 +103,7 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
((boss_sv->GetSize() - BOSS_SAVE_HEADER_SIZE) % BOSS_S_ENTRY_SIZE) == 0 &&
boss_sv->GetSize() == boss_ss->GetSize())) {
LOG_ERROR(Service_BOSS, "BOSS database has incorrect size.");
return RESULT_SUCCESS;
return ResultSuccess;
}
// Read the files if they already exist
@ -135,7 +135,7 @@ ResultCode OnlineService::InitializeSession(u64 init_program_id) {
current_props = BossTaskProperties();
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void OnlineService::RegisterTask(const u32 size, Kernel::MappedBuffer& buffer) {
@ -150,11 +150,11 @@ void OnlineService::RegisterTask(const u32 size, Kernel::MappedBuffer& buffer) {
current_props = BossTaskProperties();
}
ResultCode OnlineService::UnregisterTask(const u32 size, Kernel::MappedBuffer& buffer) {
Result OnlineService::UnregisterTask(const u32 size, Kernel::MappedBuffer& buffer) {
if (size > TASK_ID_SIZE) {
LOG_WARNING(Service_BOSS, "TaskId cannot be longer than 8");
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
std::string task_id(size, 0);
@ -162,10 +162,10 @@ ResultCode OnlineService::UnregisterTask(const u32 size, Kernel::MappedBuffer& b
if (task_id_list.erase(task_id) == 0) {
LOG_WARNING(Service_BOSS, "TaskId not in list");
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void OnlineService::GetTaskIdList() {
@ -334,13 +334,13 @@ std::optional<NsDataEntry> OnlineService::GetNsDataEntryFromId(const u32 ns_data
return *entry_iter;
}
ResultCode OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type,
const u32 size, Kernel::MappedBuffer& buffer) {
Result OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type,
const u32 size, Kernel::MappedBuffer& buffer) {
const auto entry = GetNsDataEntryFromId(ns_data_id);
if (!entry.has_value()) {
LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id);
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
static constexpr std::array EXPECTED_NS_DATA_HEADER_INFO_SIZES = {
@ -355,31 +355,31 @@ ResultCode OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsData
if (size != EXPECTED_NS_DATA_HEADER_INFO_SIZES[static_cast<u8>(type)]) {
LOG_WARNING(Service_BOSS, "Invalid size {} for type {}", size, type);
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
switch (type) {
case NsDataHeaderInfoType::ProgramId:
buffer.Write(&entry->header.program_id, 0, size);
return RESULT_SUCCESS;
return ResultSuccess;
case NsDataHeaderInfoType::Unknown: {
// TODO: Figure out what this is. Stubbed to zero for now.
const u32 zero = 0;
buffer.Write(&zero, 0, size);
return RESULT_SUCCESS;
return ResultSuccess;
}
case NsDataHeaderInfoType::Datatype:
buffer.Write(&entry->header.datatype, 0, size);
return RESULT_SUCCESS;
return ResultSuccess;
case NsDataHeaderInfoType::PayloadSize:
buffer.Write(&entry->header.payload_size, 0, size);
return RESULT_SUCCESS;
return ResultSuccess;
case NsDataHeaderInfoType::NsDataId:
buffer.Write(&entry->header.ns_data_id, 0, size);
return RESULT_SUCCESS;
return ResultSuccess;
case NsDataHeaderInfoType::Version:
buffer.Write(&entry->header.version, 0, size);
return RESULT_SUCCESS;
return ResultSuccess;
case NsDataHeaderInfoType::Everything: {
const NsDataHeaderInfo info = {
.program_id = entry->header.program_id,
@ -389,12 +389,12 @@ ResultCode OnlineService::GetNsDataHeaderInfo(const u32 ns_data_id, const NsData
.version = entry->header.version,
};
buffer.Write(&info, 0, size);
return RESULT_SUCCESS;
return ResultSuccess;
}
default:
LOG_WARNING(Service_BOSS, "Unknown header info type {}", type);
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
}
@ -404,7 +404,7 @@ ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offs
if (!entry.has_value()) {
LOG_WARNING(Service_BOSS, "Failed to find NsData entry for ID {:#010X}", ns_data_id);
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
if (entry->header.payload_size < size + offset) {
@ -413,13 +413,13 @@ ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offs
"length is {:#010X}",
size, offset, static_cast<u32>(entry->header.payload_size));
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
auto boss_archive = OpenBossExtData();
if (!boss_archive) {
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
FileSys::Path file_path = fmt::format("/{}", entry->filename);
@ -429,7 +429,7 @@ ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offs
if (!file_result.Succeeded()) {
LOG_WARNING(Service_BOSS, "Failed to open SpotPass extdata file '{}'.", entry->filename);
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
auto file = std::move(file_result).Unwrap();
@ -438,7 +438,7 @@ ResultVal<size_t> OnlineService::ReadNsData(const u32 ns_data_id, const u64 offs
if (!read_result.Succeeded()) {
LOG_WARNING(Service_BOSS, "Failed to read SpotPass extdata file '{}'.", entry->filename);
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
buffer.Write(ns_data_array.data(), 0, size);
@ -452,12 +452,12 @@ struct overload : Ts... {
template <class... Ts>
overload(Ts...) -> overload<Ts...>;
ResultCode OnlineService::SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer) {
Result OnlineService::SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer) {
const auto property_id = static_cast<PropertyID>(id);
if (!current_props.properties.contains(property_id)) {
LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size);
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
auto& prop = current_props.properties[property_id];
@ -489,16 +489,15 @@ ResultCode OnlineService::SendProperty(const u16 id, const u32 size, Kernel::Map
[&](std::vector<u32>& cur_prop) { read_vector(cur_prop); }},
prop);
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode OnlineService::ReceiveProperty(const u16 id, const u32 size,
Kernel::MappedBuffer& buffer) {
Result OnlineService::ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer) {
const auto property_id = static_cast<PropertyID>(id);
if (!current_props.properties.contains(property_id)) {
LOG_ERROR(Service_BOSS, "Unknown property with ID {:#06x} and size {}", property_id, size);
// TODO: Proper error code.
return RESULT_UNKNOWN;
return ResultUnknown;
}
auto write_pod = [&]<typename T>(T& cur_prop) {
@ -526,7 +525,7 @@ ResultCode OnlineService::ReceiveProperty(const u16 id, const u32 size,
[&](std::vector<u32>& cur_prop) { write_vector(cur_prop); }},
prop);
return RESULT_SUCCESS;
return ResultSuccess;
}
} // namespace Service::BOSS

View file

@ -161,18 +161,18 @@ class OnlineService final {
public:
explicit OnlineService(u64 program_id_, u64 extdata_id_);
ResultCode InitializeSession(u64 init_program_id);
Result InitializeSession(u64 init_program_id);
void RegisterTask(const u32 size, Kernel::MappedBuffer& buffer);
ResultCode UnregisterTask(const u32 size, Kernel::MappedBuffer& buffer);
Result UnregisterTask(const u32 size, Kernel::MappedBuffer& buffer);
void GetTaskIdList();
u16 GetNsDataIdList(const u32 filter, const u32 max_entries, Kernel::MappedBuffer& buffer);
std::optional<NsDataEntry> GetNsDataEntryFromId(const u32 ns_data_id);
ResultCode GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type,
const u32 size, Kernel::MappedBuffer& buffer);
Result GetNsDataHeaderInfo(const u32 ns_data_id, const NsDataHeaderInfoType type,
const u32 size, Kernel::MappedBuffer& buffer);
ResultVal<size_t> ReadNsData(const u32 ns_data_id, const u64 offset, const u32 size,
Kernel::MappedBuffer& buffer);
ResultCode SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);
ResultCode ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);
Result SendProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);
Result ReceiveProperty(const u16 id, const u32 size, Kernel::MappedBuffer& buffer);
private:
std::unique_ptr<FileSys::ArchiveBackend> OpenBossExtData();

View file

@ -77,10 +77,10 @@ constexpr std::array<int, 13> LATENCY_BY_FRAME_RATE{{
33, // Rate_30_To_10
}};
const ResultCode ERROR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
const ResultCode ERROR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
const Result ERROR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
const Result ERROR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
void Module::PortConfig::Clear() {
completion_event->Clear();
@ -278,7 +278,7 @@ void Module::Interface::StartCapture(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_CAM, "port {} already started", i);
}
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -303,7 +303,7 @@ void Module::Interface::StopCapture(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_CAM, "port {} already stopped", i);
}
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -324,7 +324,7 @@ void Module::Interface::IsBusy(Kernel::HLERequestContext& ctx) {
for (int i : port_select) {
is_busy &= cam->ports[i].is_busy;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(is_busy);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -340,7 +340,7 @@ void Module::Interface::ClearBuffer(Kernel::HLERequestContext& ctx) {
const PortSet port_select(rp.Pop<u8>());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CAM, "(STUBBED) called, port_select={}", port_select.m_val);
}
@ -352,7 +352,7 @@ void Module::Interface::GetVsyncInterruptEvent(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
if (port_select.IsSingle()) {
int port = *port_select.begin();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(cam->ports[port].vsync_interrupt_event);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -370,7 +370,7 @@ void Module::Interface::GetBufferErrorInterruptEvent(Kernel::HLERequestContext&
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
if (port_select.IsSingle()) {
int port = *port_select.begin();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(cam->ports[port].buffer_error_interrupt_event);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -405,7 +405,7 @@ void Module::Interface::SetReceiving(Kernel::HLERequestContext& ctx) {
port.is_pending_receiving = true;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(port.completion_event);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -425,7 +425,7 @@ void Module::Interface::IsFinishedReceiving(Kernel::HLERequestContext& ctx) {
if (port_select.IsSingle()) {
int port = *port_select.begin();
bool is_busy = cam->ports[port].is_receiving || cam->ports[port].is_pending_receiving;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(!is_busy);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -448,7 +448,7 @@ void Module::Interface::SetTransferLines(Kernel::HLERequestContext& ctx) {
for (int i : port_select) {
cam->ports[i].transfer_bytes = transfer_lines * width * 2;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -476,7 +476,7 @@ void Module::Interface::GetMaxLines(Kernel::HLERequestContext& ctx) {
if (lines > height) {
lines = height;
}
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
while (height % lines != 0 || (lines * width * 2 % MIN_TRANSFER_UNIT != 0)) {
--lines;
if (lines == 0) {
@ -503,7 +503,7 @@ void Module::Interface::SetTransferBytes(Kernel::HLERequestContext& ctx) {
for (int i : port_select) {
cam->ports[i].transfer_bytes = transfer_bytes;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -520,7 +520,7 @@ void Module::Interface::GetTransferBytes(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
if (port_select.IsSingle()) {
int port = *port_select.begin();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(cam->ports[port].transfer_bytes);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -551,7 +551,7 @@ void Module::Interface::GetMaxBytes(Kernel::HLERequestContext& ctx) {
bytes -= MIN_TRANSFER_UNIT;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(bytes);
}
@ -568,7 +568,7 @@ void Module::Interface::SetTrimming(Kernel::HLERequestContext& ctx) {
for (int i : port_select) {
cam->ports[i].is_trimming = trim;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -584,7 +584,7 @@ void Module::Interface::IsTrimming(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
if (port_select.IsSingle()) {
int port = *port_select.begin();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(cam->ports[port].is_trimming);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
@ -611,7 +611,7 @@ void Module::Interface::SetTrimmingParams(Kernel::HLERequestContext& ctx) {
cam->ports[i].x1 = x1;
cam->ports[i].y1 = y1;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -628,7 +628,7 @@ void Module::Interface::GetTrimmingParams(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
if (port_select.IsSingle()) {
int port = *port_select.begin();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(cam->ports[port].x0);
rb.Push(cam->ports[port].y0);
rb.Push(cam->ports[port].x1);
@ -658,7 +658,7 @@ void Module::Interface::SetTrimmingParamsCenter(Kernel::HLERequestContext& ctx)
cam->ports[i].x1 = cam->ports[i].x0 + trim_w;
cam->ports[i].y1 = cam->ports[i].y0 + trim_h;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid port_select={}", port_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -684,7 +684,7 @@ void Module::Interface::Activate(Kernel::HLERequestContext& ctx) {
cam->ports[i].is_active = false;
cam->system.CoreTiming().UnscheduleEvent(cam->vsync_interrupt_event_callback, i);
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else if (camera_select[0] && camera_select[1]) {
LOG_ERROR(Service_CAM, "camera 0 and 1 can't be both activated");
rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -698,7 +698,7 @@ void Module::Interface::Activate(Kernel::HLERequestContext& ctx) {
if (camera_select[2]) {
cam->ActivatePort(1, 2);
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
} else {
LOG_ERROR(Service_CAM, "invalid camera_select={}", camera_select.m_val);
@ -724,7 +724,7 @@ void Module::Interface::SwitchContext(Kernel::HLERequestContext& ctx) {
cam->cameras[camera].impl->SetFormat(context_config.format);
cam->cameras[camera].impl->SetResolution(context_config.resolution);
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val);
@ -751,7 +751,7 @@ void Module::Interface::FlipImage(Kernel::HLERequestContext& ctx) {
}
}
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val);
@ -784,7 +784,7 @@ void Module::Interface::SetDetailSize(Kernel::HLERequestContext& ctx) {
}
}
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val);
@ -814,7 +814,7 @@ void Module::Interface::SetSize(Kernel::HLERequestContext& ctx) {
}
}
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val);
@ -836,7 +836,7 @@ void Module::Interface::SetFrameRate(Kernel::HLERequestContext& ctx) {
cam->cameras[camera].frame_rate = frame_rate;
cam->cameras[camera].impl->SetFrameRate(frame_rate);
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid camera_select={}", camera_select.m_val);
rb.Push(ERROR_INVALID_ENUM_VALUE);
@ -862,7 +862,7 @@ void Module::Interface::SetEffect(Kernel::HLERequestContext& ctx) {
}
}
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val);
@ -889,7 +889,7 @@ void Module::Interface::SetOutputFormat(Kernel::HLERequestContext& ctx) {
}
}
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", camera_select.m_val,
context_select.m_val);
@ -906,7 +906,7 @@ void Module::Interface::SynchronizeVsyncTiming(Kernel::HLERequestContext& ctx) {
const u8 camera_select2 = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CAM, "(STUBBED) called, camera_select1={}, camera_select2={}",
camera_select1, camera_select2);
@ -925,7 +925,7 @@ void Module::Interface::GetLatestVsyncTiming(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
const std::size_t port_id = port_select.m_val == 1 ? 0 : 1;
std::vector<u8> out(count * sizeof(s64_le));
@ -961,7 +961,7 @@ void Module::Interface::GetStereoCameraCalibrationData(Kernel::HLERequestContext
data.imageWidth = 640;
data.imageHeight = 480;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(data);
LOG_TRACE(Service_CAM, "called");
@ -974,13 +974,13 @@ void Module::Interface::SetPackageParameterWithoutContext(Kernel::HLERequestCont
rp.PopRaw(package);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CAM, "(STUBBED) called");
}
template <typename PackageParameterType>
ResultCode Module::SetPackageParameter(const PackageParameterType& package) {
Result Module::SetPackageParameter(const PackageParameterType& package) {
const CameraSet camera_select(package.camera_select);
const ContextSet context_select(package.context_select);
@ -999,7 +999,7 @@ ResultCode Module::SetPackageParameter(const PackageParameterType& package) {
}
}
}
return RESULT_SUCCESS;
return ResultSuccess;
} else {
LOG_ERROR(Service_CAM, "invalid camera_select={}, context_select={}", package.camera_select,
package.context_select);
@ -1018,7 +1018,7 @@ void Module::Interface::SetPackageParameterWithContext(Kernel::HLERequestContext
rp.PopRaw(package);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
ResultCode result = cam->SetPackageParameter(package);
Result result = cam->SetPackageParameter(package);
rb.Push(result);
LOG_DEBUG(Service_CAM, "called");
@ -1031,7 +1031,7 @@ void Module::Interface::SetPackageParameterWithContextDetail(Kernel::HLERequestC
rp.PopRaw(package);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
ResultCode result = cam->SetPackageParameter(package);
Result result = cam->SetPackageParameter(package);
rb.Push(result);
LOG_DEBUG(Service_CAM, "called");
@ -1040,7 +1040,7 @@ void Module::Interface::SetPackageParameterWithContextDetail(Kernel::HLERequestC
void Module::Interface::GetSuitableY2rStandardCoefficient(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0);
LOG_WARNING(Service_CAM, "(STUBBED) called");
@ -1051,7 +1051,7 @@ void Module::Interface::PlayShutterSound(Kernel::HLERequestContext& ctx) {
u8 sound_id = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CAM, "(STUBBED) called, sound_id={}", sound_id);
}
@ -1081,7 +1081,7 @@ void Module::Interface::DriverInitialize(Kernel::HLERequestContext& ctx) {
cam->initialized = true;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_CAM, "called");
}
@ -1099,7 +1099,7 @@ void Module::Interface::DriverFinalize(Kernel::HLERequestContext& ctx) {
cam->initialized = false;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_CAM, "called");
}

View file

@ -166,7 +166,7 @@ public:
* 1: u8 selected port
* Outputs:
* 0: 0x00010040
* 1: ResultCode
* 1: Result
*/
void StartCapture(Kernel::HLERequestContext& ctx);
@ -177,7 +177,7 @@ public:
* 1: u8 selected port
* Outputs:
* 0: 0x00020040
* 1: ResultCode
* 1: Result
*/
void StopCapture(Kernel::HLERequestContext& ctx);
@ -188,7 +188,7 @@ public:
* 1: u8 selected port
* Outputs:
* 0: 0x00030080
* 1: ResultCode
* 1: Result
* 2: 0 if not capturing, 1 if capturing
*/
void IsBusy(Kernel::HLERequestContext& ctx);
@ -200,7 +200,7 @@ public:
* 1: u8 selected port
* Outputs:
* 0: 0x00040040
* 2: ResultCode
* 2: Result
*/
void ClearBuffer(Kernel::HLERequestContext& ctx);
@ -211,7 +211,7 @@ public:
* 1: u8 selected port
* Outputs:
* 0: 0x00050042
* 1: ResultCode
* 1: Result
* 2: Descriptor: Handle
* 3: Event handle
*/
@ -224,7 +224,7 @@ public:
* 1: u8 selected port
* Outputs:
* 0: 0x00060042
* 1: ResultCode
* 1: Result
* 2: Descriptor: Handle
* 3: Event handle
*/
@ -244,7 +244,7 @@ public:
* 6: Handle to destination process
* Outputs:
* 0: 0x00070042
* 1: ResultCode
* 1: Result
* 2: Descriptor: Handle
* 3: Handle to event signalled when transfer finishes
*/
@ -257,7 +257,7 @@ public:
* 1: u8 selected port
* Outputs:
* 0: 0x00080080
* 1: ResultCode
* 1: Result
* 2: 0 if not finished, 1 if finished
*/
void IsFinishedReceiving(Kernel::HLERequestContext& ctx);
@ -272,7 +272,7 @@ public:
* 4: u16 Height
* Outputs:
* 0: 0x00090040
* 1: ResultCode
* 1: Result
* @todo figure out how the "buffer" actually works.
*/
void SetTransferLines(Kernel::HLERequestContext& ctx);
@ -285,7 +285,7 @@ public:
* 2: u16 Height
* Outputs:
* 0: 0x000A0080
* 1: ResultCode
* 1: Result
* 2: Maximum number of lines that fit in the buffer
* @todo figure out how the "buffer" actually works.
*/
@ -301,7 +301,7 @@ public:
* 4: u16 Height
* Outputs:
* 0: 0x000B0040
* 1: ResultCode
* 1: Result
* @todo figure out how the "buffer" actually works.
*/
void SetTransferBytes(Kernel::HLERequestContext& ctx);
@ -313,7 +313,7 @@ public:
* 1: u8 selected port
* Outputs:
* 0: 0x000C0080
* 1: ResultCode
* 1: Result
* 2: The number of bytes the buffer contains
* @todo figure out how the "buffer" actually works.
*/
@ -327,7 +327,7 @@ public:
* 2: u16 Height
* Outputs:
* 0: 0x000D0080
* 1: ResultCode
* 1: Result
* 2: Maximum number of bytes that fit in the buffer
* @todo figure out how the "buffer" actually works.
*/
@ -341,7 +341,7 @@ public:
* 2: u8 bool Enable trimming if true
* Outputs:
* 0: 0x000E0040
* 1: ResultCode
* 1: Result
*/
void SetTrimming(Kernel::HLERequestContext& ctx);
@ -352,7 +352,7 @@ public:
* 1: u8 selected port
* Outputs:
* 0: 0x000F0080
* 1: ResultCode
* 1: Result
* 2: u8 bool Enable trimming if true
*/
void IsTrimming(Kernel::HLERequestContext& ctx);
@ -368,7 +368,7 @@ public:
* 5: y end (exclusive)
* Outputs:
* 0: 0x00100040
* 1: ResultCode
* 1: Result
*/
void SetTrimmingParams(Kernel::HLERequestContext& ctx);
@ -380,7 +380,7 @@ public:
*
* Outputs:
* 0: 0x00110140
* 1: ResultCode
* 1: Result
* 2: x start
* 3: y start
* 4: x end (exclusive)
@ -400,7 +400,7 @@ public:
* 5: s16 Camera height
* Outputs:
* 0: 0x00120040
* 1: ResultCode
* 1: Result
*/
void SetTrimmingParamsCenter(Kernel::HLERequestContext& ctx);
@ -411,7 +411,7 @@ public:
* 1: u8 selected camera
* Outputs:
* 0: 0x00130040
* 1: ResultCode
* 1: Result
*/
void Activate(Kernel::HLERequestContext& ctx);
@ -423,7 +423,7 @@ public:
* 2: u8 selected context
* Outputs:
* 0: 0x00140040
* 1: ResultCode
* 1: Result
*/
void SwitchContext(Kernel::HLERequestContext& ctx);
@ -436,7 +436,7 @@ public:
* 3: u8 selected context
* Outputs:
* 0: 0x001D0040
* 1: ResultCode
* 1: Result
*/
void FlipImage(Kernel::HLERequestContext& ctx);
@ -455,7 +455,7 @@ public:
* 8: u8 selected context
* Outputs:
* 0: 0x001E0040
* 1: ResultCode
* 1: Result
*/
void SetDetailSize(Kernel::HLERequestContext& ctx);
@ -468,7 +468,7 @@ public:
* 3: u8 selected context
* Outputs:
* 0: 0x001F0040
* 1: ResultCode
* 1: Result
*/
void SetSize(Kernel::HLERequestContext& ctx);
@ -480,7 +480,7 @@ public:
* 2: u8 Camera framerate (`FrameRate` enum)
* Outputs:
* 0: 0x00200040
* 1: ResultCode
* 1: Result
*/
void SetFrameRate(Kernel::HLERequestContext& ctx);
@ -493,7 +493,7 @@ public:
* 3: u8 selected context
* Outputs:
* 0: 0x00220040
* 1: ResultCode
* 1: Result
*/
void SetEffect(Kernel::HLERequestContext& ctx);
@ -506,7 +506,7 @@ public:
* 3: u8 selected context
* Outputs:
* 0: 0x00250040
* 1: ResultCode
* 1: Result
*/
void SetOutputFormat(Kernel::HLERequestContext& ctx);
@ -518,7 +518,7 @@ public:
* 2: u8 selected camera 2
* Outputs:
* 0: 0x00280040
* 1: ResultCode
* 1: Result
*/
void SynchronizeVsyncTiming(Kernel::HLERequestContext& ctx);
@ -532,7 +532,7 @@ public:
* 65: s64* TimingsOutput
* Outputs:
* 0: 0x002A0042
* 1: ResultCode
* 1: Result
* 2-3: Output static buffer
*/
void GetLatestVsyncTiming(Kernel::HLERequestContext& ctx);
@ -545,7 +545,7 @@ public:
* 0: 0x002B0000
* Outputs:
* 0: 0x002B0440
* 1: ResultCode
* 1: Result
* 2-17: `StereoCameraCalibrationData` structure with calibration values
*/
void GetStereoCameraCalibrationData(Kernel::HLERequestContext& ctx);
@ -559,7 +559,7 @@ public:
* 8-11: unused
* Outputs:
* 0: 0x00330040
* 1: ResultCode
* 1: Result
*/
void SetPackageParameterWithoutContext(Kernel::HLERequestContext& ctx);
@ -572,7 +572,7 @@ public:
* 3-5: unused
* Outputs:
* 0: 0x00340040
* 1: ResultCode
* 1: Result
*/
void SetPackageParameterWithContext(Kernel::HLERequestContext& ctx);
@ -585,7 +585,7 @@ public:
* 5-7: unused
* Outputs:
* 0: 0x00350040
* 1: ResultCode
* 1: Result
*/
void SetPackageParameterWithContextDetail(Kernel::HLERequestContext& ctx);
@ -595,7 +595,7 @@ public:
* 0: 0x00360000
* Outputs:
* 0: 0x00360080
* 1: ResultCode
* 1: Result
* 2: ?
*/
void GetSuitableY2rStandardCoefficient(Kernel::HLERequestContext& ctx);
@ -607,7 +607,7 @@ public:
* 1: u8 Sound ID
* Outputs:
* 0: 0x00380040
* 1: ResultCode
* 1: Result
*/
void PlayShutterSound(Kernel::HLERequestContext& ctx);
@ -617,7 +617,7 @@ public:
* 0: 0x00390000
* Outputs:
* 0: 0x00390040
* 1: ResultCode
* 1: Result
*/
void DriverInitialize(Kernel::HLERequestContext& ctx);
@ -627,7 +627,7 @@ public:
* 0: 0x003A0000
* Outputs:
* 0: 0x003A0040
* 1: ResultCode
* 1: Result
*/
void DriverFinalize(Kernel::HLERequestContext& ctx);
@ -653,7 +653,7 @@ private:
void ActivatePort(int port_id, int camera_id);
template <typename PackageParameterType>
ResultCode SetPackageParameter(const PackageParameterType& package);
Result SetPackageParameter(const PackageParameterType& package);
struct ContextConfig {
Flip flip{Flip::None};

View file

@ -37,23 +37,23 @@ constexpr std::array<CoefficientSet, 4> standard_coefficients{{
{{0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421}}, // ITU_Rec709_Scaling
}};
ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) {
Result ConversionConfiguration::SetInputLineWidth(u16 width) {
if (width == 0 || width > 1024 || width % 8 != 0) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
return Result(ErrorDescription::OutOfRange, ErrorModule::CAM, ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E053FD
}
// Note: The hardware uses the register value 0 to represent a width of 1024, so for a width of
// 1024 the `camera` module would set the value 0 here, but we don't need to emulate this
// internal detail.
this->input_line_width = width;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
Result ConversionConfiguration::SetInputLines(u16 lines) {
if (lines == 0 || lines > 1024) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
return Result(ErrorDescription::OutOfRange, ErrorModule::CAM, ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E053FD
}
// Note: In what appears to be a bug, the `camera` module does not set the hardware register at
@ -62,19 +62,18 @@ ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
if (lines != 1024) {
this->input_lines = lines;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode ConversionConfiguration::SetStandardCoefficient(
StandardCoefficient standard_coefficient) {
Result ConversionConfiguration::SetStandardCoefficient(StandardCoefficient standard_coefficient) {
const auto index = static_cast<std::size_t>(standard_coefficient);
if (index >= standard_coefficients.size()) {
return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
return Result(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
}
std::memcpy(coefficients.data(), standard_coefficients[index].data(), sizeof(coefficients));
return RESULT_SUCCESS;
return ResultSuccess;
}
void Y2R_U::SetInputFormat(Kernel::HLERequestContext& ctx) {
@ -83,7 +82,7 @@ void Y2R_U::SetInputFormat(Kernel::HLERequestContext& ctx) {
conversion.input_format = rp.PopEnum<InputFormat>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called input_format={}", conversion.input_format);
}
@ -92,7 +91,7 @@ void Y2R_U::GetInputFormat(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(conversion.input_format);
LOG_DEBUG(Service_Y2R, "called input_format={}", conversion.input_format);
@ -104,7 +103,7 @@ void Y2R_U::SetOutputFormat(Kernel::HLERequestContext& ctx) {
conversion.output_format = rp.PopEnum<OutputFormat>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called output_format={}", conversion.output_format);
}
@ -113,7 +112,7 @@ void Y2R_U::GetOutputFormat(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(conversion.output_format);
LOG_DEBUG(Service_Y2R, "called output_format={}", conversion.output_format);
@ -125,7 +124,7 @@ void Y2R_U::SetRotation(Kernel::HLERequestContext& ctx) {
conversion.rotation = rp.PopEnum<Rotation>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called rotation={}", conversion.rotation);
}
@ -134,7 +133,7 @@ void Y2R_U::GetRotation(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(conversion.rotation);
LOG_DEBUG(Service_Y2R, "called rotation={}", conversion.rotation);
@ -146,7 +145,7 @@ void Y2R_U::SetBlockAlignment(Kernel::HLERequestContext& ctx) {
conversion.block_alignment = rp.PopEnum<BlockAlignment>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called block_alignment={}", conversion.block_alignment);
}
@ -155,7 +154,7 @@ void Y2R_U::GetBlockAlignment(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(conversion.block_alignment);
LOG_DEBUG(Service_Y2R, "called block_alignment={}", conversion.block_alignment);
@ -167,7 +166,7 @@ void Y2R_U::SetSpacialDithering(Kernel::HLERequestContext& ctx) {
spacial_dithering_enabled = rp.Pop<bool>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
}
@ -176,7 +175,7 @@ void Y2R_U::GetSpacialDithering(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(spacial_dithering_enabled);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -187,7 +186,7 @@ void Y2R_U::SetTemporalDithering(Kernel::HLERequestContext& ctx) {
temporal_dithering_enabled = rp.Pop<bool>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
}
@ -196,7 +195,7 @@ void Y2R_U::GetTemporalDithering(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(temporal_dithering_enabled);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -207,7 +206,7 @@ void Y2R_U::SetTransferEndInterrupt(Kernel::HLERequestContext& ctx) {
transfer_end_interrupt_enabled = rp.Pop<bool>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
}
@ -216,7 +215,7 @@ void Y2R_U::GetTransferEndInterrupt(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(transfer_end_interrupt_enabled);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -226,7 +225,7 @@ void Y2R_U::GetTransferEndEvent(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(completion_event);
LOG_DEBUG(Service_Y2R, "called");
@ -242,7 +241,7 @@ void Y2R_U::SetSendingY(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -261,7 +260,7 @@ void Y2R_U::SetSendingU(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -281,7 +280,7 @@ void Y2R_U::SetSendingV(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -301,7 +300,7 @@ void Y2R_U::SetSendingYUYV(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -314,7 +313,7 @@ void Y2R_U::IsFinishedSendingYuv(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -324,7 +323,7 @@ void Y2R_U::IsFinishedSendingY(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -334,7 +333,7 @@ void Y2R_U::IsFinishedSendingU(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -344,7 +343,7 @@ void Y2R_U::IsFinishedSendingV(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -361,7 +360,7 @@ void Y2R_U::SetReceiving(Kernel::HLERequestContext& ctx) {
// TODO (wwylele): pass the process handle to y2r engine or convert VAddr to PAddr
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R,
"called image_size=0x{:08X}, transfer_unit={}, transfer_stride={}, "
@ -374,7 +373,7 @@ void Y2R_U::IsFinishedReceiving(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(1);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -394,7 +393,7 @@ void Y2R_U::GetInputLineWidth(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(conversion.input_line_width);
LOG_DEBUG(Service_Y2R, "called input_line_width={}", conversion.input_line_width);
@ -414,7 +413,7 @@ void Y2R_U::GetInputLines(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(static_cast<u32>(conversion.input_lines));
LOG_DEBUG(Service_Y2R, "called input_lines={}", conversion.input_lines);
@ -426,7 +425,7 @@ void Y2R_U::SetCoefficient(Kernel::HLERequestContext& ctx) {
rp.PopRaw<CoefficientSet>(conversion.coefficients);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called coefficients=[{:X}, {:X}, {:X}, {:X}, {:X}, {:X}, {:X}, {:X}]",
conversion.coefficients[0], conversion.coefficients[1], conversion.coefficients[2],
@ -438,7 +437,7 @@ void Y2R_U::GetCoefficient(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(conversion.coefficients);
LOG_DEBUG(Service_Y2R, "called");
@ -460,14 +459,14 @@ void Y2R_U::GetStandardCoefficient(Kernel::HLERequestContext& ctx) {
if (index < standard_coefficients.size()) {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(standard_coefficients[index]);
LOG_DEBUG(Service_Y2R, "called standard_coefficient={} ", index);
} else {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage));
LOG_ERROR(Service_Y2R, "called standard_coefficient={} The argument is invalid!", index);
}
@ -478,7 +477,7 @@ void Y2R_U::SetAlpha(Kernel::HLERequestContext& ctx) {
conversion.alpha = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called alpha={}", conversion.alpha);
}
@ -487,7 +486,7 @@ void Y2R_U::GetAlpha(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(conversion.alpha);
LOG_DEBUG(Service_Y2R, "called alpha={}", conversion.alpha);
@ -497,7 +496,7 @@ void Y2R_U::SetDitheringWeightParams(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
rp.PopRaw(dithering_weight_params);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called");
}
@ -506,7 +505,7 @@ void Y2R_U::GetDitheringWeightParams(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(9, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(dithering_weight_params);
LOG_DEBUG(Service_Y2R, "called");
@ -526,7 +525,7 @@ void Y2R_U::StartConversion(Kernel::HLERequestContext& ctx) {
completion_event->Signal();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called");
}
@ -535,7 +534,7 @@ void Y2R_U::StopConversion(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called");
}
@ -544,7 +543,7 @@ void Y2R_U::IsBusyConversion(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(0); // StartConversion always finishes immediately
LOG_DEBUG(Service_Y2R, "called");
@ -559,7 +558,7 @@ void Y2R_U::SetPackageParameter(Kernel::HLERequestContext& ctx) {
conversion.rotation = params.rotation;
conversion.block_alignment = params.block_alignment;
ResultCode result = conversion.SetInputLineWidth(params.input_line_width);
Result result = conversion.SetInputLineWidth(params.input_line_width);
if (result.IsError())
goto cleanup;
@ -593,7 +592,7 @@ void Y2R_U::PingProcess(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(0);
LOG_DEBUG(Service_Y2R, "(STUBBED) called");
@ -621,7 +620,7 @@ void Y2R_U::DriverInitialize(Kernel::HLERequestContext& ctx) {
completion_event->Clear();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called");
}
@ -630,7 +629,7 @@ void Y2R_U::DriverFinalize(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_Y2R, "called");
}
@ -639,7 +638,7 @@ void Y2R_U::GetPackageParameter(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(4, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(conversion);
LOG_DEBUG(Service_Y2R, "called");

View file

@ -120,9 +120,9 @@ struct ConversionConfiguration {
/// Output parameters for the conversion results
ConversionBuffer dst;
ResultCode SetInputLineWidth(u16 width);
ResultCode SetInputLines(u16 lines);
ResultCode SetStandardCoefficient(StandardCoefficient standard_coefficient);
Result SetInputLineWidth(u16 width);
Result SetInputLines(u16 lines);
Result SetStandardCoefficient(StandardCoefficient standard_coefficient);
private:
template <class Archive>

View file

@ -76,11 +76,11 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
if (dir_result.Failed()) {
if (open_mode.create) {
cecd->cecd_system_save_data_archive->CreateDirectory(path);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_DEBUG(Service_CECD, "Failed to open directory: {}", path.AsString());
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC,
ErrorSummary::NotFound, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
}
rb.Push<u32>(0); // Zero entries
} else {
@ -93,7 +93,7 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_CECD, "Number of entries found: {}", entry_count);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(entry_count); // Entry count
directory->Close();
}
@ -103,12 +103,12 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
auto file_result = cecd->cecd_system_save_data_archive->OpenFile(path, mode);
if (file_result.Failed()) {
LOG_DEBUG(Service_CECD, "Failed to open file: {}", path.AsString());
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push<u32>(0); // No file size
} else {
session_data->file = std::move(file_result).Unwrap();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(session_data->file->GetSize())); // Return file size
}
@ -151,8 +151,8 @@ void Module::Interface::Read(Kernel::HLERequestContext& ctx) {
case CecDataPathType::MboxDir:
case CecDataPathType::InboxDir:
case CecDataPathType::OutboxDir:
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC,
ErrorSummary::NotFound, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push<u32>(0); // No bytes read
break;
default: // If not directory, then it is a file
@ -163,7 +163,7 @@ void Module::Interface::Read(Kernel::HLERequestContext& ctx) {
write_buffer.Write(buffer.data(), 0, write_buffer_size);
session_data->file->Close();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(bytes_read);
}
rb.PushMappedBuffer(write_buffer);
@ -225,11 +225,11 @@ void Module::Interface::ReadMessage(Kernel::HLERequestContext& ctx) {
msg_header.sender_id, msg_header.sender_id2, msg_header.send_count,
msg_header.forward_count, msg_header.user_data);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(bytes_read);
} else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push<u32>(0); // zero bytes read
}
rb.PushMappedBuffer(message_id_buffer);
@ -317,11 +317,11 @@ void Module::Interface::ReadMessageWithHMAC(Kernel::HLERequestContext& ctx) {
else
LOG_DEBUG(Service_CECD, "Verification failed");
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(bytes_read);
} else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push<u32>(0); // zero bytes read
}
@ -356,8 +356,8 @@ void Module::Interface::Write(Kernel::HLERequestContext& ctx) {
case CecDataPathType::MboxDir:
case CecDataPathType::InboxDir:
case CecDataPathType::OutboxDir:
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC,
ErrorSummary::NotFound, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
break;
default: // If not directory, then it is a file
std::vector<u8> buffer(read_buffer_size);
@ -376,7 +376,7 @@ void Module::Interface::Write(Kernel::HLERequestContext& ctx) {
session_data->file->Write(0, buffer.size(), true, buffer.data()).Unwrap());
session_data->file->Close();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
rb.PushMappedBuffer(read_buffer);
@ -438,10 +438,10 @@ void Module::Interface::WriteMessage(Kernel::HLERequestContext& ctx) {
static_cast<u32>(message->Write(0, buffer_size, true, buffer.data()).Unwrap());
message->Close();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
}
rb.PushMappedBuffer(read_buffer);
@ -525,10 +525,10 @@ void Module::Interface::WriteMessageWithHMAC(Kernel::HLERequestContext& ctx) {
static_cast<u32>(message->Write(0, buffer_size, true, buffer.data()).Unwrap());
message->Close();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
}
rb.PushMappedBuffer(read_buffer);
@ -613,7 +613,7 @@ void Module::Interface::SetData(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(read_buffer);
LOG_DEBUG(Service_CECD, "called, ncch_program_id={:#010x}, buffer_size={:#x}, option={:#x}",
@ -651,7 +651,7 @@ void Module::Interface::ReadData(Kernel::HLERequestContext& ctx) {
dest_buffer.Write(buffer.data(), 0,
std::min(static_cast<size_t>(dest_buffer_size), buffer.size()));
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(param_buffer);
rb.PushMappedBuffer(dest_buffer);
@ -665,7 +665,7 @@ void Module::Interface::Start(Kernel::HLERequestContext& ctx) {
const CecCommand command = rp.PopEnum<CecCommand>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CECD, "(STUBBED) called, command={}", cecd->GetCecCommandAsString(command));
}
@ -675,7 +675,7 @@ void Module::Interface::Stop(Kernel::HLERequestContext& ctx) {
const CecCommand command = rp.PopEnum<CecCommand>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CECD, "(STUBBED) called, command={}", cecd->GetCecCommandAsString(command));
}
@ -687,7 +687,7 @@ void Module::Interface::GetCecInfoBuffer(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_DEBUG(Service_CECD, "called, buffer_size={}, possible_info_type={}", buffer_size,
@ -698,7 +698,7 @@ void Module::Interface::GetCecdState(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(CecdState::NdmStatusIdle);
LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -708,7 +708,7 @@ void Module::Interface::GetCecInfoEventHandle(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(cecd->cecinfo_event);
LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -718,7 +718,7 @@ void Module::Interface::GetChangeStateEventHandle(Kernel::HLERequestContext& ctx
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(cecd->change_state_event);
LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -745,8 +745,8 @@ void Module::Interface::OpenAndWrite(Kernel::HLERequestContext& ctx) {
case CecDataPathType::MboxDir:
case CecDataPathType::InboxDir:
case CecDataPathType::OutboxDir:
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC,
ErrorSummary::NotFound, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
break;
default: // If not directory, then it is a file
auto file_result = cecd->cecd_system_save_data_archive->OpenFile(path, mode);
@ -768,10 +768,10 @@ void Module::Interface::OpenAndWrite(Kernel::HLERequestContext& ctx) {
static_cast<u32>(file->Write(0, buffer.size(), true, buffer.data()).Unwrap());
file->Close();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
}
}
rb.PushMappedBuffer(read_buffer);
@ -804,8 +804,8 @@ void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) {
case CecDataPathType::MboxDir:
case CecDataPathType::InboxDir:
case CecDataPathType::OutboxDir:
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC,
ErrorSummary::NotFound, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push<u32>(0); // No entries read
break;
default: // If not directory, then it is a file
@ -819,11 +819,11 @@ void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) {
write_buffer.Write(buffer.data(), 0, buffer_size);
file->Close();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(bytes_read);
} else {
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push<u32>(0); // No bytes read
}
}
@ -842,7 +842,7 @@ void Module::Interface::GetCecInfoEventHandleSys(Kernel::HLERequestContext& ctx)
rp.PopPID();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(cecd->cecinfosys_event);
LOG_WARNING(Service_CECD, "(STUBBED) called");
@ -1404,7 +1404,7 @@ Module::Module(Core::System& system) : system(system) {
auto archive_result = systemsavedata_factory.Open(archive_path, 0);
// If the archive didn't exist, create the files inside
if (archive_result.Code() != FileSys::ERROR_NOT_FOUND) {
if (archive_result.Code() != FileSys::ResultNotFound) {
ASSERT_MSG(archive_result.Succeeded(), "Could not open the CECD SystemSaveData archive!");
cecd_system_save_data_archive = std::move(archive_result).Unwrap();
} else {

View file

@ -500,7 +500,7 @@ public:
* Inputs:
* 0: Header Code[0x000E0000]
* Outputs:
* 1: ResultCode
* 1: Result
* 2: CecdState
*/
void GetCecdState(Kernel::HLERequestContext& ctx);
@ -510,7 +510,7 @@ public:
* Inputs:
* 0: Header Code[0x000F0000]
* Outputs:
* 1: ResultCode
* 1: Result
* 3: Event Handle
*/
void GetCecInfoEventHandle(Kernel::HLERequestContext& ctx);
@ -520,7 +520,7 @@ public:
* Inputs:
* 0: Header Code[0x00100000]
* Outputs:
* 1: ResultCode
* 1: Result
* 3: Event Handle
*/
void GetChangeStateEventHandle(Kernel::HLERequestContext& ctx);
@ -593,7 +593,7 @@ public:
* Inputs:
* 0: Header Code[0x40020002]
* Outputs:
* 1: ResultCode
* 1: Result
* 3: Event Handle
*/
void GetCecInfoEventHandleSys(Kernel::HLERequestContext& ctx);

View file

@ -153,13 +153,13 @@ void Module::Interface::GetCountryCodeString(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
if (country_code_id >= country_codes.size() || 0 == country_codes[country_code_id]) {
LOG_ERROR(Service_CFG, "requested country code id={} is invalid", country_code_id);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument,
ErrorLevel::Permanent));
rb.Skip(1, false);
return;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
// the real CFG service copies only three bytes (including the null-terminator) here
rb.Push<u32>(country_codes[country_code_id]);
}
@ -187,13 +187,13 @@ void Module::Interface::GetCountryCodeID(Kernel::HLERequestContext& ctx) {
if (0 == country_code_id) {
LOG_ERROR(Service_CFG, "requested country code name={}{} is invalid",
static_cast<char>(country_code & 0xff), static_cast<char>(country_code >> 8));
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::Config, ErrorSummary::WrongArgument,
ErrorLevel::Permanent));
rb.Push<u16>(0x00FF);
return;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(country_code_id);
}
@ -210,7 +210,7 @@ void Module::Interface::GetRegion(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(static_cast<u8>(cfg->GetRegionValue()));
}
@ -220,7 +220,7 @@ void Module::Interface::SecureInfoGetByte101(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_CFG, "(STUBBED) called");
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
// According to 3dbrew this is normally 0.
rb.Push<u8>(0);
}
@ -232,14 +232,14 @@ void Module::Interface::SetUUIDClockSequence(Kernel::HLERequestContext& ctx) {
cfg->SaveMCUConfig();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::Interface::GetUUIDClockSequence(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(static_cast<u16>(cfg->mcu_data.clock_sequence));
}
@ -250,7 +250,7 @@ void Module::Interface::GetTransferableId(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
std::array<u8, 12> buffer;
const ResultCode result =
const Result result =
cfg->GetConfigBlock(ConsoleUniqueID2BlockID, 8, AccessFlag::SystemRead, buffer.data());
rb.Push(result);
if (result.IsSuccess()) {
@ -274,7 +274,7 @@ void Module::Interface::IsCoppacsSupported(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
u8 canada_or_usa = 1;
if (canada_or_usa == cfg->GetRegionValue()) {
@ -407,23 +407,23 @@ ResultVal<void*> Module::GetConfigBlockPointer(u32 block_id, u32 size, AccessFla
"Config block 0x{:X} with flags {} and size {} was not found, and no default "
"exists.",
block_id, accesss_flag, size);
return ResultCode(ErrorDescription::NotFound, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
return Result(ErrorDescription::NotFound, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
}
if (False(itr->access_flags & accesss_flag)) {
LOG_ERROR(Service_CFG, "Invalid access flag {:X} for config block 0x{:X} with size {}",
accesss_flag, block_id, size);
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
return Result(ErrorDescription::NotAuthorized, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
if (itr->size != size) {
LOG_ERROR(Service_CFG, "Invalid size {} for config block 0x{:X} with flags {}", size,
block_id, accesss_flag);
return ResultCode(ErrorDescription::InvalidSize, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
return Result(ErrorDescription::InvalidSize, ErrorModule::Config,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
void* pointer;
@ -437,27 +437,26 @@ ResultVal<void*> Module::GetConfigBlockPointer(u32 block_id, u32 size, AccessFla
return pointer;
}
ResultCode Module::GetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, void* output) {
Result Module::GetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, void* output) {
void* pointer = nullptr;
CASCADE_RESULT(pointer, GetConfigBlockPointer(block_id, size, accesss_flag));
std::memcpy(output, pointer, size);
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode Module::SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag,
const void* input) {
Result Module::SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, const void* input) {
void* pointer = nullptr;
CASCADE_RESULT(pointer, GetConfigBlockPointer(block_id, size, accesss_flag));
std::memcpy(pointer, input, size);
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode Module::CreateConfigBlock(u32 block_id, u16 size, AccessFlag access_flags,
const void* data) {
Result Module::CreateConfigBlock(u32 block_id, u16 size, AccessFlag access_flags,
const void* data) {
SaveFileConfig* config = reinterpret_cast<SaveFileConfig*>(cfg_config_file_buffer.data());
if (config->total_entries >= CONFIG_FILE_MAX_BLOCK_ENTRIES)
return ResultCode(-1); // TODO(Subv): Find the right error code
return ResultUnknown; // TODO(Subv): Find the right error code
// Insert the block header with offset 0 for now
config->block_entries[config->total_entries] = {block_id, 0, size, access_flags};
@ -483,15 +482,15 @@ ResultCode Module::CreateConfigBlock(u32 block_id, u16 size, AccessFlag access_f
}
++config->total_entries;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode Module::DeleteConfigNANDSaveFile() {
Result Module::DeleteConfigNANDSaveFile() {
FileSys::Path path("/config");
return cfg_system_save_data_archive->DeleteFile(path);
}
ResultCode Module::UpdateConfigNANDSavegame() {
Result Module::UpdateConfigNANDSavegame() {
FileSys::Mode mode = {};
mode.write_flag.Assign(1);
mode.create_flag.Assign(1);
@ -504,13 +503,13 @@ ResultCode Module::UpdateConfigNANDSavegame() {
auto config = std::move(config_result).Unwrap();
config->Write(0, CONFIG_SAVEFILE_SIZE, 1, cfg_config_file_buffer.data());
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode Module::FormatConfig() {
ResultCode res = DeleteConfigNANDSaveFile();
Result Module::FormatConfig() {
Result res = DeleteConfigNANDSaveFile();
// The delete command fails if the file doesn't exist, so we have to check that too
if (!res.IsSuccess() && res != FileSys::ERROR_FILE_NOT_FOUND) {
if (!res.IsSuccess() && res != FileSys::ResultFileNotFound) {
return res;
}
// Delete the old data
@ -540,10 +539,10 @@ ResultCode Module::FormatConfig() {
return res;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode Module::LoadConfigNANDSaveFile() {
Result Module::LoadConfigNANDSaveFile() {
const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory);
@ -552,7 +551,7 @@ ResultCode Module::LoadConfigNANDSaveFile() {
auto archive_result = systemsavedata_factory.Open(archive_path, 0);
// If the archive didn't exist, create the files inside
if (archive_result.Code() == FileSys::ERROR_NOT_FOUND) {
if (archive_result.Code() == FileSys::ResultNotFound) {
// Format the archive to create the directories
systemsavedata_factory.Format(archive_path, FileSys::ArchiveFormatInfo(), 0);
@ -574,7 +573,7 @@ ResultCode Module::LoadConfigNANDSaveFile() {
if (config_result.Succeeded()) {
auto config = std::move(config_result).Unwrap();
config->Read(0, CONFIG_SAVEFILE_SIZE, cfg_config_file_buffer.data());
return RESULT_SUCCESS;
return ResultSuccess;
}
return FormatConfig();
@ -777,10 +776,10 @@ std::pair<u32, u64> Module::GenerateConsoleUniqueId() const {
return std::make_pair(random_number, console_id);
}
ResultCode Module::SetConsoleUniqueId(u32 random_number, u64 console_id) {
Result Module::SetConsoleUniqueId(u32 random_number, u64 console_id) {
u64_le console_id_le = console_id;
ResultCode res = SetConfigBlock(ConsoleUniqueID1BlockID, sizeof(console_id_le),
AccessFlag::Global, &console_id_le);
Result res = SetConfigBlock(ConsoleUniqueID1BlockID, sizeof(console_id_le), AccessFlag::Global,
&console_id_le);
if (!res.IsSuccess())
return res;
@ -795,7 +794,7 @@ ResultCode Module::SetConsoleUniqueId(u32 random_number, u64 console_id) {
if (!res.IsSuccess())
return res;
return RESULT_SUCCESS;
return ResultSuccess;
}
u64 Module::GetConsoleUniqueId() {

View file

@ -389,9 +389,9 @@ private:
* @param size The size of the block we want to read
* @param accesss_flag The requested block must have this access flag set
* @param output A pointer where we will write the read data
* @returns ResultCode indicating the result of the operation, 0 on success
* @returns Result indicating the result of the operation, 0 on success
*/
ResultCode GetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, void* output);
Result GetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, void* output);
/**
* Reads data from input and writes to a block with the specified id and flag
@ -402,9 +402,9 @@ private:
* @param size The size of the block we want to write
* @param accesss_flag The target block must have this access flag set
* @param input A pointer where we will read data and write to Config savegame buffer
* @returns ResultCode indicating the result of the operation, 0 on success
* @returns Result indicating the result of the operation, 0 on success
*/
ResultCode SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, const void* input);
Result SetConfigBlock(u32 block_id, u32 size, AccessFlag accesss_flag, const void* input);
/**
* Creates a block with the specified id and writes the input data to the cfg savegame buffer in
@ -414,28 +414,27 @@ private:
* @param size The size of the block we want to create
* @param accesss_flags The access flags of the new block
* @param data A pointer containing the data we will write to the new block
* @returns ResultCode indicating the result of the operation, 0 on success
* @returns Result indicating the result of the operation, 0 on success
*/
ResultCode CreateConfigBlock(u32 block_id, u16 size, AccessFlag accesss_flags,
const void* data);
Result CreateConfigBlock(u32 block_id, u16 size, AccessFlag accesss_flags, const void* data);
/**
* Deletes the config savegame file from the filesystem, the buffer in memory is not affected
* @returns ResultCode indicating the result of the operation, 0 on success
* @returns Result indicating the result of the operation, 0 on success
*/
ResultCode DeleteConfigNANDSaveFile();
Result DeleteConfigNANDSaveFile();
/**
* Re-creates the config savegame file in memory and the filesystem with the default blocks
* @returns ResultCode indicating the result of the operation, 0 on success
* @returns Result indicating the result of the operation, 0 on success
*/
ResultCode FormatConfig();
Result FormatConfig();
/**
* Open the config savegame file and load it to the memory buffer
* @returns ResultCode indicating the result of the operation, 0 on success
* @returns Result indicating the result of the operation, 0 on success
*/
ResultCode LoadConfigNANDSaveFile();
Result LoadConfigNANDSaveFile();
/**
* Loads MCU specific data
@ -538,7 +537,7 @@ public:
* @param random_number the random_number to set
* @param console_id the console id to set
*/
ResultCode SetConsoleUniqueId(u32 random_number, u64 console_id);
Result SetConsoleUniqueId(u32 random_number, u64 console_id);
/**
* Gets the console unique id from config savegame.
@ -572,9 +571,9 @@ public:
/**
* Writes the config savegame memory buffer to the config savegame file in the filesystem
* @returns ResultCode indicating the result of the operation, 0 on success
* @returns Result indicating the result of the operation, 0 on success
*/
ResultCode UpdateConfigNANDSavegame();
Result UpdateConfigNANDSavegame();
/**
* Saves MCU specific data

View file

@ -208,7 +208,7 @@ void CSND_SND::Initialize(Kernel::HLERequestContext& ctx) {
.Unwrap();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 3);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(mutex, shared_memory);
LOG_WARNING(Service_CSND,
@ -228,7 +228,7 @@ void CSND_SND::Shutdown(Kernel::HLERequestContext& ctx) {
shared_memory = nullptr;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CSND, "(STUBBED) called");
}
@ -240,8 +240,8 @@ void CSND_SND::ExecuteCommands(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
if (!shared_memory) {
rb.Push(ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::CSND,
ErrorSummary::InvalidState, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::InvalidResultValue, ErrorModule::CSND,
ErrorSummary::InvalidState, ErrorLevel::Status));
LOG_ERROR(Service_CSND, "called, shared memory not allocated");
return;
}
@ -394,7 +394,7 @@ void CSND_SND::ExecuteCommands(Kernel::HLERequestContext& ctx) {
*shared_memory->GetPointer(addr + offsetof(Type0Command, finished)) = 1;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void CSND_SND::AcquireSoundChannels(Kernel::HLERequestContext& ctx) {
@ -405,7 +405,7 @@ void CSND_SND::AcquireSoundChannels(Kernel::HLERequestContext& ctx) {
acquired_channel_mask = 0xFFFFFF00;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(acquired_channel_mask);
LOG_WARNING(Service_CSND, "(STUBBED) called");
@ -417,7 +417,7 @@ void CSND_SND::ReleaseSoundChannels(Kernel::HLERequestContext& ctx) {
acquired_channel_mask = 0;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CSND, "(STUBBED) called");
}
@ -428,12 +428,12 @@ void CSND_SND::AcquireCapUnit(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
if (capture_units[0] && capture_units[1]) {
LOG_WARNING(Service_CSND, "No more capture units available");
rb.Push(ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::CSND,
ErrorSummary::OutOfResource, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::InvalidResultValue, ErrorModule::CSND,
ErrorSummary::OutOfResource, ErrorLevel::Status));
rb.Skip(1, false);
return;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
if (capture_units[0]) {
capture_units[1] = true;
@ -453,7 +453,7 @@ void CSND_SND::ReleaseCapUnit(Kernel::HLERequestContext& ctx) {
capture_units[index] = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CSND, "(STUBBED) called, capture_unit_index={}", index);
}
@ -465,7 +465,7 @@ void CSND_SND::FlushDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_CSND, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address,
size, process->process_id);
@ -478,7 +478,7 @@ void CSND_SND::StoreDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_CSND, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address,
size, process->process_id);
@ -491,7 +491,7 @@ void CSND_SND::InvalidateDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_CSND, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address,
size, process->process_id);
@ -501,7 +501,7 @@ void CSND_SND::Reset(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_CSND, "(STUBBED) called");
}

View file

@ -18,7 +18,7 @@ void DLP_SRVR::IsChild(Kernel::HLERequestContext& ctx) {
rp.Skip(1, false);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(false);
LOG_WARNING(Service_DLP, "(STUBBED) called");

View file

@ -28,7 +28,7 @@ void DSP_DSP::RecvData(Kernel::HLERequestContext& ctx) {
const u32 register_number = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(system.DSP().RecvData(register_number));
LOG_DEBUG(Service_DSP, "register_number={}", register_number);
@ -39,7 +39,7 @@ void DSP_DSP::RecvDataIsReady(Kernel::HLERequestContext& ctx) {
const u32 register_number = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(system.DSP().RecvDataIsReady(register_number));
LOG_DEBUG(Service_DSP, "register_number={}", register_number);
@ -52,7 +52,7 @@ void DSP_DSP::SetSemaphore(Kernel::HLERequestContext& ctx) {
system.DSP().SetSemaphore(semaphore_value);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_INFO(Service_DSP, "called, semaphore_value={:04X}", semaphore_value);
}
@ -62,7 +62,7 @@ void DSP_DSP::ConvertProcessAddressFromDspDram(Kernel::HLERequestContext& ctx) {
const u32 address = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
// TODO(merry): There is a per-region offset missing in this calculation (that seems to be
// always zero).
@ -103,7 +103,7 @@ void DSP_DSP::WriteProcessPipe(Kernel::HLERequestContext& ctx) {
system.DSP().PipeWrite(pipe, buffer);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_DSP, "channel={}, size=0x{:X}, buffer_size={:X}", channel, size,
buffer.size());
@ -125,7 +125,7 @@ void DSP_DSP::ReadPipe(Kernel::HLERequestContext& ctx) {
UNREACHABLE(); // No more data is in pipe. Hardware hangs in this case; Should never happen.
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(pipe_buffer), 0);
LOG_DEBUG(Service_DSP, "channel={}, peer={}, size=0x{:04X}, pipe_readable_size=0x{:04X}",
@ -141,7 +141,7 @@ void DSP_DSP::GetPipeReadableSize(Kernel::HLERequestContext& ctx) {
const u16 pipe_readable_size = static_cast<u16>(system.DSP().GetPipeReadableSize(pipe));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(pipe_readable_size);
LOG_DEBUG(Service_DSP, "channel={}, peer={}, return pipe_readable_size=0x{:04X}", channel, peer,
@ -163,7 +163,7 @@ void DSP_DSP::ReadPipeIfPossible(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u16>(static_cast<u16>(pipe_buffer.size()));
rb.PushStaticBuffer(std::move(pipe_buffer), 0);
@ -179,7 +179,7 @@ void DSP_DSP::LoadComponent(Kernel::HLERequestContext& ctx) {
auto& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(true);
rb.PushMappedBuffer(buffer);
@ -198,7 +198,7 @@ void DSP_DSP::UnloadComponent(Kernel::HLERequestContext& ctx) {
system.DSP().UnloadComponent();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_INFO(Service_DSP, "(STUBBED)");
}
@ -210,7 +210,7 @@ void DSP_DSP::FlushDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_DSP, "called address=0x{:08X}, size=0x{:X}, process={}", address, size,
process->process_id);
@ -223,7 +223,7 @@ void DSP_DSP::InvalidateDataCache(Kernel::HLERequestContext& ctx) {
const auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_DSP, "called address=0x{:08X}, size=0x{:X}, process={}", address, size,
process->process_id);
@ -250,8 +250,8 @@ void DSP_DSP::RegisterInterruptEvents(Kernel::HLERequestContext& ctx) {
"Ran out of space to register interrupts (Attempted to register "
"interrupt={}, channel={}, event={})",
interrupt, channel, event->GetName());
rb.Push(ResultCode(ErrorDescription::InvalidResultValue, ErrorModule::DSP,
ErrorSummary::OutOfResource, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::InvalidResultValue, ErrorModule::DSP,
ErrorSummary::OutOfResource, ErrorLevel::Status));
return;
} else {
GetInterruptEvent(type, pipe) = event;
@ -262,14 +262,14 @@ void DSP_DSP::RegisterInterruptEvents(Kernel::HLERequestContext& ctx) {
GetInterruptEvent(type, pipe) = nullptr;
LOG_INFO(Service_DSP, "Unregistered interrupt={}, channel={}", interrupt, channel);
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void DSP_DSP::GetSemaphoreEventHandle(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(semaphore_event);
LOG_WARNING(Service_DSP, "(STUBBED) called");
@ -280,7 +280,7 @@ void DSP_DSP::SetSemaphoreMask(Kernel::HLERequestContext& ctx) {
preset_semaphore = rp.Pop<u16>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_DSP, "(STUBBED) called mask=0x{:04X}", preset_semaphore);
}
@ -289,7 +289,7 @@ void DSP_DSP::GetHeadphoneStatus(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(false); /// u8, 0 = not inserted, 1 = inserted
LOG_DEBUG(Service_DSP, "called");
@ -300,7 +300,7 @@ void DSP_DSP::ForceHeadphoneOut(Kernel::HLERequestContext& ctx) {
const u8 force = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_DSP, "(STUBBED) called, force={}", force);
}

View file

@ -155,7 +155,7 @@ static void LogGenericInfo(const ErrInfo::ErrInfoCommon& errinfo_common) {
errinfo_common.app_title_id_low);
LOG_CRITICAL(Service_ERR, "ADR: 0x{:08X}", errinfo_common.pc_address);
ResultCode result_code{errinfo_common.result_code};
Result result_code{errinfo_common.result_code};
LOG_CRITICAL(Service_ERR, "RSL: 0x{:08X}", result_code.raw);
LOG_CRITICAL(Service_ERR, " Level: {}", static_cast<u32>(result_code.level.Value()));
LOG_CRITICAL(Service_ERR, " Summary: {}", static_cast<u32>(result_code.summary.Value()));
@ -244,7 +244,7 @@ void ERR_F::ThrowFatalError(Kernel::HLERequestContext& ctx) {
} // switch FatalErrType
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
ERR_F::ERR_F(Core::System& system) : ServiceFramework("err:f", 1), system(system) {

View file

@ -35,7 +35,7 @@ void Module::Interface::GetMyPresence(Kernel::HLERequestContext& ctx) {
std::memcpy(buffer.data(), &frd->my_presence, buffer.size());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0);
LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -49,7 +49,7 @@ void Module::Interface::GetFriendKeyList(Kernel::HLERequestContext& ctx) {
std::vector<u8> buffer(sizeof(FriendKey) * frd_count, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // 0 friends
rb.PushStaticBuffer(std::move(buffer), 0);
@ -65,7 +65,7 @@ void Module::Interface::GetFriendProfile(Kernel::HLERequestContext& ctx) {
std::vector<u8> buffer(sizeof(Profile) * count, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0);
LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count);
@ -80,7 +80,7 @@ void Module::Interface::GetFriendAttributeFlags(Kernel::HLERequestContext& ctx)
// TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte
std::vector<u8> buffer(1 * count, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0);
LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count);
@ -89,7 +89,7 @@ void Module::Interface::GetFriendAttributeFlags(Kernel::HLERequestContext& ctx)
void Module::Interface::GetMyFriendKey(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(frd->my_friend_key);
LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -105,7 +105,7 @@ void Module::Interface::GetMyScreenName(Kernel::HLERequestContext& ctx) {
ScreenName screen_name{};
std::memcpy(screen_name.name.data(), username.data(), username.length() * sizeof(char16_t));
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(screen_name);
rb.Push(0);
@ -118,7 +118,7 @@ void Module::Interface::GetMyComment(Kernel::HLERequestContext& ctx) {
constexpr Comment comment{.name = {u'H', u'e', u'y', '!'}};
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<Comment>(comment);
rb.Push(0);
@ -133,7 +133,7 @@ void Module::Interface::GetMyMii(Kernel::HLERequestContext& ctx) {
Mii::ChecksummedMiiData mii{};
mii.SetMiiData(mii_data);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<Mii::ChecksummedMiiData>(mii);
LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -145,7 +145,7 @@ void Module::Interface::GetMyProfile(Kernel::HLERequestContext& ctx) {
constexpr Profile profile{.region = 1, .country = 1, .area = 1, .language = 1, .platform = 1};
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<Profile>(profile);
LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -157,7 +157,7 @@ void Module::Interface::GetMyFavoriteGame(Kernel::HLERequestContext& ctx) {
constexpr Game game{.title_id = 0x0004000E00030700, .version = 1};
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<Game>(game);
LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -169,7 +169,7 @@ void Module::Interface::GetMyPlayingGame(Kernel::HLERequestContext& ctx) {
constexpr Game game{.title_id = 0x0004000E00030700, .version = 1};
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<Game>(game);
LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -183,7 +183,7 @@ void Module::Interface::GetMyPreference(Kernel::HLERequestContext& ctx) {
constexpr u32 show_game = 1;
constexpr u32 show_history = 0;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(is_public);
rb.Push<u32>(show_game);
rb.Push<u32>(show_history);
@ -218,7 +218,7 @@ void Module::Interface::UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx
LOG_WARNING(Service_FRD, "(STUBBED) called");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(unscrambled_friend_codes), 0);
}
@ -228,7 +228,7 @@ void Module::Interface::SetClientSdkVersion(Kernel::HLERequestContext& ctx) {
rp.PopPID();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_FRD, "(STUBBED) called, version: 0x{:08X}", version);
}
@ -237,7 +237,7 @@ void Module::Interface::IsOnline(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(frd->logged_in);
LOG_WARNING(Service_FRD, "(STUBBED) called");
@ -248,7 +248,7 @@ void Module::Interface::HasLoggedIn(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(frd->logged_in);
}
@ -270,7 +270,7 @@ void Module::Interface::Login(Kernel::HLERequestContext& ctx) {
frd->system.CoreTiming().ScheduleEvent(msToCycles(login_delay_ms), frd->login_delay_event);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void Module::Interface::GetLastResponseResult(Kernel::HLERequestContext& ctx) {
@ -278,7 +278,7 @@ void Module::Interface::GetLastResponseResult(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
Module::Module(Core::System& system) : system(system){};

View file

@ -52,7 +52,7 @@ ResultVal<ArchiveHandle> ArchiveManager::OpenArchive(ArchiveIdCode id_code,
auto itr = id_code_map.find(id_code);
if (itr == id_code_map.end()) {
return FileSys::ERROR_NOT_FOUND;
return FileSys::ResultNotFound;
}
CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res,
@ -66,17 +66,17 @@ ResultVal<ArchiveHandle> ArchiveManager::OpenArchive(ArchiveIdCode id_code,
return next_handle++;
}
ResultCode ArchiveManager::CloseArchive(ArchiveHandle handle) {
Result ArchiveManager::CloseArchive(ArchiveHandle handle) {
if (handle_map.erase(handle) == 0)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
else
return RESULT_SUCCESS;
return ResultSuccess;
}
// TODO(yuriks): This might be what the fs:REG service is for. See the Register/Unregister calls in
// http://3dbrew.org/wiki/Filesystem_services#ProgramRegistry_service_.22fs:REG.22
ResultCode ArchiveManager::RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
ArchiveIdCode id_code) {
Result ArchiveManager::RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
ArchiveIdCode id_code) {
auto result = id_code_map.emplace(id_code, std::move(factory));
bool inserted = result.second;
@ -85,7 +85,7 @@ ResultCode ArchiveManager::RegisterArchiveType(std::unique_ptr<FileSys::ArchiveF
auto& archive = result.first->second;
LOG_DEBUG(Service_FS, "Registered archive {} with id code 0x{:08X}", archive->GetName(),
id_code);
return RESULT_SUCCESS;
return ResultSuccess;
}
std::pair<ResultVal<std::shared_ptr<File>>, std::chrono::nanoseconds>
@ -93,7 +93,7 @@ ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys:
const FileSys::Mode mode) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) {
return std::make_pair(FileSys::ERR_INVALID_ARCHIVE_HANDLE, std::chrono::nanoseconds{0});
return std::make_pair(FileSys::ResultInvalidArchiveHandle, std::chrono::nanoseconds{0});
}
const std::chrono::nanoseconds open_timeout_ns{archive->GetOpenDelayNs()};
@ -106,23 +106,23 @@ ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys:
return std::make_pair(std::move(file), open_timeout_ns);
}
ResultCode ArchiveManager::DeleteFileFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) {
Result ArchiveManager::DeleteFileFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
return archive->DeleteFile(path);
}
ResultCode ArchiveManager::RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path) {
Result ArchiveManager::RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path) {
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
if (src_archive == nullptr || dest_archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
if (src_archive == dest_archive) {
return src_archive->RenameFile(src_path, dest_path);
@ -132,50 +132,50 @@ ResultCode ArchiveManager::RenameFileBetweenArchives(ArchiveHandle src_archive_h
}
}
ResultCode ArchiveManager::DeleteDirectoryFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) {
Result ArchiveManager::DeleteDirectoryFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
return archive->DeleteDirectory(path);
}
ResultCode ArchiveManager::DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) {
Result ArchiveManager::DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
return archive->DeleteDirectoryRecursively(path);
}
ResultCode ArchiveManager::CreateFileInArchive(ArchiveHandle archive_handle,
const FileSys::Path& path, u64 file_size) {
Result ArchiveManager::CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
u64 file_size) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
return archive->CreateFile(path, file_size);
}
ResultCode ArchiveManager::CreateDirectoryFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) {
Result ArchiveManager::CreateDirectoryFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
return archive->CreateDirectory(path);
}
ResultCode ArchiveManager::RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path) {
Result ArchiveManager::RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path) {
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
if (src_archive == nullptr || dest_archive == nullptr)
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
if (src_archive == dest_archive) {
return src_archive->RenameDirectory(src_path, dest_path);
@ -189,7 +189,7 @@ ResultVal<std::shared_ptr<Directory>> ArchiveManager::OpenDirectoryFromArchive(
ArchiveHandle archive_handle, const FileSys::Path& path) {
ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) {
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
}
auto backend = archive->OpenDirectory(path);
@ -203,14 +203,14 @@ ResultVal<std::shared_ptr<Directory>> ArchiveManager::OpenDirectoryFromArchive(
ResultVal<u64> ArchiveManager::GetFreeBytesInArchive(ArchiveHandle archive_handle) {
const ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) {
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
return FileSys::ResultInvalidArchiveHandle;
}
return archive->GetFreeBytes();
}
ResultCode ArchiveManager::FormatArchive(ArchiveIdCode id_code,
const FileSys::ArchiveFormatInfo& format_info,
const FileSys::Path& path, u64 program_id) {
Result ArchiveManager::FormatArchive(ArchiveIdCode id_code,
const FileSys::ArchiveFormatInfo& format_info,
const FileSys::Path& path, u64 program_id) {
auto archive_itr = id_code_map.find(id_code);
if (archive_itr == id_code_map.end()) {
return UnimplementedFunction(ErrorModule::FS); // TODO(Subv): Find the right error
@ -229,10 +229,10 @@ ResultVal<FileSys::ArchiveFormatInfo> ArchiveManager::GetArchiveFormatInfo(
return archive->second->GetFormatInfo(archive_path, program_id);
}
ResultCode ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32 low,
std::span<const u8> smdh_icon,
const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) {
Result ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32 low,
std::span<const u8> smdh_icon,
const FileSys::ArchiveFormatInfo& format_info,
u64 program_id) {
// Construct the binary path to the archive first
FileSys::Path path =
FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
@ -246,16 +246,16 @@ ResultCode ArchiveManager::CreateExtSaveData(MediaType media_type, u32 high, u32
auto ext_savedata = static_cast<FileSys::ArchiveFactory_ExtSaveData*>(archive->second.get());
ResultCode result = ext_savedata->Format(path, format_info, program_id);
Result result = ext_savedata->Format(path, format_info, program_id);
if (result.IsError()) {
return result;
}
ext_savedata->WriteIcon(path, smdh_icon);
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32 low) {
Result ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32 low) {
// Construct the binary path to the archive first
FileSys::Path path =
FileSys::ConstructExtDataBinaryPath(static_cast<u32>(media_type), high, low);
@ -267,7 +267,7 @@ ResultCode ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32
media_type_directory = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir);
} else {
LOG_ERROR(Service_FS, "Unsupported media type {}", media_type);
return ResultCode(-1); // TODO(Subv): Find the right error code
return ResultUnknown; // TODO(Subv): Find the right error code
}
// Delete all directories (/user, /boss) and the icon file.
@ -275,11 +275,11 @@ ResultCode ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32
FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND);
std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path);
if (FileUtil::Exists(extsavedata_path) && !FileUtil::DeleteDirRecursively(extsavedata_path))
return ResultCode(-1); // TODO(Subv): Find the right error code
return RESULT_SUCCESS;
return ResultUnknown; // TODO(Subv): Find the right error code
return ResultSuccess;
}
ResultCode ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) {
Result ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) {
// Construct the binary path to the archive first
const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low);
@ -287,13 +287,13 @@ ResultCode ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) {
const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory);
const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path);
if (!FileUtil::DeleteDirRecursively(systemsavedata_path)) {
return ResultCode(-1); // TODO(Subv): Find the right error code
return ResultUnknown; // TODO(Subv): Find the right error code
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode ArchiveManager::CreateSystemSaveData(u32 high, u32 low) {
Result ArchiveManager::CreateSystemSaveData(u32 high, u32 low) {
// Construct the binary path to the archive first
const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low);
@ -301,10 +301,10 @@ ResultCode ArchiveManager::CreateSystemSaveData(u32 high, u32 low) {
const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory);
const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path);
if (!FileUtil::CreateFullPath(systemsavedata_path)) {
return ResultCode(-1); // TODO(Subv): Find the right error code
return ResultUnknown; // TODO(Subv): Find the right error code
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultVal<ArchiveResource> ArchiveManager::GetArchiveResource(MediaType media_type) const {

View file

@ -88,7 +88,7 @@ public:
* Closes an archive
* @param handle Handle to the archive to close
*/
ResultCode CloseArchive(ArchiveHandle handle);
Result CloseArchive(ArchiveHandle handle);
/**
* Open a File from an Archive
@ -106,7 +106,7 @@ public:
* @param path Path to the File inside of the Archive
* @return Whether deletion succeeded
*/
ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path);
Result DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path);
/**
* Rename a File between two Archives
@ -116,10 +116,10 @@ public:
* @param dest_path Path to the File inside of the destination Archive
* @return Whether rename succeeded
*/
ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path);
Result RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path);
/**
* Delete a Directory from an Archive
@ -127,7 +127,7 @@ public:
* @param path Path to the Directory inside of the Archive
* @return Whether deletion succeeded
*/
ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path);
Result DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path);
/**
* Delete a Directory and anything under it from an Archive
@ -135,8 +135,8 @@ public:
* @param path Path to the Directory inside of the Archive
* @return Whether deletion succeeded
*/
ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path);
Result DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path);
/**
* Create a File in an Archive
@ -145,8 +145,8 @@ public:
* @param file_size The size of the new file, filled with zeroes
* @return File creation result code
*/
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
u64 file_size);
Result CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
u64 file_size);
/**
* Create a Directory from an Archive
@ -154,7 +154,7 @@ public:
* @param path Path to the Directory inside of the Archive
* @return Whether creation of directory succeeded
*/
ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path);
Result CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path);
/**
* Rename a Directory between two Archives
@ -164,10 +164,10 @@ public:
* @param dest_path Path to the Directory inside of the destination Archive
* @return Whether rename succeeded
*/
ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path);
Result RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
const FileSys::Path& src_path,
ArchiveHandle dest_archive_handle,
const FileSys::Path& dest_path);
/**
* Open a Directory from an Archive
@ -192,10 +192,10 @@ public:
* @param format_info Format information about the new archive
* @param path The path to the archive, if relevant.
* @param program_id the program ID of the client that requests the operation
* @return ResultCode 0 on success or the corresponding code on error
* @return Result 0 on success or the corresponding code on error
*/
ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info,
const FileSys::Path& path, u64 program_id);
Result FormatArchive(ArchiveIdCode id_code, const FileSys::ArchiveFormatInfo& format_info,
const FileSys::Path& path, u64 program_id);
/**
* Retrieves the format info about the archive of the specified type and path.
@ -217,36 +217,35 @@ public:
* @param smdh_icon the SMDH icon for this ExtSaveData
* @param format_info Format information about the new archive
* @param program_id the program ID of the client that requests the operation
* @return ResultCode 0 on success or the corresponding code on error
* @return Result 0 on success or the corresponding code on error
*/
ResultCode CreateExtSaveData(MediaType media_type, u32 high, u32 low,
std::span<const u8> smdh_icon,
const FileSys::ArchiveFormatInfo& format_info, u64 program_id);
Result CreateExtSaveData(MediaType media_type, u32 high, u32 low, std::span<const u8> smdh_icon,
const FileSys::ArchiveFormatInfo& format_info, u64 program_id);
/**
* Deletes the SharedExtSaveData archive for the specified extdata ID
* @param media_type The media type of the archive to delete (NAND / SDMC)
* @param high The high word of the extdata id to delete
* @param low The low word of the extdata id to delete
* @return ResultCode 0 on success or the corresponding code on error
* @return Result 0 on success or the corresponding code on error
*/
ResultCode DeleteExtSaveData(MediaType media_type, u32 high, u32 low);
Result DeleteExtSaveData(MediaType media_type, u32 high, u32 low);
/**
* Deletes the SystemSaveData archive folder for the specified save data id
* @param high The high word of the SystemSaveData archive to delete
* @param low The low word of the SystemSaveData archive to delete
* @return ResultCode 0 on success or the corresponding code on error
* @return Result 0 on success or the corresponding code on error
*/
ResultCode DeleteSystemSaveData(u32 high, u32 low);
Result DeleteSystemSaveData(u32 high, u32 low);
/**
* Creates the SystemSaveData archive folder for the specified save data id
* @param high The high word of the SystemSaveData archive to create
* @param low The low word of the SystemSaveData archive to create
* @return ResultCode 0 on success or the corresponding code on error
* @return Result 0 on success or the corresponding code on error
*/
ResultCode CreateSystemSaveData(u32 high, u32 low);
Result CreateSystemSaveData(u32 high, u32 low);
/**
* Returns capacity and free space information about the given media type.
@ -266,8 +265,8 @@ private:
* @param factory File system backend interface to the archive
* @param id_code Id code used to access this type of archive
*/
ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
ArchiveIdCode id_code);
Result RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory,
ArchiveIdCode id_code);
/// Register all archive types
void RegisterArchiveTypes();

View file

@ -51,7 +51,7 @@ void Directory::Read(Kernel::HLERequestContext& ctx) {
buffer.Write(entries.data(), 0, read * sizeof(FileSys::Entry));
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(read);
rb.PushMappedBuffer(buffer);
}
@ -62,7 +62,7 @@ void Directory::Close(Kernel::HLERequestContext& ctx) {
backend->Close();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
} // namespace Service::FS

View file

@ -86,7 +86,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
rb.Push<u32>(0);
} else {
buffer.Write(*data, 0, *read);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(*read));
}
rb.PushMappedBuffer(buffer);
@ -104,7 +104,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
bool cache_ready;
// Output
ResultCode ret{0};
Result ret{0};
Kernel::MappedBuffer* buffer;
std::unique_ptr<u8*> data;
size_t read_size;
@ -130,7 +130,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
async_data->ret = read.Code();
async_data->read_size = 0;
} else {
async_data->ret = RESULT_SUCCESS;
async_data->ret = ResultSuccess;
async_data->read_size = *read;
}
@ -157,7 +157,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
rb.Push<u32>(0);
} else {
async_data->buffer->Write(*async_data->data, 0, async_data->read_size);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(async_data->read_size));
}
rb.PushMappedBuffer(*async_data->buffer);
@ -180,7 +180,7 @@ void File::Write(Kernel::HLERequestContext& ctx) {
// Subfiles can not be written to
if (file->subfile) {
rb.Push(FileSys::ERROR_UNSUPPORTED_OPEN_FLAGS);
rb.Push(FileSys::ResultUnsupportedOpenFlags);
rb.Push<u32>(0);
rb.PushMappedBuffer(buffer);
return;
@ -197,7 +197,7 @@ void File::Write(Kernel::HLERequestContext& ctx) {
rb.Push(written.Code());
rb.Push<u32>(0);
} else {
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(static_cast<u32>(*written));
}
rb.PushMappedBuffer(buffer);
@ -209,7 +209,7 @@ void File::GetSize(Kernel::HLERequestContext& ctx) {
const FileSessionSlot* file = GetSessionData(ctx.Session());
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u64>(file->size);
}
@ -223,13 +223,13 @@ void File::SetSize(Kernel::HLERequestContext& ctx) {
// SetSize can not be called on subfiles.
if (file->subfile) {
rb.Push(FileSys::ERROR_UNSUPPORTED_OPEN_FLAGS);
rb.Push(FileSys::ResultUnsupportedOpenFlags);
return;
}
file->size = size;
backend->SetSize(size);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void File::Close(Kernel::HLERequestContext& ctx) {
@ -242,7 +242,7 @@ void File::Close(Kernel::HLERequestContext& ctx) {
backend->Close();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void File::Flush(Kernel::HLERequestContext& ctx) {
@ -254,12 +254,12 @@ void File::Flush(Kernel::HLERequestContext& ctx) {
// Subfiles can not be flushed.
if (file->subfile) {
rb.Push(FileSys::ERROR_UNSUPPORTED_OPEN_FLAGS);
rb.Push(FileSys::ResultUnsupportedOpenFlags);
return;
}
backend->Flush();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void File::SetPriority(Kernel::HLERequestContext& ctx) {
@ -269,7 +269,7 @@ void File::SetPriority(Kernel::HLERequestContext& ctx) {
file->priority = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void File::GetPriority(Kernel::HLERequestContext& ctx) {
@ -277,7 +277,7 @@ void File::GetPriority(Kernel::HLERequestContext& ctx) {
const FileSessionSlot* file = GetSessionData(ctx.Session());
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(file->priority);
}
@ -298,7 +298,7 @@ void File::OpenLinkFile(Kernel::HLERequestContext& ctx) {
slot->size = backend->GetSize();
slot->subfile = false;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMoveObjects(client);
}
@ -313,21 +313,21 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
if (original_file->subfile) {
// OpenSubFile can not be called on a file which is already as subfile
rb.Push(FileSys::ERROR_UNSUPPORTED_OPEN_FLAGS);
rb.Push(FileSys::ResultUnsupportedOpenFlags);
return;
}
if (offset < 0 || size < 0) {
rb.Push(FileSys::ERR_WRITE_BEYOND_END);
rb.Push(FileSys::ResultWriteBeyondEnd);
return;
}
std::size_t end = offset + size;
// TODO(Subv): Check for overflow and return ERR_WRITE_BEYOND_END
// TODO(Subv): Check for overflow and return ResultWriteBeyondEnd
if (end > original_file->size) {
rb.Push(FileSys::ERR_WRITE_BEYOND_END);
rb.Push(FileSys::ResultWriteBeyondEnd);
return;
}
@ -342,7 +342,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
slot->size = size;
slot->subfile = true;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMoveObjects(client);
}

View file

@ -43,7 +43,7 @@ void FS_USER::Initialize(Kernel::HLERequestContext& ctx) {
slot->program_id = system.Kernel().GetProcessById(pid)->codeset->program_id;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void FS_USER::OpenFile(Kernel::HLERequestContext& ctx) {
@ -349,7 +349,7 @@ void FS_USER::ControlArchive(Kernel::HLERequestContext& ctx) {
archive_handle, action, input_size, output_size);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void FS_USER::CloseArchive(Kernel::HLERequestContext& ctx) {
@ -363,14 +363,14 @@ void FS_USER::CloseArchive(Kernel::HLERequestContext& ctx) {
void FS_USER::IsSdmcDetected(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(Settings::values.use_virtual_sd.GetValue());
}
void FS_USER::IsSdmcWriteable(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
// If the SD isn't enabled, it can't be writeable...else, stubbed true
rb.Push(Settings::values.use_virtual_sd.GetValue());
LOG_DEBUG(Service_FS, " (STUBBED)");
@ -398,7 +398,7 @@ void FS_USER::FormatSaveData(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
if (archive_id != FS::ArchiveIdCode::SaveData) {
LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, {}", archive_id);
rb.Push(FileSys::ERROR_INVALID_PATH);
rb.Push(FileSys::ResultInvalidPath);
return;
}
@ -471,7 +471,7 @@ void FS_USER::GetSdmcArchiveResource(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(*resource);
}
@ -488,7 +488,7 @@ void FS_USER::GetNandArchiveResource(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(*resource);
}
@ -544,7 +544,7 @@ void FS_USER::DeleteExtSaveData(Kernel::HLERequestContext& ctx) {
void FS_USER::CardSlotIsInserted(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(false);
LOG_WARNING(Service_FS, "(STUBBED) called");
}
@ -614,7 +614,7 @@ void FS_USER::InitializeWithSdkVersion(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x{:08X}", version);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void FS_USER::SetPriority(Kernel::HLERequestContext& ctx) {
@ -623,7 +623,7 @@ void FS_USER::SetPriority(Kernel::HLERequestContext& ctx) {
priority = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_FS, "called priority=0x{:X}", priority);
}
@ -636,7 +636,7 @@ void FS_USER::GetPriority(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(priority);
LOG_DEBUG(Service_FS, "called priority=0x{:X}", priority);
@ -656,7 +656,7 @@ void FS_USER::GetArchiveResource(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(*resource);
}
@ -699,12 +699,12 @@ void FS_USER::GetProductInfo(Kernel::HLERequestContext& ctx) {
const auto product_info = GetProductInfo(process_id);
if (!product_info.has_value()) {
rb.Push(ResultCode(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Status));
rb.Push(Result(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Status));
return;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<ProductInfo>(product_info.value());
}
@ -737,7 +737,7 @@ void FS_USER::GetProgramLaunchInfo(Kernel::HLERequestContext& ctx) {
program_info.media_type = MediaType::SDMC;
}
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<ProgramInfo>(program_info);
}
@ -801,7 +801,7 @@ void FS_USER::GetSpecialContentIndex(Kernel::HLERequestContext& ctx) {
if (index.Succeeded()) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(index.Unwrap());
} else {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
@ -812,7 +812,7 @@ void FS_USER::GetSpecialContentIndex(Kernel::HLERequestContext& ctx) {
void FS_USER::GetNumSeeds(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(FileSys::GetSeedCount());
}
@ -822,7 +822,7 @@ void FS_USER::AddSeed(Kernel::HLERequestContext& ctx) {
FileSys::Seed::Data seed{rp.PopRaw<FileSys::Seed::Data>()};
FileSys::AddSeed({title_id, seed, {}});
IPC::RequestBuilder rb{rp.MakeBuilder(1, 0)};
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void FS_USER::ObsoletedSetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
@ -841,7 +841,7 @@ void FS_USER::ObsoletedSetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void FS_USER::ObsoletedGetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
@ -857,7 +857,7 @@ void FS_USER::ObsoletedGetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(4, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
// TODO: Implement Secure Value Lookup & Generation
@ -877,7 +877,7 @@ void FS_USER::SetThisSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void FS_USER::GetThisSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
@ -888,7 +888,7 @@ void FS_USER::GetThisSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
// TODO: Implement Secure Value Lookup & Generation
@ -913,7 +913,7 @@ void FS_USER::SetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void FS_USER::GetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
@ -926,7 +926,7 @@ void FS_USER::GetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
// TODO: Implement Secure Value Lookup & Generation
@ -966,7 +966,7 @@ ResultVal<u16> FS_USER::GetSpecialContentIndexFromGameCard(u64 title_id, Special
if (type > SpecialContentType::DLPChild) {
// Maybe type 4 is New 3DS update/partition 6 but this needs more research
// TODO(B3N30): Find correct result code
return ResultCode(-1);
return ResultUnknown;
}
switch (type) {
@ -985,7 +985,7 @@ ResultVal<u16> FS_USER::GetSpecialContentIndexFromTMD(MediaType media_type, u64
SpecialContentType type) {
if (type > SpecialContentType::DLPChild) {
// TODO(B3N30): Find correct result code
return ResultCode(-1);
return ResultUnknown;
}
std::string tmd_path = AM::GetTitleMetadataPath(media_type, title_id);
@ -993,7 +993,7 @@ ResultVal<u16> FS_USER::GetSpecialContentIndexFromTMD(MediaType media_type, u64
FileSys::TitleMetadata tmd;
if (tmd.Load(tmd_path) != Loader::ResultStatus::Success || type == SpecialContentType::Update) {
// TODO(B3N30): Find correct result code
return ResultCode(-1);
return ResultUnknown;
}
// TODO(B3N30): Does real 3DS check if content exists in TMD?
@ -1007,7 +1007,7 @@ ResultVal<u16> FS_USER::GetSpecialContentIndexFromTMD(MediaType media_type, u64
ASSERT(false);
}
return ResultCode(-1);
return ResultUnknown;
}
FS_USER::FS_USER(Core::System& system)

View file

@ -72,8 +72,8 @@ public:
if (info != program_info_map.end()) {
return info->second;
} else {
return ResultCode(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Status);
return Result(FileSys::ErrCodes::ArchiveNotMounted, ErrorModule::FS,
ErrorSummary::NotFound, ErrorLevel::Status);
}
}

View file

@ -37,18 +37,17 @@ enum {
};
}
constexpr ResultCode RESULT_FIRST_INITIALIZATION(ErrCodes::FirstInitialization, ErrorModule::GX,
ErrorSummary::Success, ErrorLevel::Success);
constexpr ResultCode ERR_REGS_OUTOFRANGE_OR_MISALIGNED(ErrCodes::OutofRangeOrMisalignedAddress,
ErrorModule::GX,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E02A01
constexpr ResultCode ERR_REGS_MISALIGNED(ErrorDescription::MisalignedSize, ErrorModule::GX,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E02BF2
constexpr ResultCode ERR_REGS_INVALID_SIZE(ErrorDescription::InvalidSize, ErrorModule::GX,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E02BEC
constexpr Result ResultFirstInitialization(ErrCodes::FirstInitialization, ErrorModule::GX,
ErrorSummary::Success, ErrorLevel::Success);
constexpr Result ResultRegsOutOfRangeOrMisaligned(ErrCodes::OutofRangeOrMisalignedAddress,
ErrorModule::GX, ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E02A01
constexpr Result ResultRegsMisaligned(ErrorDescription::MisalignedSize, ErrorModule::GX,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E02BF2
constexpr Result ResultRegsInvalidSize(ErrorDescription::InvalidSize, ErrorModule::GX,
ErrorSummary::InvalidArgument,
ErrorLevel::Usage); // 0xE0E02BEC
u32 GSP_GPU::GetUnusedThreadId() const {
for (u32 id = 0; id < MaxGSPThreads; ++id) {
@ -94,10 +93,10 @@ void GSP_GPU::ClientDisconnected(std::shared_ptr<Kernel::ServerSession> server_s
* @param base_address The address of the first register in the sequence
* @param size_in_bytes The number of registers to update (size of data)
* @param data A vector containing the source data
* @return RESULT_SUCCESS if the parameters are valid, error code otherwise
* @return ResultSuccess if the parameters are valid, error code otherwise
*/
static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, std::span<const u8> data,
VideoCore::GPU& gpu) {
static Result WriteHWRegs(u32 base_address, u32 size_in_bytes, std::span<const u8> data,
VideoCore::GPU& gpu) {
// This magic number is verified to be done by the gsp module
const u32 max_size_in_bytes = 0x80;
@ -105,17 +104,17 @@ static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, std::span<con
LOG_ERROR(Service_GSP,
"Write address was out of range or misaligned! (address=0x{:08x}, size=0x{:08x})",
base_address, size_in_bytes);
return ERR_REGS_OUTOFRANGE_OR_MISALIGNED;
return ResultRegsOutOfRangeOrMisaligned;
}
if (size_in_bytes > max_size_in_bytes) {
LOG_ERROR(Service_GSP, "Out of range size 0x{:08x}", size_in_bytes);
return ERR_REGS_INVALID_SIZE;
return ResultRegsInvalidSize;
}
if (size_in_bytes & 3) {
LOG_ERROR(Service_GSP, "Misaligned size 0x{:08x}", size_in_bytes);
return ERR_REGS_MISALIGNED;
return ResultRegsMisaligned;
}
std::size_t offset = 0;
@ -129,7 +128,7 @@ static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, std::span<con
base_address += 4;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
/**
@ -140,10 +139,10 @@ static ResultCode WriteHWRegs(u32 base_address, u32 size_in_bytes, std::span<con
* @param size_in_bytes The number of registers to update (size of data)
* @param data A vector containing the data to write
* @param masks A vector containing the masks
* @return RESULT_SUCCESS if the parameters are valid, error code otherwise
* @return ResultSuccess if the parameters are valid, error code otherwise
*/
static ResultCode WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, std::span<const u8> data,
std::span<const u8> masks, VideoCore::GPU& gpu) {
static Result WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, std::span<const u8> data,
std::span<const u8> masks, VideoCore::GPU& gpu) {
// This magic number is verified to be done by the gsp module
const u32 max_size_in_bytes = 0x80;
@ -151,17 +150,17 @@ static ResultCode WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, std::
LOG_ERROR(Service_GSP,
"Write address was out of range or misaligned! (address=0x{:08x}, size=0x{:08x})",
base_address, size_in_bytes);
return ERR_REGS_OUTOFRANGE_OR_MISALIGNED;
return ResultRegsOutOfRangeOrMisaligned;
}
if (size_in_bytes > max_size_in_bytes) {
LOG_ERROR(Service_GSP, "Out of range size 0x{:08x}", size_in_bytes);
return ERR_REGS_INVALID_SIZE;
return ResultRegsInvalidSize;
}
if (size_in_bytes & 3) {
LOG_ERROR(Service_GSP, "Misaligned size 0x{:08x}", size_in_bytes);
return ERR_REGS_MISALIGNED;
return ResultRegsMisaligned;
}
std::size_t offset = 0;
@ -182,7 +181,7 @@ static ResultCode WriteHWRegsWithMask(u32 base_address, u32 size_in_bytes, std::
base_address += 4;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void GSP_GPU::WriteHWRegs(Kernel::HLERequestContext& ctx) {
@ -216,7 +215,7 @@ void GSP_GPU::ReadHWRegs(Kernel::HLERequestContext& ctx) {
if ((reg_addr % 4) != 0 || reg_addr >= 0x420000) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERR_REGS_OUTOFRANGE_OR_MISALIGNED);
rb.Push(ResultRegsOutOfRangeOrMisaligned);
LOG_ERROR(Service_GSP, "Invalid address 0x{:08x}", reg_addr);
return;
}
@ -224,7 +223,7 @@ void GSP_GPU::ReadHWRegs(Kernel::HLERequestContext& ctx) {
// Size should be word-aligned
if ((size % 4) != 0) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERR_REGS_MISALIGNED);
rb.Push(ResultRegsMisaligned);
LOG_ERROR(Service_GSP, "Invalid size 0x{:08x}", size);
return;
}
@ -236,7 +235,7 @@ void GSP_GPU::ReadHWRegs(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushStaticBuffer(std::move(buffer), 0);
}
@ -248,7 +247,7 @@ void GSP_GPU::SetBufferSwap(Kernel::HLERequestContext& ctx) {
system.GPU().SetBufferSwap(screen_id, fb_info);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void GSP_GPU::FlushDataCache(Kernel::HLERequestContext& ctx) {
@ -260,7 +259,7 @@ void GSP_GPU::FlushDataCache(Kernel::HLERequestContext& ctx) {
// TODO(purpasmart96): Verify return header on HW
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_GSP, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address,
size, process->process_id);
@ -275,7 +274,7 @@ void GSP_GPU::InvalidateDataCache(Kernel::HLERequestContext& ctx) {
// TODO(purpasmart96): Verify return header on HW
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_GSP, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address,
size, process->process_id);
@ -286,7 +285,7 @@ void GSP_GPU::SetAxiConfigQoSMode(Kernel::HLERequestContext& ctx) {
u32 mode = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_GSP, "(STUBBED) called mode=0x{:08X}", mode);
}
@ -309,9 +308,9 @@ void GSP_GPU::RegisterInterruptRelayQueue(Kernel::HLERequestContext& ctx) {
if (first_initialization) {
// This specific code is required for a successful initialization, rather than 0
first_initialization = false;
rb.Push(RESULT_FIRST_INITIALIZATION);
rb.Push(ResultFirstInitialization);
} else {
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
rb.Push(session_data->thread_id);
@ -328,7 +327,7 @@ void GSP_GPU::UnregisterInterruptRelayQueue(Kernel::HLERequestContext& ctx) {
session_data->registered = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_GSP, "called");
}
@ -403,7 +402,7 @@ void GSP_GPU::SetLcdForceBlack(Kernel::HLERequestContext& ctx) {
system.GPU().SetColorFill(data);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void GSP_GPU::TriggerCmdReqQueue(Kernel::HLERequestContext& ctx) {
@ -423,7 +422,7 @@ void GSP_GPU::TriggerCmdReqQueue(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void GSP_GPU::ImportDisplayCaptureInfo(Kernel::HLERequestContext& ctx) {
@ -462,7 +461,7 @@ void GSP_GPU::ImportDisplayCaptureInfo(Kernel::HLERequestContext& ctx) {
bottom_entry.stride = bottom_screen->framebuffer_info[bottom_screen->index].stride;
IPC::RequestBuilder rb = rp.MakeBuilder(9, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(top_entry);
rb.PushRaw(bottom_entry);
@ -537,7 +536,7 @@ void GSP_GPU::SaveVramSysArea(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void GSP_GPU::RestoreVramSysArea(Kernel::HLERequestContext& ctx) {
@ -554,12 +553,12 @@ void GSP_GPU::RestoreVramSysArea(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
ResultCode GSP_GPU::AcquireGpuRight(const Kernel::HLERequestContext& ctx,
const std::shared_ptr<Kernel::Process>& process, u32 flag,
bool blocking) {
Result GSP_GPU::AcquireGpuRight(const Kernel::HLERequestContext& ctx,
const std::shared_ptr<Kernel::Process>& process, u32 flag,
bool blocking) {
const auto session_data = GetSessionData(ctx.Session());
LOG_DEBUG(Service_GSP, "called flag={:08X} process={} thread_id={}", flag, process->process_id,
@ -580,7 +579,7 @@ ResultCode GSP_GPU::AcquireGpuRight(const Kernel::HLERequestContext& ctx,
}
active_thread_id = session_data->thread_id;
return RESULT_SUCCESS;
return ResultSuccess;
}
void GSP_GPU::TryAcquireRight(Kernel::HLERequestContext& ctx) {
@ -617,7 +616,7 @@ void GSP_GPU::ReleaseRight(Kernel::HLERequestContext& ctx) {
ReleaseRight(session_data);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_GSP, "called");
}
@ -630,7 +629,7 @@ void GSP_GPU::StoreDataCache(Kernel::HLERequestContext& ctx) {
auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_GSP, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}", address,
size, process->process_id);
@ -644,7 +643,7 @@ void GSP_GPU::SetLedForceOff(Kernel::HLERequestContext& ctx) {
system.Kernel().GetSharedPageHandler().Set3DLed(state);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_GSP, "(STUBBED) called");
}
@ -654,7 +653,7 @@ void GSP_GPU::SetInternalPriorities(Kernel::HLERequestContext& ctx) {
const auto priority_with_rights = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_GSP, "(STUBBED) called priority={:#02X}, priority_with_rights={:#02X}",
priority, priority_with_rights);

View file

@ -366,9 +366,9 @@ private:
std::unique_ptr<Kernel::SessionRequestHandler::SessionDataBase> MakeSessionData() override;
ResultCode AcquireGpuRight(const Kernel::HLERequestContext& ctx,
const std::shared_ptr<Kernel::Process>& process, u32 flag,
bool blocking);
Result AcquireGpuRight(const Kernel::HLERequestContext& ctx,
const std::shared_ptr<Kernel::Process>& process, u32 flag,
bool blocking);
Core::System& system;

View file

@ -308,7 +308,7 @@ void Module::UpdateGyroscopeCallback(std::uintptr_t user_data, s64 cycles_late)
void Module::Interface::GetIPCHandles(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 7);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(hid->shared_mem, hid->event_pad_or_touch_1, hid->event_pad_or_touch_2,
hid->event_accelerometer, hid->event_gyroscope, hid->event_debug_pad);
}
@ -325,7 +325,7 @@ void Module::Interface::EnableAccelerometer(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_HID, "called");
}
@ -341,7 +341,7 @@ void Module::Interface::DisableAccelerometer(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_HID, "called");
}
@ -357,7 +357,7 @@ void Module::Interface::EnableGyroscopeLow(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_HID, "called");
}
@ -373,7 +373,7 @@ void Module::Interface::DisableGyroscopeLow(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_HID, "called");
}
@ -382,7 +382,7 @@ void Module::Interface::GetGyroscopeLowRawToDpsCoefficient(Kernel::HLERequestCon
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(gyroscope_coef);
}
@ -390,7 +390,7 @@ void Module::Interface::GetGyroscopeLowCalibrateParam(Kernel::HLERequestContext&
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(6, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
const s16 param_unit = 6700; // an approximate value taken from hw
GyroscopeCalibrateParam param = {
@ -409,7 +409,7 @@ void Module::Interface::GetSoundVolume(Kernel::HLERequestContext& ctx) {
const u8 volume = static_cast<u8>(0x3F * Settings::values.volume.GetValue());
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(volume);
}

View file

@ -45,25 +45,25 @@ enum {
};
}
const ResultCode ERROR_STATE_ERROR = // 0xD8A0A066
ResultCode(ErrCodes::SessionStateError, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
const ResultCode ERROR_NOT_IMPLEMENTED = // 0xD960A3F4
ResultCode(ErrCodes::NotImplemented, ErrorModule::HTTP, ErrorSummary::Internal,
ErrorLevel::Permanent);
const ResultCode ERROR_TOO_MANY_CLIENT_CERTS = // 0xD8A0A0CB
ResultCode(ErrCodes::TooManyClientCerts, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
const ResultCode ERROR_HEADER_NOT_FOUND = ResultCode(
ErrCodes::HeaderNotFound, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent);
const ResultCode ERROR_BUFFER_SMALL = ResultCode(ErrCodes::BufferTooSmall, ErrorModule::HTTP,
ErrorSummary::WouldBlock, ErrorLevel::Permanent);
const ResultCode ERROR_WRONG_CERT_ID = // 0xD8E0B839
ResultCode(57, ErrorModule::SSL, ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
const ResultCode ERROR_WRONG_CERT_HANDLE = // 0xD8A0A0C9
ResultCode(201, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent);
const ResultCode ERROR_CERT_ALREADY_SET = // 0xD8A0A03D
ResultCode(61, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent);
const Result ERROR_STATE_ERROR = // 0xD8A0A066
Result(ErrCodes::SessionStateError, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
const Result ERROR_NOT_IMPLEMENTED = // 0xD960A3F4
Result(ErrCodes::NotImplemented, ErrorModule::HTTP, ErrorSummary::Internal,
ErrorLevel::Permanent);
const Result ERROR_TOO_MANY_CLIENT_CERTS = // 0xD8A0A0CB
Result(ErrCodes::TooManyClientCerts, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
const Result ERROR_HEADER_NOT_FOUND = Result(ErrCodes::HeaderNotFound, ErrorModule::HTTP,
ErrorSummary::InvalidState, ErrorLevel::Permanent);
const Result ERROR_BUFFER_SMALL = Result(ErrCodes::BufferTooSmall, ErrorModule::HTTP,
ErrorSummary::WouldBlock, ErrorLevel::Permanent);
const Result ERROR_WRONG_CERT_ID = // 0xD8E0B839
Result(57, ErrorModule::SSL, ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
const Result ERROR_WRONG_CERT_HANDLE = // 0xD8A0A0C9
Result(201, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent);
const Result ERROR_CERT_ALREADY_SET = // 0xD8A0A03D
Result(61, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent);
// Splits URL into its components. Example: https://citra-emu.org:443/index.html
// is_https: true; host: citra-emu.org; port: 443; path: /index.html
@ -334,7 +334,7 @@ void HTTP_C::Initialize(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
// This returns 0xd8a0a046 if no network connection is available.
// Just assume we are always connected.
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::InitializeConnectionSession(Kernel::HLERequestContext& ctx) {
@ -358,8 +358,8 @@ void HTTP_C::InitializeConnectionSession(Kernel::HLERequestContext& ctx) {
auto itr = contexts.find(context_handle);
if (itr == contexts.end()) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::ContextNotFound, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::ContextNotFound, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
return;
}
@ -369,7 +369,7 @@ void HTTP_C::InitializeConnectionSession(Kernel::HLERequestContext& ctx) {
session_data->current_http_context = context_handle;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::BeginRequest(Kernel::HLERequestContext& ctx) {
@ -404,7 +404,7 @@ void HTTP_C::BeginRequest(Kernel::HLERequestContext& ctx) {
http_context.current_copied_data = 0;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::BeginRequestAsync(Kernel::HLERequestContext& ctx) {
@ -439,7 +439,7 @@ void HTTP_C::BeginRequestAsync(Kernel::HLERequestContext& ctx) {
http_context.current_copied_data = 0;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::ReceiveData(Kernel::HLERequestContext& ctx) {
@ -462,7 +462,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) {
Kernel::MappedBuffer* buffer;
bool is_complete;
// Output
ResultCode async_res = RESULT_SUCCESS;
Result async_res = ResultSuccess;
};
std::shared_ptr<AsyncData> async_data = std::make_shared<AsyncData>();
async_data->timeout = timeout;
@ -490,8 +490,8 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) {
std::chrono::nanoseconds(async_data->timeout_nanos));
if (wait_res == std::future_status::timeout) {
async_data->async_res =
ResultCode(105, ErrorModule::HTTP, ErrorSummary::NothingHappened,
ErrorLevel::Permanent);
Result(105, ErrorModule::HTTP, ErrorSummary::NothingHappened,
ErrorLevel::Permanent);
}
} else {
http_context.request_future.wait();
@ -502,7 +502,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) {
[this, async_data](Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb(ctx, static_cast<u16>(ctx.CommandHeader().command_id.Value()), 1,
0);
if (async_data->async_res != RESULT_SUCCESS) {
if (async_data->async_res != ResultSuccess) {
rb.Push(async_data->async_res);
return;
}
@ -516,7 +516,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) {
http_context.current_copied_data,
0, remaining_data);
http_context.current_copied_data += remaining_data;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
async_data->buffer->Write(http_context.response.body.data() +
http_context.current_copied_data,
@ -537,7 +537,7 @@ void HTTP_C::SetProxyDefault(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_HTTP, "(STUBBED) called, handle={}", context_handle);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) {
@ -562,8 +562,8 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_HTTP, "Command called with a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
rb.Push(Result(ErrorDescription::NotImplemented, ErrorModule::HTTP, ErrorSummary::Internal,
ErrorLevel::Permanent));
rb.PushMappedBuffer(buffer);
return;
}
@ -574,8 +574,8 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_HTTP, "Tried to open too many HTTP contexts");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::TooManyContexts, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::TooManyContexts, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
rb.PushMappedBuffer(buffer);
return;
}
@ -584,8 +584,8 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_HTTP, "invalid request method={}", method);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidRequestMethod, ErrorModule::HTTP,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidRequestMethod, ErrorModule::HTTP,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
rb.PushMappedBuffer(buffer);
return;
}
@ -602,7 +602,7 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) {
session_data->num_http_contexts++;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(context_counter);
rb.PushMappedBuffer(buffer);
}
@ -626,7 +626,7 @@ void HTTP_C::CloseContext(Kernel::HLERequestContext& ctx) {
if (itr == contexts.end()) {
// The real HTTP module just silently fails in this case.
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_ERROR(Service_HTTP, "called, context {} not found", context_handle);
return;
}
@ -639,7 +639,7 @@ void HTTP_C::CloseContext(Kernel::HLERequestContext& ctx) {
session_data->num_http_contexts--;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::CancelConnection(Kernel::HLERequestContext& ctx) {
@ -656,7 +656,7 @@ void HTTP_C::CancelConnection(Kernel::HLERequestContext& ctx) {
[[maybe_unused]] Context& http_context = GetContext(context_handle);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
@ -687,8 +687,8 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_HTTP,
"Tried to add a request header on a context that has already been started.");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidRequestState, ErrorModule::HTTP,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidRequestState, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
rb.PushMappedBuffer(value_buffer);
return;
}
@ -696,7 +696,7 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
http_context.headers.emplace_back(name, value);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(value_buffer);
}
@ -728,8 +728,8 @@ void HTTP_C::AddPostDataAscii(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_HTTP,
"Tried to add post data on a context that has already been started.");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidRequestState, ErrorModule::HTTP,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidRequestState, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
rb.PushMappedBuffer(value_buffer);
return;
}
@ -737,7 +737,7 @@ void HTTP_C::AddPostDataAscii(Kernel::HLERequestContext& ctx) {
http_context.post_data.emplace(name, value);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(value_buffer);
}
@ -760,8 +760,8 @@ void HTTP_C::AddPostDataRaw(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_HTTP,
"Tried to add post data on a context that has already been started.");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrCodes::InvalidRequestState, ErrorModule::HTTP,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidRequestState, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
rb.PushMappedBuffer(buffer);
return;
}
@ -770,7 +770,7 @@ void HTTP_C::AddPostDataRaw(Kernel::HLERequestContext& ctx) {
buffer.Read(http_context.post_data_raw.data(), 0, buffer.GetSize());
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
}
@ -836,7 +836,7 @@ void HTTP_C::GetResponseHeader(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb(ctx, static_cast<u16>(ctx.CommandHeader().command_id.Value()), 2,
2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(copied_size);
rb.PushMappedBuffer(*async_data->value_buffer);
});
@ -859,7 +859,7 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time
bool timeout;
u64 timeout_nanos = 0;
// Output
ResultCode async_res = RESULT_SUCCESS;
Result async_res = ResultSuccess;
};
std::shared_ptr<AsyncData> async_data = std::make_shared<AsyncData>();
@ -887,8 +887,8 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time
if (wait_res == std::future_status::timeout) {
LOG_DEBUG(Service_HTTP, "Status code: {}", "timeout");
async_data->async_res =
ResultCode(105, ErrorModule::HTTP, ErrorSummary::NothingHappened,
ErrorLevel::Permanent);
Result(105, ErrorModule::HTTP, ErrorSummary::NothingHappened,
ErrorLevel::Permanent);
}
} else {
http_context.request_future.wait();
@ -896,7 +896,7 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time
return 0;
},
[this, async_data](Kernel::HLERequestContext& ctx) {
if (async_data->async_res != RESULT_SUCCESS) {
if (async_data->async_res != ResultSuccess) {
IPC::RequestBuilder rb(
ctx, static_cast<u16>(ctx.CommandHeader().command_id.Value()), 1, 0);
rb.Push(async_data->async_res);
@ -910,7 +910,7 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time
IPC::RequestBuilder rb(ctx, static_cast<u16>(ctx.CommandHeader().command_id.Value()), 2,
0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(response_code);
});
}
@ -924,7 +924,7 @@ void HTTP_C::AddTrustedRootCA(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_HTTP, "(STUBBED) called, handle={}", context_handle);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(root_ca_data);
}
@ -937,7 +937,7 @@ void HTTP_C::AddDefaultCert(Kernel::HLERequestContext& ctx) {
certificate_id);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::SetDefaultClientCert(Kernel::HLERequestContext& ctx) {
@ -963,7 +963,7 @@ void HTTP_C::SetDefaultClientCert(Kernel::HLERequestContext& ctx) {
http_context.clcert_data = &GetClCertA();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::SetClientCertContext(Kernel::HLERequestContext& ctx) {
@ -1000,14 +1000,14 @@ void HTTP_C::SetClientCertContext(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_HTTP,
"Tried to set a client cert on a context that has already been started.");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::InvalidRequestState, ErrorModule::HTTP,
ErrorSummary::InvalidState, ErrorLevel::Permanent));
rb.Push(Result(ErrCodes::InvalidRequestState, ErrorModule::HTTP, ErrorSummary::InvalidState,
ErrorLevel::Permanent));
return;
}
http_context.ssl_config.client_cert_ctx = cert_context_itr->second;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::GetSSLError(Kernel::HLERequestContext& ctx) {
@ -1020,7 +1020,7 @@ void HTTP_C::GetSSLError(Kernel::HLERequestContext& ctx) {
[[maybe_unused]] Context& http_context = GetContext(context_handle);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
// Since we create the actual http/ssl context only when the request is submitted we can't check
// for SSL Errors here. Just submit no error.
rb.Push<u32>(0);
@ -1034,7 +1034,7 @@ void HTTP_C::SetSSLOpt(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_HTTP, "(STUBBED) called, context_handle={}, opts={}", context_handle, opts);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::OpenClientCertContext(Kernel::HLERequestContext& ctx) {
@ -1049,7 +1049,7 @@ void HTTP_C::OpenClientCertContext(Kernel::HLERequestContext& ctx) {
auto* session_data = GetSessionData(ctx.Session());
ASSERT(session_data);
ResultCode result(RESULT_SUCCESS);
Result result(ResultSuccess);
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Command called without Initialize");
@ -1114,7 +1114,7 @@ void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
if (!ClCertA.init) {
LOG_ERROR(Service_HTTP, "called but ClCertA is missing");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(static_cast<ResultCode>(-1));
rb.Push(static_cast<Result>(-1));
return;
}
@ -1126,7 +1126,7 @@ void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
if (it != client_certs.end()) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(it->first);
LOG_DEBUG(Service_HTTP, "called, with an already loaded cert_id={}", cert_id);
@ -1141,7 +1141,7 @@ void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
++session_data->num_client_certs;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(client_certs_counter);
}
@ -1158,7 +1158,7 @@ void HTTP_C::CloseClientCertContext(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_HTTP, "Command called with a unkown client cert handle {}", cert_handle);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
// This just return success without doing anything
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
return;
}
@ -1166,7 +1166,7 @@ void HTTP_C::CloseClientCertContext(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_HTTP, "called from another main session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
// This just return success without doing anything
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
return;
}
@ -1174,7 +1174,7 @@ void HTTP_C::CloseClientCertContext(Kernel::HLERequestContext& ctx) {
session_data->num_client_certs--;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::SetKeepAlive(Kernel::HLERequestContext& ctx) {
@ -1185,7 +1185,7 @@ void HTTP_C::SetKeepAlive(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_HTTP, "(STUBBED) called, handle={}, option={}", context_handle, option);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void HTTP_C::Finalize(Kernel::HLERequestContext& ctx) {
@ -1194,7 +1194,7 @@ void HTTP_C::Finalize(Kernel::HLERequestContext& ctx) {
shared_memory = nullptr;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_HTTP, "(STUBBED) called");
}
@ -1230,7 +1230,7 @@ void HTTP_C::GetDownloadSizeState(Kernel::HLERequestContext& ctx) {
content_length);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(static_cast<u32>(http_context.current_copied_data));
rb.Push(content_length);
}
@ -1262,8 +1262,8 @@ bool HTTP_C::PerformStateChecks(Kernel::HLERequestContext& ctx, IPC::RequestPars
LOG_ERROR(Service_HTTP, "Tried to make a request without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
rb.Push(Result(ErrorDescription::NotImplemented, ErrorModule::HTTP, ErrorSummary::Internal,
ErrorLevel::Permanent));
return false;
}

View file

@ -130,7 +130,7 @@ void IR_RST::UpdateCallback(std::uintptr_t user_data, s64 cycles_late) {
void IR_RST::GetHandles(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 3);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMoveObjects(shared_memory, update_event);
}
@ -147,7 +147,7 @@ void IR_RST::Initialize(Kernel::HLERequestContext& ctx) {
system.CoreTiming().ScheduleEvent(msToCycles(update_period), update_callback_id);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_IR, "called. update_period={}, raw_c_stick={}", update_period, raw_c_stick);
}
@ -159,7 +159,7 @@ void IR_RST::Shutdown(Kernel::HLERequestContext& ctx) {
UnloadInputDevices();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_IR, "called");
}

View file

@ -293,7 +293,7 @@ void IR_USER::InitializeIrNopShared(Kernel::HLERequestContext& ctx) {
shared_memory_init.initialized = 1;
std::memcpy(shared_memory->GetPointer(), &shared_memory_init, sizeof(SharedMemoryHeader));
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_INFO(Service_IR,
"called, shared_buff_size={}, recv_buff_size={}, "
@ -325,7 +325,7 @@ void IR_USER::RequireConnection(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_INFO(Service_IR, "called, device_id = {}", device_id);
}
@ -333,7 +333,7 @@ void IR_USER::RequireConnection(Kernel::HLERequestContext& ctx) {
void IR_USER::GetReceiveEvent(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb(ctx, 0x0A, 1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(receive_event);
LOG_INFO(Service_IR, "called");
@ -342,7 +342,7 @@ void IR_USER::GetReceiveEvent(Kernel::HLERequestContext& ctx) {
void IR_USER::GetSendEvent(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb(ctx, 0x0B, 1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(send_event);
LOG_INFO(Service_IR, "called");
@ -360,7 +360,7 @@ void IR_USER::Disconnect(Kernel::HLERequestContext& ctx) {
shared_memory_ptr[offsetof(SharedMemoryHeader, connected)] = 0;
IPC::RequestBuilder rb(ctx, 0x09, 1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_INFO(Service_IR, "called");
}
@ -368,7 +368,7 @@ void IR_USER::Disconnect(Kernel::HLERequestContext& ctx) {
void IR_USER::GetConnectionStatusEvent(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb(ctx, 0x0C, 1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(conn_status_event);
LOG_INFO(Service_IR, "called");
@ -384,7 +384,7 @@ void IR_USER::FinalizeIrNop(Kernel::HLERequestContext& ctx) {
receive_buffer = nullptr;
IPC::RequestBuilder rb(ctx, 0x02, 1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_INFO(Service_IR, "called");
}
@ -399,11 +399,11 @@ void IR_USER::SendIrNop(Kernel::HLERequestContext& ctx) {
if (connected_device) {
extra_hid->OnReceive(buffer);
send_event->Signal();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_IR, "not connected");
rb.Push(ResultCode(static_cast<ErrorDescription>(13), ErrorModule::IR,
ErrorSummary::InvalidState, ErrorLevel::Status));
rb.Push(Result(static_cast<ErrorDescription>(13), ErrorModule::IR,
ErrorSummary::InvalidState, ErrorLevel::Status));
}
LOG_TRACE(Service_IR, "called, data={}", fmt::format("{:02x}", fmt::join(buffer, " ")));
@ -416,11 +416,11 @@ void IR_USER::ReleaseReceivedData(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
if (receive_buffer->Release(count)) {
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
} else {
LOG_ERROR(Service_IR, "failed to release {} packets", count);
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::IR, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NoData, ErrorModule::IR, ErrorSummary::NotFound,
ErrorLevel::Status));
}
LOG_TRACE(Service_IR, "called, count={}", count);

View file

@ -12,13 +12,13 @@
namespace Service::LDR {
static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument,
ErrorLevel::Usage);
static const Result ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
Result(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument,
ErrorLevel::Usage);
static constexpr ResultCode CROFormatError(u32 description) {
return ResultCode(static_cast<ErrorDescription>(description), ErrorModule::RO,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
static constexpr Result CROFormatError(u32 description) {
return Result(static_cast<ErrorDescription>(description), ErrorModule::RO,
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
}
const std::array<int, 17> CROHelper::ENTRY_SIZE{{
@ -63,8 +63,8 @@ VAddr CROHelper::SegmentTagToAddress(SegmentTag segment_tag) const {
return entry.offset + segment_tag.offset_into_segment;
}
ResultCode CROHelper::ApplyRelocation(VAddr target_address, RelocationType relocation_type,
u32 addend, u32 symbol_address, u32 target_future_address) {
Result CROHelper::ApplyRelocation(VAddr target_address, RelocationType relocation_type, u32 addend,
u32 symbol_address, u32 target_future_address) {
switch (relocation_type) {
case RelocationType::Nothing:
@ -88,10 +88,10 @@ ResultCode CROHelper::ApplyRelocation(VAddr target_address, RelocationType reloc
default:
return CROFormatError(0x22);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ClearRelocation(VAddr target_address, RelocationType relocation_type) {
Result CROHelper::ClearRelocation(VAddr target_address, RelocationType relocation_type) {
switch (relocation_type) {
case RelocationType::Nothing:
break;
@ -111,10 +111,10 @@ ResultCode CROHelper::ClearRelocation(VAddr target_address, RelocationType reloc
default:
return CROFormatError(0x22);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset) {
Result CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset) {
if (symbol_address == 0 && !reset)
return CROFormatError(0x10);
@ -129,8 +129,8 @@ ResultCode CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool
return CROFormatError(0x12);
}
ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
symbol_address, relocation_target);
Result result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
symbol_address, relocation_target);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation {:08X}", result.raw);
return result;
@ -146,7 +146,7 @@ ResultCode CROHelper::ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool
system.Memory().ReadBlock(process, batch, &relocation, sizeof(RelocationEntry));
relocation.is_batch_resolved = reset ? 0 : 1;
system.Memory().WriteBlock(process, batch, &relocation, sizeof(RelocationEntry));
return RESULT_SUCCESS;
return ResultSuccess;
}
VAddr CROHelper::FindExportNamedSymbol(const std::string& name) const {
@ -195,8 +195,8 @@ VAddr CROHelper::FindExportNamedSymbol(const std::string& name) const {
return SegmentTagToAddress(symbol_entry.symbol_position);
}
ResultCode CROHelper::RebaseHeader(u32 cro_size) {
ResultCode error = CROFormatError(0x11);
Result CROHelper::RebaseHeader(u32 cro_size) {
Result error = CROFormatError(0x11);
// verifies magic
if (GetField(Magic) != MAGIC_CRO0)
@ -269,7 +269,7 @@ ResultCode CROHelper::RebaseHeader(u32 cro_size) {
return error;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultVal<VAddr> CROHelper::RebaseSegmentTable(u32 cro_size, VAddr data_segment_address,
@ -304,7 +304,7 @@ ResultVal<VAddr> CROHelper::RebaseSegmentTable(u32 cro_size, VAddr data_segment_
return prev_data_segment + module_address;
}
ResultCode CROHelper::RebaseExportNamedSymbolTable() {
Result CROHelper::RebaseExportNamedSymbolTable() {
VAddr export_strings_offset = GetField(ExportStringsOffset);
VAddr export_strings_end = export_strings_offset + GetField(ExportStringsSize);
@ -323,10 +323,10 @@ ResultCode CROHelper::RebaseExportNamedSymbolTable() {
SetEntry(system.Memory(), i, entry);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::VerifyExportTreeTable() const {
Result CROHelper::VerifyExportTreeTable() const {
u32 tree_num = GetField(ExportTreeNum);
for (u32 i = 0; i < tree_num; ++i) {
ExportTreeEntry entry;
@ -336,10 +336,10 @@ ResultCode CROHelper::VerifyExportTreeTable() const {
return CROFormatError(0x11);
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::RebaseImportModuleTable() {
Result CROHelper::RebaseImportModuleTable() {
VAddr import_strings_offset = GetField(ImportStringsOffset);
VAddr import_strings_end = import_strings_offset + GetField(ImportStringsSize);
VAddr import_indexed_symbol_table_offset = GetField(ImportIndexedSymbolTableOffset);
@ -382,10 +382,10 @@ ResultCode CROHelper::RebaseImportModuleTable() {
SetEntry(system.Memory(), i, entry);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::RebaseImportNamedSymbolTable() {
Result CROHelper::RebaseImportNamedSymbolTable() {
VAddr import_strings_offset = GetField(ImportStringsOffset);
VAddr import_strings_end = import_strings_offset + GetField(ImportStringsSize);
VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset);
@ -416,10 +416,10 @@ ResultCode CROHelper::RebaseImportNamedSymbolTable() {
SetEntry(system.Memory(), i, entry);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::RebaseImportIndexedSymbolTable() {
Result CROHelper::RebaseImportIndexedSymbolTable() {
VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset);
VAddr external_relocation_table_end =
external_relocation_table_offset +
@ -440,10 +440,10 @@ ResultCode CROHelper::RebaseImportIndexedSymbolTable() {
SetEntry(system.Memory(), i, entry);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::RebaseImportAnonymousSymbolTable() {
Result CROHelper::RebaseImportAnonymousSymbolTable() {
VAddr external_relocation_table_offset = GetField(ExternalRelocationTableOffset);
VAddr external_relocation_table_end =
external_relocation_table_offset +
@ -464,14 +464,14 @@ ResultCode CROHelper::RebaseImportAnonymousSymbolTable() {
SetEntry(system.Memory(), i, entry);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
VAddr CROHelper::GetOnUnresolvedAddress() {
return SegmentTagToAddress(SegmentTag(GetField(OnUnresolvedSegmentTag)));
}
ResultCode CROHelper::ResetExternalRelocations() {
Result CROHelper::ResetExternalRelocations() {
u32 unresolved_symbol = GetOnUnresolvedAddress();
u32 external_relocation_num = GetField(ExternalRelocationNum);
ExternalRelocationEntry relocation;
@ -491,8 +491,8 @@ ResultCode CROHelper::ResetExternalRelocations() {
return CROFormatError(0x12);
}
ResultCode result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
unresolved_symbol, relocation_target);
Result result = ApplyRelocation(relocation_target, relocation.type, relocation.addend,
unresolved_symbol, relocation_target);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation {:08X}", result.raw);
return result;
@ -508,10 +508,10 @@ ResultCode CROHelper::ResetExternalRelocations() {
batch_begin = relocation.is_batch_end != 0;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ClearExternalRelocations() {
Result CROHelper::ClearExternalRelocations() {
u32 external_relocation_num = GetField(ExternalRelocationNum);
ExternalRelocationEntry relocation;
@ -524,7 +524,7 @@ ResultCode CROHelper::ClearExternalRelocations() {
return CROFormatError(0x12);
}
ResultCode result = ClearRelocation(relocation_target, relocation.type);
Result result = ClearRelocation(relocation_target, relocation.type);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error clearing relocation {:08X}", result.raw);
return result;
@ -540,10 +540,10 @@ ResultCode CROHelper::ClearExternalRelocations() {
batch_begin = relocation.is_batch_end != 0;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) {
Result CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) {
VAddr static_relocation_table_offset = GetField(StaticRelocationTableOffset);
VAddr static_relocation_table_end =
static_relocation_table_offset +
@ -566,16 +566,16 @@ ResultCode CROHelper::ApplyStaticAnonymousSymbolToCRS(VAddr crs_address) {
u32 symbol_address = SegmentTagToAddress(entry.symbol_position);
LOG_TRACE(Service_LDR, "CRO \"{}\" exports 0x{:08X} to the static module", ModuleName(),
symbol_address);
ResultCode result = crs.ApplyRelocationBatch(batch_address, symbol_address);
Result result = crs.ApplyRelocationBatch(batch_address, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
return result;
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) {
Result CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) {
u32 segment_num = GetField(SegmentNum);
u32 internal_relocation_num = GetField(InternalRelocationNum);
for (u32 i = 0; i < internal_relocation_num; ++i) {
@ -606,17 +606,17 @@ ResultCode CROHelper::ApplyInternalRelocations(u32 old_data_segment_address) {
GetEntry(system.Memory(), relocation.symbol_segment, symbol_segment);
LOG_TRACE(Service_LDR, "Internally relocates 0x{:08X} with 0x{:08X}", target_address,
symbol_segment.offset);
ResultCode result = ApplyRelocation(target_address, relocation.type, relocation.addend,
symbol_segment.offset, target_addressB);
Result result = ApplyRelocation(target_address, relocation.type, relocation.addend,
symbol_segment.offset, target_addressB);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation {:08X}", result.raw);
return result;
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ClearInternalRelocations() {
Result CROHelper::ClearInternalRelocations() {
u32 internal_relocation_num = GetField(InternalRelocationNum);
for (u32 i = 0; i < internal_relocation_num; ++i) {
InternalRelocationEntry relocation;
@ -627,13 +627,13 @@ ResultCode CROHelper::ClearInternalRelocations() {
return CROFormatError(0x15);
}
ResultCode result = ClearRelocation(target_address, relocation.type);
Result result = ClearRelocation(target_address, relocation.type);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error clearing relocation {:08X}", result.raw);
return result;
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void CROHelper::UnrebaseImportAnonymousSymbolTable() {
@ -747,7 +747,7 @@ void CROHelper::UnrebaseHeader() {
}
}
ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) {
Result CROHelper::ApplyImportNamedSymbol(VAddr crs_address) {
u32 import_strings_size = GetField(ImportStringsSize);
u32 symbol_import_num = GetField(ImportNamedSymbolNum);
for (u32 i = 0; i < symbol_import_num; ++i) {
@ -759,7 +759,7 @@ ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) {
sizeof(ExternalRelocationEntry));
if (!relocation_entry.is_batch_resolved) {
ResultCode result = ForEachAutoLinkCRO(
Result result = ForEachAutoLinkCRO(
process, system, crs_address, [&](CROHelper source) -> ResultVal<bool> {
std::string symbol_name =
system.Memory().ReadCString(entry.name_offset, import_strings_size);
@ -769,7 +769,7 @@ ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) {
LOG_TRACE(Service_LDR, "CRO \"{}\" imports \"{}\" from \"{}\"",
ModuleName(), symbol_name, source.ModuleName());
ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
Result result = ApplyRelocationBatch(relocation_addr, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}",
result.raw);
@ -786,10 +786,10 @@ ResultCode CROHelper::ApplyImportNamedSymbol(VAddr crs_address) {
}
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ResetImportNamedSymbol() {
Result CROHelper::ResetImportNamedSymbol() {
u32 unresolved_symbol = GetOnUnresolvedAddress();
u32 symbol_import_num = GetField(ImportNamedSymbolNum);
@ -801,16 +801,16 @@ ResultCode CROHelper::ResetImportNamedSymbol() {
system.Memory().ReadBlock(process, relocation_addr, &relocation_entry,
sizeof(ExternalRelocationEntry));
ResultCode result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
Result result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error reseting relocation batch {:08X}", result.raw);
return result;
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ResetImportIndexedSymbol() {
Result CROHelper::ResetImportIndexedSymbol() {
u32 unresolved_symbol = GetOnUnresolvedAddress();
u32 import_num = GetField(ImportIndexedSymbolNum);
@ -822,16 +822,16 @@ ResultCode CROHelper::ResetImportIndexedSymbol() {
system.Memory().ReadBlock(process, relocation_addr, &relocation_entry,
sizeof(ExternalRelocationEntry));
ResultCode result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
Result result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error reseting relocation batch {:08X}", result.raw);
return result;
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ResetImportAnonymousSymbol() {
Result CROHelper::ResetImportAnonymousSymbol() {
u32 unresolved_symbol = GetOnUnresolvedAddress();
u32 import_num = GetField(ImportAnonymousSymbolNum);
@ -843,16 +843,16 @@ ResultCode CROHelper::ResetImportAnonymousSymbol() {
system.Memory().ReadBlock(process, relocation_addr, &relocation_entry,
sizeof(ExternalRelocationEntry));
ResultCode result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
Result result = ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error reseting relocation batch {:08X}", result.raw);
return result;
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
Result CROHelper::ApplyModuleImport(VAddr crs_address) {
u32 import_strings_size = GetField(ImportStringsSize);
u32 import_module_num = GetField(ImportModuleNum);
@ -862,7 +862,7 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
std::string want_cro_name =
system.Memory().ReadCString(entry.name_offset, import_strings_size);
ResultCode result = ForEachAutoLinkCRO(
Result result = ForEachAutoLinkCRO(
process, system, crs_address, [&](CROHelper source) -> ResultVal<bool> {
if (want_cro_name == source.ModuleName()) {
LOG_INFO(Service_LDR, "CRO \"{}\" imports {} indexed symbols from \"{}\"",
@ -874,7 +874,7 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
source.GetEntry(system.Memory(), im.index, ex);
u32 symbol_address = source.SegmentTagToAddress(ex.symbol_position);
LOG_TRACE(Service_LDR, " Imports 0x{:08X}", symbol_address);
ResultCode result =
Result result =
ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}",
@ -889,7 +889,7 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
entry.GetImportAnonymousSymbolEntry(process, system.Memory(), j, im);
u32 symbol_address = source.SegmentTagToAddress(im.symbol_position);
LOG_TRACE(Service_LDR, " Imports 0x{:08X}", symbol_address);
ResultCode result =
Result result =
ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}",
@ -905,10 +905,10 @@ ResultCode CROHelper::ApplyModuleImport(VAddr crs_address) {
return result;
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
Result CROHelper::ApplyExportNamedSymbol(CROHelper target) {
LOG_DEBUG(Service_LDR, "CRO \"{}\" exports named symbols to \"{}\"", ModuleName(),
target.ModuleName());
u32 target_import_strings_size = target.GetField(ImportStringsSize);
@ -927,7 +927,7 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
u32 symbol_address = FindExportNamedSymbol(symbol_name);
if (symbol_address != 0) {
LOG_TRACE(Service_LDR, " exports symbol \"{}\"", symbol_name);
ResultCode result = target.ApplyRelocationBatch(relocation_addr, symbol_address);
Result result = target.ApplyRelocationBatch(relocation_addr, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
return result;
@ -935,10 +935,10 @@ ResultCode CROHelper::ApplyExportNamedSymbol(CROHelper target) {
}
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) {
Result CROHelper::ResetExportNamedSymbol(CROHelper target) {
LOG_DEBUG(Service_LDR, "CRO \"{}\" unexports named symbols to \"{}\"", ModuleName(),
target.ModuleName());
u32 unresolved_symbol = target.GetOnUnresolvedAddress();
@ -958,7 +958,7 @@ ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) {
u32 symbol_address = FindExportNamedSymbol(symbol_name);
if (symbol_address != 0) {
LOG_TRACE(Service_LDR, " unexports symbol \"{}\"", symbol_name);
ResultCode result =
Result result =
target.ApplyRelocationBatch(relocation_addr, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
@ -967,10 +967,10 @@ ResultCode CROHelper::ResetExportNamedSymbol(CROHelper target) {
}
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
Result CROHelper::ApplyModuleExport(CROHelper target) {
std::string module_name = ModuleName();
u32 target_import_string_size = target.GetField(ImportStringsSize);
u32 target_import_module_num = target.GetField(ImportModuleNum);
@ -991,8 +991,7 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
GetEntry(system.Memory(), im.index, ex);
u32 symbol_address = SegmentTagToAddress(ex.symbol_position);
LOG_TRACE(Service_LDR, " exports symbol 0x{:08X}", symbol_address);
ResultCode result =
target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
Result result = target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
return result;
@ -1006,8 +1005,7 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
entry.GetImportAnonymousSymbolEntry(process, system.Memory(), j, im);
u32 symbol_address = SegmentTagToAddress(im.symbol_position);
LOG_TRACE(Service_LDR, " exports symbol 0x{:08X}", symbol_address);
ResultCode result =
target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
Result result = target.ApplyRelocationBatch(im.relocation_batch_offset, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
return result;
@ -1015,10 +1013,10 @@ ResultCode CROHelper::ApplyModuleExport(CROHelper target) {
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ResetModuleExport(CROHelper target) {
Result CROHelper::ResetModuleExport(CROHelper target) {
u32 unresolved_symbol = target.GetOnUnresolvedAddress();
std::string module_name = ModuleName();
@ -1037,7 +1035,7 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) {
for (u32 j = 0; j < entry.import_indexed_symbol_num; ++j) {
ImportIndexedSymbolEntry im;
entry.GetImportIndexedSymbolEntry(process, system.Memory(), j, im);
ResultCode result =
Result result =
target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
@ -1050,7 +1048,7 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) {
for (u32 j = 0; j < entry.import_anonymous_symbol_num; ++j) {
ImportAnonymousSymbolEntry im;
entry.GetImportAnonymousSymbolEntry(process, system.Memory(), j, im);
ResultCode result =
Result result =
target.ApplyRelocationBatch(im.relocation_batch_offset, unresolved_symbol, true);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}", result.raw);
@ -1059,10 +1057,10 @@ ResultCode CROHelper::ResetModuleExport(CROHelper target) {
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) {
Result CROHelper::ApplyExitRelocations(VAddr crs_address) {
u32 import_strings_size = GetField(ImportStringsSize);
u32 symbol_import_num = GetField(ImportNamedSymbolNum);
for (u32 i = 0; i < symbol_import_num; ++i) {
@ -1075,7 +1073,7 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) {
if (system.Memory().ReadCString(entry.name_offset, import_strings_size) ==
"__aeabi_atexit") {
ResultCode result = ForEachAutoLinkCRO(
Result result = ForEachAutoLinkCRO(
process, system, crs_address, [&](CROHelper source) -> ResultVal<bool> {
u32 symbol_address = source.FindExportNamedSymbol("nnroAeabiAtexit_");
@ -1083,7 +1081,7 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) {
LOG_DEBUG(Service_LDR, "CRO \"{}\" import exit function from \"{}\"",
ModuleName(), source.ModuleName());
ResultCode result = ApplyRelocationBatch(relocation_addr, symbol_address);
Result result = ApplyRelocationBatch(relocation_addr, symbol_address);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error applying relocation batch {:08X}",
result.raw);
@ -1101,7 +1099,7 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) {
}
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
/**
@ -1111,21 +1109,21 @@ ResultCode CROHelper::ApplyExitRelocations(VAddr crs_address) {
* whole string (table) is terminated properly, despite that it is not actually one string.
* @param address the virtual address of the string (table)
* @param size the size of the string (table), including the terminating 0
* @returns ResultCode RESULT_SUCCESS if the size matches, otherwise error code.
* @returns Result ResultSuccess if the size matches, otherwise error code.
*/
static ResultCode VerifyStringTableLength(Memory::MemorySystem& memory, VAddr address, u32 size) {
static Result VerifyStringTableLength(Memory::MemorySystem& memory, VAddr address, u32 size) {
if (size != 0) {
if (memory.Read8(address + size - 1) != 0)
return CROFormatError(0x0B);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_addresss,
u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size,
bool is_crs) {
Result CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_addresss,
u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size,
bool is_crs) {
ResultCode result = RebaseHeader(cro_size);
Result result = RebaseHeader(cro_size);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error rebasing header {:08X}", result.raw);
return result;
@ -1227,7 +1225,7 @@ ResultCode CROHelper::Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment
}
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void CROHelper::Unrebase(bool is_crs) {
@ -1248,13 +1246,13 @@ void CROHelper::Unrebase(bool is_crs) {
UnrebaseHeader();
}
ResultCode CROHelper::VerifyHash(u32 cro_size, VAddr crr) const {
Result CROHelper::VerifyHash(u32 cro_size, VAddr crr) const {
// TODO(wwylele): actually verify the hash
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) {
ResultCode result = RESULT_SUCCESS;
Result CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) {
Result result = ResultSuccess;
{
VAddr data_segment_address = 0;
@ -1309,7 +1307,7 @@ ResultCode CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) {
// Exports symbols to other modules
result = ForEachAutoLinkCRO(process, system, crs_address,
[this](CROHelper target) -> ResultVal<bool> {
ResultCode result = ApplyExportNamedSymbol(target);
Result result = ApplyExportNamedSymbol(target);
if (result.IsError())
return result;
@ -1324,13 +1322,13 @@ ResultCode CROHelper::Link(VAddr crs_address, bool link_on_load_bug_fix) {
return result;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::Unlink(VAddr crs_address) {
Result CROHelper::Unlink(VAddr crs_address) {
// Resets all imported named symbols
ResultCode result = ResetImportNamedSymbol();
Result result = ResetImportNamedSymbol();
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error resetting symbol import {:08X}", result.raw);
return result;
@ -1354,7 +1352,7 @@ ResultCode CROHelper::Unlink(VAddr crs_address) {
// Note: the RO service seems only searching in auto-link modules
result = ForEachAutoLinkCRO(process, system, crs_address,
[this](CROHelper target) -> ResultVal<bool> {
ResultCode result = ResetExportNamedSymbol(target);
Result result = ResetExportNamedSymbol(target);
if (result.IsError())
return result;
@ -1369,11 +1367,11 @@ ResultCode CROHelper::Unlink(VAddr crs_address) {
return result;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode CROHelper::ClearRelocations() {
ResultCode result = ClearExternalRelocations();
Result CROHelper::ClearRelocations() {
Result result = ClearExternalRelocations();
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error clearing external relocations {:08X}", result.raw);
return result;
@ -1384,7 +1382,7 @@ ResultCode CROHelper::ClearRelocations() {
LOG_ERROR(Service_LDR, "Error clearing internal relocations {:08X}", result.raw);
return result;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void CROHelper::InitCRS() {

View file

@ -51,11 +51,11 @@ public:
* @param bss_segment_address the buffer address for .bss segment
* @param bss_segment_size the buffer size for .bss segment
* @param is_crs true if the module itself is the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_address,
u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size,
bool is_crs);
Result Rebase(VAddr crs_address, u32 cro_size, VAddr data_segment_address,
u32 data_segment_size, VAddr bss_segment_address, u32 bss_segment_size,
bool is_crs);
/**
* Unrebases the module.
@ -67,30 +67,30 @@ public:
* Verifies module hash by CRR.
* @param cro_size the size of the CRO
* @param crr the virtual address of the CRR
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode VerifyHash(u32 cro_size, VAddr crr) const;
Result VerifyHash(u32 cro_size, VAddr crr) const;
/**
* Links this module with all registered auto-link module.
* @param crs_address the virtual address of the static module
* @param link_on_load_bug_fix true if links when loading and fixes the bug
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode Link(VAddr crs_address, bool link_on_load_bug_fix);
Result Link(VAddr crs_address, bool link_on_load_bug_fix);
/**
* Unlinks this module with other modules.
* @param crs_address the virtual address of the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode Unlink(VAddr crs_address);
Result Unlink(VAddr crs_address);
/**
* Clears all relocations to zero.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ClearRelocations();
Result ClearRelocations();
/// Initialize this module as the static module (CRS)
void InitCRS();
@ -465,13 +465,13 @@ private:
* CROHelper and returns ResultVal<bool>. It should return true to continue the
* iteration,
* false to stop the iteration, or an error code (which will also stop the iteration).
* @returns ResultCode indicating the result of the operation, RESULT_SUCCESS if all iteration
* @returns Result indicating the result of the operation, ResultSuccess if all iteration
* success,
* otherwise error code of the last iteration.
*/
template <typename FunctionObject>
static ResultCode ForEachAutoLinkCRO(Kernel::Process& process, Core::System& system,
VAddr crs_address, FunctionObject func) {
static Result ForEachAutoLinkCRO(Kernel::Process& process, Core::System& system,
VAddr crs_address, FunctionObject func) {
VAddr current = crs_address;
while (current != 0) {
CROHelper cro(current, process, system);
@ -480,7 +480,7 @@ private:
break;
current = cro.NextModule();
}
return RESULT_SUCCESS;
return ResultSuccess;
}
/**
@ -491,18 +491,18 @@ private:
* @param symbol_address the symbol address to be relocated with
* @param target_future_address the future address of the target.
* Usually equals to target_address, but will be different for a target in .data segment
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ApplyRelocation(VAddr target_address, RelocationType relocation_type, u32 addend,
u32 symbol_address, u32 target_future_address);
Result ApplyRelocation(VAddr target_address, RelocationType relocation_type, u32 addend,
u32 symbol_address, u32 target_future_address);
/**
* Clears a relocation to zero
* @param target_address where to apply the relocation
* @param relocation_type the type of the relocation
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ClearRelocation(VAddr target_address, RelocationType relocation_type);
Result ClearRelocation(VAddr target_address, RelocationType relocation_type);
/**
* Applies or resets a batch of relocations
@ -510,9 +510,9 @@ private:
* @param symbol_address the symbol address to be relocated with
* @param reset false to set the batch to resolved state, true to reset the batch to unresolved
* state
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset = false);
Result ApplyRelocationBatch(VAddr batch, u32 symbol_address, bool reset = false);
/**
* Finds an exported named symbol in this module.
@ -524,10 +524,10 @@ private:
/**
* Rebases offsets in module header according to module address.
* @param cro_size the size of the CRO file
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* @returns Result ResultSuccess if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseHeader(u32 cro_size);
Result RebaseHeader(u32 cro_size);
/**
* Rebases offsets in segment table according to module address.
@ -544,45 +544,45 @@ private:
/**
* Rebases offsets in exported named symbol table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* @returns Result ResultSuccess if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseExportNamedSymbolTable();
Result RebaseExportNamedSymbolTable();
/**
* Verifies indices in export tree table.
* @returns ResultCode RESULT_SUCCESS if all indices are verified as valid, otherwise error
* @returns Result ResultSuccess if all indices are verified as valid, otherwise error
* code.
*/
ResultCode VerifyExportTreeTable() const;
Result VerifyExportTreeTable() const;
/**
* Rebases offsets in exported module table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* @returns Result ResultSuccess if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseImportModuleTable();
Result RebaseImportModuleTable();
/**
* Rebases offsets in imported named symbol table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* @returns Result ResultSuccess if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseImportNamedSymbolTable();
Result RebaseImportNamedSymbolTable();
/**
* Rebases offsets in imported indexed symbol table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* @returns Result ResultSuccess if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseImportIndexedSymbolTable();
Result RebaseImportIndexedSymbolTable();
/**
* Rebases offsets in imported anonymous symbol table according to module address.
* @returns ResultCode RESULT_SUCCESS if all offsets are verified as valid, otherwise error
* @returns Result ResultSuccess if all offsets are verified as valid, otherwise error
* code.
*/
ResultCode RebaseImportAnonymousSymbolTable();
Result RebaseImportAnonymousSymbolTable();
/**
* Gets the address of OnUnresolved function in this module.
@ -593,35 +593,35 @@ private:
/**
* Resets all external relocations to unresolved state.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ResetExternalRelocations();
Result ResetExternalRelocations();
/**
* Clears all external relocations to zero.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ClearExternalRelocations();
Result ClearExternalRelocations();
/**
* Applies all static anonymous symbol to the static module.
* @param crs_address the virtual address of the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ApplyStaticAnonymousSymbolToCRS(VAddr crs_address);
Result ApplyStaticAnonymousSymbolToCRS(VAddr crs_address);
/**
* Applies all internal relocations to the module itself.
* @param old_data_segment_address the virtual address of data segment in CRO buffer
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ApplyInternalRelocations(u32 old_data_segment_address);
Result ApplyInternalRelocations(u32 old_data_segment_address);
/**
* Clears all internal relocations to zero.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ClearInternalRelocations();
Result ClearInternalRelocations();
/// Unrebases offsets in imported anonymous symbol table
void UnrebaseImportAnonymousSymbolTable();
@ -648,71 +648,71 @@ private:
* Looks up all imported named symbols of this module in all registered auto-link modules, and
* resolves them if found.
* @param crs_address the virtual address of the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ApplyImportNamedSymbol(VAddr crs_address);
Result ApplyImportNamedSymbol(VAddr crs_address);
/**
* Resets all imported named symbols of this module to unresolved state.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ResetImportNamedSymbol();
Result ResetImportNamedSymbol();
/**
* Resets all imported indexed symbols of this module to unresolved state.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ResetImportIndexedSymbol();
Result ResetImportIndexedSymbol();
/**
* Resets all imported anonymous symbols of this module to unresolved state.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ResetImportAnonymousSymbol();
Result ResetImportAnonymousSymbol();
/**
* Finds registered auto-link modules that this module imports, and resolves indexed and
* anonymous symbols exported by them.
* @param crs_address the virtual address of the static module
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ApplyModuleImport(VAddr crs_address);
Result ApplyModuleImport(VAddr crs_address);
/**
* Resolves target module's imported named symbols that exported by this module.
* @param target the module to resolve.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ApplyExportNamedSymbol(CROHelper target);
Result ApplyExportNamedSymbol(CROHelper target);
/**
* Resets target's named symbols imported from this module to unresolved state.
* @param target the module to reset.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ResetExportNamedSymbol(CROHelper target);
Result ResetExportNamedSymbol(CROHelper target);
/**
* Resolves imported indexed and anonymous symbols in the target module which imports this
* module.
* @param target the module to resolve.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ApplyModuleExport(CROHelper target);
Result ApplyModuleExport(CROHelper target);
/**
* Resets target's indexed and anonymous symbol imported from this module to unresolved state.
* @param target the module to reset.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ResetModuleExport(CROHelper target);
Result ResetModuleExport(CROHelper target);
/**
* Resolves the exit function in this module
* @param crs_address the virtual address of the static module.
* @returns ResultCode RESULT_SUCCESS on success, otherwise error code.
* @returns Result ResultSuccess on success, otherwise error code.
*/
ResultCode ApplyExitRelocations(VAddr crs_address);
Result ApplyExitRelocations(VAddr crs_address);
};
} // namespace Service::LDR

View file

@ -19,30 +19,30 @@ SERIALIZE_EXPORT_IMPL(Service::LDR::ClientSlot)
namespace Service::LDR {
static const ResultCode ERROR_ALREADY_INITIALIZED = // 0xD9612FF9
ResultCode(ErrorDescription::AlreadyInitialized, ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Permanent);
static const ResultCode ERROR_NOT_INITIALIZED = // 0xD9612FF8
ResultCode(ErrorDescription::NotInitialized, ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Permanent);
static const ResultCode ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
ResultCode(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument,
ErrorLevel::Usage);
static const ResultCode ERROR_MISALIGNED_ADDRESS = // 0xD9012FF1
ResultCode(ErrorDescription::MisalignedAddress, ErrorModule::RO, ErrorSummary::WrongArgument,
ErrorLevel::Permanent);
static const ResultCode ERROR_MISALIGNED_SIZE = // 0xD9012FF2
ResultCode(ErrorDescription::MisalignedSize, ErrorModule::RO, ErrorSummary::WrongArgument,
ErrorLevel::Permanent);
static const ResultCode ERROR_ILLEGAL_ADDRESS = // 0xE1612C0F
ResultCode(static_cast<ErrorDescription>(15), ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Usage);
static const ResultCode ERROR_INVALID_MEMORY_STATE = // 0xD8A12C08
ResultCode(static_cast<ErrorDescription>(8), ErrorModule::RO, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
static const ResultCode ERROR_NOT_LOADED = // 0xD8A12C0D
ResultCode(static_cast<ErrorDescription>(13), ErrorModule::RO, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
static const Result ERROR_ALREADY_INITIALIZED = // 0xD9612FF9
Result(ErrorDescription::AlreadyInitialized, ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Permanent);
static const Result ERROR_NOT_INITIALIZED = // 0xD9612FF8
Result(ErrorDescription::NotInitialized, ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Permanent);
static const Result ERROR_BUFFER_TOO_SMALL = // 0xE0E12C1F
Result(static_cast<ErrorDescription>(31), ErrorModule::RO, ErrorSummary::InvalidArgument,
ErrorLevel::Usage);
static const Result ERROR_MISALIGNED_ADDRESS = // 0xD9012FF1
Result(ErrorDescription::MisalignedAddress, ErrorModule::RO, ErrorSummary::WrongArgument,
ErrorLevel::Permanent);
static const Result ERROR_MISALIGNED_SIZE = // 0xD9012FF2
Result(ErrorDescription::MisalignedSize, ErrorModule::RO, ErrorSummary::WrongArgument,
ErrorLevel::Permanent);
static const Result ERROR_ILLEGAL_ADDRESS = // 0xE1612C0F
Result(static_cast<ErrorDescription>(15), ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Usage);
static const Result ERROR_INVALID_MEMORY_STATE = // 0xD8A12C08
Result(static_cast<ErrorDescription>(8), ErrorModule::RO, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
static const Result ERROR_NOT_LOADED = // 0xD8A12C0D
Result(static_cast<ErrorDescription>(13), ErrorModule::RO, ErrorSummary::InvalidState,
ErrorLevel::Permanent);
static bool VerifyBufferState(Kernel::Process& process, VAddr buffer_ptr, u32 size) {
auto vma = process.vm_manager.FindVMA(buffer_ptr);
@ -118,7 +118,7 @@ void RO::Initialize(Kernel::HLERequestContext& ctx) {
return;
}
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
result = process->Map(crs_address, crs_buffer_ptr, crs_size, Kernel::VMAPermission::Read, true);
if (result.IsError()) {
@ -139,7 +139,7 @@ void RO::Initialize(Kernel::HLERequestContext& ctx) {
slot->loaded_crs = crs_address;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void RO::LoadCRR(Kernel::HLERequestContext& ctx) {
@ -149,7 +149,7 @@ void RO::LoadCRR(Kernel::HLERequestContext& ctx) {
auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x{:08X}, crr_size=0x{:08X}",
crr_buffer_ptr, crr_size);
@ -161,7 +161,7 @@ void RO::UnloadCRR(Kernel::HLERequestContext& ctx) {
auto process = rp.PopObject<Kernel::Process>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_LDR, "(STUBBED) called, crr_buffer_ptr=0x{:08X}", crr_buffer_ptr);
}
@ -245,13 +245,13 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
if (zero) {
LOG_ERROR(Service_LDR, "Zero is not zero {}", zero);
rb.Push(ResultCode(static_cast<ErrorDescription>(29), ErrorModule::RO,
ErrorSummary::Internal, ErrorLevel::Usage));
rb.Push(Result(static_cast<ErrorDescription>(29), ErrorModule::RO, ErrorSummary::Internal,
ErrorLevel::Usage));
rb.Push<u32>(0);
return;
}
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
result = process->Map(cro_address, cro_buffer_ptr, cro_size, Kernel::VMAPermission::Read, true);
if (result.IsError()) {
@ -330,7 +330,7 @@ void RO::LoadCRO(Kernel::HLERequestContext& ctx, bool link_on_load_bug_fix) {
LOG_INFO(Service_LDR, "CRO \"{}\" loaded at 0x{:08X}, fixed_end=0x{:08X}", cro.ModuleName(),
cro_address, cro_address + fix_size);
rb.Push(RESULT_SUCCESS, fix_size);
rb.Push(ResultSuccess, fix_size);
}
void RO::UnloadCRO(Kernel::HLERequestContext& ctx) {
@ -372,7 +372,7 @@ void RO::UnloadCRO(Kernel::HLERequestContext& ctx) {
cro.Unregister(slot->loaded_crs);
ResultCode result = cro.Unlink(slot->loaded_crs);
Result result = cro.Unlink(slot->loaded_crs);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error unlinking CRO {:08X}", result.raw);
rb.Push(result);
@ -435,7 +435,7 @@ void RO::LinkCRO(Kernel::HLERequestContext& ctx) {
LOG_INFO(Service_LDR, "Linking CRO \"{}\"", cro.ModuleName());
ResultCode result = cro.Link(slot->loaded_crs, false);
Result result = cro.Link(slot->loaded_crs, false);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error linking CRO {:08X}", result.raw);
}
@ -475,7 +475,7 @@ void RO::UnlinkCRO(Kernel::HLERequestContext& ctx) {
LOG_INFO(Service_LDR, "Unlinking CRO \"{}\"", cro.ModuleName());
ResultCode result = cro.Unlink(slot->loaded_crs);
Result result = cro.Unlink(slot->loaded_crs);
if (result.IsError()) {
LOG_ERROR(Service_LDR, "Error unlinking CRO {:08X}", result.raw);
}
@ -502,7 +502,7 @@ void RO::Shutdown(Kernel::HLERequestContext& ctx) {
CROHelper crs(slot->loaded_crs, *process, system);
crs.Unrebase(true);
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
result = process->Unmap(slot->loaded_crs, crs_buffer_ptr, crs.GetFileSize(),
Kernel::VMAPermission::ReadWrite, true);

View file

@ -157,7 +157,7 @@ struct MIC_U::Impl {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_MIC, "called, size=0x{:X}", size);
}
@ -166,7 +166,7 @@ struct MIC_U::Impl {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
shared_memory = nullptr;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_MIC, "called");
}
@ -230,7 +230,7 @@ struct MIC_U::Impl {
timing.ScheduleEvent(GetBufferUpdatePeriod(state.sample_rate), buffer_write_event);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_MIC,
"called, encoding={}, sample_rate={}, "
"audio_buffer_offset={}, audio_buffer_size={}, audio_buffer_loop={}",
@ -246,7 +246,7 @@ struct MIC_U::Impl {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_MIC, "sample_rate={}", sample_rate);
}
@ -254,7 +254,7 @@ struct MIC_U::Impl {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
timing.RemoveEvent(buffer_write_event);
if (mic) {
mic->StopSampling();
@ -267,7 +267,7 @@ struct MIC_U::Impl {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
bool is_sampling = mic && mic->IsSampling();
rb.Push<bool>(is_sampling);
LOG_TRACE(Service_MIC, "IsSampling: {}", is_sampling);
@ -277,7 +277,7 @@ struct MIC_U::Impl {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(buffer_full_event);
LOG_WARNING(Service_MIC, "(STUBBED) called");
}
@ -288,7 +288,7 @@ struct MIC_U::Impl {
state.gain = gain;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_MIC, "gain={}", gain);
}
@ -296,7 +296,7 @@ struct MIC_U::Impl {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(state.gain);
LOG_TRACE(Service_MIC, "gain={}", state.gain);
}
@ -307,7 +307,7 @@ struct MIC_U::Impl {
state.power = power;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_TRACE(Service_MIC, "mic_power={}", power);
}
@ -315,7 +315,7 @@ struct MIC_U::Impl {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u8>(state.power);
LOG_TRACE(Service_MIC, "called");
}
@ -326,7 +326,7 @@ struct MIC_U::Impl {
const Kernel::MappedBuffer& buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_MIC, "(STUBBED) called, size=0x{:X}, buffer=0x{:08X}", size,
buffer.GetId());
@ -337,7 +337,7 @@ struct MIC_U::Impl {
clamp = rp.Pop<bool>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_MIC, "(STUBBED) called, clamp={}", clamp);
}
@ -345,7 +345,7 @@ struct MIC_U::Impl {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<bool>(clamp);
LOG_WARNING(Service_MIC, "(STUBBED) called");
}
@ -355,7 +355,7 @@ struct MIC_U::Impl {
allow_shell_closed = rp.Pop<bool>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_MIC, "(STUBBED) called, allow_shell_closed={}", allow_shell_closed);
}
@ -365,7 +365,7 @@ struct MIC_U::Impl {
LOG_WARNING(Service_MIC, "(STUBBED) called, version: 0x{:08X}", version);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void CreateMic() {

View file

@ -17,7 +17,7 @@ void NDM_U::EnterExclusiveState(Kernel::HLERequestContext& ctx) {
rp.PopPID();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED) exclusive_state=0x{:08X}", exclusive_state);
}
@ -26,14 +26,14 @@ void NDM_U::LeaveExclusiveState(Kernel::HLERequestContext& ctx) {
rp.PopPID();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED)");
}
void NDM_U::QueryExclusiveMode(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(exclusive_state);
LOG_WARNING(Service_NDM, "(STUBBED)");
}
@ -44,7 +44,7 @@ void NDM_U::LockState(Kernel::HLERequestContext& ctx) {
daemon_lock_enabled = true;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED)");
}
@ -54,7 +54,7 @@ void NDM_U::UnlockState(Kernel::HLERequestContext& ctx) {
daemon_lock_enabled = false;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED)");
}
@ -70,7 +70,7 @@ void NDM_U::SuspendDaemons(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED) bit_mask=0x{:08X}", bit_mask);
}
@ -85,7 +85,7 @@ void NDM_U::ResumeDaemons(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED) bit_mask=0x{:08X}", bit_mask);
}
@ -94,14 +94,14 @@ void NDM_U::SuspendScheduler(Kernel::HLERequestContext& ctx) {
bool perform_in_background = rp.Pop<bool>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED) perform_in_background={}", perform_in_background);
}
void NDM_U::ResumeScheduler(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED)");
}
@ -110,7 +110,7 @@ void NDM_U::QueryStatus(Kernel::HLERequestContext& ctx) {
u8 daemon = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(daemon_status.at(daemon));
LOG_WARNING(Service_NDM, "(STUBBED) daemon=0x{:02X}", daemon);
}
@ -120,7 +120,7 @@ void NDM_U::GetDaemonDisableCount(Kernel::HLERequestContext& ctx) {
u8 daemon = rp.Pop<u8>();
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // current process disable count
rb.Push<u32>(0); // total disable count
LOG_WARNING(Service_NDM, "(STUBBED) daemon=0x{:02X}", daemon);
@ -130,7 +130,7 @@ void NDM_U::GetSchedulerDisableCount(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0); // current process disable count
rb.Push<u32>(0); // total disable count
LOG_WARNING(Service_NDM, "(STUBBED)");
@ -141,14 +141,14 @@ void NDM_U::SetScanInterval(Kernel::HLERequestContext& ctx) {
scan_interval = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED) scan_interval=0x{:08X}", scan_interval);
}
void NDM_U::GetScanInterval(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(scan_interval);
LOG_WARNING(Service_NDM, "(STUBBED)");
}
@ -158,14 +158,14 @@ void NDM_U::SetRetryInterval(Kernel::HLERequestContext& ctx) {
retry_interval = rp.Pop<u32>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED) retry_interval=0x{:08X}", retry_interval);
}
void NDM_U::GetRetryInterval(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(retry_interval);
LOG_WARNING(Service_NDM, "(STUBBED)");
}
@ -182,7 +182,7 @@ void NDM_U::OverrideDefaultDaemons(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED) bit_mask=0x{:08X}", bit_mask);
}
@ -191,14 +191,14 @@ void NDM_U::ResetDefaultDaemons(Kernel::HLERequestContext& ctx) {
default_daemon_bit_mask = DaemonMask::Default;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED)");
}
void NDM_U::GetDefaultDaemons(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(default_daemon_bit_mask);
LOG_WARNING(Service_NDM, "(STUBBED)");
}
@ -206,7 +206,7 @@ void NDM_U::GetDefaultDaemons(Kernel::HLERequestContext& ctx) {
void NDM_U::ClearHalfAwakeMacFilter(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NDM, "(STUBBED)");
}

View file

@ -24,7 +24,7 @@ void NEWS_S::GetTotalNotifications(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0);
}
@ -40,7 +40,7 @@ void NEWS_S::GetNewsDBHeader(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(size);
}

View file

@ -34,7 +34,7 @@ void Module::Interface::Initialize(Kernel::HLERequestContext& ctx) {
return;
}
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
switch (communication_mode) {
case CommunicationMode::Ntag:
case CommunicationMode::Amiibo:
@ -68,7 +68,7 @@ void Module::Interface::Finalize(Kernel::HLERequestContext& ctx) {
return;
}
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
switch (communication_mode) {
case CommunicationMode::Ntag:
case CommunicationMode::Amiibo:
@ -97,7 +97,7 @@ void Module::Interface::Connect(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
if (nfc->nfc_mode == CommunicationMode::TrainTag) {
LOG_ERROR(Service_NFC, "CommunicationMode {} not implemented", nfc->nfc_mode);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
return;
}
@ -114,7 +114,7 @@ void Module::Interface::Disconnect(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
if (nfc->nfc_mode == CommunicationMode::TrainTag) {
LOG_ERROR(Service_NFC, "CommunicationMode {} not implemented", nfc->nfc_mode);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
return;
}
@ -129,7 +129,7 @@ void Module::Interface::StartDetection(Kernel::HLERequestContext& ctx) {
LOG_INFO(Service_NFC, "called, in_val={:04x}", in_val);
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
switch (nfc->nfc_mode) {
case CommunicationMode::Ntag:
case CommunicationMode::Amiibo:
@ -150,7 +150,7 @@ void Module::Interface::StopDetection(Kernel::HLERequestContext& ctx) {
LOG_INFO(Service_NFC, "called");
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
switch (nfc->nfc_mode) {
case CommunicationMode::Ntag:
case CommunicationMode::Amiibo:
@ -175,7 +175,7 @@ void Module::Interface::Mount(Kernel::HLERequestContext& ctx) {
nfc->device->RescheduleTagRemoveEvent();
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
switch (nfc->nfc_mode) {
case CommunicationMode::Ntag:
result = nfc->device->Mount();
@ -197,7 +197,7 @@ void Module::Interface::Unmount(Kernel::HLERequestContext& ctx) {
LOG_INFO(Service_NFC, "called");
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
switch (nfc->nfc_mode) {
case CommunicationMode::Ntag:
case CommunicationMode::Amiibo:
@ -217,7 +217,7 @@ void Module::Interface::Flush(Kernel::HLERequestContext& ctx) {
LOG_INFO(Service_NFC, "called");
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
switch (nfc->nfc_mode) {
case CommunicationMode::Ntag:
LOG_ERROR(Service_NFC, "CommunicationMode {} not implemented", nfc->nfc_mode);
@ -247,7 +247,7 @@ void Module::Interface::GetActivateEvent(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(nfc->device->GetActivateEvent());
}
@ -264,7 +264,7 @@ void Module::Interface::GetDeactivateEvent(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(nfc->device->GetDeactivateEvent());
}
@ -281,7 +281,7 @@ void Module::Interface::GetStatus(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(state);
}
@ -293,7 +293,7 @@ void Module::Interface::GetTargetConnectionStatus(Kernel::HLERequestContext& ctx
if (nfc->nfc_mode == CommunicationMode::TrainTag) {
LOG_ERROR(Service_NFC, "CommunicationMode {} not implemented", nfc->nfc_mode);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushEnum(CommunicationState::Idle);
return;
}
@ -315,7 +315,7 @@ void Module::Interface::GetTagInfo2(Kernel::HLERequestContext& ctx) {
if (nfc->nfc_mode == CommunicationMode::TrainTag) {
LOG_ERROR(Service_NFC, "CommunicationMode {} not implemented", nfc->nfc_mode);
IPC::RequestBuilder rb = rp.MakeBuilder(25, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<TagInfo2>({});
return;
}
@ -337,7 +337,7 @@ void Module::Interface::GetTagInfo(Kernel::HLERequestContext& ctx) {
if (nfc->nfc_mode == CommunicationMode::TrainTag) {
LOG_ERROR(Service_NFC, "CommunicationMode {} not implemented", nfc->nfc_mode);
IPC::RequestBuilder rb = rp.MakeBuilder(12, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<TagInfo>({});
return;
}
@ -353,7 +353,7 @@ void Module::Interface::GetConnectResult(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(0);
LOG_WARNING(Service_NFC, "(STUBBED) called");
}
@ -505,7 +505,7 @@ void Module::Interface::InitializeCreateInfo(Kernel::HLERequestContext& ctx) {
InitialStruct empty{};
IPC::RequestBuilder rb = rp.MakeBuilder(16, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<InitialStruct>(empty);
}
@ -514,7 +514,7 @@ void Module::Interface::MountRom(Kernel::HLERequestContext& ctx) {
LOG_INFO(Service_NFC, "called");
ResultCode result = RESULT_SUCCESS;
Result result = ResultSuccess;
switch (nfc->nfc_mode) {
case CommunicationMode::Ntag:
result = nfc->device->PartiallyMount();
@ -599,7 +599,7 @@ void Module::Interface::GetEmptyRegisterInfo(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(43, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<RegisterInfo>({});
}

View file

@ -166,7 +166,7 @@ void NfcDevice::Finalize() {
is_initalized = false;
}
ResultCode NfcDevice::StartCommunication() {
Result NfcDevice::StartCommunication() {
const auto connection_result = CheckConnectionState();
if (connection_result.IsError()) {
return connection_result;
@ -181,10 +181,10 @@ ResultCode NfcDevice::StartCommunication() {
// This is a hack. This mode needs to change when the tag reader has completed the initalization
communication_state = CommunicationState::Initialized;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::StopCommunication() {
Result NfcDevice::StopCommunication() {
const auto connection_result = CheckConnectionState();
if (connection_result.IsError()) {
return connection_result;
@ -201,10 +201,10 @@ ResultCode NfcDevice::StopCommunication() {
device_state = DeviceState::Initialized;
communication_state = CommunicationState::Idle;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::StartDetection(TagProtocol allowed_protocol) {
Result NfcDevice::StartDetection(TagProtocol allowed_protocol) {
const auto connection_result = CheckConnectionState();
if (connection_result.IsError()) {
return connection_result;
@ -227,10 +227,10 @@ ResultCode NfcDevice::StartDetection(TagProtocol allowed_protocol) {
LoadAmiibo(amiibo_filename);
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::StopDetection() {
Result NfcDevice::StopDetection() {
const auto connection_result = CheckConnectionState();
if (connection_result.IsError()) {
return connection_result;
@ -250,14 +250,14 @@ ResultCode NfcDevice::StopDetection() {
// TODO: Stop console search mode here
device_state = DeviceState::Initialized;
connection_state = ConnectionState::Success;
return RESULT_SUCCESS;
return ResultSuccess;
}
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
return ResultInvalidOperation;
}
ResultCode NfcDevice::Flush() {
Result NfcDevice::Flush() {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -282,7 +282,7 @@ ResultCode NfcDevice::Flush() {
if (is_write_protected) {
LOG_ERROR(Service_NFC, "No keys available skipping write request");
return RESULT_SUCCESS;
return ResultSuccess;
}
if (!is_plain_amiibo) {
@ -324,10 +324,10 @@ ResultCode NfcDevice::Flush() {
is_data_moddified = false;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::Mount() {
Result NfcDevice::Mount() {
if (device_state != DeviceState::TagFound) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -345,7 +345,7 @@ ResultCode NfcDevice::Mount() {
// The loaded amiibo is not encrypted
if (is_plain_amiibo) {
device_state = DeviceState::TagMounted;
return RESULT_SUCCESS;
return ResultSuccess;
}
if (!AmiiboCrypto::DecodeAmiibo(encrypted_tag.file, tag.file)) {
@ -354,10 +354,10 @@ ResultCode NfcDevice::Mount() {
}
device_state = DeviceState::TagMounted;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::MountAmiibo() {
Result NfcDevice::MountAmiibo() {
TagInfo tag_info{};
const auto result = GetTagInfo(tag_info);
@ -372,7 +372,7 @@ ResultCode NfcDevice::MountAmiibo() {
return Mount();
}
ResultCode NfcDevice::PartiallyMount() {
Result NfcDevice::PartiallyMount() {
if (device_state != DeviceState::TagFound) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -390,7 +390,7 @@ ResultCode NfcDevice::PartiallyMount() {
// The loaded amiibo is not encrypted
if (is_plain_amiibo) {
device_state = DeviceState::TagPartiallyMounted;
return RESULT_SUCCESS;
return ResultSuccess;
}
if (!AmiiboCrypto::DecodeAmiibo(encrypted_tag.file, tag.file)) {
@ -399,10 +399,10 @@ ResultCode NfcDevice::PartiallyMount() {
}
device_state = DeviceState::TagPartiallyMounted;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::PartiallyMountAmiibo() {
Result NfcDevice::PartiallyMountAmiibo() {
TagInfo tag_info{};
const auto result = GetTagInfo(tag_info);
@ -416,7 +416,7 @@ ResultCode NfcDevice::PartiallyMountAmiibo() {
return PartiallyMount();
}
ResultCode NfcDevice::ResetTagScanState() {
Result NfcDevice::ResetTagScanState() {
if (device_state != DeviceState::TagMounted &&
device_state != DeviceState::TagPartiallyMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
@ -430,10 +430,10 @@ ResultCode NfcDevice::ResetTagScanState() {
device_state = DeviceState::TagFound;
is_app_area_open = false;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::GetTagInfo2(TagInfo2& tag_info) const {
Result NfcDevice::GetTagInfo2(TagInfo2& tag_info) const {
tag_info = {
.uuid_length = static_cast<u16>(encrypted_tag.file.uuid.uid.size()),
.tag_type = PackedTagType::Type2,
@ -443,10 +443,10 @@ ResultCode NfcDevice::GetTagInfo2(TagInfo2& tag_info) const {
.extra_data2 = {}, // Used on non amiibo tags
};
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::GetTagInfo(TagInfo& tag_info) const {
Result NfcDevice::GetTagInfo(TagInfo& tag_info) const {
if (device_state != DeviceState::TagFound && device_state != DeviceState::TagMounted &&
device_state != DeviceState::TagPartiallyMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
@ -465,10 +465,10 @@ ResultCode NfcDevice::GetTagInfo(TagInfo& tag_info) const {
.extra_data = {}, // Used on non amiibo tags
};
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::GetCommonInfo(CommonInfo& common_info) const {
Result NfcDevice::GetCommonInfo(CommonInfo& common_info) const {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -494,10 +494,10 @@ ResultCode NfcDevice::GetCommonInfo(CommonInfo& common_info) const {
.application_area_size = sizeof(ApplicationArea),
};
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::GetModelInfo(ModelInfo& model_info) const {
Result NfcDevice::GetModelInfo(ModelInfo& model_info) const {
if (device_state != DeviceState::TagMounted &&
device_state != DeviceState::TagPartiallyMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
@ -517,10 +517,10 @@ ResultCode NfcDevice::GetModelInfo(ModelInfo& model_info) const {
.amiibo_type = model_info_data.amiibo_type,
};
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::GetRegisterInfo(RegisterInfo& register_info) const {
Result NfcDevice::GetRegisterInfo(RegisterInfo& register_info) const {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -545,10 +545,10 @@ ResultCode NfcDevice::GetRegisterInfo(RegisterInfo& register_info) const {
.creation_date = settings.init_date.GetWriteDate(),
};
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::GetAdminInfo(AdminInfo& admin_info) const {
Result NfcDevice::GetAdminInfo(AdminInfo& admin_info) const {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -604,10 +604,10 @@ ResultCode NfcDevice::GetAdminInfo(AdminInfo& admin_info) const {
.app_area_version = app_area_version,
};
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::DeleteRegisterInfo() {
Result NfcDevice::DeleteRegisterInfo() {
// This is a hack to get around a HW issue
if (device_state == DeviceState::TagFound) {
Mount();
@ -645,7 +645,7 @@ ResultCode NfcDevice::DeleteRegisterInfo() {
return Flush();
}
ResultCode NfcDevice::SetRegisterInfoPrivate(const RegisterInfoPrivate& register_info) {
Result NfcDevice::SetRegisterInfoPrivate(const RegisterInfoPrivate& register_info) {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -677,7 +677,7 @@ ResultCode NfcDevice::SetRegisterInfoPrivate(const RegisterInfoPrivate& register
return Flush();
}
ResultCode NfcDevice::RestoreAmiibo() {
Result NfcDevice::RestoreAmiibo() {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -689,25 +689,25 @@ ResultCode NfcDevice::RestoreAmiibo() {
// TODO: Load amiibo from backup on system
LOG_ERROR(Service_NFC, "Not Implemented");
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::Format() {
auto ResultCode = DeleteApplicationArea();
auto ResultCode2 = DeleteRegisterInfo();
Result NfcDevice::Format() {
auto Result = DeleteApplicationArea();
auto Result2 = DeleteRegisterInfo();
if (ResultCode.IsError()) {
return ResultCode;
if (Result.IsError()) {
return Result;
}
if (ResultCode2.IsError()) {
return ResultCode2;
if (Result2.IsError()) {
return Result2;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::OpenApplicationArea(u32 access_id) {
Result NfcDevice::OpenApplicationArea(u32 access_id) {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -729,10 +729,10 @@ ResultCode NfcDevice::OpenApplicationArea(u32 access_id) {
is_app_area_open = true;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::GetApplicationAreaId(u32& application_area_id) const {
Result NfcDevice::GetApplicationAreaId(u32& application_area_id) const {
application_area_id = {};
if (device_state != DeviceState::TagMounted) {
@ -751,10 +751,10 @@ ResultCode NfcDevice::GetApplicationAreaId(u32& application_area_id) const {
application_area_id = tag.file.application_area_id;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::GetApplicationArea(std::vector<u8>& data) const {
Result NfcDevice::GetApplicationArea(std::vector<u8>& data) const {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -780,10 +780,10 @@ ResultCode NfcDevice::GetApplicationArea(std::vector<u8>& data) const {
memcpy(data.data(), tag.file.application_area.data(), data.size());
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::SetApplicationArea(std::span<const u8> data) {
Result NfcDevice::SetApplicationArea(std::span<const u8> data) {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -828,10 +828,10 @@ ResultCode NfcDevice::SetApplicationArea(std::span<const u8> data) {
is_data_moddified = true;
return RESULT_SUCCESS;
return ResultSuccess;
}
ResultCode NfcDevice::CreateApplicationArea(u32 access_id, std::span<const u8> data) {
Result NfcDevice::CreateApplicationArea(u32 access_id, std::span<const u8> data) {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -849,7 +849,7 @@ ResultCode NfcDevice::CreateApplicationArea(u32 access_id, std::span<const u8> d
return RecreateApplicationArea(access_id, data);
}
ResultCode NfcDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> data) {
Result NfcDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> data) {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -900,7 +900,7 @@ ResultCode NfcDevice::RecreateApplicationArea(u32 access_id, std::span<const u8>
return Flush();
}
ResultCode NfcDevice::DeleteApplicationArea() {
Result NfcDevice::DeleteApplicationArea() {
// This is a hack to get around a HW issue
if (device_state == DeviceState::TagFound) {
Mount();
@ -943,7 +943,7 @@ ResultCode NfcDevice::DeleteApplicationArea() {
return Flush();
}
ResultCode NfcDevice::ApplicationAreaExist(bool& has_application_area) {
Result NfcDevice::ApplicationAreaExist(bool& has_application_area) {
if (device_state != DeviceState::TagMounted) {
LOG_ERROR(Service_NFC, "Wrong device state {}", device_state);
const auto connection_result = CheckConnectionState();
@ -955,7 +955,7 @@ ResultCode NfcDevice::ApplicationAreaExist(bool& has_application_area) {
has_application_area = tag.file.settings.settings.appdata_initialized.Value() != 0;
return RESULT_SUCCESS;
return ResultSuccess;
}
constexpr u32 NfcDevice::GetApplicationAreaSize() const {
@ -966,23 +966,23 @@ DeviceState NfcDevice::GetCurrentState() const {
return device_state;
}
ResultCode NfcDevice::GetCommunicationStatus(CommunicationState& status) const {
Result NfcDevice::GetCommunicationStatus(CommunicationState& status) const {
if (communication_state == CommunicationState::Idle ||
communication_state == CommunicationState::SearchingForAdapter) {
status = communication_state;
return RESULT_SUCCESS;
return ResultSuccess;
}
if (communication_state == CommunicationState::Initialized ||
communication_state == CommunicationState::Active) {
status = CommunicationState::Initialized;
return RESULT_SUCCESS;
return ResultSuccess;
}
return ResultInvalidOperation;
}
ResultCode NfcDevice::CheckConnectionState() const {
Result NfcDevice::CheckConnectionState() const {
if (connection_state == ConnectionState::Lost) {
return ResultSleep;
}
@ -991,7 +991,7 @@ ResultCode NfcDevice::CheckConnectionState() const {
return ResultWifiOff;
}
return RESULT_SUCCESS;
return ResultSuccess;
}
void NfcDevice::SetAmiiboName(AmiiboSettings& settings, const AmiiboName& amiibo_name) {

View file

@ -31,42 +31,42 @@ public:
void Initialize();
void Finalize();
ResultCode StartCommunication();
ResultCode StopCommunication();
ResultCode StartDetection(TagProtocol allowed_protocol);
ResultCode StopDetection();
ResultCode Mount();
ResultCode MountAmiibo();
ResultCode PartiallyMount();
ResultCode PartiallyMountAmiibo();
ResultCode ResetTagScanState();
ResultCode Flush();
Result StartCommunication();
Result StopCommunication();
Result StartDetection(TagProtocol allowed_protocol);
Result StopDetection();
Result Mount();
Result MountAmiibo();
Result PartiallyMount();
Result PartiallyMountAmiibo();
Result ResetTagScanState();
Result Flush();
ResultCode GetTagInfo2(TagInfo2& tag_info) const;
ResultCode GetTagInfo(TagInfo& tag_info) const;
ResultCode GetCommonInfo(CommonInfo& common_info) const;
ResultCode GetModelInfo(ModelInfo& model_info) const;
ResultCode GetRegisterInfo(RegisterInfo& register_info) const;
ResultCode GetAdminInfo(AdminInfo& admin_info) const;
Result GetTagInfo2(TagInfo2& tag_info) const;
Result GetTagInfo(TagInfo& tag_info) const;
Result GetCommonInfo(CommonInfo& common_info) const;
Result GetModelInfo(ModelInfo& model_info) const;
Result GetRegisterInfo(RegisterInfo& register_info) const;
Result GetAdminInfo(AdminInfo& admin_info) const;
ResultCode DeleteRegisterInfo();
ResultCode SetRegisterInfoPrivate(const RegisterInfoPrivate& register_info);
ResultCode RestoreAmiibo();
ResultCode Format();
Result DeleteRegisterInfo();
Result SetRegisterInfoPrivate(const RegisterInfoPrivate& register_info);
Result RestoreAmiibo();
Result Format();
ResultCode OpenApplicationArea(u32 access_id);
ResultCode GetApplicationAreaId(u32& application_area_id) const;
ResultCode GetApplicationArea(std::vector<u8>& data) const;
ResultCode SetApplicationArea(std::span<const u8> data);
ResultCode CreateApplicationArea(u32 access_id, std::span<const u8> data);
ResultCode RecreateApplicationArea(u32 access_id, std::span<const u8> data);
ResultCode DeleteApplicationArea();
ResultCode ApplicationAreaExist(bool& has_application_area);
Result OpenApplicationArea(u32 access_id);
Result GetApplicationAreaId(u32& application_area_id) const;
Result GetApplicationArea(std::vector<u8>& data) const;
Result SetApplicationArea(std::span<const u8> data);
Result CreateApplicationArea(u32 access_id, std::span<const u8> data);
Result RecreateApplicationArea(u32 access_id, std::span<const u8> data);
Result DeleteApplicationArea();
Result ApplicationAreaExist(bool& has_application_area);
constexpr u32 GetApplicationAreaSize() const;
DeviceState GetCurrentState() const;
ResultCode GetCommunicationStatus(CommunicationState& status) const;
ResultCode CheckConnectionState() const;
Result GetCommunicationStatus(CommunicationState& status) const;
Result CheckConnectionState() const;
std::shared_ptr<Kernel::Event> GetActivateEvent() const;
std::shared_ptr<Kernel::Event> GetDeactivateEvent() const;

View file

@ -43,29 +43,29 @@ enum {
};
} // namespace ErrCodes
constexpr ResultCode ResultInvalidArgumentValue(ErrCodes::InvalidArgumentValue, ErrorModule::NFC,
ErrorSummary::InvalidArgument, ErrorLevel::Status);
constexpr ResultCode ResultInvalidArgument(ErrCodes::InvalidArgument, ErrorModule::NFC,
ErrorSummary::InvalidArgument, ErrorLevel::Status);
constexpr ResultCode ResultInvalidOperation(ErrCodes::InvalidOperation, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr ResultCode ResultNotSupported(ErrCodes::NotSupported, ErrorModule::NFC,
constexpr Result ResultInvalidArgumentValue(ErrCodes::InvalidArgumentValue, ErrorModule::NFC,
ErrorSummary::InvalidArgument, ErrorLevel::Status);
constexpr Result ResultInvalidArgument(ErrCodes::InvalidArgument, ErrorModule::NFC,
ErrorSummary::InvalidArgument, ErrorLevel::Status);
constexpr Result ResultInvalidOperation(ErrCodes::InvalidOperation, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr ResultCode ResultNeedFormat(ErrCodes::NeedFormat, ErrorModule::NFC,
constexpr Result ResultNotSupported(ErrCodes::NotSupported, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr Result ResultNeedFormat(ErrCodes::NeedFormat, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr Result ResultOperationFailed(ErrCodes::OperationFailed, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr Result ResultNeedCreate(ErrCodes::NeedCreate, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr Result ResultNeedRegister(ErrCodes::NeedRegister, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr Result ResultAlreadyCreated(ErrCodes::AlreadyCreated, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr ResultCode ResultOperationFailed(ErrCodes::OperationFailed, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr ResultCode ResultNeedCreate(ErrCodes::NeedCreate, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr ResultCode ResultNeedRegister(ErrCodes::NeedRegister, ErrorModule::NFC,
constexpr Result ResultAccessIdMisMatch(ErrCodes::AccessIdMisMatch, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr ResultCode ResultAlreadyCreated(ErrCodes::AlreadyCreated, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr ResultCode ResultAccessIdMisMatch(ErrCodes::AccessIdMisMatch, ErrorModule::NFC,
ErrorSummary::InvalidState, ErrorLevel::Status);
constexpr ResultCode ResultSleep(ErrCodes::Sleep, ErrorModule::NFC, ErrorSummary::InvalidState,
ErrorLevel::Status);
constexpr ResultCode ResultWifiOff(ErrCodes::WifiOff, ErrorModule::NFC, ErrorSummary::InvalidState,
ErrorLevel::Status);
constexpr Result ResultSleep(ErrCodes::Sleep, ErrorModule::NFC, ErrorSummary::InvalidState,
ErrorLevel::Status);
constexpr Result ResultWifiOff(ErrCodes::WifiOff, ErrorModule::NFC, ErrorSummary::InvalidState,
ErrorLevel::Status);
} // namespace Service::NFC

View file

@ -190,7 +190,7 @@ void NIM_U::StartNetworkUpdate(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -202,7 +202,7 @@ void NIM_U::GetProgress(Kernel::HLERequestContext& ctx) {
std::memset(&progress, 0, sizeof(progress));
IPC::RequestBuilder rb = rp.MakeBuilder(13, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(progress);
rb.Push(0);
rb.Push(0);
@ -214,7 +214,7 @@ void NIM_U::Cancel(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -223,7 +223,7 @@ void NIM_U::CommitSystemTitles(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -232,7 +232,7 @@ void NIM_U::GetBackgroundEventForMenu(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(nim_system_update_event_for_menu);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -242,7 +242,7 @@ void NIM_U::GetBackgroundEventForNews(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(nim_system_update_event_for_news);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -252,7 +252,7 @@ void NIM_U::FormatSaveData(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -261,7 +261,7 @@ void NIM_U::GetCustomerSupportCode(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(0); // Customer support code
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -271,7 +271,7 @@ void NIM_U::IsCommittableAllSystemTitles(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(false);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -284,7 +284,7 @@ void NIM_U::GetBackgroundProgress(Kernel::HLERequestContext& ctx) {
std::memset(&progress, 0, sizeof(progress));
IPC::RequestBuilder rb = rp.MakeBuilder(13, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(progress);
rb.Push(0);
rb.Push(0);
@ -299,7 +299,7 @@ void NIM_U::GetSavedHash(Kernel::HLERequestContext& ctx) {
std::memset(&hash, 0, sizeof(hash));
IPC::RequestBuilder rb = rp.MakeBuilder(10, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(hash);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -312,8 +312,8 @@ void NIM_U::UnregisterTask(Kernel::HLERequestContext& ctx) {
const u32 process_id = rp.PopPID();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::NIM, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::NIM, ErrorSummary::NotFound,
ErrorLevel::Status));
LOG_WARNING(Service_NIM, "(STUBBED) called title_id={:016X}, process_id={:08X}", title_id,
process_id);
@ -325,7 +325,7 @@ void NIM_U::IsRegistered(Kernel::HLERequestContext& ctx) {
const u64 title_id = rp.Pop<u64>();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(false);
LOG_WARNING(Service_NIM, "(STUBBED) called title_id={:016X}", title_id);
@ -339,8 +339,8 @@ void NIM_U::FindTaskInfo(Kernel::HLERequestContext& ctx) {
std::vector<u8> buffer(0x120, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::NIM, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::NIM, ErrorSummary::NotFound,
ErrorLevel::Status));
rb.PushStaticBuffer(std::move(buffer), 0);
LOG_WARNING(Service_NIM, "(STUBBED) called title_id={:016X}", title_id);
@ -353,7 +353,7 @@ void NIM_U::GetTaskInfos(Kernel::HLERequestContext& ctx) {
auto& task_infos_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(0);
rb.PushMappedBuffer(task_infos_buffer);
@ -365,7 +365,7 @@ void NIM_U::DeleteUnmanagedContexts(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -377,7 +377,7 @@ void NIM_U::UpdateAutoTitleDownloadTasksAsync(Kernel::HLERequestContext& ctx) {
nim_async_completion_event->Signal();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(nim_async_completion_event);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -390,7 +390,7 @@ void NIM_U::StartPendingAutoTitleDownloadTasksAsync(Kernel::HLERequestContext& c
nim_async_completion_event->Signal();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(nim_async_completion_event);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -400,8 +400,8 @@ void NIM_U::GetAsyncResult(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ResultSuccess);
rb.Push(0);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -411,7 +411,7 @@ void NIM_U::CancelAsyncCall(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -420,7 +420,7 @@ void NIM_U::IsPendingAutoTitleDownloadTasks(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(false);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -430,7 +430,7 @@ void NIM_U::GetNumAutoTitleDownloadTasks(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(0);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -443,7 +443,7 @@ void NIM_U::GetAutoTitleDownloadTaskInfos(Kernel::HLERequestContext& ctx) {
auto& task_infos_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(0);
rb.PushMappedBuffer(task_infos_buffer);
@ -457,7 +457,7 @@ void NIM_U::CancelAutoTitleDownloadTask(Kernel::HLERequestContext& ctx) {
const u64 task_id = rp.Pop<u64>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called task_id={:016X}", task_id);
}
@ -468,7 +468,7 @@ void NIM_U::SetAutoDbgDat(Kernel::HLERequestContext& ctx) {
auto& auto_dbg_dat_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(auto_dbg_dat_buffer);
LOG_WARNING(Service_NIM, "(STUBBED) called auto_dbg_dat_buffer=0x{:08X}",
@ -481,7 +481,7 @@ void NIM_U::GetAutoDbgDat(Kernel::HLERequestContext& ctx) {
auto& auto_dbg_dat_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(auto_dbg_dat_buffer);
LOG_WARNING(Service_NIM, "(STUBBED) called auto_dbg_dat_buffer=0x{:08X}",
@ -495,7 +495,7 @@ void NIM_U::SetDbgTasks(Kernel::HLERequestContext& ctx) {
auto& task_infos_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(task_infos_buffer);
LOG_WARNING(Service_NIM, "(STUBBED) called max_task_infos={:08X}, task_infos_buffer=0x{:08X}",
@ -509,7 +509,7 @@ void NIM_U::GetDbgTasks(Kernel::HLERequestContext& ctx) {
auto& task_infos_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(0);
rb.PushMappedBuffer(task_infos_buffer);
@ -521,7 +521,7 @@ void NIM_U::DeleteDbgData(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -533,7 +533,7 @@ void NIM_U::SetTslXml(Kernel::HLERequestContext& ctx) {
auto& xml_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(xml_buffer);
LOG_WARNING(Service_NIM, "(STUBBED) called buffer_size={:08X}, xml_buffer=0x{:08X}",
@ -544,7 +544,7 @@ void NIM_U::GetTslXmlSize(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u64>(0);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -557,7 +557,7 @@ void NIM_U::GetTslXml(Kernel::HLERequestContext& ctx) {
auto& xml_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(xml_buffer);
LOG_WARNING(Service_NIM, "(STUBBED) called buffer_capacity={:08X}, xml_buffer=0x{:08X}",
@ -568,7 +568,7 @@ void NIM_U::DeleteTslXml(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -580,7 +580,7 @@ void NIM_U::SetDtlXml(Kernel::HLERequestContext& ctx) {
auto& xml_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(xml_buffer);
LOG_WARNING(Service_NIM, "(STUBBED) called buffer_size={:08X}, xml_buffer=0x{:08X}",
@ -591,7 +591,7 @@ void NIM_U::GetDtlXmlSize(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u64>(0);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -604,7 +604,7 @@ void NIM_U::GetDtlXml(Kernel::HLERequestContext& ctx) {
auto& xml_buffer = rp.PopMappedBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(xml_buffer);
LOG_WARNING(Service_NIM, "(STUBBED) called buffer_capacity={:08X}, xml_buffer=0x{:08X}",
@ -615,8 +615,8 @@ void NIM_U::UpdateAccountStatus(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ResultSuccess);
rb.Push(0);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -628,7 +628,7 @@ void NIM_U::StartTitleDownload(Kernel::HLERequestContext& ctx) {
const auto& download_config = rp.PopRaw<TitleDownloadConfig>();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called title_id={:016X}", download_config.title_id);
}
@ -637,7 +637,7 @@ void NIM_U::StopTitleDownload(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -649,7 +649,7 @@ void NIM_U::GetTitleDownloadProgress(Kernel::HLERequestContext& ctx) {
std::memset(&progress, 0, sizeof(progress));
IPC::RequestBuilder rb = rp.MakeBuilder(9, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(progress);
rb.Push(0);
rb.Push(0);
@ -669,7 +669,7 @@ void NIM_U::RegisterTask(Kernel::HLERequestContext& ctx) {
const auto& developer_name = rp.PopStaticBuffer();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
const auto title_name_end = std::find(title_name.begin(), title_name.end(), u'\0');
const auto title_name_utf8 =
@ -690,8 +690,8 @@ void NIM_U::IsSystemUpdateAvailable(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(4, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ResultSuccess);
rb.Push(0);
rb.Push(false);
@ -702,7 +702,7 @@ void NIM_U::Unknown2B(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_WARNING(Service_NIM, "(STUBBED) called");
}
@ -711,8 +711,8 @@ void NIM_U::UpdateTickets(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ResultSuccess);
rb.Push(0);
LOG_WARNING(Service_NIM, "(STUBBED) called");
@ -728,7 +728,7 @@ void NIM_U::DownloadTitleSeedAsync(Kernel::HLERequestContext& ctx) {
nim_async_completion_event->Signal();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(nim_async_completion_event);
LOG_WARNING(Service_NIM, "(STUBBED) called title_id={:016X}, country_code={:04X}", title_id,
@ -742,7 +742,7 @@ void NIM_U::DownloadMissingTitleSeedsAsync(Kernel::HLERequestContext& ctx) {
nim_async_completion_event->Signal();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(nim_async_completion_event);
LOG_WARNING(Service_NIM, "(STUBBED) called");

View file

@ -576,7 +576,7 @@ void NWM_UDS::Shutdown(Kernel::HLERequestContext& ctx) {
recv_buffer_memory.reset();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_NWM, "called");
}
@ -636,7 +636,7 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) {
out_buffer.Write(&data_reply_header, 0, sizeof(BeaconDataReplyHeader));
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(out_buffer);
LOG_DEBUG(Service_NWM,
@ -707,7 +707,7 @@ void NWM_UDS::GetConnectionStatus(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(13, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
{
std::scoped_lock lock(connection_status_mutex);
rb.PushRaw(connection_status);
@ -728,8 +728,8 @@ void NWM_UDS::GetNodeInformation(Kernel::HLERequestContext& ctx) {
if (!initialized) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotInitialized, ErrorModule::UDS,
ErrorSummary::StatusChanged, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotInitialized, ErrorModule::UDS,
ErrorSummary::StatusChanged, ErrorLevel::Status));
return;
}
@ -741,13 +741,13 @@ void NWM_UDS::GetNodeInformation(Kernel::HLERequestContext& ctx) {
});
if (itr == node_info.end()) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
return;
}
IPC::RequestBuilder rb = rp.MakeBuilder(11, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<NodeInfo>(*itr);
}
LOG_DEBUG(Service_NWM, "called");
@ -765,8 +765,8 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
if (data_channel == 0 || bind_node_id == 0) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
LOG_WARNING(Service_NWM, "data_channel = {}, bind_node_id = {}", data_channel,
bind_node_id);
return;
@ -775,8 +775,8 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
constexpr std::size_t MaxBindNodes = 16;
if (channel_data.size() >= MaxBindNodes) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::OutOfMemory, ErrorModule::UDS,
ErrorSummary::OutOfResource, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::OutOfMemory, ErrorModule::UDS, ErrorSummary::OutOfResource,
ErrorLevel::Status));
LOG_WARNING(Service_NWM, "max bind nodes");
return;
}
@ -784,8 +784,8 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
constexpr u32 MinRecvBufferSize = 0x5F4;
if (recv_buffer_size < MinRecvBufferSize) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument,
ErrorLevel::Usage));
LOG_WARNING(Service_NWM, "MinRecvBufferSize");
return;
}
@ -800,7 +800,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
channel_data[data_channel] = {bind_node_id, data_channel, network_node_id, event};
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushCopyObjects(event);
}
@ -810,8 +810,8 @@ void NWM_UDS::Unbind(Kernel::HLERequestContext& ctx) {
u32 bind_node_id = rp.Pop<u32>();
if (bind_node_id == 0) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
return;
}
@ -829,7 +829,7 @@ void NWM_UDS::Unbind(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(bind_node_id);
// TODO(B3N30): Find out what the other return values are
rb.Push<u32>(0);
@ -837,8 +837,8 @@ void NWM_UDS::Unbind(Kernel::HLERequestContext& ctx) {
rb.Push<u32>(0);
}
ResultCode NWM_UDS::BeginHostingNetwork(std::span<const u8> network_info_buffer,
std::vector<u8> passphrase) {
Result NWM_UDS::BeginHostingNetwork(std::span<const u8> network_info_buffer,
std::vector<u8> passphrase) {
// TODO(Subv): Store the passphrase and verify it when attempting a connection.
{
@ -901,7 +901,7 @@ ResultCode NWM_UDS::BeginHostingNetwork(std::span<const u8> network_info_buffer,
system.CoreTiming().ScheduleEvent(msToCycles(DefaultBeaconInterval * MillisecondsPerTU),
beacon_broadcast_event, 0);
return RESULT_SUCCESS;
return ResultSuccess;
}
void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) {
@ -950,22 +950,22 @@ void NWM_UDS::EjectClient(Kernel::HLERequestContext& ctx) {
// The host can not be kicked.
if (network_node_id == 1) {
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
return;
}
std::scoped_lock lock(connection_status_mutex);
if (connection_status.status != NetworkStatus::ConnectedAsHost) {
// Only the host can kick people.
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::InvalidState, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::InvalidState, ErrorLevel::Usage));
LOG_WARNING(Service_NWM, "called with status {}", connection_status.status);
return;
}
// This function always returns success if the status is valid.
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
using Network::WifiPacket;
Network::MacAddress dest_address = Network::BroadcastMac;
@ -996,7 +996,7 @@ void NWM_UDS::UpdateNetworkAttribute(Kernel::HLERequestContext& ctx) {
rp.Skip(2, false);
LOG_WARNING(Service_NWM, "stubbed");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void NWM_UDS::DestroyNetwork(Kernel::HLERequestContext& ctx) {
@ -1009,8 +1009,8 @@ void NWM_UDS::DestroyNetwork(Kernel::HLERequestContext& ctx) {
std::scoped_lock lock(connection_status_mutex);
if (connection_status.status != NetworkStatus::ConnectedAsHost) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState,
ErrorLevel::Status));
rb.Push(Result(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState,
ErrorLevel::Status));
LOG_WARNING(Service_NWM, "called with status {}",
static_cast<u32>(connection_status.status));
return;
@ -1032,7 +1032,7 @@ void NWM_UDS::DestroyNetwork(Kernel::HLERequestContext& ctx) {
}
channel_data.clear();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_NWM, "called");
}
@ -1053,8 +1053,8 @@ void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) {
connection_status.network_node_id = tmp_node_id;
node_map.clear();
LOG_DEBUG(Service_NWM, "called as a host");
rb.Push(ResultCode(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState,
ErrorLevel::Status));
rb.Push(Result(ErrCodes::WrongStatus, ErrorModule::UDS, ErrorSummary::InvalidState,
ErrorLevel::Status));
return;
}
u16_le tmp_node_id = connection_status.network_node_id;
@ -1078,7 +1078,7 @@ void NWM_UDS::DisconnectNetwork(Kernel::HLERequestContext& ctx) {
}
channel_data.clear();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_NWM, "called");
}
@ -1101,23 +1101,23 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) {
std::scoped_lock lock(connection_status_mutex);
if (connection_status.status != NetworkStatus::ConnectedAsClient &&
connection_status.status != NetworkStatus::ConnectedAsHost) {
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::InvalidState, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::InvalidState, ErrorLevel::Status));
return;
}
// There should never be a dest_node_id of 0
if (dest_node_id == 0) {
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::UDS, ErrorSummary::WrongArgument,
ErrorLevel::Status));
LOG_ERROR(Service_NWM, "dest_node_id is 0");
return;
}
if (dest_node_id == connection_status.network_node_id) {
LOG_ERROR(Service_NWM, "tried to send packet to itself");
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::UDS, ErrorSummary::WrongArgument,
ErrorLevel::Status));
return;
}
@ -1127,15 +1127,15 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) {
auto dest_address = GetNodeMacAddress(dest_node_id, flags);
if (!dest_address) {
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotFound, ErrorModule::UDS, ErrorSummary::WrongArgument,
ErrorLevel::Status));
return;
}
constexpr std::size_t MaxSize = 0x5C6;
if (data_size > MaxSize) {
rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument,
ErrorLevel::Usage));
return;
}
@ -1157,7 +1157,7 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) {
SendPacket(packet);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) {
@ -1175,8 +1175,8 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) {
connection_status.status != NetworkStatus::ConnectedAsClient &&
connection_status.status != NetworkStatus::ConnectedAsSpectator) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::InvalidState, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::InvalidState, ErrorLevel::Status));
return;
}
@ -1187,15 +1187,15 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) {
if (channel == channel_data.end()) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::NotAuthorized, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
return;
}
if (channel->second.received_packets.empty()) {
std::vector<u8> output_buffer(buff_size);
IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0);
rb.Push<u16>(0);
rb.PushStaticBuffer(std::move(output_buffer), 0);
@ -1209,8 +1209,8 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) {
if (data_size > max_out_buff_size) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument,
ErrorLevel::Usage));
return;
}
@ -1221,7 +1221,7 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) {
std::memcpy(output_buffer.data(),
next_packet.data() + sizeof(LLCHeader) + sizeof(SecureDataHeader), data_size);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(data_size);
rb.Push<u16>(secure_data.src_node_id);
rb.PushStaticBuffer(std::move(output_buffer), 0);
@ -1238,7 +1238,7 @@ void NWM_UDS::GetChannel(Kernel::HLERequestContext& ctx) {
u8 channel = is_connected ? network_channel : 0;
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(channel);
LOG_DEBUG(Service_NWM, "called");
@ -1252,7 +1252,7 @@ public:
Kernel::ThreadWakeupReason reason) {
// TODO(B3N30): Add error handling for host full and timeout
IPC::RequestBuilder rb(ctx, command_id, 1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
LOG_DEBUG(Service_NWM, "connection sequence finished");
}
@ -1331,15 +1331,15 @@ void NWM_UDS::SetApplicationData(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
if (size > ApplicationDataSize) {
rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Usage));
rb.Push(Result(ErrorDescription::TooLarge, ErrorModule::UDS, ErrorSummary::WrongArgument,
ErrorLevel::Usage));
return;
}
network_info.application_data_size = static_cast<u8>(size);
std::memcpy(network_info.application_data.data(), application_data.data(), size);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void NWM_UDS::GetApplicationData(Kernel::HLERequestContext& ctx) {
@ -1348,7 +1348,7 @@ void NWM_UDS::GetApplicationData(Kernel::HLERequestContext& ctx) {
u8 appdata_size = network_info.application_data_size;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
if (input_size < appdata_size) {
rb.Push(0);
@ -1420,7 +1420,7 @@ void NWM_UDS::DecryptBeaconData(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
std::vector<u8> output_buffer(sizeof(NodeInfo) * UDSMaxNodes);
std::memcpy(output_buffer.data(), nodes.data(), sizeof(NodeInfo) * nodes.size());

View file

@ -449,8 +449,7 @@ private:
u32 sharedmem_size, const NodeInfo& node, u16 version,
std::shared_ptr<Kernel::SharedMemory> sharedmem);
ResultCode BeginHostingNetwork(std::span<const u8> network_info_buffer,
std::vector<u8> passphrase);
Result BeginHostingNetwork(std::span<const u8> network_info_buffer, std::vector<u8> passphrase);
void ConnectToNetwork(Kernel::HLERequestContext& ctx, u16 command_id,
std::span<const u8> network_info_buffer, u8 connection_type,

View file

@ -130,21 +130,22 @@ void PLG_LDR::OnProcessExit(Kernel::Process& process, Kernel::KernelSystem& kern
}
ResultVal<Kernel::Handle> PLG_LDR::GetMemoryChangedHandle(Kernel::KernelSystem& kernel) {
if (plgldr_context.memory_changed_handle)
if (plgldr_context.memory_changed_handle) {
return plgldr_context.memory_changed_handle;
}
std::shared_ptr<Kernel::Event> evt = kernel.CreateEvent(
Kernel::ResetType::OneShot,
fmt::format("event-{:08x}", Core::System::GetInstance().GetRunningCore().GetReg(14)));
CASCADE_RESULT(plgldr_context.memory_changed_handle,
kernel.GetCurrentProcess()->handle_table.Create(std::move(evt)));
R_TRY(kernel.GetCurrentProcess()->handle_table.Create(
std::addressof(plgldr_context.memory_changed_handle), std::move(evt)));
return plgldr_context.memory_changed_handle;
}
void PLG_LDR::OnMemoryChanged(Kernel::Process& process, Kernel::KernelSystem& kernel) {
if (!plgldr_context.plugin_loaded || !plgldr_context.memory_changed_handle)
if (!plgldr_context.plugin_loaded || !plgldr_context.memory_changed_handle) {
return;
}
std::shared_ptr<Kernel::Event> evt =
kernel.GetCurrentProcess()->handle_table.Get<Kernel::Event>(
@ -159,7 +160,7 @@ void PLG_LDR::IsEnabled(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(plgldr_context.is_enabled);
}
@ -173,7 +174,7 @@ void PLG_LDR::SetEnabled(Kernel::HLERequestContext& ctx) {
Settings::values.plugin_loader_enabled.SetValue(enabled);
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push((can_change) ? RESULT_SUCCESS : Kernel::ERR_NOT_AUTHORIZED);
rb.Push((can_change) ? ResultSuccess : Kernel::ResultNotAuthorized);
}
void PLG_LDR::SetLoadSettings(Kernel::HLERequestContext& ctx) {
@ -197,7 +198,7 @@ void PLG_LDR::SetLoadSettings(Kernel::HLERequestContext& ctx) {
std::min(sizeof(PluginLoaderContext::PluginLoadParameters::config), config.GetSize()));
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void PLG_LDR::DisplayErrorMessage(Kernel::HLERequestContext& ctx) {
@ -219,14 +220,14 @@ void PLG_LDR::DisplayErrorMessage(Kernel::HLERequestContext& ctx) {
std::string(title_data.data()), std::string(desc_data.data()));
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
}
void PLG_LDR::GetPLGLDRVersion(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(plgldr_version.raw);
}
@ -238,7 +239,7 @@ void PLG_LDR::GetArbiter(Kernel::HLERequestContext& ctx) {
// signal the plgldr service thread when a event is ready. Instead we just send
// an error and the 3GX plugin will take care of it.
// (We never send any events anyways)
rb.Push(Kernel::ERR_NOT_IMPLEMENTED);
rb.Push(Kernel::ResultNotImplemented);
}
void PLG_LDR::GetPluginPath(Kernel::HLERequestContext& ctx) {
@ -259,7 +260,7 @@ void PLG_LDR::GetPluginPath(Kernel::HLERequestContext& ctx) {
path.Write(plugin_path.c_str(), 0, std::min(path.GetSize(), plugin_path.length() + 1));
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(path);
}

View file

@ -77,8 +77,8 @@ void PS_PS::EncryptDecryptAes(Kernel::HLERequestContext& ctx) {
if (algorithm == AlgorithmType::CCM_Encrypt || algorithm == AlgorithmType::CCM_Decrypt) {
// AES-CCM is not supported with this function
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(ResultCode(ErrorDescription::InvalidSection, ErrorModule::PS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
rb.Push(Result(ErrorDescription::InvalidSection, ErrorModule::PS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
rb.PushMappedBuffer(source);
rb.PushMappedBuffer(destination);
return;
@ -141,7 +141,7 @@ void PS_PS::EncryptDecryptAes(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(5, 4);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw(new_iv);
rb.PushMappedBuffer(source);
rb.PushMappedBuffer(destination);
@ -157,7 +157,7 @@ void PS_PS::GenerateRandomBytes(Kernel::HLERequestContext& ctx) {
buffer.Write(out_data.data(), 0, size);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
}

View file

@ -30,7 +30,7 @@ void Module::Interface::GetAdapterState(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ptm->battery_is_charging);
LOG_WARNING(Service_PTM, "(STUBBED) called");
@ -40,7 +40,7 @@ void Module::Interface::GetShellState(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ptm->shell_open);
}
@ -48,7 +48,7 @@ void Module::Interface::GetBatteryLevel(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(static_cast<u32>(ChargeLevels::CompletelyFull)); // Set to a completely full battery
LOG_WARNING(Service_PTM, "(STUBBED) called");
@ -58,7 +58,7 @@ void Module::Interface::GetBatteryChargeState(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ptm->battery_is_charging);
LOG_WARNING(Service_PTM, "(STUBBED) called");
@ -68,7 +68,7 @@ void Module::Interface::GetPedometerState(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(ptm->pedometer_is_counting);
LOG_WARNING(Service_PTM, "(STUBBED) called");
@ -90,7 +90,7 @@ void Module::Interface::GetStepHistory(Kernel::HLERequestContext& ctx) {
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushMappedBuffer(buffer);
LOG_WARNING(Service_PTM, "(STUBBED) called, from time(raw): 0x{:x}, for {} hours", start_time,
@ -101,7 +101,7 @@ void Module::Interface::GetTotalStepCount(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push<u32>(0);
LOG_WARNING(Service_PTM, "(STUBBED) called");
@ -111,7 +111,7 @@ void Module::Interface::GetSoftwareClosedFlag(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(false);
LOG_WARNING(Service_PTM, "(STUBBED) called");
@ -120,7 +120,7 @@ void Module::Interface::GetSoftwareClosedFlag(Kernel::HLERequestContext& ctx) {
void CheckNew3DS(IPC::RequestBuilder& rb) {
const bool is_new_3ds = Settings::values.is_new_3ds.GetValue();
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(is_new_3ds);
LOG_DEBUG(Service_PTM, "called isNew3DS = 0x{:08x}", static_cast<u32>(is_new_3ds));
@ -140,7 +140,7 @@ void Module::Interface::GetSystemTime(Kernel::HLERequestContext& ctx) {
const u64 console_time = share_page.GetSystemTimeSince2000();
IPC::RequestBuilder rb = rp.MakeBuilder(3, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.Push(console_time);
}
@ -155,7 +155,7 @@ static void WriteGameCoinData(GameCoin gamecoin_data) {
FileSys::Path gamecoin_path("/gamecoin.dat");
// If the archive didn't exist, create the files inside
if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
if (archive_result.Code() == FileSys::ResultNotFormatted) {
// Format the archive to create the directories
extdata_archive_factory.Format(archive_path, FileSys::ArchiveFormatInfo(), 0);
// Open it again to get a valid archive now that the folder exists
@ -216,7 +216,7 @@ Module::Module() {
const FileSys::Path archive_path(ptm_shared_extdata_id);
const auto archive_result = extdata_archive_factory.Open(archive_path, 0);
// If the archive didn't exist, write the default game coin file
if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
if (archive_result.Code() == FileSys::ResultNotFormatted) {
WriteGameCoinData(default_game_coin);
}
}

View file

@ -16,7 +16,7 @@ void QTM_S::GetHeadtrackingInfo(Kernel::HLERequestContext& ctx) {
std::array<u8, 0x40> data{};
IPC::RequestBuilder rb = rp.MakeBuilder(17, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(ResultSuccess);
rb.PushRaw<std::array<u8, 0x40>>(data);
LOG_DEBUG(Service, "(STUBBED) called");

View file

@ -130,7 +130,8 @@ ServiceFrameworkBase::ServiceFrameworkBase(const char* service_name, u32 max_ses
ServiceFrameworkBase::~ServiceFrameworkBase() = default;
void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) {
auto port = service_manager.RegisterService(service_name, max_sessions).Unwrap();
std::shared_ptr<Kernel::ServerPort> port;
R_ASSERT(service_manager.RegisterService(std::addressof(port), service_name, max_sessions));
port->SetHleHandler(shared_from_this());
}

View file

@ -12,14 +12,10 @@
namespace Service::SM {
static ResultCode ValidateServiceName(const std::string& name) {
if (name.size() <= 0 || name.size() > 8) {
return ERR_INVALID_NAME_SIZE;
}
if (name.find('\0') != std::string::npos) {
return ERR_NAME_CONTAINS_NUL;
}
return RESULT_SUCCESS;
static Result ValidateServiceName(const std::string& name) {
R_UNLESS(name.size() > 0 && name.size() <= 8, ResultInvalidNameSize);
R_UNLESS(name.find('\0') == std::string::npos, ResultNameContainsNul);
return ResultSuccess;
}
ServiceManager::ServiceManager(Core::System& system) : system(system) {}
@ -32,38 +28,35 @@ void ServiceManager::InstallInterfaces(Core::System& system) {
system.ServiceManager().srv_interface = srv;
}
ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(
std::string name, unsigned int max_sessions) {
CASCADE_CODE(ValidateServiceName(name));
if (registered_services.find(name) != registered_services.end())
return ERR_ALREADY_REGISTERED;
auto [server_port, client_port] = system.Kernel().CreatePortPair(max_sessions, name);
Result ServiceManager::RegisterService(std::shared_ptr<Kernel::ServerPort>* out_server_port,
std::string name, u32 max_sessions) {
R_TRY(ValidateServiceName(name));
R_UNLESS(registered_services.find(name) == registered_services.end(), ResultAlreadyRegistered);
const auto [server_port, client_port] = system.Kernel().CreatePortPair(max_sessions, name);
registered_services_inverse.emplace(client_port->GetObjectId(), name);
registered_services.emplace(std::move(name), std::move(client_port));
return server_port;
*out_server_port = server_port;
return ResultSuccess;
}
ResultVal<std::shared_ptr<Kernel::ClientPort>> ServiceManager::GetServicePort(
const std::string& name) {
Result ServiceManager::GetServicePort(std::shared_ptr<Kernel::ClientPort>* out_client_port,
const std::string& name) {
R_TRY(ValidateServiceName(name));
CASCADE_CODE(ValidateServiceName(name));
auto it = registered_services.find(name);
if (it == registered_services.end()) {
return ERR_SERVICE_NOT_REGISTERED;
}
R_UNLESS(it != registered_services.end(), ResultServiceNotRegistered);
return it->second;
*out_client_port = it->second;
return ResultSuccess;
}
ResultVal<std::shared_ptr<Kernel::ClientSession>> ServiceManager::ConnectToService(
const std::string& name) {
CASCADE_RESULT(auto client_port, GetServicePort(name));
return client_port->Connect();
Result ServiceManager::ConnectToService(std::shared_ptr<Kernel::ClientSession>* out_client_session,
const std::string& name) {
std::shared_ptr<Kernel::ClientPort> client_port;
R_TRY(GetServicePort(std::addressof(client_port), name));
return client_port->Connect(out_client_session);
}
std::string ServiceManager::GetServiceNameByPortId(u32 port) const {

View file

@ -31,19 +31,19 @@ namespace Service::SM {
class SRV;
constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(1, ErrorModule::SRV, ErrorSummary::WouldBlock,
ErrorLevel::Temporary); // 0xD0406401
constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(2, ErrorModule::SRV, ErrorSummary::WouldBlock,
ErrorLevel::Temporary); // 0xD0406402
constexpr ResultCode ERR_INVALID_NAME_SIZE(5, ErrorModule::SRV, ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9006405
constexpr ResultCode ERR_ACCESS_DENIED(6, ErrorModule::SRV, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E06406
constexpr ResultCode ERR_NAME_CONTAINS_NUL(7, ErrorModule::SRV, ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9006407
constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorDescription::AlreadyExists, ErrorModule::OS,
ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9001BFC
constexpr Result ResultServiceNotRegistered(1, ErrorModule::SRV, ErrorSummary::WouldBlock,
ErrorLevel::Temporary); // 0xD0406401
constexpr Result ResultMaxConnectionsReached(2, ErrorModule::SRV, ErrorSummary::WouldBlock,
ErrorLevel::Temporary); // 0xD0406402
constexpr Result ResultInvalidNameSize(5, ErrorModule::SRV, ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9006405
constexpr Result ResultAccessDenied(6, ErrorModule::SRV, ErrorSummary::InvalidArgument,
ErrorLevel::Permanent); // 0xD8E06406
constexpr Result ResultNameContainsNul(7, ErrorModule::SRV, ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9006407
constexpr Result ResultAlreadyRegistered(ErrorDescription::AlreadyExists, ErrorModule::OS,
ErrorSummary::WrongArgument,
ErrorLevel::Permanent); // 0xD9001BFC
class ServiceManager {
public:
@ -51,10 +51,12 @@ public:
explicit ServiceManager(Core::System& system);
ResultVal<std::shared_ptr<Kernel::ServerPort>> RegisterService(std::string name,
unsigned int max_sessions);
ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name);
ResultVal<std::shared_ptr<Kernel::ClientSession>> ConnectToService(const std::string& name);
Result RegisterService(std::shared_ptr<Kernel::ServerPort>* out_server_port, std::string name,
u32 max_sessions);
Result GetServicePort(std::shared_ptr<Kernel::ClientPort>* out_client_port,
const std::string& name);
Result ConnectToService(std::shared_ptr<Kernel::ClientSession>* out_client_session,
const std::string& name);
// For IPC Recorder
std::string GetServiceNameByPortId(u32 port) const;

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