mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-22 07:42:52 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 46710a37bb | |||
| 22e5c009c2 | |||
| 6dad5281d1 | |||
| e0d992cf1a |
@@ -0,0 +1,40 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index a236839..8d98365 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -188,18 +188,23 @@ set(HTTPLIB_IS_USING_NON_BLOCKING_GETADDRINFO ${HTTPLIB_USE_NON_BLOCKING_GETADDR
|
||||
# Threads needed for <thread> on some systems, and for <pthread.h> on Linux
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
-# Since Cmake v3.11, Crypto & SSL became optional when not specified as COMPONENTS.
|
||||
-if(HTTPLIB_REQUIRE_OPENSSL)
|
||||
- find_package(OpenSSL ${_HTTPLIB_OPENSSL_MIN_VER} COMPONENTS Crypto SSL REQUIRED)
|
||||
- set(HTTPLIB_IS_USING_OPENSSL TRUE)
|
||||
-elseif(HTTPLIB_USE_OPENSSL_IF_AVAILABLE)
|
||||
- find_package(OpenSSL ${_HTTPLIB_OPENSSL_MIN_VER} COMPONENTS Crypto SSL QUIET)
|
||||
- # Avoid a rare circumstance of not finding all components but the end-user did their
|
||||
- # own call for OpenSSL, which might trick us into thinking we'd otherwise have what we wanted
|
||||
- if (TARGET OpenSSL::SSL AND TARGET OpenSSL::Crypto)
|
||||
- set(HTTPLIB_IS_USING_OPENSSL ${OPENSSL_FOUND})
|
||||
- else()
|
||||
- set(HTTPLIB_IS_USING_OPENSSL FALSE)
|
||||
+
|
||||
+# Eden top level defines it's own custom target alias for OpenSSL...
|
||||
+if (NOT TARGET OpenSSL::SSL OR NOT TARGET OpenSSL::Crypto)
|
||||
+ add_subdirectory(${CMAKE_SOURCE_DIR}/externals/openssl)
|
||||
+ # Since Cmake v3.11, Crypto & SSL became optional when not specified as COMPONENTS.
|
||||
+ if(HTTPLIB_REQUIRE_OPENSSL)
|
||||
+ #find_package(OpenSSL ${_HTTPLIB_OPENSSL_MIN_VER} COMPONENTS Crypto SSL REQUIRED)
|
||||
+ set(HTTPLIB_IS_USING_OPENSSL TRUE)
|
||||
+ elseif(HTTPLIB_USE_OPENSSL_IF_AVAILABLE)
|
||||
+ #find_package(OpenSSL ${_HTTPLIB_OPENSSL_MIN_VER} COMPONENTS Crypto SSL QUIET)
|
||||
+ # Avoid a rare circumstance of not finding all components but the end-user did their
|
||||
+ # own call for OpenSSL, which might trick us into thinking we'd otherwise have what we wanted
|
||||
+ if (TARGET OpenSSL::SSL AND TARGET OpenSSL::Crypto)
|
||||
+ set(HTTPLIB_IS_USING_OPENSSL ${OPENSSL_FOUND})
|
||||
+ else()
|
||||
+ set(HTTPLIB_IS_USING_OPENSSL FALSE)
|
||||
+ endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+11
-11
@@ -66,6 +66,10 @@ if (YUZU_STATIC_ROOM)
|
||||
set(fmt_FORCE_BUNDLED ON)
|
||||
endif()
|
||||
|
||||
if (YUZU_USE_EXTERNAL_OPENSSL)
|
||||
set(httplib_FORCE_BUNDLED ON)
|
||||
endif()
|
||||
|
||||
# qt stuff
|
||||
option(ENABLE_QT "Enable the Qt frontend" ON)
|
||||
option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF)
|
||||
@@ -207,6 +211,10 @@ endif()
|
||||
option(YUZU_USE_BUNDLED_FFMPEG "Download bundled FFmpeg" ${EXT_DEFAULT})
|
||||
cmake_dependent_option(YUZU_USE_EXTERNAL_FFMPEG "Build FFmpeg from external source" "${PLATFORM_SUN}" "NOT WIN32 AND NOT ANDROID" OFF)
|
||||
|
||||
# openssl
|
||||
option(YUZU_USE_BUNDLED_OPENSSL "Download bundled OpenSSL" ON)
|
||||
option(YUZU_USE_EXTERNAL_OPENSSL "Build OpenSSL from external source" OFF)
|
||||
|
||||
# sirit
|
||||
set(BUNDLED_SIRIT_DEFAULT OFF)
|
||||
if (MSVC AND NOT (CMAKE_BUILD_TYPE MATCHES "Deb") OR ANDROID)
|
||||
@@ -378,17 +386,6 @@ find_package(Threads REQUIRED)
|
||||
|
||||
find_package(RenderDoc MODULE)
|
||||
|
||||
# openssl funniness
|
||||
if (YUZU_USE_BUNDLED_OPENSSL)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
AddJsonPackage(openssl)
|
||||
if (OpenSSL_ADDED)
|
||||
add_compile_definitions(YUZU_BUNDLED_OPENSSL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(OpenSSL 3 REQUIRED)
|
||||
|
||||
message(STATUS "Fetching needed dependencies with CPM")
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
@@ -424,6 +421,9 @@ if (Boost_ADDED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# OpenSSL
|
||||
add_subdirectory(externals/openssl)
|
||||
|
||||
# fmt
|
||||
AddJsonPackage(fmt)
|
||||
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
{
|
||||
"openssl": {
|
||||
"package": "OpenSSL",
|
||||
"name": "openssl",
|
||||
"repo": "openssl/openssl",
|
||||
"tag": "openssl-%VERSION%",
|
||||
"version": "4.0.0",
|
||||
"git_version": "4.0.0"
|
||||
},
|
||||
"openssl-ci": {
|
||||
"ci": true,
|
||||
"package": "OpenSSL",
|
||||
"name": "openssl",
|
||||
|
||||
Vendored
+2
-1
@@ -33,7 +33,8 @@
|
||||
"find_args": "MODULE GLOBAL",
|
||||
"patches": [
|
||||
"0001-mingw.patch",
|
||||
"0002-fix-zstd.patch"
|
||||
"0002-fix-zstd.patch",
|
||||
"0003-openssl.patch"
|
||||
],
|
||||
"options": [
|
||||
"HTTPLIB_REQUIRE_OPENSSL ON",
|
||||
|
||||
Vendored
+102
@@ -0,0 +1,102 @@
|
||||
# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
if (YUZU_USE_BUNDLED_OPENSSL)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
AddJsonPackage(openssl-ci)
|
||||
if (OpenSSL_ADDED)
|
||||
add_compile_definitions(YUZU_BUNDLED_OPENSSL)
|
||||
endif()
|
||||
# openssl funniness
|
||||
find_package(OpenSSL 3 COMPONENTS SSL Crypto REQUIRED)
|
||||
else()
|
||||
message(STATUS "Using OpenSSL from externals")
|
||||
AddJsonPackage(openssl)
|
||||
set(OpenSSL_PREFIX ${OpenSSL_SOURCE_DIR})
|
||||
set(OpenSSL_BUILD_DIR ${OpenSSL_BINARY_DIR})
|
||||
set(OpenSSL_MAKEFILE ${OpenSSL_BUILD_DIR}/Makefile)
|
||||
set(OpenSSL_BUILD_LIBRARIES "")
|
||||
list(APPEND OpenSSL_BUILD_LIBRARIES
|
||||
"${OpenSSL_BUILD_DIR}/libssl.a"
|
||||
"${OpenSSL_BUILD_DIR}/libcrypto.a")
|
||||
|
||||
make_directory(${OpenSSL_BUILD_DIR})
|
||||
|
||||
# The ABSOLUTE best language, hands down, better than bash by a MILE
|
||||
find_program(PERL_PROGRAM perl)
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${OpenSSL_MAKEFILE}
|
||||
COMMAND
|
||||
${PERL_PROGRAM} ${OpenSSL_PREFIX}/Configure
|
||||
shared
|
||||
no-makedepend
|
||||
--release
|
||||
threads
|
||||
no-tests
|
||||
no-docs
|
||||
enable-camellia
|
||||
enable-ec
|
||||
enable-ec2m
|
||||
enable-sm2
|
||||
enable-srp
|
||||
enable-idea
|
||||
enable-mdc2
|
||||
enable-rc5
|
||||
enable-rfc3779
|
||||
enable-asm
|
||||
enable-quic
|
||||
enable-fips
|
||||
WORKING_DIRECTORY
|
||||
${OpenSSL_BUILD_DIR}
|
||||
)
|
||||
|
||||
# Workaround for Ubuntu 18.04's older version of make not being able to call make as a child
|
||||
# with context of the jobserver. Also helps ninja users.
|
||||
execute_process(COMMAND nproc OUTPUT_VARIABLE SYSTEM_THREADS)
|
||||
# BSD make or Solaris make don't support ffmpeg make-j8
|
||||
set(OpenSSL_MAKE_ARGS "")
|
||||
if (PLATFORM_LINUX OR ANDROID OR APPLE OR WIN32 OR PLATFORM_FREEBSD)
|
||||
set(OpenSSL_MAKE_ARGS -j${SYSTEM_THREADS})
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${OpenSSL_BUILD_LIBRARIES}
|
||||
COMMAND
|
||||
gmake ${OpenSSL_MAKE_ARGS}
|
||||
WORKING_DIRECTORY
|
||||
${OpenSSL_BUILD_DIR}
|
||||
)
|
||||
add_custom_target(openssl-configure ALL DEPENDS ${OpenSSL_MAKEFILE})
|
||||
add_custom_target(openssl-build ALL DEPENDS ${OpenSSL_BUILD_LIBRARIES} openssl-configure)
|
||||
|
||||
add_library(SSL INTERFACE)
|
||||
target_include_directories(SSL INTERFACE ${OpenSSL_SOURCE_DIR}/include)
|
||||
target_link_libraries(SSL INTERFACE openssl-build)
|
||||
|
||||
add_library(Crypto INTERFACE)
|
||||
target_include_directories(Crypto INTERFACE ${OpenSSL_SOURCE_DIR}/include)
|
||||
target_link_libraries(Crypto INTERFACE openssl-build)
|
||||
|
||||
add_library(OpenSSL::SSL ALIAS SSL)
|
||||
add_library(OpenSSL::Crypto ALIAS Crypto)
|
||||
|
||||
# evil haxx for httplib https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
|
||||
# fuck httplib
|
||||
set(OpenSSL_FOUND TRUE PARENT_SCOPE)
|
||||
set(OpenSSL_VERSION "4.0.0" PARENT_SCOPE)
|
||||
# Deprecated but some people run older cmake
|
||||
set(OPENSSL_FOUND TRUE PARENT_SCOPE)
|
||||
set(OPENSSL_VERSION "4.0.0" PARENT_SCOPE)
|
||||
|
||||
set(OPENSSL_INCLUDE_DIR ${OpenSSL_SOURCE_DIR}/include PARENT_SCOPE)
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${OpenSSL_BUILD_DIR}/libcrypto.a PARENT_SCOPE)
|
||||
set(OPENSSL_CRYPTO_LIBRARIES ${OpenSSL_BUILD_DIR}/libcrypto.a PARENT_SCOPE)
|
||||
set(OPENSSL_SSL_LIBRARY ${OpenSSL_BUILD_DIR}/libssl.a PARENT_SCOPE)
|
||||
set(OPENSSL_SSL_LIBRARIES ${OpenSSL_BUILD_DIR}/libssl.a PARENT_SCOPE)
|
||||
set(OPENSSL_LIBRARIES "${OpenSSL_BUILD_DIR}/libssl.a;${OpenSSL_BUILD_DIR}/libcrypto.a" PARENT_SCOPE)
|
||||
|
||||
set(OPENSSL_ROOT_DIR ${OpenSSL_BUILD_DIR} PARENT_SCOPE)
|
||||
set(OPENSSL_USE_STATIC_LIBS TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
@@ -150,13 +150,13 @@ add_library(
|
||||
httplib.h
|
||||
net/net.h net/net.cpp)
|
||||
|
||||
# httplib must be put first otherwise external-openssl builds won't work
|
||||
target_link_libraries(common PUBLIC httplib::httplib)
|
||||
if(WIN32)
|
||||
target_sources(common PRIVATE windows/timer_resolution.cpp
|
||||
windows/timer_resolution.h)
|
||||
target_link_libraries(common PRIVATE ntdll)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
else()
|
||||
target_sources(common PRIVATE signal_chain.cpp signal_chain.h)
|
||||
endif()
|
||||
|
||||
@@ -239,7 +239,7 @@ else()
|
||||
target_link_libraries(common PUBLIC Boost::headers)
|
||||
endif()
|
||||
|
||||
target_link_libraries(common PUBLIC Boost::filesystem Boost::context httplib::httplib nlohmann_json::nlohmann_json)
|
||||
target_link_libraries(common PUBLIC Boost::filesystem Boost::context nlohmann_json::nlohmann_json)
|
||||
|
||||
if (lz4_ADDED)
|
||||
target_include_directories(common PRIVATE ${lz4_SOURCE_DIR}/lib)
|
||||
|
||||
@@ -1206,7 +1206,9 @@ else()
|
||||
endif()
|
||||
|
||||
target_include_directories(core PRIVATE ${OPUS_INCLUDE_DIRS})
|
||||
target_link_libraries(core PUBLIC common PRIVATE audio_core hid_core network video_core nx_tzdb tz)
|
||||
target_link_libraries(core
|
||||
PUBLIC common
|
||||
PRIVATE audio_core hid_core network video_core nx_tzdb tz)
|
||||
|
||||
if (BOOST_NO_HEADERS)
|
||||
target_link_libraries(core PUBLIC Boost::container Boost::heap Boost::asio Boost::process Boost::crc)
|
||||
@@ -1220,7 +1222,7 @@ target_link_libraries(core PRIVATE
|
||||
RenderDoc::API
|
||||
ZLIB::ZLIB)
|
||||
|
||||
target_link_libraries(core PUBLIC httplib::httplib zstd::zstd)
|
||||
target_link_libraries(core PUBLIC zstd::zstd)
|
||||
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
target_compile_definitions(core PUBLIC ENABLE_WEB_SERVICE)
|
||||
|
||||
+101
-83
@@ -6,7 +6,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <span>
|
||||
@@ -123,14 +122,83 @@ struct Memory::Impl {
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] inline u8* GetPointerFromRasterizerCachedMemory(u64 vaddr) const {
|
||||
auto const paddr = current_page_table->entries[vaddr >> YUZU_PAGEBITS].addr;
|
||||
return paddr ? system.DeviceMemory().GetPointer<u8>(paddr + vaddr) : nullptr;
|
||||
[[nodiscard]] u8* GetPointerFromRasterizerCachedMemory(u64 vaddr) const {
|
||||
Common::PhysicalAddress const paddr = current_page_table->entries[vaddr >> YUZU_PAGEBITS].addr;
|
||||
if (paddr)
|
||||
return system.DeviceMemory().GetPointer<u8>(paddr + vaddr);
|
||||
return {};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline u8* GetPointerFromDebugMemory(u64 vaddr) const {
|
||||
auto const paddr = current_page_table->entries[vaddr >> YUZU_PAGEBITS].addr;
|
||||
return paddr ? system.DeviceMemory().GetPointer<u8>(paddr + vaddr) : nullptr;
|
||||
[[nodiscard]] u8* GetPointerFromDebugMemory(u64 vaddr) const {
|
||||
const Common::PhysicalAddress paddr = current_page_table->entries[vaddr >> YUZU_PAGEBITS].addr;
|
||||
if (paddr != 0)
|
||||
return system.DeviceMemory().GetPointer<u8>(paddr + vaddr);
|
||||
return {};
|
||||
}
|
||||
|
||||
u8 Read8(const Common::ProcessAddress addr) {
|
||||
return Read<u8>(addr);
|
||||
}
|
||||
|
||||
u16 Read16(const Common::ProcessAddress addr) {
|
||||
if ((addr & 1) == 0) {
|
||||
return Read<u16_le>(addr);
|
||||
} else {
|
||||
const u32 a{Read<u8>(addr)};
|
||||
const u32 b{Read<u8>(addr + sizeof(u8))};
|
||||
return static_cast<u16>((b << 8) | a);
|
||||
}
|
||||
}
|
||||
|
||||
u32 Read32(const Common::ProcessAddress addr) {
|
||||
if ((addr & 3) == 0) {
|
||||
return Read<u32_le>(addr);
|
||||
} else {
|
||||
const u32 a{Read16(addr)};
|
||||
const u32 b{Read16(addr + sizeof(u16))};
|
||||
return (b << 16) | a;
|
||||
}
|
||||
}
|
||||
|
||||
u64 Read64(const Common::ProcessAddress addr) {
|
||||
if ((addr & 7) == 0) {
|
||||
return Read<u64_le>(addr);
|
||||
} else {
|
||||
const u32 a{Read32(addr)};
|
||||
const u32 b{Read32(addr + sizeof(u32))};
|
||||
return (static_cast<u64>(b) << 32) | a;
|
||||
}
|
||||
}
|
||||
|
||||
void Write8(const Common::ProcessAddress addr, const u8 data) {
|
||||
Write<u8>(addr, data);
|
||||
}
|
||||
|
||||
void Write16(const Common::ProcessAddress addr, const u16 data) {
|
||||
if ((addr & 1) == 0) {
|
||||
Write<u16_le>(addr, data);
|
||||
} else {
|
||||
Write<u8>(addr, static_cast<u8>(data));
|
||||
Write<u8>(addr + sizeof(u8), static_cast<u8>(data >> 8));
|
||||
}
|
||||
}
|
||||
|
||||
void Write32(const Common::ProcessAddress addr, const u32 data) {
|
||||
if ((addr & 3) == 0) {
|
||||
Write<u32_le>(addr, data);
|
||||
} else {
|
||||
Write16(addr, static_cast<u16>(data));
|
||||
Write16(addr + sizeof(u16), static_cast<u16>(data >> 16));
|
||||
}
|
||||
}
|
||||
|
||||
void Write64(const Common::ProcessAddress addr, const u64 data) {
|
||||
if ((addr & 7) == 0) {
|
||||
Write<u64_le>(addr, data);
|
||||
} else {
|
||||
Write32(addr, static_cast<u32>(data));
|
||||
Write32(addr + sizeof(u32), static_cast<u32>(data >> 32));
|
||||
}
|
||||
}
|
||||
|
||||
bool WriteExclusive8(const Common::ProcessAddress addr, const u8 data, const u8 expected) {
|
||||
@@ -496,7 +564,7 @@ struct Memory::Impl {
|
||||
}
|
||||
|
||||
template<typename F, typename G>
|
||||
[[nodiscard]] inline u8* GetPointerImpl(u64 vaddr, F&& on_unmapped, G&& on_rasterizer) const {
|
||||
[[nodiscard]] u8* GetPointerImpl(u64 vaddr, F&& on_unmapped, G&& on_rasterizer) const {
|
||||
// AARCH64 masks the upper 16 bit of all memory accesses
|
||||
vaddr &= 0xffffffffffffULL;
|
||||
if (AddressSpaceContains(*current_page_table, vaddr, 1)) [[likely]] {
|
||||
@@ -551,42 +619,18 @@ struct Memory::Impl {
|
||||
/// @returns The instance of T read from the specified virtual address.
|
||||
template <typename T>
|
||||
inline T Read(Common::ProcessAddress vaddr) noexcept requires(std::is_trivially_copyable_v<T>) {
|
||||
auto const addr_c1 = GetInteger(vaddr);
|
||||
if (!(sizeof(T) > 1 && (addr_c1 & 4095) + sizeof(T) > 4096)) {
|
||||
if (auto const ptr_c1 = GetPointerImpl(addr_c1, [addr_c1] {
|
||||
LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8, addr_c1);
|
||||
}, [&] {
|
||||
HandleRasterizerDownload(addr_c1, sizeof(T));
|
||||
}); ptr_c1) {
|
||||
// It may be tempting to rewrite this particular section to use "reinterpret_cast";
|
||||
// afterall, it's trivially copyable so surely it can be copied ov- Alignment.
|
||||
// Remember, alignment. memcpy() will deal with all the alignment extremely fast.
|
||||
T result{};
|
||||
std::memcpy(&result, ptr_c1, sizeof(T));
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
auto const addr_c2 = (addr_c1 & (~0xfff)) + 0x1000;
|
||||
// page crossing: say if sizeof(T) = 2, vaddr = 4095
|
||||
// 4095 + 2 mod 4096 = 1 => 2 - 1 = 1, thus c1=1, c2=1
|
||||
auto const count_c2 = (addr_c1 + sizeof(T)) & 4095;
|
||||
auto const count_c1 = sizeof(T) - count_c2;
|
||||
if (auto const ptr_c1 = GetPointerImpl(addr_c1, [addr_c1] {
|
||||
LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8, addr_c1);
|
||||
}, [&] {
|
||||
HandleRasterizerDownload(addr_c1, count_c1);
|
||||
}); ptr_c1) {
|
||||
if (auto const ptr_c2 = GetPointerImpl(addr_c2, [addr_c2] {
|
||||
LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8, addr_c2);
|
||||
}, [&] {
|
||||
HandleRasterizerDownload(addr_c2, count_c2);
|
||||
}); ptr_c2) {
|
||||
std::array<char, sizeof(T)> result{};
|
||||
std::memcpy(result.data() + 0, ptr_c1, count_c1);
|
||||
std::memcpy(result.data() + count_c1, ptr_c2, count_c2);
|
||||
return std::bit_cast<T>(result);
|
||||
}
|
||||
}
|
||||
const u64 addr = GetInteger(vaddr);
|
||||
if (auto const ptr = GetPointerImpl(addr, [addr]() {
|
||||
LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8, addr);
|
||||
}, [&]() {
|
||||
HandleRasterizerDownload(addr, sizeof(T));
|
||||
}); ptr) [[likely]] {
|
||||
// It may be tempting to rewrite this particular section to use "reinterpret_cast";
|
||||
// afterall, it's trivially copyable so surely it can be copied ov- Alignment.
|
||||
// Remember, alignment. memcpy() will deal with all the alignment extremely fast.
|
||||
T result{};
|
||||
std::memcpy(&result, ptr, sizeof(T));
|
||||
return result;
|
||||
}
|
||||
return T{};
|
||||
}
|
||||
@@ -596,37 +640,11 @@ struct Memory::Impl {
|
||||
/// @tparam T The data type to write to memory.
|
||||
template <typename T>
|
||||
inline void Write(Common::ProcessAddress vaddr, const T data) noexcept requires(std::is_trivially_copyable_v<T>) {
|
||||
auto const addr_c1 = GetInteger(vaddr);
|
||||
if (!(sizeof(T) > 1 && (addr_c1 & 4095) + sizeof(T) > 4096)) {
|
||||
if (auto const ptr_c1 = GetPointerImpl(addr_c1, [addr_c1] {
|
||||
LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8, addr_c1);
|
||||
}, [&] {
|
||||
HandleRasterizerWrite(addr_c1, sizeof(T));
|
||||
}); ptr_c1) {
|
||||
std::memcpy(ptr_c1, &data, sizeof(T));
|
||||
}
|
||||
} else {
|
||||
auto const addr_c2 = (addr_c1 & (~0xfff)) + 0x1000;
|
||||
// page crossing: say if sizeof(T) = 2, vaddr = 4095
|
||||
// 4095 + 2 mod 4096 = 1 => 2 - 1 = 1, thus c1=1, c2=1
|
||||
auto const count_c2 = (addr_c1 + sizeof(T)) & 4095;
|
||||
auto const count_c1 = sizeof(T) - count_c2;
|
||||
if (auto const ptr_c1 = GetPointerImpl(addr_c1, [addr_c1] {
|
||||
LOG_ERROR(HW_Memory, "Unmapped Write{} @ 0x{:016X}", sizeof(T) * 8, addr_c1);
|
||||
}, [&] {
|
||||
HandleRasterizerWrite(addr_c1, count_c1);
|
||||
}); ptr_c1) {
|
||||
if (auto const ptr_c2 = GetPointerImpl(addr_c2, [addr_c2] {
|
||||
LOG_ERROR(HW_Memory, "Unmapped Write{} @ 0x{:016X}", sizeof(T) * 8, addr_c2);
|
||||
}, [&] {
|
||||
HandleRasterizerWrite(addr_c2, count_c2);
|
||||
}); ptr_c2) {
|
||||
std::array<char, sizeof(T)> tmp = std::bit_cast<std::array<char, sizeof(T)>>(data);
|
||||
std::memcpy(ptr_c1, tmp.data() + 0, count_c1);
|
||||
std::memcpy(ptr_c2, tmp.data() + count_c1, count_c2);
|
||||
}
|
||||
}
|
||||
}
|
||||
const u64 addr = GetInteger(vaddr);
|
||||
if (auto const ptr = GetPointerImpl(addr, [addr, data]() {
|
||||
LOG_ERROR(HW_Memory, "Unmapped Write{} @ 0x{:016X} = 0x{:016X}", sizeof(T) * 8, addr, u64(data));
|
||||
}, [&]() { HandleRasterizerWrite(addr, sizeof(T)); }); ptr) [[likely]]
|
||||
std::memcpy(ptr, &data, sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -824,35 +842,35 @@ const u8* Memory::GetPointer(Common::ProcessAddress vaddr) const {
|
||||
}
|
||||
|
||||
u8 Memory::Read8(const Common::ProcessAddress addr) {
|
||||
return impl->Read<u8>(addr);
|
||||
return impl->Read8(addr);
|
||||
}
|
||||
|
||||
u16 Memory::Read16(const Common::ProcessAddress addr) {
|
||||
return impl->Read<u16_le>(addr);
|
||||
return impl->Read16(addr);
|
||||
}
|
||||
|
||||
u32 Memory::Read32(const Common::ProcessAddress addr) {
|
||||
return impl->Read<u32_le>(addr);
|
||||
return impl->Read32(addr);
|
||||
}
|
||||
|
||||
u64 Memory::Read64(const Common::ProcessAddress addr) {
|
||||
return impl->Read<u64_le>(addr);
|
||||
return impl->Read64(addr);
|
||||
}
|
||||
|
||||
void Memory::Write8(Common::ProcessAddress addr, u8 data) {
|
||||
impl->Write<u8>(addr, data);
|
||||
impl->Write8(addr, data);
|
||||
}
|
||||
|
||||
void Memory::Write16(Common::ProcessAddress addr, u16 data) {
|
||||
impl->Write<u16_le>(addr, data);
|
||||
impl->Write16(addr, data);
|
||||
}
|
||||
|
||||
void Memory::Write32(Common::ProcessAddress addr, u32 data) {
|
||||
impl->Write<u32_le>(addr, data);
|
||||
impl->Write32(addr, data);
|
||||
}
|
||||
|
||||
void Memory::Write64(Common::ProcessAddress addr, u64 data) {
|
||||
impl->Write<u64_le>(addr, data);
|
||||
impl->Write64(addr, data);
|
||||
}
|
||||
|
||||
bool Memory::WriteExclusive8(Common::ProcessAddress addr, u8 data, u8 expected) {
|
||||
|
||||
@@ -49,7 +49,7 @@ if (USE_DISCORD_PRESENCE)
|
||||
discord/discord_impl.cpp
|
||||
discord/discord_impl.h
|
||||
)
|
||||
target_link_libraries(qt_common PUBLIC DiscordRPC::discord-rpc httplib::httplib)
|
||||
target_link_libraries(qt_common PUBLIC httplib::httplib DiscordRPC::discord-rpc)
|
||||
|
||||
if (YUZU_USE_BUNDLED_OPENSSL)
|
||||
target_link_libraries(qt_common PUBLIC OpenSSL::SSL OpenSSL::Crypto)
|
||||
|
||||
@@ -331,9 +331,7 @@ endif()
|
||||
if (YUZU_USE_EXTERNAL_FFMPEG)
|
||||
add_dependencies(video_core ffmpeg-build)
|
||||
endif()
|
||||
|
||||
target_include_directories(video_core PRIVATE ${FFmpeg_INCLUDE_DIR})
|
||||
|
||||
target_link_libraries(video_core PRIVATE ${FFmpeg_LIBRARIES})
|
||||
target_link_options(video_core PRIVATE ${FFmpeg_LDFLAGS})
|
||||
|
||||
|
||||
@@ -18,7 +18,5 @@ add_library(web_service STATIC
|
||||
|
||||
create_target_directory_groups(web_service)
|
||||
target_include_directories(web_service PUBLIC ${cpp-jwt_SOURCE_DIR}/include)
|
||||
target_link_libraries(web_service PRIVATE common network nlohmann_json::nlohmann_json httplib::httplib cpp-jwt::cpp-jwt)
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(web_service PRIVATE httplib::httplib common network nlohmann_json::nlohmann_json cpp-jwt::cpp-jwt)
|
||||
target_link_libraries(web_service PRIVATE OpenSSL::SSL OpenSSL::Crypto)
|
||||
|
||||
Reference in New Issue
Block a user