diff options
128 files changed, 1602 insertions, 1278 deletions
diff --git a/src/audio_core/audio_out.cpp b/src/audio_core/audio_out.cpp index 0cabaa354..3dfdf61f9 100644 --- a/src/audio_core/audio_out.cpp +++ b/src/audio_core/audio_out.cpp @@ -39,7 +39,7 @@ StreamPtr AudioOut::OpenStream(u32 sample_rate, u32 num_channels, sink->AcquireSinkStream(sample_rate, num_channels)); } -std::vector<u64> AudioOut::GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count) { +std::vector<Buffer::Tag> AudioOut::GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count) { return stream->GetTagsAndReleaseBuffers(max_count); } diff --git a/src/audio_core/audio_out.h b/src/audio_core/audio_out.h index 8d9b695d4..95e9b53fe 100644 --- a/src/audio_core/audio_out.h +++ b/src/audio_core/audio_out.h @@ -24,7 +24,7 @@ public: Stream::ReleaseCallback&& release_callback); /// Returns a vector of recently released buffers specified by tag for the specified stream - std::vector<u64> GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count); + std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count); /// Starts an audio stream for playback void StartStream(StreamPtr stream); diff --git a/src/audio_core/sink_details.h b/src/audio_core/sink_details.h index aa8aae1a9..ea666c554 100644 --- a/src/audio_core/sink_details.h +++ b/src/audio_core/sink_details.h @@ -6,6 +6,7 @@ #include <functional> #include <memory> +#include <utility> #include <vector> namespace AudioCore { @@ -13,16 +14,18 @@ namespace AudioCore { class Sink; struct SinkDetails { - SinkDetails(const char* id_, std::function<std::unique_ptr<Sink>(std::string)> factory_, - std::function<std::vector<std::string>()> list_devices_) - : id(id_), factory(factory_), list_devices(list_devices_) {} + using FactoryFn = std::function<std::unique_ptr<Sink>(std::string)>; + using ListDevicesFn = std::function<std::vector<std::string>()>; + + SinkDetails(const char* id_, FactoryFn factory_, ListDevicesFn list_devices_) + : id(id_), factory(std::move(factory_)), list_devices(std::move(list_devices_)) {} /// Name for this sink. const char* id; /// A method to call to construct an instance of this type of sink. - std::function<std::unique_ptr<Sink>(std::string device_id)> factory; + FactoryFn factory; /// A method to call to list available devices. - std::function<std::vector<std::string>()> list_devices; + ListDevicesFn list_devices; }; extern const std::vector<SinkDetails> g_sink_details; diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index d7d2f9a20..34dec06fe 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -169,7 +169,9 @@ void FileBackend::Write(const Entry& entry) { SUB(Service, AOC) \ SUB(Service, APM) \ SUB(Service, BCAT) \ + SUB(Service, BPC) \ SUB(Service, BTM) \ + SUB(Service, Capture) \ SUB(Service, Fatal) \ SUB(Service, FGM) \ SUB(Service, Friend) \ @@ -178,6 +180,7 @@ void FileBackend::Write(const Entry& entry) { SUB(Service, LBL) \ SUB(Service, LDN) \ SUB(Service, LM) \ + SUB(Service, Migration) \ SUB(Service, Mii) \ SUB(Service, MM) \ SUB(Service, NCM) \ @@ -188,7 +191,9 @@ void FileBackend::Write(const Entry& entry) { SUB(Service, NVDRV) \ SUB(Service, PCIE) \ SUB(Service, PCTL) \ + SUB(Service, PCV) \ SUB(Service, PREPO) \ + SUB(Service, PSC) \ SUB(Service, SET) \ SUB(Service, SM) \ SUB(Service, SPL) \ diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 5a580b004..dd5c9e6be 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -56,7 +56,9 @@ enum class Class : ClassType { Service_APM, ///< The APM (Performance) service Service_Audio, ///< The Audio (Audio control) service Service_BCAT, ///< The BCAT service + Service_BPC, ///< The BPC service Service_BTM, ///< The BTM service + Service_Capture, ///< The capture service Service_Fatal, ///< The Fatal service Service_FGM, ///< The FGM service Service_Friend, ///< The friend service @@ -65,6 +67,7 @@ enum class Class : ClassType { Service_LBL, ///< The LBL (LCD backlight) service Service_LDN, ///< The LDN (Local domain network) service Service_LM, ///< The LM (Logger) service + Service_Migration, ///< The migration service Service_Mii, ///< The Mii service Service_MM, ///< The MM (Multimedia) service Service_NCM, ///< The NCM service @@ -75,7 +78,9 @@ enum class Class : ClassType { Service_NVDRV, ///< The NVDRV (Nvidia driver) service Service_PCIE, ///< The PCIe service Service_PCTL, ///< The PCTL (Parental control) service + Service_PCV, ///< The PCV service Service_PREPO, ///< The PREPO (Play report) service + Service_PSC, ///< The PSC service Service_SET, ///< The SET (Settings) service Service_SM, ///< The SM (Service manager) service Service_SPL, ///< The SPL service diff --git a/src/common/math_util.h b/src/common/math_util.h index c6a83c953..343cdd902 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -19,12 +19,12 @@ inline bool IntervalsIntersect(unsigned start0, unsigned length0, unsigned start template <class T> struct Rectangle { - T left; - T top; - T right; - T bottom; + T left{}; + T top{}; + T right{}; + T bottom{}; - Rectangle() {} + Rectangle() = default; Rectangle(T left, T top, T right, T bottom) : left(left), top(top), right(right), bottom(bottom) {} diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 22fad97a3..28de22398 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -73,10 +73,10 @@ add_library(core STATIC hle/kernel/hle_ipc.h hle/kernel/kernel.cpp hle/kernel/kernel.h - hle/kernel/memory.cpp - hle/kernel/memory.h hle/kernel/mutex.cpp hle/kernel/mutex.h + hle/kernel/object.cpp + hle/kernel/object.h hle/kernel/process.cpp hle/kernel/process.h hle/kernel/resource_limit.cpp @@ -164,10 +164,14 @@ add_library(core STATIC hle/service/bcat/bcat.h hle/service/bcat/module.cpp hle/service/bcat/module.h + hle/service/bpc/bpc.cpp + hle/service/bpc/bpc.h hle/service/btdrv/btdrv.cpp hle/service/btdrv/btdrv.h hle/service/btm/btm.cpp hle/service/btm/btm.h + hle/service/caps/caps.cpp + hle/service/caps/caps.h hle/service/erpt/erpt.cpp hle/service/erpt/erpt.h hle/service/es/es.cpp @@ -182,6 +186,10 @@ add_library(core STATIC hle/service/fatal/fatal_u.h hle/service/filesystem/filesystem.cpp hle/service/filesystem/filesystem.h + hle/service/filesystem/fsp_ldr.cpp + hle/service/filesystem/fsp_ldr.h + hle/service/filesystem/fsp_pr.cpp + hle/service/filesystem/fsp_pr.h hle/service/filesystem/fsp_srv.cpp hle/service/filesystem/fsp_srv.h hle/service/fgm/fgm.cpp @@ -206,6 +214,8 @@ add_library(core STATIC hle/service/ldr/ldr.h hle/service/lm/lm.cpp hle/service/lm/lm.h + hle/service/mig/mig.cpp + hle/service/mig/mig.h hle/service/mii/mii.cpp hle/service/mii/mii.h hle/service/mm/mm_u.cpp @@ -257,10 +267,14 @@ add_library(core STATIC hle/service/pctl/module.h hle/service/pctl/pctl.cpp hle/service/pctl/pctl.h + hle/service/pcv/pcv.cpp + hle/service/pcv/pcv.h hle/service/pm/pm.cpp hle/service/pm/pm.h hle/service/prepo/prepo.cpp hle/service/prepo/prepo.h + hle/service/psc/psc.cpp + hle/service/psc/psc.h hle/service/service.cpp hle/service/service.h hle/service/set/set.cpp @@ -309,10 +323,6 @@ add_library(core STATIC hle/service/vi/vi_u.h hle/service/wlan/wlan.cpp hle/service/wlan/wlan.h - hw/hw.cpp - hw/hw.h - hw/lcd.cpp - hw/lcd.h loader/deconstructed_rom_directory.cpp loader/deconstructed_rom_directory.h loader/elf.cpp diff --git a/src/core/core.cpp b/src/core/core.cpp index 0ef6af3fe..e51e66550 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -15,9 +15,7 @@ #include "core/hle/service/service.h" #include "core/hle/service/sm/controller.h" #include "core/hle/service/sm/sm.h" -#include "core/hw/hw.h" #include "core/loader/loader.h" -#include "core/memory_setup.h" #include "core/settings.h" #include "file_sys/vfs_real.h" #include "video_core/video_core.h" @@ -86,7 +84,7 @@ System::ResultStatus System::SingleStep() { return RunLoop(false); } -System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& filepath) { +System::ResultStatus System::Load(EmuWindow& emu_window, const std::string& filepath) { app_loader = Loader::GetLoader(std::make_shared<FileSys::RealVfsFile>(filepath)); if (!app_loader) { @@ -114,7 +112,7 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file } } - ResultStatus init_result{Init(emu_window, system_mode.first.get())}; + ResultStatus init_result{Init(emu_window)}; if (init_result != ResultStatus::Success) { LOG_CRITICAL(Core, "Failed to initialize system (Error {})!", static_cast<int>(init_result)); @@ -167,7 +165,7 @@ Cpu& System::CpuCore(size_t core_index) { return *cpu_cores[core_index]; } -System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { +System::ResultStatus System::Init(EmuWindow& emu_window) { LOG_DEBUG(HW_Memory, "initialized OK"); CoreTiming::Init(); @@ -184,8 +182,7 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { telemetry_session = std::make_unique<Core::TelemetrySession>(); service_manager = std::make_shared<Service::SM::ServiceManager>(); - HW::Init(); - Kernel::Init(system_mode); + Kernel::Init(); Service::Init(service_manager); GDBStub::Init(); @@ -228,7 +225,6 @@ void System::Shutdown() { GDBStub::Shutdown(); Service::Shutdown(); Kernel::Shutdown(); - HW::Shutdown(); service_manager.reset(); telemetry_session.reset(); gpu_core.reset(); diff --git a/src/core/core.h b/src/core/core.h index a90bff3df..4c9967559 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -11,7 +11,7 @@ #include "common/common_types.h" #include "core/arm/exclusive_monitor.h" #include "core/core_cpu.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/scheduler.h" #include "core/loader/loader.h" #include "core/memory.h" @@ -83,11 +83,12 @@ public: /** * Load an executable application. - * @param emu_window Pointer to the host-system window used for video output and keyboard input. + * @param emu_window Reference to the host-system window used for video output and keyboard + * input. * @param filepath String path to the executable application to load on the host file system. * @returns ResultStatus code, indicating if the operation succeeded. */ - ResultStatus Load(EmuWindow* emu_window, const std::string& filepath); + ResultStatus Load(EmuWindow& emu_window, const std::string& filepath); /** * Indicates if the emulated system is powered on (all subsystems initialized and able to run an @@ -188,11 +189,11 @@ private: /** * Initialize the emulated system. - * @param emu_window Pointer to the host-system window used for video output and keyboard input. - * @param system_mode The system mode. + * @param emu_window Reference to the host-system window used for video output and keyboard + * input. * @return ResultStatus code, indicating if the operation succeeded. */ - ResultStatus Init(EmuWindow* emu_window, u32 system_mode); + ResultStatus Init(EmuWindow& emu_window); /// AppLoader used to load the current executing application std::unique_ptr<Loader::AppLoader> app_loader; diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index 54e15a701..46a522fcd 100644 --- a/src/core/core_cpu.cpp +++ b/src/core/core_cpu.cpp @@ -12,7 +12,6 @@ #include "core/arm/unicorn/arm_unicorn.h" #include "core/core_cpu.h" #include "core/core_timing.h" -#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/scheduler.h" #include "core/hle/kernel/thread.h" #include "core/settings.h" diff --git a/src/core/file_sys/vfs_vector.cpp b/src/core/file_sys/vfs_vector.cpp index 4c6337e3a..fda603960 100644 --- a/src/core/file_sys/vfs_vector.cpp +++ b/src/core/file_sys/vfs_vector.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include <algorithm> +#include <utility> #include "core/file_sys/vfs_vector.h" namespace FileSys { @@ -31,16 +32,18 @@ bool VectorVfsDirectory::IsReadable() const { std::string VectorVfsDirectory::GetName() const { return name; } + std::shared_ptr<VfsDirectory> VectorVfsDirectory::GetParentDirectory() const { return parent; } template <typename T> static bool FindAndRemoveVectorElement(std::vector<T>& vec, std::string_view name) { - auto iter = std::find_if(vec.begin(), vec.end(), [name](T e) { return e->GetName() == name; }); + const auto iter = + std::find_if(vec.begin(), vec.end(), [name](const T& e) { return e->GetName() == name; }); if (iter == vec.end()) return false; - auto old_size = vec.size(); + vec.erase(iter); return true; } @@ -77,7 +80,7 @@ void VectorVfsDirectory::AddDirectory(VirtualDir dir) { bool VectorVfsDirectory::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) { if (!DeleteFile(file->GetName())) return false; - dirs.emplace_back(dir); + dirs.emplace_back(std::move(dir)); return true; } } // namespace FileSys diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 5ca573652..75f6b8235 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -37,7 +37,6 @@ #include "core/core.h" #include "core/core_cpu.h" #include "core/gdbstub/gdbstub.h" -#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/scheduler.h" #include "core/loader/loader.h" #include "core/memory.h" diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 7fb0da408..d3a734831 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -5,15 +5,18 @@ #pragma once #include <array> +#include <cstring> +#include <memory> #include <tuple> #include <type_traits> #include <utility> +#include "common/assert.h" +#include "common/common_types.h" #include "core/hle/ipc.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" -#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/hle_ipc.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/server_port.h" namespace IPC { diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index 6a10efab1..7a17ed162 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp @@ -9,7 +9,7 @@ #include "common/common_types.h" #include "core/core.h" #include "core/hle/kernel/errors.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/thread.h" #include "core/hle/result.h" diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp index 2d6051e8b..7933c105c 100644 --- a/src/core/hle/kernel/client_port.cpp +++ b/src/core/hle/kernel/client_port.cpp @@ -8,7 +8,7 @@ #include "core/hle/kernel/client_session.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/hle_ipc.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/server_port.h" #include "core/hle/kernel/server_session.h" diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index a829aeb6d..b42c94bde 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h @@ -6,7 +6,7 @@ #include <string> #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/result.h" namespace Kernel { diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index 2258f95bc..dabd93ed7 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -7,7 +7,7 @@ #include <memory> #include <string> #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/result.h" namespace Kernel { diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index 37e0766c3..5623c4b6a 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp @@ -5,7 +5,7 @@ #include <algorithm> #include "common/assert.h" #include "core/hle/kernel/event.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/thread.h" namespace Kernel { diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h index e5c924a75..1c99911b2 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h @@ -5,7 +5,7 @@ #pragma once #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/wait_object.h" namespace Kernel { diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 7dd67f80f..28e21428a 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp @@ -8,7 +8,6 @@ #include "core/core.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/handle_table.h" -#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/thread.h" diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index ba968c666..22ddda630 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h @@ -7,7 +7,7 @@ #include <array> #include <cstddef> #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/result.h" namespace Kernel { diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 771d6d476..5dd1b68d7 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -3,17 +3,21 @@ // Refer to the license.txt file included. #include <algorithm> +#include <array> +#include <sstream> #include <utility> #include <boost/range/algorithm_ext/erase.hpp> + #include "common/assert.h" #include "common/common_funcs.h" #include "common/common_types.h" +#include "common/logging/log.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/hle_ipc.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/server_session.h" #include "core/memory.h" diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index ee4abebf2..9ce52db24 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -13,7 +13,7 @@ #include "common/common_types.h" #include "common/swap.h" #include "core/hle/ipc.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/server_session.h" #include "core/hle/kernel/thread.h" diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 3eb4f465c..1b0cd0abf 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -4,7 +4,6 @@ #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/memory.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/resource_limit.h" #include "core/hle/kernel/thread.h" @@ -15,9 +14,7 @@ namespace Kernel { unsigned int Object::next_object_id; /// Initialize the kernel -void Init(u32 system_mode) { - Kernel::MemoryInit(system_mode); - +void Init() { Kernel::ResourceLimitsInit(); Kernel::ThreadingInit(); Kernel::TimersInit(); @@ -37,7 +34,6 @@ void Shutdown() { Kernel::TimersShutdown(); Kernel::ResourceLimitsShutdown(); - Kernel::MemoryShutdown(); } } // namespace Kernel diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 402ae900f..131311472 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -4,122 +4,12 @@ #pragma once -#include <cstddef> -#include <string> -#include <utility> -#include <boost/smart_ptr/intrusive_ptr.hpp> -#include "common/assert.h" #include "common/common_types.h" namespace Kernel { -using Handle = u32; - -enum class HandleType : u32 { - Unknown, - Event, - SharedMemory, - Thread, - Process, - AddressArbiter, - Timer, - ResourceLimit, - CodeSet, - ClientPort, - ServerPort, - ClientSession, - ServerSession, -}; - -enum class ResetType { - OneShot, - Sticky, - Pulse, -}; - -class Object : NonCopyable { -public: - virtual ~Object() {} - - /// Returns a unique identifier for the object. For debugging purposes only. - unsigned int GetObjectId() const { - return object_id; - } - - virtual std::string GetTypeName() const { - return "[BAD KERNEL OBJECT TYPE]"; - } - virtual std::string GetName() const { - return "[UNKNOWN KERNEL OBJECT]"; - } - virtual Kernel::HandleType GetHandleType() const = 0; - - /** - * Check if a thread can wait on the object - * @return True if a thread can wait on the object, otherwise false - */ - bool IsWaitable() const { - switch (GetHandleType()) { - case HandleType::Event: - case HandleType::Thread: - case HandleType::Timer: - case HandleType::ServerPort: - case HandleType::ServerSession: - return true; - - case HandleType::Unknown: - case HandleType::SharedMemory: - case HandleType::Process: - case HandleType::AddressArbiter: - case HandleType::ResourceLimit: - case HandleType::CodeSet: - case HandleType::ClientPort: - case HandleType::ClientSession: - return false; - } - - UNREACHABLE(); - } - -public: - static unsigned int next_object_id; - -private: - friend void intrusive_ptr_add_ref(Object*); - friend void intrusive_ptr_release(Object*); - - unsigned int ref_count = 0; - unsigned int object_id = next_object_id++; -}; - -// Special functions used by boost::instrusive_ptr to do automatic ref-counting -inline void intrusive_ptr_add_ref(Object* object) { - ++object->ref_count; -} - -inline void intrusive_ptr_release(Object* object) { - if (--object->ref_count == 0) { - delete object; - } -} - -template <typename T> -using SharedPtr = boost::intrusive_ptr<T>; - -/** - * Attempts to downcast the given Object pointer to a pointer to T. - * @return Derived pointer to the object, or `nullptr` if `object` isn't of type T. - */ -template <typename T> -inline SharedPtr<T> DynamicObjectCast(SharedPtr<Object> object) { - if (object != nullptr && object->GetHandleType() == T::HANDLE_TYPE) { - return boost::static_pointer_cast<T>(std::move(object)); - } - return nullptr; -} - /// Initialize the kernel with the specified system mode. -void Init(u32 system_mode); +void Init(); /// Shutdown the kernel void Shutdown(); diff --git a/src/core/hle/kernel/memory.cpp b/src/core/hle/kernel/memory.cpp deleted file mode 100644 index a7f3c3c5a..000000000 --- a/src/core/hle/kernel/memory.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2014 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include <algorithm> -#include <cinttypes> -#include <memory> -#include <utility> -#include <vector> -#include "common/assert.h" -#include "common/common_types.h" -#include "common/logging/log.h" -#include "core/hle/kernel/memory.h" -#include "core/hle/kernel/process.h" -#include "core/hle/kernel/vm_manager.h" -#include "core/memory.h" - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -namespace Kernel { - -MemoryRegionInfo memory_regions[3]; - -/// Size of the APPLICATION, SYSTEM and BASE memory regions (respectively) for each system -/// memory configuration type. -static const u32 memory_region_sizes[8][3] = { - // Old 3DS layouts - {0x04000000, 0x02C00000, 0x01400000}, // 0 - {/* This appears to be unused. */}, // 1 - {0x06000000, 0x00C00000, 0x01400000}, // 2 - {0x05000000, 0x01C00000, 0x01400000}, // 3 - {0x04800000, 0x02400000, 0x01400000}, // 4 - {0x02000000, 0x04C00000, 0x01400000}, // 5 - - // New 3DS layouts - {0x07C00000, 0x06400000, 0x02000000}, // 6 - {0x0B200000, 0x02E00000, 0x02000000}, // 7 -}; - -void MemoryInit(u32 mem_type) { - // TODO(yuriks): On the n3DS, all o3DS configurations (<=5) are forced to 6 instead. - ASSERT_MSG(mem_type <= 5, "New 3DS memory configuration aren't supported yet!"); - ASSERT(mem_type != 1); - - // The kernel allocation regions (APPLICATION, SYSTEM and BASE) are laid out in sequence, with - // the sizes specified in the memory_region_sizes table. - VAddr base = 0; - for (int i = 0; i < 3; ++i) { - memory_regions[i].base = base; - memory_regions[i].size = memory_region_sizes[mem_type][i]; - memory_regions[i].used = 0; - memory_regions[i].linear_heap_memory = std::make_shared<std::vector<u8>>(); - // Reserve enough space for this region of FCRAM. - // We do not want this block of memory to be relocated when allocating from it. - memory_regions[i].linear_heap_memory->reserve(memory_regions[i].size); - - base += memory_regions[i].size; - } - - // We must've allocated the entire FCRAM by the end - ASSERT(base == Memory::FCRAM_SIZE); -} - -void MemoryShutdown() { - for (auto& region : memory_regions) { - region.base = 0; - region.size = 0; - region.used = 0; - region.linear_heap_memory = nullptr; - } -} - -MemoryRegionInfo* GetMemoryRegion(MemoryRegion region) { - switch (region) { - case MemoryRegion::APPLICATION: - return &memory_regions[0]; - case MemoryRegion::SYSTEM: - return &memory_regions[1]; - case MemoryRegion::BASE: - return &memory_regions[2]; - default: - UNREACHABLE(); - } -} - -void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping) {} - -void MapSharedPages(VMManager& address_space) {} - -} // namespace Kernel diff --git a/src/core/hle/kernel/memory.h b/src/core/hle/kernel/memory.h deleted file mode 100644 index 1d05b8871..000000000 --- a/src/core/hle/kernel/memory.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include <memory> -#include <vector> - -#include "common/common_types.h" - -namespace Kernel { - -class VMManager; -enum class MemoryRegion : u16; -struct AddressMapping; - -struct MemoryRegionInfo { - u64 base; // Not an address, but offset from start of FCRAM - u64 size; - u64 used; - - std::shared_ptr<std::vector<u8>> linear_heap_memory; -}; - -void MemoryInit(u32 mem_type); -void MemoryShutdown(); -MemoryRegionInfo* GetMemoryRegion(MemoryRegion region); - -void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping); -void MapSharedPages(VMManager& address_space); - -extern MemoryRegionInfo memory_regions[3]; -} // namespace Kernel diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 12b974c4b..cb7f58b35 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -12,8 +12,8 @@ #include "core/core.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/handle_table.h" -#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/mutex.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/thread.h" #include "core/hle/result.h" diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index febfde698..45268bbe9 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h @@ -5,7 +5,7 @@ #pragma once #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" union ResultCode; diff --git a/src/core/hle/kernel/object.cpp b/src/core/hle/kernel/object.cpp new file mode 100644 index 000000000..cdba272f5 --- /dev/null +++ b/src/core/hle/kernel/object.cpp @@ -0,0 +1,35 @@ +// Copyright 2018 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/assert.h" +#include "core/hle/kernel/object.h" + +namespace Kernel { + +Object::~Object() = default; + +bool Object::IsWaitable() const { + switch (GetHandleType()) { + case HandleType::Event: + case HandleType::Thread: + case HandleType::Timer: + case HandleType::ServerPort: + case HandleType::ServerSession: + return true; + + case HandleType::Unknown: + case HandleType::SharedMemory: + case HandleType::Process: + case HandleType::AddressArbiter: + case HandleType::ResourceLimit: + case HandleType::CodeSet: + case HandleType::ClientPort: + case HandleType::ClientSession: + return false; + } + + UNREACHABLE(); +} + +} // namespace Kernel diff --git a/src/core/hle/kernel/object.h b/src/core/hle/kernel/object.h new file mode 100644 index 000000000..83df68dfd --- /dev/null +++ b/src/core/hle/kernel/object.h @@ -0,0 +1,100 @@ +// Copyright 2018 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <string> +#include <utility> + +#include <boost/smart_ptr/intrusive_ptr.hpp> + +#include "common/common_types.h" + +namespace Kernel { + +using Handle = u32; + +enum class HandleType : u32 { + Unknown, + Event, + SharedMemory, + Thread, + Process, + AddressArbiter, + Timer, + ResourceLimit, + CodeSet, + ClientPort, + ServerPort, + ClientSession, + ServerSession, +}; + +enum class ResetType { + OneShot, + Sticky, + Pulse, +}; + +class Object : NonCopyable { +public: + virtual ~Object(); + + /// Returns a unique identifier for the object. For debugging purposes only. + unsigned int GetObjectId() const { + return object_id; + } + + virtual std::string GetTypeName() const { + return "[BAD KERNEL OBJECT TYPE]"; + } + virtual std::string GetName() const { + return "[UNKNOWN KERNEL OBJECT]"; + } + virtual HandleType GetHandleType() const = 0; + + /** + * Check if a thread can wait on the object + * @return True if a thread can wait on the object, otherwise false + */ + bool IsWaitable() const; + +public: + static unsigned int next_object_id; + +private: + friend void intrusive_ptr_add_ref(Object*); + friend void intrusive_ptr_release(Object*); + + unsigned int ref_count = 0; + unsigned int object_id = next_object_id++; +}; + +// Special functions used by boost::instrusive_ptr to do automatic ref-counting +inline void intrusive_ptr_add_ref(Object* object) { + ++object->ref_count; +} + +inline void intrusive_ptr_release(Object* object) { + if (--object->ref_count == 0) { + delete object; + } +} + +template <typename T> +using SharedPtr = boost::intrusive_ptr<T>; + +/** + * Attempts to downcast the given Object pointer to a pointer to T. + * @return Derived pointer to the object, or `nullptr` if `object` isn't of type T. + */ +template <typename T> +inline SharedPtr<T> DynamicObjectCast(SharedPtr<Object> object) { + if (object != nullptr && object->GetHandleType() == T::HANDLE_TYPE) { + return boost::static_pointer_cast<T>(std::move(object)); + } + return nullptr; +} + +} // namespace Kernel diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 0c0506085..edf34c5a3 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -8,7 +8,6 @@ #include "common/common_funcs.h" #include "common/logging/log.h" #include "core/hle/kernel/errors.h" -#include "core/hle/kernel/memory.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/resource_limit.h" #include "core/hle/kernel/thread.h" @@ -125,14 +124,6 @@ void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) { std::make_shared<std::vector<u8>>(stack_size, 0), 0, stack_size, MemoryState::Mapped) .Unwrap(); - misc_memory_used += stack_size; - memory_region->used += stack_size; - - // Map special address mappings - MapSharedPages(vm_manager); - for (const auto& mapping : address_mappings) { - HandleSpecialMapping(vm_manager, mapping); - } vm_manager.LogLayout(); status = ProcessStatus::Running; @@ -141,37 +132,19 @@ void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) { } void Process::LoadModule(SharedPtr<CodeSet> module_, VAddr base_addr) { - memory_region = GetMemoryRegion(flags.memory_region); - - auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions, - MemoryState memory_state) { + const auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions, + MemoryState memory_state) { auto vma = vm_manager .MapMemoryBlock(segment.addr + base_addr, module_->memory, segment.offset, segment.size, memory_state) .Unwrap(); vm_manager.Reprotect(vma, permissions); - misc_memory_used += segment.size; - memory_region->used += segment.size; }; // Map CodeSet segments - MapSegment(module_->code, VMAPermission::ReadExecute, MemoryState::CodeStatic); - MapSegment(module_->rodata, VMAPermission::Read, MemoryState::CodeMutable); - MapSegment(module_->data, VMAPermission::ReadWrite, MemoryState::CodeMutable); -} - -VAddr Process::GetLinearHeapAreaAddress() const { - // Starting from system version 8.0.0 a new linear heap layout is supported to allow usage of - // the extra RAM in the n3DS. - return kernel_version < 0x22C ? Memory::LINEAR_HEAP_VADDR : Memory::NEW_LINEAR_HEAP_VADDR; -} - -VAddr Process::GetLinearHeapBase() const { - return GetLinearHeapAreaAddress() + memory_region->base; -} - -VAddr Process::GetLinearHeapLimit() const { - return GetLinearHeapBase() + memory_region->size; + MapSegment(module_->CodeSegment(), VMAPermission::ReadExecute, MemoryState::CodeStatic); + MapSegment(module_->RODataSegment(), VMAPermission::Read, MemoryState::CodeMutable); + MapSegment(module_->DataSegment(), VMAPermission::ReadWrite, MemoryState::CodeMutable); } ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission perms) { @@ -206,7 +179,6 @@ ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission per vm_manager.Reprotect(vma, perms); heap_used = size; - memory_region->used += size; return MakeResult<VAddr>(heap_end - size); } @@ -226,52 +198,6 @@ ResultCode Process::HeapFree(VAddr target, u32 size) { return result; heap_used -= size; - memory_region->used -= size; - - return RESULT_SUCCESS; -} - -ResultVal<VAddr> Process::LinearAllocate(VAddr target, u32 size, VMAPermission perms) { - UNIMPLEMENTED(); - return {}; -} - -ResultCode Process::LinearFree(VAddr target, u32 size) { - auto& linheap_memory = memory_region->linear_heap_memory; - - if (target < GetLinearHeapBase() || target + size > GetLinearHeapLimit() || - target + size < target) { - - return ERR_INVALID_ADDRESS; - } - - if (size == 0) { - return RESULT_SUCCESS; - } - - VAddr heap_end = GetLinearHeapBase() + (u32)linheap_memory->size(); - if (target + size > heap_end) { - return ERR_INVALID_ADDRESS_STATE; - } - - ResultCode result = vm_manager.UnmapRange(target, size); - if (result.IsError()) - return result; - - linear_heap_used -= size; - memory_region->used -= size; - - if (target + size == heap_end) { - // End of linear heap has been freed, so check what's the last allocated block in it and - // reduce the size. - auto vma = vm_manager.FindVMA(target); - ASSERT(vma != vm_manager.vma_map.end()); - ASSERT(vma->second.type == VMAType::Free); - VAddr new_end = vma->second.base; - if (new_end >= GetLinearHeapBase()) { - linheap_memory->resize(new_end - GetLinearHeapBase()); - } - } return RESULT_SUCCESS; } diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 68e77a4d1..992689186 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -4,6 +4,7 @@ #pragma once +#include <array> #include <bitset> #include <cstddef> #include <memory> @@ -12,7 +13,7 @@ #include <boost/container/static_vector.hpp> #include "common/bit_field.h" #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/thread.h" #include "core/hle/kernel/vm_manager.h" @@ -53,9 +54,14 @@ union ProcessFlags { enum class ProcessStatus { Created, Running, Exited }; class ResourceLimit; -struct MemoryRegionInfo; struct CodeSet final : public Object { + struct Segment { + size_t offset = 0; + VAddr addr = 0; + u32 size = 0; + }; + static SharedPtr<CodeSet> Create(std::string name); std::string GetTypeName() const override { @@ -70,24 +76,38 @@ struct CodeSet final : public Object { return HANDLE_TYPE; } - /// Name of the process - std::string name; + Segment& CodeSegment() { + return segments[0]; + } - std::shared_ptr<std::vector<u8>> memory; + const Segment& CodeSegment() const { + return segments[0]; + } - struct Segment { - size_t offset = 0; - VAddr addr = 0; - u32 size = 0; - }; + Segment& RODataSegment() { + return segments[1]; + } + + const Segment& RODataSegment() const { + return segments[1]; + } + + Segment& DataSegment() { + return segments[2]; + } + + const Segment& DataSegment() const { + return segments[2]; + } - Segment segments[3]; - Segment& code = segments[0]; - Segment& rodata = segments[1]; - Segment& data = segments[2]; + std::shared_ptr<std::vector<u8>> memory; + std::array<Segment, 3> segments; VAddr entrypoint; + /// Name of the process + std::string name; + private: CodeSet(); ~CodeSet() override; @@ -163,12 +183,11 @@ public: // This makes deallocation and reallocation of holes fast and keeps process memory contiguous // in the emulator address space, allowing Memory::GetPointer to be reasonably safe. std::shared_ptr<std::vector<u8>> heap_memory; - // The left/right bounds of the address space covered by heap_memory. - VAddr heap_start = 0, heap_end = 0; - u64 heap_used = 0, linear_heap_used = 0, misc_memory_used = 0; - - MemoryRegionInfo* memory_region = nullptr; + // The left/right bounds of the address space covered by heap_memory. + VAddr heap_start = 0; + VAddr heap_end = 0; + u64 heap_used = 0; /// The Thread Local Storage area is allocated as processes create threads, /// each TLS area is 0x200 bytes, so one page (0x1000) is split up in 8 parts, and each part @@ -179,16 +198,9 @@ public: std::string name; - VAddr GetLinearHeapAreaAddress() const; - VAddr GetLinearHeapBase() const; - VAddr GetLinearHeapLimit() const; - ResultVal<VAddr> HeapAllocate(VAddr target, u64 size, VMAPermission perms); ResultCode HeapFree(VAddr target, u32 size); - ResultVal<VAddr> LinearAllocate(VAddr target, u32 size, VMAPermission perms); - ResultCode LinearFree(VAddr target, u32 size); - ResultCode MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size); ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size); diff --git a/src/core/hle/kernel/resource_limit.h b/src/core/hle/kernel/resource_limit.h index cc689a27a..0fa141db3 100644 --- a/src/core/hle/kernel/resource_limit.h +++ b/src/core/hle/kernel/resource_limit.h @@ -5,7 +5,7 @@ #pragma once #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" namespace Kernel { diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h index cdc14808b..1a4ee8f36 100644 --- a/src/core/hle/kernel/scheduler.h +++ b/src/core/hle/kernel/scheduler.h @@ -8,6 +8,7 @@ #include <vector> #include "common/common_types.h" #include "common/thread_queue_list.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/thread.h" class ARM_Interface; diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index 0b7061403..7b6211fd8 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp @@ -6,7 +6,7 @@ #include "common/assert.h" #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/errors.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/server_port.h" #include "core/hle/kernel/server_session.h" #include "core/hle/kernel/thread.h" diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index e6546687e..7f6d6b3eb 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h @@ -9,7 +9,7 @@ #include <tuple> #include <vector> #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/wait_object.h" namespace Kernel { diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index c7656cc49..2bce54fee 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h @@ -9,7 +9,7 @@ #include <vector> #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/wait_object.h" #include "core/hle/result.h" diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h index e69b034a7..7a551f5e4 100644 --- a/src/core/hle/kernel/session.h +++ b/src/core/hle/kernel/session.h @@ -4,7 +4,7 @@ #pragma once -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" namespace Kernel { diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index a5b11bd87..21ddc2f7d 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp @@ -8,7 +8,6 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hle/kernel/errors.h" -#include "core/hle/kernel/memory.h" #include "core/hle/kernel/shared_memory.h" #include "core/memory.h" @@ -30,35 +29,17 @@ SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u shared_memory->other_permissions = other_permissions; if (address == 0) { - // We need to allocate a block from the Linear Heap ourselves. - // We'll manually allocate some memory from the linear heap in the specified region. - MemoryRegionInfo* memory_region = GetMemoryRegion(region); - auto& linheap_memory = memory_region->linear_heap_memory; - - ASSERT_MSG(linheap_memory->size() + size <= memory_region->size, - "Not enough space in region to allocate shared memory!"); - - shared_memory->backing_block = linheap_memory; - shared_memory->backing_block_offset = linheap_memory->size(); - // Allocate some memory from the end of the linear heap for this region. - linheap_memory->insert(linheap_memory->end(), size, 0); - memory_region->used += size; - - shared_memory->linear_heap_phys_address = - Memory::FCRAM_PADDR + memory_region->base + - static_cast<PAddr>(shared_memory->backing_block_offset); - - // Increase the amount of used linear heap memory for the owner process. - if (shared_memory->owner_process != nullptr) { - shared_memory->owner_process->linear_heap_used += size; - } + shared_memory->backing_block = std::make_shared<std::vector<u8>>(size); + shared_memory->backing_block_offset = 0; // Refresh the address mappings for the current process. if (Core::CurrentProcess() != nullptr) { - Core::CurrentProcess()->vm_manager.RefreshMemoryBlockMappings(linheap_memory.get()); + Core::CurrentProcess()->vm_manager.RefreshMemoryBlockMappings( + shared_memory->backing_block.get()); } } else { auto& vm_manager = shared_memory->owner_process->vm_manager; + // The memory is already available and mapped in the owner process. auto vma = vm_manager.FindVMA(address); ASSERT_MSG(vma != vm_manager.vma_map.end(), "Invalid memory address"); @@ -74,6 +55,7 @@ SharedPtr<SharedMemory> SharedMemory::Create(SharedPtr<Process> owner_process, u } shared_memory->base_address = address; + return shared_memory; } @@ -124,11 +106,6 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi VAddr target_address = address; - if (base_address == 0 && target_address == 0) { - // Calculate the address at which to map the memory block. - target_address = Memory::PhysicalToVirtualAddress(linear_heap_phys_address).value(); - } - // Map the memory block into the target process auto result = target_process->vm_manager.MapMemoryBlock( target_address, backing_block, backing_block_offset, size, MemoryState::Shared); diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index 17b9cedc4..c50fee615 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h @@ -9,7 +9,7 @@ #include <vector> #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/process.h" #include "core/hle/result.h" @@ -111,9 +111,6 @@ public: SharedPtr<Process> owner_process; /// Address of shared memory block in the owner process if specified. VAddr base_address; - /// Physical address of the shared memory block in the linear heap if no address was specified - /// during creation. - PAddr linear_heap_phys_address; /// Backing memory for this shared memory block. std::shared_ptr<std::vector<u8>> backing_block; /// Offset into the backing block for this shared memory. diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index d1cbbc1f2..5db2db687 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -267,7 +267,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, info_sub_id, handle); - auto& vm_manager = Core::CurrentProcess()->vm_manager; + const auto& vm_manager = Core::CurrentProcess()->vm_manager; switch (static_cast<GetInfoType>(info_id)) { case GetInfoType::AllowedCpuIdBitmask: diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 93ea58a1e..b9022feae 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -20,8 +20,7 @@ #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" -#include "core/hle/kernel/memory.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/thread.h" #include "core/hle/result.h" @@ -81,8 +80,8 @@ void Thread::Stop() { wait_objects.clear(); // Mark the TLS slot in the thread's page as free. - u64 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE; - u64 tls_slot = + const u64 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE; + const u64 tls_slot = ((tls_address - Memory::TLS_AREA_VADDR) % Memory::PAGE_SIZE) / Memory::TLS_ENTRY_SIZE; Core::CurrentProcess()->tls_slots[tls_page].reset(tls_slot); } @@ -252,13 +251,14 @@ void Thread::ResumeFromWait() { * slot: The index of the first free slot in the indicated page. * alloc_needed: Whether there's a need to allocate a new TLS page (All pages are full). */ -std::tuple<u32, u32, bool> GetFreeThreadLocalSlot(std::vector<std::bitset<8>>& tls_slots) { +static std::tuple<std::size_t, std::size_t, bool> GetFreeThreadLocalSlot( + const std::vector<std::bitset<8>>& tls_slots) { // Iterate over all the allocated pages, and try to find one where not all slots are used. - for (unsigned page = 0; page < tls_slots.size(); ++page) { + for (std::size_t page = 0; page < tls_slots.size(); ++page) { const auto& page_tls_slots = tls_slots[page]; if (!page_tls_slots.all()) { // We found a page with at least one free slot, find which slot it is - for (unsigned slot = 0; slot < page_tls_slots.size(); ++slot) { + for (std::size_t slot = 0; slot < page_tls_slots.size(); ++slot) { if (!page_tls_slots.test(slot)) { return std::make_tuple(page, slot, false); } @@ -333,42 +333,22 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, // Find the next available TLS index, and mark it as used auto& tls_slots = owner_process->tls_slots; - bool needs_allocation = true; - u32 available_page; // Which allocated page has free space - u32 available_slot; // Which slot within the page is free - - std::tie(available_page, available_slot, needs_allocation) = GetFreeThreadLocalSlot(tls_slots); + auto [available_page, available_slot, needs_allocation] = GetFreeThreadLocalSlot(tls_slots); if (needs_allocation) { - // There are no already-allocated pages with free slots, lets allocate a new one. - // TLS pages are allocated from the BASE region in the linear heap. - MemoryRegionInfo* memory_region = GetMemoryRegion(MemoryRegion::BASE); - auto& linheap_memory = memory_region->linear_heap_memory; - - if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) { - LOG_ERROR(Kernel_SVC, - "Not enough space in region to allocate a new TLS page for thread"); - return ERR_OUT_OF_MEMORY; - } - - size_t offset = linheap_memory->size(); - - // Allocate some memory from the end of the linear heap for this region. - linheap_memory->insert(linheap_memory->end(), Memory::PAGE_SIZE, 0); - memory_region->used += Memory::PAGE_SIZE; - owner_process->linear_heap_used += Memory::PAGE_SIZE; - tls_slots.emplace_back(0); // The page is completely available at the start - available_page = static_cast<u32>(tls_slots.size() - 1); + available_page = tls_slots.size() - 1; available_slot = 0; // Use the first slot in the new page + // Allocate some memory from the end of the linear heap for this region. + const size_t offset = thread->tls_memory->size(); + thread->tls_memory->insert(thread->tls_memory->end(), Memory::PAGE_SIZE, 0); + auto& vm_manager = owner_process->vm_manager; - vm_manager.RefreshMemoryBlockMappings(linheap_memory.get()); + vm_manager.RefreshMemoryBlockMappings(thread->tls_memory.get()); - // Map the page to the current process' address space. - // TODO(Subv): Find the correct MemoryState for this region. vm_manager.MapMemoryBlock(Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE, - linheap_memory, offset, Memory::PAGE_SIZE, + thread->tls_memory, 0, Memory::PAGE_SIZE, MemoryState::ThreadLocal); } diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index a456745a1..adc804248 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -11,7 +11,7 @@ #include "common/common_types.h" #include "core/arm/arm_interface.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/wait_object.h" #include "core/hle/result.h" @@ -265,6 +265,8 @@ public: private: Thread(); ~Thread() override; + + std::shared_ptr<std::vector<u8>> tls_memory = std::make_shared<std::vector<u8>>(); }; /** @@ -288,12 +290,6 @@ Thread* GetCurrentThread(); void WaitCurrentThread_Sleep(); /** - * Waits the current thread from an ArbitrateAddress call - * @param wait_address Arbitration address used to resume from wait - */ -void WaitCurrentThread_ArbitrateAddress(VAddr wait_address); - -/** * Stops the current thread and removes it from the thread_list */ void ExitCurrentThread(); diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 904a3d0a5..282360745 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -8,7 +8,7 @@ #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/object.h" #include "core/hle/kernel/thread.h" #include "core/hle/kernel/timer.h" diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h index c63f0ed90..4dddc67e0 100644 --- a/src/core/hle/kernel/timer.h +++ b/src/core/hle/kernel/timer.h @@ -5,7 +5,7 @@ #pragma once #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/wait_object.h" namespace Kernel { diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 9d26fd781..479cacb62 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> #include <iterator> #include <utility> #include "common/assert.h" @@ -175,9 +176,9 @@ VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) { ResultCode VMManager::UnmapRange(VAddr target, u64 size) { CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); - VAddr target_end = target + size; + const VAddr target_end = target + size; - VMAIter end = vma_map.end(); + const VMAIter end = vma_map.end(); // The comparison against the end of the range must be done using addresses since VMAs can be // merged during this process, causing invalidation of the iterators. while (vma != end && vma->second.base < target_end) { @@ -207,9 +208,9 @@ VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission ne ResultCode VMManager::ReprotectRange(VAddr target, u64 size, VMAPermission new_perms) { CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size)); - VAddr target_end = target + size; + const VAddr target_end = target + size; - VMAIter end = vma_map.end(); + const VMAIter end = vma_map.end(); // The comparison against the end of the range must be done using addresses since VMAs can be // merged during this process, causing invalidation of the iterators. while (vma != end && vma->second.base < target_end) { @@ -258,14 +259,14 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u64 size) { return ERR_INVALID_ADDRESS; } - VirtualMemoryArea& vma = vma_handle->second; + const VirtualMemoryArea& vma = vma_handle->second; if (vma.type != VMAType::Free) { // Region is already allocated return ERR_INVALID_ADDRESS_STATE; } - u64 start_in_vma = base - vma.base; - u64 end_in_vma = start_in_vma + size; + const VAddr start_in_vma = base - vma.base; + const VAddr end_in_vma = start_in_vma + size; if (end_in_vma > vma.size) { // Requested allocation doesn't fit inside VMA @@ -288,17 +289,16 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u64 size) { ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x{:016X}", size); ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x{:016X}", target); - VAddr target_end = target + size; + const VAddr target_end = target + size; ASSERT(target_end >= target); ASSERT(target_end <= MAX_ADDRESS); ASSERT(size > 0); VMAIter begin_vma = StripIterConstness(FindVMA(target)); - VMAIter i_end = vma_map.lower_bound(target_end); - for (auto i = begin_vma; i != i_end; ++i) { - if (i->second.type == VMAType::Free) { - return ERR_INVALID_ADDRESS_STATE; - } + const VMAIter i_end = vma_map.lower_bound(target_end); + if (std::any_of(begin_vma, i_end, + [](const auto& entry) { return entry.second.type == VMAType::Free; })) { + return ERR_INVALID_ADDRESS_STATE; } if (target != begin_vma->second.base) { @@ -346,7 +346,7 @@ VMManager::VMAIter VMManager::SplitVMA(VMAIter vma_handle, u64 offset_in_vma) { } VMManager::VMAIter VMManager::MergeAdjacent(VMAIter iter) { - VMAIter next_vma = std::next(iter); + const VMAIter next_vma = std::next(iter); if (next_vma != vma_map.end() && iter->second.CanBeMergedWith(next_vma->second)) { iter->second.size += next_vma->second.size; vma_map.erase(next_vma); @@ -382,22 +382,22 @@ void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) { } } -u64 VMManager::GetTotalMemoryUsage() { +u64 VMManager::GetTotalMemoryUsage() const { LOG_WARNING(Kernel, "(STUBBED) called"); return 0xF8000000; } -u64 VMManager::GetTotalHeapUsage() { +u64 VMManager::GetTotalHeapUsage() const { LOG_WARNING(Kernel, "(STUBBED) called"); return 0x0; } -VAddr VMManager::GetAddressSpaceBaseAddr() { +VAddr VMManager::GetAddressSpaceBaseAddr() const { LOG_WARNING(Kernel, "(STUBBED) called"); return 0x8000000; } -u64 VMManager::GetAddressSpaceSize() { +u64 VMManager::GetAddressSpaceSize() const { LOG_WARNING(Kernel, "(STUBBED) called"); return MAX_ADDRESS; } diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 38e4ebcd3..98bd04bea 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -190,16 +190,16 @@ public: void LogLayout() const; /// Gets the total memory usage, used by svcGetInfo - u64 GetTotalMemoryUsage(); + u64 GetTotalMemoryUsage() const; /// Gets the total heap usage, used by svcGetInfo - u64 GetTotalHeapUsage(); + u64 GetTotalHeapUsage() const; /// Gets the total address space base address, used by svcGetInfo - VAddr GetAddressSpaceBaseAddr(); + VAddr GetAddressSpaceBaseAddr() const; /// Gets the total address space address size, used by svcGetInfo - u64 GetAddressSpaceSize(); + u64 GetAddressSpaceSize() const; /// Each VMManager has its own page table, which is set as the main one when the owning process /// is scheduled. diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index 97394bca2..7681cdee7 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp @@ -5,8 +5,7 @@ #include <algorithm> #include "common/assert.h" #include "common/logging/log.h" -#include "core/hle/kernel/kernel.h" -#include "core/hle/kernel/memory.h" +#include "core/hle/kernel/object.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/thread.h" #include "core/hle/kernel/timer.h" diff --git a/src/core/hle/kernel/wait_object.h b/src/core/hle/kernel/wait_object.h index 78bfd8c6c..b5fbc647b 100644 --- a/src/core/hle/kernel/wait_object.h +++ b/src/core/hle/kernel/wait_object.h @@ -7,7 +7,7 @@ #include <vector> #include <boost/smart_ptr/intrusive_ptr.hpp> #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" namespace Kernel { diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 0b158e015..6d15b46ed 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -10,6 +10,7 @@ #include "core/hle/service/acc/acc_su.h" #include "core/hle/service/acc/acc_u0.h" #include "core/hle/service/acc/acc_u1.h" +#include "core/settings.h" namespace Service::Account { @@ -31,13 +32,14 @@ struct ProfileBase { }; static_assert(sizeof(ProfileBase) == 0x38, "ProfileBase structure has incorrect size"); +// TODO(ogniK): Generate a real user id based on username, md5(username) maybe? static constexpr u128 DEFAULT_USER_ID{1ull, 0ull}; class IProfile final : public ServiceFramework<IProfile> { public: explicit IProfile(u128 user_id) : ServiceFramework("IProfile"), user_id(user_id) { static const FunctionInfo functions[] = { - {0, nullptr, "Get"}, + {0, &IProfile::Get, "Get"}, {1, &IProfile::GetBase, "GetBase"}, {10, nullptr, "GetImageSize"}, {11, nullptr, "LoadImage"}, @@ -46,14 +48,36 @@ public: } private: + void Get(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_ACC, "(STUBBED) called"); + ProfileBase profile_base{}; + profile_base.user_id = user_id; + if (Settings::values.username.size() > profile_base.username.size()) { + std::copy_n(Settings::values.username.begin(), profile_base.username.size(), + profile_base.username.begin()); + } else { + std::copy(Settings::values.username.begin(), Settings::values.username.end(), + profile_base.username.begin()); + } + + IPC::ResponseBuilder rb{ctx, 16}; + rb.Push(RESULT_SUCCESS); + rb.PushRaw(profile_base); + } + void GetBase(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_ACC, "(STUBBED) called"); // TODO(Subv): Retrieve this information from somewhere. ProfileBase profile_base{}; profile_base.user_id = user_id; - profile_base.username = {'y', 'u', 'z', 'u'}; - + if (Settings::values.username.size() > profile_base.username.size()) { + std::copy_n(Settings::values.username.begin(), profile_base.username.size(), + profile_base.username.begin()); + } else { + std::copy(Settings::values.username.begin(), Settings::values.username.end(), + profile_base.username.begin()); + } IPC::ResponseBuilder rb{ctx, 16}; rb.Push(RESULT_SUCCESS); rb.PushRaw(profile_base); diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 94d2a973d..9404d6b8c 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -652,7 +652,8 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { // TODO(bunnei): This should be configurable IPC::ResponseBuilder rb{ctx, 4}; rb.Push(RESULT_SUCCESS); - rb.Push(static_cast<u64>(Service::Set::LanguageCode::EN_US)); + rb.Push( + static_cast<u64>(Service::Set::GetLanguageCodeFromIndex(Settings::values.language_index))); LOG_DEBUG(Service_AM, "called"); } diff --git a/src/core/hle/service/bpc/bpc.cpp b/src/core/hle/service/bpc/bpc.cpp new file mode 100644 index 000000000..1c1ecdb60 --- /dev/null +++ b/src/core/hle/service/bpc/bpc.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 <memory> + +#include "core/hle/service/bpc/bpc.h" +#include "core/hle/service/service.h" +#include "core/hle/service/sm/sm.h" + +namespace Service::BPC { + +class BPC final : public ServiceFramework<BPC> { +public: + explicit BPC() : ServiceFramework{"bpc"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "ShutdownSystem"}, + {1, nullptr, "RebootSystem"}, + {2, nullptr, "GetWakeupReason"}, + {3, nullptr, "GetShutdownReason"}, + {4, nullptr, "GetAcOk"}, + {5, nullptr, "GetBoardPowerControlEvent"}, + {6, nullptr, "GetSleepButtonState"}, + {7, nullptr, "GetPowerEvent"}, + {8, nullptr, "Unknown1"}, + {9, nullptr, "Unknown2"}, + {10, nullptr, "Unknown3"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class BPC_R final : public ServiceFramework<BPC_R> { +public: + explicit BPC_R() : ServiceFramework{"bpc:r"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GetExternalRtcValue"}, + {1, nullptr, "SetExternalRtcValue"}, + {2, nullptr, "ReadExternalRtcResetFlag"}, + {3, nullptr, "ClearExternalRtcResetFlag"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<BPC>()->InstallAsService(sm); + std::make_shared<BPC_R>()->InstallAsService(sm); +} + +} // namespace Service::BPC diff --git a/src/core/hle/service/bpc/bpc.h b/src/core/hle/service/bpc/bpc.h new file mode 100644 index 000000000..eaa37be8d --- /dev/null +++ b/src/core/hle/service/bpc/bpc.h @@ -0,0 +1,15 @@ +// 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::BPC { + +void InstallInterfaces(SM::ServiceManager& sm); + +} // namespace Service::BPC diff --git a/src/core/hle/service/caps/caps.cpp b/src/core/hle/service/caps/caps.cpp new file mode 100644 index 000000000..ae7b0720b --- /dev/null +++ b/src/core/hle/service/caps/caps.cpp @@ -0,0 +1,152 @@ +// 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/caps/caps.h" +#include "core/hle/service/service.h" +#include "core/hle/service/sm/sm.h" + +namespace Service::Capture { + +class CAPS_A final : public ServiceFramework<CAPS_A> { +public: + explicit CAPS_A() : ServiceFramework{"caps:a"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "Unknown1"}, + {1, nullptr, "Unknown2"}, + {2, nullptr, "Unknown3"}, + {3, nullptr, "Unknown4"}, + {4, nullptr, "Unknown5"}, + {5, nullptr, "Unknown6"}, + {6, nullptr, "Unknown7"}, + {7, nullptr, "Unknown8"}, + {8, nullptr, "Unknown9"}, + {9, nullptr, "Unknown10"}, + {10, nullptr, "Unknown11"}, + {11, nullptr, "Unknown12"}, + {12, nullptr, "Unknown13"}, + {13, nullptr, "Unknown14"}, + {14, nullptr, "Unknown15"}, + {301, nullptr, "Unknown16"}, + {401, nullptr, "Unknown17"}, + {501, nullptr, "Unknown18"}, + {1001, nullptr, "Unknown19"}, + {1002, nullptr, "Unknown20"}, + {8001, nullptr, "Unknown21"}, + {8002, nullptr, "Unknown22"}, + {8011, nullptr, "Unknown23"}, + {8012, nullptr, "Unknown24"}, + {8021, nullptr, "Unknown25"}, + {10011, nullptr, "Unknown26"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class CAPS_C final : public ServiceFramework<CAPS_C> { +public: + explicit CAPS_C() : ServiceFramework{"caps:c"} { + // clang-format off + static const FunctionInfo functions[] = { + {2001, nullptr, "Unknown1"}, + {2002, nullptr, "Unknown2"}, + {2011, nullptr, "Unknown3"}, + {2012, nullptr, "Unknown4"}, + {2013, nullptr, "Unknown5"}, + {2014, nullptr, "Unknown6"}, + {2101, nullptr, "Unknown7"}, + {2102, nullptr, "Unknown8"}, + {2201, nullptr, "Unknown9"}, + {2301, nullptr, "Unknown10"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class CAPS_SC final : public ServiceFramework<CAPS_SC> { +public: + explicit CAPS_SC() : ServiceFramework{"caps:sc"} { + // clang-format off + static const FunctionInfo functions[] = { + {1, nullptr, "Unknown1"}, + {2, nullptr, "Unknown2"}, + {1001, nullptr, "Unknown3"}, + {1002, nullptr, "Unknown4"}, + {1003, nullptr, "Unknown5"}, + {1011, nullptr, "Unknown6"}, + {1012, nullptr, "Unknown7"}, + {1201, nullptr, "Unknown8"}, + {1202, nullptr, "Unknown9"}, + {1203, nullptr, "Unknown10"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class CAPS_SS final : public ServiceFramework<CAPS_SS> { +public: + explicit CAPS_SS() : ServiceFramework{"caps:ss"} { + // clang-format off + static const FunctionInfo functions[] = { + {201, nullptr, "Unknown1"}, + {202, nullptr, "Unknown2"}, + {203, nullptr, "Unknown3"}, + {204, nullptr, "Unknown4"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class CAPS_SU final : public ServiceFramework<CAPS_SU> { +public: + explicit CAPS_SU() : ServiceFramework{"caps:su"} { + // clang-format off + static const FunctionInfo functions[] = { + {201, nullptr, "SaveScreenShot"}, + {203, nullptr, "SaveScreenShotEx0"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class CAPS_U final : public ServiceFramework<CAPS_U> { +public: + explicit CAPS_U() : ServiceFramework{"caps:u"} { + // clang-format off + static const FunctionInfo functions[] = { + {102, nullptr, "GetAlbumFileListByAruid"}, + {103, nullptr, "DeleteAlbumFileByAruid"}, + {104, nullptr, "GetAlbumFileSizeByAruid"}, + {110, nullptr, "LoadAlbumScreenShotImageByAruid"}, + {120, nullptr, "LoadAlbumScreenShotThumbnailImageByAruid"}, + {60002, nullptr, "OpenAccessorSessionForApplication"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<CAPS_A>()->InstallAsService(sm); + std::make_shared<CAPS_C>()->InstallAsService(sm); + std::make_shared<CAPS_SC>()->InstallAsService(sm); + std::make_shared<CAPS_SS>()->InstallAsService(sm); + std::make_shared<CAPS_SU>()->InstallAsService(sm); + std::make_shared<CAPS_U>()->InstallAsService(sm); +} + +} // namespace Service::Capture diff --git a/src/core/hle/service/caps/caps.h b/src/core/hle/service/caps/caps.h new file mode 100644 index 000000000..471185dfa --- /dev/null +++ b/src/core/hle/service/caps/caps.h @@ -0,0 +1,15 @@ +// 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::Capture { + +void InstallInterfaces(SM::ServiceManager& sm); + +} // namespace Service::Capture diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index fdd2fda18..e17d637e4 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -14,6 +14,8 @@ #include "core/file_sys/vfs_offset.h" #include "core/file_sys/vfs_real.h" #include "core/hle/service/filesystem/filesystem.h" +#include "core/hle/service/filesystem/fsp_ldr.h" +#include "core/hle/service/filesystem/fsp_pr.h" #include "core/hle/service/filesystem/fsp_srv.h" namespace Service::FileSystem { @@ -298,6 +300,8 @@ void RegisterFileSystems() { void InstallInterfaces(SM::ServiceManager& service_manager) { RegisterFileSystems(); + std::make_shared<FSP_LDR>()->InstallAsService(service_manager); + std::make_shared<FSP_PR>()->InstallAsService(service_manager); std::make_shared<FSP_SRV>()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/filesystem/fsp_ldr.cpp b/src/core/hle/service/filesystem/fsp_ldr.cpp new file mode 100644 index 000000000..ee6d4d055 --- /dev/null +++ b/src/core/hle/service/filesystem/fsp_ldr.cpp @@ -0,0 +1,24 @@ +// 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/filesystem/fsp_ldr.h" +#include "core/hle/service/service.h" + +namespace Service::FileSystem { + +FSP_LDR::FSP_LDR() : ServiceFramework{"fsp:ldr"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "OpenCodeFileSystem"}, + {1, nullptr, "IsArchivedProgram"}, + {2, nullptr, "SetCurrentProcess"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +} // namespace Service::FileSystem diff --git a/src/core/hle/service/filesystem/fsp_ldr.h b/src/core/hle/service/filesystem/fsp_ldr.h new file mode 100644 index 000000000..fa8e11b4c --- /dev/null +++ b/src/core/hle/service/filesystem/fsp_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 + +#include "core/hle/service/service.h" + +namespace Service::FileSystem { + +class FSP_LDR final : public ServiceFramework<FSP_LDR> { +public: + explicit FSP_LDR(); +}; + +} // namespace Service::FileSystem diff --git a/src/core/hle/service/filesystem/fsp_pr.cpp b/src/core/hle/service/filesystem/fsp_pr.cpp new file mode 100644 index 000000000..0b51385ee --- /dev/null +++ b/src/core/hle/service/filesystem/fsp_pr.cpp @@ -0,0 +1,25 @@ +// 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/filesystem/fsp_pr.h" +#include "core/hle/service/service.h" + +namespace Service::FileSystem { + +FSP_PR::FSP_PR() : ServiceFramework{"fsp:pr"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "RegisterProgram"}, + {1, nullptr, "UnregisterProgram"}, + {2, nullptr, "SetCurrentProcess"}, + {256, nullptr, "SetEnabledProgramVerification"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +} // namespace Service::FileSystem diff --git a/src/core/hle/service/filesystem/fsp_pr.h b/src/core/hle/service/filesystem/fsp_pr.h new file mode 100644 index 000000000..62edcd08a --- /dev/null +++ b/src/core/hle/service/filesystem/fsp_pr.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 + +#include "core/hle/service/service.h" + +namespace Service::FileSystem { + +class FSP_PR final : public ServiceFramework<FSP_PR> { +public: + explicit FSP_PR(); +}; + +} // namespace Service::FileSystem diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index b497376d7..2e99ddf51 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp @@ -13,11 +13,11 @@ namespace Service::LM { -class Logger final : public ServiceFramework<Logger> { +class ILogger final : public ServiceFramework<ILogger> { public: - Logger() : ServiceFramework("Logger") { + ILogger() : ServiceFramework("ILogger") { static const FunctionInfo functions[] = { - {0x00000000, &Logger::Initialize, "Initialize"}, + {0x00000000, &ILogger::Initialize, "Initialize"}, {0x00000001, nullptr, "SetDestination"}, }; RegisterHandlers(functions); @@ -182,7 +182,7 @@ public: void OpenLogger(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<Logger>(); + rb.PushIpcInterface<ILogger>(); LOG_DEBUG(Service_LM, "called"); } diff --git a/src/core/hle/service/mig/mig.cpp b/src/core/hle/service/mig/mig.cpp new file mode 100644 index 000000000..d16367f2c --- /dev/null +++ b/src/core/hle/service/mig/mig.cpp @@ -0,0 +1,34 @@ +// 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/mig/mig.h" +#include "core/hle/service/service.h" +#include "core/hle/service/sm/sm.h" + +namespace Service::Migration { + +class MIG_USR final : public ServiceFramework<MIG_USR> { +public: + explicit MIG_USR() : ServiceFramework{"mig:usr"} { + // clang-format off + static const FunctionInfo functions[] = { + {10, nullptr, "TryGetLastMigrationInfo"}, + {100, nullptr, "CreateServer"}, + {101, nullptr, "ResumeServer"}, + {200, nullptr, "CreateClient"}, + {201, nullptr, "ResumeClient"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<MIG_USR>()->InstallAsService(sm); +} + +} // namespace Service::Migration diff --git a/src/core/hle/service/mig/mig.h b/src/core/hle/service/mig/mig.h new file mode 100644 index 000000000..288c1c1b3 --- /dev/null +++ b/src/core/hle/service/mig/mig.h @@ -0,0 +1,15 @@ +// 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::Migration { + +void InstallInterfaces(SM::ServiceManager& sm); + +} // namespace Service::Migration diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 89c703310..98017267c 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp @@ -2,12 +2,459 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/hle_ipc.h" #include "core/hle/service/ns/ns.h" #include "core/hle/service/ns/pl_u.h" namespace Service::NS { +class IAccountProxyInterface final : public ServiceFramework<IAccountProxyInterface> { +public: + explicit IAccountProxyInterface() : ServiceFramework{"IAccountProxyInterface"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "CreateUserAccount"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class IApplicationManagerInterface final : public ServiceFramework<IApplicationManagerInterface> { +public: + explicit IApplicationManagerInterface() : ServiceFramework{"IApplicationManagerInterface"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "ListApplicationRecord"}, + {1, nullptr, "GenerateApplicationRecordCount"}, + {2, nullptr, "GetApplicationRecordUpdateSystemEvent"}, + {3, nullptr, "GetApplicationViewDeprecated"}, + {4, nullptr, "DeleteApplicationEntity"}, + {5, nullptr, "DeleteApplicationCompletely"}, + {6, nullptr, "IsAnyApplicationEntityRedundant"}, + {7, nullptr, "DeleteRedundantApplicationEntity"}, + {8, nullptr, "IsApplicationEntityMovable"}, + {9, nullptr, "MoveApplicationEntity"}, + {11, nullptr, "CalculateApplicationOccupiedSize"}, + {16, nullptr, "PushApplicationRecord"}, + {17, nullptr, "ListApplicationRecordContentMeta"}, + {19, nullptr, "LaunchApplication"}, + {21, nullptr, "GetApplicationContentPath"}, + {22, nullptr, "TerminateApplication"}, + {23, nullptr, "ResolveApplicationContentPath"}, + {26, nullptr, "BeginInstallApplication"}, + {27, nullptr, "DeleteApplicationRecord"}, + {30, nullptr, "RequestApplicationUpdateInfo"}, + {32, nullptr, "CancelApplicationDownload"}, + {33, nullptr, "ResumeApplicationDownload"}, + {35, nullptr, "UpdateVersionList"}, + {36, nullptr, "PushLaunchVersion"}, + {37, nullptr, "ListRequiredVersion"}, + {38, nullptr, "CheckApplicationLaunchVersion"}, + {39, nullptr, "CheckApplicationLaunchRights"}, + {40, nullptr, "GetApplicationLogoData"}, + {41, nullptr, "CalculateApplicationDownloadRequiredSize"}, + {42, nullptr, "CleanupSdCard"}, + {43, nullptr, "CheckSdCardMountStatus"}, + {44, nullptr, "GetSdCardMountStatusChangedEvent"}, + {45, nullptr, "GetGameCardAttachmentEvent"}, + {46, nullptr, "GetGameCardAttachmentInfo"}, + {47, nullptr, "GetTotalSpaceSize"}, + {48, nullptr, "GetFreeSpaceSize"}, + {49, nullptr, "GetSdCardRemovedEvent"}, + {52, nullptr, "GetGameCardUpdateDetectionEvent"}, + {53, nullptr, "DisableApplicationAutoDelete"}, + {54, nullptr, "EnableApplicationAutoDelete"}, + {55, nullptr, "GetApplicationDesiredLanguage"}, + {56, nullptr, "SetApplicationTerminateResult"}, + {57, nullptr, "ClearApplicationTerminateResult"}, + {58, nullptr, "GetLastSdCardMountUnexpectedResult"}, + {59, nullptr, "ConvertApplicationLanguageToLanguageCode"}, + {60, nullptr, "ConvertLanguageCodeToApplicationLanguage"}, + {61, nullptr, "GetBackgroundDownloadStressTaskInfo"}, + {62, nullptr, "GetGameCardStopper"}, + {63, nullptr, "IsSystemProgramInstalled"}, + {64, nullptr, "StartApplyDeltaTask"}, + {65, nullptr, "GetRequestServerStopper"}, + {66, nullptr, "GetBackgroundApplyDeltaStressTaskInfo"}, + {67, nullptr, "CancelApplicationApplyDelta"}, + {68, nullptr, "ResumeApplicationApplyDelta"}, + {69, nullptr, "CalculateApplicationApplyDeltaRequiredSize"}, + {70, nullptr, "ResumeAll"}, + {71, nullptr, "GetStorageSize"}, + {80, nullptr, "RequestDownloadApplication"}, + {81, nullptr, "RequestDownloadAddOnContent"}, + {82, nullptr, "DownloadApplication"}, + {83, nullptr, "CheckApplicationResumeRights"}, + {84, nullptr, "GetDynamicCommitEvent"}, + {85, nullptr, "RequestUpdateApplication2"}, + {86, nullptr, "EnableApplicationCrashReport"}, + {87, nullptr, "IsApplicationCrashReportEnabled"}, + {90, nullptr, "BoostSystemMemoryResourceLimit"}, + {100, nullptr, "ResetToFactorySettings"}, + {101, nullptr, "ResetToFactorySettingsWithoutUserSaveData"}, + {102, nullptr, "ResetToFactorySettingsForRefurbishment"}, + {200, nullptr, "CalculateUserSaveDataStatistics"}, + {201, nullptr, "DeleteUserSaveDataAll"}, + {210, nullptr, "DeleteUserSystemSaveData"}, + {220, nullptr, "UnregisterNetworkServiceAccount"}, + {300, nullptr, "GetApplicationShellEvent"}, + {301, nullptr, "PopApplicationShellEventInfo"}, + {302, nullptr, "LaunchLibraryApplet"}, + {303, nullptr, "TerminateLibraryApplet"}, + {304, nullptr, "LaunchSystemApplet"}, + {305, nullptr, "TerminateSystemApplet"}, + {306, nullptr, "LaunchOverlayApplet"}, + {307, nullptr, "TerminateOverlayApplet"}, + {400, nullptr, "GetApplicationControlData"}, + {401, nullptr, "InvalidateAllApplicationControlCache"}, + {402, nullptr, "RequestDownloadApplicationControlData"}, + {403, nullptr, "GetMaxApplicationControlCacheCount"}, + {404, nullptr, "InvalidateApplicationControlCache"}, + {405, nullptr, "ListApplicationControlCacheEntryInfo"}, + {502, nullptr, "RequestCheckGameCardRegistration"}, + {503, nullptr, "RequestGameCardRegistrationGoldPoint"}, + {504, nullptr, "RequestRegisterGameCard"}, + {505, nullptr, "GetGameCardMountFailureEvent"}, + {506, nullptr, "IsGameCardInserted"}, + {507, nullptr, "EnsureGameCardAccess"}, + {508, nullptr, "GetLastGameCardMountFailureResult"}, + {509, nullptr, "ListApplicationIdOnGameCard"}, + {600, nullptr, "CountApplicationContentMeta"}, + {601, nullptr, "ListApplicationContentMetaStatus"}, + {602, nullptr, "ListAvailableAddOnContent"}, + {603, nullptr, "GetOwnedApplicationContentMetaStatus"}, + {604, nullptr, "RegisterContentsExternalKey"}, + {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"}, + {606, nullptr, "GetContentMetaStorage"}, + {700, nullptr, "PushDownloadTaskList"}, + {701, nullptr, "ClearTaskStatusList"}, + {702, nullptr, "RequestDownloadTaskList"}, + {703, nullptr, "RequestEnsureDownloadTask"}, + {704, nullptr, "ListDownloadTaskStatus"}, + {705, nullptr, "RequestDownloadTaskListData"}, + {800, nullptr, "RequestVersionList"}, + {801, nullptr, "ListVersionList"}, + {802, nullptr, "RequestVersionListData"}, + {900, nullptr, "GetApplicationRecord"}, + {901, nullptr, "GetApplicationRecordProperty"}, + {902, nullptr, "EnableApplicationAutoUpdate"}, + {903, nullptr, "DisableApplicationAutoUpdate"}, + {904, nullptr, "TouchApplication"}, + {905, nullptr, "RequestApplicationUpdate"}, + {906, nullptr, "IsApplicationUpdateRequested"}, + {907, nullptr, "WithdrawApplicationUpdateRequest"}, + {908, nullptr, "ListApplicationRecordInstalledContentMeta"}, + {909, nullptr, "WithdrawCleanupAddOnContentsWithNoRightsRecommendation"}, + {1000, nullptr, "RequestVerifyApplicationDeprecated"}, + {1001, nullptr, "CorruptApplicationForDebug"}, + {1002, nullptr, "RequestVerifyAddOnContentsRights"}, + {1003, nullptr, "RequestVerifyApplication"}, + {1004, nullptr, "CorruptContentForDebug"}, + {1200, nullptr, "NeedsUpdateVulnerability"}, + {1300, nullptr, "IsAnyApplicationEntityInstalled"}, + {1301, nullptr, "DeleteApplicationContentEntities"}, + {1302, nullptr, "CleanupUnrecordedApplicationEntity"}, + {1303, nullptr, "CleanupAddOnContentsWithNoRights"}, + {1304, nullptr, "DeleteApplicationContentEntity"}, + {1305, nullptr, "TryDeleteRunningApplicationEntity"}, + {1306, nullptr, "TryDeleteRunningApplicationCompletely"}, + {1307, nullptr, "TryDeleteRunningApplicationContentEntities"}, + {1400, nullptr, "PrepareShutdown"}, + {1500, nullptr, "FormatSdCard"}, + {1501, nullptr, "NeedsSystemUpdateToFormatSdCard"}, + {1502, nullptr, "GetLastSdCardFormatUnexpectedResult"}, + {1504, nullptr, "InsertSdCard"}, + {1505, nullptr, "RemoveSdCard"}, + {1600, nullptr, "GetSystemSeedForPseudoDeviceId"}, + {1601, nullptr, "ResetSystemSeedForPseudoDeviceId"}, + {1700, nullptr, "ListApplicationDownloadingContentMeta"}, + {1701, nullptr, "GetApplicationView"}, + {1702, nullptr, "GetApplicationDownloadTaskStatus"}, + {1703, nullptr, "GetApplicationViewDownloadErrorContext"}, + {1800, nullptr, "IsNotificationSetupCompleted"}, + {1801, nullptr, "GetLastNotificationInfoCount"}, + {1802, nullptr, "ListLastNotificationInfo"}, + {1803, nullptr, "ListNotificationTask"}, + {1900, nullptr, "IsActiveAccount"}, + {1901, nullptr, "RequestDownloadApplicationPrepurchasedRights"}, + {1902, nullptr, "GetApplicationTicketInfo"}, + {2000, nullptr, "GetSystemDeliveryInfo"}, + {2001, nullptr, "SelectLatestSystemDeliveryInfo"}, + {2002, nullptr, "VerifyDeliveryProtocolVersion"}, + {2003, nullptr, "GetApplicationDeliveryInfo"}, + {2004, nullptr, "HasAllContentsToDeliver"}, + {2005, nullptr, "CompareApplicationDeliveryInfo"}, + {2006, nullptr, "CanDeliverApplication"}, + {2007, nullptr, "ListContentMetaKeyToDeliverApplication"}, + {2008, nullptr, "NeedsSystemUpdateToDeliverApplication"}, + {2009, nullptr, "EstimateRequiredSize"}, + {2010, nullptr, "RequestReceiveApplication"}, + {2011, nullptr, "CommitReceiveApplication"}, + {2012, nullptr, "GetReceiveApplicationProgress"}, + {2013, nullptr, "RequestSendApplication"}, + {2014, nullptr, "GetSendApplicationProgress"}, + {2015, nullptr, "CompareSystemDeliveryInfo"}, + {2016, nullptr, "ListNotCommittedContentMeta"}, + {2017, nullptr, "CreateDownloadTask"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> { +public: + explicit IApplicationVersionInterface() : ServiceFramework{"IApplicationVersionInterface"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GetLaunchRequiredVersion"}, + {1, nullptr, "UpgradeLaunchRequiredVersion"}, + {35, nullptr, "UpdateVersionList"}, + {36, nullptr, "PushLaunchVersion"}, + {37, nullptr, "ListRequiredVersion"}, + {800, nullptr, "RequestVersionList"}, + {801, nullptr, "ListVersionList"}, + {802, nullptr, "RequestVersionListData"}, + {1000, nullptr, "PerformAutoUpdate"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class IContentManagerInterface final : public ServiceFramework<IContentManagerInterface> { +public: + explicit IContentManagerInterface() : ServiceFramework{"IContentManagerInterface"} { + // clang-format off + static const FunctionInfo functions[] = { + {11, nullptr, "CalculateApplicationOccupiedSize"}, + {43, nullptr, "CheckSdCardMountStatus"}, + {47, nullptr, "GetTotalSpaceSize"}, + {48, nullptr, "GetFreeSpaceSize"}, + {600, nullptr, "CountApplicationContentMeta"}, + {601, nullptr, "ListApplicationContentMetaStatus"}, + {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"}, + {607, nullptr, "IsAnyApplicationRunning"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class IDocumentInterface final : public ServiceFramework<IDocumentInterface> { +public: + explicit IDocumentInterface() : ServiceFramework{"IDocumentInterface"} { + // clang-format off + static const FunctionInfo functions[] = { + {21, nullptr, "GetApplicationContentPath"}, + {23, nullptr, "ResolveApplicationContentPath"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class IDownloadTaskInterface final : public ServiceFramework<IDownloadTaskInterface> { +public: + explicit IDownloadTaskInterface() : ServiceFramework{"IDownloadTaskInterface"} { + // clang-format off + static const FunctionInfo functions[] = { + {701, nullptr, "ClearTaskStatusList"}, + {702, nullptr, "RequestDownloadTaskList"}, + {703, nullptr, "RequestEnsureDownloadTask"}, + {704, nullptr, "ListDownloadTaskStatus"}, + {705, nullptr, "RequestDownloadTaskListData"}, + {706, nullptr, "TryCommitCurrentApplicationDownloadTask"}, + {707, nullptr, "EnableAutoCommit"}, + {708, nullptr, "DisableAutoCommit"}, + {709, nullptr, "TriggerDynamicCommitEvent"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class IECommerceInterface final : public ServiceFramework<IECommerceInterface> { +public: + explicit IECommerceInterface() : ServiceFramework{"IECommerceInterface"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "RequestLinkDevice"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class IFactoryResetInterface final : public ServiceFramework<IFactoryResetInterface> { +public: + explicit IFactoryResetInterface() : ServiceFramework{"IFactoryResetInterface"} { + // clang-format off + static const FunctionInfo functions[] = { + {100, nullptr, "ResetToFactorySettings"}, + {101, nullptr, "ResetToFactorySettingsWithoutUserSaveData"}, + {102, nullptr, "ResetToFactorySettingsForRefurbishment "}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class NS final : public ServiceFramework<NS> { +public: + explicit NS(const char* name) : ServiceFramework{name} { + // clang-format off + static const FunctionInfo functions[] = { + {7992, &NS::PushInterface<IECommerceInterface>, "GetECommerceInterface"}, + {7993, &NS::PushInterface<IApplicationVersionInterface>, "GetApplicationVersionInterface"}, + {7994, &NS::PushInterface<IFactoryResetInterface>, "GetFactoryResetInterface"}, + {7995, &NS::PushInterface<IAccountProxyInterface>, "GetAccountProxyInterface"}, + {7996, &NS::PushInterface<IApplicationManagerInterface>, "GetApplicationManagerInterface"}, + {7997, &NS::PushInterface<IDownloadTaskInterface>, "GetDownloadTaskInterface"}, + {7998, &NS::PushInterface<IContentManagerInterface>, "GetContentManagementInterface"}, + {7999, &NS::PushInterface<IDocumentInterface>, "GetDocumentInterface"}, + }; + // clang-format on + + RegisterHandlers(functions); + } + +private: + template <typename T> + void PushInterface(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface<T>(); + + LOG_DEBUG(Service_NS, "called"); + } +}; + +class NS_DEV final : public ServiceFramework<NS_DEV> { +public: + explicit NS_DEV() : ServiceFramework{"ns:dev"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "LaunchProgram"}, + {1, nullptr, "TerminateProcess"}, + {2, nullptr, "TerminateProgram"}, + {3, nullptr, "GetShellEventHandle"}, + {4, nullptr, "GetShellEventInfo"}, + {5, nullptr, "TerminateApplication"}, + {6, nullptr, "PrepareLaunchProgramFromHost"}, + {7, nullptr, "LaunchApplication"}, + {8, nullptr, "LaunchApplicationWithStorageId"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class ISystemUpdateControl final : public ServiceFramework<ISystemUpdateControl> { +public: + explicit ISystemUpdateControl() : ServiceFramework{"ISystemUpdateControl"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "HasDownloaded"}, + {1, nullptr, "RequestCheckLatestUpdate"}, + {2, nullptr, "RequestDownloadLatestUpdate"}, + {3, nullptr, "GetDownloadProgress"}, + {4, nullptr, "ApplyDownloadedUpdate"}, + {5, nullptr, "RequestPrepareCardUpdate"}, + {6, nullptr, "GetPrepareCardUpdateProgress"}, + {7, nullptr, "HasPreparedCardUpdate"}, + {8, nullptr, "ApplyCardUpdate"}, + {9, nullptr, "GetDownloadedEulaDataSize"}, + {10, nullptr, "GetDownloadedEulaData"}, + {11, nullptr, "SetupCardUpdate"}, + {12, nullptr, "GetPreparedCardUpdateEulaDataSize"}, + {13, nullptr, "GetPreparedCardUpdateEulaData"}, + {14, nullptr, "SetupCardUpdateViaSystemUpdater"}, + {15, nullptr, "HasReceived"}, + {16, nullptr, "RequestReceiveSystemUpdate"}, + {17, nullptr, "GetReceiveProgress"}, + {18, nullptr, "ApplyReceivedUpdate"}, + {19, nullptr, "GetReceivedEulaDataSize"}, + {20, nullptr, "GetReceivedEulaData"}, + {21, nullptr, "SetupToReceiveSystemUpdate"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class NS_SU final : public ServiceFramework<NS_SU> { +public: + explicit NS_SU() : ServiceFramework{"ns:su"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GetBackgroundNetworkUpdateState"}, + {1, &NS_SU::OpenSystemUpdateControl, "OpenSystemUpdateControl"}, + {2, nullptr, "NotifyExFatDriverRequired"}, + {3, nullptr, "ClearExFatDriverStatusForDebug"}, + {4, nullptr, "RequestBackgroundNetworkUpdate"}, + {5, nullptr, "NotifyBackgroundNetworkUpdate"}, + {6, nullptr, "NotifyExFatDriverDownloadedForDebug"}, + {9, nullptr, "GetSystemUpdateNotificationEventForContentDelivery"}, + {10, nullptr, "NotifySystemUpdateForContentDelivery"}, + {11, nullptr, "PrepareShutdown"}, + {16, nullptr, "DestroySystemUpdateTask"}, + {17, nullptr, "RequestSendSystemUpdate"}, + {18, nullptr, "GetSendSystemUpdateProgress"}, + }; + // clang-format on + + RegisterHandlers(functions); + } + +private: + void OpenSystemUpdateControl(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface<ISystemUpdateControl>(); + + LOG_DEBUG(Service_NS, "called"); + } +}; + +class NS_VM final : public ServiceFramework<NS_VM> { +public: + explicit NS_VM() : ServiceFramework{"ns:vm"} { + // clang-format off + static const FunctionInfo functions[] = { + {1200, nullptr, "NeedsUpdateVulnerability"}, + {1201, nullptr, "UpdateSafeSystemVersionForDebug"}, + {1202, nullptr, "GetSafeSystemVersion"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + void InstallInterfaces(SM::ServiceManager& service_manager) { + std::make_shared<NS>("ns:am2")->InstallAsService(service_manager); + std::make_shared<NS>("ns:ec")->InstallAsService(service_manager); + std::make_shared<NS>("ns:rid")->InstallAsService(service_manager); + std::make_shared<NS>("ns:rt")->InstallAsService(service_manager); + std::make_shared<NS>("ns:web")->InstallAsService(service_manager); + + std::make_shared<NS_DEV>()->InstallAsService(service_manager); + std::make_shared<NS_SU>()->InstallAsService(service_manager); + std::make_shared<NS_VM>()->InstallAsService(service_manager); + std::make_shared<PL_U>()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp index 7132b18ad..adf180509 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.cpp +++ b/src/core/hle/service/nvflinger/buffer_queue.cpp @@ -4,9 +4,8 @@ #include <algorithm> -#include "common/alignment.h" -#include "common/scope_exit.h" -#include "core/core_timing.h" +#include "common/assert.h" +#include "common/logging/log.h" #include "core/hle/service/nvflinger/buffer_queue.h" namespace Service { diff --git a/src/core/hle/service/pcv/pcv.cpp b/src/core/hle/service/pcv/pcv.cpp new file mode 100644 index 000000000..d6891a659 --- /dev/null +++ b/src/core/hle/service/pcv/pcv.cpp @@ -0,0 +1,84 @@ +// 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/pcv/pcv.h" +#include "core/hle/service/service.h" +#include "core/hle/service/sm/sm.h" + +namespace Service::PCV { + +class PCV final : public ServiceFramework<PCV> { +public: + explicit PCV() : ServiceFramework{"pcv"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "SetPowerEnabled"}, + {1, nullptr, "SetClockEnabled"}, + {2, nullptr, "SetClockRate"}, + {3, nullptr, "GetClockRate"}, + {4, nullptr, "GetState"}, + {5, nullptr, "GetPossibleClockRates"}, + {6, nullptr, "SetMinVClockRate"}, + {7, nullptr, "SetReset"}, + {8, nullptr, "SetVoltageEnabled"}, + {9, nullptr, "GetVoltageEnabled"}, + {10, nullptr, "GetVoltageRange"}, + {11, nullptr, "SetVoltageValue"}, + {12, nullptr, "GetVoltageValue"}, + {13, nullptr, "GetTemperatureThresholds"}, + {14, nullptr, "SetTemperature"}, + {15, nullptr, "Initialize"}, + {16, nullptr, "IsInitialized"}, + {17, nullptr, "Finalize"}, + {18, nullptr, "PowerOn"}, + {19, nullptr, "PowerOff"}, + {20, nullptr, "ChangeVoltage"}, + {21, nullptr, "GetPowerClockInfoEvent"}, + {22, nullptr, "GetOscillatorClock"}, + {23, nullptr, "GetDvfsTable"}, + {24, nullptr, "GetModuleStateTable"}, + {25, nullptr, "GetPowerDomainStateTable"}, + {26, nullptr, "GetFuseInfo"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class PCV_ARB final : public ServiceFramework<PCV_ARB> { +public: + explicit PCV_ARB() : ServiceFramework{"pcv:arb"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "ReleaseControl"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class PCV_IMM final : public ServiceFramework<PCV_IMM> { +public: + explicit PCV_IMM() : ServiceFramework{"pcv:imm"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "SetClockRate"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<PCV>()->InstallAsService(sm); + std::make_shared<PCV_ARB>()->InstallAsService(sm); + std::make_shared<PCV_IMM>()->InstallAsService(sm); +} + +} // namespace Service::PCV diff --git a/src/core/hle/service/pcv/pcv.h b/src/core/hle/service/pcv/pcv.h new file mode 100644 index 000000000..219a893c3 --- /dev/null +++ b/src/core/hle/service/pcv/pcv.h @@ -0,0 +1,15 @@ +// 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::PCV { + +void InstallInterfaces(SM::ServiceManager& sm); + +} // namespace Service::PCV diff --git a/src/core/hle/service/psc/psc.cpp b/src/core/hle/service/psc/psc.cpp new file mode 100644 index 000000000..bbad870a2 --- /dev/null +++ b/src/core/hle/service/psc/psc.cpp @@ -0,0 +1,77 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <memory> + +#include "common/logging/log.h" +#include "core/hle/ipc_helpers.h" +#include "core/hle/service/psc/psc.h" +#include "core/hle/service/service.h" +#include "core/hle/service/sm/sm.h" + +namespace Service::PSC { + +class PSC_C final : public ServiceFramework<PSC_C> { +public: + explicit PSC_C() : ServiceFramework{"psc:c"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "Unknown1"}, + {1, nullptr, "Unknown2"}, + {2, nullptr, "Unknown3"}, + {3, nullptr, "Unknown4"}, + {4, nullptr, "Unknown5"}, + {5, nullptr, "Unknown6"}, + {6, nullptr, "Unknown7"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class IPmModule final : public ServiceFramework<IPmModule> { +public: + explicit IPmModule() : ServiceFramework{"IPmModule"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "Initialize"}, + {1, nullptr, "GetRequest"}, + {2, nullptr, "Acknowledge"}, + {3, nullptr, "Unknown1"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class PSC_M final : public ServiceFramework<PSC_M> { +public: + explicit PSC_M() : ServiceFramework{"psc:m"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, &PSC_M::GetPmModule, "GetPmModule"}, + }; + // clang-format on + + RegisterHandlers(functions); + } + +private: + void GetPmModule(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface<IPmModule>(); + + LOG_DEBUG(Service_PSC, "called"); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<PSC_C>()->InstallAsService(sm); + std::make_shared<PSC_M>()->InstallAsService(sm); +} + +} // namespace Service::PSC diff --git a/src/core/hle/service/psc/psc.h b/src/core/hle/service/psc/psc.h new file mode 100644 index 000000000..5052eb02c --- /dev/null +++ b/src/core/hle/service/psc/psc.h @@ -0,0 +1,15 @@ +// 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::PSC { + +void InstallInterfaces(SM::ServiceManager& sm); + +} // namespace Service::PSC diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index fccc4c461..61e0c34a0 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -21,8 +21,10 @@ #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/bpc/bpc.h" #include "core/hle/service/btdrv/btdrv.h" #include "core/hle/service/btm/btm.h" +#include "core/hle/service/caps/caps.h" #include "core/hle/service/erpt/erpt.h" #include "core/hle/service/es/es.h" #include "core/hle/service/eupld/eupld.h" @@ -36,6 +38,7 @@ #include "core/hle/service/ldn/ldn.h" #include "core/hle/service/ldr/ldr.h" #include "core/hle/service/lm/lm.h" +#include "core/hle/service/mig/mig.h" #include "core/hle/service/mii/mii.h" #include "core/hle/service/mm/mm_u.h" #include "core/hle/service/ncm/ncm.h" @@ -47,8 +50,10 @@ #include "core/hle/service/nvdrv/nvdrv.h" #include "core/hle/service/pcie/pcie.h" #include "core/hle/service/pctl/pctl.h" +#include "core/hle/service/pcv/pcv.h" #include "core/hle/service/pm/pm.h" #include "core/hle/service/prepo/prepo.h" +#include "core/hle/service/psc/psc.h" #include "core/hle/service/service.h" #include "core/hle/service/set/settings.h" #include "core/hle/service/sm/controller.h" @@ -204,8 +209,10 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { APM::InstallInterfaces(*sm); Audio::InstallInterfaces(*sm); BCAT::InstallInterfaces(*sm); + BPC::InstallInterfaces(*sm); BtDrv::InstallInterfaces(*sm); BTM::InstallInterfaces(*sm); + Capture::InstallInterfaces(*sm); ERPT::InstallInterfaces(*sm); ES::InstallInterfaces(*sm); EUPLD::InstallInterfaces(*sm); @@ -219,6 +226,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { LDN::InstallInterfaces(*sm); LDR::InstallInterfaces(*sm); LM::InstallInterfaces(*sm); + Migration::InstallInterfaces(*sm); Mii::InstallInterfaces(*sm); MM::InstallInterfaces(*sm); NCM::InstallInterfaces(*sm); @@ -230,8 +238,10 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { Nvidia::InstallInterfaces(*sm); PCIe::InstallInterfaces(*sm); PCTL::InstallInterfaces(*sm); + PCV::InstallInterfaces(*sm); PlayReport::InstallInterfaces(*sm); PM::InstallInterfaces(*sm); + PSC::InstallInterfaces(*sm); Set::InstallInterfaces(*sm); Sockets::InstallInterfaces(*sm); SPL::InstallInterfaces(*sm); diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 180f22703..046c5e18d 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -8,10 +8,9 @@ #include <string> #include <unordered_map> #include <boost/container/flat_map.hpp> -#include "common/bit_field.h" #include "common/common_types.h" #include "core/hle/kernel/hle_ipc.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace Service diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp index 1651f6122..a461e72ec 100644 --- a/src/core/hle/service/set/set.cpp +++ b/src/core/hle/service/set/set.cpp @@ -8,6 +8,7 @@ #include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" #include "core/hle/service/set/set.h" +#include "core/settings.h" namespace Service::Set { @@ -31,6 +32,10 @@ constexpr std::array<LanguageCode, 17> available_language_codes = {{ LanguageCode::ZH_HANT, }}; +LanguageCode GetLanguageCodeFromIndex(size_t index) { + return available_language_codes.at(index); +} + void SET::GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx) { ctx.WriteBuffer(available_language_codes); @@ -49,9 +54,17 @@ void SET::GetAvailableLanguageCodeCount(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); } +void SET::GetLanguageCode(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.Push(static_cast<u64>(available_language_codes[Settings::values.language_index])); + + LOG_DEBUG(Service_SET, "called {}", Settings::values.language_index); +} + SET::SET() : ServiceFramework("set") { static const FunctionInfo functions[] = { - {0, nullptr, "GetLanguageCode"}, + {0, &SET::GetLanguageCode, "GetLanguageCode"}, {1, &SET::GetAvailableLanguageCodes, "GetAvailableLanguageCodes"}, {2, nullptr, "MakeLanguageCode"}, {3, &SET::GetAvailableLanguageCodeCount, "GetAvailableLanguageCodeCount"}, diff --git a/src/core/hle/service/set/set.h b/src/core/hle/service/set/set.h index a2472ec4c..4232b6162 100644 --- a/src/core/hle/service/set/set.h +++ b/src/core/hle/service/set/set.h @@ -28,6 +28,7 @@ enum class LanguageCode : u64 { ZH_HANS = 0x00736E61482D687A, ZH_HANT = 0x00746E61482D687A, }; +LanguageCode GetLanguageCodeFromIndex(size_t idx); class SET final : public ServiceFramework<SET> { public: @@ -35,6 +36,7 @@ public: ~SET() = default; private: + void GetLanguageCode(Kernel::HLERequestContext& ctx); void GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx); void GetAvailableLanguageCodeCount(Kernel::HLERequestContext& ctx); }; diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index e2a00e4f6..e8ea62f08 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -4,9 +4,11 @@ #pragma once +#include <memory> #include <string> #include <unordered_map> -#include "core/hle/kernel/kernel.h" + +#include "core/hle/kernel/object.h" #include "core/hle/result.h" #include "core/hle/service/service.h" @@ -19,6 +21,8 @@ class SessionRequestHandler; namespace Service::SM { +class Controller; + /// Interface to "sm:" service class SM final : public ServiceFramework<SM> { public: @@ -32,8 +36,6 @@ private: std::shared_ptr<ServiceManager> service_manager; }; -class Controller; - constexpr ResultCode ERR_SERVICE_NOT_REGISTERED(-1); constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(-1); constexpr ResultCode ERR_INVALID_NAME_SIZE(-1); diff --git a/src/core/hw/aes/ccm.cpp b/src/core/hw/aes/ccm.cpp deleted file mode 100644 index 1ee37aaa4..000000000 --- a/src/core/hw/aes/ccm.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include <algorithm> -#include "common/alignment.h" -#include "common/assert.h" -#include "common/logging/log.h" -#include "core/hw/aes/ccm.h" -#include "core/hw/aes/key.h" - -namespace HW { -namespace AES { - -std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& nonce, - size_t slot_id) { - UNIMPLEMENTED(); - return {}; -} - -std::vector<u8> DecryptVerifyCCM(const std::vector<u8>& cipher, const CCMNonce& nonce, - size_t slot_id) { - UNIMPLEMENTED(); - return {}; -} - -} // namespace AES -} // namespace HW diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp deleted file mode 100644 index 2f48068c1..000000000 --- a/src/core/hw/hw.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2014 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "common/common_types.h" -#include "common/logging/log.h" -#include "core/hw/hw.h" -#include "core/hw/lcd.h" - -namespace HW { - -template <typename T> -inline void Read(T& var, const u32 addr) { - switch (addr & 0xFFFFF000) { - case VADDR_GPU: - case VADDR_GPU + 0x1000: - case VADDR_GPU + 0x2000: - case VADDR_GPU + 0x3000: - case VADDR_GPU + 0x4000: - case VADDR_GPU + 0x5000: - case VADDR_GPU + 0x6000: - case VADDR_GPU + 0x7000: - case VADDR_GPU + 0x8000: - case VADDR_GPU + 0x9000: - case VADDR_GPU + 0xA000: - case VADDR_GPU + 0xB000: - case VADDR_GPU + 0xC000: - case VADDR_GPU + 0xD000: - case VADDR_GPU + 0xE000: - case VADDR_GPU + 0xF000: - break; - case VADDR_LCD: - LCD::Read(var, addr); - break; - default: - LOG_ERROR(HW_Memory, "Unknown Read{} @ 0x{:08X}", sizeof(var) * 8, addr); - break; - } -} - -template <typename T> -inline void Write(u32 addr, const T data) { - switch (addr & 0xFFFFF000) { - case VADDR_GPU: - case VADDR_GPU + 0x1000: - case VADDR_GPU + 0x2000: - case VADDR_GPU + 0x3000: - case VADDR_GPU + 0x4000: - case VADDR_GPU + 0x5000: - case VADDR_GPU + 0x6000: - case VADDR_GPU + 0x7000: - case VADDR_GPU + 0x8000: - case VADDR_GPU + 0x9000: - case VADDR_GPU + 0xA000: - case VADDR_GPU + 0xB000: - case VADDR_GPU + 0xC000: - case VADDR_GPU + 0xD000: - case VADDR_GPU + 0xE000: - case VADDR_GPU + 0xF000: - break; - case VADDR_LCD: - LCD::Write(addr, data); - break; - default: - LOG_ERROR(HW_Memory, "Unknown Write{} 0x{:08X} @ 0x{:08X}", sizeof(data) * 8, data, addr); - break; - } -} - -// Explicitly instantiate template functions because we aren't defining this in the header: - -template void Read<u64>(u64& var, const u32 addr); -template void Read<u32>(u32& var, const u32 addr); -template void Read<u16>(u16& var, const u32 addr); -template void Read<u8>(u8& var, const u32 addr); - -template void Write<u64>(u32 addr, const u64 data); -template void Write<u32>(u32 addr, const u32 data); -template void Write<u16>(u32 addr, const u16 data); -template void Write<u8>(u32 addr, const u8 data); - -/// Update hardware -void Update() {} - -/// Initialize hardware -void Init() { - LCD::Init(); - LOG_DEBUG(HW, "Initialized OK"); -} - -/// Shutdown hardware -void Shutdown() { - LCD::Shutdown(); - LOG_DEBUG(HW, "Shutdown OK"); -} -} // namespace HW diff --git a/src/core/hw/hw.h b/src/core/hw/hw.h deleted file mode 100644 index 5890d2b5c..000000000 --- a/src/core/hw/hw.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2014 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include "common/common_types.h" - -namespace HW { - -/// Beginnings of IO register regions, in the user VA space. -enum : u32 { - VADDR_HASH = 0x1EC01000, - VADDR_CSND = 0x1EC03000, - VADDR_DSP = 0x1EC40000, - VADDR_PDN = 0x1EC41000, - VADDR_CODEC = 0x1EC41000, - VADDR_SPI = 0x1EC42000, - VADDR_SPI_2 = 0x1EC43000, // Only used under TWL_FIRM? - VADDR_I2C = 0x1EC44000, - VADDR_CODEC_2 = 0x1EC45000, - VADDR_HID = 0x1EC46000, - VADDR_GPIO = 0x1EC47000, - VADDR_I2C_2 = 0x1EC48000, - VADDR_SPI_3 = 0x1EC60000, - VADDR_I2C_3 = 0x1EC61000, - VADDR_MIC = 0x1EC62000, - VADDR_PXI = 0x1EC63000, - VADDR_LCD = 0x1ED02000, - VADDR_DSP_2 = 0x1ED03000, - VADDR_HASH_2 = 0x1EE01000, - VADDR_GPU = 0x1EF00000, -}; - -template <typename T> -void Read(T& var, const u32 addr); - -template <typename T> -void Write(u32 addr, const T data); - -/// Update hardware -void Update(); - -/// Initialize hardware -void Init(); - -/// Shutdown hardware -void Shutdown(); - -} // namespace HW diff --git a/src/core/hw/lcd.cpp b/src/core/hw/lcd.cpp deleted file mode 100644 index 0b62174d5..000000000 --- a/src/core/hw/lcd.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2015 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include <cstring> -#include "common/common_types.h" -#include "common/logging/log.h" -#include "core/hw/hw.h" -#include "core/hw/lcd.h" -#include "core/tracer/recorder.h" - -namespace LCD { - -Regs g_regs; - -template <typename T> -inline void Read(T& var, const u32 raw_addr) { - u32 addr = raw_addr - HW::VADDR_LCD; - u32 index = addr / 4; - - // Reads other than u32 are untested, so I'd rather have them abort than silently fail - if (index >= 0x400 || !std::is_same<T, u32>::value) { - LOG_ERROR(HW_LCD, "Unknown Read{} @ 0x{:08X}", sizeof(var) * 8, addr); - return; - } - - var = g_regs[index]; -} - -template <typename T> -inline void Write(u32 addr, const T data) { - addr -= HW::VADDR_LCD; - u32 index = addr / 4; - - // Writes other than u32 are untested, so I'd rather have them abort than silently fail - if (index >= 0x400 || !std::is_same<T, u32>::value) { - LOG_ERROR(HW_LCD, "Unknown Write{} 0x{:08X} @ 0x{:08X}", sizeof(data) * 8, data, addr); - return; - } - - g_regs[index] = static_cast<u32>(data); -} - -// Explicitly instantiate template functions because we aren't defining this in the header: - -template void Read<u64>(u64& var, const u32 addr); -template void Read<u32>(u32& var, const u32 addr); -template void Read<u16>(u16& var, const u32 addr); -template void Read<u8>(u8& var, const u32 addr); - -template void Write<u64>(u32 addr, const u64 data); -template void Write<u32>(u32 addr, const u32 data); -template void Write<u16>(u32 addr, const u16 data); -template void Write<u8>(u32 addr, const u8 data); - -/// Initialize hardware -void Init() { - memset(&g_regs, 0, sizeof(g_regs)); - LOG_DEBUG(HW_LCD, "Initialized OK"); -} - -/// Shutdown hardware -void Shutdown() { - LOG_DEBUG(HW_LCD, "Shutdown OK"); -} - -} // namespace LCD diff --git a/src/core/hw/lcd.h b/src/core/hw/lcd.h deleted file mode 100644 index d2db9700f..000000000 --- a/src/core/hw/lcd.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2015 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include <cstddef> -#include <type_traits> -#include "common/bit_field.h" -#include "common/common_funcs.h" -#include "common/common_types.h" - -#define LCD_REG_INDEX(field_name) (offsetof(LCD::Regs, field_name) / sizeof(u32)) - -namespace LCD { - -struct Regs { - - union ColorFill { - u32 raw; - - BitField<0, 8, u32> color_r; - BitField<8, 8, u32> color_g; - BitField<16, 8, u32> color_b; - BitField<24, 1, u32> is_enabled; - }; - - INSERT_PADDING_WORDS(0x81); - ColorFill color_fill_top; - INSERT_PADDING_WORDS(0xE); - u32 backlight_top; - - INSERT_PADDING_WORDS(0x1F0); - - ColorFill color_fill_bottom; - INSERT_PADDING_WORDS(0xE); - u32 backlight_bottom; - INSERT_PADDING_WORDS(0x16F); - - static constexpr size_t NumIds() { - return sizeof(Regs) / sizeof(u32); - } - - const u32& operator[](int index) const { - const u32* content = reinterpret_cast<const u32*>(this); - return content[index]; - } - - u32& operator[](int index) { - u32* content = reinterpret_cast<u32*>(this); - return content[index]; - } -}; -static_assert(std::is_standard_layout<Regs>::value, "Structure does not use standard layout"); - -// TODO: MSVC does not support using offsetof() on non-static data members even though this -// is technically allowed since C++11. This macro should be enabled once MSVC adds -// support for that. -#ifndef _MSC_VER -#define ASSERT_REG_POSITION(field_name, position) \ - static_assert(offsetof(Regs, field_name) == position * 4, \ - "Field " #field_name " has invalid position") - -ASSERT_REG_POSITION(color_fill_top, 0x81); -ASSERT_REG_POSITION(backlight_top, 0x90); -ASSERT_REG_POSITION(color_fill_bottom, 0x281); -ASSERT_REG_POSITION(backlight_bottom, 0x290); - -#undef ASSERT_REG_POSITION -#endif // !defined(_MSC_VER) - -extern Regs g_regs; - -template <typename T> -void Read(T& var, const u32 addr); - -template <typename T> -void Write(u32 addr, const T data); - -/// Initialize hardware -void Init(); - -/// Shutdown hardware -void Shutdown(); - -} // namespace LCD diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.h index 982a037f7..7319ba6ea 100644 --- a/src/core/loader/deconstructed_rom_directory.h +++ b/src/core/loader/deconstructed_rom_directory.h @@ -7,7 +7,7 @@ #include <string> #include "common/common_types.h" #include "core/file_sys/program_metadata.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/loader/loader.h" namespace Loader { diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index 352938dcb..a7133f5a6 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp @@ -311,11 +311,11 @@ SharedPtr<CodeSet> ElfReader::LoadInto(u32 vaddr) { CodeSet::Segment* codeset_segment; u32 permission_flags = p->p_flags & (PF_R | PF_W | PF_X); if (permission_flags == (PF_R | PF_X)) { - codeset_segment = &codeset->code; + codeset_segment = &codeset->CodeSegment(); } else if (permission_flags == (PF_R)) { - codeset_segment = &codeset->rodata; + codeset_segment = &codeset->RODataSegment(); } else if (permission_flags == (PF_R | PF_W)) { - codeset_segment = &codeset->data; + codeset_segment = &codeset->DataSegment(); } else { LOG_ERROR(Loader, "Unexpected ELF PT_LOAD segment id {} with flags {:X}", i, p->p_flags); diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index cd8b41bb6..e69ab85ef 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -14,7 +14,7 @@ #include "common/common_types.h" #include "common/file_util.h" #include "core/file_sys/vfs.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" namespace Kernel { struct AddressMapping; diff --git a/src/core/loader/nca.h b/src/core/loader/nca.h index fb96c0a22..e14d618b3 100644 --- a/src/core/loader/nca.h +++ b/src/core/loader/nca.h @@ -8,7 +8,7 @@ #include "common/common_types.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/program_metadata.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/loader/loader.h" namespace Loader { diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 7d3ec2a76..dc053cdad 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp @@ -159,7 +159,7 @@ bool AppLoader_NRO::LoadNro(FileSys::VirtualFile file, VAddr load_base) { // Resize program image to include .bss section and page align each section bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset); } - codeset->data.size += bss_size; + codeset->DataSegment().size += bss_size; program_image.resize(static_cast<u32>(program_image.size()) + bss_size); // Load codeset for current process diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h index 04a0f497e..bb01c9e25 100644 --- a/src/core/loader/nro.h +++ b/src/core/loader/nro.h @@ -6,7 +6,7 @@ #include <string> #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/loader/linker.h" #include "core/loader/loader.h" diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 06b1b33f4..fee7d58c6 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -127,7 +127,7 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base) { // Resize program image to include .bss section and page align each section bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset); } - codeset->data.size += bss_size; + codeset->DataSegment().size += bss_size; const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)}; program_image.resize(image_size); diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h index 3f7567500..aaeb1f2a9 100644 --- a/src/core/loader/nso.h +++ b/src/core/loader/nso.h @@ -6,7 +6,7 @@ #include <string> #include "common/common_types.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" #include "core/loader/linker.h" #include "core/loader/loader.h" diff --git a/src/core/memory.cpp b/src/core/memory.cpp index e753e3436..4b3bb7b31 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -14,7 +14,6 @@ #include "common/swap.h" #include "core/arm/arm_interface.h" #include "core/core.h" -#include "core/hle/kernel/memory.h" #include "core/hle/kernel/process.h" #include "core/hle/lock.h" #include "core/memory.h" @@ -24,8 +23,6 @@ namespace Memory { -static std::array<u8, Memory::VRAM_SIZE> vram; - static PageTable* current_page_table = nullptr; void SetCurrentPageTable(PageTable* page_table) { @@ -102,22 +99,6 @@ void RemoveDebugHook(PageTable& page_table, VAddr base, u64 size, MemoryHookPoin } /** - * This function should only be called for virtual addreses with attribute `PageType::Special`. - */ -static std::set<MemoryHookPointer> GetSpecialHandlers(const PageTable& page_table, VAddr vaddr, - u64 size) { - std::set<MemoryHookPointer> result; - auto interval = boost::icl::discrete_interval<VAddr>::closed(vaddr, vaddr + size - 1); - auto interval_list = page_table.special_regions.equal_range(interval); - for (auto it = interval_list.first; it != interval_list.second; ++it) { - for (const auto& region : it->second) { - result.insert(region.handler); - } - } - return result; -} - -/** * Gets a pointer to the exact memory at the virtual address (i.e. not page aligned) * using a VMA from the current process */ @@ -242,10 +223,6 @@ bool IsKernelVirtualAddress(const VAddr vaddr) { return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END; } -bool IsValidPhysicalAddress(const PAddr paddr) { - return GetPhysicalPointer(paddr) != nullptr; -} - u8* GetPointer(const VAddr vaddr) { u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS]; if (page_pointer) { @@ -274,61 +251,6 @@ std::string ReadCString(VAddr vaddr, std::size_t max_length) { return string; } -u8* GetPhysicalPointer(PAddr address) { - struct MemoryArea { - PAddr paddr_base; - u32 size; - }; - - static constexpr MemoryArea memory_areas[] = { - {VRAM_PADDR, VRAM_SIZE}, - {IO_AREA_PADDR, IO_AREA_SIZE}, - {DSP_RAM_PADDR, DSP_RAM_SIZE}, - {FCRAM_PADDR, FCRAM_N3DS_SIZE}, - }; - - const auto area = - std::find_if(std::begin(memory_areas), std::end(memory_areas), [&](const auto& area) { - return address >= area.paddr_base && address < area.paddr_base + area.size; - }); - - if (area == std::end(memory_areas)) { - LOG_ERROR(HW_Memory, "Unknown GetPhysicalPointer @ 0x{:016X}", address); - return nullptr; - } - - if (area->paddr_base == IO_AREA_PADDR) { - LOG_ERROR(HW_Memory, "MMIO mappings are not supported yet. phys_addr={:016X}", address); - return nullptr; - } - - u64 offset_into_region = address - area->paddr_base; - - u8* target_pointer = nullptr; - switch (area->paddr_base) { - case VRAM_PADDR: - target_pointer = vram.data() + offset_into_region; - break; - case DSP_RAM_PADDR: - break; - case FCRAM_PADDR: - for (const auto& region : Kernel::memory_regions) { - if (offset_into_region >= region.base && - offset_into_region < region.base + region.size) { - target_pointer = - region.linear_heap_memory->data() + offset_into_region - region.base; - break; - } - } - ASSERT_MSG(target_pointer != nullptr, "Invalid FCRAM address"); - break; - default: - UNREACHABLE(); - } - - return target_pointer; -} - void RasterizerMarkRegionCached(Tegra::GPUVAddr gpu_addr, u64 size, bool cached) { if (gpu_addr == 0) { return; @@ -666,48 +588,4 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, size_t size) { CopyBlock(*Core::CurrentProcess(), dest_addr, src_addr, size); } -boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) { - if (addr == 0) { - return 0; - } else if (addr >= VRAM_VADDR && addr < VRAM_VADDR_END) { - return addr - VRAM_VADDR + VRAM_PADDR; - } else if (addr >= LINEAR_HEAP_VADDR && addr < LINEAR_HEAP_VADDR_END) { - return addr - LINEAR_HEAP_VADDR + FCRAM_PADDR; - } else if (addr >= NEW_LINEAR_HEAP_VADDR && addr < NEW_LINEAR_HEAP_VADDR_END) { - return addr - NEW_LINEAR_HEAP_VADDR + FCRAM_PADDR; - } else if (addr >= DSP_RAM_VADDR && addr < DSP_RAM_VADDR_END) { - return addr - DSP_RAM_VADDR + DSP_RAM_PADDR; - } else if (addr >= IO_AREA_VADDR && addr < IO_AREA_VADDR_END) { - return addr - IO_AREA_VADDR + IO_AREA_PADDR; - } - - return boost::none; -} - -PAddr VirtualToPhysicalAddress(const VAddr addr) { - auto paddr = TryVirtualToPhysicalAddress(addr); - if (!paddr) { - LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x{:016X}", addr); - // To help with debugging, set bit on address so that it's obviously invalid. - return addr | 0x80000000; - } - return *paddr; -} - -boost::optional<VAddr> PhysicalToVirtualAddress(const PAddr addr) { - if (addr == 0) { - return 0; - } else if (addr >= VRAM_PADDR && addr < VRAM_PADDR_END) { - return addr - VRAM_PADDR + VRAM_VADDR; - } else if (addr >= FCRAM_PADDR && addr < FCRAM_PADDR_END) { - return addr - FCRAM_PADDR + Core::CurrentProcess()->GetLinearHeapAreaAddress(); - } else if (addr >= DSP_RAM_PADDR && addr < DSP_RAM_PADDR_END) { - return addr - DSP_RAM_PADDR + DSP_RAM_VADDR; - } else if (addr >= IO_AREA_PADDR && addr < IO_AREA_PADDR_END) { - return addr - IO_AREA_PADDR + IO_AREA_VADDR; - } - - return boost::none; -} - } // namespace Memory diff --git a/src/core/memory.h b/src/core/memory.h index 8d5d017a4..b5d885b8a 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -6,12 +6,9 @@ #include <array> #include <cstddef> -#include <map> #include <string> #include <tuple> -#include <vector> #include <boost/icl/interval_map.hpp> -#include <boost/optional.hpp> #include "common/common_types.h" #include "core/memory_hook.h" #include "video_core/memory_manager.h" @@ -85,40 +82,6 @@ struct PageTable { std::array<PageType, PAGE_TABLE_NUM_ENTRIES> attributes; }; -/// Physical memory regions as seen from the ARM11 -enum : PAddr { - /// IO register area - IO_AREA_PADDR = 0x10100000, - IO_AREA_SIZE = 0x01000000, ///< IO area size (16MB) - IO_AREA_PADDR_END = IO_AREA_PADDR + IO_AREA_SIZE, - - /// MPCore internal memory region - MPCORE_RAM_PADDR = 0x17E00000, - MPCORE_RAM_SIZE = 0x00002000, ///< MPCore internal memory size (8KB) - MPCORE_RAM_PADDR_END = MPCORE_RAM_PADDR + MPCORE_RAM_SIZE, - - /// Video memory - VRAM_PADDR = 0x18000000, - VRAM_SIZE = 0x00600000, ///< VRAM size (6MB) - VRAM_PADDR_END = VRAM_PADDR + VRAM_SIZE, - - /// DSP memory - DSP_RAM_PADDR = 0x1FF00000, - DSP_RAM_SIZE = 0x00080000, ///< DSP memory size (512KB) - DSP_RAM_PADDR_END = DSP_RAM_PADDR + DSP_RAM_SIZE, - - /// AXI WRAM - AXI_WRAM_PADDR = 0x1FF80000, - AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size (512KB) - AXI_WRAM_PADDR_END = AXI_WRAM_PADDR + AXI_WRAM_SIZE, - - /// Main FCRAM - FCRAM_PADDR = 0x20000000, - FCRAM_SIZE = 0x08000000, ///< FCRAM size on the Old 3DS (128MB) - FCRAM_N3DS_SIZE = 0x10000000, ///< FCRAM size on the New 3DS (256MB) - FCRAM_PADDR_END = FCRAM_PADDR + FCRAM_SIZE, -}; - /// Virtual user-space memory regions enum : VAddr { /// Where the application text, data and bss reside. @@ -126,24 +89,6 @@ enum : VAddr { PROCESS_IMAGE_MAX_SIZE = 0x08000000, PROCESS_IMAGE_VADDR_END = PROCESS_IMAGE_VADDR + PROCESS_IMAGE_MAX_SIZE, - /// Maps 1:1 to an offset in FCRAM. Used for HW allocations that need to be linear in physical - /// memory. - LINEAR_HEAP_VADDR = 0x14000000, - LINEAR_HEAP_SIZE = 0x08000000, - LINEAR_HEAP_VADDR_END = LINEAR_HEAP_VADDR + LINEAR_HEAP_SIZE, - - /// Maps 1:1 to the IO register area. - IO_AREA_VADDR = 0x1EC00000, - IO_AREA_VADDR_END = IO_AREA_VADDR + IO_AREA_SIZE, - - /// Maps 1:1 to VRAM. - VRAM_VADDR = 0x1F000000, - VRAM_VADDR_END = VRAM_VADDR + VRAM_SIZE, - - /// Maps 1:1 to DSP memory. - DSP_RAM_VADDR = 0x1FF00000, - DSP_RAM_VADDR_END = DSP_RAM_VADDR + DSP_RAM_SIZE, - /// Read-only page containing kernel and system configuration values. CONFIG_MEMORY_VADDR = 0x1FF80000, CONFIG_MEMORY_SIZE = 0x00001000, @@ -154,13 +99,8 @@ enum : VAddr { SHARED_PAGE_SIZE = 0x00001000, SHARED_PAGE_VADDR_END = SHARED_PAGE_VADDR + SHARED_PAGE_SIZE, - /// Equivalent to LINEAR_HEAP_VADDR, but expanded to cover the extra memory in the New 3DS. - NEW_LINEAR_HEAP_VADDR = 0x30000000, - NEW_LINEAR_HEAP_SIZE = 0x10000000, - NEW_LINEAR_HEAP_VADDR_END = NEW_LINEAR_HEAP_VADDR + NEW_LINEAR_HEAP_SIZE, - /// Area where TLS (Thread-Local Storage) buffers are allocated. - TLS_AREA_VADDR = NEW_LINEAR_HEAP_VADDR_END, + TLS_AREA_VADDR = 0x40000000, TLS_ENTRY_SIZE = 0x200, TLS_AREA_SIZE = 0x10000000, TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE, @@ -205,8 +145,6 @@ bool IsValidVirtualAddress(const VAddr addr); /// Determines if the given VAddr is a kernel address bool IsKernelVirtualAddress(const VAddr addr); -bool IsValidPhysicalAddress(const PAddr addr); - u8 Read8(VAddr addr); u16 Read16(VAddr addr); u32 Read32(VAddr addr); @@ -230,30 +168,6 @@ u8* GetPointer(VAddr virtual_address); std::string ReadCString(VAddr virtual_address, std::size_t max_length); -/** - * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical - * address. This should be used by services to translate addresses for use by the hardware. - */ -boost::optional<PAddr> TryVirtualToPhysicalAddress(VAddr addr); - -/** - * Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical - * address. This should be used by services to translate addresses for use by the hardware. - * - * @deprecated Use TryVirtualToPhysicalAddress(), which reports failure. - */ -PAddr VirtualToPhysicalAddress(VAddr addr); - -/** - * Undoes a mapping performed by VirtualToPhysicalAddress(). - */ -boost::optional<VAddr> PhysicalToVirtualAddress(PAddr addr); - -/** - * Gets a pointer to the memory region beginning at the specified physical address. - */ -u8* GetPhysicalPointer(PAddr address); - enum class FlushMode { /// Write back modified surfaces to RAM Flush, diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 444bcc387..79e0b347b 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -5,10 +5,9 @@ #include "core/gdbstub/gdbstub.h" #include "core/hle/service/hid/hid.h" #include "core/settings.h" +#include "video_core/renderer_base.h" #include "video_core/video_core.h" -#include "core/frontend/emu_window.h" - namespace Settings { Values values = {}; @@ -20,9 +19,8 @@ void Apply() { VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit; - if (VideoCore::g_emu_window) { - auto layout = VideoCore::g_emu_window->GetFramebufferLayout(); - VideoCore::g_emu_window->UpdateCurrentFramebufferLayout(layout.width, layout.height); + if (VideoCore::g_renderer) { + VideoCore::g_renderer->UpdateCurrentFramebufferLayout(); } Service::HID::ReloadInputDevices(); diff --git a/src/core/settings.h b/src/core/settings.h index 55da39b6c..73dc3061f 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -112,6 +112,8 @@ static const std::array<const char*, NumAnalogs> mapping = {{ struct Values { // System bool use_docked_mode; + std::string username; + int language_index; // Controls std::array<std::string, NativeButton::NumButtons> buttons; diff --git a/src/input_common/keyboard.cpp b/src/input_common/keyboard.cpp index 0f0d10f23..525fe6abc 100644 --- a/src/input_common/keyboard.cpp +++ b/src/input_common/keyboard.cpp @@ -5,6 +5,7 @@ #include <atomic> #include <list> #include <mutex> +#include <utility> #include "input_common/keyboard.h" namespace InputCommon { @@ -12,9 +13,9 @@ namespace InputCommon { class KeyButton final : public Input::ButtonDevice { public: explicit KeyButton(std::shared_ptr<KeyButtonList> key_button_list_) - : key_button_list(key_button_list_) {} + : key_button_list(std::move(key_button_list_)) {} - ~KeyButton(); + ~KeyButton() override; bool GetStatus() const override { return status.load(); diff --git a/src/input_common/motion_emu.cpp b/src/input_common/motion_emu.cpp index caffe48cb..9570c060e 100644 --- a/src/input_common/motion_emu.cpp +++ b/src/input_common/motion_emu.cpp @@ -131,7 +131,7 @@ public: device = std::make_shared<MotionEmuDevice>(update_millisecond, sensitivity); } - std::tuple<Math::Vec3<float>, Math::Vec3<float>> GetStatus() const { + std::tuple<Math::Vec3<float>, Math::Vec3<float>> GetStatus() const override { return device->GetStatus(); } diff --git a/src/input_common/sdl/sdl.cpp b/src/input_common/sdl/sdl.cpp index 8d117c2d4..d1b960fd7 100644 --- a/src/input_common/sdl/sdl.cpp +++ b/src/input_common/sdl/sdl.cpp @@ -82,7 +82,7 @@ private: class SDLButton final : public Input::ButtonDevice { public: explicit SDLButton(std::shared_ptr<SDLJoystick> joystick_, int button_) - : joystick(joystick_), button(button_) {} + : joystick(std::move(joystick_)), button(button_) {} bool GetStatus() const override { return joystick->GetButton(button); @@ -96,7 +96,7 @@ private: class SDLDirectionButton final : public Input::ButtonDevice { public: explicit SDLDirectionButton(std::shared_ptr<SDLJoystick> joystick_, int hat_, Uint8 direction_) - : joystick(joystick_), hat(hat_), direction(direction_) {} + : joystick(std::move(joystick_)), hat(hat_), direction(direction_) {} bool GetStatus() const override { return joystick->GetHatDirection(hat, direction); @@ -112,7 +112,7 @@ class SDLAxisButton final : public Input::ButtonDevice { public: explicit SDLAxisButton(std::shared_ptr<SDLJoystick> joystick_, int axis_, float threshold_, bool trigger_if_greater_) - : joystick(joystick_), axis(axis_), threshold(threshold_), + : joystick(std::move(joystick_)), axis(axis_), threshold(threshold_), trigger_if_greater(trigger_if_greater_) {} bool GetStatus() const override { @@ -132,7 +132,7 @@ private: class SDLAnalog final : public Input::AnalogDevice { public: SDLAnalog(std::shared_ptr<SDLJoystick> joystick_, int axis_x_, int axis_y_) - : joystick(joystick_), axis_x(axis_x_), axis_y(axis_y_) {} + : joystick(std::move(joystick_)), axis_x(axis_x_), axis_y(axis_y_) {} std::tuple<float, float> GetStatus() const override { return joystick->GetAnalog(axis_x, axis_y); @@ -314,10 +314,6 @@ namespace Polling { class SDLPoller : public InputCommon::Polling::DevicePoller { public: - SDLPoller() = default; - - ~SDLPoller() = default; - void Start() override { // SDL joysticks must be opened, otherwise they don't generate events SDL_JoystickUpdate(); @@ -341,10 +337,6 @@ private: class SDLButtonPoller final : public SDLPoller { public: - SDLButtonPoller() = default; - - ~SDLButtonPoller() = default; - Common::ParamPackage GetNextInput() override { SDL_Event event; while (SDL_PollEvent(&event)) { @@ -364,10 +356,6 @@ public: class SDLAnalogPoller final : public SDLPoller { public: - SDLAnalogPoller() = default; - - ~SDLAnalogPoller() = default; - void Start() override { SDLPoller::Start(); diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 6a0a62ecc..4d74bb395 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -3,7 +3,6 @@ add_executable(tests core/arm/arm_test_common.cpp core/arm/arm_test_common.h core/core_timing.cpp - core/memory/memory.cpp glad.cpp tests.cpp ) diff --git a/src/tests/core/memory/memory.cpp b/src/tests/core/memory/memory.cpp deleted file mode 100644 index 165496a54..000000000 --- a/src/tests/core/memory/memory.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2017 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include <catch.hpp> -#include "core/hle/kernel/memory.h" -#include "core/hle/kernel/process.h" -#include "core/memory.h" - -TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory][!hide]") { - SECTION("these regions should not be mapped on an empty process") { - auto process = Kernel::Process::Create(""); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::PROCESS_IMAGE_VADDR) == false); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::HEAP_VADDR) == false); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::LINEAR_HEAP_VADDR) == false); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::VRAM_VADDR) == false); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == false); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::SHARED_PAGE_VADDR) == false); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::TLS_AREA_VADDR) == false); - } - - SECTION("CONFIG_MEMORY_VADDR and SHARED_PAGE_VADDR should be valid after mapping them") { - auto process = Kernel::Process::Create(""); - Kernel::MapSharedPages(process->vm_manager); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == true); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::SHARED_PAGE_VADDR) == true); - } - - SECTION("special regions should be valid after mapping them") { - auto process = Kernel::Process::Create(""); - SECTION("VRAM") { - Kernel::HandleSpecialMapping(process->vm_manager, - {Memory::VRAM_VADDR, Memory::VRAM_SIZE, false, false}); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::VRAM_VADDR) == true); - } - - SECTION("IO (Not yet implemented)") { - Kernel::HandleSpecialMapping( - process->vm_manager, {Memory::IO_AREA_VADDR, Memory::IO_AREA_SIZE, false, false}); - CHECK_FALSE(Memory::IsValidVirtualAddress(*process, Memory::IO_AREA_VADDR) == true); - } - - SECTION("DSP") { - Kernel::HandleSpecialMapping( - process->vm_manager, {Memory::DSP_RAM_VADDR, Memory::DSP_RAM_SIZE, false, false}); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::DSP_RAM_VADDR) == true); - } - } - - SECTION("Unmapping a VAddr should make it invalid") { - auto process = Kernel::Process::Create(""); - Kernel::MapSharedPages(process->vm_manager); - process->vm_manager.UnmapRange(Memory::CONFIG_MEMORY_VADDR, Memory::CONFIG_MEMORY_SIZE); - CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == false); - } -} diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 60c49d672..141e20444 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -40,6 +40,7 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { case RenderTargetFormat::RGBA8_UNORM: case RenderTargetFormat::RGB10_A2_UNORM: case RenderTargetFormat::BGRA8_UNORM: + case RenderTargetFormat::R32_FLOAT: return 4; default: UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format)); diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index c464fc6d1..08aa75503 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -29,6 +29,7 @@ enum class RenderTargetFormat : u32 { RG16_UINT = 0xDD, RG16_FLOAT = 0xDE, R11G11B10_FLOAT = 0xE0, + R32_FLOAT = 0xE5, R16_FLOAT = 0xF2, R8_UNORM = 0xF3, }; diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp index 30075b23c..dbe3edf09 100644 --- a/src/video_core/renderer_base.cpp +++ b/src/video_core/renderer_base.cpp @@ -2,14 +2,22 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <atomic> #include <memory> +#include "core/frontend/emu_window.h" #include "video_core/renderer_base.h" #include "video_core/renderer_opengl/gl_rasterizer.h" -#include "video_core/video_core.h" + +RendererBase::RendererBase(EmuWindow& window) : render_window{window} {} +RendererBase::~RendererBase() = default; + +void RendererBase::UpdateCurrentFramebufferLayout() { + const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout(); + + render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height); +} void RendererBase::RefreshRasterizerSetting() { if (rasterizer == nullptr) { - rasterizer = std::make_unique<RasterizerOpenGL>(); + rasterizer = std::make_unique<RasterizerOpenGL>(render_window); } } diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index 89a960eaf..1cb161b7f 100644 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h @@ -18,23 +18,21 @@ public: /// Used to reference a framebuffer enum kFramebuffer { kFramebuffer_VirtualXFB = 0, kFramebuffer_EFB, kFramebuffer_Texture }; - virtual ~RendererBase() {} + explicit RendererBase(EmuWindow& window); + virtual ~RendererBase(); /// Swap buffers (render frame) virtual void SwapBuffers(boost::optional<const Tegra::FramebufferConfig&> framebuffer) = 0; - /** - * Set the emulator window to use for renderer - * @param window EmuWindow handle to emulator window to use for rendering - */ - virtual void SetWindow(EmuWindow* window) = 0; - /// Initialize the renderer virtual bool Init() = 0; /// Shutdown the renderer virtual void ShutDown() = 0; + /// Updates the framebuffer layout of the contained render window handle. + void UpdateCurrentFramebufferLayout(); + // Getter/setter functions: // ------------------------ @@ -53,9 +51,8 @@ public: void RefreshRasterizerSetting(); protected: + EmuWindow& render_window; ///< Reference to the render window handle. std::unique_ptr<VideoCore::RasterizerInterface> rasterizer; f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer int m_current_frame = 0; ///< Current frame, should be set by the renderer - -private: }; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index a1c47bae9..6555db5bb 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -14,7 +14,6 @@ #include "common/logging/log.h" #include "common/math_util.h" #include "common/microprofile.h" -#include "common/scope_exit.h" #include "core/core.h" #include "core/frontend/emu_window.h" #include "core/hle/kernel/process.h" @@ -37,7 +36,7 @@ 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_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100)); -RasterizerOpenGL::RasterizerOpenGL() { +RasterizerOpenGL::RasterizerOpenGL(EmuWindow& window) : emu_window{window} { // Create sampler objects for (size_t i = 0; i < texture_samplers.size(); ++i) { texture_samplers[i].Create(); @@ -395,7 +394,7 @@ void RasterizerOpenGL::Clear() { if (clear_mask == 0) return; - ScopeAcquireGLContext acquire_context; + ScopeAcquireGLContext acquire_context{emu_window}; auto [dirty_color_surface, dirty_depth_surface] = ConfigureFramebuffers(use_color_fb, use_depth_fb); @@ -425,7 +424,7 @@ void RasterizerOpenGL::DrawArrays() { MICROPROFILE_SCOPE(OpenGL_Drawing); const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; - ScopeAcquireGLContext acquire_context; + ScopeAcquireGLContext acquire_context{emu_window}; auto [dirty_color_surface, dirty_depth_surface] = ConfigureFramebuffers(true, regs.zeta.Address() != 0 && regs.zeta_enable != 0); diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index e150be58f..6d6d85cc1 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -21,11 +21,12 @@ #include "video_core/renderer_opengl/gl_state.h" #include "video_core/renderer_opengl/gl_stream_buffer.h" +class EmuWindow; struct ScreenInfo; class RasterizerOpenGL : public VideoCore::RasterizerInterface { public: - RasterizerOpenGL(); + explicit RasterizerOpenGL(EmuWindow& renderer); ~RasterizerOpenGL() override; void DrawArrays() override; @@ -144,6 +145,8 @@ private: RasterizerCacheOpenGL res_cache; + EmuWindow& emu_window; + std::unique_ptr<GLShader::ProgramManager> shader_program_manager; OGLVertexArray sw_vao; OGLVertexArray hw_vao; diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index a4d9707cb..c8f0c4e28 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -118,6 +118,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form {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_RGB32F, GL_RGB, GL_FLOAT, ComponentType::Float, false}, // RGB32F {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // SRGBA8 // DepthStencil formats @@ -218,9 +219,10 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), 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::Z32FS8>, + MortonCopy<true, PixelFormat::RGB32F>, MortonCopy<true, PixelFormat::SRGBA8>, + MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>, + MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>, + MortonCopy<true, PixelFormat::Z32FS8>, }; static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), @@ -253,6 +255,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), MortonCopy<false, PixelFormat::RG16UI>, MortonCopy<false, PixelFormat::RG16I>, MortonCopy<false, PixelFormat::RG16S>, + MortonCopy<false, PixelFormat::RGB32F>, MortonCopy<false, PixelFormat::SRGBA8>, MortonCopy<false, PixelFormat::Z24S8>, MortonCopy<false, PixelFormat::S8Z24>, diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index bf0458b94..4e1e18d9c 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -48,16 +48,17 @@ struct SurfaceParams { RG16UI = 23, RG16I = 24, RG16S = 25, - SRGBA8 = 26, + RGB32F = 26, + SRGBA8 = 27, MaxColorFormat, // DepthStencil formats - Z24S8 = 27, - S8Z24 = 28, - Z32F = 29, - Z16 = 30, - Z32FS8 = 31, + Z24S8 = 28, + S8Z24 = 29, + Z32F = 30, + Z16 = 31, + Z32FS8 = 32, MaxDepthStencilFormat, @@ -121,6 +122,7 @@ struct SurfaceParams { 1, // RG16UI 1, // RG16I 1, // RG16S + 1, // RGB32F 1, // SRGBA8 1, // Z24S8 1, // S8Z24 @@ -164,6 +166,7 @@ struct SurfaceParams { 32, // RG16UI 32, // RG16I 32, // RG16S + 96, // RGB32F 32, // SRGBA8 32, // Z24S8 32, // S8Z24 @@ -232,6 +235,8 @@ struct SurfaceParams { return PixelFormat::RG16S; case Tegra::RenderTargetFormat::R16_FLOAT: return PixelFormat::R16F; + case Tegra::RenderTargetFormat::R32_FLOAT: + return PixelFormat::R32F; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); UNREACHABLE(); @@ -270,6 +275,8 @@ struct SurfaceParams { UNREACHABLE(); case Tegra::Texture::TextureFormat::R32_G32: return PixelFormat::RG32F; + case Tegra::Texture::TextureFormat::R32_G32_B32: + return PixelFormat::RGB32F; case Tegra::Texture::TextureFormat::R16: switch (component_type) { case Tegra::Texture::ComponentType::FLOAT: @@ -361,6 +368,8 @@ struct SurfaceParams { return Tegra::Texture::TextureFormat::A8R8G8B8; case PixelFormat::RGBA32F: return Tegra::Texture::TextureFormat::R32_G32_B32_A32; + case PixelFormat::RGB32F: + return Tegra::Texture::TextureFormat::R32_G32_B32; case PixelFormat::RG32F: return Tegra::Texture::TextureFormat::R32_G32; case PixelFormat::R32F: @@ -439,6 +448,7 @@ struct SurfaceParams { case Tegra::RenderTargetFormat::RG32_FLOAT: case Tegra::RenderTargetFormat::RG16_FLOAT: case Tegra::RenderTargetFormat::R16_FLOAT: + case Tegra::RenderTargetFormat::R32_FLOAT: return ComponentType::Float; case Tegra::RenderTargetFormat::RGBA32_UINT: case Tegra::RenderTargetFormat::RG16_UINT: diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index acf067050..68db3c22a 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -412,7 +412,6 @@ public: } declarations.AddNewLine(); - unsigned const_buffer_layout = 0; for (const auto& entry : GetConstBuffersDeclarations()) { declarations.AddLine("layout(std140) uniform " + entry.GetName()); declarations.AddLine('{'); @@ -420,7 +419,6 @@ public: "[MAX_CONSTBUFFER_ELEMENTS];"); declarations.AddLine("};"); declarations.AddNewLine(); - ++const_buffer_layout; } declarations.AddNewLine(); diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index e81fcbbc4..415d42fda 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -13,15 +13,16 @@ namespace Impl { static void SetShaderUniformBlockBinding(GLuint shader, const char* name, Maxwell3D::Regs::ShaderStage binding, size_t expected_size) { - GLuint ub_index = glGetUniformBlockIndex(shader, name); - if (ub_index != GL_INVALID_INDEX) { - GLint ub_size = 0; - glGetActiveUniformBlockiv(shader, ub_index, GL_UNIFORM_BLOCK_DATA_SIZE, &ub_size); - ASSERT_MSG(ub_size == expected_size, - "Uniform block size did not match! Got {}, expected {}", - static_cast<int>(ub_size), expected_size); - glUniformBlockBinding(shader, ub_index, static_cast<GLuint>(binding)); + const GLuint ub_index = glGetUniformBlockIndex(shader, name); + if (ub_index == GL_INVALID_INDEX) { + return; } + + GLint ub_size = 0; + glGetActiveUniformBlockiv(shader, ub_index, GL_UNIFORM_BLOCK_DATA_SIZE, &ub_size); + ASSERT_MSG(static_cast<size_t>(ub_size) == expected_size, + "Uniform block size did not match! Got {}, expected {}", ub_size, expected_size); + glUniformBlockBinding(shader, ub_index, static_cast<GLuint>(binding)); } void SetShaderUniformBlockBindings(GLuint shader) { diff --git a/src/video_core/renderer_opengl/gl_shader_manager.h b/src/video_core/renderer_opengl/gl_shader_manager.h index e29d551e1..716933a0b 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.h +++ b/src/video_core/renderer_opengl/gl_shader_manager.h @@ -105,20 +105,20 @@ public: } ShaderEntries UseProgrammableVertexShader(const MaxwellVSConfig& config, - const ShaderSetup setup) { + const ShaderSetup& setup) { ShaderEntries result; std::tie(current.vs, result) = vertex_shaders.Get(config, setup); return result; } ShaderEntries UseProgrammableFragmentShader(const MaxwellFSConfig& config, - const ShaderSetup setup) { + const ShaderSetup& setup) { ShaderEntries result; std::tie(current.fs, result) = fragment_shaders.Get(config, setup); return result; } - GLuint GetCurrentProgramStage(Maxwell3D::Regs::ShaderStage stage) { + GLuint GetCurrentProgramStage(Maxwell3D::Regs::ShaderStage stage) const { switch (stage) { case Maxwell3D::Regs::ShaderStage::Vertex: return current.vs; diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index 3398d7c04..24b1d956b 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h @@ -82,7 +82,7 @@ public: GLenum logic_op; // GL_LOGIC_OP_MODE // 3 texture units - one for each that is used in PICA fragment shader emulation - struct { + struct TextureUnit { GLuint texture_2d; // GL_TEXTURE_BINDING_2D GLuint sampler; // GL_SAMPLER_BINDING struct { @@ -104,7 +104,8 @@ public: Unbind(); sampler = 0; } - } texture_units[32]; + }; + std::array<TextureUnit, 32> texture_units; struct { GLuint read_framebuffer; // GL_READ_FRAMEBUFFER_BINDING diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 7810b9147..74383c7cf 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -92,23 +92,23 @@ static std::array<GLfloat, 3 * 2> MakeOrthographicMatrix(const float width, cons return matrix; } -ScopeAcquireGLContext::ScopeAcquireGLContext() { +ScopeAcquireGLContext::ScopeAcquireGLContext(EmuWindow& emu_window_) : emu_window{emu_window_} { if (Settings::values.use_multi_core) { - VideoCore::g_emu_window->MakeCurrent(); + emu_window.MakeCurrent(); } } ScopeAcquireGLContext::~ScopeAcquireGLContext() { if (Settings::values.use_multi_core) { - VideoCore::g_emu_window->DoneCurrent(); + emu_window.DoneCurrent(); } } -RendererOpenGL::RendererOpenGL() = default; +RendererOpenGL::RendererOpenGL(EmuWindow& window) : RendererBase{window} {} RendererOpenGL::~RendererOpenGL() = default; /// Swap buffers (render frame) void RendererOpenGL::SwapBuffers(boost::optional<const Tegra::FramebufferConfig&> framebuffer) { - ScopeAcquireGLContext acquire_context; + ScopeAcquireGLContext acquire_context{render_window}; Core::System::GetInstance().perf_stats.EndSystemFrame(); @@ -130,10 +130,10 @@ void RendererOpenGL::SwapBuffers(boost::optional<const Tegra::FramebufferConfig& // Load the framebuffer from memory, draw it to the screen, and swap buffers LoadFBToScreenInfo(*framebuffer, screen_info); DrawScreen(); - render_window->SwapBuffers(); + render_window.SwapBuffers(); } - render_window->PollEvents(); + render_window.PollEvents(); Core::System::GetInstance().frame_limiter.DoFrameLimiting(CoreTiming::GetGlobalTimeUs()); Core::System::GetInstance().perf_stats.BeginSystemFrame(); @@ -356,7 +356,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x, * Draws the emulated screens to the emulator window. */ void RendererOpenGL::DrawScreen() { - const auto& layout = render_window->GetFramebufferLayout(); + const auto& layout = render_window.GetFramebufferLayout(); const auto& screen = layout.screen; glViewport(0, 0, layout.width, layout.height); @@ -380,14 +380,6 @@ void RendererOpenGL::DrawScreen() { /// Updates the framerate void RendererOpenGL::UpdateFramerate() {} -/** - * Set the emulator window to use for renderer - * @param window EmuWindow handle to emulator window to use for rendering - */ -void RendererOpenGL::SetWindow(EmuWindow* window) { - render_window = window; -} - static const char* GetSource(GLenum source) { #define RET(s) \ case GL_DEBUG_SOURCE_##s: \ @@ -445,7 +437,7 @@ static void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum /// Initialize the renderer bool RendererOpenGL::Init() { - ScopeAcquireGLContext acquire_context; + ScopeAcquireGLContext acquire_context{render_window}; if (GLAD_GL_KHR_debug) { glEnable(GL_DEBUG_OUTPUT); diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 59d92a3dc..ab7de41c8 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -34,24 +34,21 @@ struct ScreenInfo { /// Helper class to acquire/release OpenGL context within a given scope class ScopeAcquireGLContext : NonCopyable { public: - ScopeAcquireGLContext(); + explicit ScopeAcquireGLContext(EmuWindow& window); ~ScopeAcquireGLContext(); + +private: + EmuWindow& emu_window; }; class RendererOpenGL : public RendererBase { public: - RendererOpenGL(); + explicit RendererOpenGL(EmuWindow& window); ~RendererOpenGL() override; /// Swap buffers (render frame) void SwapBuffers(boost::optional<const Tegra::FramebufferConfig&> framebuffer) override; - /** - * Set the emulator window to use for renderer - * @param window EmuWindow handle to emulator window to use for rendering - */ - void SetWindow(EmuWindow* window) override; - /// Initialize the renderer bool Init() override; @@ -72,8 +69,6 @@ private: void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, u8 color_a, const TextureInfo& texture); - EmuWindow* render_window; ///< Handle to render window - OpenGLState state; // OpenGL object IDs diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index d794f8402..65db84ad3 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp @@ -57,6 +57,8 @@ u32 BytesPerPixel(TextureFormat format) { case TextureFormat::BC7U: // In this case a 'pixel' actually refers to a 4x4 tile. return 16; + case TextureFormat::R32_G32_B32: + return 12; case TextureFormat::ASTC_2D_4X4: case TextureFormat::A8R8G8B8: case TextureFormat::A2B10G10R10: @@ -131,6 +133,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, case TextureFormat::R16_G16: case TextureFormat::BF10GF11RF11: case TextureFormat::ASTC_2D_4X4: + case TextureFormat::R32_G32_B32: CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, unswizzled_data.data(), true, block_height); break; @@ -190,6 +193,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat case TextureFormat::R32: case TextureFormat::R16: case TextureFormat::R16_G16: + case TextureFormat::R32_G32_B32: // TODO(Subv): For the time being just forward the same data without any decoding. rgba_data = texture_data; break; diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 289140f31..06b13e681 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -13,16 +13,13 @@ namespace VideoCore { -EmuWindow* g_emu_window = nullptr; ///< Frontend emulator window std::unique_ptr<RendererBase> g_renderer; ///< Renderer plugin std::atomic<bool> g_toggle_framelimit_enabled; /// Initialize the video core -bool Init(EmuWindow* emu_window) { - g_emu_window = emu_window; - g_renderer = std::make_unique<RendererOpenGL>(); - g_renderer->SetWindow(g_emu_window); +bool Init(EmuWindow& emu_window) { + g_renderer = std::make_unique<RendererOpenGL>(emu_window); if (g_renderer->Init()) { LOG_DEBUG(Render, "initialized OK"); } else { diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h index 37da62436..519b757f5 100644 --- a/src/video_core/video_core.h +++ b/src/video_core/video_core.h @@ -18,17 +18,13 @@ namespace VideoCore { enum class Renderer { Software, OpenGL }; extern std::unique_ptr<RendererBase> g_renderer; ///< Renderer plugin -extern EmuWindow* g_emu_window; ///< Emu window // TODO: Wrap these in a user settings struct along with any other graphics settings (often set from // qt ui) extern std::atomic<bool> g_toggle_framelimit_enabled; -/// Start the video core -void Start(); - /// Initialize the video core -bool Init(EmuWindow* emu_window); +bool Init(EmuWindow& emu_window); /// Shutdown the video core void Shutdown(); diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 2f2d8c4c5..bf469ee73 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -105,6 +105,8 @@ void Config::ReadValues() { qt_config->beginGroup("System"); Settings::values.use_docked_mode = qt_config->value("use_docked_mode", false).toBool(); + Settings::values.username = qt_config->value("username", "yuzu").toString().toStdString(); + Settings::values.language_index = qt_config->value("language_index", 1).toInt(); qt_config->endGroup(); qt_config->beginGroup("Miscellaneous"); @@ -215,6 +217,8 @@ void Config::SaveValues() { qt_config->beginGroup("System"); qt_config->setValue("use_docked_mode", Settings::values.use_docked_mode); + qt_config->setValue("username", QString::fromStdString(Settings::values.username)); + qt_config->setValue("language_index", Settings::values.language_index); qt_config->endGroup(); qt_config->beginGroup("Miscellaneous"); diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index d09505a0f..9be2c939c 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -4,9 +4,10 @@ #include <QMessageBox> #include "core/core.h" +#include "core/settings.h" #include "ui_configure_system.h" #include "yuzu/configuration/configure_system.h" -#include "yuzu/ui_settings.h" +#include "yuzu/main.h" static const std::array<int, 12> days_in_month = {{ 31, @@ -38,6 +39,8 @@ ConfigureSystem::~ConfigureSystem() {} void ConfigureSystem::setConfiguration() { enabled = !Core::System::GetInstance().IsPoweredOn(); + ui->edit_username->setText(QString::fromStdString(Settings::values.username)); + ui->combo_language->setCurrentIndex(Settings::values.language_index); } void ConfigureSystem::ReadSystemSettings() {} @@ -45,6 +48,9 @@ void ConfigureSystem::ReadSystemSettings() {} void ConfigureSystem::applyConfiguration() { if (!enabled) return; + Settings::values.username = ui->edit_username->text().toStdString(); + Settings::values.language_index = ui->combo_language->currentIndex(); + Settings::Apply(); } void ConfigureSystem::updateBirthdayComboBox(int birthmonth_index) { diff --git a/src/yuzu/configuration/configure_system.ui b/src/yuzu/configuration/configure_system.ui index 8caf49623..f3f8db038 100644 --- a/src/yuzu/configuration/configure_system.ui +++ b/src/yuzu/configuration/configure_system.ui @@ -38,7 +38,7 @@ </sizepolicy> </property> <property name="maxLength"> - <number>10</number> + <number>32</number> </property> </widget> </item> @@ -164,7 +164,7 @@ </item> <item> <property name="text"> - <string>Simplified Chinese (简体中文)</string> + <string>Chinese</string> </property> </item> <item> @@ -187,6 +187,31 @@ <string>Russian (Русский)</string> </property> </item> + <item> + <property name="text"> + <string>Taiwanese</string> + </property> + </item> + <item> + <property name="text"> + <string>British English</string> + </property> + </item> + <item> + <property name="text"> + <string>Canadian French</string> + </property> + </item> + <item> + <property name="text"> + <string>Latin American Spanish</string> + </property> + </item> + <item> + <property name="text"> + <string>Simplified Chinese</string> + </property> + </item> <item> <property name="text"> <string>Traditional Chinese (正體中文)</string> diff --git a/src/yuzu/debugger/graphics/graphics_breakpoint_observer.cpp b/src/yuzu/debugger/graphics/graphics_breakpoint_observer.cpp index d6d61a739..5f459ccfb 100644 --- a/src/yuzu/debugger/graphics/graphics_breakpoint_observer.cpp +++ b/src/yuzu/debugger/graphics/graphics_breakpoint_observer.cpp @@ -10,12 +10,12 @@ BreakPointObserverDock::BreakPointObserverDock(std::shared_ptr<Tegra::DebugConte : QDockWidget(title, parent), BreakPointObserver(debug_context) { qRegisterMetaType<Tegra::DebugContext::Event>("Tegra::DebugContext::Event"); - connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed())); + connect(this, &BreakPointObserverDock::Resumed, this, &BreakPointObserverDock::OnResumed); // NOTE: This signal is emitted from a non-GUI thread, but connect() takes // care of delaying its handling to the GUI thread. - connect(this, SIGNAL(BreakPointHit(Tegra::DebugContext::Event, void*)), this, - SLOT(OnBreakPointHit(Tegra::DebugContext::Event, void*)), Qt::BlockingQueuedConnection); + connect(this, &BreakPointObserverDock::BreakPointHit, this, + &BreakPointObserverDock::OnBreakPointHit, Qt::BlockingQueuedConnection); } void BreakPointObserverDock::OnMaxwellBreakPointHit(Tegra::DebugContext::Event event, void* data) { diff --git a/src/yuzu/debugger/graphics/graphics_breakpoint_observer.h b/src/yuzu/debugger/graphics/graphics_breakpoint_observer.h index 9d05493cf..ab32f0115 100644 --- a/src/yuzu/debugger/graphics/graphics_breakpoint_observer.h +++ b/src/yuzu/debugger/graphics/graphics_breakpoint_observer.h @@ -23,11 +23,11 @@ public: void OnMaxwellBreakPointHit(Tegra::DebugContext::Event event, void* data) override; void OnMaxwellResume() override; -private slots: - virtual void OnBreakPointHit(Tegra::DebugContext::Event event, void* data) = 0; - virtual void OnResumed() = 0; - signals: void Resumed(); void BreakPointHit(Tegra::DebugContext::Event event, void* data); + +private: + virtual void OnBreakPointHit(Tegra::DebugContext::Event event, void* data) = 0; + virtual void OnResumed() = 0; }; diff --git a/src/yuzu/debugger/graphics/graphics_breakpoints.cpp b/src/yuzu/debugger/graphics/graphics_breakpoints.cpp index f98cc8152..eb16a38a0 100644 --- a/src/yuzu/debugger/graphics/graphics_breakpoints.cpp +++ b/src/yuzu/debugger/graphics/graphics_breakpoints.cpp @@ -144,21 +144,25 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget( qRegisterMetaType<Tegra::DebugContext::Event>("Tegra::DebugContext::Event"); - connect(breakpoint_list, SIGNAL(doubleClicked(const QModelIndex&)), this, - SLOT(OnItemDoubleClicked(const QModelIndex&))); + connect(breakpoint_list, &QTreeView::doubleClicked, this, + &GraphicsBreakPointsWidget::OnItemDoubleClicked); - connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested())); + connect(resume_button, &QPushButton::clicked, this, + &GraphicsBreakPointsWidget::OnResumeRequested); - connect(this, SIGNAL(BreakPointHit(Tegra::DebugContext::Event, void*)), this, - SLOT(OnBreakPointHit(Tegra::DebugContext::Event, void*)), Qt::BlockingQueuedConnection); - connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed())); + connect(this, &GraphicsBreakPointsWidget::BreakPointHit, this, + &GraphicsBreakPointsWidget::OnBreakPointHit, Qt::BlockingQueuedConnection); + connect(this, &GraphicsBreakPointsWidget::Resumed, this, &GraphicsBreakPointsWidget::OnResumed); - connect(this, SIGNAL(BreakPointHit(Tegra::DebugContext::Event, void*)), breakpoint_model, - SLOT(OnBreakPointHit(Tegra::DebugContext::Event)), Qt::BlockingQueuedConnection); - connect(this, SIGNAL(Resumed()), breakpoint_model, SLOT(OnResumed())); + connect(this, &GraphicsBreakPointsWidget::BreakPointHit, breakpoint_model, + &BreakPointModel::OnBreakPointHit, Qt::BlockingQueuedConnection); + connect(this, &GraphicsBreakPointsWidget::Resumed, breakpoint_model, + &BreakPointModel::OnResumed); - connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&, const QModelIndex&)), - breakpoint_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); + connect(this, &GraphicsBreakPointsWidget::BreakPointsChanged, + [this](const QModelIndex& top_left, const QModelIndex& bottom_right) { + breakpoint_model->dataChanged(top_left, bottom_right); + }); QWidget* main_widget = new QWidget; auto main_layout = new QVBoxLayout; diff --git a/src/yuzu/debugger/graphics/graphics_breakpoints.h b/src/yuzu/debugger/graphics/graphics_breakpoints.h index ae0ede2e8..a920a2ae5 100644 --- a/src/yuzu/debugger/graphics/graphics_breakpoints.h +++ b/src/yuzu/debugger/graphics/graphics_breakpoints.h @@ -26,18 +26,17 @@ public: void OnMaxwellBreakPointHit(Tegra::DebugContext::Event event, void* data) override; void OnMaxwellResume() override; -public slots: - void OnBreakPointHit(Tegra::DebugContext::Event event, void* data); - void OnItemDoubleClicked(const QModelIndex&); - void OnResumeRequested(); - void OnResumed(); - signals: void Resumed(); void BreakPointHit(Tegra::DebugContext::Event event, void* data); void BreakPointsChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); private: + void OnBreakPointHit(Tegra::DebugContext::Event event, void* data); + void OnItemDoubleClicked(const QModelIndex&); + void OnResumeRequested(); + void OnResumed(); + QLabel* status_text; QPushButton* resume_button; diff --git a/src/yuzu/debugger/graphics/graphics_breakpoints_p.h b/src/yuzu/debugger/graphics/graphics_breakpoints_p.h index 35a6876ae..7112b87e6 100644 --- a/src/yuzu/debugger/graphics/graphics_breakpoints_p.h +++ b/src/yuzu/debugger/graphics/graphics_breakpoints_p.h @@ -25,7 +25,6 @@ public: bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; -public slots: void OnBreakPointHit(Tegra::DebugContext::Event event); void OnResumed(); diff --git a/src/yuzu/debugger/graphics/graphics_surface.cpp b/src/yuzu/debugger/graphics/graphics_surface.cpp index c41ff693b..ff3efcdaa 100644 --- a/src/yuzu/debugger/graphics/graphics_surface.cpp +++ b/src/yuzu/debugger/graphics/graphics_surface.cpp @@ -153,22 +153,24 @@ GraphicsSurfaceWidget::GraphicsSurfaceWidget(std::shared_ptr<Tegra::DebugContext save_surface = new QPushButton(QIcon::fromTheme("document-save"), tr("Save")); // Connections - connect(this, SIGNAL(Update()), this, SLOT(OnUpdate())); - connect(surface_source_list, SIGNAL(currentIndexChanged(int)), this, - SLOT(OnSurfaceSourceChanged(int))); - connect(surface_address_control, SIGNAL(ValueChanged(qint64)), this, - SLOT(OnSurfaceAddressChanged(qint64))); - connect(surface_width_control, SIGNAL(valueChanged(int)), this, - SLOT(OnSurfaceWidthChanged(int))); - connect(surface_height_control, SIGNAL(valueChanged(int)), this, - SLOT(OnSurfaceHeightChanged(int))); - connect(surface_format_control, SIGNAL(currentIndexChanged(int)), this, - SLOT(OnSurfaceFormatChanged(int))); - connect(surface_picker_x_control, SIGNAL(valueChanged(int)), this, - SLOT(OnSurfacePickerXChanged(int))); - connect(surface_picker_y_control, SIGNAL(valueChanged(int)), this, - SLOT(OnSurfacePickerYChanged(int))); - connect(save_surface, SIGNAL(clicked()), this, SLOT(SaveSurface())); + connect(this, &GraphicsSurfaceWidget::Update, this, &GraphicsSurfaceWidget::OnUpdate); + connect(surface_source_list, + static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, + &GraphicsSurfaceWidget::OnSurfaceSourceChanged); + connect(surface_address_control, &CSpinBox::ValueChanged, this, + &GraphicsSurfaceWidget::OnSurfaceAddressChanged); + connect(surface_width_control, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), + this, &GraphicsSurfaceWidget::OnSurfaceWidthChanged); + connect(surface_height_control, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), + this, &GraphicsSurfaceWidget::OnSurfaceHeightChanged); + connect(surface_format_control, + static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, + &GraphicsSurfaceWidget::OnSurfaceFormatChanged); + connect(surface_picker_x_control, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), + this, &GraphicsSurfaceWidget::OnSurfacePickerXChanged); + connect(surface_picker_y_control, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), + this, &GraphicsSurfaceWidget::OnSurfacePickerYChanged); + connect(save_surface, &QPushButton::clicked, this, &GraphicsSurfaceWidget::SaveSurface); auto main_widget = new QWidget; auto main_layout = new QVBoxLayout; diff --git a/src/yuzu/debugger/graphics/graphics_surface.h b/src/yuzu/debugger/graphics/graphics_surface.h index 6a344bdfc..58f9db465 100644 --- a/src/yuzu/debugger/graphics/graphics_surface.h +++ b/src/yuzu/debugger/graphics/graphics_surface.h @@ -65,16 +65,15 @@ public slots: void OnSurfacePickerYChanged(int new_value); void OnUpdate(); -private slots: +signals: + void Update(); + +private: void OnBreakPointHit(Tegra::DebugContext::Event event, void* data) override; void OnResumed() override; void SaveSurface(); -signals: - void Update(); - -private: QComboBox* surface_source_list; CSpinBox* surface_address_control; QSpinBox* surface_width_control; diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h index 10fc9e968..6cbce6856 100644 --- a/src/yuzu/debugger/wait_tree.h +++ b/src/yuzu/debugger/wait_tree.h @@ -9,7 +9,7 @@ #include <QTreeView> #include <boost/container/flat_set.hpp> #include "core/core.h" -#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/object.h" class EmuThread; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 34d4f0754..eac41553a 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -403,7 +403,7 @@ bool GMainWindow::LoadROM(const QString& filename) { system.SetGPUDebugContext(debug_context); - const Core::System::ResultStatus result{system.Load(render_window, filename.toStdString())}; + const Core::System::ResultStatus result{system.Load(*render_window, filename.toStdString())}; render_window->DoneCurrent(); diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 6553c7814..9a935a0d5 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -164,6 +164,16 @@ use_virtual_sd = # 1: Yes, 0 (default): No use_docked_mode = +# Sets the account username, max length is 32 characters +# yuzu (default) +username = + +# Sets the systems language index +# 0: Japanese, 1: English (default), 2: French, 3: German, 4: Italian, 5: Spanish, 6: Chinese, +# 7: Korean, 8: Dutch, 9: Portuguese, 10: Russian, 11: Taiwanese, 12: British English, 13: Canadian French, +# 14: Latin American Spanish, 15: Simplified Chinese, 16: Traditional Chinese +language_index = + # The system region that yuzu will use during emulation # -1: Auto-select (default), 0: Japan, 1: USA, 2: Europe, 3: Australia, 4: China, 5: Korea, 6: Taiwan region_value = diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index c3b0d9f1f..b23213cf6 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -164,7 +164,7 @@ int main(int argc, char** argv) { SCOPE_EXIT({ system.Shutdown(); }); - const Core::System::ResultStatus load_result{system.Load(emu_window.get(), filepath)}; + const Core::System::ResultStatus load_result{system.Load(*emu_window, filepath)}; switch (load_result) { case Core::System::ResultStatus::ErrorGetLoader: |