diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-01-23 06:44:52 +0100 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-01-30 14:49:45 +0100 |
commit | 09ae6e1fa38bbf75dcb2796e96575fdba32ec69c (patch) | |
tree | e760cb36500849a65931a2f0ad0d6174be617601 /src/core/hle | |
parent | SVC: Change return type of handlers to ResultCode (diff) | |
download | yuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.tar yuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.tar.gz yuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.tar.bz2 yuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.tar.lz yuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.tar.xz yuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.tar.zst yuzu-09ae6e1fa38bbf75dcb2796e96575fdba32ec69c.zip |
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/kernel/kernel.h | 3 | ||||
-rw-r--r-- | src/core/hle/result.h | 5 | ||||
-rw-r--r-- | src/core/hle/service/fs/archive.cpp | 23 | ||||
-rw-r--r-- | src/core/hle/svc.cpp | 31 |
4 files changed, 32 insertions, 30 deletions
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 08a5db3b7..9860479ac 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -31,7 +31,8 @@ class Thread; const ResultCode ERR_OUT_OF_HANDLES(ErrorDescription::OutOfMemory, ErrorModule::Kernel, ErrorSummary::OutOfResource, ErrorLevel::Temporary); // TOOD: Verify code -const ResultCode ERR_INVALID_HANDLE = InvalidHandle(ErrorModule::Kernel); +const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel, + ErrorSummary::InvalidArgument, ErrorLevel::Permanent); enum KernelHandle : Handle { CurrentThread = 0xFFFF8000, diff --git a/src/core/hle/result.h b/src/core/hle/result.h index ad06d00aa..948b9e38e 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -227,11 +227,6 @@ inline ResultCode UnimplementedFunction(ErrorModule module) { return ResultCode(ErrorDescription::NotImplemented, module, ErrorSummary::NotSupported, ErrorLevel::Permanent); } -/// Returned when a function is passed an invalid handle. -inline ResultCode InvalidHandle(ErrorModule module) { - return ResultCode(ErrorDescription::InvalidHandle, module, - ErrorSummary::InvalidArgument, ErrorLevel::Permanent); -} /** * This is an optional value type. It holds a `ResultCode` and, if that code is a success code, diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 1bb4e4b23..6682f6590 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -43,6 +43,11 @@ const std::string SDCARD_ID = "00000000000000000000000000000000"; namespace Service { namespace FS { +// TODO: Verify code +/// Returned when a function is passed an invalid handle. +const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS, + ErrorSummary::InvalidArgument, ErrorLevel::Permanent); + // Command to access archive file enum class FileCommand : u32 { Dummy1 = 0x000100C6, @@ -280,7 +285,7 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi ResultCode CloseArchive(ArchiveHandle handle) { if (handle_map.erase(handle) == 0) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; else return RESULT_SUCCESS; } @@ -301,7 +306,7 @@ ResultCode CreateArchive(std::unique_ptr<FileSys::ArchiveBackend>&& backend, Arc ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; std::unique_ptr<FileSys::FileBackend> backend = archive->backend->OpenFile(path, mode); if (backend == nullptr) { @@ -318,7 +323,7 @@ ResultVal<Handle> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSy ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (archive->backend->DeleteFile(path)) return RESULT_SUCCESS; @@ -331,7 +336,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil Archive* src_archive = GetArchive(src_archive_handle); Archive* dest_archive = GetArchive(dest_archive_handle); if (src_archive == nullptr || dest_archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (src_archive == dest_archive) { if (src_archive->backend->RenameFile(src_path, dest_path)) @@ -350,7 +355,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (archive->backend->DeleteDirectory(path)) return RESULT_SUCCESS; @@ -361,7 +366,7 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u32 file_size) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; return archive->backend->CreateFile(path, file_size); } @@ -369,7 +374,7 @@ ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (archive->backend->CreateDirectory(path)) return RESULT_SUCCESS; @@ -382,7 +387,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons Archive* src_archive = GetArchive(src_archive_handle); Archive* dest_archive = GetArchive(dest_archive_handle); if (src_archive == nullptr || dest_archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; if (src_archive == dest_archive) { if (src_archive->backend->RenameDirectory(src_path, dest_path)) @@ -407,7 +412,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons ResultVal<Handle> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { Archive* archive = GetArchive(archive_handle); if (archive == nullptr) - return InvalidHandle(ErrorModule::FS); + return ERR_INVALID_HANDLE; std::unique_ptr<FileSys::DirectoryBackend> backend = archive->backend->OpenDirectory(path); if (backend == nullptr) { diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index bec9837a4..46fca51c7 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -26,6 +26,7 @@ // Namespace SVC using Kernel::SharedPtr; +using Kernel::ERR_INVALID_HANDLE; namespace SVC { @@ -71,7 +72,7 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o SharedPtr<SharedMemory> shared_memory = Kernel::g_handle_table.Get<SharedMemory>(handle); if (shared_memory == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; MemoryPermission permissions_type = static_cast<MemoryPermission>(permissions); switch (permissions_type) { @@ -108,7 +109,7 @@ static ResultCode ConnectToPort(Handle* out, const char* port_name) { static ResultCode SendSyncRequest(Handle handle) { SharedPtr<Kernel::Session> session = Kernel::g_handle_table.Get<Kernel::Session>(handle); if (session == nullptr) { - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; } LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str()); @@ -127,7 +128,7 @@ static ResultCode CloseHandle(Handle handle) { static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) { auto object = Kernel::g_handle_table.GetWaitObject(handle); if (object == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(), object->GetName().c_str(), nano_seconds); @@ -176,7 +177,7 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou for (int i = 0; i < handle_count; ++i) { auto object = Kernel::g_handle_table.GetWaitObject(handles[i]); if (object == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; // Check if the current thread should wait on this object... if (object->ShouldWait()) { @@ -272,7 +273,7 @@ static ResultCode ArbitrateAddress(Handle handle, u32 address, u32 type, u32 val SharedPtr<AddressArbiter> arbiter = Kernel::g_handle_table.Get<AddressArbiter>(handle); if (arbiter == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; return arbiter->ArbitrateAddress(static_cast<Kernel::ArbitrationType>(type), address, value, nanoseconds); @@ -347,7 +348,7 @@ static void ExitThread() { static ResultCode GetThreadPriority(s32* priority, Handle handle) { const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); if (thread == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; *priority = thread->GetPriority(); return RESULT_SUCCESS; @@ -357,7 +358,7 @@ static ResultCode GetThreadPriority(s32* priority, Handle handle) { static ResultCode SetThreadPriority(Handle handle, s32 priority) { SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); if (thread == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; thread->SetPriority(priority); return RESULT_SUCCESS; @@ -386,7 +387,7 @@ static ResultCode ReleaseMutex(Handle handle) { SharedPtr<Mutex> mutex = Kernel::g_handle_table.Get<Mutex>(handle); if (mutex == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; mutex->Release(); return RESULT_SUCCESS; @@ -398,7 +399,7 @@ static ResultCode GetThreadId(u32* thread_id, Handle handle) { const SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle); if (thread == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; *thread_id = thread->GetThreadId(); return RESULT_SUCCESS; @@ -430,7 +431,7 @@ static ResultCode ReleaseSemaphore(s32* count, Handle handle, s32 release_count) SharedPtr<Semaphore> semaphore = Kernel::g_handle_table.Get<Semaphore>(handle); if (semaphore == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; ResultVal<s32> release_res = semaphore->Release(release_count); if (release_res.Failed()) @@ -476,7 +477,7 @@ static ResultCode SignalEvent(Handle handle) { auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle); if (evt == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; evt->Signal(); HLE::Reschedule(__func__); @@ -489,7 +490,7 @@ static ResultCode ClearEvent(Handle handle) { auto evt = Kernel::g_handle_table.Get<Kernel::Event>(handle); if (evt == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; evt->Clear(); return RESULT_SUCCESS; @@ -520,7 +521,7 @@ static ResultCode ClearTimer(Handle handle) { SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); if (timer == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; timer->Clear(); return RESULT_SUCCESS; @@ -534,7 +535,7 @@ static ResultCode SetTimer(Handle handle, s64 initial, s64 interval) { SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); if (timer == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; timer->Set(initial, interval); return RESULT_SUCCESS; @@ -548,7 +549,7 @@ static ResultCode CancelTimer(Handle handle) { SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle); if (timer == nullptr) - return InvalidHandle(ErrorModule::Kernel); + return ERR_INVALID_HANDLE; timer->Cancel(); return RESULT_SUCCESS; |