diff options
44 files changed, 221 insertions, 104 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index ad9e2915c..dbae75d8c 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp @@ -10,6 +10,7 @@ #include "audio_core/stream.h" #include "common/assert.h" #include "common/logging/log.h" +#include "common/microprofile.h" #include "core/core_timing.h" #include "core/core_timing_util.h" #include "core/settings.h" @@ -94,7 +95,10 @@ void Stream::PlayNextBuffer() { CoreTiming::ScheduleEventThreadsafe(GetBufferReleaseCycles(*active_buffer), release_event, {}); } +MICROPROFILE_DEFINE(AudioOutput, "Audio", "ReleaseActiveBuffer", MP_RGB(100, 100, 255)); + void Stream::ReleaseActiveBuffer() { + MICROPROFILE_SCOPE(AudioOutput); ASSERT(active_buffer); released_buffers.push(std::move(active_buffer)); release_callback(); diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index de44ccebd..b47f04988 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp @@ -7,6 +7,7 @@ #include <dynarmic/A64/a64.h> #include <dynarmic/A64/config.h> #include "common/logging/log.h" +#include "common/microprofile.h" #include "core/arm/dynarmic/arm_dynarmic.h" #include "core/core.h" #include "core/core_cpu.h" @@ -143,7 +144,10 @@ std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const { return std::make_unique<Dynarmic::A64::Jit>(config); } +MICROPROFILE_DEFINE(ARM_Jit_Dynarmic, "ARM JIT", "Dynarmic", MP_RGB(255, 64, 64)); + void ARM_Dynarmic::Run() { + MICROPROFILE_SCOPE(ARM_Jit_Dynarmic); ASSERT(Memory::GetCurrentPageTable() == current_page_table); jit->Run(); diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp index 307f12198..4c4de2623 100644 --- a/src/core/arm/unicorn/arm_unicorn.cpp +++ b/src/core/arm/unicorn/arm_unicorn.cpp @@ -193,10 +193,10 @@ void ARM_Unicorn::Step() { ExecuteInstructions(1); } -MICROPROFILE_DEFINE(ARM_Jit, "ARM JIT", "ARM JIT", MP_RGB(255, 64, 64)); +MICROPROFILE_DEFINE(ARM_Jit_Unicorn, "ARM JIT", "Unicorn", MP_RGB(255, 64, 64)); void ARM_Unicorn::ExecuteInstructions(int num_instructions) { - MICROPROFILE_SCOPE(ARM_Jit); + MICROPROFILE_SCOPE(ARM_Jit_Unicorn); CHECKED(uc_emu_start(uc, GetPC(), 1ULL << 63, 0, num_instructions)); CoreTiming::AddTicks(num_instructions); if (GDBStub::IsServerEnabled()) { diff --git a/src/core/core.cpp b/src/core/core.cpp index 2cfae18df..29983b9b4 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -14,6 +14,9 @@ #include "core/core.h" #include "core/core_cpu.h" #include "core/core_timing.h" +#include "core/file_sys/mode.h" +#include "core/file_sys/vfs_concat.h" +#include "core/file_sys/vfs_real.h" #include "core/gdbstub/gdbstub.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/kernel.h" @@ -27,8 +30,6 @@ #include "core/perf_stats.h" #include "core/settings.h" #include "core/telemetry_session.h" -#include "file_sys/vfs_concat.h" -#include "file_sys/vfs_real.h" #include "video_core/debug_utils/debug_utils.h" #include "video_core/gpu.h" #include "video_core/renderer_base.h" diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 0b6c07de8..f768533da 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -8,12 +8,15 @@ #include <locale> #include <sstream> #include <string_view> +#include <tuple> +#include <vector> #include "common/common_paths.h" #include "common/file_util.h" #include "common/hex_util.h" #include "common/logging/log.h" #include "core/crypto/aes_util.h" #include "core/crypto/key_manager.h" +#include "core/loader/loader.h" #include "core/settings.h" namespace Core::Crypto { diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index 7ca3e6cbc..bf51bf31f 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -6,13 +6,14 @@ #include <array> #include <string> -#include <string_view> -#include <type_traits> -#include <vector> #include <boost/container/flat_map.hpp> +#include <boost/optional.hpp> #include <fmt/format.h> #include "common/common_types.h" -#include "core/loader/loader.h" + +namespace Loader { +enum class ResultStatus : u16; +} namespace Core::Crypto { diff --git a/src/core/file_sys/bis_factory.cpp b/src/core/file_sys/bis_factory.cpp index 08a7cea5a..205492897 100644 --- a/src/core/file_sys/bis_factory.cpp +++ b/src/core/file_sys/bis_factory.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "core/file_sys/bis_factory.h" +#include "core/file_sys/registered_cache.h" namespace FileSys { @@ -13,6 +14,8 @@ BISFactory::BISFactory(VirtualDir nand_root_) usrnand_cache(std::make_shared<RegisteredCache>( GetOrCreateDirectoryRelative(nand_root, "/user/Contents/registered"))) {} +BISFactory::~BISFactory() = default; + std::shared_ptr<RegisteredCache> BISFactory::GetSystemNANDContents() const { return sysnand_cache; } diff --git a/src/core/file_sys/bis_factory.h b/src/core/file_sys/bis_factory.h index a970a5e2e..9523dd864 100644 --- a/src/core/file_sys/bis_factory.h +++ b/src/core/file_sys/bis_factory.h @@ -5,17 +5,20 @@ #pragma once #include <memory> -#include "core/loader/loader.h" -#include "registered_cache.h" + +#include "core/file_sys/vfs.h" namespace FileSys { +class RegisteredCache; + /// File system interface to the Built-In Storage /// This is currently missing accessors to BIS partitions, but seemed like a good place for the NAND /// registered caches. class BISFactory { public: explicit BISFactory(VirtualDir nand_root); + ~BISFactory(); std::shared_ptr<RegisteredCache> GetSystemNANDContents() const; std::shared_ptr<RegisteredCache> GetUserNANDContents() const; diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp index d61a2ebe1..ce4423fa6 100644 --- a/src/core/file_sys/card_image.cpp +++ b/src/core/file_sys/card_image.cpp @@ -9,6 +9,7 @@ #include "common/logging/log.h" #include "core/file_sys/card_image.h" +#include "core/file_sys/content_archive.h" #include "core/file_sys/partition_filesystem.h" #include "core/file_sys/vfs_offset.h" #include "core/loader/loader.h" @@ -74,6 +75,8 @@ XCI::XCI(VirtualFile file_) : file(std::move(file_)), partitions(0x4) { status = Loader::ResultStatus::Success; } +XCI::~XCI() = default; + Loader::ResultStatus XCI::GetStatus() const { return status; } diff --git a/src/core/file_sys/card_image.h b/src/core/file_sys/card_image.h index 54ab828d1..4f104d18a 100644 --- a/src/core/file_sys/card_image.h +++ b/src/core/file_sys/card_image.h @@ -5,15 +5,21 @@ #pragma once #include <array> +#include <memory> #include <vector> #include "common/common_types.h" #include "common/swap.h" -#include "core/file_sys/content_archive.h" #include "core/file_sys/vfs.h" -#include "core/loader/loader.h" + +namespace Loader { +enum class ResultStatus : u16; +} namespace FileSys { +class NCA; +enum class NCAContentType : u8; + enum class GamecardSize : u8 { S_1GB = 0xFA, S_2GB = 0xF8, @@ -57,6 +63,7 @@ enum class XCIPartition : u8 { Update, Normal, Secure, Logo }; class XCI : public ReadOnlyVfsDirectory { public: explicit XCI(VirtualFile file); + ~XCI() override; Loader::ResultStatus GetStatus() const; Loader::ResultStatus GetProgramNCAStatus() const; diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index e8b5d6ece..7cfb6f36b 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp @@ -3,12 +3,16 @@ // Refer to the license.txt file included. #include <algorithm> +#include <cstring> #include <utility> + #include <boost/optional.hpp> + #include "common/logging/log.h" #include "core/crypto/aes_util.h" #include "core/crypto/ctr_encryption_layer.h" #include "core/file_sys/content_archive.h" +#include "core/file_sys/partition_filesystem.h" #include "core/file_sys/romfs.h" #include "core/file_sys/vfs_offset.h" #include "core/loader/loader.h" diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index b961cfde7..0ea666cac 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h @@ -12,10 +12,12 @@ #include "common/common_funcs.h" #include "common/common_types.h" #include "common/swap.h" -#include "control_metadata.h" #include "core/crypto/key_manager.h" -#include "core/file_sys/partition_filesystem.h" -#include "core/loader/loader.h" +#include "core/file_sys/vfs.h" + +namespace Loader { +enum class ResultStatus : u16; +} namespace FileSys { diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index 8c2cc1a2a..1568046f1 100644 --- a/src/core/file_sys/control_metadata.h +++ b/src/core/file_sys/control_metadata.h @@ -8,6 +8,7 @@ #include <memory> #include <string> #include "common/common_funcs.h" +#include "common/common_types.h" #include "core/file_sys/vfs.h" namespace FileSys { diff --git a/src/core/file_sys/nca_metadata.cpp b/src/core/file_sys/nca_metadata.cpp index 449244444..cdfbc5aaf 100644 --- a/src/core/file_sys/nca_metadata.cpp +++ b/src/core/file_sys/nca_metadata.cpp @@ -3,10 +3,9 @@ // Refer to the license.txt file included. #include <cstring> -#include "common/common_funcs.h" +#include "common/common_types.h" #include "common/logging/log.h" #include "common/swap.h" -#include "content_archive.h" #include "core/file_sys/nca_metadata.h" namespace FileSys { diff --git a/src/core/file_sys/nca_metadata.h b/src/core/file_sys/nca_metadata.h index ce05b4c1d..da5a8dbe8 100644 --- a/src/core/file_sys/nca_metadata.h +++ b/src/core/file_sys/nca_metadata.h @@ -4,7 +4,6 @@ #pragma once -#include <cstring> #include <memory> #include <vector> #include "common/common_funcs.h" diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp index 279f987d4..ccb685526 100644 --- a/src/core/file_sys/program_metadata.cpp +++ b/src/core/file_sys/program_metadata.cpp @@ -2,7 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/file_util.h" +#include <cstddef> +#include <cstring> +#include <vector> + #include "common/logging/log.h" #include "core/file_sys/program_metadata.h" #include "core/loader/loader.h" diff --git a/src/core/file_sys/program_metadata.h b/src/core/file_sys/program_metadata.h index 74a91052b..3c0a49f16 100644 --- a/src/core/file_sys/program_metadata.h +++ b/src/core/file_sys/program_metadata.h @@ -5,12 +5,10 @@ #pragma once #include <array> -#include <string> -#include <vector> #include "common/bit_field.h" #include "common/common_types.h" #include "common/swap.h" -#include "partition_filesystem.h" +#include "core/file_sys/vfs.h" namespace Loader { enum class ResultStatus : u16; diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index dacf8568b..d9decc104 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -5,13 +5,16 @@ #include <regex> #include <mbedtls/sha256.h> #include "common/assert.h" +#include "common/file_util.h" #include "common/hex_util.h" #include "common/logging/log.h" -#include "core/crypto/encryption_layer.h" +#include "core/crypto/key_manager.h" #include "core/file_sys/card_image.h" +#include "core/file_sys/content_archive.h" #include "core/file_sys/nca_metadata.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/vfs_concat.h" +#include "core/loader/loader.h" namespace FileSys { std::string RegisteredCacheEntry::DebugInfo() const { diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 7b8955dfa..fe2cdc3d9 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -11,15 +11,18 @@ #include <string> #include <vector> #include <boost/container/flat_map.hpp> -#include "common/common_funcs.h" #include "common/common_types.h" -#include "content_archive.h" -#include "core/file_sys/nca_metadata.h" #include "core/file_sys/vfs.h" namespace FileSys { -class XCI; class CNMT; +class NCA; +class XCI; + +enum class ContentRecordType : u8; +enum class TitleType : u8; + +struct ContentRecord; using NcaID = std::array<u8, 0x10>; using RegisteredCacheParsingFunction = std::function<VirtualFile(const VirtualFile&, const NcaID&)>; diff --git a/src/core/file_sys/romfs.h b/src/core/file_sys/romfs.h index 03a876d22..e54a7d7a9 100644 --- a/src/core/file_sys/romfs.h +++ b/src/core/file_sys/romfs.h @@ -6,6 +6,7 @@ #include <array> #include "common/common_funcs.h" +#include "common/common_types.h" #include "common/swap.h" #include "core/file_sys/vfs.h" diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index eb4e6c865..66f9786e0 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp @@ -2,14 +2,13 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <algorithm> #include <memory> +#include "common/assert.h" #include "common/common_types.h" #include "common/logging/log.h" -#include "core/file_sys/nca_metadata.h" +#include "core/file_sys/content_archive.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/romfs_factory.h" -#include "core/hle/kernel/process.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/loader/loader.h" diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index 952bd74b3..e437d34e5 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include <memory> +#include "common/assert.h" #include "common/common_types.h" #include "common/logging/log.h" #include "core/core.h" diff --git a/src/core/file_sys/savedata_factory.h b/src/core/file_sys/savedata_factory.h index c6f9549f0..ba978695b 100644 --- a/src/core/file_sys/savedata_factory.h +++ b/src/core/file_sys/savedata_factory.h @@ -6,6 +6,7 @@ #include <memory> #include <string> +#include "common/common_funcs.h" #include "common/common_types.h" #include "common/swap.h" #include "core/file_sys/vfs.h" diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp index 2b8ac7103..89b101145 100644 --- a/src/core/file_sys/vfs_real.cpp +++ b/src/core/file_sys/vfs_real.cpp @@ -8,6 +8,7 @@ #include <utility> #include "common/assert.h" #include "common/common_paths.h" +#include "common/file_util.h" #include "common/logging/log.h" #include "core/file_sys/vfs_real.h" @@ -39,6 +40,7 @@ static std::string ModeFlagsToString(Mode mode) { } RealVfsFilesystem::RealVfsFilesystem() : VfsFilesystem(nullptr) {} +RealVfsFilesystem::~RealVfsFilesystem() = default; std::string RealVfsFilesystem::GetName() const { return "Real"; @@ -219,6 +221,8 @@ RealVfsFile::RealVfsFile(RealVfsFilesystem& base_, std::shared_ptr<FileUtil::IOF parent_components(FileUtil::SliceVector(path_components, 0, path_components.size() - 1)), perms(perms_) {} +RealVfsFile::~RealVfsFile() = default; + std::string RealVfsFile::GetName() const { return path_components.back(); } @@ -312,6 +316,8 @@ RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string& FileUtil::CreateDir(path); } +RealVfsDirectory::~RealVfsDirectory() = default; + std::shared_ptr<VfsFile> RealVfsDirectory::GetFileRelative(std::string_view path) const { const auto full_path = FileUtil::SanitizePath(this->path + DIR_SEP + std::string(path)); if (!FileUtil::Exists(full_path) || FileUtil::IsDirectory(full_path)) diff --git a/src/core/file_sys/vfs_real.h b/src/core/file_sys/vfs_real.h index 989803d43..7db86691f 100644 --- a/src/core/file_sys/vfs_real.h +++ b/src/core/file_sys/vfs_real.h @@ -6,15 +6,19 @@ #include <string_view> #include <boost/container/flat_map.hpp> -#include "common/file_util.h" #include "core/file_sys/mode.h" #include "core/file_sys/vfs.h" +namespace FileUtil { +class IOFile; +} + namespace FileSys { class RealVfsFilesystem : public VfsFilesystem { public: RealVfsFilesystem(); + ~RealVfsFilesystem() override; std::string GetName() const override; bool IsReadable() const override; @@ -40,10 +44,9 @@ class RealVfsFile : public VfsFile { friend class RealVfsDirectory; friend class RealVfsFilesystem; - RealVfsFile(RealVfsFilesystem& base, std::shared_ptr<FileUtil::IOFile> backing, - const std::string& path, Mode perms = Mode::Read); - public: + ~RealVfsFile() override; + std::string GetName() const override; size_t GetSize() const override; bool Resize(size_t new_size) override; @@ -55,6 +58,9 @@ public: bool Rename(std::string_view name) override; private: + RealVfsFile(RealVfsFilesystem& base, std::shared_ptr<FileUtil::IOFile> backing, + const std::string& path, Mode perms = Mode::Read); + bool Close(); RealVfsFilesystem& base; @@ -70,9 +76,9 @@ private: class RealVfsDirectory : public VfsDirectory { friend class RealVfsFilesystem; - RealVfsDirectory(RealVfsFilesystem& base, const std::string& path, Mode perms = Mode::Read); - public: + ~RealVfsDirectory() override; + std::shared_ptr<VfsFile> GetFileRelative(std::string_view path) const override; std::shared_ptr<VfsDirectory> GetDirectoryRelative(std::string_view path) const override; std::shared_ptr<VfsFile> GetFile(std::string_view name) const override; @@ -97,6 +103,8 @@ protected: bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override; private: + RealVfsDirectory(RealVfsFilesystem& base, const std::string& path, Mode perms = Mode::Read); + template <typename T, typename R> std::vector<std::shared_ptr<R>> IterateEntries() const; diff --git a/src/core/file_sys/xts_archive.cpp b/src/core/file_sys/xts_archive.cpp index 552835738..4dbc25c55 100644 --- a/src/core/file_sys/xts_archive.cpp +++ b/src/core/file_sys/xts_archive.cpp @@ -10,6 +10,7 @@ #include <mbedtls/md.h> #include <mbedtls/sha256.h> #include "common/assert.h" +#include "common/file_util.h" #include "common/hex_util.h" #include "common/logging/log.h" #include "core/crypto/aes_util.h" diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 615d7901a..7902c2882 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -13,6 +13,7 @@ #include "core/core.h" #include "core/core_timing.h" +#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" @@ -124,6 +125,8 @@ struct KernelCore::Impl { timer_callback_handle_table.Clear(); timer_callback_event_type = nullptr; + + named_ports.clear(); } void InitializeResourceLimits(KernelCore& kernel) { @@ -217,6 +220,10 @@ struct KernelCore::Impl { // TODO(yuriks): This can be removed if Thread objects are explicitly pooled in the future, // allowing us to simply use a pool index or similar. Kernel::HandleTable thread_wakeup_callback_handle_table; + + /// Map of named ports managed by the kernel, which can be retrieved using + /// the ConnectToPort SVC. + NamedPortTable named_ports; }; KernelCore::KernelCore() : impl{std::make_unique<Impl>()} {} @@ -257,6 +264,23 @@ void KernelCore::AppendNewProcess(SharedPtr<Process> process) { impl->process_list.push_back(std::move(process)); } +void KernelCore::AddNamedPort(std::string name, SharedPtr<ClientPort> port) { + impl->named_ports.emplace(std::move(name), std::move(port)); +} + +KernelCore::NamedPortTable::iterator KernelCore::FindNamedPort(const std::string& name) { + return impl->named_ports.find(name); +} + +KernelCore::NamedPortTable::const_iterator KernelCore::FindNamedPort( + const std::string& name) const { + return impl->named_ports.find(name); +} + +bool KernelCore::IsValidNamedPort(NamedPortTable::const_iterator port) const { + return port != impl->named_ports.cend(); +} + u32 KernelCore::CreateNewObjectID() { return impl->next_object_id++; } diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 089e959ac..ab2e9bffa 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -4,6 +4,8 @@ #pragma once +#include <string> +#include <unordered_map> #include "core/hle/kernel/object.h" template <typename T> @@ -15,6 +17,7 @@ struct EventType; namespace Kernel { +class ClientPort; class HandleTable; class Process; class ResourceLimit; @@ -25,6 +28,9 @@ enum class ResourceLimitCategory : u8; /// Represents a single instance of the kernel. class KernelCore { +private: + using NamedPortTable = std::unordered_map<std::string, SharedPtr<ClientPort>>; + public: KernelCore(); ~KernelCore(); @@ -59,6 +65,18 @@ public: /// Adds the given shared pointer to an internal list of active processes. void AppendNewProcess(SharedPtr<Process> process); + /// Adds a port to the named port table + void AddNamedPort(std::string name, SharedPtr<ClientPort> port); + + /// Finds a port within the named port table with the given name. + NamedPortTable::iterator FindNamedPort(const std::string& name); + + /// Finds a port within the named port table with the given name. + NamedPortTable::const_iterator FindNamedPort(const std::string& name) const; + + /// Determines whether or not the given port is a valid named port. + bool IsValidNamedPort(NamedPortTable::const_iterator port) const; + private: friend class Object; friend class Process; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 5da71cff0..1c9373ed8 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -68,19 +68,22 @@ static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { /// Connect to an OS service given the port name, returns the handle to the port to out static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address) { - if (!Memory::IsValidVirtualAddress(port_name_address)) + if (!Memory::IsValidVirtualAddress(port_name_address)) { return ERR_NOT_FOUND; + } static constexpr std::size_t PortNameMaxLength = 11; // Read 1 char beyond the max allowed port name to detect names that are too long. std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); - if (port_name.size() > PortNameMaxLength) + if (port_name.size() > PortNameMaxLength) { return ERR_PORT_NAME_TOO_LONG; + } LOG_TRACE(Kernel_SVC, "called port_name={}", port_name); - auto it = Service::g_kernel_named_ports.find(port_name); - if (it == Service::g_kernel_named_ports.end()) { + auto& kernel = Core::System::GetInstance().Kernel(); + auto it = kernel.FindNamedPort(port_name); + if (!kernel.IsValidNamedPort(it)) { LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name); return ERR_NOT_FOUND; } @@ -91,7 +94,6 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address CASCADE_RESULT(client_session, client_port->Connect()); // Return the client session - auto& kernel = Core::System::GetInstance().Kernel(); CASCADE_RESULT(*out_handle, kernel.HandleTable().Create(client_session)); return RESULT_SUCCESS; } diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index 51638793d..878bbe439 100644 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp @@ -5,7 +5,9 @@ #include "common/common_paths.h" #include "common/file_util.h" #include "core/core.h" -#include "core/file_sys/bis_factory.h" +#include "core/file_sys/content_archive.h" +#include "core/file_sys/nca_metadata.h" +#include "core/file_sys/registered_cache.h" #include "core/file_sys/romfs.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/filesystem/filesystem.h" diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 8fb907072..9d804652e 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -12,6 +12,7 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/handle_table.h" +#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/server_port.h" #include "core/hle/kernel/thread.h" @@ -114,7 +115,7 @@ void ServiceFrameworkBase::InstallAsNamedPort() { std::tie(server_port, client_port) = ServerPort::CreatePortPair(kernel, max_sessions, service_name); server_port->SetHleHandler(shared_from_this()); - AddNamedPort(service_name, std::move(client_port)); + kernel.AddNamedPort(service_name, std::move(client_port)); } Kernel::SharedPtr<Kernel::ClientPort> ServiceFrameworkBase::CreatePort() { @@ -197,11 +198,6 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co //////////////////////////////////////////////////////////////////////////////////////////////////// // Module interface -// TODO(yuriks): Move to kernel -void AddNamedPort(std::string name, SharedPtr<ClientPort> port) { - g_kernel_named_ports.emplace(std::move(name), std::move(port)); -} - /// Initialize ServiceManager void Init(std::shared_ptr<SM::ServiceManager>& sm, const FileSys::VirtualFilesystem& rfs) { // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it @@ -264,7 +260,6 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, const FileSys::VirtualFilesys /// Shutdown ServiceManager void Shutdown() { - g_kernel_named_ports.clear(); LOG_DEBUG(Service, "shutdown OK"); } } // namespace Service diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index cd9c74f3d..7a051523e 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -6,7 +6,6 @@ #include <cstddef> #include <string> -#include <unordered_map> #include <boost/container/flat_map.hpp> #include "common/common_types.h" #include "core/hle/kernel/hle_ipc.h" @@ -187,10 +186,4 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, /// Shutdown ServiceManager void Shutdown(); -/// Map of named ports managed by the kernel, which can be retrieved using the ConnectToPort SVC. -extern std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> g_kernel_named_ports; - -/// Adds a port to the named port table -void AddNamedPort(std::string name, Kernel::SharedPtr<Kernel::ClientPort> port); - } // namespace Service diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 40aea6090..63b86e099 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp @@ -3,6 +3,9 @@ // Refer to the license.txt file included. #include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/hle_ipc.h" +#include "core/hle/service/service.h" +#include "core/hle/service/sm/sm.h" #include "core/hle/service/ssl/ssl.h" namespace Service::SSL { @@ -81,36 +84,43 @@ private: } }; -void SSL::CreateContext(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_SSL, "(STUBBED) called"); +class SSL final : public ServiceFramework<SSL> { +public: + explicit SSL() : ServiceFramework{"ssl"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, &SSL::CreateContext, "CreateContext"}, + {1, nullptr, "GetContextCount"}, + {2, nullptr, "GetCertificates"}, + {3, nullptr, "GetCertificateBufSize"}, + {4, nullptr, "DebugIoctl"}, + {5, &SSL::SetInterfaceVersion, "SetInterfaceVersion"}, + {6, nullptr, "FlushSessionCache"}, + }; + // clang-format on - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<ISslContext>(); -} + RegisterHandlers(functions); + } -SSL::SSL() : ServiceFramework("ssl") { - static const FunctionInfo functions[] = { - {0, &SSL::CreateContext, "CreateContext"}, - {1, nullptr, "GetContextCount"}, - {2, nullptr, "GetCertificates"}, - {3, nullptr, "GetCertificateBufSize"}, - {4, nullptr, "DebugIoctl"}, - {5, &SSL::SetInterfaceVersion, "SetInterfaceVersion"}, - {6, nullptr, "FlushSessionCache"}, - }; - RegisterHandlers(functions); -} +private: + void CreateContext(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_SSL, "(STUBBED) called"); -void SSL::SetInterfaceVersion(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_SSL, "(STUBBED) called"); - IPC::RequestParser rp{ctx}; - u32 unk1 = rp.Pop<u32>(); // Probably minor/major? - u32 unk2 = rp.Pop<u32>(); // TODO(ogniK): Figure out what this does + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface<ISslContext>(); + } - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(RESULT_SUCCESS); -} + void SetInterfaceVersion(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_SSL, "(STUBBED) called"); + IPC::RequestParser rp{ctx}; + u32 unk1 = rp.Pop<u32>(); // Probably minor/major? + u32 unk2 = rp.Pop<u32>(); // TODO(ogniK): Figure out what this does + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + } +}; void InstallInterfaces(SM::ServiceManager& service_manager) { std::make_shared<SSL>()->InstallAsService(service_manager); diff --git a/src/core/hle/service/ssl/ssl.h b/src/core/hle/service/ssl/ssl.h index 8fef13022..5cb04c3b9 100644 --- a/src/core/hle/service/ssl/ssl.h +++ b/src/core/hle/service/ssl/ssl.h @@ -4,20 +4,12 @@ #pragma once -#include "core/hle/service/service.h" +namespace Service::SM { +class ServiceManager; +} namespace Service::SSL { -class SSL final : public ServiceFramework<SSL> { -public: - explicit SSL(); - ~SSL() = default; - -private: - void CreateContext(Kernel::HLERequestContext& ctx); - void SetInterfaceVersion(Kernel::HLERequestContext& ctx); -}; - /// Registers all SSL services with the specified service manager. void InstallInterfaces(SM::ServiceManager& service_manager); diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index c13fb49b8..5980cdb25 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -5,9 +5,9 @@ #include <memory> #include <ostream> #include <string> +#include "common/file_util.h" #include "common/logging/log.h" #include "common/string_util.h" -#include "core/file_sys/vfs_real.h" #include "core/hle/kernel/process.h" #include "core/loader/deconstructed_rom_directory.h" #include "core/loader/elf.h" @@ -144,6 +144,9 @@ std::ostream& operator<<(std::ostream& os, ResultStatus status) { return os; } +AppLoader::AppLoader(FileSys::VirtualFile file) : file(std::move(file)) {} +AppLoader::~AppLoader() = default; + /** * Get a loader for a file with a specific type * @param file The file to load diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 885fee84c..5a8540b0e 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -4,7 +4,6 @@ #pragma once -#include <algorithm> #include <iosfwd> #include <memory> #include <string> @@ -12,7 +11,6 @@ #include <vector> #include <boost/optional.hpp> #include "common/common_types.h" -#include "common/file_util.h" #include "core/file_sys/vfs.h" #include "core/hle/kernel/object.h" @@ -114,8 +112,8 @@ std::ostream& operator<<(std::ostream& os, ResultStatus status); /// Interface for loading an application class AppLoader : NonCopyable { public: - explicit AppLoader(FileSys::VirtualFile file) : file(std::move(file)) {} - virtual ~AppLoader() {} + explicit AppLoader(FileSys::VirtualFile file); + virtual ~AppLoader(); /** * Returns the type of this file diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 7ce969f73..e260c9140 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -33,10 +33,13 @@ using PixelFormat = SurfaceParams::PixelFormat; using SurfaceType = SurfaceParams::SurfaceType; MICROPROFILE_DEFINE(OpenGL_VAO, "OpenGL", "Vertex Array Setup", MP_RGB(128, 128, 192)); -MICROPROFILE_DEFINE(OpenGL_VS, "OpenGL", "Vertex Shader Setup", MP_RGB(128, 128, 192)); -MICROPROFILE_DEFINE(OpenGL_FS, "OpenGL", "Fragment Shader Setup", MP_RGB(128, 128, 192)); +MICROPROFILE_DEFINE(OpenGL_Shader, "OpenGL", "Shader Setup", MP_RGB(128, 128, 192)); +MICROPROFILE_DEFINE(OpenGL_UBO, "OpenGL", "Const Buffer Setup", MP_RGB(128, 128, 192)); +MICROPROFILE_DEFINE(OpenGL_Index, "OpenGL", "Index Buffer Setup", MP_RGB(128, 128, 192)); +MICROPROFILE_DEFINE(OpenGL_Texture, "OpenGL", "Texture Setup", MP_RGB(128, 128, 192)); +MICROPROFILE_DEFINE(OpenGL_Framebuffer, "OpenGL", "Framebuffer Setup", MP_RGB(128, 128, 192)); MICROPROFILE_DEFINE(OpenGL_Drawing, "OpenGL", "Drawing", MP_RGB(128, 128, 192)); -MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(100, 100, 255)); +MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(128, 128, 192)); MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100)); RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, ScreenInfo& info) @@ -179,6 +182,7 @@ std::pair<u8*, GLintptr> RasterizerOpenGL::SetupVertexArrays(u8* array_ptr, } std::pair<u8*, GLintptr> RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset) { + MICROPROFILE_SCOPE(OpenGL_Shader); auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); // Next available bindpoints to use when uploading the const buffers and textures to the GLSL @@ -312,6 +316,7 @@ void RasterizerOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { std::pair<Surface, Surface> RasterizerOpenGL::ConfigureFramebuffers(bool using_color_fb, bool using_depth_fb, bool preserve_contents) { + MICROPROFILE_SCOPE(OpenGL_Framebuffer); const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; if (regs.rt[0].format == Tegra::RenderTargetFormat::NONE) { @@ -512,6 +517,7 @@ void RasterizerOpenGL::DrawArrays() { // If indexed mode, copy the index buffer GLintptr index_buffer_offset = 0; if (is_indexed) { + MICROPROFILE_SCOPE(OpenGL_Index); std::tie(buffer_ptr, buffer_offset, index_buffer_offset) = UploadMemory( buffer_ptr, buffer_offset, regs.index_array.StartAddress(), index_buffer_size); } @@ -657,6 +663,7 @@ std::tuple<u8*, GLintptr, u32> RasterizerOpenGL::SetupConstBuffers(u8* buffer_pt Maxwell::ShaderStage stage, Shader& shader, u32 current_bindpoint) { + MICROPROFILE_SCOPE(OpenGL_UBO); const auto& gpu = Core::System::GetInstance().GPU(); const auto& maxwell3d = gpu.Maxwell3D(); const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<size_t>(stage)]; @@ -712,6 +719,7 @@ std::tuple<u8*, GLintptr, u32> RasterizerOpenGL::SetupConstBuffers(u8* buffer_pt } u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, Shader& shader, u32 current_unit) { + MICROPROFILE_SCOPE(OpenGL_Texture); const auto& gpu = Core::System::GetInstance().GPU(); const auto& maxwell3d = gpu.Maxwell3D(); const auto& entries = shader->GetShaderEntries().texture_samplers; diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index c4e7e1e3b..d3e8f5078 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -441,7 +441,7 @@ public: declarations.AddNewLine(); // Append the sampler2D array for the used textures. - size_t num_samplers = GetSamplers().size(); + const size_t num_samplers = used_samplers.size(); if (num_samplers > 0) { declarations.AddLine("uniform sampler2D " + SamplerEntry::GetArrayName(stage) + '[' + std::to_string(num_samplers) + "];"); diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index d15242d59..71953cee3 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -13,13 +13,14 @@ #include <QKeyEvent> #include <QMenu> #include <QThreadPool> -#include <boost/container/flat_map.hpp> #include <fmt/format.h> #include "common/common_paths.h" +#include "common/common_types.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/file_sys/control_metadata.h" +#include "core/file_sys/nca_metadata.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/romfs.h" #include "core/file_sys/vfs_real.h" diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index 6a5c2f5f8..84731464a 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h @@ -20,6 +20,8 @@ #include <QVBoxLayout> #include <QWidget> +#include "common/common_types.h" + class GameListWorker; class GMainWindow; diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 3624cb21a..4ddd8cd88 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -4,18 +4,23 @@ #pragma once +#include <algorithm> #include <array> #include <atomic> #include <map> #include <memory> +#include <string> #include <unordered_map> #include <utility> + #include <QCoreApplication> #include <QImage> #include <QObject> #include <QRunnable> #include <QStandardItem> #include <QString> + +#include "common/common_types.h" #include "common/logging/log.h" #include "common/string_util.h" #include "yuzu/ui_settings.h" diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index a21f7bdbc..262e33487 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -19,6 +19,7 @@ #include <QtWidgets> #include <fmt/format.h> #include "common/common_paths.h" +#include "common/file_util.h" #include "common/logging/backend.h" #include "common/logging/filter.h" #include "common/logging/log.h" @@ -30,6 +31,7 @@ #include "core/core.h" #include "core/crypto/key_manager.h" #include "core/file_sys/card_image.h" +#include "core/file_sys/content_archive.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/savedata_factory.h" #include "core/file_sys/vfs_real.h" diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 56b592a9e..089ea2445 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -6,8 +6,11 @@ #include <memory> #include <unordered_map> + #include <QMainWindow> #include <QTimer> + +#include "common/common_types.h" #include "core/core.h" #include "ui_main.h" #include "yuzu/hotkeys.h" diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 41e7da897..173ac0e0f 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -10,6 +10,7 @@ #include <fmt/ostream.h> #include "common/common_paths.h" +#include "common/file_util.h" #include "common/logging/backend.h" #include "common/logging/filter.h" #include "common/logging/log.h" |