diff options
Diffstat (limited to 'src')
57 files changed, 881 insertions, 487 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6b6efbc00..2e2de59b1 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -10,6 +10,8 @@ add_library(core STATIC core_cpu.h core_timing.cpp core_timing.h + core_timing_util.cpp + core_timing_util.h file_sys/content_archive.cpp file_sys/content_archive.h file_sys/control_metadata.cpp @@ -114,26 +116,32 @@ add_library(core STATIC hle/service/apm/apm.h hle/service/apm/interface.cpp hle/service/apm/interface.h - hle/service/audio/audio.cpp - hle/service/audio/audio.h hle/service/audio/audin_u.cpp hle/service/audio/audin_u.h + hle/service/audio/audio.cpp + hle/service/audio/audio.h hle/service/audio/audout_u.cpp hle/service/audio/audout_u.h hle/service/audio/audrec_u.cpp hle/service/audio/audrec_u.h hle/service/audio/audren_u.cpp - hle/service/audio/audren_u.h hle/service/audio/audren_u.cpp hle/service/audio/audren_u.h + hle/service/audio/audren_u.h hle/service/audio/codecctl.cpp hle/service/audio/codecctl.h hle/service/audio/hwopus.cpp hle/service/audio/hwopus.h - hle/service/bcat/module.cpp - hle/service/bcat/module.h hle/service/bcat/bcat.cpp hle/service/bcat/bcat.h + hle/service/bcat/module.cpp + hle/service/bcat/module.h + hle/service/erpt/erpt.cpp + hle/service/erpt/erpt.h + hle/service/es/es.cpp + hle/service/es/es.h + hle/service/eupld/eupld.cpp + hle/service/eupld/eupld.h hle/service/fatal/fatal.cpp hle/service/fatal/fatal.h hle/service/fatal/fatal_p.cpp @@ -146,28 +154,22 @@ add_library(core STATIC hle/service/filesystem/fsp_srv.h hle/service/friend/friend.cpp hle/service/friend/friend.h - hle/service/friend/friend_a.cpp - hle/service/friend/friend_a.h - hle/service/friend/friend_u.cpp - hle/service/friend/friend_u.h + hle/service/friend/interface.cpp + hle/service/friend/interface.h hle/service/hid/hid.cpp hle/service/hid/hid.h + hle/service/ldr/ldr.cpp + hle/service/ldr/ldr.h hle/service/lm/lm.cpp hle/service/lm/lm.h hle/service/mm/mm_u.cpp hle/service/mm/mm_u.h - hle/service/nifm/nifm.cpp - hle/service/nifm/nifm.h - hle/service/nifm/nifm_a.cpp - hle/service/nifm/nifm_a.h - hle/service/nifm/nifm_s.cpp - hle/service/nifm/nifm_s.h - hle/service/nifm/nifm_u.cpp - hle/service/nifm/nifm_u.h hle/service/nfp/nfp.cpp hle/service/nfp/nfp.h hle/service/nfp/nfp_user.cpp hle/service/nfp/nfp_user.h + hle/service/nifm/nifm.cpp + hle/service/nifm/nifm.h hle/service/ns/ns.cpp hle/service/ns/ns.h hle/service/ns/pl_u.cpp @@ -201,6 +203,8 @@ add_library(core STATIC hle/service/pctl/module.h hle/service/pctl/pctl.cpp hle/service/pctl/pctl.h + hle/service/pm/pm.cpp + hle/service/pm/pm.h hle/service/prepo/prepo.cpp hle/service/prepo/prepo.h hle/service/service.cpp @@ -235,12 +239,10 @@ add_library(core STATIC hle/service/spl/spl.h hle/service/ssl/ssl.cpp hle/service/ssl/ssl.h + hle/service/time/interface.cpp + hle/service/time/interface.h hle/service/time/time.cpp hle/service/time/time.h - hle/service/time/time_s.cpp - hle/service/time/time_s.h - hle/service/time/time_u.cpp - hle/service/time/time_u.h hle/service/vi/vi.cpp hle/service/vi/vi.h hle/service/vi/vi_m.cpp diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 50d1e3fc9..a1b6f96f1 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -5,17 +5,15 @@ #include "core/core_timing.h" #include <algorithm> -#include <cinttypes> -#include <limits> #include <mutex> #include <string> #include <tuple> #include <unordered_map> #include <vector> #include "common/assert.h" -#include "common/logging/log.h" #include "common/thread.h" #include "common/threadsafe_queue.h" +#include "core/core_timing_util.h" namespace CoreTiming { @@ -59,7 +57,6 @@ static u64 event_fifo_id; static Common::MPSCQueue<Event, false> ts_queue; constexpr int MAX_SLICE_LENGTH = 20000; -constexpr u64 MAX_VALUE_TO_MULTIPLY = std::numeric_limits<s64>::max() / BASE_CLOCK_RATE; static s64 idled_cycles; @@ -72,54 +69,6 @@ static EventType* ev_lost = nullptr; static void EmptyTimedCallback(u64 userdata, s64 cyclesLate) {} -s64 usToCycles(s64 us) { - if (us / 1000000 > MAX_VALUE_TO_MULTIPLY) { - LOG_ERROR(Core_Timing, "Integer overflow, use max value"); - return std::numeric_limits<s64>::max(); - } - if (us > MAX_VALUE_TO_MULTIPLY) { - LOG_DEBUG(Core_Timing, "Time very big, do rounding"); - return BASE_CLOCK_RATE * (us / 1000000); - } - return (BASE_CLOCK_RATE * us) / 1000000; -} - -s64 usToCycles(u64 us) { - if (us / 1000000 > MAX_VALUE_TO_MULTIPLY) { - LOG_ERROR(Core_Timing, "Integer overflow, use max value"); - return std::numeric_limits<s64>::max(); - } - if (us > MAX_VALUE_TO_MULTIPLY) { - LOG_DEBUG(Core_Timing, "Time very big, do rounding"); - return BASE_CLOCK_RATE * static_cast<s64>(us / 1000000); - } - return (BASE_CLOCK_RATE * static_cast<s64>(us)) / 1000000; -} - -s64 nsToCycles(s64 ns) { - if (ns / 1000000000 > MAX_VALUE_TO_MULTIPLY) { - LOG_ERROR(Core_Timing, "Integer overflow, use max value"); - return std::numeric_limits<s64>::max(); - } - if (ns > MAX_VALUE_TO_MULTIPLY) { - LOG_DEBUG(Core_Timing, "Time very big, do rounding"); - return BASE_CLOCK_RATE * (ns / 1000000000); - } - return (BASE_CLOCK_RATE * ns) / 1000000000; -} - -s64 nsToCycles(u64 ns) { - if (ns / 1000000000 > MAX_VALUE_TO_MULTIPLY) { - LOG_ERROR(Core_Timing, "Integer overflow, use max value"); - return std::numeric_limits<s64>::max(); - } - if (ns > MAX_VALUE_TO_MULTIPLY) { - LOG_DEBUG(Core_Timing, "Time very big, do rounding"); - return BASE_CLOCK_RATE * (static_cast<s64>(ns) / 1000000000); - } - return (BASE_CLOCK_RATE * static_cast<s64>(ns)) / 1000000000; -} - EventType* RegisterEvent(const std::string& name, TimedCallback callback) { // check for existing type with same name. // we want event type names to remain unique so that we can use them for serialization. diff --git a/src/core/core_timing.h b/src/core/core_timing.h index dc31124a8..7fe6380ad 100644 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h @@ -23,59 +23,6 @@ namespace CoreTiming { -// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz -// The exact value used is of course unverified. -constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked - -inline s64 msToCycles(int ms) { - // since ms is int there is no way to overflow - return BASE_CLOCK_RATE * static_cast<s64>(ms) / 1000; -} - -inline s64 msToCycles(float ms) { - return static_cast<s64>(BASE_CLOCK_RATE * (0.001f) * ms); -} - -inline s64 msToCycles(double ms) { - return static_cast<s64>(BASE_CLOCK_RATE * (0.001) * ms); -} - -inline s64 usToCycles(float us) { - return static_cast<s64>(BASE_CLOCK_RATE * (0.000001f) * us); -} - -inline s64 usToCycles(int us) { - return (BASE_CLOCK_RATE * static_cast<s64>(us) / 1000000); -} - -s64 usToCycles(s64 us); - -s64 usToCycles(u64 us); - -inline s64 nsToCycles(float ns) { - return static_cast<s64>(BASE_CLOCK_RATE * (0.000000001f) * ns); -} - -inline s64 nsToCycles(int ns) { - return BASE_CLOCK_RATE * static_cast<s64>(ns) / 1000000000; -} - -s64 nsToCycles(s64 ns); - -s64 nsToCycles(u64 ns); - -inline u64 cyclesToNs(s64 cycles) { - return cycles * 1000000000 / BASE_CLOCK_RATE; -} - -inline s64 cyclesToUs(s64 cycles) { - return cycles * 1000000 / BASE_CLOCK_RATE; -} - -inline u64 cyclesToMs(s64 cycles) { - return cycles * 1000 / BASE_CLOCK_RATE; -} - /** * CoreTiming begins at the boundary of timing slice -1. An initial call to Advance() is * required to end slice -1 and start slice 0 before the first cycle of code is executed. diff --git a/src/core/core_timing_util.cpp b/src/core/core_timing_util.cpp new file mode 100644 index 000000000..73dea4edb --- /dev/null +++ b/src/core/core_timing_util.cpp @@ -0,0 +1,63 @@ +// Copyright 2008 Dolphin Emulator Project / 2017 Citra Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "core/core_timing_util.h" + +#include <cinttypes> +#include <limits> +#include "common/logging/log.h" + +namespace CoreTiming { + +constexpr u64 MAX_VALUE_TO_MULTIPLY = std::numeric_limits<s64>::max() / BASE_CLOCK_RATE; + +s64 usToCycles(s64 us) { + if (us / 1000000 > MAX_VALUE_TO_MULTIPLY) { + LOG_ERROR(Core_Timing, "Integer overflow, use max value"); + return std::numeric_limits<s64>::max(); + } + if (us > MAX_VALUE_TO_MULTIPLY) { + LOG_DEBUG(Core_Timing, "Time very big, do rounding"); + return BASE_CLOCK_RATE * (us / 1000000); + } + return (BASE_CLOCK_RATE * us) / 1000000; +} + +s64 usToCycles(u64 us) { + if (us / 1000000 > MAX_VALUE_TO_MULTIPLY) { + LOG_ERROR(Core_Timing, "Integer overflow, use max value"); + return std::numeric_limits<s64>::max(); + } + if (us > MAX_VALUE_TO_MULTIPLY) { + LOG_DEBUG(Core_Timing, "Time very big, do rounding"); + return BASE_CLOCK_RATE * static_cast<s64>(us / 1000000); + } + return (BASE_CLOCK_RATE * static_cast<s64>(us)) / 1000000; +} + +s64 nsToCycles(s64 ns) { + if (ns / 1000000000 > MAX_VALUE_TO_MULTIPLY) { + LOG_ERROR(Core_Timing, "Integer overflow, use max value"); + return std::numeric_limits<s64>::max(); + } + if (ns > MAX_VALUE_TO_MULTIPLY) { + LOG_DEBUG(Core_Timing, "Time very big, do rounding"); + return BASE_CLOCK_RATE * (ns / 1000000000); + } + return (BASE_CLOCK_RATE * ns) / 1000000000; +} + +s64 nsToCycles(u64 ns) { + if (ns / 1000000000 > MAX_VALUE_TO_MULTIPLY) { + LOG_ERROR(Core_Timing, "Integer overflow, use max value"); + return std::numeric_limits<s64>::max(); + } + if (ns > MAX_VALUE_TO_MULTIPLY) { + LOG_DEBUG(Core_Timing, "Time very big, do rounding"); + return BASE_CLOCK_RATE * (static_cast<s64>(ns) / 1000000000); + } + return (BASE_CLOCK_RATE * static_cast<s64>(ns)) / 1000000000; +} + +} // namespace CoreTiming diff --git a/src/core/core_timing_util.h b/src/core/core_timing_util.h new file mode 100644 index 000000000..5c3718782 --- /dev/null +++ b/src/core/core_timing_util.h @@ -0,0 +1,64 @@ +// Copyright 2008 Dolphin Emulator Project / 2017 Citra Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "common/common_types.h" + +namespace CoreTiming { + +// The below clock rate is based on Switch's clockspeed being widely known as 1.020GHz +// The exact value used is of course unverified. +constexpr u64 BASE_CLOCK_RATE = 1019215872; // Switch clock speed is 1020MHz un/docked + +inline s64 msToCycles(int ms) { + // since ms is int there is no way to overflow + return BASE_CLOCK_RATE * static_cast<s64>(ms) / 1000; +} + +inline s64 msToCycles(float ms) { + return static_cast<s64>(BASE_CLOCK_RATE * (0.001f) * ms); +} + +inline s64 msToCycles(double ms) { + return static_cast<s64>(BASE_CLOCK_RATE * (0.001) * ms); +} + +inline s64 usToCycles(float us) { + return static_cast<s64>(BASE_CLOCK_RATE * (0.000001f) * us); +} + +inline s64 usToCycles(int us) { + return (BASE_CLOCK_RATE * static_cast<s64>(us) / 1000000); +} + +s64 usToCycles(s64 us); + +s64 usToCycles(u64 us); + +inline s64 nsToCycles(float ns) { + return static_cast<s64>(BASE_CLOCK_RATE * (0.000000001f) * ns); +} + +inline s64 nsToCycles(int ns) { + return BASE_CLOCK_RATE * static_cast<s64>(ns) / 1000000000; +} + +s64 nsToCycles(s64 ns); + +s64 nsToCycles(u64 ns); + +inline u64 cyclesToNs(s64 cycles) { + return cycles * 1000000000 / BASE_CLOCK_RATE; +} + +inline s64 cyclesToUs(s64 cycles) { + return cycles * 1000000 / BASE_CLOCK_RATE; +} + +inline u64 cyclesToMs(s64 cycles) { + return cycles * 1000 / BASE_CLOCK_RATE; +} + +} // namespace CoreTiming diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index f5bd27a75..7fb0da408 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -300,6 +300,14 @@ public: template <typename First, typename... Other> void Pop(First& first_value, Other&... other_values); + template <typename T> + T PopEnum() { + static_assert(std::is_enum_v<T>, "T must be an enum type within a PopEnum call."); + static_assert(!std::is_convertible_v<T, int>, + "enum type in PopEnum must be a strongly typed enum."); + return static_cast<T>(Pop<std::underlying_type_t<T>>()); + } + /** * @brief Reads the next normal parameters as a struct, by copying it * @note: The output class must be correctly packed/padded to fit hardware layout. diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 7b41c9cfd..0b439401a 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -40,7 +40,9 @@ static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { } static ResultCode SetMemoryAttribute(VAddr addr, u64 size, u32 state0, u32 state1) { - LOG_WARNING(Kernel_SVC, "(STUBBED) called, addr=0x{:X}", addr); + LOG_WARNING(Kernel_SVC, + "(STUBBED) called, addr=0x{:X}, size=0x{:X}, state0=0x{:X}, state1=0x{:X}", addr, + size, state0, state1); return RESULT_SUCCESS; } @@ -165,11 +167,14 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 using ObjectPtr = SharedPtr<WaitObject>; std::vector<ObjectPtr> objects(handle_count); - for (int i = 0; i < handle_count; ++i) { - Handle handle = Memory::Read32(handles_address + i * sizeof(Handle)); - auto object = g_handle_table.Get<WaitObject>(handle); - if (object == nullptr) + for (u64 i = 0; i < handle_count; ++i) { + const Handle handle = Memory::Read32(handles_address + i * sizeof(Handle)); + const auto object = g_handle_table.Get<WaitObject>(handle); + + if (object == nullptr) { return ERR_INVALID_HANDLE; + } + objects[i] = object; } diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index cd85c4b7c..94735c86e 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -14,6 +14,7 @@ #include "core/arm/arm_interface.h" #include "core/core.h" #include "core/core_timing.h" +#include "core/core_timing_util.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/kernel.h" diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 0141125e4..904a3d0a5 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -6,6 +6,7 @@ #include "common/assert.h" #include "common/logging/log.h" #include "core/core_timing.h" +#include "core/core_timing_util.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/thread.h" diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 154bc12da..1dcd84d98 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -6,6 +6,7 @@ #include <vector> #include "common/logging/log.h" #include "core/core_timing.h" +#include "core/core_timing_util.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/hle_ipc.h" diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index e623f4f8e..6aed9e2fa 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -7,6 +7,7 @@ #include "common/alignment.h" #include "common/logging/log.h" #include "core/core_timing.h" +#include "core/core_timing_util.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/hle_ipc.h" diff --git a/src/core/hle/service/erpt/erpt.cpp b/src/core/hle/service/erpt/erpt.cpp new file mode 100644 index 000000000..ee11cd78e --- /dev/null +++ b/src/core/hle/service/erpt/erpt.cpp @@ -0,0 +1,51 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <memory> + +#include "core/hle/service/erpt/erpt.h" +#include "core/hle/service/service.h" +#include "core/hle/service/sm/sm.h" + +namespace Service::ERPT { + +class ErrorReportContext final : public ServiceFramework<ErrorReportContext> { +public: + explicit ErrorReportContext() : ServiceFramework{"erpt:c"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "SubmitContext"}, + {1, nullptr, "CreateReport"}, + {2, nullptr, "Unknown1"}, + {3, nullptr, "Unknown2"}, + {4, nullptr, "Unknown3"}, + {5, nullptr, "Unknown4"}, + {6, nullptr, "Unknown5"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class ErrorReportSession final : public ServiceFramework<ErrorReportSession> { +public: + explicit ErrorReportSession() : ServiceFramework{"erpt:r"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "OpenReport"}, + {1, nullptr, "OpenManager"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<ErrorReportContext>()->InstallAsService(sm); + std::make_shared<ErrorReportSession>()->InstallAsService(sm); +} + +} // namespace Service::ERPT diff --git a/src/core/hle/service/erpt/erpt.h b/src/core/hle/service/erpt/erpt.h new file mode 100644 index 000000000..de439ab6d --- /dev/null +++ b/src/core/hle/service/erpt/erpt.h @@ -0,0 +1,16 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace Service::SM { +class ServiceManager; +} + +namespace Service::ERPT { + +/// Registers all ERPT services with the specified service manager. +void InstallInterfaces(SM::ServiceManager& sm); + +} // namespace Service::ERPT diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp new file mode 100644 index 000000000..d40f18565 --- /dev/null +++ b/src/core/hle/service/es/es.cpp @@ -0,0 +1,57 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/service/service.h" + +namespace Service::ES { + +class ETicket final : public ServiceFramework<ETicket> { +public: + explicit ETicket() : ServiceFramework{"es"} { + static const FunctionInfo functions[] = { + {1, nullptr, "ImportTicket"}, + {2, nullptr, "ImportTicketCertificateSet"}, + {3, nullptr, "DeleteTicket"}, + {4, nullptr, "DeletePersonalizedTicket"}, + {5, nullptr, "DeleteAllCommonTicket"}, + {6, nullptr, "DeleteAllPersonalizedTicket"}, + {7, nullptr, "DeleteAllPersonalizedTicketEx"}, + {8, nullptr, "GetTitleKey"}, + {9, nullptr, "CountCommonTicket"}, + {10, nullptr, "CountPersonalizedTicket"}, + {11, nullptr, "ListCommonTicket"}, + {12, nullptr, "ListPersonalizedTicket"}, + {13, nullptr, "ListMissingPersonalizedTicket"}, + {14, nullptr, "GetCommonTicketSize"}, + {15, nullptr, "GetPersonalizedTicketSize"}, + {16, nullptr, "GetCommonTicketData"}, + {17, nullptr, "GetPersonalizedTicketData"}, + {18, nullptr, "OwnTicket"}, + {19, nullptr, "GetTicketInfo"}, + {20, nullptr, "ListLightTicketInfo"}, + {21, nullptr, "SignData"}, + {22, nullptr, "GetCommonTicketAndCertificateSize"}, + {23, nullptr, "GetCommonTicketAndCertificateData"}, + {24, nullptr, "ImportPrepurchaseRecord"}, + {25, nullptr, "DeletePrepurchaseRecord"}, + {26, nullptr, "DeleteAllPrepurchaseRecord"}, + {27, nullptr, "CountPrepurchaseRecord"}, + {28, nullptr, "ListPrepurchaseRecord"}, + {29, nullptr, "ListPrepurchaseRecordInfo"}, + {30, nullptr, "Unknown1"}, + {31, nullptr, "Unknown2"}, + {32, nullptr, "Unknown3"}, + {33, nullptr, "Unknown4"}, + {34, nullptr, "Unknown5"}, + {35, nullptr, "Unknown6"}, + }; + RegisterHandlers(functions); + } +}; + +void InstallInterfaces(SM::ServiceManager& service_manager) { + std::make_shared<ETicket>()->InstallAsService(service_manager); +} + +} // namespace Service::ES diff --git a/src/core/hle/service/es/es.h b/src/core/hle/service/es/es.h new file mode 100644 index 000000000..afe70465b --- /dev/null +++ b/src/core/hle/service/es/es.h @@ -0,0 +1,16 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace Service::SM { +class ServiceManager; +} + +namespace Service::ES { + +/// Registers all ES services with the specified service manager. +void InstallInterfaces(SM::ServiceManager& service_manager); + +} // namespace Service::ES diff --git a/src/core/hle/service/eupld/eupld.cpp b/src/core/hle/service/eupld/eupld.cpp new file mode 100644 index 000000000..2df30acee --- /dev/null +++ b/src/core/hle/service/eupld/eupld.cpp @@ -0,0 +1,52 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <memory> + +#include "core/hle/service/eupld/eupld.h" +#include "core/hle/service/service.h" +#include "core/hle/service/sm/sm.h" + +namespace Service::EUPLD { + +class ErrorUploadContext final : public ServiceFramework<ErrorUploadContext> { +public: + explicit ErrorUploadContext() : ServiceFramework{"eupld:c"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "SetUrl"}, + {1, nullptr, "ImportCrt"}, + {2, nullptr, "ImportPki"}, + {3, nullptr, "SetAutoUpload"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class ErrorUploadRequest final : public ServiceFramework<ErrorUploadRequest> { +public: + explicit ErrorUploadRequest() : ServiceFramework{"eupld:r"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "Initialize"}, + {1, nullptr, "UploadAll"}, + {2, nullptr, "UploadSelected"}, + {3, nullptr, "GetUploadStatus"}, + {4, nullptr, "CancelUpload"}, + {5, nullptr, "GetResult"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<ErrorUploadContext>()->InstallAsService(sm); + std::make_shared<ErrorUploadRequest>()->InstallAsService(sm); +} + +} // namespace Service::EUPLD diff --git a/src/core/hle/service/eupld/eupld.h b/src/core/hle/service/eupld/eupld.h new file mode 100644 index 000000000..6eef2c15f --- /dev/null +++ b/src/core/hle/service/eupld/eupld.h @@ -0,0 +1,16 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace Service::SM { +class ServiceManager; +} + +namespace Service::EUPLD { + +/// Registers all EUPLD services with the specified service manager. +void InstallInterfaces(SM::ServiceManager& sm); + +} // namespace Service::EUPLD diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index c98a46e05..fb4d89068 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -5,8 +5,7 @@ #include "common/logging/log.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/friend/friend.h" -#include "core/hle/service/friend/friend_a.h" -#include "core/hle/service/friend/friend_u.h" +#include "core/hle/service/friend/interface.h" namespace Service::Friend { @@ -21,8 +20,11 @@ Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) void InstallInterfaces(SM::ServiceManager& service_manager) { auto module = std::make_shared<Module>(); - std::make_shared<Friend_A>(module)->InstallAsService(service_manager); - std::make_shared<Friend_U>(module)->InstallAsService(service_manager); + std::make_shared<Friend>(module, "friend:a")->InstallAsService(service_manager); + std::make_shared<Friend>(module, "friend:m")->InstallAsService(service_manager); + std::make_shared<Friend>(module, "friend:s")->InstallAsService(service_manager); + std::make_shared<Friend>(module, "friend:u")->InstallAsService(service_manager); + std::make_shared<Friend>(module, "friend:v")->InstallAsService(service_manager); } } // namespace Service::Friend diff --git a/src/core/hle/service/friend/friend_u.cpp b/src/core/hle/service/friend/friend_u.cpp deleted file mode 100644 index 90b30883f..000000000 --- a/src/core/hle/service/friend/friend_u.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/friend/friend_u.h" - -namespace Service::Friend { - -Friend_U::Friend_U(std::shared_ptr<Module> module) - : Module::Interface(std::move(module), "friend:u") { - static const FunctionInfo functions[] = { - {0, &Friend_U::CreateFriendService, "CreateFriendService"}, - {1, nullptr, "CreateNotificationService"}, - }; - RegisterHandlers(functions); -} - -} // namespace Service::Friend diff --git a/src/core/hle/service/friend/friend_u.h b/src/core/hle/service/friend/friend_u.h deleted file mode 100644 index 0d953d807..000000000 --- a/src/core/hle/service/friend/friend_u.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "core/hle/service/friend/friend.h" - -namespace Service::Friend { - -class Friend_U final : public Module::Interface { -public: - explicit Friend_U(std::shared_ptr<Module> module); -}; - -} // namespace Service::Friend diff --git a/src/core/hle/service/friend/friend_a.cpp b/src/core/hle/service/friend/interface.cpp index a2cc81926..27c6a09e2 100644 --- a/src/core/hle/service/friend/friend_a.cpp +++ b/src/core/hle/service/friend/interface.cpp @@ -2,15 +2,16 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "core/hle/service/friend/friend_a.h" +#include "core/hle/service/friend/interface.h" namespace Service::Friend { -Friend_A::Friend_A(std::shared_ptr<Module> module) - : Module::Interface(std::move(module), "friend:a") { +Friend::Friend(std::shared_ptr<Module> module, const char* name) + : Interface(std::move(module), name) { static const FunctionInfo functions[] = { - {0, &Friend_A::CreateFriendService, "CreateFriendService"}, + {0, &Friend::CreateFriendService, "CreateFriendService"}, {1, nullptr, "CreateNotificationService"}, + {2, nullptr, "CreateDaemonSuspendSessionService"}, }; RegisterHandlers(functions); } diff --git a/src/core/hle/service/friend/friend_a.h b/src/core/hle/service/friend/interface.h index 81257583b..89dae8471 100644 --- a/src/core/hle/service/friend/friend_a.h +++ b/src/core/hle/service/friend/interface.h @@ -8,9 +8,9 @@ namespace Service::Friend { -class Friend_A final : public Module::Interface { +class Friend final : public Module::Interface { public: - explicit Friend_A(std::shared_ptr<Module> module); + explicit Friend(std::shared_ptr<Module> module, const char* name); }; } // namespace Service::Friend diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 475a0a5cf..9a02ba686 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -5,6 +5,7 @@ #include <atomic> #include "common/logging/log.h" #include "core/core_timing.h" +#include "core/core_timing_util.h" #include "core/frontend/emu_window.h" #include "core/frontend/input.h" #include "core/hle/ipc_helpers.h" diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp new file mode 100644 index 000000000..ec32faf15 --- /dev/null +++ b/src/core/hle/service/ldr/ldr.cpp @@ -0,0 +1,81 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <memory> + +#include "core/hle/service/ldr/ldr.h" +#include "core/hle/service/service.h" + +namespace Service::LDR { + +class DebugMonitor final : public ServiceFramework<DebugMonitor> { +public: + explicit DebugMonitor() : ServiceFramework{"ldr:dmnt"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "AddProcessToDebugLaunchQueue"}, + {1, nullptr, "ClearDebugLaunchQueue"}, + {2, nullptr, "GetNsoInfos"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class ProcessManager final : public ServiceFramework<ProcessManager> { +public: + explicit ProcessManager() : ServiceFramework{"ldr:pm"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "CreateProcess"}, + {1, nullptr, "GetProgramInfo"}, + {2, nullptr, "RegisterTitle"}, + {3, nullptr, "UnregisterTitle"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class Shell final : public ServiceFramework<Shell> { +public: + explicit Shell() : ServiceFramework{"ldr:shel"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "AddProcessToLaunchQueue"}, + {1, nullptr, "ClearLaunchQueue"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class RelocatableObject final : public ServiceFramework<RelocatableObject> { +public: + explicit RelocatableObject() : ServiceFramework{"ldr:ro"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "LoadNro"}, + {1, nullptr, "UnloadNro"}, + {2, nullptr, "LoadNrr"}, + {3, nullptr, "UnloadNrr"}, + {4, nullptr, "Initialize"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<DebugMonitor>()->InstallAsService(sm); + std::make_shared<ProcessManager>()->InstallAsService(sm); + std::make_shared<Shell>()->InstallAsService(sm); + std::make_shared<RelocatableObject>()->InstallAsService(sm); +} + +} // namespace Service::LDR diff --git a/src/core/hle/service/ldr/ldr.h b/src/core/hle/service/ldr/ldr.h new file mode 100644 index 000000000..412410c4f --- /dev/null +++ b/src/core/hle/service/ldr/ldr.h @@ -0,0 +1,16 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace Service::SM { +class ServiceManager; +} + +namespace Service::LDR { + +/// Registers all LDR services with the specified service manager. +void InstallInterfaces(SM::ServiceManager& sm); + +} // namespace Service::LDR diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index e85a8bdb9..b497376d7 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -4,10 +4,12 @@ #include <sstream> #include <string> + #include "common/logging/log.h" #include "core/hle/ipc_helpers.h" -#include "core/hle/kernel/client_session.h" #include "core/hle/service/lm/lm.h" +#include "core/hle/service/service.h" +#include "core/memory.h" namespace Service::LM { @@ -15,13 +17,12 @@ class Logger final : public ServiceFramework<Logger> { public: Logger() : ServiceFramework("Logger") { static const FunctionInfo functions[] = { - {0x00000000, &Logger::Log, "Log"}, + {0x00000000, &Logger::Initialize, "Initialize"}, + {0x00000001, nullptr, "SetDestination"}, }; RegisterHandlers(functions); } - ~Logger() = default; - private: struct MessageHeader { enum Flags : u32_le { @@ -66,13 +67,13 @@ private: }; /** - * LM::Log service function + * ILogger::Initialize service function * Inputs: * 0: 0x00000000 * Outputs: * 0: ResultCode */ - void Log(Kernel::HLERequestContext& ctx) { + void Initialize(Kernel::HLERequestContext& ctx) { // This function only succeeds - Get that out of the way IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); @@ -162,30 +163,33 @@ private: std::ostringstream log_stream; }; -void InstallInterfaces(SM::ServiceManager& service_manager) { - std::make_shared<LM>()->InstallAsService(service_manager); -} +class LM final : public ServiceFramework<LM> { +public: + explicit LM() : ServiceFramework{"lm"} { + static const FunctionInfo functions[] = { + {0x00000000, &LM::OpenLogger, "OpenLogger"}, + }; + RegisterHandlers(functions); + } -/** - * LM::Initialize service function - * Inputs: - * 0: 0x00000000 - * Outputs: - * 0: ResultCode - */ -void LM::Initialize(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<Logger>(); - - LOG_DEBUG(Service_LM, "called"); -} + /** + * LM::OpenLogger service function + * Inputs: + * 0: 0x00000000 + * Outputs: + * 0: ResultCode + */ + void OpenLogger(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface<Logger>(); -LM::LM() : ServiceFramework("lm") { - static const FunctionInfo functions[] = { - {0x00000000, &LM::Initialize, "Initialize"}, - }; - RegisterHandlers(functions); + LOG_DEBUG(Service_LM, "called"); + } +}; + +void InstallInterfaces(SM::ServiceManager& service_manager) { + std::make_shared<LM>()->InstallAsService(service_manager); } } // namespace Service::LM diff --git a/src/core/hle/service/lm/lm.h b/src/core/hle/service/lm/lm.h index 63d6506fe..7806ae27b 100644 --- a/src/core/hle/service/lm/lm.h +++ b/src/core/hle/service/lm/lm.h @@ -4,21 +4,12 @@ #pragma once -#include <vector> -#include "core/hle/kernel/kernel.h" -#include "core/hle/service/service.h" +namespace Service::SM { +class ServiceManager; +} namespace Service::LM { -class LM final : public ServiceFramework<LM> { -public: - LM(); - ~LM() = default; - -private: - void Initialize(Kernel::HLERequestContext& ctx); -}; - /// Registers all LM services with the specified service manager. void InstallInterfaces(SM::ServiceManager& service_manager); diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 0d951084b..cfe8d9178 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -5,9 +5,7 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" #include "core/hle/service/nifm/nifm.h" -#include "core/hle/service/nifm/nifm_a.h" -#include "core/hle/service/nifm/nifm_s.h" -#include "core/hle/service/nifm/nifm_u.h" +#include "core/hle/service/service.h" namespace Service::NIFM { @@ -210,28 +208,35 @@ IGeneralService::IGeneralService() : ServiceFramework("IGeneralService") { RegisterHandlers(functions); } -void Module::Interface::CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IGeneralService>(); - LOG_DEBUG(Service_NIFM, "called"); -} +class NetworkInterface final : public ServiceFramework<NetworkInterface> { +public: + explicit NetworkInterface(const char* name) : ServiceFramework{name} { + static const FunctionInfo functions[] = { + {4, &NetworkInterface::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, + {5, &NetworkInterface::CreateGeneralService, "CreateGeneralService"}, + }; + RegisterHandlers(functions); + } -void Module::Interface::CreateGeneralService(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IGeneralService>(); - LOG_DEBUG(Service_NIFM, "called"); -} + void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface<IGeneralService>(); + LOG_DEBUG(Service_NIFM, "called"); + } -Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) - : ServiceFramework(name), module(std::move(module)) {} + void CreateGeneralService(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface<IGeneralService>(); + LOG_DEBUG(Service_NIFM, "called"); + } +}; void InstallInterfaces(SM::ServiceManager& service_manager) { - auto module = std::make_shared<Module>(); - std::make_shared<NIFM_A>(module)->InstallAsService(service_manager); - std::make_shared<NIFM_S>(module)->InstallAsService(service_manager); - std::make_shared<NIFM_U>(module)->InstallAsService(service_manager); + std::make_shared<NetworkInterface>("nifm:a")->InstallAsService(service_manager); + std::make_shared<NetworkInterface>("nifm:s")->InstallAsService(service_manager); + std::make_shared<NetworkInterface>("nifm:u")->InstallAsService(service_manager); } } // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm.h b/src/core/hle/service/nifm/nifm.h index 11f1b5831..4616b3b48 100644 --- a/src/core/hle/service/nifm/nifm.h +++ b/src/core/hle/service/nifm/nifm.h @@ -4,24 +4,13 @@ #pragma once -#include "core/hle/service/service.h" +namespace Service::SM { +class ServiceManager; +} namespace Service::NIFM { -class Module final { -public: - class Interface : public ServiceFramework<Interface> { - public: - explicit Interface(std::shared_ptr<Module> module, const char* name); - - void CreateGeneralServiceOld(Kernel::HLERequestContext& ctx); - void CreateGeneralService(Kernel::HLERequestContext& ctx); - - protected: - std::shared_ptr<Module> module; - }; -}; - +/// Registers all NIFM services with the specified service manager. void InstallInterfaces(SM::ServiceManager& service_manager); } // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_a.cpp b/src/core/hle/service/nifm/nifm_a.cpp deleted file mode 100644 index b7f296a20..000000000 --- a/src/core/hle/service/nifm/nifm_a.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/nifm/nifm_a.h" - -namespace Service::NIFM { - -NIFM_A::NIFM_A(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "nifm:a") { - static const FunctionInfo functions[] = { - {4, &NIFM_A::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, - {5, &NIFM_A::CreateGeneralService, "CreateGeneralService"}, - }; - RegisterHandlers(functions); -} - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_a.h b/src/core/hle/service/nifm/nifm_a.h deleted file mode 100644 index c3ba33110..000000000 --- a/src/core/hle/service/nifm/nifm_a.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "core/hle/service/nifm/nifm.h" - -namespace Service::NIFM { - -class NIFM_A final : public Module::Interface { -public: - explicit NIFM_A(std::shared_ptr<Module> module); -}; - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_s.cpp b/src/core/hle/service/nifm/nifm_s.cpp deleted file mode 100644 index 96e3c0cee..000000000 --- a/src/core/hle/service/nifm/nifm_s.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/nifm/nifm_s.h" - -namespace Service::NIFM { - -NIFM_S::NIFM_S(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "nifm:s") { - static const FunctionInfo functions[] = { - {4, &NIFM_S::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, - {5, &NIFM_S::CreateGeneralService, "CreateGeneralService"}, - }; - RegisterHandlers(functions); -} - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_s.h b/src/core/hle/service/nifm/nifm_s.h deleted file mode 100644 index 8d1635a5d..000000000 --- a/src/core/hle/service/nifm/nifm_s.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "core/hle/service/nifm/nifm.h" - -namespace Service::NIFM { - -class NIFM_S final : public Module::Interface { -public: - explicit NIFM_S(std::shared_ptr<Module> module); -}; - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_u.cpp b/src/core/hle/service/nifm/nifm_u.cpp deleted file mode 100644 index 8cb75b903..000000000 --- a/src/core/hle/service/nifm/nifm_u.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/nifm/nifm_u.h" - -namespace Service::NIFM { - -NIFM_U::NIFM_U(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "nifm:u") { - static const FunctionInfo functions[] = { - {4, &NIFM_U::CreateGeneralServiceOld, "CreateGeneralServiceOld"}, - {5, &NIFM_U::CreateGeneralService, "CreateGeneralService"}, - }; - RegisterHandlers(functions); -} - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nifm/nifm_u.h b/src/core/hle/service/nifm/nifm_u.h deleted file mode 100644 index def9726b1..000000000 --- a/src/core/hle/service/nifm/nifm_u.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "core/hle/service/nifm/nifm.h" - -namespace Service::NIFM { - -class NIFM_U final : public Module::Interface { -public: - explicit NIFM_U(std::shared_ptr<Module> module); -}; - -} // namespace Service::NIFM diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index cc5cfe34e..1555ea806 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <utility> + #include "core/hle/ipc_helpers.h" #include "core/hle/service/nvdrv/devices/nvdevice.h" #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" @@ -40,14 +42,14 @@ Module::Module() { devices["/dev/nvhost-nvdec"] = std::make_shared<Devices::nvhost_nvdec>(); } -u32 Module::Open(std::string device_name) { +u32 Module::Open(const std::string& device_name) { ASSERT_MSG(devices.find(device_name) != devices.end(), "Trying to open unknown device {}", device_name); auto device = devices[device_name]; - u32 fd = next_fd++; + const u32 fd = next_fd++; - open_files[fd] = device; + open_files[fd] = std::move(device); return fd; } @@ -56,7 +58,7 @@ u32 Module::Ioctl(u32 fd, u32_le command, const std::vector<u8>& input, std::vec auto itr = open_files.find(fd); ASSERT_MSG(itr != open_files.end(), "Tried to talk to an invalid device"); - auto device = itr->second; + auto& device = itr->second; return device->ioctl({command}, input, output); } diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 35b2c65fc..184f3c9fc 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -38,7 +38,7 @@ public: } /// Opens a device node and returns a file descriptor to it. - u32 Open(std::string device_name); + u32 Open(const std::string& device_name); /// Sends an ioctl command to the specified file descriptor. u32 Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector<u8>& output); /// Closes a device file descriptor and returns operation success. diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 1fca1743d..5344441e1 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -9,6 +9,7 @@ #include "common/scope_exit.h" #include "core/core.h" #include "core/core_timing.h" +#include "core/core_timing_util.h" #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" #include "core/hle/service/nvdrv/nvdrv.h" #include "core/hle/service/nvflinger/buffer_queue.h" diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp new file mode 100644 index 000000000..e20a25689 --- /dev/null +++ b/src/core/hle/service/pm/pm.cpp @@ -0,0 +1,70 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/service/service.h" + +namespace Service::PM { + +class BootMode final : public ServiceFramework<BootMode> { +public: + explicit BootMode() : ServiceFramework{"pm:bm"} { + static const FunctionInfo functions[] = { + {0, nullptr, "GetBootMode"}, + {1, nullptr, "SetMaintenanceBoot"}, + }; + RegisterHandlers(functions); + } +}; + +class DebugMonitor final : public ServiceFramework<DebugMonitor> { +public: + explicit DebugMonitor() : ServiceFramework{"pm:dmnt"} { + static const FunctionInfo functions[] = { + {0, nullptr, "IsDebugMode"}, + {1, nullptr, "GetDebugProcesses"}, + {2, nullptr, "StartDebugProcess"}, + {3, nullptr, "GetTitlePid"}, + {4, nullptr, "EnableDebugForTitleId"}, + {5, nullptr, "GetApplicationPid"}, + {6, nullptr, "EnableDebugForApplication"}, + }; + RegisterHandlers(functions); + } +}; + +class Info final : public ServiceFramework<Info> { +public: + explicit Info() : ServiceFramework{"pm:info"} { + static const FunctionInfo functions[] = { + {0, nullptr, "GetTitleId"}, + }; + RegisterHandlers(functions); + } +}; + +class Shell final : public ServiceFramework<Shell> { +public: + explicit Shell() : ServiceFramework{"pm:shell"} { + static const FunctionInfo functions[] = { + {0, nullptr, "LaunchProcess"}, + {1, nullptr, "TerminateProcessByPid"}, + {2, nullptr, "TerminateProcessByTitleId"}, + {3, nullptr, "GetProcessEventWaiter"}, + {4, nullptr, "GetProcessEventType"}, + {5, nullptr, "NotifyBootFinished"}, + {6, nullptr, "GetApplicationPid"}, + {7, nullptr, "BoostSystemMemoryResourceLimit"}, + }; + RegisterHandlers(functions); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<BootMode>()->InstallAsService(sm); + std::make_shared<DebugMonitor>()->InstallAsService(sm); + std::make_shared<Info>()->InstallAsService(sm); + std::make_shared<Shell>()->InstallAsService(sm); +} + +} // namespace Service::PM diff --git a/src/core/hle/service/pm/pm.h b/src/core/hle/service/pm/pm.h new file mode 100644 index 000000000..9fc19fed6 --- /dev/null +++ b/src/core/hle/service/pm/pm.h @@ -0,0 +1,16 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace Service::SM { +class ServiceManager; +} + +namespace Service::PM { + +/// Registers all PM services with the specified service manager. +void InstallInterfaces(SM::ServiceManager& service_manager); + +} // namespace Service::PM diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 0d036bfaa..482989ea7 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -21,10 +21,14 @@ #include "core/hle/service/apm/apm.h" #include "core/hle/service/audio/audio.h" #include "core/hle/service/bcat/bcat.h" +#include "core/hle/service/erpt/erpt.h" +#include "core/hle/service/es/es.h" +#include "core/hle/service/eupld/eupld.h" #include "core/hle/service/fatal/fatal.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/friend/friend.h" #include "core/hle/service/hid/hid.h" +#include "core/hle/service/ldr/ldr.h" #include "core/hle/service/lm/lm.h" #include "core/hle/service/mm/mm_u.h" #include "core/hle/service/nfp/nfp.h" @@ -32,6 +36,7 @@ #include "core/hle/service/ns/ns.h" #include "core/hle/service/nvdrv/nvdrv.h" #include "core/hle/service/pctl/pctl.h" +#include "core/hle/service/pm/pm.h" #include "core/hle/service/prepo/prepo.h" #include "core/hle/service/service.h" #include "core/hle/service/set/settings.h" @@ -187,10 +192,14 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { APM::InstallInterfaces(*sm); BCAT::InstallInterfaces(*sm); Audio::InstallInterfaces(*sm); + ERPT::InstallInterfaces(*sm); + ES::InstallInterfaces(*sm); + EUPLD::InstallInterfaces(*sm); Fatal::InstallInterfaces(*sm); FileSystem::InstallInterfaces(*sm); Friend::InstallInterfaces(*sm); HID::InstallInterfaces(*sm); + LDR::InstallInterfaces(*sm); LM::InstallInterfaces(*sm); MM::InstallInterfaces(*sm); NFP::InstallInterfaces(*sm); @@ -199,6 +208,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { Nvidia::InstallInterfaces(*sm); PCTL::InstallInterfaces(*sm); PlayReport::InstallInterfaces(*sm); + PM::InstallInterfaces(*sm); Sockets::InstallInterfaces(*sm); SPL::InstallInterfaces(*sm); SSL::InstallInterfaces(*sm); diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index fa85277fe..41efca31c 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp @@ -10,13 +10,22 @@ namespace Service::Set { void SET_SYS::GetColorSetId(Kernel::HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); - rb.Push<u32>(0); + rb.PushEnum(color_set); - LOG_WARNING(Service_SET, "(STUBBED) called"); + LOG_DEBUG(Service_SET, "called"); +} + +void SET_SYS::SetColorSetId(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + color_set = rp.PopEnum<ColorSet>(); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + + LOG_DEBUG(Service_SET, "called"); } SET_SYS::SET_SYS() : ServiceFramework("set:sys") { @@ -44,7 +53,7 @@ SET_SYS::SET_SYS() : ServiceFramework("set:sys") { {21, nullptr, "GetEulaVersions"}, {22, nullptr, "SetEulaVersions"}, {23, &SET_SYS::GetColorSetId, "GetColorSetId"}, - {24, nullptr, "SetColorSetId"}, + {24, &SET_SYS::SetColorSetId, "SetColorSetId"}, {25, nullptr, "GetConsoleInformationUploadFlag"}, {26, nullptr, "SetConsoleInformationUploadFlag"}, {27, nullptr, "GetAutomaticApplicationDownloadFlag"}, @@ -172,4 +181,6 @@ SET_SYS::SET_SYS() : ServiceFramework("set:sys") { RegisterHandlers(functions); } +SET_SYS::~SET_SYS() = default; + } // namespace Service::Set diff --git a/src/core/hle/service/set/set_sys.h b/src/core/hle/service/set/set_sys.h index b77a97cde..f602f3c77 100644 --- a/src/core/hle/service/set/set_sys.h +++ b/src/core/hle/service/set/set_sys.h @@ -11,10 +11,19 @@ namespace Service::Set { class SET_SYS final : public ServiceFramework<SET_SYS> { public: explicit SET_SYS(); - ~SET_SYS() = default; + ~SET_SYS() override; private: + /// Indicates the current theme set by the system settings + enum class ColorSet : u32 { + BasicWhite = 0, + BasicBlack = 1, + }; + void GetColorSetId(Kernel::HLERequestContext& ctx); + void SetColorSetId(Kernel::HLERequestContext& ctx); + + ColorSet color_set = ColorSet::BasicWhite; }; } // namespace Service::Set diff --git a/src/core/hle/service/time/time_s.cpp b/src/core/hle/service/time/interface.cpp index 0b599ea00..048d5b077 100644 --- a/src/core/hle/service/time/time_s.cpp +++ b/src/core/hle/service/time/interface.cpp @@ -2,17 +2,18 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "core/hle/service/time/time_s.h" +#include "core/hle/service/time/interface.h" namespace Service::Time { -TIME_S::TIME_S(std::shared_ptr<Module> time) : Module::Interface(std::move(time), "time:s") { +Time::Time(std::shared_ptr<Module> time, const char* name) + : Module::Interface(std::move(time), name) { static const FunctionInfo functions[] = { - {0, &TIME_S::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, - {1, &TIME_S::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"}, - {2, &TIME_S::GetStandardSteadyClock, "GetStandardSteadyClock"}, - {3, &TIME_S::GetTimeZoneService, "GetTimeZoneService"}, - {4, &TIME_S::GetStandardLocalSystemClock, "GetStandardLocalSystemClock"}, + {0, &Time::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, + {1, &Time::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"}, + {2, &Time::GetStandardSteadyClock, "GetStandardSteadyClock"}, + {3, &Time::GetTimeZoneService, "GetTimeZoneService"}, + {4, &Time::GetStandardLocalSystemClock, "GetStandardLocalSystemClock"}, {5, nullptr, "GetEphemeralNetworkSystemClock"}, {50, nullptr, "SetStandardSteadyClockInternalOffset"}, {100, nullptr, "IsStandardUserSystemClockAutomaticCorrectionEnabled"}, diff --git a/src/core/hle/service/time/time_s.h b/src/core/hle/service/time/interface.h index 4a2daa513..183a53db1 100644 --- a/src/core/hle/service/time/time_s.h +++ b/src/core/hle/service/time/interface.h @@ -8,9 +8,9 @@ namespace Service::Time { -class TIME_S final : public Module::Interface { +class Time final : public Module::Interface { public: - explicit TIME_S(std::shared_ptr<Module> time); + explicit Time(std::shared_ptr<Module> time, const char* name); }; } // namespace Service::Time diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 507ae95f4..37b58bb77 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -6,12 +6,12 @@ #include <ctime> #include "common/logging/log.h" #include "core/core_timing.h" +#include "core/core_timing_util.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" +#include "core/hle/service/time/interface.h" #include "core/hle/service/time/time.h" -#include "core/hle/service/time/time_s.h" -#include "core/hle/service/time/time_u.h" namespace Service::Time { @@ -212,8 +212,9 @@ Module::Interface::Interface(std::shared_ptr<Module> time, const char* name) void InstallInterfaces(SM::ServiceManager& service_manager) { auto time = std::make_shared<Module>(); - std::make_shared<TIME_S>(time)->InstallAsService(service_manager); - std::make_shared<TIME_U>(time)->InstallAsService(service_manager); + std::make_shared<Time>(time, "time:a")->InstallAsService(service_manager); + std::make_shared<Time>(time, "time:s")->InstallAsService(service_manager); + std::make_shared<Time>(time, "time:u")->InstallAsService(service_manager); } } // namespace Service::Time diff --git a/src/core/hle/service/time/time_u.cpp b/src/core/hle/service/time/time_u.cpp deleted file mode 100644 index 1ed42c419..000000000 --- a/src/core/hle/service/time/time_u.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/time/time_u.h" - -namespace Service::Time { - -TIME_U::TIME_U(std::shared_ptr<Module> time) : Module::Interface(std::move(time), "time:u") { - static const FunctionInfo functions[] = { - {0, &TIME_U::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, - {1, &TIME_U::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"}, - {2, &TIME_U::GetStandardSteadyClock, "GetStandardSteadyClock"}, - {3, &TIME_U::GetTimeZoneService, "GetTimeZoneService"}, - {4, &TIME_U::GetStandardLocalSystemClock, "GetStandardLocalSystemClock"}, - {5, nullptr, "GetEphemeralNetworkSystemClock"}, - {50, nullptr, "SetStandardSteadyClockInternalOffset"}, - {100, nullptr, "IsStandardUserSystemClockAutomaticCorrectionEnabled"}, - {101, nullptr, "SetStandardUserSystemClockAutomaticCorrectionEnabled"}, - {102, nullptr, "GetStandardUserSystemClockInitialYear"}, - {200, nullptr, "IsStandardNetworkSystemClockAccuracySufficient"}, - {300, nullptr, "CalculateMonotonicSystemClockBaseTimePoint"}, - {400, nullptr, "GetClockSnapshot"}, - {401, nullptr, "GetClockSnapshotFromSystemClockContext"}, - {500, nullptr, "CalculateStandardUserSystemClockDifferenceByUser"}, - {501, nullptr, "CalculateSpanBetween"}, - }; - RegisterHandlers(functions); -} - -} // namespace Service::Time diff --git a/src/core/hle/service/time/time_u.h b/src/core/hle/service/time/time_u.h deleted file mode 100644 index 3724bcdc7..000000000 --- a/src/core/hle/service/time/time_u.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "core/hle/service/time/time.h" - -namespace Service::Time { - -class TIME_U final : public Module::Interface { -public: - explicit TIME_U(std::shared_ptr<Module> time); -}; - -} // namespace Service::Time diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 18bd62a08..b0277a875 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp @@ -6,7 +6,6 @@ #include "common/common_funcs.h" #include "common/file_util.h" #include "common/logging/log.h" -#include "common/string_util.h" #include "core/file_sys/content_archive.h" #include "core/gdbstub/gdbstub.h" #include "core/hle/kernel/process.h" @@ -18,34 +17,6 @@ namespace Loader { -static std::string FindRomFS(const std::string& directory) { - std::string filepath_romfs; - const auto callback = [&filepath_romfs](u64*, const std::string& directory, - const std::string& virtual_name) -> bool { - const std::string physical_name = directory + virtual_name; - if (FileUtil::IsDirectory(physical_name)) { - // Skip directories - return true; - } - - // Verify extension - const std::string extension = physical_name.substr(physical_name.find_last_of(".") + 1); - if (Common::ToLower(extension) != "romfs") { - return true; - } - - // Found it - we are done - filepath_romfs = std::move(physical_name); - return false; - }; - - // Search the specified directory recursively, looking for the first .romfs file, which will - // be used for the RomFS - FileUtil::ForeachDirectoryEntry(nullptr, directory, callback); - - return filepath_romfs; -} - AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file) : AppLoader(std::move(file)) {} diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index d7328ff39..0e205ed72 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -75,14 +75,6 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { ProcessMacroUpload(value); break; } - case MAXWELL3D_REG_INDEX(code_address.code_address_high): - case MAXWELL3D_REG_INDEX(code_address.code_address_low): { - // Note: For some reason games (like Puyo Puyo Tetris) seem to write 0 to the CODE_ADDRESS - // register, we do not currently know if that's intended or a bug, so we assert it lest - // stuff breaks in other places (like the shader address calculation). - ASSERT_MSG(regs.code_address.CodeAddress() == 0, "Unexpected CODE_ADDRESS register value."); - break; - } case MAXWELL3D_REG_INDEX(const_buffer.cb_data[0]): case MAXWELL3D_REG_INDEX(const_buffer.cb_data[1]): case MAXWELL3D_REG_INDEX(const_buffer.cb_data[2]): diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 58501ca8b..c464fc6d1 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -23,7 +23,14 @@ enum class RenderTargetFormat : u32 { RGB10_A2_UNORM = 0xD1, RGBA8_UNORM = 0xD5, RGBA8_SRGB = 0xD6, + RG16_UNORM = 0xDA, + RG16_SNORM = 0xDB, + RG16_SINT = 0xDC, + RG16_UINT = 0xDD, + RG16_FLOAT = 0xDE, R11G11B10_FLOAT = 0xE0, + R16_FLOAT = 0xF2, + R8_UNORM = 0xF3, }; enum class DepthFormat : u32 { @@ -33,6 +40,7 @@ enum class DepthFormat : u32 { Z24_X8_UNORM = 0x15, Z24_S8_UNORM = 0x16, Z24_C8_UNORM = 0x18, + Z32_S8_X24_FLOAT = 0x19, }; /// Returns the number of bytes per pixel of each rendertarget format. diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 5d5ad84b7..a1c47bae9 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -5,6 +5,7 @@ #include <algorithm> #include <memory> #include <string> +#include <string_view> #include <tuple> #include <utility> #include <glad/glad.h> @@ -37,11 +38,6 @@ MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(100, 100, 255)); MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100)); RasterizerOpenGL::RasterizerOpenGL() { - has_ARB_buffer_storage = false; - has_ARB_direct_state_access = false; - has_ARB_separate_shader_objects = false; - has_ARB_vertex_attrib_binding = false; - // Create sampler objects for (size_t i = 0; i < texture_samplers.size(); ++i) { texture_samplers[i].Create(); @@ -59,7 +55,8 @@ RasterizerOpenGL::RasterizerOpenGL() { GLint ext_num; glGetIntegerv(GL_NUM_EXTENSIONS, &ext_num); for (GLint i = 0; i < ext_num; i++) { - std::string extension{reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i))}; + const std::string_view extension{ + reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i))}; if (extension == "GL_ARB_buffer_storage") { has_ARB_buffer_storage = true; @@ -110,8 +107,6 @@ RasterizerOpenGL::RasterizerOpenGL() { glBindBufferBase(GL_UNIFORM_BUFFER, index, buffer.handle); } - accelerate_draw = AccelDraw::Disabled; - glEnable(GL_BLEND); LOG_CRITICAL(Render_OpenGL, "Sync fixed function OpenGL state here!"); @@ -694,10 +689,12 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr glBindBuffer(GL_UNIFORM_BUFFER, 0); // Now configure the bindpoint of the buffer inside the shader - std::string buffer_name = used_buffer.GetName(); - GLuint index = glGetProgramResourceIndex(program, GL_UNIFORM_BLOCK, buffer_name.c_str()); - if (index != -1) + const std::string buffer_name = used_buffer.GetName(); + const GLuint index = + glGetProgramResourceIndex(program, GL_UNIFORM_BLOCK, buffer_name.c_str()); + if (index != GL_INVALID_INDEX) { glUniformBlockBinding(program, index, buffer_draw_state.bindpoint); + } } state.Apply(); diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index ab06e2d95..e150be58f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -135,10 +135,10 @@ private: /// Syncs the blend state to match the guest state void SyncBlendState(); - bool has_ARB_buffer_storage; - bool has_ARB_direct_state_access; - bool has_ARB_separate_shader_objects; - bool has_ARB_vertex_attrib_binding; + bool has_ARB_buffer_storage = false; + bool has_ARB_direct_state_access = false; + bool has_ARB_separate_shader_objects = false; + bool has_ARB_vertex_attrib_binding = false; OpenGLState state; @@ -167,5 +167,5 @@ private: void SetupShaders(u8* buffer_ptr, GLintptr buffer_offset); enum class AccelDraw { Disabled, Arrays, Indexed }; - AccelDraw accelerate_draw; + AccelDraw accelerate_draw = AccelDraw::Disabled; }; diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 1d3aff97b..a4d9707cb 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -104,13 +104,21 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form true}, // DXT45 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, - true}, // BC7U - {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 - {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8 - {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8 - {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F - {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F - {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F + true}, // BC7U + {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 + {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8 + {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8 + {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F + {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F + {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F + {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F + {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16UNORM + {GL_RG16, GL_RG, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RG16 + {GL_RG16F, GL_RG, GL_HALF_FLOAT, ComponentType::Float, false}, // RG16F + {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RG16UI + {GL_RG16I, GL_RG_INTEGER, GL_SHORT, ComponentType::SInt, false}, // RG16I + {GL_RG16_SNORM, GL_RG, GL_SHORT, ComponentType::SNorm, false}, // RG16S + {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // SRGBA8 // DepthStencil formats {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, @@ -120,6 +128,8 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // Z16 + {GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, + ComponentType::Float, false}, // Z32FS8 }}; static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) { @@ -204,9 +214,13 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, - MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::Z24S8>, + MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>, + MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::RG16>, + MortonCopy<true, PixelFormat::RG16F>, MortonCopy<true, PixelFormat::RG16UI>, + MortonCopy<true, PixelFormat::RG16I>, MortonCopy<true, PixelFormat::RG16S>, + MortonCopy<true, PixelFormat::SRGBA8>, MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, - MortonCopy<true, PixelFormat::Z16>, + MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::Z32FS8>, }; static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), @@ -232,10 +246,19 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), MortonCopy<false, PixelFormat::RGBA32F>, MortonCopy<false, PixelFormat::RG32F>, MortonCopy<false, PixelFormat::R32F>, + MortonCopy<false, PixelFormat::R16F>, + MortonCopy<false, PixelFormat::R16UNORM>, + MortonCopy<false, PixelFormat::RG16>, + MortonCopy<false, PixelFormat::RG16F>, + MortonCopy<false, PixelFormat::RG16UI>, + MortonCopy<false, PixelFormat::RG16I>, + MortonCopy<false, PixelFormat::RG16S>, + MortonCopy<false, PixelFormat::SRGBA8>, MortonCopy<false, PixelFormat::Z24S8>, MortonCopy<false, PixelFormat::S8Z24>, MortonCopy<false, PixelFormat::Z32F>, MortonCopy<false, PixelFormat::Z16>, + MortonCopy<false, PixelFormat::Z32FS8>, }; // Allocate an uninitialized texture of appropriate size and format for the surface diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 800d239d9..bf0458b94 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -41,14 +41,23 @@ struct SurfaceParams { RGBA32F = 16, RG32F = 17, R32F = 18, + R16F = 19, + R16UNORM = 20, + RG16 = 21, + RG16F = 22, + RG16UI = 23, + RG16I = 24, + RG16S = 25, + SRGBA8 = 26, MaxColorFormat, // DepthStencil formats - Z24S8 = 19, - S8Z24 = 20, - Z32F = 21, - Z16 = 22, + Z24S8 = 27, + S8Z24 = 28, + Z32F = 29, + Z16 = 30, + Z32FS8 = 31, MaxDepthStencilFormat, @@ -105,10 +114,19 @@ struct SurfaceParams { 1, // RGBA32F 1, // RG32F 1, // R32F + 1, // R16F + 1, // R16UNORM + 1, // RG16 + 1, // RG16F + 1, // RG16UI + 1, // RG16I + 1, // RG16S + 1, // SRGBA8 1, // Z24S8 1, // S8Z24 1, // Z32F 1, // Z16 + 1, // Z32FS8 }}; ASSERT(static_cast<size_t>(format) < compression_factor_table.size()); @@ -139,10 +157,19 @@ struct SurfaceParams { 128, // RGBA32F 64, // RG32F 32, // R32F + 16, // R16F + 16, // R16UNORM + 32, // RG16 + 32, // RG16F + 32, // RG16UI + 32, // RG16I + 32, // RG16S + 32, // SRGBA8 32, // Z24S8 32, // S8Z24 32, // Z32F 16, // Z16 + 64, // Z32FS8 }}; ASSERT(static_cast<size_t>(format) < bpp_table.size()); @@ -163,6 +190,8 @@ struct SurfaceParams { return PixelFormat::Z32F; case Tegra::DepthFormat::Z16_UNORM: return PixelFormat::Z16; + case Tegra::DepthFormat::Z32_S8_X24_FLOAT: + return PixelFormat::Z32FS8; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); UNREACHABLE(); @@ -171,8 +200,9 @@ struct SurfaceParams { static PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) { switch (format) { - case Tegra::RenderTargetFormat::RGBA8_UNORM: case Tegra::RenderTargetFormat::RGBA8_SRGB: + return PixelFormat::SRGBA8; + case Tegra::RenderTargetFormat::RGBA8_UNORM: return PixelFormat::ABGR8; case Tegra::RenderTargetFormat::BGRA8_UNORM: return PixelFormat::BGRA8; @@ -188,6 +218,20 @@ struct SurfaceParams { return PixelFormat::R11FG11FB10F; case Tegra::RenderTargetFormat::RGBA32_UINT: return PixelFormat::RGBA32UI; + case Tegra::RenderTargetFormat::R8_UNORM: + return PixelFormat::R8; + case Tegra::RenderTargetFormat::RG16_FLOAT: + return PixelFormat::RG16F; + case Tegra::RenderTargetFormat::RG16_UINT: + return PixelFormat::RG16UI; + case Tegra::RenderTargetFormat::RG16_SINT: + return PixelFormat::RG16I; + case Tegra::RenderTargetFormat::RG16_UNORM: + return PixelFormat::RG16; + case Tegra::RenderTargetFormat::RG16_SNORM: + return PixelFormat::RG16S; + case Tegra::RenderTargetFormat::R16_FLOAT: + return PixelFormat::R16F; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); UNREACHABLE(); @@ -226,8 +270,22 @@ struct SurfaceParams { UNREACHABLE(); case Tegra::Texture::TextureFormat::R32_G32: return PixelFormat::RG32F; + case Tegra::Texture::TextureFormat::R16: + switch (component_type) { + case Tegra::Texture::ComponentType::FLOAT: + return PixelFormat::R16F; + case Tegra::Texture::ComponentType::UNORM: + return PixelFormat::R16UNORM; + } + LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", + static_cast<u32>(component_type)); + UNREACHABLE(); case Tegra::Texture::TextureFormat::R32: return PixelFormat::R32F; + case Tegra::Texture::TextureFormat::ZF32: + return PixelFormat::Z32F; + case Tegra::Texture::TextureFormat::Z24S8: + return PixelFormat::Z24S8; case Tegra::Texture::TextureFormat::DXT1: return PixelFormat::DXT1; case Tegra::Texture::TextureFormat::DXT23: @@ -240,6 +298,22 @@ struct SurfaceParams { return PixelFormat::BC7U; case Tegra::Texture::TextureFormat::ASTC_2D_4X4: return PixelFormat::ASTC_2D_4X4; + case Tegra::Texture::TextureFormat::R16_G16: + switch (component_type) { + case Tegra::Texture::ComponentType::FLOAT: + return PixelFormat::RG16F; + case Tegra::Texture::ComponentType::UNORM: + return PixelFormat::RG16; + case Tegra::Texture::ComponentType::SNORM: + return PixelFormat::RG16S; + case Tegra::Texture::ComponentType::UINT: + return PixelFormat::RG16UI; + case Tegra::Texture::ComponentType::SINT: + return PixelFormat::RG16I; + } + LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", + static_cast<u32>(component_type)); + UNREACHABLE(); default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", static_cast<u32>(format), static_cast<u32>(component_type)); @@ -251,6 +325,7 @@ struct SurfaceParams { // TODO(Subv): Properly implement this switch (format) { case PixelFormat::ABGR8: + case PixelFormat::SRGBA8: return Tegra::Texture::TextureFormat::A8R8G8B8; case PixelFormat::B5G6R5: return Tegra::Texture::TextureFormat::B5G6R5; @@ -290,6 +365,19 @@ struct SurfaceParams { return Tegra::Texture::TextureFormat::R32_G32; case PixelFormat::R32F: return Tegra::Texture::TextureFormat::R32; + case PixelFormat::R16F: + case PixelFormat::R16UNORM: + return Tegra::Texture::TextureFormat::R16; + case PixelFormat::Z32F: + return Tegra::Texture::TextureFormat::ZF32; + case PixelFormat::Z24S8: + return Tegra::Texture::TextureFormat::Z24S8; + case PixelFormat::RG16F: + case PixelFormat::RG16: + case PixelFormat::RG16UI: + case PixelFormat::RG16I: + case PixelFormat::RG16S: + return Tegra::Texture::TextureFormat::R16_G16; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); UNREACHABLE(); @@ -306,6 +394,8 @@ struct SurfaceParams { return Tegra::DepthFormat::Z32_FLOAT; case PixelFormat::Z16: return Tegra::DepthFormat::Z16_UNORM; + case PixelFormat::Z32FS8: + return Tegra::DepthFormat::Z32_S8_X24_FLOAT; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); UNREACHABLE(); @@ -319,6 +409,12 @@ struct SurfaceParams { return ComponentType::UNorm; case Tegra::Texture::ComponentType::FLOAT: return ComponentType::Float; + case Tegra::Texture::ComponentType::SNORM: + return ComponentType::SNorm; + case Tegra::Texture::ComponentType::UINT: + return ComponentType::UInt; + case Tegra::Texture::ComponentType::SINT: + return ComponentType::SInt; default: LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type)); UNREACHABLE(); @@ -332,14 +428,23 @@ struct SurfaceParams { case Tegra::RenderTargetFormat::RGBA8_SRGB: case Tegra::RenderTargetFormat::BGRA8_UNORM: case Tegra::RenderTargetFormat::RGB10_A2_UNORM: + case Tegra::RenderTargetFormat::R8_UNORM: + case Tegra::RenderTargetFormat::RG16_UNORM: return ComponentType::UNorm; + case Tegra::RenderTargetFormat::RG16_SNORM: + return ComponentType::SNorm; case Tegra::RenderTargetFormat::RGBA16_FLOAT: case Tegra::RenderTargetFormat::R11G11B10_FLOAT: case Tegra::RenderTargetFormat::RGBA32_FLOAT: case Tegra::RenderTargetFormat::RG32_FLOAT: + case Tegra::RenderTargetFormat::RG16_FLOAT: + case Tegra::RenderTargetFormat::R16_FLOAT: return ComponentType::Float; case Tegra::RenderTargetFormat::RGBA32_UINT: + case Tegra::RenderTargetFormat::RG16_UINT: return ComponentType::UInt; + case Tegra::RenderTargetFormat::RG16_SINT: + return ComponentType::SInt; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); UNREACHABLE(); @@ -363,6 +468,7 @@ struct SurfaceParams { case Tegra::DepthFormat::Z24_S8_UNORM: return ComponentType::UNorm; case Tegra::DepthFormat::Z32_FLOAT: + case Tegra::DepthFormat::Z32_S8_X24_FLOAT: return ComponentType::Float; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index cda2646ad..d794f8402 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp @@ -62,10 +62,12 @@ u32 BytesPerPixel(TextureFormat format) { case TextureFormat::A2B10G10R10: case TextureFormat::BF10GF11RF11: case TextureFormat::R32: + case TextureFormat::R16_G16: return 4; case TextureFormat::A1B5G5R5: case TextureFormat::B5G6R5: case TextureFormat::G8R8: + case TextureFormat::R16: return 2; case TextureFormat::R8: return 1; @@ -89,6 +91,8 @@ static u32 DepthBytesPerPixel(DepthFormat format) { case DepthFormat::Z24_S8_UNORM: case DepthFormat::Z32_FLOAT: return 4; + case DepthFormat::Z32_S8_X24_FLOAT: + return 8; default: UNIMPLEMENTED_MSG("Format not implemented"); break; @@ -123,6 +127,8 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, case TextureFormat::R32_G32_B32_A32: case TextureFormat::R32_G32: case TextureFormat::R32: + case TextureFormat::R16: + case TextureFormat::R16_G16: case TextureFormat::BF10GF11RF11: case TextureFormat::ASTC_2D_4X4: CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, @@ -148,6 +154,7 @@ std::vector<u8> UnswizzleDepthTexture(VAddr address, DepthFormat format, u32 wid case DepthFormat::S8_Z24_UNORM: case DepthFormat::Z24_S8_UNORM: case DepthFormat::Z32_FLOAT: + case DepthFormat::Z32_S8_X24_FLOAT: CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, unswizzled_data.data(), true, block_height); break; @@ -181,6 +188,8 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat case TextureFormat::R32_G32_B32_A32: case TextureFormat::R32_G32: case TextureFormat::R32: + case TextureFormat::R16: + case TextureFormat::R16_G16: // TODO(Subv): For the time being just forward the same data without any decoding. rgba_data = texture_data; break; diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp index 8f24586ce..2b45b8573 100644 --- a/src/yuzu/debugger/wait_tree.cpp +++ b/src/yuzu/debugger/wait_tree.cpp @@ -5,6 +5,7 @@ #include "yuzu/debugger/wait_tree.h" #include "yuzu/util/util.h" +#include "common/assert.h" #include "core/core.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/handle_table.h" @@ -169,6 +170,8 @@ QString WaitTreeWaitObject::GetResetTypeQString(Kernel::ResetType reset_type) { case Kernel::ResetType::Pulse: return tr("pulse"); } + UNREACHABLE(); + return {}; } WaitTreeObjectList::WaitTreeObjectList( @@ -206,6 +209,9 @@ QString WaitTreeThread::GetText() const { case ThreadStatus::WaitSleep: status = tr("sleeping"); break; + case ThreadStatus::WaitIPC: + status = tr("waiting for IPC reply"); + break; case ThreadStatus::WaitSynchAll: case ThreadStatus::WaitSynchAny: status = tr("waiting for objects"); @@ -237,6 +243,7 @@ QColor WaitTreeThread::GetColor() const { case ThreadStatus::Ready: return QColor(Qt::GlobalColor::darkBlue); case ThreadStatus::WaitHLEEvent: + case ThreadStatus::WaitIPC: return QColor(Qt::GlobalColor::darkRed); case ThreadStatus::WaitSleep: return QColor(Qt::GlobalColor::darkYellow); |