diff --git a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_page_table.hpp b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_page_table.hpp index 6b7d001e4..efaf8a7ac 100644 --- a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_page_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_page_table.hpp @@ -191,7 +191,7 @@ namespace ams::kern::arch::arm64 { Result Map(KProcessAddress virt_addr, KPhysicalAddress phys_addr, size_t num_pages, PageTableEntry entry_template, bool disable_head_merge, size_t page_size, PageLinkedList *page_list, bool reuse_ll) { switch (page_size) { case L1BlockSize: - return this->MapL1Blocks(virt_addr, phys_addr, num_pages, entry_template, disable_head_merge, page_list, reuse_ll); + R_RETURN(this->MapL1Blocks(virt_addr, phys_addr, num_pages, entry_template, disable_head_merge, page_list, reuse_ll)); case L2ContiguousBlockSize: entry_template.SetContiguous(true); [[fallthrough]]; @@ -199,12 +199,12 @@ namespace ams::kern::arch::arm64 { case L2TegraSmmuBlockSize: #endif case L2BlockSize: - return this->MapL2Blocks(virt_addr, phys_addr, num_pages, entry_template, disable_head_merge, page_list, reuse_ll); + R_RETURN(this->MapL2Blocks(virt_addr, phys_addr, num_pages, entry_template, disable_head_merge, page_list, reuse_ll)); case L3ContiguousBlockSize: entry_template.SetContiguous(true); [[fallthrough]]; case L3BlockSize: - return this->MapL3Blocks(virt_addr, phys_addr, num_pages, entry_template, disable_head_merge, page_list, reuse_ll); + R_RETURN(this->MapL3Blocks(virt_addr, phys_addr, num_pages, entry_template, disable_head_merge, page_list, reuse_ll)); MESOSPHERE_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_process_page_table.hpp b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_process_page_table.hpp index 99839cb0e..e6f0eb1d7 100644 --- a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_process_page_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_process_page_table.hpp @@ -29,7 +29,7 @@ namespace ams::kern::arch::arm64 { } Result Initialize(u32 id, ams::svc::CreateProcessFlag as_type, bool enable_aslr, bool enable_das_merge, bool from_back, KMemoryManager::Pool pool, KProcessAddress code_address, size_t code_size, KMemoryBlockSlabManager *mem_block_slab_manager, KBlockInfoManager *block_info_manager, KPageTableManager *pt_manager, KResourceLimit *resource_limit) { - return m_page_table.InitializeForProcess(id, as_type, enable_aslr, enable_das_merge, from_back, pool, code_address, code_size, mem_block_slab_manager, block_info_manager, pt_manager, resource_limit); + R_RETURN(m_page_table.InitializeForProcess(id, as_type, enable_aslr, enable_das_merge, from_back, pool, code_address, code_size, mem_block_slab_manager, block_info_manager, pt_manager, resource_limit)); } void Finalize() { m_page_table.Finalize(); } @@ -39,231 +39,231 @@ namespace ams::kern::arch::arm64 { } Result SetMemoryPermission(KProcessAddress addr, size_t size, ams::svc::MemoryPermission perm) { - return m_page_table.SetMemoryPermission(addr, size, perm); + R_RETURN(m_page_table.SetMemoryPermission(addr, size, perm)); } Result SetProcessMemoryPermission(KProcessAddress addr, size_t size, ams::svc::MemoryPermission perm) { - return m_page_table.SetProcessMemoryPermission(addr, size, perm); + R_RETURN(m_page_table.SetProcessMemoryPermission(addr, size, perm)); } Result SetMemoryAttribute(KProcessAddress addr, size_t size, u32 mask, u32 attr) { - return m_page_table.SetMemoryAttribute(addr, size, mask, attr); + R_RETURN(m_page_table.SetMemoryAttribute(addr, size, mask, attr)); } Result SetHeapSize(KProcessAddress *out, size_t size) { - return m_page_table.SetHeapSize(out, size); + R_RETURN(m_page_table.SetHeapSize(out, size)); } Result SetMaxHeapSize(size_t size) { - return m_page_table.SetMaxHeapSize(size); + R_RETURN(m_page_table.SetMaxHeapSize(size)); } Result QueryInfo(KMemoryInfo *out_info, ams::svc::PageInfo *out_page_info, KProcessAddress addr) const { - return m_page_table.QueryInfo(out_info, out_page_info, addr); + R_RETURN(m_page_table.QueryInfo(out_info, out_page_info, addr)); } Result QueryPhysicalAddress(ams::svc::PhysicalMemoryInfo *out, KProcessAddress address) const { - return m_page_table.QueryPhysicalAddress(out, address); + R_RETURN(m_page_table.QueryPhysicalAddress(out, address)); } Result QueryStaticMapping(KProcessAddress *out, KPhysicalAddress address, size_t size) const { - return m_page_table.QueryStaticMapping(out, address, size); + R_RETURN(m_page_table.QueryStaticMapping(out, address, size)); } Result QueryIoMapping(KProcessAddress *out, KPhysicalAddress address, size_t size) const { - return m_page_table.QueryIoMapping(out, address, size); + R_RETURN(m_page_table.QueryIoMapping(out, address, size)); } Result MapMemory(KProcessAddress dst_address, KProcessAddress src_address, size_t size) { - return m_page_table.MapMemory(dst_address, src_address, size); + R_RETURN(m_page_table.MapMemory(dst_address, src_address, size)); } Result UnmapMemory(KProcessAddress dst_address, KProcessAddress src_address, size_t size) { - return m_page_table.UnmapMemory(dst_address, src_address, size); + R_RETURN(m_page_table.UnmapMemory(dst_address, src_address, size)); } Result MapCodeMemory(KProcessAddress dst_address, KProcessAddress src_address, size_t size) { - return m_page_table.MapCodeMemory(dst_address, src_address, size); + R_RETURN(m_page_table.MapCodeMemory(dst_address, src_address, size)); } Result UnmapCodeMemory(KProcessAddress dst_address, KProcessAddress src_address, size_t size) { - return m_page_table.UnmapCodeMemory(dst_address, src_address, size); + R_RETURN(m_page_table.UnmapCodeMemory(dst_address, src_address, size)); } Result MapIo(KPhysicalAddress phys_addr, size_t size, KMemoryPermission perm) { - return m_page_table.MapIo(phys_addr, size, perm); + R_RETURN(m_page_table.MapIo(phys_addr, size, perm)); } Result MapIoRegion(KProcessAddress dst_address, KPhysicalAddress phys_addr, size_t size, ams::svc::MemoryMapping mapping, ams::svc::MemoryPermission perm) { - return m_page_table.MapIoRegion(dst_address, phys_addr, size, mapping, perm); + R_RETURN(m_page_table.MapIoRegion(dst_address, phys_addr, size, mapping, perm)); } Result UnmapIoRegion(KProcessAddress dst_address, KPhysicalAddress phys_addr, size_t size) { - return m_page_table.UnmapIoRegion(dst_address, phys_addr, size); + R_RETURN(m_page_table.UnmapIoRegion(dst_address, phys_addr, size)); } Result MapStatic(KPhysicalAddress phys_addr, size_t size, KMemoryPermission perm) { - return m_page_table.MapStatic(phys_addr, size, perm); + R_RETURN(m_page_table.MapStatic(phys_addr, size, perm)); } Result MapRegion(KMemoryRegionType region_type, KMemoryPermission perm) { - return m_page_table.MapRegion(region_type, perm); + R_RETURN(m_page_table.MapRegion(region_type, perm)); } Result MapPageGroup(KProcessAddress addr, const KPageGroup &pg, KMemoryState state, KMemoryPermission perm) { - return m_page_table.MapPageGroup(addr, pg, state, perm); + R_RETURN(m_page_table.MapPageGroup(addr, pg, state, perm)); } Result UnmapPageGroup(KProcessAddress address, const KPageGroup &pg, KMemoryState state) { - return m_page_table.UnmapPageGroup(address, pg, state); + R_RETURN(m_page_table.UnmapPageGroup(address, pg, state)); } Result MapPages(KProcessAddress *out_addr, size_t num_pages, size_t alignment, KPhysicalAddress phys_addr, KMemoryState state, KMemoryPermission perm) { - return m_page_table.MapPages(out_addr, num_pages, alignment, phys_addr, state, perm); + R_RETURN(m_page_table.MapPages(out_addr, num_pages, alignment, phys_addr, state, perm)); } Result MapPages(KProcessAddress *out_addr, size_t num_pages, KMemoryState state, KMemoryPermission perm) { - return m_page_table.MapPages(out_addr, num_pages, state, perm); + R_RETURN(m_page_table.MapPages(out_addr, num_pages, state, perm)); } Result MapPages(KProcessAddress address, size_t num_pages, KMemoryState state, KMemoryPermission perm) { - return m_page_table.MapPages(address, num_pages, state, perm); + R_RETURN(m_page_table.MapPages(address, num_pages, state, perm)); } Result UnmapPages(KProcessAddress addr, size_t num_pages, KMemoryState state) { - return m_page_table.UnmapPages(addr, num_pages, state); + R_RETURN(m_page_table.UnmapPages(addr, num_pages, state)); } Result MakeAndOpenPageGroup(KPageGroup *out, KProcessAddress address, size_t num_pages, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr) { - return m_page_table.MakeAndOpenPageGroup(out, address, num_pages, state_mask, state, perm_mask, perm, attr_mask, attr); + R_RETURN(m_page_table.MakeAndOpenPageGroup(out, address, num_pages, state_mask, state, perm_mask, perm, attr_mask, attr)); } Result InvalidateProcessDataCache(KProcessAddress address, size_t size) { - return m_page_table.InvalidateProcessDataCache(address, size); + R_RETURN(m_page_table.InvalidateProcessDataCache(address, size)); } Result ReadDebugMemory(void *buffer, KProcessAddress address, size_t size) { - return m_page_table.ReadDebugMemory(buffer, address, size); + R_RETURN(m_page_table.ReadDebugMemory(buffer, address, size)); } Result ReadDebugIoMemory(void *buffer, KProcessAddress address, size_t size) { - return m_page_table.ReadDebugIoMemory(buffer, address, size); + R_RETURN(m_page_table.ReadDebugIoMemory(buffer, address, size)); } Result WriteDebugMemory(KProcessAddress address, const void *buffer, size_t size) { - return m_page_table.WriteDebugMemory(address, buffer, size); + R_RETURN(m_page_table.WriteDebugMemory(address, buffer, size)); } Result WriteDebugIoMemory(KProcessAddress address, const void *buffer, size_t size) { - return m_page_table.WriteDebugIoMemory(address, buffer, size); + R_RETURN(m_page_table.WriteDebugIoMemory(address, buffer, size)); } Result LockForMapDeviceAddressSpace(KProcessAddress address, size_t size, KMemoryPermission perm, bool is_aligned) { - return m_page_table.LockForMapDeviceAddressSpace(address, size, perm, is_aligned); + R_RETURN(m_page_table.LockForMapDeviceAddressSpace(address, size, perm, is_aligned)); } Result LockForUnmapDeviceAddressSpace(KProcessAddress address, size_t size) { - return m_page_table.LockForUnmapDeviceAddressSpace(address, size); + R_RETURN(m_page_table.LockForUnmapDeviceAddressSpace(address, size)); } Result UnlockForDeviceAddressSpace(KProcessAddress address, size_t size) { - return m_page_table.UnlockForDeviceAddressSpace(address, size); + R_RETURN(m_page_table.UnlockForDeviceAddressSpace(address, size)); } Result UnlockForDeviceAddressSpacePartialMap(KProcessAddress address, size_t size) { - return m_page_table.UnlockForDeviceAddressSpacePartialMap(address, size); + R_RETURN(m_page_table.UnlockForDeviceAddressSpacePartialMap(address, size)); } Result OpenMemoryRangeForMapDeviceAddressSpace(KPageTableBase::MemoryRange *out, KProcessAddress address, size_t size, KMemoryPermission perm, bool is_aligned) { - return m_page_table.OpenMemoryRangeForMapDeviceAddressSpace(out, address, size, perm, is_aligned); + R_RETURN(m_page_table.OpenMemoryRangeForMapDeviceAddressSpace(out, address, size, perm, is_aligned)); } Result OpenMemoryRangeForUnmapDeviceAddressSpace(KPageTableBase::MemoryRange *out, KProcessAddress address, size_t size) { - return m_page_table.OpenMemoryRangeForUnmapDeviceAddressSpace(out, address, size); + R_RETURN(m_page_table.OpenMemoryRangeForUnmapDeviceAddressSpace(out, address, size)); } Result LockForIpcUserBuffer(KPhysicalAddress *out, KProcessAddress address, size_t size) { - return m_page_table.LockForIpcUserBuffer(out, address, size); + R_RETURN(m_page_table.LockForIpcUserBuffer(out, address, size)); } Result UnlockForIpcUserBuffer(KProcessAddress address, size_t size) { - return m_page_table.UnlockForIpcUserBuffer(address, size); + R_RETURN(m_page_table.UnlockForIpcUserBuffer(address, size)); } Result LockForTransferMemory(KPageGroup *out, KProcessAddress address, size_t size, KMemoryPermission perm) { - return m_page_table.LockForTransferMemory(out, address, size, perm); + R_RETURN(m_page_table.LockForTransferMemory(out, address, size, perm)); } Result UnlockForTransferMemory(KProcessAddress address, size_t size, const KPageGroup &pg) { - return m_page_table.UnlockForTransferMemory(address, size, pg); + R_RETURN(m_page_table.UnlockForTransferMemory(address, size, pg)); } Result LockForCodeMemory(KPageGroup *out, KProcessAddress address, size_t size) { - return m_page_table.LockForCodeMemory(out, address, size); + R_RETURN(m_page_table.LockForCodeMemory(out, address, size)); } Result UnlockForCodeMemory(KProcessAddress address, size_t size, const KPageGroup &pg) { - return m_page_table.UnlockForCodeMemory(address, size, pg); + R_RETURN(m_page_table.UnlockForCodeMemory(address, size, pg)); } Result OpenMemoryRangeForProcessCacheOperation(KPageTableBase::MemoryRange *out, KProcessAddress address, size_t size) { - return m_page_table.OpenMemoryRangeForProcessCacheOperation(out, address, size); + R_RETURN(m_page_table.OpenMemoryRangeForProcessCacheOperation(out, address, size)); } Result CopyMemoryFromLinearToUser(KProcessAddress dst_addr, size_t size, KProcessAddress src_addr, u32 src_state_mask, u32 src_state, KMemoryPermission src_test_perm, u32 src_attr_mask, u32 src_attr) { - return m_page_table.CopyMemoryFromLinearToUser(dst_addr, size, src_addr, src_state_mask, src_state, src_test_perm, src_attr_mask, src_attr); + R_RETURN(m_page_table.CopyMemoryFromLinearToUser(dst_addr, size, src_addr, src_state_mask, src_state, src_test_perm, src_attr_mask, src_attr)); } Result CopyMemoryFromLinearToKernel(KProcessAddress dst_addr, size_t size, KProcessAddress src_addr, u32 src_state_mask, u32 src_state, KMemoryPermission src_test_perm, u32 src_attr_mask, u32 src_attr) { - return m_page_table.CopyMemoryFromLinearToKernel(dst_addr, size, src_addr, src_state_mask, src_state, src_test_perm, src_attr_mask, src_attr); + R_RETURN(m_page_table.CopyMemoryFromLinearToKernel(dst_addr, size, src_addr, src_state_mask, src_state, src_test_perm, src_attr_mask, src_attr)); } Result CopyMemoryFromUserToLinear(KProcessAddress dst_addr, size_t size, u32 dst_state_mask, u32 dst_state, KMemoryPermission dst_test_perm, u32 dst_attr_mask, u32 dst_attr, KProcessAddress src_addr) { - return m_page_table.CopyMemoryFromUserToLinear(dst_addr, size, dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr, src_addr); + R_RETURN(m_page_table.CopyMemoryFromUserToLinear(dst_addr, size, dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr, src_addr)); } Result CopyMemoryFromKernelToLinear(KProcessAddress dst_addr, size_t size, u32 dst_state_mask, u32 dst_state, KMemoryPermission dst_test_perm, u32 dst_attr_mask, u32 dst_attr, KProcessAddress src_addr) { - return m_page_table.CopyMemoryFromKernelToLinear(dst_addr, size, dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr, src_addr); + R_RETURN(m_page_table.CopyMemoryFromKernelToLinear(dst_addr, size, dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr, src_addr)); } Result CopyMemoryFromHeapToHeap(KProcessPageTable &dst_page_table, KProcessAddress dst_addr, size_t size, u32 dst_state_mask, u32 dst_state, KMemoryPermission dst_test_perm, u32 dst_attr_mask, u32 dst_attr, KProcessAddress src_addr, u32 src_state_mask, u32 src_state, KMemoryPermission src_test_perm, u32 src_attr_mask, u32 src_attr) { - return m_page_table.CopyMemoryFromHeapToHeap(dst_page_table.m_page_table, dst_addr, size, dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr, src_addr, src_state_mask, src_state, src_test_perm, src_attr_mask, src_attr); + R_RETURN(m_page_table.CopyMemoryFromHeapToHeap(dst_page_table.m_page_table, dst_addr, size, dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr, src_addr, src_state_mask, src_state, src_test_perm, src_attr_mask, src_attr)); } Result CopyMemoryFromHeapToHeapWithoutCheckDestination(KProcessPageTable &dst_page_table, KProcessAddress dst_addr, size_t size, u32 dst_state_mask, u32 dst_state, KMemoryPermission dst_test_perm, u32 dst_attr_mask, u32 dst_attr, KProcessAddress src_addr, u32 src_state_mask, u32 src_state, KMemoryPermission src_test_perm, u32 src_attr_mask, u32 src_attr) { - return m_page_table.CopyMemoryFromHeapToHeapWithoutCheckDestination(dst_page_table.m_page_table, dst_addr, size, dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr, src_addr, src_state_mask, src_state, src_test_perm, src_attr_mask, src_attr); + R_RETURN(m_page_table.CopyMemoryFromHeapToHeapWithoutCheckDestination(dst_page_table.m_page_table, dst_addr, size, dst_state_mask, dst_state, dst_test_perm, dst_attr_mask, dst_attr, src_addr, src_state_mask, src_state, src_test_perm, src_attr_mask, src_attr)); } Result SetupForIpc(KProcessAddress *out_dst_addr, size_t size, KProcessAddress src_addr, KProcessPageTable &src_page_table, KMemoryPermission test_perm, KMemoryState dst_state, bool send) { - return m_page_table.SetupForIpc(out_dst_addr, size, src_addr, src_page_table.m_page_table, test_perm, dst_state, send); + R_RETURN(m_page_table.SetupForIpc(out_dst_addr, size, src_addr, src_page_table.m_page_table, test_perm, dst_state, send)); } Result CleanupForIpcServer(KProcessAddress address, size_t size, KMemoryState dst_state) { - return m_page_table.CleanupForIpcServer(address, size, dst_state); + R_RETURN(m_page_table.CleanupForIpcServer(address, size, dst_state)); } Result CleanupForIpcClient(KProcessAddress address, size_t size, KMemoryState dst_state) { - return m_page_table.CleanupForIpcClient(address, size, dst_state); + R_RETURN(m_page_table.CleanupForIpcClient(address, size, dst_state)); } Result MapPhysicalMemory(KProcessAddress address, size_t size) { - return m_page_table.MapPhysicalMemory(address, size); + R_RETURN(m_page_table.MapPhysicalMemory(address, size)); } Result UnmapPhysicalMemory(KProcessAddress address, size_t size) { - return m_page_table.UnmapPhysicalMemory(address, size); + R_RETURN(m_page_table.UnmapPhysicalMemory(address, size)); } Result MapPhysicalMemoryUnsafe(KProcessAddress address, size_t size) { - return m_page_table.MapPhysicalMemoryUnsafe(address, size); + R_RETURN(m_page_table.MapPhysicalMemoryUnsafe(address, size)); } Result UnmapPhysicalMemoryUnsafe(KProcessAddress address, size_t size) { - return m_page_table.UnmapPhysicalMemoryUnsafe(address, size); + R_RETURN(m_page_table.UnmapPhysicalMemoryUnsafe(address, size)); } Result UnmapProcessMemory(KProcessAddress dst_address, size_t size, KProcessPageTable &src_page_table, KProcessAddress src_address) { - return m_page_table.UnmapProcessMemory(dst_address, size, src_page_table.m_page_table, src_address); + R_RETURN(m_page_table.UnmapProcessMemory(dst_address, size, src_page_table.m_page_table, src_address)); } void DumpMemoryBlocks() const { diff --git a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_supervisor_page_table.hpp b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_supervisor_page_table.hpp index 19f1dade7..c8ccca33d 100644 --- a/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_supervisor_page_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_supervisor_page_table.hpp @@ -42,19 +42,19 @@ namespace ams::kern::arch::arm64 { } Result MapPages(KProcessAddress *out_addr, size_t num_pages, size_t alignment, KPhysicalAddress phys_addr, KProcessAddress region_start, size_t region_num_pages, KMemoryState state, KMemoryPermission perm) { - return m_page_table.MapPages(out_addr, num_pages, alignment, phys_addr, region_start, region_num_pages, state, perm); + R_RETURN(m_page_table.MapPages(out_addr, num_pages, alignment, phys_addr, region_start, region_num_pages, state, perm)); } Result UnmapPages(KProcessAddress address, size_t num_pages, KMemoryState state) { - return m_page_table.UnmapPages(address, num_pages, state); + R_RETURN(m_page_table.UnmapPages(address, num_pages, state)); } Result MapPageGroup(KProcessAddress *out_addr, const KPageGroup &pg, KProcessAddress region_start, size_t region_num_pages, KMemoryState state, KMemoryPermission perm) { - return m_page_table.MapPageGroup(out_addr, pg, region_start, region_num_pages, state, perm); + R_RETURN(m_page_table.MapPageGroup(out_addr, pg, region_start, region_num_pages, state, perm)); } Result UnmapPageGroup(KProcessAddress address, const KPageGroup &pg, KMemoryState state) { - return m_page_table.UnmapPageGroup(address, pg, state); + R_RETURN(m_page_table.UnmapPageGroup(address, pg, state)); } bool GetPhysicalAddress(KPhysicalAddress *out, KProcessAddress address) const { diff --git a/libraries/libmesosphere/include/mesosphere/board/generic/kern_k_device_page_table.hpp b/libraries/libmesosphere/include/mesosphere/board/generic/kern_k_device_page_table.hpp index 0fb09b4ef..1a56fb3d8 100644 --- a/libraries/libmesosphere/include/mesosphere/board/generic/kern_k_device_page_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/board/generic/kern_k_device_page_table.hpp @@ -29,29 +29,29 @@ namespace ams::kern::board::generic { Result ALWAYS_INLINE Initialize(u64 space_address, u64 space_size) { MESOSPHERE_UNUSED(space_address, space_size); - return ams::kern::svc::ResultNotImplemented(); + R_THROW(ams::kern::svc::ResultNotImplemented()); } void ALWAYS_INLINE Finalize() { /* ... */ } Result ALWAYS_INLINE Attach(ams::svc::DeviceName device_name, u64 space_address, u64 space_size) { MESOSPHERE_UNUSED(device_name, space_address, space_size); - return ams::kern::svc::ResultNotImplemented(); + R_THROW(ams::kern::svc::ResultNotImplemented()); } Result ALWAYS_INLINE Detach(ams::svc::DeviceName device_name) { MESOSPHERE_UNUSED(device_name); - return ams::kern::svc::ResultNotImplemented(); + R_THROW(ams::kern::svc::ResultNotImplemented()); } Result ALWAYS_INLINE Map(KProcessPageTable *page_table, KProcessAddress process_address, size_t size, KDeviceVirtualAddress device_address, ams::svc::MemoryPermission device_perm, bool is_aligned) { MESOSPHERE_UNUSED(page_table, process_address, size, device_address, device_perm, is_aligned); - return ams::kern::svc::ResultNotImplemented(); + R_THROW(ams::kern::svc::ResultNotImplemented()); } Result ALWAYS_INLINE Unmap(KProcessPageTable *page_table, KProcessAddress process_address, size_t size, KDeviceVirtualAddress device_address) { MESOSPHERE_UNUSED(page_table, process_address, size, device_address); - return ams::kern::svc::ResultNotImplemented(); + R_THROW(ams::kern::svc::ResultNotImplemented()); } void ALWAYS_INLINE Unmap(KDeviceVirtualAddress device_address, size_t size) { diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_address_arbiter.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_address_arbiter.hpp index f413d7bbc..4066de80d 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_address_arbiter.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_address_arbiter.hpp @@ -30,11 +30,11 @@ namespace ams::kern { Result SignalToAddress(uintptr_t addr, ams::svc::SignalType type, s32 value, s32 count) { switch (type) { case ams::svc::SignalType_Signal: - return this->Signal(addr, count); + R_RETURN(this->Signal(addr, count)); case ams::svc::SignalType_SignalAndIncrementIfEqual: - return this->SignalAndIncrementIfEqual(addr, value, count); + R_RETURN(this->SignalAndIncrementIfEqual(addr, value, count)); case ams::svc::SignalType_SignalAndModifyByWaitingCountIfEqual: - return this->SignalAndModifyByWaitingCountIfEqual(addr, value, count); + R_RETURN(this->SignalAndModifyByWaitingCountIfEqual(addr, value, count)); MESOSPHERE_UNREACHABLE_DEFAULT_CASE(); } } @@ -42,11 +42,11 @@ namespace ams::kern { Result WaitForAddress(uintptr_t addr, ams::svc::ArbitrationType type, s32 value, s64 timeout) { switch (type) { case ams::svc::ArbitrationType_WaitIfLessThan: - return this->WaitIfLessThan(addr, value, false, timeout); + R_RETURN(this->WaitIfLessThan(addr, value, false, timeout)); case ams::svc::ArbitrationType_DecrementAndWaitIfLessThan: - return this->WaitIfLessThan(addr, value, true, timeout); + R_RETURN(this->WaitIfLessThan(addr, value, true, timeout)); case ams::svc::ArbitrationType_WaitIfEqual: - return this->WaitIfEqual(addr, value, timeout); + R_RETURN(this->WaitIfEqual(addr, value, timeout)); MESOSPHERE_UNREACHABLE_DEFAULT_CASE(); } } diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_device_address_space.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_device_address_space.hpp index 8b85b58ca..f80d32855 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_device_address_space.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_device_address_space.hpp @@ -42,11 +42,11 @@ namespace ams::kern { Result Detach(ams::svc::DeviceName device_name); Result MapByForce(KProcessPageTable *page_table, KProcessAddress process_address, size_t size, u64 device_address, ams::svc::MemoryPermission device_perm) { - return this->Map(page_table, process_address, size, device_address, device_perm, false); + R_RETURN(this->Map(page_table, process_address, size, device_address, device_perm, false)); } Result MapAligned(KProcessPageTable *page_table, KProcessAddress process_address, size_t size, u64 device_address, ams::svc::MemoryPermission device_perm) { - return this->Map(page_table, process_address, size, device_address, device_perm, true); + R_RETURN(this->Map(page_table, process_address, size, device_address, device_perm, true)); } Result Unmap(KProcessPageTable *page_table, KProcessAddress process_address, size_t size, u64 device_address); diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_dynamic_page_manager.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_dynamic_page_manager.hpp index 15f2c91ce..72ca881a0 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_dynamic_page_manager.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_dynamic_page_manager.hpp @@ -72,7 +72,7 @@ namespace ams::kern { m_page_bitmap.SetBit(i); } - return ResultSuccess(); + R_SUCCEED(); } constexpr KVirtualAddress GetAddress() const { return m_address; } diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp index 0f9af8fb5..5600aacfd 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp @@ -93,7 +93,7 @@ namespace ams::kern { m_free_head_index = i; } - return ResultSuccess(); + R_SUCCEED(); } constexpr ALWAYS_INLINE size_t GetTableSize() const { return m_table_size; } diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_interrupt_event.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_interrupt_event.hpp index 23531d9c5..e35c29f3e 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_interrupt_event.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_interrupt_event.hpp @@ -46,7 +46,7 @@ namespace ams::kern { /* Try to perform a reset, succeeding unconditionally. */ this->Reset(); - return ResultSuccess(); + R_SUCCEED(); } bool IsInitialized() const { return m_is_initialized; } diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_light_session.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_light_session.hpp index 8ba769ca2..228924038 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_light_session.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_light_session.hpp @@ -62,7 +62,7 @@ namespace ams::kern { bool IsServerClosed() const { return m_state != State::Normal; } bool IsClientClosed() const { return m_state != State::Normal; } - Result OnRequest(KThread *request_thread) { return m_server.OnRequest(request_thread); } + Result OnRequest(KThread *request_thread) { R_RETURN(m_server.OnRequest(request_thread)); } KLightClientSession &GetClientSession() { return m_client; } KLightServerSession &GetServerSession() { return m_server; } diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_memory_block_manager.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_memory_block_manager.hpp index ddf6f7dbe..99caae0c2 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_memory_block_manager.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_memory_block_manager.hpp @@ -41,7 +41,7 @@ namespace ams::kern { R_UNLESS(m_blocks[m_index + i] != nullptr, svc::ResultOutOfResource()); } - return ResultSuccess(); + R_SUCCEED(); } public: KMemoryBlockManagerUpdateAllocator(Result *out_result, KMemoryBlockSlabManager *sm, size_t num_blocks = MaxBlocks) : m_blocks(), m_index(MaxBlocks), m_slab_manager(sm) { diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_page_table_base.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_page_table_base.hpp index 0152f1321..c2adc0f7c 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_page_table_base.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_page_table_base.hpp @@ -284,16 +284,16 @@ namespace ams::kern { Result CheckMemoryStateContiguous(size_t *out_blocks_needed, KProcessAddress addr, size_t size, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr) const; Result CheckMemoryStateContiguous(KProcessAddress addr, size_t size, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr) const { - return this->CheckMemoryStateContiguous(nullptr, addr, size, state_mask, state, perm_mask, perm, attr_mask, attr); + R_RETURN(this->CheckMemoryStateContiguous(nullptr, addr, size, state_mask, state, perm_mask, perm, attr_mask, attr)); } Result CheckMemoryState(const KMemoryInfo &info, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr) const; Result CheckMemoryState(KMemoryState *out_state, KMemoryPermission *out_perm, KMemoryAttribute *out_attr, size_t *out_blocks_needed, KProcessAddress addr, size_t size, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr, u32 ignore_attr = DefaultMemoryIgnoreAttr) const; Result CheckMemoryState(size_t *out_blocks_needed, KProcessAddress addr, size_t size, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr, u32 ignore_attr = DefaultMemoryIgnoreAttr) const { - return this->CheckMemoryState(nullptr, nullptr, nullptr, out_blocks_needed, addr, size, state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr); + R_RETURN(this->CheckMemoryState(nullptr, nullptr, nullptr, out_blocks_needed, addr, size, state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr)); } Result CheckMemoryState(KProcessAddress addr, size_t size, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr, u32 ignore_attr = DefaultMemoryIgnoreAttr) const { - return this->CheckMemoryState(nullptr, addr, size, state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr); + R_RETURN(this->CheckMemoryState(nullptr, addr, size, state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr)); } Result LockMemoryAndOpen(KPageGroup *out_pg, KPhysicalAddress *out_paddr, KProcessAddress addr, size_t size, u32 state_mask, u32 state, u32 perm_mask, u32 perm, u32 attr_mask, u32 attr, KMemoryPermission new_perm, u32 lock_attr); @@ -351,8 +351,8 @@ namespace ams::kern { Result SetMaxHeapSize(size_t size); Result QueryInfo(KMemoryInfo *out_info, ams::svc::PageInfo *out_page_info, KProcessAddress addr) const; Result QueryPhysicalAddress(ams::svc::PhysicalMemoryInfo *out, KProcessAddress address) const; - Result QueryStaticMapping(KProcessAddress *out, KPhysicalAddress address, size_t size) const { return this->QueryMappingImpl(out, address, size, KMemoryState_Static); } - Result QueryIoMapping(KProcessAddress *out, KPhysicalAddress address, size_t size) const { return this->QueryMappingImpl(out, address, size, KMemoryState_Io); } + Result QueryStaticMapping(KProcessAddress *out, KPhysicalAddress address, size_t size) const { R_RETURN(this->QueryMappingImpl(out, address, size, KMemoryState_Static)); } + Result QueryIoMapping(KProcessAddress *out, KPhysicalAddress address, size_t size) const { R_RETURN(this->QueryMappingImpl(out, address, size, KMemoryState_Io)); } Result MapMemory(KProcessAddress dst_address, KProcessAddress src_address, size_t size); Result UnmapMemory(KProcessAddress dst_address, KProcessAddress src_address, size_t size); Result MapCodeMemory(KProcessAddress dst_address, KProcessAddress src_address, size_t size); @@ -364,15 +364,15 @@ namespace ams::kern { Result MapRegion(KMemoryRegionType region_type, KMemoryPermission perm); Result MapPages(KProcessAddress *out_addr, size_t num_pages, size_t alignment, KPhysicalAddress phys_addr, KProcessAddress region_start, size_t region_num_pages, KMemoryState state, KMemoryPermission perm) { - return this->MapPages(out_addr, num_pages, alignment, phys_addr, true, region_start, region_num_pages, state, perm); + R_RETURN(this->MapPages(out_addr, num_pages, alignment, phys_addr, true, region_start, region_num_pages, state, perm)); } Result MapPages(KProcessAddress *out_addr, size_t num_pages, size_t alignment, KPhysicalAddress phys_addr, KMemoryState state, KMemoryPermission perm) { - return this->MapPages(out_addr, num_pages, alignment, phys_addr, true, this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize, state, perm); + R_RETURN(this->MapPages(out_addr, num_pages, alignment, phys_addr, true, this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize, state, perm)); } Result MapPages(KProcessAddress *out_addr, size_t num_pages, KMemoryState state, KMemoryPermission perm) { - return this->MapPages(out_addr, num_pages, PageSize, Null, false, this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize, state, perm); + R_RETURN(this->MapPages(out_addr, num_pages, PageSize, Null, false, this->GetRegionAddress(state), this->GetRegionSize(state) / PageSize, state, perm)); } Result MapPages(KProcessAddress address, size_t num_pages, KMemoryState state, KMemoryPermission perm); diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp index cc945906b..87b14b656 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_process.hpp @@ -356,15 +356,15 @@ namespace ams::kern { } Result WaitConditionVariable(KProcessAddress address, uintptr_t cv_key, u32 tag, s64 ns) { - return m_cond_var.Wait(address, cv_key, tag, ns); + R_RETURN(m_cond_var.Wait(address, cv_key, tag, ns)); } Result SignalAddressArbiter(uintptr_t address, ams::svc::SignalType signal_type, s32 value, s32 count) { - return m_address_arbiter.SignalToAddress(address, signal_type, value, count); + R_RETURN(m_address_arbiter.SignalToAddress(address, signal_type, value, count)); } Result WaitAddressArbiter(uintptr_t address, ams::svc::ArbitrationType arb_type, s32 value, s64 timeout) { - return m_address_arbiter.WaitForAddress(address, arb_type, value, timeout); + R_RETURN(m_address_arbiter.WaitForAddress(address, arb_type, value, timeout)); } Result GetThreadList(s32 *out_num_threads, ams::kern::svc::KUserPointer out_thread_ids, s32 max_out_count); @@ -415,7 +415,7 @@ namespace ams::kern { /* We succeeded, so note that we did. */ m_is_handle_table_initialized = true; - return ResultSuccess(); + R_SUCCEED(); } ALWAYS_INLINE void FinalizeHandleTable() { diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_readable_event.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_readable_event.hpp index 08f04fa17..d5888f989 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_readable_event.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_readable_event.hpp @@ -44,7 +44,7 @@ namespace ams::kern { /* Try to perform a reset, succeeding unconditionally. */ this->Reset(); - return ResultSuccess(); + R_SUCCEED(); } virtual bool IsSignaled() const override; diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_session.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_session.hpp index 3c3e544d5..ff5718263 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_session.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_session.hpp @@ -75,7 +75,7 @@ namespace ams::kern { bool IsServerClosed() const { return this->GetState() != State::Normal; } bool IsClientClosed() const { return this->GetState() != State::Normal; } - Result OnRequest(KSessionRequest *request) { return m_server.OnRequest(request); } + Result OnRequest(KSessionRequest *request) { R_RETURN(m_server.OnRequest(request)); } KClientSession &GetClientSession() { return m_client; } KServerSession &GetServerSession() { return m_server; } diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_session_request.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_session_request.hpp index 07f9a7c5a..3ca4c1cfa 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_session_request.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_session_request.hpp @@ -190,15 +190,15 @@ namespace ams::kern { constexpr ALWAYS_INLINE size_t GetExchangeCount() const { return m_mappings.GetExchangeCount(); } ALWAYS_INLINE Result PushSend(KProcessAddress client, KProcessAddress server, size_t size, KMemoryState state) { - return m_mappings.PushSend(client, server, size, state); + R_RETURN(m_mappings.PushSend(client, server, size, state)); } ALWAYS_INLINE Result PushReceive(KProcessAddress client, KProcessAddress server, size_t size, KMemoryState state) { - return m_mappings.PushReceive(client, server, size, state); + R_RETURN(m_mappings.PushReceive(client, server, size, state)); } ALWAYS_INLINE Result PushExchange(KProcessAddress client, KProcessAddress server, size_t size, KMemoryState state) { - return m_mappings.PushExchange(client, server, size, state); + R_RETURN(m_mappings.PushExchange(client, server, size, state)); } constexpr ALWAYS_INLINE KProcessAddress GetSendClientAddress(size_t i) const { return m_mappings.GetSendClientAddress(i); } diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp index 93958cf58..a9574e584 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp @@ -256,15 +256,15 @@ namespace ams::kern { static Result InitializeThread(KThread *thread, KThreadFunction func, uintptr_t arg, KProcessAddress user_stack_top, s32 prio, s32 virt_core, KProcess *owner, ThreadType type); public: static Result InitializeKernelThread(KThread *thread, KThreadFunction func, uintptr_t arg, s32 prio, s32 virt_core) { - return InitializeThread(thread, func, arg, Null, prio, virt_core, nullptr, ThreadType_Kernel); + R_RETURN(InitializeThread(thread, func, arg, Null, prio, virt_core, nullptr, ThreadType_Kernel)); } static Result InitializeHighPriorityThread(KThread *thread, KThreadFunction func, uintptr_t arg) { - return InitializeThread(thread, func, arg, Null, 0, GetCurrentCoreId(), nullptr, ThreadType_HighPriority); + R_RETURN(InitializeThread(thread, func, arg, Null, 0, GetCurrentCoreId(), nullptr, ThreadType_HighPriority)); } static Result InitializeUserThread(KThread *thread, KThreadFunction func, uintptr_t arg, KProcessAddress user_stack_top, s32 prio, s32 virt_core, KProcess *owner) { - return InitializeThread(thread, func, arg, user_stack_top, prio, virt_core, owner, ThreadType_User); + R_RETURN(InitializeThread(thread, func, arg, user_stack_top, prio, virt_core, owner, ThreadType_User)); } static void ResumeThreadsSuspendedForInit(); diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_unsafe_memory.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_unsafe_memory.hpp index 916227f7b..db63c2974 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_unsafe_memory.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_unsafe_memory.hpp @@ -72,7 +72,7 @@ namespace ams::kern { R_UNLESS(size >= m_current_size, svc::ResultLimitReached()); m_limit_size = size; - return ResultSuccess(); + R_SUCCEED(); } }; } diff --git a/libraries/libmesosphere/include/mesosphere/kern_select_page_table.hpp b/libraries/libmesosphere/include/mesosphere/kern_select_page_table.hpp index 49eb36a2d..d6cd1f7b0 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_select_page_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_select_page_table.hpp @@ -41,15 +41,15 @@ namespace ams::kern { static_assert(std::derived_from); ALWAYS_INLINE Result KPageTableBase::Operate(PageLinkedList *page_list, KProcessAddress virt_addr, size_t num_pages, KPhysicalAddress phys_addr, bool is_pa_valid, const KPageProperties properties, OperationType operation, bool reuse_ll) { - return static_cast(this)->OperateImpl(page_list, virt_addr, num_pages, phys_addr, is_pa_valid, properties, operation, reuse_ll); + R_RETURN(static_cast(this)->OperateImpl(page_list, virt_addr, num_pages, phys_addr, is_pa_valid, properties, operation, reuse_ll)); } ALWAYS_INLINE Result KPageTableBase::Operate(PageLinkedList *page_list, KProcessAddress virt_addr, size_t num_pages, const KPageGroup &page_group, const KPageProperties properties, OperationType operation, bool reuse_ll) { - return static_cast(this)->OperateImpl(page_list, virt_addr, num_pages, page_group, properties, operation, reuse_ll); + R_RETURN(static_cast(this)->OperateImpl(page_list, virt_addr, num_pages, page_group, properties, operation, reuse_ll)); } ALWAYS_INLINE void KPageTableBase::FinalizeUpdate(PageLinkedList *page_list) { - return static_cast(this)->FinalizeUpdateImpl(page_list); + static_cast(this)->FinalizeUpdateImpl(page_list); } } \ No newline at end of file diff --git a/libraries/libmesosphere/include/mesosphere/svc/kern_svc_k_user_pointer.hpp b/libraries/libmesosphere/include/mesosphere/svc/kern_svc_k_user_pointer.hpp index cc06cfd77..ad2c107c5 100644 --- a/libraries/libmesosphere/include/mesosphere/svc/kern_svc_k_user_pointer.hpp +++ b/libraries/libmesosphere/include/mesosphere/svc/kern_svc_k_user_pointer.hpp @@ -56,12 +56,12 @@ namespace ams::kern::svc { public: static ALWAYS_INLINE Result CopyFromUserspace(void *dst, const void *src, size_t size) { R_UNLESS(UserspaceAccess::CopyMemoryFromUser(dst, src, size), svc::ResultInvalidPointer()); - return ResultSuccess(); + R_SUCCEED(); } static ALWAYS_INLINE Result CopyToUserspace(void *dst, const void *src, size_t size) { R_UNLESS(UserspaceAccess::CopyMemoryToUser(dst, src, size), svc::ResultInvalidPointer()); - return ResultSuccess(); + R_SUCCEED(); } }; @@ -72,12 +72,12 @@ namespace ams::kern::svc { public: static ALWAYS_INLINE Result CopyFromUserspace(void *dst, const void *src, size_t size) { R_UNLESS(UserspaceAccess::CopyMemoryFromUserAligned32Bit(dst, src, size), svc::ResultInvalidPointer()); - return ResultSuccess(); + R_SUCCEED(); } static ALWAYS_INLINE Result CopyToUserspace(void *dst, const void *src, size_t size) { R_UNLESS(UserspaceAccess::CopyMemoryToUserAligned32Bit(dst, src, size), svc::ResultInvalidPointer()); - return ResultSuccess(); + R_SUCCEED(); } }; @@ -88,12 +88,12 @@ namespace ams::kern::svc { public: static ALWAYS_INLINE Result CopyFromUserspace(void *dst, const void *src, size_t size) { R_UNLESS(UserspaceAccess::CopyMemoryFromUserAligned64Bit(dst, src, size), svc::ResultInvalidPointer()); - return ResultSuccess(); + R_SUCCEED(); } static ALWAYS_INLINE Result CopyToUserspace(void *dst, const void *src, size_t size) { R_UNLESS(UserspaceAccess::CopyMemoryToUserAligned64Bit(dst, src, size), svc::ResultInvalidPointer()); - return ResultSuccess(); + R_SUCCEED(); } }; @@ -111,21 +111,21 @@ namespace ams::kern::svc { CT *m_ptr; private: ALWAYS_INLINE Result CopyToImpl(void *p, size_t size) const { - return Traits::CopyFromUserspace(p, m_ptr, size); + R_RETURN(Traits::CopyFromUserspace(p, m_ptr, size)); } ALWAYS_INLINE Result CopyFromImpl(const void *p, size_t size) const { - return Traits::CopyToUserspace(m_ptr, p, size); + R_RETURN(Traits::CopyToUserspace(m_ptr, p, size)); } protected: - ALWAYS_INLINE Result CopyTo(T *p) const { return this->CopyToImpl(p, sizeof(*p)); } - ALWAYS_INLINE Result CopyFrom(const T *p) const { return this->CopyFromImpl(p, sizeof(*p)); } + ALWAYS_INLINE Result CopyTo(T *p) const { R_RETURN(this->CopyToImpl(p, sizeof(*p))); } + ALWAYS_INLINE Result CopyFrom(const T *p) const { R_RETURN(this->CopyFromImpl(p, sizeof(*p))); } - ALWAYS_INLINE Result CopyArrayElementTo(T *p, size_t index) const { return Traits::CopyFromUserspace(p, m_ptr + index, sizeof(*p)); } - ALWAYS_INLINE Result CopyArrayElementFrom(const T *p, size_t index) const { return Traits::CopyToUserspace(m_ptr + index, p, sizeof(*p)); } + ALWAYS_INLINE Result CopyArrayElementTo(T *p, size_t index) const { R_RETURN(Traits::CopyFromUserspace(p, m_ptr + index, sizeof(*p))); } + ALWAYS_INLINE Result CopyArrayElementFrom(const T *p, size_t index) const { R_RETURN(Traits::CopyToUserspace(m_ptr + index, p, sizeof(*p))); } - ALWAYS_INLINE Result CopyArrayTo(T *arr, size_t count) const { return this->CopyToImpl(arr, sizeof(*arr) * count); } - ALWAYS_INLINE Result CopyArrayFrom(const T *arr, size_t count) const { return this->CopyFromImpl(arr, sizeof(*arr) * count); } + ALWAYS_INLINE Result CopyArrayTo(T *arr, size_t count) const { R_RETURN(this->CopyToImpl(arr, sizeof(*arr) * count)); } + ALWAYS_INLINE Result CopyArrayFrom(const T *arr, size_t count) const { R_RETURN(this->CopyFromImpl(arr, sizeof(*arr) * count)); } constexpr ALWAYS_INLINE bool IsNull() const { return m_ptr == nullptr; } @@ -145,11 +145,11 @@ namespace ams::kern::svc { ALWAYS_INLINE Result CopyStringTo(char *dst, size_t size) const { static_assert(sizeof(char) == 1); R_UNLESS(UserspaceAccess::CopyStringFromUser(dst, m_ptr, size) > 0, svc::ResultInvalidPointer()); - return ResultSuccess(); + R_SUCCEED(); } ALWAYS_INLINE Result CopyArrayElementTo(char *dst, size_t index) const { - return Traits::CopyFromUserspace(dst, m_ptr + index, sizeof(*dst)); + R_RETURN(Traits::CopyFromUserspace(dst, m_ptr + index, sizeof(*dst))); } constexpr ALWAYS_INLINE bool IsNull() const { return m_ptr == nullptr; } diff --git a/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp b/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp index 1a491671d..15fecd44c 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_cpu.cpp @@ -304,7 +304,7 @@ namespace ams::kern::arch::arm64::cpu { MESOSPHERE_ASSERT(util::IsAligned(end, DataCacheLineSize)); R_UNLESS(UserspaceAccess::InvalidateDataCache(start, end), svc::ResultInvalidCurrentMemory()); DataSynchronizationBarrier(); - return ResultSuccess(); + R_SUCCEED(); } ALWAYS_INLINE Result StoreDataCacheRange(uintptr_t start, uintptr_t end) { @@ -312,7 +312,7 @@ namespace ams::kern::arch::arm64::cpu { MESOSPHERE_ASSERT(util::IsAligned(end, DataCacheLineSize)); R_UNLESS(UserspaceAccess::StoreDataCache(start, end), svc::ResultInvalidCurrentMemory()); DataSynchronizationBarrier(); - return ResultSuccess(); + R_SUCCEED(); } ALWAYS_INLINE Result FlushDataCacheRange(uintptr_t start, uintptr_t end) { @@ -320,7 +320,7 @@ namespace ams::kern::arch::arm64::cpu { MESOSPHERE_ASSERT(util::IsAligned(end, DataCacheLineSize)); R_UNLESS(UserspaceAccess::FlushDataCache(start, end), svc::ResultInvalidCurrentMemory()); DataSynchronizationBarrier(); - return ResultSuccess(); + R_SUCCEED(); } ALWAYS_INLINE Result InvalidateInstructionCacheRange(uintptr_t start, uintptr_t end) { @@ -328,7 +328,7 @@ namespace ams::kern::arch::arm64::cpu { MESOSPHERE_ASSERT(util::IsAligned(end, InstructionCacheLineSize)); R_UNLESS(UserspaceAccess::InvalidateInstructionCache(start, end), svc::ResultInvalidCurrentMemory()); EnsureInstructionConsistency(); - return ResultSuccess(); + R_SUCCEED(); } ALWAYS_INLINE void InvalidateEntireInstructionCacheLocalImpl() { @@ -440,7 +440,7 @@ namespace ams::kern::arch::arm64::cpu { R_TRY(InvalidateDataCacheRange(aligned_start, aligned_end)); } - return ResultSuccess(); + R_SUCCEED(); } Result StoreDataCache(const void *addr, size_t size) { @@ -448,7 +448,7 @@ namespace ams::kern::arch::arm64::cpu { const uintptr_t start = util::AlignDown(reinterpret_cast(addr), DataCacheLineSize); const uintptr_t end = util::AlignUp( reinterpret_cast(addr) + size, DataCacheLineSize); - return StoreDataCacheRange(start, end); + R_RETURN(StoreDataCacheRange(start, end)); } Result FlushDataCache(const void *addr, size_t size) { @@ -456,7 +456,7 @@ namespace ams::kern::arch::arm64::cpu { const uintptr_t start = util::AlignDown(reinterpret_cast(addr), DataCacheLineSize); const uintptr_t end = util::AlignUp( reinterpret_cast(addr) + size, DataCacheLineSize); - return FlushDataCacheRange(start, end); + R_RETURN(FlushDataCacheRange(start, end)); } Result InvalidateInstructionCache(void *addr, size_t size) { @@ -469,7 +469,7 @@ namespace ams::kern::arch::arm64::cpu { /* Request the interrupt helper to perform an instruction memory barrier. */ g_cache_operation_handler.RequestOperation(KCacheHelperInterruptHandler::Operation::InstructionMemoryBarrier); - return ResultSuccess(); + R_SUCCEED(); } void InvalidateEntireInstructionCache() { diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_debug.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_debug.cpp index c065f69b7..6f6b1334a 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_debug.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_debug.cpp @@ -131,7 +131,7 @@ namespace ams::kern::arch::arm64 { } /* Get the FPU context. */ - return this->GetFpuContext(out, thread, context_flags); + R_RETURN(this->GetFpuContext(out, thread, context_flags)); } Result KDebug::SetThreadContextImpl(const ams::svc::ThreadContext &ctx, KThread *thread, u32 context_flags) { @@ -180,7 +180,7 @@ namespace ams::kern::arch::arm64 { } /* Set the FPU context. */ - return this->SetFpuContext(ctx, thread, context_flags); + R_RETURN(this->SetFpuContext(ctx, thread, context_flags)); } Result KDebug::GetFpuContext(ams::svc::ThreadContext *out, KThread *thread, u32 context_flags) { @@ -218,7 +218,7 @@ namespace ams::kern::arch::arm64 { } } - return ResultSuccess(); + R_SUCCEED(); } Result KDebug::SetFpuContext(const ams::svc::ThreadContext &ctx, KThread *thread, u32 context_flags) { @@ -243,11 +243,11 @@ namespace ams::kern::arch::arm64 { t_ctx->SetFpuRegisters(ctx.v, this->Is64Bit()); } - return ResultSuccess(); + R_SUCCEED(); } Result KDebug::BreakIfAttached(ams::svc::BreakReason break_reason, uintptr_t address, size_t size) { - return KDebugBase::OnDebugEvent(ams::svc::DebugEvent_Exception, ams::svc::DebugException_UserBreak, GetProgramCounter(GetCurrentThread()), break_reason, address, size); + R_RETURN(KDebugBase::OnDebugEvent(ams::svc::DebugEvent_Exception, ams::svc::DebugException_UserBreak, GetProgramCounter(GetCurrentThread()), break_reason, address, size)); } #define MESOSPHERE_SET_HW_BREAK_POINT(ID, FLAGS, VALUE) \ @@ -384,10 +384,10 @@ namespace ams::kern::arch::arm64 { } } else { /* Invalid name. */ - return svc::ResultInvalidEnumValue(); + R_THROW(svc::ResultInvalidEnumValue()); } - return ResultSuccess(); + R_SUCCEED(); } #undef MESOSPHERE_SET_HW_WATCH_POINT diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp index 9ac764dd7..95e917901 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_interrupt_manager.cpp @@ -215,12 +215,12 @@ namespace ams::kern::arch::arm64 { if (KInterruptController::IsGlobal(irq)) { KScopedInterruptDisable di; KScopedSpinLock lk(this->GetGlobalInterruptLock()); - return this->BindGlobal(handler, irq, core_id, priority, manual_clear, level); + R_RETURN(this->BindGlobal(handler, irq, core_id, priority, manual_clear, level)); } else { MESOSPHERE_ASSERT(core_id == GetCurrentCoreId()); KScopedInterruptDisable di; - return this->BindLocal(handler, irq, priority, manual_clear); + R_RETURN(this->BindLocal(handler, irq, priority, manual_clear)); } } @@ -234,12 +234,12 @@ namespace ams::kern::arch::arm64 { KScopedInterruptDisable di; KScopedSpinLock lk(this->GetGlobalInterruptLock()); - return this->UnbindGlobal(irq); + R_RETURN(this->UnbindGlobal(irq)); } else { MESOSPHERE_ASSERT(core_id == GetCurrentCoreId()); KScopedInterruptDisable di; - return this->UnbindLocal(irq); + R_RETURN(this->UnbindLocal(irq)); } } @@ -252,12 +252,12 @@ namespace ams::kern::arch::arm64 { if (KInterruptController::IsGlobal(irq)) { KScopedInterruptDisable di; KScopedSpinLock lk(this->GetGlobalInterruptLock()); - return this->ClearGlobal(irq); + R_RETURN(this->ClearGlobal(irq)); } else { MESOSPHERE_ASSERT(core_id == GetCurrentCoreId()); KScopedInterruptDisable di; - return this->ClearLocal(irq); + R_RETURN(this->ClearLocal(irq)); } } @@ -288,7 +288,7 @@ namespace ams::kern::arch::arm64 { m_interrupt_controller.SetPriorityLevel(irq, priority); m_interrupt_controller.Enable(irq); - return ResultSuccess(); + R_SUCCEED(); } Result KInterruptManager::BindLocal(KInterruptHandler *handler, s32 irq, s32 priority, bool manual_clear) { @@ -311,7 +311,7 @@ namespace ams::kern::arch::arm64 { m_interrupt_controller.SetPriorityLevel(irq, priority); m_interrupt_controller.Enable(irq); - return ResultSuccess(); + R_SUCCEED(); } Result KInterruptManager::UnbindGlobal(s32 irq) { @@ -323,7 +323,7 @@ namespace ams::kern::arch::arm64 { GetGlobalInterruptEntry(irq).handler = nullptr; - return ResultSuccess(); + R_SUCCEED(); } Result KInterruptManager::UnbindLocal(s32 irq) { @@ -335,7 +335,7 @@ namespace ams::kern::arch::arm64 { entry.handler = nullptr; - return ResultSuccess(); + R_SUCCEED(); } Result KInterruptManager::ClearGlobal(s32 irq) { @@ -350,7 +350,7 @@ namespace ams::kern::arch::arm64 { /* Clear and enable. */ entry.needs_clear = false; m_interrupt_controller.Enable(irq); - return ResultSuccess(); + R_SUCCEED(); } Result KInterruptManager::ClearLocal(s32 irq) { @@ -365,7 +365,7 @@ namespace ams::kern::arch::arm64 { /* Clear and set priority. */ entry.needs_clear = false; m_interrupt_controller.SetPriorityLevel(irq, entry.priority); - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp index 23c680dcb..2622fe355 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_thread_context.cpp @@ -150,12 +150,12 @@ namespace ams::kern::arch::arm64 { /* Lock the context, if we're a main thread. */ m_locked = is_main; - return ResultSuccess(); + R_SUCCEED(); } Result KThreadContext::Finalize() { /* This doesn't actually do anything. */ - return ResultSuccess(); + R_SUCCEED(); } void KThreadContext::SetArguments(uintptr_t arg0, uintptr_t arg1) { diff --git a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_device_page_table.cpp b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_device_page_table.cpp index c98f7181a..e9899f574 100644 --- a/libraries/libmesosphere/source/board/nintendo/nx/kern_k_device_page_table.cpp +++ b/libraries/libmesosphere/source/board/nintendo/nx/kern_k_device_page_table.cpp @@ -334,7 +334,7 @@ namespace ams::kern::board::nintendo::nx { for (size_t i = 0; i < num_reserved; i++) { this->ReleaseImpl(out[i]); } - return svc::ResultOutOfResource(); + R_THROW(svc::ResultOutOfResource()); } void Release(u8 asid) { diff --git a/libraries/libmesosphere/source/board/nintendo/nx/kern_lps_driver.cpp b/libraries/libmesosphere/source/board/nintendo/nx/kern_lps_driver.cpp index f2094e13b..bce9da12a 100644 --- a/libraries/libmesosphere/source/board/nintendo/nx/kern_lps_driver.cpp +++ b/libraries/libmesosphere/source/board/nintendo/nx/kern_lps_driver.cpp @@ -392,7 +392,7 @@ namespace ams::kern::board::nintendo::nx::lps { /* Instruct BPMP to enable suspend-to-sc7. */ R_UNLESS(BpmpEnableSuspend(TEGRA_BPMP_PM_SC7, 0) == 0, svc::ResultInvalidState()); - return ResultSuccess(); + R_SUCCEED(); } void InvokeCpuSleepHandler(uintptr_t arg, uintptr_t entry) { diff --git a/libraries/libmesosphere/source/kern_debug_log.cpp b/libraries/libmesosphere/source/kern_debug_log.cpp index 5f296b65b..898937952 100644 --- a/libraries/libmesosphere/source/kern_debug_log.cpp +++ b/libraries/libmesosphere/source/kern_debug_log.cpp @@ -55,7 +55,7 @@ namespace ams::kern { Result PutUserString(ams::kern::svc::KUserPointer user_str, size_t len) { /* Only print if the implementation is initialized. */ if (!g_initialized_impl) { - return ResultSuccess(); + R_SUCCEED(); } #if defined(MESOSPHERE_DEBUG_LOG_USE_SEMIHOSTING) @@ -78,7 +78,7 @@ namespace ams::kern { KDebugLogImpl::Flush(); #endif - return ResultSuccess(); + R_SUCCEED(); } #endif @@ -173,7 +173,7 @@ namespace ams::kern { MESOSPHERE_UNUSED(user_str, len); #endif - return ResultSuccess(); + R_SUCCEED(); } void KDebugLog::Save() { diff --git a/libraries/libmesosphere/source/kern_k_address_arbiter.cpp b/libraries/libmesosphere/source/kern_k_address_arbiter.cpp index f8e15984a..00290c81a 100644 --- a/libraries/libmesosphere/source/kern_k_address_arbiter.cpp +++ b/libraries/libmesosphere/source/kern_k_address_arbiter.cpp @@ -82,7 +82,7 @@ namespace ams::kern { ++num_waiters; } } - return ResultSuccess(); + R_SUCCEED(); } Result KAddressArbiter::SignalAndIncrementIfEqual(uintptr_t addr, s32 value, s32 count) { @@ -109,7 +109,7 @@ namespace ams::kern { ++num_waiters; } } - return ResultSuccess(); + R_SUCCEED(); } Result KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(uintptr_t addr, s32 value, s32 count) { @@ -171,7 +171,7 @@ namespace ams::kern { ++num_waiters; } } - return ResultSuccess(); + R_SUCCEED(); } Result KAddressArbiter::WaitIfLessThan(uintptr_t addr, s32 value, bool decrement, s64 timeout) { @@ -186,7 +186,7 @@ namespace ams::kern { /* Check that the thread isn't terminating. */ if (cur_thread->IsTerminationRequested()) { slp.CancelSleep(); - return svc::ResultTerminationRequested(); + R_THROW(svc::ResultTerminationRequested()); } /* Read the value from userspace. */ @@ -200,19 +200,19 @@ namespace ams::kern { if (!succeeded) { slp.CancelSleep(); - return svc::ResultInvalidCurrentMemory(); + R_THROW(svc::ResultInvalidCurrentMemory()); } /* Check that the value is less than the specified one. */ if (user_value >= value) { slp.CancelSleep(); - return svc::ResultInvalidState(); + R_THROW(svc::ResultInvalidState()); } /* Check that the timeout is non-zero. */ if (timeout == 0) { slp.CancelSleep(); - return svc::ResultTimedOut(); + R_THROW(svc::ResultTimedOut()); } /* Set the arbiter. */ @@ -225,7 +225,7 @@ namespace ams::kern { } /* Get the wait result. */ - return cur_thread->GetWaitResult(); + R_RETURN(cur_thread->GetWaitResult()); } Result KAddressArbiter::WaitIfEqual(uintptr_t addr, s32 value, s64 timeout) { @@ -240,26 +240,26 @@ namespace ams::kern { /* Check that the thread isn't terminating. */ if (cur_thread->IsTerminationRequested()) { slp.CancelSleep(); - return svc::ResultTerminationRequested(); + R_THROW(svc::ResultTerminationRequested()); } /* Read the value from userspace. */ s32 user_value; if (!ReadFromUser(std::addressof(user_value), addr)) { slp.CancelSleep(); - return svc::ResultInvalidCurrentMemory(); + R_THROW(svc::ResultInvalidCurrentMemory()); } /* Check that the value is equal. */ if (value != user_value) { slp.CancelSleep(); - return svc::ResultInvalidState(); + R_THROW(svc::ResultInvalidState()); } /* Check that the timeout is non-zero. */ if (timeout == 0) { slp.CancelSleep(); - return svc::ResultTimedOut(); + R_THROW(svc::ResultTimedOut()); } /* Set the arbiter. */ @@ -272,7 +272,7 @@ namespace ams::kern { } /* Get the wait result. */ - return cur_thread->GetWaitResult(); + R_RETURN(cur_thread->GetWaitResult()); } } diff --git a/libraries/libmesosphere/source/kern_k_capabilities.cpp b/libraries/libmesosphere/source/kern_k_capabilities.cpp index 1aa8f4999..d68d902eb 100644 --- a/libraries/libmesosphere/source/kern_k_capabilities.cpp +++ b/libraries/libmesosphere/source/kern_k_capabilities.cpp @@ -38,7 +38,7 @@ namespace ams::kern { m_intended_kernel_version.Set(ams::svc::SupportedKernelMinorVersion); /* Parse the capabilities array. */ - return this->SetCapabilities(caps, num_caps, page_table); + R_RETURN(this->SetCapabilities(caps, num_caps, page_table)); } Result KCapabilities::Initialize(svc::KUserPointer user_caps, s32 num_caps, KProcessPageTable *page_table) { @@ -55,7 +55,7 @@ namespace ams::kern { m_priority_mask = 0; /* Parse the user capabilities array. */ - return this->SetCapabilities(user_caps, num_caps, page_table); + R_RETURN(this->SetCapabilities(user_caps, num_caps, page_table)); } Result KCapabilities::SetCorePriorityCapability(const util::BitPack32 cap) { @@ -93,7 +93,7 @@ namespace ams::kern { /* Processes must not have access to kernel thread priorities. */ R_UNLESS((m_priority_mask & 0xF) == 0, svc::ResultInvalidArgument()); - return ResultSuccess(); + R_SUCCEED(); } Result KCapabilities::SetSyscallMaskCapability(const util::BitPack32 cap, u32 &set_svc) { @@ -113,7 +113,7 @@ namespace ams::kern { } } - return ResultSuccess(); + R_SUCCEED(); } Result KCapabilities::MapRange(const util::BitPack32 cap, const util::BitPack32 size_cap, KProcessPageTable *page_table) { @@ -136,9 +136,9 @@ namespace ams::kern { /* Do the mapping. */ const KMemoryPermission perm = cap.Get() ? KMemoryPermission_UserRead : KMemoryPermission_UserReadWrite; if (size_cap.Get()) { - return page_table->MapStatic(phys_addr, size, perm); + R_RETURN(page_table->MapStatic(phys_addr, size, perm)); } else { - return page_table->MapIo(phys_addr, size, perm); + R_RETURN(page_table->MapIo(phys_addr, size, perm)); } } @@ -153,7 +153,7 @@ namespace ams::kern { R_UNLESS(((phys_addr + size - 1) & ~PhysicalMapAllowedMask) == 0, svc::ResultInvalidAddress()); /* Do the mapping. */ - return page_table->MapIo(phys_addr, size, KMemoryPermission_UserReadWrite); + R_RETURN(page_table->MapIo(phys_addr, size, KMemoryPermission_UserReadWrite)); } Result KCapabilities::MapRegion(const util::BitPack32 cap, KProcessPageTable *page_table) { @@ -181,11 +181,11 @@ namespace ams::kern { R_TRY(page_table->MapRegion(MemoryRegions[static_cast(type)], perm)); break; default: - return svc::ResultNotFound(); + R_THROW(svc::ResultNotFound()); } } - return ResultSuccess(); + R_SUCCEED(); } Result KCapabilities::SetInterruptPairCapability(const util::BitPack32 cap) { @@ -199,7 +199,7 @@ namespace ams::kern { } } - return ResultSuccess(); + R_SUCCEED(); } Result KCapabilities::SetProgramTypeCapability(const util::BitPack32 cap) { @@ -207,7 +207,7 @@ namespace ams::kern { R_UNLESS(cap.Get() == 0, svc::ResultReservedUsed()); m_program_type = cap.Get(); - return ResultSuccess(); + R_SUCCEED(); } Result KCapabilities::SetKernelVersionCapability(const util::BitPack32 cap) { @@ -218,7 +218,7 @@ namespace ams::kern { m_intended_kernel_version = cap; R_UNLESS(m_intended_kernel_version.Get() != 0, svc::ResultInvalidArgument()); - return ResultSuccess(); + R_SUCCEED(); } Result KCapabilities::SetHandleTableCapability(const util::BitPack32 cap) { @@ -226,7 +226,7 @@ namespace ams::kern { R_UNLESS(cap.Get() == 0, svc::ResultReservedUsed()); m_handle_table_size = cap.Get(); - return ResultSuccess(); + R_SUCCEED(); } Result KCapabilities::SetDebugFlagsCapability(const util::BitPack32 cap) { @@ -235,7 +235,7 @@ namespace ams::kern { m_debug_capabilities.Set(cap.Get()); m_debug_capabilities.Set(cap.Get()); - return ResultSuccess(); + R_SUCCEED(); } Result KCapabilities::SetCapability(const util::BitPack32 cap, u32 &set_flags, u32 &set_svc, KProcessPageTable *page_table) { @@ -253,16 +253,16 @@ namespace ams::kern { /* Process the capability. */ switch (type) { - case CapabilityType::CorePriority: return this->SetCorePriorityCapability(cap); - case CapabilityType::SyscallMask: return this->SetSyscallMaskCapability(cap, set_svc); - case CapabilityType::MapIoPage: return this->MapIoPage(cap, page_table); - case CapabilityType::MapRegion: return this->MapRegion(cap, page_table); - case CapabilityType::InterruptPair: return this->SetInterruptPairCapability(cap); - case CapabilityType::ProgramType: return this->SetProgramTypeCapability(cap); - case CapabilityType::KernelVersion: return this->SetKernelVersionCapability(cap); - case CapabilityType::HandleTable: return this->SetHandleTableCapability(cap); - case CapabilityType::DebugFlags: return this->SetDebugFlagsCapability(cap); - default: return svc::ResultInvalidArgument(); + case CapabilityType::CorePriority: R_RETURN(this->SetCorePriorityCapability(cap)); + case CapabilityType::SyscallMask: R_RETURN(this->SetSyscallMaskCapability(cap, set_svc)); + case CapabilityType::MapIoPage: R_RETURN(this->MapIoPage(cap, page_table)); + case CapabilityType::MapRegion: R_RETURN(this->MapRegion(cap, page_table)); + case CapabilityType::InterruptPair: R_RETURN(this->SetInterruptPairCapability(cap)); + case CapabilityType::ProgramType: R_RETURN(this->SetProgramTypeCapability(cap)); + case CapabilityType::KernelVersion: R_RETURN(this->SetKernelVersionCapability(cap)); + case CapabilityType::HandleTable: R_RETURN(this->SetHandleTableCapability(cap)); + case CapabilityType::DebugFlags: R_RETURN(this->SetDebugFlagsCapability(cap)); + default: R_THROW(svc::ResultInvalidArgument()); } } @@ -286,7 +286,7 @@ namespace ams::kern { } } - return ResultSuccess(); + R_SUCCEED(); } Result KCapabilities::SetCapabilities(svc::KUserPointer user_caps, s32 num_caps, KProcessPageTable *page_table) { @@ -317,7 +317,7 @@ namespace ams::kern { } } - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/kern_k_client_session.cpp b/libraries/libmesosphere/source/kern_k_client_session.cpp index 603eaa3de..510ff7d4d 100644 --- a/libraries/libmesosphere/source/kern_k_client_session.cpp +++ b/libraries/libmesosphere/source/kern_k_client_session.cpp @@ -40,7 +40,7 @@ namespace ams::kern { request->Initialize(nullptr, address, size); /* Send the request. */ - return m_parent->OnRequest(request); + R_RETURN(m_parent->OnRequest(request)); } Result KClientSession::SendAsyncRequest(KEvent *event, uintptr_t address, size_t size) { @@ -55,7 +55,7 @@ namespace ams::kern { request->Initialize(event, address, size); /* Send the request. */ - return m_parent->OnRequest(request); + R_RETURN(m_parent->OnRequest(request)); } } diff --git a/libraries/libmesosphere/source/kern_k_code_memory.cpp b/libraries/libmesosphere/source/kern_k_code_memory.cpp index d4a7494c3..6a5a30ffa 100644 --- a/libraries/libmesosphere/source/kern_k_code_memory.cpp +++ b/libraries/libmesosphere/source/kern_k_code_memory.cpp @@ -49,7 +49,7 @@ namespace ams::kern { /* We succeeded. */ pg_guard.Cancel(); - return ResultSuccess(); + R_SUCCEED(); } void KCodeMemory::Finalize() { @@ -87,7 +87,7 @@ namespace ams::kern { /* Mark ourselves as mapped. */ m_is_mapped = true; - return ResultSuccess(); + R_SUCCEED(); } Result KCodeMemory::Unmap(KProcessAddress address, size_t size) { @@ -106,7 +106,7 @@ namespace ams::kern { MESOSPHERE_ASSERT(m_is_mapped); m_is_mapped = false; - return ResultSuccess(); + R_SUCCEED(); } Result KCodeMemory::MapToOwner(KProcessAddress address, size_t size, ams::svc::MemoryPermission perm) { @@ -135,7 +135,7 @@ namespace ams::kern { /* Mark ourselves as mapped. */ m_is_owner_mapped = true; - return ResultSuccess(); + R_SUCCEED(); } Result KCodeMemory::UnmapFromOwner(KProcessAddress address, size_t size) { @@ -154,7 +154,7 @@ namespace ams::kern { MESOSPHERE_ASSERT(m_is_owner_mapped); m_is_owner_mapped = false; - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/kern_k_condition_variable.cpp b/libraries/libmesosphere/source/kern_k_condition_variable.cpp index 97e4402b4..6dc2b25b6 100644 --- a/libraries/libmesosphere/source/kern_k_condition_variable.cpp +++ b/libraries/libmesosphere/source/kern_k_condition_variable.cpp @@ -98,12 +98,12 @@ namespace ams::kern { /* Signal the next owner thread. */ next_owner_thread->EndWait(result); - return result; + R_RETURN(result); } else { /* Just write the value to userspace. */ R_UNLESS(WriteToUser(addr, std::addressof(next_value)), svc::ResultInvalidCurrentMemory()); - return ResultSuccess(); + R_SUCCEED(); } } } @@ -143,7 +143,7 @@ namespace ams::kern { owner_thread->Close(); /* Get the wait result. */ - return cur_thread->GetWaitResult(); + R_RETURN(cur_thread->GetWaitResult()); } void KConditionVariable::SignalImpl(KThread *thread) { @@ -224,7 +224,7 @@ namespace ams::kern { /* Check that the thread isn't terminating. */ if (cur_thread->IsTerminationRequested()) { slp.CancelSleep(); - return svc::ResultTerminationRequested(); + R_THROW(svc::ResultTerminationRequested()); } /* Update the value and process for the next owner. */ @@ -256,7 +256,7 @@ namespace ams::kern { /* Write the value to userspace. */ if (!WriteToUser(addr, std::addressof(next_value))) { slp.CancelSleep(); - return svc::ResultInvalidCurrentMemory(); + R_THROW(svc::ResultInvalidCurrentMemory()); } } @@ -273,7 +273,7 @@ namespace ams::kern { } /* Get the wait result. */ - return cur_thread->GetWaitResult(); + R_RETURN(cur_thread->GetWaitResult()); } } diff --git a/libraries/libmesosphere/source/kern_k_debug_base.cpp b/libraries/libmesosphere/source/kern_k_debug_base.cpp index 02f46436d..5493e62fa 100644 --- a/libraries/libmesosphere/source/kern_k_debug_base.cpp +++ b/libraries/libmesosphere/source/kern_k_debug_base.cpp @@ -69,7 +69,7 @@ namespace ams::kern { /* Write output. */ *out_memory_info = info.GetSvcMemoryInfo(); - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::ReadMemory(KProcessAddress buffer, KProcessAddress address, size_t size) { @@ -132,7 +132,7 @@ namespace ams::kern { remaining -= cur_size; } - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::WriteMemory(KProcessAddress buffer, KProcessAddress address, size_t size) { @@ -195,7 +195,7 @@ namespace ams::kern { remaining -= cur_size; } - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::GetRunningThreadInfo(ams::svc::LastThreadContext *out_context, u64 *out_thread_id) { @@ -233,7 +233,7 @@ namespace ams::kern { *out_thread_id = thread->GetId(); } - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::Attach(KProcess *target) { @@ -265,10 +265,10 @@ namespace ams::kern { case KProcess::State_CreatedAttached: case KProcess::State_RunningAttached: case KProcess::State_DebugBreak: - return svc::ResultBusy(); + R_THROW(svc::ResultBusy()); case KProcess::State_Terminating: case KProcess::State_Terminated: - return svc::ResultProcessTerminated(); + R_THROW(svc::ResultProcessTerminated()); MESOSPHERE_UNREACHABLE_DEFAULT_CASE(); } @@ -313,7 +313,7 @@ namespace ams::kern { } } - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::BreakProcess() { @@ -385,7 +385,7 @@ namespace ams::kern { /* Set the process as breaked. */ target->SetDebugBreak(); - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::TerminateProcess() { @@ -467,7 +467,7 @@ namespace ams::kern { /* Terminate the process. */ target->Terminate(); - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::GetThreadContext(ams::svc::ThreadContext *out, u64 thread_id, u32 context_flags) { @@ -529,7 +529,7 @@ namespace ams::kern { /* Get the thread context. */ static_assert(std::derived_from); - return static_cast(this)->GetThreadContextImpl(out, thread, context_flags); + R_RETURN(static_cast(this)->GetThreadContextImpl(out, thread, context_flags)); } } @@ -621,7 +621,7 @@ namespace ams::kern { /* Set the thread context. */ static_assert(std::derived_from); - return static_cast(this)->SetThreadContextImpl(ctx, thread, context_flags); + R_RETURN(static_cast(this)->SetThreadContextImpl(ctx, thread, context_flags)); } } @@ -722,7 +722,7 @@ namespace ams::kern { target->SetAttached(); } - return ResultSuccess(); + R_SUCCEED(); } KEventInfo *KDebugBase::CreateDebugEvent(ams::svc::DebugEvent event, uintptr_t param0, uintptr_t param1, uintptr_t param2, uintptr_t param3, uintptr_t param4, u64 cur_thread_id) { @@ -975,15 +975,15 @@ namespace ams::kern { break; } - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::GetDebugEventInfo(ams::svc::lp64::DebugEventInfo *out) { - return this->GetDebugEventInfoImpl(out); + R_RETURN(this->GetDebugEventInfoImpl(out)); } Result KDebugBase::GetDebugEventInfo(ams::svc::ilp32::DebugEventInfo *out) { - return this->GetDebugEventInfoImpl(out); + R_RETURN(this->GetDebugEventInfoImpl(out)); } void KDebugBase::Finalize() { @@ -1091,7 +1091,7 @@ namespace ams::kern { /* If the event is an exception and we don't have exception events enabled, we can't handle the event. */ if (event == ams::svc::DebugEvent_Exception && (debug->m_continue_flags & ams::svc::ContinueFlag_EnableExceptionEvent) == 0) { GetCurrentThread().SetDebugExceptionResult(ResultSuccess()); - return svc::ResultNotHandled(); + R_THROW(svc::ResultNotHandled()); } /* If the current thread is suspended, retry. */ @@ -1134,21 +1134,21 @@ namespace ams::kern { /* Get the debug object. */ if (KDebugBase *debug = GetDebugObject(process); debug != nullptr) { /* If we have one, check the debug exception. */ - return GetCurrentThread().GetDebugExceptionResult(); + R_RETURN(GetCurrentThread().GetDebugExceptionResult()); } else { /* We don't have a debug object, so stop processing the exception. */ - return svc::ResultStopProcessingException(); + R_THROW(svc::ResultStopProcessingException()); } } - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::OnDebugEvent(ams::svc::DebugEvent event, uintptr_t param0, uintptr_t param1, uintptr_t param2, uintptr_t param3, uintptr_t param4) { if (KProcess *process = GetCurrentProcessPointer(); process != nullptr && process->IsAttachedToDebugger()) { - return ProcessDebugEvent(event, param0, param1, param2, param3, param4); + R_RETURN(ProcessDebugEvent(event, param0, param1, param2, param3, param4)); } - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::OnExitProcess(KProcess *process) { @@ -1166,7 +1166,7 @@ namespace ams::kern { } } - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::OnTerminateProcess(KProcess *process) { @@ -1184,7 +1184,7 @@ namespace ams::kern { } } - return ResultSuccess(); + R_SUCCEED(); } Result KDebugBase::OnExitThread(KThread *thread) { @@ -1196,7 +1196,7 @@ namespace ams::kern { R_TRY(OnDebugEvent(ams::svc::DebugEvent_ExitThread, thread->GetId(), thread->IsTerminationRequested() ? ams::svc::ThreadExitReason_TerminateThread : ams::svc::ThreadExitReason_ExitThread)); } - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/kern_k_event.cpp b/libraries/libmesosphere/source/kern_k_event.cpp index ccb3eee0c..5400557ec 100644 --- a/libraries/libmesosphere/source/kern_k_event.cpp +++ b/libraries/libmesosphere/source/kern_k_event.cpp @@ -43,7 +43,7 @@ namespace ams::kern { R_SUCCEED_IF(m_readable_event_destroyed); - return m_readable_event.Signal(); + R_RETURN(m_readable_event.Signal()); } Result KEvent::Clear() { @@ -51,7 +51,7 @@ namespace ams::kern { R_SUCCEED_IF(m_readable_event_destroyed); - return m_readable_event.Clear(); + R_RETURN(m_readable_event.Clear()); } void KEvent::PostDestroy(uintptr_t arg) { diff --git a/libraries/libmesosphere/source/kern_k_handle_table.cpp b/libraries/libmesosphere/source/kern_k_handle_table.cpp index af9b8cfba..421df9281 100644 --- a/libraries/libmesosphere/source/kern_k_handle_table.cpp +++ b/libraries/libmesosphere/source/kern_k_handle_table.cpp @@ -36,7 +36,7 @@ namespace ams::kern { } } - return ResultSuccess(); + R_SUCCEED(); } bool KHandleTable::Remove(ams::svc::Handle handle) { @@ -95,7 +95,7 @@ namespace ams::kern { *out_handle = EncodeHandle(index, linear_id); } - return ResultSuccess(); + R_SUCCEED(); } Result KHandleTable::Reserve(ams::svc::Handle *out_handle) { @@ -107,7 +107,7 @@ namespace ams::kern { R_UNLESS(m_count < m_table_size, svc::ResultOutOfHandles()); *out_handle = EncodeHandle(this->AllocateEntry(), this->AllocateLinearId()); - return ResultSuccess(); + R_SUCCEED(); } void KHandleTable::Unreserve(ams::svc::Handle handle) { diff --git a/libraries/libmesosphere/source/kern_k_initial_process_reader.cpp b/libraries/libmesosphere/source/kern_k_initial_process_reader.cpp index 5e8357711..a7c272dc5 100644 --- a/libraries/libmesosphere/source/kern_k_initial_process_reader.cpp +++ b/libraries/libmesosphere/source/kern_k_initial_process_reader.cpp @@ -143,7 +143,7 @@ namespace ams::kern { /* All initial processes should disable device address space merge. */ out->flags |= ams::svc::CreateProcessFlag_DisableDeviceAddressSpaceMerge; - return ResultSuccess(); + R_SUCCEED(); } Result KInitialProcessReader::Load(KProcessAddress address, const ams::svc::CreateProcessParameter ¶ms, KProcessAddress src) const { @@ -187,7 +187,7 @@ namespace ams::kern { cpu::FlushEntireDataCache(); cpu::InvalidateEntireInstructionCache(); - return ResultSuccess(); + R_SUCCEED(); } Result KInitialProcessReader::SetMemoryPermissions(KProcessPageTable &page_table, const ams::svc::CreateProcessParameter ¶ms) const { @@ -215,7 +215,7 @@ namespace ams::kern { R_TRY(page_table.SetProcessMemoryPermission(start, util::AlignUp(end - start, PageSize), ams::svc::MemoryPermission_ReadWrite)); } - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/kern_k_io_pool.cpp b/libraries/libmesosphere/source/kern_k_io_pool.cpp index cb15856d8..333907f21 100644 --- a/libraries/libmesosphere/source/kern_k_io_pool.cpp +++ b/libraries/libmesosphere/source/kern_k_io_pool.cpp @@ -80,7 +80,7 @@ namespace ams::kern { m_pool_type = pool_type; m_is_initialized = true; - return ResultSuccess(); + R_SUCCEED(); } void KIoPool::Finalize() { @@ -113,7 +113,7 @@ namespace ams::kern { /* Add the region to our pool. */ m_io_region_list.push_back(*new_region); - return ResultSuccess(); + R_SUCCEED(); } void KIoPool::RemoveIoRegion(KIoRegion *region) { diff --git a/libraries/libmesosphere/source/kern_k_io_region.cpp b/libraries/libmesosphere/source/kern_k_io_region.cpp index 25cf7e204..1c309af50 100644 --- a/libraries/libmesosphere/source/kern_k_io_region.cpp +++ b/libraries/libmesosphere/source/kern_k_io_region.cpp @@ -37,7 +37,7 @@ namespace ams::kern { /* Mark ourselves as initialized. */ m_is_initialized = true; - return ResultSuccess(); + R_SUCCEED(); } void KIoRegion::Finalize() { @@ -72,7 +72,7 @@ namespace ams::kern { /* Note that we're mapped. */ m_is_mapped = true; - return ResultSuccess(); + R_SUCCEED(); } Result KIoRegion::Unmap(KProcessAddress address, size_t size) { @@ -93,7 +93,7 @@ namespace ams::kern { /* Note that we're unmapped. */ m_is_mapped = false; - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/kern_k_light_client_session.cpp b/libraries/libmesosphere/source/kern_k_light_client_session.cpp index 02660a432..c4c12899a 100644 --- a/libraries/libmesosphere/source/kern_k_light_client_session.cpp +++ b/libraries/libmesosphere/source/kern_k_light_client_session.cpp @@ -37,7 +37,7 @@ namespace ams::kern { cur_thread->SetLightSessionData(data); /* Send the request. */ - return m_parent->OnRequest(cur_thread); + R_RETURN(m_parent->OnRequest(cur_thread)); } } diff --git a/libraries/libmesosphere/source/kern_k_light_server_session.cpp b/libraries/libmesosphere/source/kern_k_light_server_session.cpp index 542ecd1c2..7c83f3b86 100644 --- a/libraries/libmesosphere/source/kern_k_light_server_session.cpp +++ b/libraries/libmesosphere/source/kern_k_light_server_session.cpp @@ -120,7 +120,7 @@ namespace ams::kern { /* NOTE: Nintendo returns GetCurrentThread().GetWaitResult() here. */ /* This is technically incorrect, although it doesn't cause problems in practice */ /* because this is only ever called with request_thread = GetCurrentThreadPointer(). */ - return request_thread->GetWaitResult(); + R_RETURN(request_thread->GetWaitResult()); } Result KLightServerSession::ReplyAndReceive(u32 *data) { @@ -193,7 +193,7 @@ namespace ams::kern { std::memcpy(GetCurrentThread().GetLightSessionData(), m_current_request->GetLightSessionData(), KLightSession::DataSize); /* We successfully received. */ - return ResultSuccess(); + R_SUCCEED(); } /* We need to wait for a request to come in. */ @@ -201,7 +201,7 @@ namespace ams::kern { /* Check if we were cancelled. */ if (GetCurrentThread().IsWaitCancelled()) { GetCurrentThread().ClearWaitCancelled(); - return svc::ResultCancelled(); + R_THROW(svc::ResultCancelled()); } /* Mark ourselves as cancellable. */ diff --git a/libraries/libmesosphere/source/kern_k_memory_block_manager.cpp b/libraries/libmesosphere/source/kern_k_memory_block_manager.cpp index ea0baf8a5..0a5732032 100644 --- a/libraries/libmesosphere/source/kern_k_memory_block_manager.cpp +++ b/libraries/libmesosphere/source/kern_k_memory_block_manager.cpp @@ -102,7 +102,7 @@ namespace ams::kern { start_block->Initialize(m_start_address, (m_end_address - m_start_address) / PageSize, KMemoryState_Free, KMemoryPermission_None, KMemoryAttribute_None); m_memory_block_tree.insert(*start_block); - return ResultSuccess(); + R_SUCCEED(); } void KMemoryBlockManager::Finalize(KMemoryBlockSlabManager *slab_manager) { diff --git a/libraries/libmesosphere/source/kern_k_object_name.cpp b/libraries/libmesosphere/source/kern_k_object_name.cpp index ffeb52f17..775807cfa 100644 --- a/libraries/libmesosphere/source/kern_k_object_name.cpp +++ b/libraries/libmesosphere/source/kern_k_object_name.cpp @@ -55,14 +55,14 @@ namespace ams::kern { KScopedAutoObject existing_object = FindImpl(name); if (existing_object.IsNull()) { g_object_list.push_back(*new_name); - return ResultSuccess(); + R_SUCCEED(); } } /* The object already exists, which is an error condition. Perform cleanup. */ obj->Close(); KObjectName::Free(new_name); - return svc::ResultInvalidState(); + R_THROW(svc::ResultInvalidState()); } Result KObjectName::Delete(KAutoObject *obj, const char *compare_name) { @@ -76,12 +76,12 @@ namespace ams::kern { obj->Close(); g_object_list.erase(g_object_list.iterator_to(name)); KObjectName::Free(std::addressof(name)); - return ResultSuccess(); + R_SUCCEED(); } } /* We didn't find the object in the list. */ - return svc::ResultNotFound(); + R_THROW(svc::ResultNotFound()); } KScopedAutoObject KObjectName::Find(const char *name) { diff --git a/libraries/libmesosphere/source/kern_k_page_group.cpp b/libraries/libmesosphere/source/kern_k_page_group.cpp index 13a630bb2..e06a51931 100644 --- a/libraries/libmesosphere/source/kern_k_page_group.cpp +++ b/libraries/libmesosphere/source/kern_k_page_group.cpp @@ -81,7 +81,7 @@ namespace ams::kern { } m_last_block = new_block; - return ResultSuccess(); + R_SUCCEED(); } void KPageGroup::Open() const { diff --git a/libraries/libmesosphere/source/kern_k_page_table_base.cpp b/libraries/libmesosphere/source/kern_k_page_table_base.cpp index f758dd237..f8f578d09 100644 --- a/libraries/libmesosphere/source/kern_k_page_table_base.cpp +++ b/libraries/libmesosphere/source/kern_k_page_table_base.cpp @@ -2829,57 +2829,57 @@ namespace ams::kern { } Result KPageTableBase::LockForIpcUserBuffer(KPhysicalAddress *out, KProcessAddress address, size_t size) { - return this->LockMemoryAndOpen(nullptr, out, address, size, + R_RETURN(this->LockMemoryAndOpen(nullptr, out, address, size, KMemoryState_FlagCanIpcUserBuffer, KMemoryState_FlagCanIpcUserBuffer, KMemoryPermission_All, KMemoryPermission_UserReadWrite, KMemoryAttribute_All, KMemoryAttribute_None, static_cast(KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite), - KMemoryAttribute_Locked); + KMemoryAttribute_Locked)); } Result KPageTableBase::UnlockForIpcUserBuffer(KProcessAddress address, size_t size) { - return this->UnlockMemory(address, size, + R_RETURN(this->UnlockMemory(address, size, KMemoryState_FlagCanIpcUserBuffer, KMemoryState_FlagCanIpcUserBuffer, KMemoryPermission_None, KMemoryPermission_None, KMemoryAttribute_All, KMemoryAttribute_Locked, KMemoryPermission_UserReadWrite, - KMemoryAttribute_Locked, nullptr); + KMemoryAttribute_Locked, nullptr)); } Result KPageTableBase::LockForTransferMemory(KPageGroup *out, KProcessAddress address, size_t size, KMemoryPermission perm) { - return this->LockMemoryAndOpen(out, nullptr, address, size, + R_RETURN(this->LockMemoryAndOpen(out, nullptr, address, size, KMemoryState_FlagCanTransfer, KMemoryState_FlagCanTransfer, KMemoryPermission_All, KMemoryPermission_UserReadWrite, KMemoryAttribute_All, KMemoryAttribute_None, perm, - KMemoryAttribute_Locked); + KMemoryAttribute_Locked)); } Result KPageTableBase::UnlockForTransferMemory(KProcessAddress address, size_t size, const KPageGroup &pg) { - return this->UnlockMemory(address, size, + R_RETURN(this->UnlockMemory(address, size, KMemoryState_FlagCanTransfer, KMemoryState_FlagCanTransfer, KMemoryPermission_None, KMemoryPermission_None, KMemoryAttribute_All, KMemoryAttribute_Locked, KMemoryPermission_UserReadWrite, - KMemoryAttribute_Locked, std::addressof(pg)); + KMemoryAttribute_Locked, std::addressof(pg))); } Result KPageTableBase::LockForCodeMemory(KPageGroup *out, KProcessAddress address, size_t size) { - return this->LockMemoryAndOpen(out, nullptr, address, size, + R_RETURN(this->LockMemoryAndOpen(out, nullptr, address, size, KMemoryState_FlagCanCodeMemory, KMemoryState_FlagCanCodeMemory, KMemoryPermission_All, KMemoryPermission_UserReadWrite, KMemoryAttribute_All, KMemoryAttribute_None, static_cast(KMemoryPermission_NotMapped | KMemoryPermission_KernelReadWrite), - KMemoryAttribute_Locked); + KMemoryAttribute_Locked)); } Result KPageTableBase::UnlockForCodeMemory(KProcessAddress address, size_t size, const KPageGroup &pg) { - return this->UnlockMemory(address, size, + R_RETURN(this->UnlockMemory(address, size, KMemoryState_FlagCanCodeMemory, KMemoryState_FlagCanCodeMemory, KMemoryPermission_None, KMemoryPermission_None, KMemoryAttribute_All, KMemoryAttribute_Locked, KMemoryPermission_UserReadWrite, - KMemoryAttribute_Locked, std::addressof(pg)); + KMemoryAttribute_Locked, std::addressof(pg))); } Result KPageTableBase::OpenMemoryRangeForProcessCacheOperation(MemoryRange *out, KProcessAddress address, size_t size) { diff --git a/libraries/libmesosphere/source/kern_k_port.cpp b/libraries/libmesosphere/source/kern_k_port.cpp index 4a5a57d5c..0e207f453 100644 --- a/libraries/libmesosphere/source/kern_k_port.cpp +++ b/libraries/libmesosphere/source/kern_k_port.cpp @@ -59,7 +59,7 @@ namespace ams::kern { R_UNLESS(m_state == State::Normal, svc::ResultPortClosed()); m_server.EnqueueSession(session); - return ResultSuccess(); + R_SUCCEED(); } Result KPort::EnqueueSession(KLightServerSession *session) { @@ -68,7 +68,7 @@ namespace ams::kern { R_UNLESS(m_state == State::Normal, svc::ResultPortClosed()); m_server.EnqueueSession(session); - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/kern_k_readable_event.cpp b/libraries/libmesosphere/source/kern_k_readable_event.cpp index 7160a1442..375e536fa 100644 --- a/libraries/libmesosphere/source/kern_k_readable_event.cpp +++ b/libraries/libmesosphere/source/kern_k_readable_event.cpp @@ -56,7 +56,7 @@ namespace ams::kern { this->NotifyAvailable(); } - return ResultSuccess(); + R_SUCCEED(); } Result KReadableEvent::Reset() { @@ -67,7 +67,7 @@ namespace ams::kern { R_UNLESS(m_is_signaled, svc::ResultInvalidState()); m_is_signaled = false; - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/kern_k_resource_limit.cpp b/libraries/libmesosphere/source/kern_k_resource_limit.cpp index 66937a5b7..6ed10a7a8 100644 --- a/libraries/libmesosphere/source/kern_k_resource_limit.cpp +++ b/libraries/libmesosphere/source/kern_k_resource_limit.cpp @@ -108,7 +108,7 @@ namespace ams::kern { m_limit_values[which] = value; m_peak_values[which] = m_current_values[which]; - return ResultSuccess(); + R_SUCCEED(); } void KResourceLimit::Add(ams::svc::LimitableResource which, s64 value) { diff --git a/libraries/libmesosphere/source/kern_k_session_request.cpp b/libraries/libmesosphere/source/kern_k_session_request.cpp index 5545b9077..c14368c83 100644 --- a/libraries/libmesosphere/source/kern_k_session_request.cpp +++ b/libraries/libmesosphere/source/kern_k_session_request.cpp @@ -40,22 +40,22 @@ namespace ams::kern { /* Set the mapping. */ mapping->Set(client, server, size, state); - return ResultSuccess(); + R_SUCCEED(); } Result KSessionRequest::SessionMappings::PushSend(KProcessAddress client, KProcessAddress server, size_t size, KMemoryState state) { MESOSPHERE_ASSERT(m_num_recv == 0); MESOSPHERE_ASSERT(m_num_exch == 0); - return this->PushMap(client, server, size, state, m_num_send++); + R_RETURN(this->PushMap(client, server, size, state, m_num_send++)); } Result KSessionRequest::SessionMappings::PushReceive(KProcessAddress client, KProcessAddress server, size_t size, KMemoryState state) { MESOSPHERE_ASSERT(m_num_exch == 0); - return this->PushMap(client, server, size, state, m_num_send + m_num_recv++); + R_RETURN(this->PushMap(client, server, size, state, m_num_send + m_num_recv++)); } Result KSessionRequest::SessionMappings::PushExchange(KProcessAddress client, KProcessAddress server, size_t size, KMemoryState state) { - return this->PushMap(client, server, size, state, m_num_send + m_num_recv + m_num_exch++); + R_RETURN(this->PushMap(client, server, size, state, m_num_send + m_num_recv + m_num_exch++)); } void KSessionRequest::SessionMappings::Finalize() { diff --git a/libraries/libmesosphere/source/kern_k_shared_memory.cpp b/libraries/libmesosphere/source/kern_k_shared_memory.cpp index e828f2f10..c7850fb1d 100644 --- a/libraries/libmesosphere/source/kern_k_shared_memory.cpp +++ b/libraries/libmesosphere/source/kern_k_shared_memory.cpp @@ -54,7 +54,7 @@ namespace ams::kern { std::memset(GetVoidPointer(KMemoryLayout::GetLinearVirtualAddress(block.GetAddress())), 0, block.GetSize()); } - return ResultSuccess(); + R_SUCCEED(); } void KSharedMemory::Finalize() { @@ -88,7 +88,7 @@ namespace ams::kern { } /* Map the memory. */ - return table->MapPageGroup(address, m_page_group, KMemoryState_Shared, ConvertToKMemoryPermission(map_perm)); + R_RETURN(table->MapPageGroup(address, m_page_group, KMemoryState_Shared, ConvertToKMemoryPermission(map_perm))); } Result KSharedMemory::Unmap(KProcessPageTable *table, KProcessAddress address, size_t size, KProcess *process) { @@ -99,7 +99,7 @@ namespace ams::kern { R_UNLESS(m_page_group.GetNumPages() == util::DivideUp(size, PageSize), svc::ResultInvalidSize()); /* Unmap the memory. */ - return table->UnmapPageGroup(address, m_page_group, KMemoryState_Shared); + R_RETURN(table->UnmapPageGroup(address, m_page_group, KMemoryState_Shared)); } } diff --git a/libraries/libmesosphere/source/kern_k_synchronization_object.cpp b/libraries/libmesosphere/source/kern_k_synchronization_object.cpp index 637fd5592..e1969b9c0 100644 --- a/libraries/libmesosphere/source/kern_k_synchronization_object.cpp +++ b/libraries/libmesosphere/source/kern_k_synchronization_object.cpp @@ -103,7 +103,7 @@ namespace ams::kern { /* Check if the thread should terminate. */ if (thread->IsTerminationRequested()) { slp.CancelSleep(); - return svc::ResultTerminationRequested(); + R_THROW(svc::ResultTerminationRequested()); } /* Check if any of the objects are already signaled. */ @@ -113,21 +113,21 @@ namespace ams::kern { if (objects[i]->IsSignaled()) { *out_index = i; slp.CancelSleep(); - return ResultSuccess(); + R_SUCCEED(); } } /* Check if the timeout is zero. */ if (timeout == 0) { slp.CancelSleep(); - return svc::ResultTimedOut(); + R_THROW(svc::ResultTimedOut()); } /* Check if waiting was canceled. */ if (thread->IsWaitCancelled()) { slp.CancelSleep(); thread->ClearWaitCancelled(); - return svc::ResultCancelled(); + R_THROW(svc::ResultCancelled()); } /* Add the waiters. */ @@ -153,7 +153,7 @@ namespace ams::kern { *out_index = thread->GetSyncedIndex(); /* Get the wait result. */ - return thread->GetWaitResult(); + R_RETURN(thread->GetWaitResult()); } void KSynchronizationObject::NotifyAvailable(Result result) { diff --git a/libraries/libmesosphere/source/kern_k_system_control_base.cpp b/libraries/libmesosphere/source/kern_k_system_control_base.cpp index e20166125..f08c34ca7 100644 --- a/libraries/libmesosphere/source/kern_k_system_control_base.cpp +++ b/libraries/libmesosphere/source/kern_k_system_control_base.cpp @@ -177,7 +177,7 @@ namespace ams::kern { Result KSystemControlBase::ReadWriteRegister(u32 *out, ams::svc::PhysicalAddress address, u32 mask, u32 value) { MESOSPHERE_UNUSED(out, address, mask, value); - return svc::ResultNotImplemented(); + R_THROW(svc::ResultNotImplemented()); } /* Randomness. */ @@ -278,7 +278,7 @@ namespace ams::kern { R_UNLESS(paddr != Null, svc::ResultOutOfMemory()); *out = KPageTable::GetHeapVirtualAddress(paddr); - return ResultSuccess(); + R_SUCCEED(); } void KSystemControlBase::FreeSecureMemory(KVirtualAddress address, size_t size, u32 pool) { diff --git a/libraries/libmesosphere/source/kern_k_transfer_memory.cpp b/libraries/libmesosphere/source/kern_k_transfer_memory.cpp index caf2b53ac..588510eff 100644 --- a/libraries/libmesosphere/source/kern_k_transfer_memory.cpp +++ b/libraries/libmesosphere/source/kern_k_transfer_memory.cpp @@ -41,7 +41,7 @@ namespace ams::kern { /* We succeeded. */ pg_guard.Cancel(); - return ResultSuccess(); + R_SUCCEED(); } void KTransferMemory::Finalize() { @@ -86,7 +86,7 @@ namespace ams::kern { /* Mark ourselves as mapped. */ m_is_mapped = true; - return ResultSuccess(); + R_SUCCEED(); } Result KTransferMemory::Unmap(KProcessAddress address, size_t size) { @@ -106,7 +106,7 @@ namespace ams::kern { MESOSPHERE_ASSERT(m_is_mapped); m_is_mapped = false; - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/kern_k_wait_object.cpp b/libraries/libmesosphere/source/kern_k_wait_object.cpp index d6f647261..78b26680a 100644 --- a/libraries/libmesosphere/source/kern_k_wait_object.cpp +++ b/libraries/libmesosphere/source/kern_k_wait_object.cpp @@ -61,7 +61,7 @@ namespace ams::kern { /* Check that the thread isn't terminating. */ if (cur_thread->IsTerminationRequested()) { slp.CancelSleep(); - return svc::ResultTerminationRequested(); + R_THROW(svc::ResultTerminationRequested()); } /* Handle the case where timeout is non-negative/infinite. */ @@ -69,7 +69,7 @@ namespace ams::kern { /* Check if we're already waiting. */ if (m_next_thread != nullptr) { slp.CancelSleep(); - return svc::ResultBusy(); + R_THROW(svc::ResultBusy()); } /* If timeout is zero, handle the special case by canceling all waiting threads. */ @@ -79,7 +79,7 @@ namespace ams::kern { } slp.CancelSleep(); - return ResultSuccess(); + R_SUCCEED(); } } @@ -96,7 +96,7 @@ namespace ams::kern { cur_thread->BeginWait(std::addressof(wait_queue)); } - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_activity.cpp b/libraries/libmesosphere/source/svc/kern_svc_activity.cpp index 17c78005b..a9ebafe3b 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_activity.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_activity.cpp @@ -56,7 +56,7 @@ namespace ams::kern::svc { /* Set the activity. */ R_TRY(thread->SetActivity(thread_activity)); - return ResultSuccess(); + R_SUCCEED(); } Result SetProcessActivity(ams::svc::Handle process_handle, ams::svc::ProcessActivity process_activity) { @@ -73,7 +73,7 @@ namespace ams::kern::svc { /* Set the activity. */ R_TRY(process->SetActivity(process_activity)); - return ResultSuccess(); + R_SUCCEED(); } } @@ -81,21 +81,21 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result SetThreadActivity64(ams::svc::Handle thread_handle, ams::svc::ThreadActivity thread_activity) { - return SetThreadActivity(thread_handle, thread_activity); + R_RETURN(SetThreadActivity(thread_handle, thread_activity)); } Result SetProcessActivity64(ams::svc::Handle process_handle, ams::svc::ProcessActivity process_activity) { - return SetProcessActivity(process_handle, process_activity); + R_RETURN(SetProcessActivity(process_handle, process_activity)); } /* ============================= 64From32 ABI ============================= */ Result SetThreadActivity64From32(ams::svc::Handle thread_handle, ams::svc::ThreadActivity thread_activity) { - return SetThreadActivity(thread_handle, thread_activity); + R_RETURN(SetThreadActivity(thread_handle, thread_activity)); } Result SetProcessActivity64From32(ams::svc::Handle process_handle, ams::svc::ProcessActivity process_activity) { - return SetProcessActivity(process_handle, process_activity); + R_RETURN(SetProcessActivity(process_handle, process_activity)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_address_arbiter.cpp b/libraries/libmesosphere/source/svc/kern_svc_address_arbiter.cpp index 6fd923552..68eb61e84 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_address_arbiter.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_address_arbiter.cpp @@ -69,7 +69,7 @@ namespace ams::kern::svc { timeout = timeout_ns; } - return GetCurrentProcess().WaitAddressArbiter(address, arb_type, value, timeout); + R_RETURN(GetCurrentProcess().WaitAddressArbiter(address, arb_type, value, timeout)); } Result SignalToAddress(uintptr_t address, ams::svc::SignalType signal_type, int32_t value, int32_t count) { @@ -78,7 +78,7 @@ namespace ams::kern::svc { R_UNLESS(util::IsAligned(address, sizeof(int32_t)), svc::ResultInvalidAddress()); R_UNLESS(IsValidSignalType(signal_type), svc::ResultInvalidEnumValue()); - return GetCurrentProcess().SignalAddressArbiter(address, signal_type, value, count); + R_RETURN(GetCurrentProcess().SignalAddressArbiter(address, signal_type, value, count)); } } @@ -86,21 +86,21 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result WaitForAddress64(ams::svc::Address address, ams::svc::ArbitrationType arb_type, int32_t value, int64_t timeout_ns) { - return WaitForAddress(address, arb_type, value, timeout_ns); + R_RETURN(WaitForAddress(address, arb_type, value, timeout_ns)); } Result SignalToAddress64(ams::svc::Address address, ams::svc::SignalType signal_type, int32_t value, int32_t count) { - return SignalToAddress(address, signal_type, value, count); + R_RETURN(SignalToAddress(address, signal_type, value, count)); } /* ============================= 64From32 ABI ============================= */ Result WaitForAddress64From32(ams::svc::Address address, ams::svc::ArbitrationType arb_type, int32_t value, int64_t timeout_ns) { - return WaitForAddress(address, arb_type, value, timeout_ns); + R_RETURN(WaitForAddress(address, arb_type, value, timeout_ns)); } Result SignalToAddress64From32(ams::svc::Address address, ams::svc::SignalType signal_type, int32_t value, int32_t count) { - return SignalToAddress(address, signal_type, value, count); + R_RETURN(SignalToAddress(address, signal_type, value, count)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_address_translation.cpp b/libraries/libmesosphere/source/svc/kern_svc_address_translation.cpp index 1e529ada6..a3bdc2d4d 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_address_translation.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_address_translation.cpp @@ -34,7 +34,7 @@ namespace ams::kern::svc { /* Query the physical mapping. */ R_TRY(pt.QueryPhysicalAddress(out_info, address)); - return ResultSuccess(); + R_SUCCEED(); } Result QueryIoMapping(uintptr_t *out_address, size_t *out_size, uint64_t phys_addr, size_t size) { @@ -61,7 +61,7 @@ namespace ams::kern::svc { /* Use the size as the found size. */ found_size = size; - return ResultSuccess(); + R_SUCCEED(); }; if (aligned) { @@ -109,7 +109,7 @@ namespace ams::kern::svc { if (out_size != nullptr) { *out_size = found_size; } - return ResultSuccess(); + R_SUCCEED(); } } @@ -117,18 +117,18 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result QueryPhysicalAddress64(ams::svc::lp64::PhysicalMemoryInfo *out_info, ams::svc::Address address) { - return QueryPhysicalAddress(out_info, address); + R_RETURN(QueryPhysicalAddress(out_info, address)); } Result QueryIoMapping64(ams::svc::Address *out_address, ams::svc::Size *out_size, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); static_assert(sizeof(*out_size) == sizeof(size_t)); - return QueryIoMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size); + R_RETURN(QueryIoMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size)); } Result LegacyQueryIoMapping64(ams::svc::Address *out_address, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); - return QueryIoMapping(reinterpret_cast(out_address), nullptr, physical_address, size); + R_RETURN(QueryIoMapping(reinterpret_cast(out_address), nullptr, physical_address, size)); } /* ============================= 64From32 ABI ============================= */ @@ -142,18 +142,18 @@ namespace ams::kern::svc { .virtual_address = static_cast(info.virtual_address), .size = static_cast(info.size), }; - return ResultSuccess(); + R_SUCCEED(); } Result QueryIoMapping64From32(ams::svc::Address *out_address, ams::svc::Size *out_size, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); static_assert(sizeof(*out_size) == sizeof(size_t)); - return QueryIoMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size); + R_RETURN(QueryIoMapping(reinterpret_cast(out_address), reinterpret_cast(out_size), physical_address, size)); } Result LegacyQueryIoMapping64From32(ams::svc::Address *out_address, ams::svc::PhysicalAddress physical_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); - return QueryIoMapping(reinterpret_cast(out_address), nullptr, physical_address, size); + R_RETURN(QueryIoMapping(reinterpret_cast(out_address), nullptr, physical_address, size)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_cache.cpp b/libraries/libmesosphere/source/svc/kern_svc_cache.cpp index fe76b399b..6b5e0ea99 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_cache.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_cache.cpp @@ -62,7 +62,7 @@ namespace ams::kern::svc { } MESOSPHERE_ASSERT(remaining == 0); - return ResultSuccess(); + R_SUCCEED(); } void FlushEntireDataCache() { @@ -88,7 +88,7 @@ namespace ams::kern::svc { /* Flush the cache. */ R_TRY(cpu::FlushDataCache(reinterpret_cast(address), size)); - return ResultSuccess(); + R_SUCCEED(); } Result InvalidateProcessDataCache(ams::svc::Handle process_handle, uint64_t address, uint64_t size) { @@ -104,7 +104,7 @@ namespace ams::kern::svc { /* Invalidate the cache. */ R_TRY(process->GetPageTable().InvalidateProcessDataCache(address, size)); - return ResultSuccess(); + R_SUCCEED(); } Result StoreProcessDataCache(ams::svc::Handle process_handle, uint64_t address, uint64_t size) { @@ -123,14 +123,14 @@ namespace ams::kern::svc { /* Perform the operation. */ if (process.GetPointerUnsafe() == GetCurrentProcessPointer()) { - return cpu::StoreDataCache(reinterpret_cast(address), size); + R_RETURN(cpu::StoreDataCache(reinterpret_cast(address), size)); } else { class StoreCacheOperation : public CacheOperation { public: virtual void Operate(void *address, size_t size) const override { cpu::StoreDataCache(address, size); } } operation; - return DoProcessCacheOperation(operation, page_table, address, size); + R_RETURN(DoProcessCacheOperation(operation, page_table, address, size)); } } @@ -150,14 +150,14 @@ namespace ams::kern::svc { /* Perform the operation. */ if (process.GetPointerUnsafe() == GetCurrentProcessPointer()) { - return cpu::FlushDataCache(reinterpret_cast(address), size); + R_RETURN(cpu::FlushDataCache(reinterpret_cast(address), size)); } else { class FlushCacheOperation : public CacheOperation { public: virtual void Operate(void *address, size_t size) const override { cpu::FlushDataCache(address, size); } } operation; - return DoProcessCacheOperation(operation, page_table, address, size); + R_RETURN(DoProcessCacheOperation(operation, page_table, address, size)); } } @@ -170,19 +170,19 @@ namespace ams::kern::svc { } Result FlushDataCache64(ams::svc::Address address, ams::svc::Size size) { - return FlushDataCache(address, size); + R_RETURN(FlushDataCache(address, size)); } Result InvalidateProcessDataCache64(ams::svc::Handle process_handle, uint64_t address, uint64_t size) { - return InvalidateProcessDataCache(process_handle, address, size); + R_RETURN(InvalidateProcessDataCache(process_handle, address, size)); } Result StoreProcessDataCache64(ams::svc::Handle process_handle, uint64_t address, uint64_t size) { - return StoreProcessDataCache(process_handle, address, size); + R_RETURN(StoreProcessDataCache(process_handle, address, size)); } Result FlushProcessDataCache64(ams::svc::Handle process_handle, uint64_t address, uint64_t size) { - return FlushProcessDataCache(process_handle, address, size); + R_RETURN(FlushProcessDataCache(process_handle, address, size)); } /* ============================= 64From32 ABI ============================= */ @@ -192,19 +192,19 @@ namespace ams::kern::svc { } Result FlushDataCache64From32(ams::svc::Address address, ams::svc::Size size) { - return FlushDataCache(address, size); + R_RETURN(FlushDataCache(address, size)); } Result InvalidateProcessDataCache64From32(ams::svc::Handle process_handle, uint64_t address, uint64_t size) { - return InvalidateProcessDataCache(process_handle, address, size); + R_RETURN(InvalidateProcessDataCache(process_handle, address, size)); } Result StoreProcessDataCache64From32(ams::svc::Handle process_handle, uint64_t address, uint64_t size) { - return StoreProcessDataCache(process_handle, address, size); + R_RETURN(StoreProcessDataCache(process_handle, address, size)); } Result FlushProcessDataCache64From32(ams::svc::Handle process_handle, uint64_t address, uint64_t size) { - return FlushProcessDataCache(process_handle, address, size); + R_RETURN(FlushProcessDataCache(process_handle, address, size)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_code_memory.cpp b/libraries/libmesosphere/source/svc/kern_svc_code_memory.cpp index 7f037fc5f..e400032a9 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_code_memory.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_code_memory.cpp @@ -61,7 +61,7 @@ namespace ams::kern::svc { /* Add the code memory to the handle table. */ R_TRY(GetCurrentProcess().GetHandleTable().Add(out, code_mem)); - return ResultSuccess(); + R_SUCCEED(); } Result ControlCodeMemory(ams::svc::Handle code_memory_handle, ams::svc::CodeMemoryOperation operation, uint64_t address, uint64_t size, ams::svc::MemoryPermission perm) { @@ -132,10 +132,10 @@ namespace ams::kern::svc { } break; default: - return svc::ResultInvalidEnumValue(); + R_THROW(svc::ResultInvalidEnumValue()); } - return ResultSuccess(); + R_SUCCEED(); } } @@ -143,21 +143,21 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result CreateCodeMemory64(ams::svc::Handle *out_handle, ams::svc::Address address, ams::svc::Size size) { - return CreateCodeMemory(out_handle, address, size); + R_RETURN(CreateCodeMemory(out_handle, address, size)); } Result ControlCodeMemory64(ams::svc::Handle code_memory_handle, ams::svc::CodeMemoryOperation operation, uint64_t address, uint64_t size, ams::svc::MemoryPermission perm) { - return ControlCodeMemory(code_memory_handle, operation, address, size, perm); + R_RETURN(ControlCodeMemory(code_memory_handle, operation, address, size, perm)); } /* ============================= 64From32 ABI ============================= */ Result CreateCodeMemory64From32(ams::svc::Handle *out_handle, ams::svc::Address address, ams::svc::Size size) { - return CreateCodeMemory(out_handle, address, size); + R_RETURN(CreateCodeMemory(out_handle, address, size)); } Result ControlCodeMemory64From32(ams::svc::Handle code_memory_handle, ams::svc::CodeMemoryOperation operation, uint64_t address, uint64_t size, ams::svc::MemoryPermission perm) { - return ControlCodeMemory(code_memory_handle, operation, address, size, perm); + R_RETURN(ControlCodeMemory(code_memory_handle, operation, address, size, perm)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_condition_variable.cpp b/libraries/libmesosphere/source/svc/kern_svc_condition_variable.cpp index dbb7ce1f6..2d3a031ef 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_condition_variable.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_condition_variable.cpp @@ -47,7 +47,7 @@ namespace ams::kern::svc { } /* Wait on the condition variable. */ - return GetCurrentProcess().WaitConditionVariable(address, util::AlignDown(cv_key, sizeof(u32)), tag, timeout); + R_RETURN(GetCurrentProcess().WaitConditionVariable(address, util::AlignDown(cv_key, sizeof(u32)), tag, timeout)); } void SignalProcessWideKey(uintptr_t cv_key, int32_t count) { @@ -60,7 +60,7 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result WaitProcessWideKeyAtomic64(ams::svc::Address address, ams::svc::Address cv_key, uint32_t tag, int64_t timeout_ns) { - return WaitProcessWideKeyAtomic(address, cv_key, tag, timeout_ns); + R_RETURN(WaitProcessWideKeyAtomic(address, cv_key, tag, timeout_ns)); } void SignalProcessWideKey64(ams::svc::Address cv_key, int32_t count) { @@ -70,7 +70,7 @@ namespace ams::kern::svc { /* ============================= 64From32 ABI ============================= */ Result WaitProcessWideKeyAtomic64From32(ams::svc::Address address, ams::svc::Address cv_key, uint32_t tag, int64_t timeout_ns) { - return WaitProcessWideKeyAtomic(address, cv_key, tag, timeout_ns); + R_RETURN(WaitProcessWideKeyAtomic(address, cv_key, tag, timeout_ns)); } void SignalProcessWideKey64From32(ams::svc::Address cv_key, int32_t count) { diff --git a/libraries/libmesosphere/source/svc/kern_svc_debug.cpp b/libraries/libmesosphere/source/svc/kern_svc_debug.cpp index 043306a78..369885355 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_debug.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_debug.cpp @@ -59,7 +59,7 @@ namespace ams::kern::svc { /* Add the new debug object to the handle table. */ R_TRY(handle_table.Add(out_handle, debug)); - return ResultSuccess(); + R_SUCCEED(); } Result BreakDebugProcess(ams::svc::Handle debug_handle) { @@ -73,7 +73,7 @@ namespace ams::kern::svc { /* Break the process. */ R_TRY(debug->BreakProcess()); - return ResultSuccess(); + R_SUCCEED(); } Result TerminateDebugProcess(ams::svc::Handle debug_handle) { @@ -87,7 +87,7 @@ namespace ams::kern::svc { /* Terminate the process. */ R_TRY(debug->TerminateProcess()); - return ResultSuccess(); + R_SUCCEED(); } template @@ -106,7 +106,7 @@ namespace ams::kern::svc { /* Copy the info out to the user. */ R_TRY(out_info.CopyFrom(std::addressof(info))); - return ResultSuccess(); + R_SUCCEED(); } Result ContinueDebugEventImpl(ams::svc::Handle debug_handle, uint32_t flags, const uint64_t *thread_ids, int32_t num_thread_ids) { @@ -117,7 +117,7 @@ namespace ams::kern::svc { /* Continue the event. */ R_TRY(debug->ContinueDebug(flags, thread_ids, num_thread_ids)); - return ResultSuccess(); + R_SUCCEED(); } Result ContinueDebugEvent(ams::svc::Handle debug_handle, uint32_t flags, KUserPointer user_thread_ids, int32_t num_thread_ids) { @@ -143,7 +143,7 @@ namespace ams::kern::svc { /* Continue the event. */ R_TRY(ContinueDebugEventImpl(debug_handle, flags, thread_ids, num_thread_ids)); - return ResultSuccess(); + R_SUCCEED(); } Result LegacyContinueDebugEvent(ams::svc::Handle debug_handle, uint32_t flags, uint64_t thread_id) { @@ -160,7 +160,7 @@ namespace ams::kern::svc { /* Continue the event. */ R_TRY(ContinueDebugEventImpl(debug_handle, flags, std::addressof(thread_id), 1)); - return ResultSuccess(); + R_SUCCEED(); } Result GetDebugThreadContext(KUserPointer out_context, ams::svc::Handle debug_handle, uint64_t thread_id, uint32_t context_flags) { @@ -178,7 +178,7 @@ namespace ams::kern::svc { /* Copy the context to userspace. */ R_TRY(out_context.CopyFrom(std::addressof(context))); - return ResultSuccess(); + R_SUCCEED(); } Result SetDebugThreadContext(ams::svc::Handle debug_handle, uint64_t thread_id, KUserPointer user_context, uint32_t context_flags) { @@ -216,7 +216,7 @@ namespace ams::kern::svc { /* Set the thread context. */ R_TRY(debug->SetThreadContext(context, thread_id, context_flags)); - return ResultSuccess(); + R_SUCCEED(); } Result QueryDebugProcessMemory(ams::svc::MemoryInfo *out_memory_info, ams::svc::PageInfo *out_page_info, ams::svc::Handle debug_handle, uintptr_t address) { @@ -227,7 +227,7 @@ namespace ams::kern::svc { /* Query the mapping's info. */ R_TRY(debug->QueryMemoryInfo(out_memory_info, out_page_info, address)); - return ResultSuccess(); + R_SUCCEED(); } template @@ -257,7 +257,7 @@ namespace ams::kern::svc { R_TRY(out_memory_info.CopyFrom(std::addressof(converted_info))); } - return ResultSuccess(); + R_SUCCEED(); } Result ReadDebugProcessMemory(uintptr_t buffer, ams::svc::Handle debug_handle, uintptr_t address, size_t size) { @@ -273,7 +273,7 @@ namespace ams::kern::svc { /* Read the memory. */ R_TRY(debug->ReadMemory(buffer, address, size)); - return ResultSuccess(); + R_SUCCEED(); } Result WriteDebugProcessMemory(ams::svc::Handle debug_handle, uintptr_t buffer, uintptr_t address, size_t size) { @@ -292,7 +292,7 @@ namespace ams::kern::svc { /* Write the memory. */ R_TRY(debug->WriteMemory(buffer, address, size)); - return ResultSuccess(); + R_SUCCEED(); } Result SetHardwareBreakPoint(ams::svc::HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value) { @@ -302,7 +302,7 @@ namespace ams::kern::svc { /* Set the breakpoint. */ R_TRY(KDebug::SetHardwareBreakPoint(name, flags, value)); - return ResultSuccess(); + R_SUCCEED(); } Result GetDebugThreadParam(uint64_t *out_64, uint32_t *out_32, ams::svc::Handle debug_handle, uint64_t thread_id, ams::svc::DebugThreadParam param) { @@ -382,7 +382,7 @@ namespace ams::kern::svc { } break; default: - return svc::ResultInvalidState(); + R_THROW(svc::ResultInvalidState()); } } break; @@ -413,10 +413,10 @@ namespace ams::kern::svc { } break; default: - return ams::svc::ResultInvalidEnumValue(); + R_THROW(ams::svc::ResultInvalidEnumValue()); } - return ResultSuccess(); + R_SUCCEED(); } } @@ -424,109 +424,109 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result DebugActiveProcess64(ams::svc::Handle *out_handle, uint64_t process_id) { - return DebugActiveProcess(out_handle, process_id); + R_RETURN(DebugActiveProcess(out_handle, process_id)); } Result BreakDebugProcess64(ams::svc::Handle debug_handle) { - return BreakDebugProcess(debug_handle); + R_RETURN(BreakDebugProcess(debug_handle)); } Result TerminateDebugProcess64(ams::svc::Handle debug_handle) { - return TerminateDebugProcess(debug_handle); + R_RETURN(TerminateDebugProcess(debug_handle)); } Result GetDebugEvent64(KUserPointer out_info, ams::svc::Handle debug_handle) { - return GetDebugEvent(out_info, debug_handle); + R_RETURN(GetDebugEvent(out_info, debug_handle)); } Result ContinueDebugEvent64(ams::svc::Handle debug_handle, uint32_t flags, KUserPointer thread_ids, int32_t num_thread_ids) { - return ContinueDebugEvent(debug_handle, flags, thread_ids, num_thread_ids); + R_RETURN(ContinueDebugEvent(debug_handle, flags, thread_ids, num_thread_ids)); } Result LegacyContinueDebugEvent64(ams::svc::Handle debug_handle, uint32_t flags, uint64_t thread_id) { - return LegacyContinueDebugEvent(debug_handle, flags, thread_id); + R_RETURN(LegacyContinueDebugEvent(debug_handle, flags, thread_id)); } Result GetDebugThreadContext64(KUserPointer out_context, ams::svc::Handle debug_handle, uint64_t thread_id, uint32_t context_flags) { - return GetDebugThreadContext(out_context, debug_handle, thread_id, context_flags); + R_RETURN(GetDebugThreadContext(out_context, debug_handle, thread_id, context_flags)); } Result SetDebugThreadContext64(ams::svc::Handle debug_handle, uint64_t thread_id, KUserPointer context, uint32_t context_flags) { - return SetDebugThreadContext(debug_handle, thread_id, context, context_flags); + R_RETURN(SetDebugThreadContext(debug_handle, thread_id, context, context_flags)); } Result QueryDebugProcessMemory64(KUserPointer out_memory_info, ams::svc::PageInfo *out_page_info, ams::svc::Handle debug_handle, ams::svc::Address address) { - return QueryDebugProcessMemory(out_memory_info, out_page_info, debug_handle, address); + R_RETURN(QueryDebugProcessMemory(out_memory_info, out_page_info, debug_handle, address)); } Result ReadDebugProcessMemory64(ams::svc::Address buffer, ams::svc::Handle debug_handle, ams::svc::Address address, ams::svc::Size size) { - return ReadDebugProcessMemory(buffer, debug_handle, address, size); + R_RETURN(ReadDebugProcessMemory(buffer, debug_handle, address, size)); } Result WriteDebugProcessMemory64(ams::svc::Handle debug_handle, ams::svc::Address buffer, ams::svc::Address address, ams::svc::Size size) { - return WriteDebugProcessMemory(debug_handle, buffer, address, size); + R_RETURN(WriteDebugProcessMemory(debug_handle, buffer, address, size)); } Result SetHardwareBreakPoint64(ams::svc::HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value) { - return SetHardwareBreakPoint(name, flags, value); + R_RETURN(SetHardwareBreakPoint(name, flags, value)); } Result GetDebugThreadParam64(uint64_t *out_64, uint32_t *out_32, ams::svc::Handle debug_handle, uint64_t thread_id, ams::svc::DebugThreadParam param) { - return GetDebugThreadParam(out_64, out_32, debug_handle, thread_id, param); + R_RETURN(GetDebugThreadParam(out_64, out_32, debug_handle, thread_id, param)); } /* ============================= 64From32 ABI ============================= */ Result DebugActiveProcess64From32(ams::svc::Handle *out_handle, uint64_t process_id) { - return DebugActiveProcess(out_handle, process_id); + R_RETURN(DebugActiveProcess(out_handle, process_id)); } Result BreakDebugProcess64From32(ams::svc::Handle debug_handle) { - return BreakDebugProcess(debug_handle); + R_RETURN(BreakDebugProcess(debug_handle)); } Result TerminateDebugProcess64From32(ams::svc::Handle debug_handle) { - return TerminateDebugProcess(debug_handle); + R_RETURN(TerminateDebugProcess(debug_handle)); } Result GetDebugEvent64From32(KUserPointer out_info, ams::svc::Handle debug_handle) { - return GetDebugEvent(out_info, debug_handle); + R_RETURN(GetDebugEvent(out_info, debug_handle)); } Result ContinueDebugEvent64From32(ams::svc::Handle debug_handle, uint32_t flags, KUserPointer thread_ids, int32_t num_thread_ids) { - return ContinueDebugEvent(debug_handle, flags, thread_ids, num_thread_ids); + R_RETURN(ContinueDebugEvent(debug_handle, flags, thread_ids, num_thread_ids)); } Result LegacyContinueDebugEvent64From32(ams::svc::Handle debug_handle, uint32_t flags, uint64_t thread_id) { - return LegacyContinueDebugEvent(debug_handle, flags, thread_id); + R_RETURN(LegacyContinueDebugEvent(debug_handle, flags, thread_id)); } Result GetDebugThreadContext64From32(KUserPointer out_context, ams::svc::Handle debug_handle, uint64_t thread_id, uint32_t context_flags) { - return GetDebugThreadContext(out_context, debug_handle, thread_id, context_flags); + R_RETURN(GetDebugThreadContext(out_context, debug_handle, thread_id, context_flags)); } Result SetDebugThreadContext64From32(ams::svc::Handle debug_handle, uint64_t thread_id, KUserPointer context, uint32_t context_flags) { - return SetDebugThreadContext(debug_handle, thread_id, context, context_flags); + R_RETURN(SetDebugThreadContext(debug_handle, thread_id, context, context_flags)); } Result QueryDebugProcessMemory64From32(KUserPointer out_memory_info, ams::svc::PageInfo *out_page_info, ams::svc::Handle debug_handle, ams::svc::Address address) { - return QueryDebugProcessMemory(out_memory_info, out_page_info, debug_handle, address); + R_RETURN(QueryDebugProcessMemory(out_memory_info, out_page_info, debug_handle, address)); } Result ReadDebugProcessMemory64From32(ams::svc::Address buffer, ams::svc::Handle debug_handle, ams::svc::Address address, ams::svc::Size size) { - return ReadDebugProcessMemory(buffer, debug_handle, address, size); + R_RETURN(ReadDebugProcessMemory(buffer, debug_handle, address, size)); } Result WriteDebugProcessMemory64From32(ams::svc::Handle debug_handle, ams::svc::Address buffer, ams::svc::Address address, ams::svc::Size size) { - return WriteDebugProcessMemory(debug_handle, buffer, address, size); + R_RETURN(WriteDebugProcessMemory(debug_handle, buffer, address, size)); } Result SetHardwareBreakPoint64From32(ams::svc::HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value) { - return SetHardwareBreakPoint(name, flags, value); + R_RETURN(SetHardwareBreakPoint(name, flags, value)); } Result GetDebugThreadParam64From32(uint64_t *out_64, uint32_t *out_32, ams::svc::Handle debug_handle, uint64_t thread_id, ams::svc::DebugThreadParam param) { - return GetDebugThreadParam(out_64, out_32, debug_handle, thread_id, param); + R_RETURN(GetDebugThreadParam(out_64, out_32, debug_handle, thread_id, param)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_debug_string.cpp b/libraries/libmesosphere/source/svc/kern_svc_debug_string.cpp index 630475206..c36c93ffe 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_debug_string.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_debug_string.cpp @@ -29,7 +29,7 @@ namespace ams::kern::svc { R_UNLESS(GetCurrentProcess().GetPageTable().Contains(KProcessAddress(debug_str.GetUnsafePointer()), len), svc::ResultInvalidCurrentMemory()); /* Output the string. */ - return KDebugLog::PrintUserString(debug_str, len); + R_RETURN(KDebugLog::PrintUserString(debug_str, len)); } } @@ -37,13 +37,13 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result OutputDebugString64(KUserPointer debug_str, ams::svc::Size len) { - return OutputDebugString(debug_str, len); + R_RETURN(OutputDebugString(debug_str, len)); } /* ============================= 64From32 ABI ============================= */ Result OutputDebugString64From32(KUserPointer debug_str, ams::svc::Size len) { - return OutputDebugString(debug_str, len); + R_RETURN(OutputDebugString(debug_str, len)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_device_address_space.cpp b/libraries/libmesosphere/source/svc/kern_svc_device_address_space.cpp index 7bb4931d2..2fec8f923 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_device_address_space.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_device_address_space.cpp @@ -48,7 +48,7 @@ namespace ams::kern::svc { /* Add to the handle table. */ R_TRY(GetCurrentProcess().GetHandleTable().Add(out, das)); - return ResultSuccess(); + R_SUCCEED(); } Result AttachDeviceAddressSpace(ams::svc::DeviceName device_name, ams::svc::Handle das_handle) { @@ -57,7 +57,7 @@ namespace ams::kern::svc { R_UNLESS(das.IsNotNull(), svc::ResultInvalidHandle()); /* Attach. */ - return das->Attach(device_name); + R_RETURN(das->Attach(device_name)); } Result DetachDeviceAddressSpace(ams::svc::DeviceName device_name, ams::svc::Handle das_handle) { @@ -66,7 +66,7 @@ namespace ams::kern::svc { R_UNLESS(das.IsNotNull(), svc::ResultInvalidHandle()); /* Detach. */ - return das->Detach(device_name); + R_RETURN(das->Detach(device_name)); } constexpr bool IsValidDeviceMemoryPermission(ams::svc::MemoryPermission device_perm) { @@ -104,7 +104,7 @@ namespace ams::kern::svc { R_UNLESS(page_table.Contains(process_address, size), svc::ResultInvalidCurrentMemory()); /* Map. */ - return das->MapByForce(std::addressof(page_table), KProcessAddress(process_address), size, device_address, device_perm); + R_RETURN(das->MapByForce(std::addressof(page_table), KProcessAddress(process_address), size, device_address, device_perm)); } Result MapDeviceAddressSpaceAligned(ams::svc::Handle das_handle, ams::svc::Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, ams::svc::MemoryPermission device_perm) { @@ -132,7 +132,7 @@ namespace ams::kern::svc { R_UNLESS(page_table.Contains(process_address, size), svc::ResultInvalidCurrentMemory()); /* Map. */ - return das->MapAligned(std::addressof(page_table), KProcessAddress(process_address), size, device_address, device_perm); + R_RETURN(das->MapAligned(std::addressof(page_table), KProcessAddress(process_address), size, device_address, device_perm)); } Result UnmapDeviceAddressSpace(ams::svc::Handle das_handle, ams::svc::Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address) { @@ -157,7 +157,7 @@ namespace ams::kern::svc { auto &page_table = process->GetPageTable(); R_UNLESS(page_table.Contains(process_address, size), svc::ResultInvalidCurrentMemory()); - return das->Unmap(std::addressof(page_table), KProcessAddress(process_address), size, device_address); + R_RETURN(das->Unmap(std::addressof(page_table), KProcessAddress(process_address), size, device_address)); } } @@ -165,53 +165,53 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result CreateDeviceAddressSpace64(ams::svc::Handle *out_handle, uint64_t das_address, uint64_t das_size) { - return CreateDeviceAddressSpace(out_handle, das_address, das_size); + R_RETURN(CreateDeviceAddressSpace(out_handle, das_address, das_size)); } Result AttachDeviceAddressSpace64(ams::svc::DeviceName device_name, ams::svc::Handle das_handle) { - return AttachDeviceAddressSpace(device_name, das_handle); + R_RETURN(AttachDeviceAddressSpace(device_name, das_handle)); } Result DetachDeviceAddressSpace64(ams::svc::DeviceName device_name, ams::svc::Handle das_handle) { - return DetachDeviceAddressSpace(device_name, das_handle); + R_RETURN(DetachDeviceAddressSpace(device_name, das_handle)); } Result MapDeviceAddressSpaceByForce64(ams::svc::Handle das_handle, ams::svc::Handle process_handle, uint64_t process_address, ams::svc::Size size, uint64_t device_address, ams::svc::MemoryPermission device_perm) { - return MapDeviceAddressSpaceByForce(das_handle, process_handle, process_address, size, device_address, device_perm); + R_RETURN(MapDeviceAddressSpaceByForce(das_handle, process_handle, process_address, size, device_address, device_perm)); } Result MapDeviceAddressSpaceAligned64(ams::svc::Handle das_handle, ams::svc::Handle process_handle, uint64_t process_address, ams::svc::Size size, uint64_t device_address, ams::svc::MemoryPermission device_perm) { - return MapDeviceAddressSpaceAligned(das_handle, process_handle, process_address, size, device_address, device_perm); + R_RETURN(MapDeviceAddressSpaceAligned(das_handle, process_handle, process_address, size, device_address, device_perm)); } Result UnmapDeviceAddressSpace64(ams::svc::Handle das_handle, ams::svc::Handle process_handle, uint64_t process_address, ams::svc::Size size, uint64_t device_address) { - return UnmapDeviceAddressSpace(das_handle, process_handle, process_address, size, device_address); + R_RETURN(UnmapDeviceAddressSpace(das_handle, process_handle, process_address, size, device_address)); } /* ============================= 64From32 ABI ============================= */ Result CreateDeviceAddressSpace64From32(ams::svc::Handle *out_handle, uint64_t das_address, uint64_t das_size) { - return CreateDeviceAddressSpace(out_handle, das_address, das_size); + R_RETURN(CreateDeviceAddressSpace(out_handle, das_address, das_size)); } Result AttachDeviceAddressSpace64From32(ams::svc::DeviceName device_name, ams::svc::Handle das_handle) { - return AttachDeviceAddressSpace(device_name, das_handle); + R_RETURN(AttachDeviceAddressSpace(device_name, das_handle)); } Result DetachDeviceAddressSpace64From32(ams::svc::DeviceName device_name, ams::svc::Handle das_handle) { - return DetachDeviceAddressSpace(device_name, das_handle); + R_RETURN(DetachDeviceAddressSpace(device_name, das_handle)); } Result MapDeviceAddressSpaceByForce64From32(ams::svc::Handle das_handle, ams::svc::Handle process_handle, uint64_t process_address, ams::svc::Size size, uint64_t device_address, ams::svc::MemoryPermission device_perm) { - return MapDeviceAddressSpaceByForce(das_handle, process_handle, process_address, size, device_address, device_perm); + R_RETURN(MapDeviceAddressSpaceByForce(das_handle, process_handle, process_address, size, device_address, device_perm)); } Result MapDeviceAddressSpaceAligned64From32(ams::svc::Handle das_handle, ams::svc::Handle process_handle, uint64_t process_address, ams::svc::Size size, uint64_t device_address, ams::svc::MemoryPermission device_perm) { - return MapDeviceAddressSpaceAligned(das_handle, process_handle, process_address, size, device_address, device_perm); + R_RETURN(MapDeviceAddressSpaceAligned(das_handle, process_handle, process_address, size, device_address, device_perm)); } Result UnmapDeviceAddressSpace64From32(ams::svc::Handle das_handle, ams::svc::Handle process_handle, uint64_t process_address, ams::svc::Size size, uint64_t device_address) { - return UnmapDeviceAddressSpace(das_handle, process_handle, process_address, size, device_address); + R_RETURN(UnmapDeviceAddressSpace(das_handle, process_handle, process_address, size, device_address)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_info.cpp b/libraries/libmesosphere/source/svc/kern_svc_info.cpp index 33a2bb115..d1a327043 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_info.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_info.cpp @@ -32,10 +32,10 @@ namespace ams::kern::svc { *out = GetInitialProcessIdMax(); break; default: - return svc::ResultInvalidCombination(); + R_THROW(svc::ResultInvalidCombination()); } - return ResultSuccess(); + R_SUCCEED(); } Result GetInfoImpl(u64 *out, ams::svc::InfoType info_type, KProcess *process) { @@ -109,7 +109,7 @@ namespace ams::kern::svc { MESOSPHERE_UNREACHABLE_DEFAULT_CASE(); } - return ResultSuccess(); + R_SUCCEED(); } Result GetInfo(u64 *out, ams::svc::InfoType info_type, ams::svc::Handle handle, u64 info_subtype) { @@ -144,7 +144,7 @@ namespace ams::kern::svc { #if defined(MESOSPHERE_ENABLE_GET_INFO_OF_DEBUG_PROCESS) /* If we the process is valid, use it. */ if (process.IsNotNull()) { - return GetInfoImpl(out, info_type, process.GetPointerUnsafe()); + R_RETURN(GetInfoImpl(out, info_type, process.GetPointerUnsafe())); } /* Otherwise, as a mesosphere extension check if we were passed a usable KDebug. */ @@ -160,13 +160,13 @@ namespace ams::kern::svc { ON_SCOPE_EXIT { debug->CloseProcess(); }; /* Return the info. */ - return GetInfoImpl(out, info_type, debug->GetProcessUnsafe()); + R_RETURN(GetInfoImpl(out, info_type, debug->GetProcessUnsafe())); #else /* Verify that the process is valid. */ R_UNLESS(process.IsNotNull(), svc::ResultInvalidHandle()); /* Return the relevant info. */ - return GetInfoImpl(out, info_type, process.GetPointerUnsafe()); + R_RETURN(GetInfoImpl(out, info_type, process.GetPointerUnsafe())); #endif } break; @@ -315,7 +315,7 @@ namespace ams::kern::svc { } break; default: - return svc::ResultInvalidCombination(); + R_THROW(svc::ResultInvalidCombination()); } } break; @@ -343,10 +343,10 @@ namespace ams::kern::svc { /* For debug, log the invalid info call. */ MESOSPHERE_LOG("GetInfo(%p, %u, %08x, %lu) was called\n", out, static_cast(info_type), static_cast(handle), info_subtype); } - return svc::ResultInvalidEnumValue(); + R_THROW(svc::ResultInvalidEnumValue()); } - return ResultSuccess(); + R_SUCCEED(); } constexpr bool IsValidMemoryPool(u64 pool) { @@ -398,10 +398,10 @@ namespace ams::kern::svc { } break; default: - return svc::ResultInvalidEnumValue(); + R_THROW(svc::ResultInvalidEnumValue()); } - return ResultSuccess(); + R_SUCCEED(); } } @@ -409,21 +409,21 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result GetInfo64(uint64_t *out, ams::svc::InfoType info_type, ams::svc::Handle handle, uint64_t info_subtype) { - return GetInfo(out, info_type, handle, info_subtype); + R_RETURN(GetInfo(out, info_type, handle, info_subtype)); } Result GetSystemInfo64(uint64_t *out, ams::svc::SystemInfoType info_type, ams::svc::Handle handle, uint64_t info_subtype) { - return GetSystemInfo(out, info_type, handle, info_subtype); + R_RETURN(GetSystemInfo(out, info_type, handle, info_subtype)); } /* ============================= 64From32 ABI ============================= */ Result GetInfo64From32(uint64_t *out, ams::svc::InfoType info_type, ams::svc::Handle handle, uint64_t info_subtype) { - return GetInfo(out, info_type, handle, info_subtype); + R_RETURN(GetInfo(out, info_type, handle, info_subtype)); } Result GetSystemInfo64From32(uint64_t *out, ams::svc::SystemInfoType info_type, ams::svc::Handle handle, uint64_t info_subtype) { - return GetSystemInfo(out, info_type, handle, info_subtype); + R_RETURN(GetSystemInfo(out, info_type, handle, info_subtype)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_interrupt_event.cpp b/libraries/libmesosphere/source/svc/kern_svc_interrupt_event.cpp index 939515c13..0c867db0e 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_interrupt_event.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_interrupt_event.cpp @@ -56,7 +56,7 @@ namespace ams::kern::svc { /* Add the event to the handle table. */ R_TRY(handle_table.Add(out, event)); - return ResultSuccess(); + R_SUCCEED(); } } @@ -64,13 +64,13 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result CreateInterruptEvent64(ams::svc::Handle *out_read_handle, int32_t interrupt_id, ams::svc::InterruptType interrupt_type) { - return CreateInterruptEvent(out_read_handle, interrupt_id, interrupt_type); + R_RETURN(CreateInterruptEvent(out_read_handle, interrupt_id, interrupt_type)); } /* ============================= 64From32 ABI ============================= */ Result CreateInterruptEvent64From32(ams::svc::Handle *out_read_handle, int32_t interrupt_id, ams::svc::InterruptType interrupt_type) { - return CreateInterruptEvent(out_read_handle, interrupt_id, interrupt_type); + R_RETURN(CreateInterruptEvent(out_read_handle, interrupt_id, interrupt_type)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_io_pool.cpp b/libraries/libmesosphere/source/svc/kern_svc_io_pool.cpp index 220f12916..ffa65f723 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_io_pool.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_io_pool.cpp @@ -69,10 +69,10 @@ namespace ams::kern::svc { /* Add the io pool to the handle table. */ R_TRY(GetCurrentProcess().GetHandleTable().Add(out, io_pool)); - return ResultSuccess(); + R_SUCCEED(); } else { MESOSPHERE_UNUSED(out, pool_type); - return svc::ResultNotImplemented(); + R_THROW(svc::ResultNotImplemented()); } } @@ -111,10 +111,10 @@ namespace ams::kern::svc { /* Add the io region to the handle table. */ R_TRY(handle_table.Add(out, io_region)); - return ResultSuccess(); + R_SUCCEED(); } else { MESOSPHERE_UNUSED(out, io_pool_handle, phys_addr, size, mapping, perm); - return svc::ResultNotImplemented(); + R_THROW(svc::ResultNotImplemented()); } } @@ -140,10 +140,10 @@ namespace ams::kern::svc { R_TRY(io_region->Map(address, size, map_perm)); /* We succeeded. */ - return ResultSuccess(); + R_SUCCEED(); } else { MESOSPHERE_UNUSED(io_region_handle, address, size, map_perm); - return svc::ResultNotImplemented(); + R_THROW(svc::ResultNotImplemented()); } } @@ -166,10 +166,10 @@ namespace ams::kern::svc { R_TRY(io_region->Unmap(address, size)); /* We succeeded. */ - return ResultSuccess(); + R_SUCCEED(); } else { MESOSPHERE_UNUSED(io_region_handle, address, size); - return svc::ResultNotImplemented(); + R_THROW(svc::ResultNotImplemented()); } } @@ -178,37 +178,37 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result CreateIoPool64(ams::svc::Handle *out_handle, ams::svc::IoPoolType pool_type) { - return CreateIoPool(out_handle, pool_type); + R_RETURN(CreateIoPool(out_handle, pool_type)); } Result CreateIoRegion64(ams::svc::Handle *out_handle, ams::svc::Handle io_pool, ams::svc::PhysicalAddress physical_address, ams::svc::Size size, ams::svc::MemoryMapping mapping, ams::svc::MemoryPermission perm) { - return CreateIoRegion(out_handle, io_pool, physical_address, size, mapping, perm); + R_RETURN(CreateIoRegion(out_handle, io_pool, physical_address, size, mapping, perm)); } Result MapIoRegion64(ams::svc::Handle io_region, ams::svc::Address address, ams::svc::Size size, ams::svc::MemoryPermission perm) { - return MapIoRegion(io_region, address, size, perm); + R_RETURN(MapIoRegion(io_region, address, size, perm)); } Result UnmapIoRegion64(ams::svc::Handle io_region, ams::svc::Address address, ams::svc::Size size) { - return UnmapIoRegion(io_region, address, size); + R_RETURN(UnmapIoRegion(io_region, address, size)); } /* ============================= 64From32 ABI ============================= */ Result CreateIoPool64From32(ams::svc::Handle *out_handle, ams::svc::IoPoolType pool_type) { - return CreateIoPool(out_handle, pool_type); + R_RETURN(CreateIoPool(out_handle, pool_type)); } Result CreateIoRegion64From32(ams::svc::Handle *out_handle, ams::svc::Handle io_pool, ams::svc::PhysicalAddress physical_address, ams::svc::Size size, ams::svc::MemoryMapping mapping, ams::svc::MemoryPermission perm) { - return CreateIoRegion(out_handle, io_pool, physical_address, size, mapping, perm); + R_RETURN(CreateIoRegion(out_handle, io_pool, physical_address, size, mapping, perm)); } Result MapIoRegion64From32(ams::svc::Handle io_region, ams::svc::Address address, ams::svc::Size size, ams::svc::MemoryPermission perm) { - return MapIoRegion(io_region, address, size, perm); + R_RETURN(MapIoRegion(io_region, address, size, perm)); } Result UnmapIoRegion64From32(ams::svc::Handle io_region, ams::svc::Address address, ams::svc::Size size) { - return UnmapIoRegion(io_region, address, size); + R_RETURN(UnmapIoRegion(io_region, address, size)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_light_ipc.cpp b/libraries/libmesosphere/source/svc/kern_svc_light_ipc.cpp index dc413b318..71ba011a8 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_light_ipc.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_light_ipc.cpp @@ -29,7 +29,7 @@ namespace ams::kern::svc { /* Send the request. */ R_TRY(session->SendSyncRequest(args)); - return ResultSuccess(); + R_SUCCEED(); } ALWAYS_INLINE Result ReplyAndReceiveLight(ams::svc::Handle session_handle, u32 *args) { @@ -40,7 +40,7 @@ namespace ams::kern::svc { /* Handle the request. */ R_TRY(session->ReplyAndReceive(args)); - return ResultSuccess(); + R_SUCCEED(); } } @@ -48,21 +48,21 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result SendSyncRequestLight64(ams::svc::Handle session_handle, u32 *args) { - return SendSyncRequestLight(session_handle, args); + R_RETURN(SendSyncRequestLight(session_handle, args)); } Result ReplyAndReceiveLight64(ams::svc::Handle session_handle, u32 *args) { - return ReplyAndReceiveLight(session_handle, args); + R_RETURN(ReplyAndReceiveLight(session_handle, args)); } /* ============================= 64From32 ABI ============================= */ Result SendSyncRequestLight64From32(ams::svc::Handle session_handle, u32 *args) { - return SendSyncRequestLight(session_handle, args); + R_RETURN(SendSyncRequestLight(session_handle, args)); } Result ReplyAndReceiveLight64From32(ams::svc::Handle session_handle, u32 *args) { - return ReplyAndReceiveLight(session_handle, args); + R_RETURN(ReplyAndReceiveLight(session_handle, args)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_lock.cpp b/libraries/libmesosphere/source/svc/kern_svc_lock.cpp index 148cb5499..be19bc0ed 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_lock.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_lock.cpp @@ -30,7 +30,7 @@ namespace ams::kern::svc { R_UNLESS(!IsKernelAddress(address), svc::ResultInvalidCurrentMemory()); R_UNLESS(util::IsAligned(address, sizeof(u32)), svc::ResultInvalidAddress()); - return KConditionVariable::WaitForAddress(thread_handle, address, tag); + R_RETURN(KConditionVariable::WaitForAddress(thread_handle, address, tag)); } Result ArbitrateUnlock(uintptr_t address) { @@ -38,7 +38,7 @@ namespace ams::kern::svc { R_UNLESS(!IsKernelAddress(address), svc::ResultInvalidCurrentMemory()); R_UNLESS(util::IsAligned(address, sizeof(u32)), svc::ResultInvalidAddress()); - return KConditionVariable::SignalToAddress(address); + R_RETURN(KConditionVariable::SignalToAddress(address)); } } @@ -46,21 +46,21 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result ArbitrateLock64(ams::svc::Handle thread_handle, ams::svc::Address address, uint32_t tag) { - return ArbitrateLock(thread_handle, address, tag); + R_RETURN(ArbitrateLock(thread_handle, address, tag)); } Result ArbitrateUnlock64(ams::svc::Address address) { - return ArbitrateUnlock(address); + R_RETURN(ArbitrateUnlock(address)); } /* ============================= 64From32 ABI ============================= */ Result ArbitrateLock64From32(ams::svc::Handle thread_handle, ams::svc::Address address, uint32_t tag) { - return ArbitrateLock(thread_handle, address, tag); + R_RETURN(ArbitrateLock(thread_handle, address, tag)); } Result ArbitrateUnlock64From32(ams::svc::Address address) { - return ArbitrateUnlock(address); + R_RETURN(ArbitrateUnlock(address)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_memory.cpp b/libraries/libmesosphere/source/svc/kern_svc_memory.cpp index 5371a5531..a6994fae4 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_memory.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_memory.cpp @@ -47,7 +47,7 @@ namespace ams::kern::svc { R_UNLESS(page_table.Contains(address, size), svc::ResultInvalidCurrentMemory()); /* Set the memory attribute. */ - return page_table.SetMemoryPermission(address, size, perm); + R_RETURN(page_table.SetMemoryPermission(address, size, perm)); } Result SetMemoryAttribute(uintptr_t address, size_t size, uint32_t mask, uint32_t attr) { @@ -67,7 +67,7 @@ namespace ams::kern::svc { R_UNLESS(page_table.Contains(address, size), svc::ResultInvalidCurrentMemory()); /* Set the memory attribute. */ - return page_table.SetMemoryAttribute(address, size, mask, attr); + R_RETURN(page_table.SetMemoryAttribute(address, size, mask, attr)); } Result MapMemory(uintptr_t dst_address, uintptr_t src_address, size_t size) { @@ -91,7 +91,7 @@ namespace ams::kern::svc { R_UNLESS(page_table.CanContain(dst_address, size, KMemoryState_Stack), svc::ResultInvalidMemoryRegion()); /* Map the memory. */ - return page_table.MapMemory(dst_address, src_address, size); + R_RETURN(page_table.MapMemory(dst_address, src_address, size)); } Result UnmapMemory(uintptr_t dst_address, uintptr_t src_address, size_t size) { @@ -115,7 +115,7 @@ namespace ams::kern::svc { R_UNLESS(page_table.CanContain(dst_address, size, KMemoryState_Stack), svc::ResultInvalidMemoryRegion()); /* Unmap the memory. */ - return page_table.UnmapMemory(dst_address, src_address, size); + R_RETURN(page_table.UnmapMemory(dst_address, src_address, size)); } } @@ -123,37 +123,37 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result SetMemoryPermission64(ams::svc::Address address, ams::svc::Size size, ams::svc::MemoryPermission perm) { - return SetMemoryPermission(address, size, perm); + R_RETURN(SetMemoryPermission(address, size, perm)); } Result SetMemoryAttribute64(ams::svc::Address address, ams::svc::Size size, uint32_t mask, uint32_t attr) { - return SetMemoryAttribute(address, size, mask, attr); + R_RETURN(SetMemoryAttribute(address, size, mask, attr)); } Result MapMemory64(ams::svc::Address dst_address, ams::svc::Address src_address, ams::svc::Size size) { - return MapMemory(dst_address, src_address, size); + R_RETURN(MapMemory(dst_address, src_address, size)); } Result UnmapMemory64(ams::svc::Address dst_address, ams::svc::Address src_address, ams::svc::Size size) { - return UnmapMemory(dst_address, src_address, size); + R_RETURN(UnmapMemory(dst_address, src_address, size)); } /* ============================= 64From32 ABI ============================= */ Result SetMemoryPermission64From32(ams::svc::Address address, ams::svc::Size size, ams::svc::MemoryPermission perm) { - return SetMemoryPermission(address, size, perm); + R_RETURN(SetMemoryPermission(address, size, perm)); } Result SetMemoryAttribute64From32(ams::svc::Address address, ams::svc::Size size, uint32_t mask, uint32_t attr) { - return SetMemoryAttribute(address, size, mask, attr); + R_RETURN(SetMemoryAttribute(address, size, mask, attr)); } Result MapMemory64From32(ams::svc::Address dst_address, ams::svc::Address src_address, ams::svc::Size size) { - return MapMemory(dst_address, src_address, size); + R_RETURN(MapMemory(dst_address, src_address, size)); } Result UnmapMemory64From32(ams::svc::Address dst_address, ams::svc::Address src_address, ams::svc::Size size) { - return UnmapMemory(dst_address, src_address, size); + R_RETURN(UnmapMemory(dst_address, src_address, size)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_physical_memory.cpp b/libraries/libmesosphere/source/svc/kern_svc_physical_memory.cpp index 55f1e5c91..1319bf1e2 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_physical_memory.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_physical_memory.cpp @@ -32,7 +32,7 @@ namespace ams::kern::svc { /* Set the output. */ *out_address = GetInteger(address); - return ResultSuccess(); + R_SUCCEED(); } Result SetUnsafeLimit(size_t limit) { @@ -43,7 +43,7 @@ namespace ams::kern::svc { R_UNLESS(limit <= Kernel::GetMemoryManager().GetSize(KMemoryManager::Pool_Unsafe), svc::ResultOutOfRange()); /* Set the size. */ - return Kernel::GetUnsafeMemory().SetLimitSize(limit); + R_RETURN(Kernel::GetUnsafeMemory().SetLimitSize(limit)); } Result MapPhysicalMemory(uintptr_t address, size_t size) { @@ -64,7 +64,7 @@ namespace ams::kern::svc { /* Map the memory. */ R_TRY(page_table.MapPhysicalMemory(address, size)); - return ResultSuccess(); + R_SUCCEED(); } Result UnmapPhysicalMemory(uintptr_t address, size_t size) { @@ -85,7 +85,7 @@ namespace ams::kern::svc { /* Unmap the memory. */ R_TRY(page_table.UnmapPhysicalMemory(address, size)); - return ResultSuccess(); + R_SUCCEED(); } Result MapPhysicalMemoryUnsafe(uintptr_t address, size_t size) { @@ -106,7 +106,7 @@ namespace ams::kern::svc { /* Map the memory. */ R_TRY(page_table.MapPhysicalMemoryUnsafe(address, size)); - return ResultSuccess(); + R_SUCCEED(); } Result UnmapPhysicalMemoryUnsafe(uintptr_t address, size_t size) { @@ -124,7 +124,7 @@ namespace ams::kern::svc { /* Unmap the memory. */ R_TRY(page_table.UnmapPhysicalMemoryUnsafe(address, size)); - return ResultSuccess(); + R_SUCCEED(); } } @@ -133,54 +133,54 @@ namespace ams::kern::svc { Result SetHeapSize64(ams::svc::Address *out_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); - return SetHeapSize(reinterpret_cast(out_address), size); + R_RETURN(SetHeapSize(reinterpret_cast(out_address), size)); } Result MapPhysicalMemory64(ams::svc::Address address, ams::svc::Size size) { - return MapPhysicalMemory(address, size); + R_RETURN(MapPhysicalMemory(address, size)); } Result UnmapPhysicalMemory64(ams::svc::Address address, ams::svc::Size size) { - return UnmapPhysicalMemory(address, size); + R_RETURN(UnmapPhysicalMemory(address, size)); } Result MapPhysicalMemoryUnsafe64(ams::svc::Address address, ams::svc::Size size) { - return MapPhysicalMemoryUnsafe(address, size); + R_RETURN(MapPhysicalMemoryUnsafe(address, size)); } Result UnmapPhysicalMemoryUnsafe64(ams::svc::Address address, ams::svc::Size size) { - return UnmapPhysicalMemoryUnsafe(address, size); + R_RETURN(UnmapPhysicalMemoryUnsafe(address, size)); } Result SetUnsafeLimit64(ams::svc::Size limit) { - return SetUnsafeLimit(limit); + R_RETURN(SetUnsafeLimit(limit)); } /* ============================= 64From32 ABI ============================= */ Result SetHeapSize64From32(ams::svc::Address *out_address, ams::svc::Size size) { static_assert(sizeof(*out_address) == sizeof(uintptr_t)); - return SetHeapSize(reinterpret_cast(out_address), size); + R_RETURN(SetHeapSize(reinterpret_cast(out_address), size)); } Result MapPhysicalMemory64From32(ams::svc::Address address, ams::svc::Size size) { - return MapPhysicalMemory(address, size); + R_RETURN(MapPhysicalMemory(address, size)); } Result UnmapPhysicalMemory64From32(ams::svc::Address address, ams::svc::Size size) { - return UnmapPhysicalMemory(address, size); + R_RETURN(UnmapPhysicalMemory(address, size)); } Result MapPhysicalMemoryUnsafe64From32(ams::svc::Address address, ams::svc::Size size) { - return MapPhysicalMemoryUnsafe(address, size); + R_RETURN(MapPhysicalMemoryUnsafe(address, size)); } Result UnmapPhysicalMemoryUnsafe64From32(ams::svc::Address address, ams::svc::Size size) { - return UnmapPhysicalMemoryUnsafe(address, size); + R_RETURN(UnmapPhysicalMemoryUnsafe(address, size)); } Result SetUnsafeLimit64From32(ams::svc::Size limit) { - return SetUnsafeLimit(limit); + R_RETURN(SetUnsafeLimit(limit)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_process.cpp b/libraries/libmesosphere/source/svc/kern_svc_process.cpp index 4cff6a1d5..aa240dff7 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_process.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_process.cpp @@ -65,7 +65,7 @@ namespace ams::kern::svc { *out_process_id = d->GetProcessUnsafe()->GetProcessId(); } - return ResultSuccess(); + R_SUCCEED(); } Result GetProcessList(int32_t *out_num_processes, KUserPointer out_process_ids, int32_t max_out_count) { @@ -78,7 +78,7 @@ namespace ams::kern::svc { } /* Get the process list. */ - return KProcess::GetProcessList(out_num_processes, out_process_ids, max_out_count); + R_RETURN(KProcess::GetProcessList(out_num_processes, out_process_ids, max_out_count)); } Result CreateProcess(ams::svc::Handle *out, const ams::svc::CreateProcessParameter ¶ms, KUserPointer user_caps, int32_t num_caps) { @@ -135,7 +135,7 @@ namespace ams::kern::svc { } break; default: - return svc::ResultInvalidEnumValue(); + R_THROW(svc::ResultInvalidEnumValue()); } /* Validate the pool partition. */ @@ -147,7 +147,7 @@ namespace ams::kern::svc { case ams::svc::CreateProcessFlag_PoolPartitionSystemNonSecure: break; default: - return svc::ResultInvalidEnumValue(); + R_THROW(svc::ResultInvalidEnumValue()); } } @@ -243,7 +243,7 @@ namespace ams::kern::svc { /* Add the process to the handle table. */ R_TRY(handle_table.Add(out, process)); - return ResultSuccess(); + R_SUCCEED(); } template @@ -254,7 +254,7 @@ namespace ams::kern::svc { /* Invoke the implementation. */ if constexpr (std::same_as) { - return CreateProcess(out, params, user_caps, num_caps); + R_RETURN(CreateProcess(out, params, user_caps, num_caps)); } else { /* Convert the parameters. */ ams::svc::CreateProcessParameter converted_params; @@ -270,7 +270,7 @@ namespace ams::kern::svc { converted_params.system_resource_num_pages = params.system_resource_num_pages; /* Invoke. */ - return CreateProcess(out, converted_params, user_caps, num_caps); + R_RETURN(CreateProcess(out, converted_params, user_caps, num_caps)); } } @@ -294,7 +294,7 @@ namespace ams::kern::svc { process->SetIdealCoreId(core_id); /* Run the process. */ - return process->Run(priority, static_cast(main_thread_stack_size)); + R_RETURN(process->Run(priority, static_cast(main_thread_stack_size))); } Result TerminateProcess(ams::svc::Handle process_handle) { @@ -316,7 +316,7 @@ namespace ams::kern::svc { ExitProcess(); } - return ResultSuccess(); + R_SUCCEED(); } Result GetProcessInfo(int64_t *out, ams::svc::Handle process_handle, ams::svc::ProcessInfoType info_type) { @@ -352,10 +352,10 @@ namespace ams::kern::svc { } break; default: - return svc::ResultInvalidEnumValue(); + R_THROW(svc::ResultInvalidEnumValue()); } - return ResultSuccess(); + R_SUCCEED(); } } @@ -367,27 +367,27 @@ namespace ams::kern::svc { } Result GetProcessId64(uint64_t *out_process_id, ams::svc::Handle process_handle) { - return GetProcessId(out_process_id, process_handle); + R_RETURN(GetProcessId(out_process_id, process_handle)); } Result GetProcessList64(int32_t *out_num_processes, KUserPointer out_process_ids, int32_t max_out_count) { - return GetProcessList(out_num_processes, out_process_ids, max_out_count); + R_RETURN(GetProcessList(out_num_processes, out_process_ids, max_out_count)); } Result CreateProcess64(ams::svc::Handle *out_handle, KUserPointer parameters, KUserPointer caps, int32_t num_caps) { - return CreateProcess(out_handle, parameters, caps, num_caps); + R_RETURN(CreateProcess(out_handle, parameters, caps, num_caps)); } Result StartProcess64(ams::svc::Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size) { - return StartProcess(process_handle, priority, core_id, main_thread_stack_size); + R_RETURN(StartProcess(process_handle, priority, core_id, main_thread_stack_size)); } Result TerminateProcess64(ams::svc::Handle process_handle) { - return TerminateProcess(process_handle); + R_RETURN(TerminateProcess(process_handle)); } Result GetProcessInfo64(int64_t *out_info, ams::svc::Handle process_handle, ams::svc::ProcessInfoType info_type) { - return GetProcessInfo(out_info, process_handle, info_type); + R_RETURN(GetProcessInfo(out_info, process_handle, info_type)); } /* ============================= 64From32 ABI ============================= */ @@ -397,27 +397,27 @@ namespace ams::kern::svc { } Result GetProcessId64From32(uint64_t *out_process_id, ams::svc::Handle process_handle) { - return GetProcessId(out_process_id, process_handle); + R_RETURN(GetProcessId(out_process_id, process_handle)); } Result GetProcessList64From32(int32_t *out_num_processes, KUserPointer out_process_ids, int32_t max_out_count) { - return GetProcessList(out_num_processes, out_process_ids, max_out_count); + R_RETURN(GetProcessList(out_num_processes, out_process_ids, max_out_count)); } Result CreateProcess64From32(ams::svc::Handle *out_handle, KUserPointer parameters, KUserPointer caps, int32_t num_caps) { - return CreateProcess(out_handle, parameters, caps, num_caps); + R_RETURN(CreateProcess(out_handle, parameters, caps, num_caps)); } Result StartProcess64From32(ams::svc::Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size) { - return StartProcess(process_handle, priority, core_id, main_thread_stack_size); + R_RETURN(StartProcess(process_handle, priority, core_id, main_thread_stack_size)); } Result TerminateProcess64From32(ams::svc::Handle process_handle) { - return TerminateProcess(process_handle); + R_RETURN(TerminateProcess(process_handle)); } Result GetProcessInfo64From32(int64_t *out_info, ams::svc::Handle process_handle, ams::svc::ProcessInfoType info_type) { - return GetProcessInfo(out_info, process_handle, info_type); + R_RETURN(GetProcessInfo(out_info, process_handle, info_type)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_process_memory.cpp b/libraries/libmesosphere/source/svc/kern_svc_process_memory.cpp index a911b4c88..91d799d78 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_process_memory.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_process_memory.cpp @@ -54,7 +54,7 @@ namespace ams::kern::svc { R_UNLESS(page_table.Contains(address, size), svc::ResultInvalidCurrentMemory()); /* Set the memory permission. */ - return page_table.SetProcessMemoryPermission(address, size, perm); + R_RETURN(page_table.SetProcessMemoryPermission(address, size, perm)); } Result MapProcessMemory(uintptr_t dst_address, ams::svc::Handle process_handle, uint64_t src_address, size_t size) { @@ -96,7 +96,7 @@ namespace ams::kern::svc { /* Map the group. */ R_TRY(dst_pt.MapPageGroup(dst_address, pg, KMemoryState_SharedCode, KMemoryPermission_UserReadWrite)); - return ResultSuccess(); + R_SUCCEED(); } Result UnmapProcessMemory(uintptr_t dst_address, ams::svc::Handle process_handle, uint64_t src_address, size_t size) { @@ -125,7 +125,7 @@ namespace ams::kern::svc { /* Unmap the memory. */ R_TRY(dst_pt.UnmapProcessMemory(dst_address, size, src_pt, src_address)); - return ResultSuccess(); + R_SUCCEED(); } Result MapProcessCodeMemory(ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { @@ -152,7 +152,7 @@ namespace ams::kern::svc { /* Map the memory. */ R_TRY(page_table.MapCodeMemory(dst_address, src_address, size)); - return ResultSuccess(); + R_SUCCEED(); } Result UnmapProcessCodeMemory(ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { @@ -179,7 +179,7 @@ namespace ams::kern::svc { /* Unmap the memory. */ R_TRY(page_table.UnmapCodeMemory(dst_address, src_address, size)); - return ResultSuccess(); + R_SUCCEED(); } } @@ -187,45 +187,45 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result SetProcessMemoryPermission64(ams::svc::Handle process_handle, uint64_t address, uint64_t size, ams::svc::MemoryPermission perm) { - return SetProcessMemoryPermission(process_handle, address, size, perm); + R_RETURN(SetProcessMemoryPermission(process_handle, address, size, perm)); } Result MapProcessMemory64(ams::svc::Address dst_address, ams::svc::Handle process_handle, uint64_t src_address, ams::svc::Size size) { - return MapProcessMemory(dst_address, process_handle, src_address, size); + R_RETURN(MapProcessMemory(dst_address, process_handle, src_address, size)); } Result UnmapProcessMemory64(ams::svc::Address dst_address, ams::svc::Handle process_handle, uint64_t src_address, ams::svc::Size size) { - return UnmapProcessMemory(dst_address, process_handle, src_address, size); + R_RETURN(UnmapProcessMemory(dst_address, process_handle, src_address, size)); } Result MapProcessCodeMemory64(ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { - return MapProcessCodeMemory(process_handle, dst_address, src_address, size); + R_RETURN(MapProcessCodeMemory(process_handle, dst_address, src_address, size)); } Result UnmapProcessCodeMemory64(ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { - return UnmapProcessCodeMemory(process_handle, dst_address, src_address, size); + R_RETURN(UnmapProcessCodeMemory(process_handle, dst_address, src_address, size)); } /* ============================= 64From32 ABI ============================= */ Result SetProcessMemoryPermission64From32(ams::svc::Handle process_handle, uint64_t address, uint64_t size, ams::svc::MemoryPermission perm) { - return SetProcessMemoryPermission(process_handle, address, size, perm); + R_RETURN(SetProcessMemoryPermission(process_handle, address, size, perm)); } Result MapProcessMemory64From32(ams::svc::Address dst_address, ams::svc::Handle process_handle, uint64_t src_address, ams::svc::Size size) { - return MapProcessMemory(dst_address, process_handle, src_address, size); + R_RETURN(MapProcessMemory(dst_address, process_handle, src_address, size)); } Result UnmapProcessMemory64From32(ams::svc::Address dst_address, ams::svc::Handle process_handle, uint64_t src_address, ams::svc::Size size) { - return UnmapProcessMemory(dst_address, process_handle, src_address, size); + R_RETURN(UnmapProcessMemory(dst_address, process_handle, src_address, size)); } Result MapProcessCodeMemory64From32(ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { - return MapProcessCodeMemory(process_handle, dst_address, src_address, size); + R_RETURN(MapProcessCodeMemory(process_handle, dst_address, src_address, size)); } Result UnmapProcessCodeMemory64From32(ams::svc::Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size) { - return UnmapProcessCodeMemory(process_handle, dst_address, src_address, size); + R_RETURN(UnmapProcessCodeMemory(process_handle, dst_address, src_address, size)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_query_memory.cpp b/libraries/libmesosphere/source/svc/kern_svc_query_memory.cpp index 8fbe98694..555130743 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_query_memory.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_query_memory.cpp @@ -32,7 +32,7 @@ namespace ams::kern::svc { /* Write output. */ *out_memory_info = info.GetSvcMemoryInfo(); - return ResultSuccess(); + R_SUCCEED(); } template @@ -62,14 +62,14 @@ namespace ams::kern::svc { R_TRY(out_memory_info.CopyFrom(std::addressof(converted_info))); } - return ResultSuccess(); + R_SUCCEED(); } template Result QueryMemory(KUserPointer out_memory_info, ams::svc::PageInfo *out_page_info, uintptr_t address) { /* Query memory is just QueryProcessMemory on the current process. */ - return QueryProcessMemory(out_memory_info, out_page_info, ams::svc::PseudoHandle::CurrentProcess, address); + R_RETURN(QueryProcessMemory(out_memory_info, out_page_info, ams::svc::PseudoHandle::CurrentProcess, address)); } } @@ -77,21 +77,21 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result QueryMemory64(KUserPointer out_memory_info, ams::svc::PageInfo *out_page_info, ams::svc::Address address) { - return QueryMemory(out_memory_info, out_page_info, address); + R_RETURN(QueryMemory(out_memory_info, out_page_info, address)); } Result QueryProcessMemory64(KUserPointer out_memory_info, ams::svc::PageInfo *out_page_info, ams::svc::Handle process_handle, uint64_t address) { - return QueryProcessMemory(out_memory_info, out_page_info, process_handle, address); + R_RETURN(QueryProcessMemory(out_memory_info, out_page_info, process_handle, address)); } /* ============================= 64From32 ABI ============================= */ Result QueryMemory64From32(KUserPointer out_memory_info, ams::svc::PageInfo *out_page_info, ams::svc::Address address) { - return QueryMemory(out_memory_info, out_page_info, address); + R_RETURN(QueryMemory(out_memory_info, out_page_info, address)); } Result QueryProcessMemory64From32(KUserPointer out_memory_info, ams::svc::PageInfo *out_page_info, ams::svc::Handle process_handle, uint64_t address) { - return QueryProcessMemory(out_memory_info, out_page_info, process_handle, address); + R_RETURN(QueryProcessMemory(out_memory_info, out_page_info, process_handle, address)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_register.cpp b/libraries/libmesosphere/source/svc/kern_svc_register.cpp index 5a0e57673..f8ab7c0df 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_register.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_register.cpp @@ -26,7 +26,7 @@ namespace ams::kern::svc { *out = 0; /* Read/write the register. */ - return KSystemControl::ReadWriteRegister(out, address, mask, value); + R_RETURN(KSystemControl::ReadWriteRegister(out, address, mask, value)); } } @@ -34,13 +34,13 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result ReadWriteRegister64(uint32_t *out_value, ams::svc::PhysicalAddress address, uint32_t mask, uint32_t value) { - return ReadWriteRegister(out_value, address, mask, value); + R_RETURN(ReadWriteRegister(out_value, address, mask, value)); } /* ============================= 64From32 ABI ============================= */ Result ReadWriteRegister64From32(uint32_t *out_value, ams::svc::PhysicalAddress address, uint32_t mask, uint32_t value) { - return ReadWriteRegister(out_value, address, mask, value); + R_RETURN(ReadWriteRegister(out_value, address, mask, value)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_resource_limit.cpp b/libraries/libmesosphere/source/svc/kern_svc_resource_limit.cpp index 8fa8fec43..cecb37dc4 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_resource_limit.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_resource_limit.cpp @@ -36,7 +36,7 @@ namespace ams::kern::svc { /* Get the limit value. */ *out_limit_value = resource_limit->GetLimitValue(which); - return ResultSuccess(); + R_SUCCEED(); } Result GetResourceLimitCurrentValue(int64_t *out_current_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) { @@ -50,7 +50,7 @@ namespace ams::kern::svc { /* Get the current value. */ *out_current_value = resource_limit->GetCurrentValue(which); - return ResultSuccess(); + R_SUCCEED(); } Result GetResourceLimitPeakValue(int64_t *out_peak_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) { @@ -64,7 +64,7 @@ namespace ams::kern::svc { /* Get the peak value. */ *out_peak_value = resource_limit->GetPeakValue(which); - return ResultSuccess(); + R_SUCCEED(); } Result CreateResourceLimit(ams::svc::Handle *out_handle) { @@ -84,7 +84,7 @@ namespace ams::kern::svc { /* Add the limit to the handle table. */ R_TRY(GetCurrentProcess().GetHandleTable().Add(out_handle, resource_limit)); - return ResultSuccess(); + R_SUCCEED(); } Result SetResourceLimitLimitValue(ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which, int64_t limit_value) { @@ -98,7 +98,7 @@ namespace ams::kern::svc { /* Set the limit value. */ R_TRY(resource_limit->SetLimitValue(which, limit_value)); - return ResultSuccess(); + R_SUCCEED(); } } @@ -106,45 +106,45 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result GetResourceLimitLimitValue64(int64_t *out_limit_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) { - return GetResourceLimitLimitValue(out_limit_value, resource_limit_handle, which); + R_RETURN(GetResourceLimitLimitValue(out_limit_value, resource_limit_handle, which)); } Result GetResourceLimitCurrentValue64(int64_t *out_current_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) { - return GetResourceLimitCurrentValue(out_current_value, resource_limit_handle, which); + R_RETURN(GetResourceLimitCurrentValue(out_current_value, resource_limit_handle, which)); } Result GetResourceLimitPeakValue64(int64_t *out_peak_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) { - return GetResourceLimitPeakValue(out_peak_value, resource_limit_handle, which); + R_RETURN(GetResourceLimitPeakValue(out_peak_value, resource_limit_handle, which)); } Result CreateResourceLimit64(ams::svc::Handle *out_handle) { - return CreateResourceLimit(out_handle); + R_RETURN(CreateResourceLimit(out_handle)); } Result SetResourceLimitLimitValue64(ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which, int64_t limit_value) { - return SetResourceLimitLimitValue(resource_limit_handle, which, limit_value); + R_RETURN(SetResourceLimitLimitValue(resource_limit_handle, which, limit_value)); } /* ============================= 64From32 ABI ============================= */ Result GetResourceLimitLimitValue64From32(int64_t *out_limit_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) { - return GetResourceLimitLimitValue(out_limit_value, resource_limit_handle, which); + R_RETURN(GetResourceLimitLimitValue(out_limit_value, resource_limit_handle, which)); } Result GetResourceLimitCurrentValue64From32(int64_t *out_current_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) { - return GetResourceLimitCurrentValue(out_current_value, resource_limit_handle, which); + R_RETURN(GetResourceLimitCurrentValue(out_current_value, resource_limit_handle, which)); } Result GetResourceLimitPeakValue64From32(int64_t *out_peak_value, ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which) { - return GetResourceLimitPeakValue(out_peak_value, resource_limit_handle, which); + R_RETURN(GetResourceLimitPeakValue(out_peak_value, resource_limit_handle, which)); } Result CreateResourceLimit64From32(ams::svc::Handle *out_handle) { - return CreateResourceLimit(out_handle); + R_RETURN(CreateResourceLimit(out_handle)); } Result SetResourceLimitLimitValue64From32(ams::svc::Handle resource_limit_handle, ams::svc::LimitableResource which, int64_t limit_value) { - return SetResourceLimitLimitValue(resource_limit_handle, which, limit_value); + R_RETURN(SetResourceLimitLimitValue(resource_limit_handle, which, limit_value)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_synchronization.cpp b/libraries/libmesosphere/source/svc/kern_svc_synchronization.cpp index 3da7bcd14..20e025bb5 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_synchronization.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_synchronization.cpp @@ -24,7 +24,7 @@ namespace ams::kern::svc { Result CloseHandle(ams::svc::Handle handle) { /* Remove the handle. */ R_UNLESS(GetCurrentProcess().GetHandleTable().Remove(handle), svc::ResultInvalidHandle()); - return ResultSuccess(); + R_SUCCEED(); } Result ResetSignal(ams::svc::Handle handle) { @@ -36,9 +36,9 @@ namespace ams::kern::svc { KScopedAutoObject readable_event = handle_table.GetObject(handle); if (readable_event.IsNotNull()) { if (auto * const interrupt_event = readable_event->DynamicCast(); interrupt_event != nullptr) { - return interrupt_event->Reset(); + R_RETURN(interrupt_event->Reset()); } else { - return readable_event->Reset(); + R_RETURN(readable_event->Reset()); } } } @@ -47,11 +47,11 @@ namespace ams::kern::svc { { KScopedAutoObject process = handle_table.GetObject(handle); if (process.IsNotNull()) { - return process->Reset(); + R_RETURN(process->Reset()); } } - return svc::ResultInvalidHandle(); + R_THROW(svc::ResultInvalidHandle()); } Result WaitSynchronizationImpl(int32_t *out_index, KSynchronizationObject **objs, int32_t num_handles, int64_t timeout_ns) { @@ -67,7 +67,7 @@ namespace ams::kern::svc { timeout = timeout_ns; } - return KSynchronizationObject::Wait(out_index, objs, num_handles, timeout); + R_RETURN(KSynchronizationObject::Wait(out_index, objs, num_handles, timeout)); } Result WaitSynchronization(int32_t *out_index, KUserPointer user_handles, int32_t num_handles, int64_t timeout_ns) { @@ -103,7 +103,7 @@ namespace ams::kern::svc { R_CONVERT(svc::ResultSessionClosed, ResultSuccess()) } R_END_TRY_CATCH; - return ResultSuccess(); + R_SUCCEED(); } Result CancelSynchronization(ams::svc::Handle handle) { @@ -113,7 +113,7 @@ namespace ams::kern::svc { /* Cancel the thread's wait. */ thread->WaitCancel(); - return ResultSuccess(); + R_SUCCEED(); } void SynchronizePreemptionState() { @@ -136,19 +136,19 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result CloseHandle64(ams::svc::Handle handle) { - return CloseHandle(handle); + R_RETURN(CloseHandle(handle)); } Result ResetSignal64(ams::svc::Handle handle) { - return ResetSignal(handle); + R_RETURN(ResetSignal(handle)); } Result WaitSynchronization64(int32_t *out_index, KUserPointer handles, int32_t num_handles, int64_t timeout_ns) { - return WaitSynchronization(out_index, handles, num_handles, timeout_ns); + R_RETURN(WaitSynchronization(out_index, handles, num_handles, timeout_ns)); } Result CancelSynchronization64(ams::svc::Handle handle) { - return CancelSynchronization(handle); + R_RETURN(CancelSynchronization(handle)); } void SynchronizePreemptionState64() { @@ -158,19 +158,19 @@ namespace ams::kern::svc { /* ============================= 64From32 ABI ============================= */ Result CloseHandle64From32(ams::svc::Handle handle) { - return CloseHandle(handle); + R_RETURN(CloseHandle(handle)); } Result ResetSignal64From32(ams::svc::Handle handle) { - return ResetSignal(handle); + R_RETURN(ResetSignal(handle)); } Result WaitSynchronization64From32(int32_t *out_index, KUserPointer handles, int32_t num_handles, int64_t timeout_ns) { - return WaitSynchronization(out_index, handles, num_handles, timeout_ns); + R_RETURN(WaitSynchronization(out_index, handles, num_handles, timeout_ns)); } Result CancelSynchronization64From32(ams::svc::Handle handle) { - return CancelSynchronization(handle); + R_RETURN(CancelSynchronization(handle)); } void SynchronizePreemptionState64From32() { diff --git a/libraries/libmesosphere/source/svc/kern_svc_thread.cpp b/libraries/libmesosphere/source/svc/kern_svc_thread.cpp index 415b1d743..99c8c37a8 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_thread.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_thread.cpp @@ -66,7 +66,7 @@ namespace ams::kern::svc { /* Add the thread to the handle table. */ R_TRY(process.GetHandleTable().Add(out, thread)); - return ResultSuccess(); + R_SUCCEED(); } Result StartThread(ams::svc::Handle thread_handle) { @@ -75,7 +75,7 @@ namespace ams::kern::svc { R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle()); /* Try to start the thread. */ - return thread->Run(); + R_RETURN(thread->Run()); } void ExitThread() { @@ -121,7 +121,7 @@ namespace ams::kern::svc { /* Get the thread's priority. */ *out_priority = thread->GetPriority(); - return ResultSuccess(); + R_SUCCEED(); } Result SetThreadPriority(ams::svc::Handle thread_handle, int32_t priority) { @@ -141,7 +141,7 @@ namespace ams::kern::svc { /* Set the thread priority. */ thread->SetBasePriority(priority); - return ResultSuccess(); + R_SUCCEED(); } Result GetThreadCoreMask(int32_t *out_core_id, uint64_t *out_affinity_mask, ams::svc::Handle thread_handle) { @@ -152,7 +152,7 @@ namespace ams::kern::svc { /* Get the core mask. */ R_TRY(thread->GetCoreMask(out_core_id, out_affinity_mask)); - return ResultSuccess(); + R_SUCCEED(); } Result SetThreadCoreMask(ams::svc::Handle thread_handle, int32_t core_id, uint64_t affinity_mask) { @@ -184,7 +184,7 @@ namespace ams::kern::svc { /* Set the core mask. */ R_TRY(thread->SetCoreMask(core_id, affinity_mask)); - return ResultSuccess(); + R_SUCCEED(); } Result GetThreadId(uint64_t *out_thread_id, ams::svc::Handle thread_handle) { @@ -194,7 +194,7 @@ namespace ams::kern::svc { /* Get the thread's id. */ *out_thread_id = thread->GetId(); - return ResultSuccess(); + R_SUCCEED(); } Result GetThreadContext3(KUserPointer out_context, ams::svc::Handle thread_handle) { @@ -213,7 +213,7 @@ namespace ams::kern::svc { /* Copy the thread context to user space. */ R_TRY(out_context.CopyFrom(std::addressof(context))); - return ResultSuccess(); + R_SUCCEED(); } Result GetThreadList(int32_t *out_num_threads, KUserPointer out_thread_ids, int32_t max_out_count, ams::svc::Handle debug_handle) { @@ -252,7 +252,7 @@ namespace ams::kern::svc { } } - return ResultSuccess(); + R_SUCCEED(); } } @@ -260,11 +260,11 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result CreateThread64(ams::svc::Handle *out_handle, ams::svc::ThreadFunc func, ams::svc::Address arg, ams::svc::Address stack_bottom, int32_t priority, int32_t core_id) { - return CreateThread(out_handle, func, arg, stack_bottom, priority, core_id); + R_RETURN(CreateThread(out_handle, func, arg, stack_bottom, priority, core_id)); } Result StartThread64(ams::svc::Handle thread_handle) { - return StartThread(thread_handle); + R_RETURN(StartThread(thread_handle)); } void ExitThread64() { @@ -276,41 +276,41 @@ namespace ams::kern::svc { } Result GetThreadPriority64(int32_t *out_priority, ams::svc::Handle thread_handle) { - return GetThreadPriority(out_priority, thread_handle); + R_RETURN(GetThreadPriority(out_priority, thread_handle)); } Result SetThreadPriority64(ams::svc::Handle thread_handle, int32_t priority) { - return SetThreadPriority(thread_handle, priority); + R_RETURN(SetThreadPriority(thread_handle, priority)); } Result GetThreadCoreMask64(int32_t *out_core_id, uint64_t *out_affinity_mask, ams::svc::Handle thread_handle) { - return GetThreadCoreMask(out_core_id, out_affinity_mask, thread_handle); + R_RETURN(GetThreadCoreMask(out_core_id, out_affinity_mask, thread_handle)); } Result SetThreadCoreMask64(ams::svc::Handle thread_handle, int32_t core_id, uint64_t affinity_mask) { - return SetThreadCoreMask(thread_handle, core_id, affinity_mask); + R_RETURN(SetThreadCoreMask(thread_handle, core_id, affinity_mask)); } Result GetThreadId64(uint64_t *out_thread_id, ams::svc::Handle thread_handle) { - return GetThreadId(out_thread_id, thread_handle); + R_RETURN(GetThreadId(out_thread_id, thread_handle)); } Result GetThreadContext364(KUserPointer out_context, ams::svc::Handle thread_handle) { - return GetThreadContext3(out_context, thread_handle); + R_RETURN(GetThreadContext3(out_context, thread_handle)); } Result GetThreadList64(int32_t *out_num_threads, KUserPointer out_thread_ids, int32_t max_out_count, ams::svc::Handle debug_handle) { - return GetThreadList(out_num_threads, out_thread_ids, max_out_count, debug_handle); + R_RETURN(GetThreadList(out_num_threads, out_thread_ids, max_out_count, debug_handle)); } /* ============================= 64From32 ABI ============================= */ Result CreateThread64From32(ams::svc::Handle *out_handle, ams::svc::ThreadFunc func, ams::svc::Address arg, ams::svc::Address stack_bottom, int32_t priority, int32_t core_id) { - return CreateThread(out_handle, func, arg, stack_bottom, priority, core_id); + R_RETURN(CreateThread(out_handle, func, arg, stack_bottom, priority, core_id)); } Result StartThread64From32(ams::svc::Handle thread_handle) { - return StartThread(thread_handle); + R_RETURN(StartThread(thread_handle)); } void ExitThread64From32() { @@ -322,31 +322,31 @@ namespace ams::kern::svc { } Result GetThreadPriority64From32(int32_t *out_priority, ams::svc::Handle thread_handle) { - return GetThreadPriority(out_priority, thread_handle); + R_RETURN(GetThreadPriority(out_priority, thread_handle)); } Result SetThreadPriority64From32(ams::svc::Handle thread_handle, int32_t priority) { - return SetThreadPriority(thread_handle, priority); + R_RETURN(SetThreadPriority(thread_handle, priority)); } Result GetThreadCoreMask64From32(int32_t *out_core_id, uint64_t *out_affinity_mask, ams::svc::Handle thread_handle) { - return GetThreadCoreMask(out_core_id, out_affinity_mask, thread_handle); + R_RETURN(GetThreadCoreMask(out_core_id, out_affinity_mask, thread_handle)); } Result SetThreadCoreMask64From32(ams::svc::Handle thread_handle, int32_t core_id, uint64_t affinity_mask) { - return SetThreadCoreMask(thread_handle, core_id, affinity_mask); + R_RETURN(SetThreadCoreMask(thread_handle, core_id, affinity_mask)); } Result GetThreadId64From32(uint64_t *out_thread_id, ams::svc::Handle thread_handle) { - return GetThreadId(out_thread_id, thread_handle); + R_RETURN(GetThreadId(out_thread_id, thread_handle)); } Result GetThreadContext364From32(KUserPointer out_context, ams::svc::Handle thread_handle) { - return GetThreadContext3(out_context, thread_handle); + R_RETURN(GetThreadContext3(out_context, thread_handle)); } Result GetThreadList64From32(int32_t *out_num_threads, KUserPointer out_thread_ids, int32_t max_out_count, ams::svc::Handle debug_handle) { - return GetThreadList(out_num_threads, out_thread_ids, max_out_count, debug_handle); + R_RETURN(GetThreadList(out_num_threads, out_thread_ids, max_out_count, debug_handle)); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_thread_profiler.cpp b/libraries/libmesosphere/source/svc/kern_svc_thread_profiler.cpp index 6e21ad1af..02264e420 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_thread_profiler.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_thread_profiler.cpp @@ -46,7 +46,7 @@ namespace ams::kern::svc { *out_flags |= ams::svc::LastThreadInfoFlag_ThreadInSystemCall; } - return ResultSuccess(); + R_SUCCEED(); } Result SynchronizeCurrentProcessToFutureTime(int64_t ns) { @@ -68,7 +68,7 @@ namespace ams::kern::svc { /* Synchronize to the desired time. */ R_TRY(wait_object->Synchronize(timeout)); - return ResultSuccess(); + R_SUCCEED(); } Result GetDebugFutureThreadInfo(ams::svc::LastThreadContext *out_context, uint64_t *out_thread_id, ams::svc::Handle debug_handle, int64_t ns) { @@ -85,7 +85,7 @@ namespace ams::kern::svc { /* Get the running thread info. */ R_TRY(debug->GetRunningThreadInfo(out_context, out_thread_id)); - return ResultSuccess(); + R_SUCCEED(); } Result LegacyGetFutureThreadInfo(ams::svc::LastThreadContext *out_context, uintptr_t *out_tls_address, uint32_t *out_flags, int64_t ns) { @@ -98,7 +98,7 @@ namespace ams::kern::svc { /* Get the thread info. */ R_TRY(GetLastThreadInfoImpl(out_context, out_tls_address, out_flags)); - return ResultSuccess(); + R_SUCCEED(); } Result GetLastThreadInfo(ams::svc::LastThreadContext *out_context, uintptr_t *out_tls_address, uint32_t *out_flags) { @@ -108,7 +108,7 @@ namespace ams::kern::svc { /* Get the thread info. */ R_TRY(GetLastThreadInfoImpl(out_context, out_tls_address, out_flags)); - return ResultSuccess(); + R_SUCCEED(); } } @@ -116,16 +116,16 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result GetDebugFutureThreadInfo64(ams::svc::lp64::LastThreadContext *out_context, uint64_t *out_thread_id, ams::svc::Handle debug_handle, int64_t ns) { - return GetDebugFutureThreadInfo(out_context, out_thread_id, debug_handle, ns); + R_RETURN(GetDebugFutureThreadInfo(out_context, out_thread_id, debug_handle, ns)); } Result LegacyGetFutureThreadInfo64(ams::svc::lp64::LastThreadContext *out_context, ams::svc::Address *out_tls_address, uint32_t *out_flags, int64_t ns) { - return LegacyGetFutureThreadInfo(out_context, reinterpret_cast(out_tls_address), out_flags, ns); + R_RETURN(LegacyGetFutureThreadInfo(out_context, reinterpret_cast(out_tls_address), out_flags, ns)); } Result GetLastThreadInfo64(ams::svc::lp64::LastThreadContext *out_context, ams::svc::Address *out_tls_address, uint32_t *out_flags) { static_assert(sizeof(*out_tls_address) == sizeof(uintptr_t)); - return GetLastThreadInfo(out_context, reinterpret_cast(out_tls_address), out_flags); + R_RETURN(GetLastThreadInfo(out_context, reinterpret_cast(out_tls_address), out_flags)); } /* ============================= 64From32 ABI ============================= */ @@ -140,7 +140,7 @@ namespace ams::kern::svc { .lr = static_cast(context.lr), .pc = static_cast(context.pc), }; - return ResultSuccess(); + R_SUCCEED(); } Result LegacyGetFutureThreadInfo64From32(ams::svc::ilp32::LastThreadContext *out_context, ams::svc::Address *out_tls_address, uint32_t *out_flags, int64_t ns) { @@ -155,7 +155,7 @@ namespace ams::kern::svc { .lr = static_cast(context.lr), .pc = static_cast(context.pc), }; - return ResultSuccess(); + R_SUCCEED(); } Result GetLastThreadInfo64From32(ams::svc::ilp32::LastThreadContext *out_context, ams::svc::Address *out_tls_address, uint32_t *out_flags) { @@ -170,7 +170,7 @@ namespace ams::kern::svc { .lr = static_cast(context.lr), .pc = static_cast(context.pc), }; - return ResultSuccess(); + R_SUCCEED(); } } diff --git a/libraries/libmesosphere/source/svc/kern_svc_transfer_memory.cpp b/libraries/libmesosphere/source/svc/kern_svc_transfer_memory.cpp index 7e5bf7c20..99f8b4744 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_transfer_memory.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_transfer_memory.cpp @@ -53,7 +53,7 @@ namespace ams::kern::svc { R_TRY(trmem->Map(address, size, map_perm)); /* We succeeded. */ - return ResultSuccess(); + R_SUCCEED(); } Result UnmapTransferMemory(ams::svc::Handle trmem_handle, uintptr_t address, size_t size) { @@ -73,7 +73,7 @@ namespace ams::kern::svc { /* Unmap the transfer memory. */ R_TRY(trmem->Unmap(address, size)); - return ResultSuccess(); + R_SUCCEED(); } Result CreateTransferMemory(ams::svc::Handle *out, uintptr_t address, size_t size, ams::svc::MemoryPermission map_perm) { @@ -116,7 +116,7 @@ namespace ams::kern::svc { /* Add the transfer memory to the handle table. */ R_TRY(handle_table.Add(out, trmem)); - return ResultSuccess(); + R_SUCCEED(); } } @@ -124,29 +124,29 @@ namespace ams::kern::svc { /* ============================= 64 ABI ============================= */ Result MapTransferMemory64(ams::svc::Handle trmem_handle, ams::svc::Address address, ams::svc::Size size, ams::svc::MemoryPermission owner_perm) { - return MapTransferMemory(trmem_handle, address, size, owner_perm); + R_RETURN(MapTransferMemory(trmem_handle, address, size, owner_perm)); } Result UnmapTransferMemory64(ams::svc::Handle trmem_handle, ams::svc::Address address, ams::svc::Size size) { - return UnmapTransferMemory(trmem_handle, address, size); + R_RETURN(UnmapTransferMemory(trmem_handle, address, size)); } Result CreateTransferMemory64(ams::svc::Handle *out_handle, ams::svc::Address address, ams::svc::Size size, ams::svc::MemoryPermission map_perm) { - return CreateTransferMemory(out_handle, address, size, map_perm); + R_RETURN(CreateTransferMemory(out_handle, address, size, map_perm)); } /* ============================= 64From32 ABI ============================= */ Result MapTransferMemory64From32(ams::svc::Handle trmem_handle, ams::svc::Address address, ams::svc::Size size, ams::svc::MemoryPermission owner_perm) { - return MapTransferMemory(trmem_handle, address, size, owner_perm); + R_RETURN(MapTransferMemory(trmem_handle, address, size, owner_perm)); } Result UnmapTransferMemory64From32(ams::svc::Handle trmem_handle, ams::svc::Address address, ams::svc::Size size) { - return UnmapTransferMemory(trmem_handle, address, size); + R_RETURN(UnmapTransferMemory(trmem_handle, address, size)); } Result CreateTransferMemory64From32(ams::svc::Handle *out_handle, ams::svc::Address address, ams::svc::Size size, ams::svc::MemoryPermission map_perm) { - return CreateTransferMemory(out_handle, address, size, map_perm); + R_RETURN(CreateTransferMemory(out_handle, address, size, map_perm)); } }