From a78061683495e1d9a3e90776992a467ba1c59245 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 3 Jan 2026 21:13:42 +0000 Subject: [PATCH 001/108] toolchain-fix --- .ci/ps4/build.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 +++ docs/Caveats.md | 8 ++++++++ 3 files changed, 63 insertions(+) create mode 100755 .ci/ps4/build.sh diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh new file mode 100755 index 0000000000..f51056262e --- /dev/null +++ b/.ci/ps4/build.sh @@ -0,0 +1,52 @@ +#!/usr/local/bin/bash -ex + +# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + +cat << EOF >"ps4-toolchain.cmake" +set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN") + +set(CMAKE_C_FLAGS "--target=x86_64-pc-freebsd12-elf -funwind-tables -fuse-ld=ldd") +set(CMAKE_CXX_FLAGS "--target=x86_64-pc-freebsd12-elf -funwind-tables -fuse-ld=lld") + +set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lc++ -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") +set(CMAKE_C_LINK_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") +set(CMAKE_CXX_LINK_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lc++ -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") + +set(CMAKE_C_COMPILER clang) +set(CMAKE_CXX_COMPILER clang++) +set(CMAKE_LINKER ld.lld) +set(CMAKE_C_LINK_EXECUTABLE " -o ") +set(CMAKE_CXX_LINK_EXECUTABLE " -o ") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +EOF + +export ARCH_FLAGS="$ARCH_FLAGS -O3" +if [ -z "$NPROC" ]; then + NPROC="$(nproc)" +fi + +# Normally a platform has a package manager +# PS4 does not, atleast not in the normal sense +export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@) +mkdir -p build +cd build && cmake .. -G Ninja \ + -DCMAKE_TOOLCHAIN_FILE="ps4-toolchain.cmake" \ + -DENABLE_QT_TRANSLATION=OFF \ + -DUSE_DISCORD_PRESENCE=OFF \ + -DENABLE_CUBEB=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_FLAGS="$ARCH_FLAGS" \ + -DCMAKE_C_FLAGS="$ARCH_FLAGS" \ + -DENABLE_SDL2=OFF \ + -DENABLE_QT=OFF \ + -DENABLE_OPENSSL=OFF \ + -DCPMUTIL_FORCE_BUNDLED=ON \ + -DYUZU_USE_CPM=ON \ + "${EXTRA_CMAKE_FLAGS[@]}" || exit + +cd build && ninja -j${NPROC} || exit diff --git a/.gitignore b/.gitignore index 67bdd8adf4..b304411646 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,6 @@ artifacts /install* vulkansdk*.exe *.tar.zst + +# PS4 toolchain stuff +ps4-toolchain.cmake diff --git a/docs/Caveats.md b/docs/Caveats.md index fb86437737..9a8de81fb3 100644 --- a/docs/Caveats.md +++ b/docs/Caveats.md @@ -12,6 +12,7 @@ - [NetBSD](#netbsd) - [MSYS2](#msys2) - [RedoxOS](#redoxos) +- [PlayStation 4](#playstation-4) - [Windows](#windows) - [Windows 7, Windows 8 and Windows 8.1](#windows-7-windows-8-and-windows-81) - [Windows Vista and below](#windows-vista-and-below) @@ -245,6 +246,13 @@ The package install may randomly hang at times, in which case it has to be resta When CMake invokes certain file syscalls - it may sometimes cause crashes or corruptions on the (kernel?) address space - so reboot the system if there is a "hang" in CMake. +## PlayStation 4 + +```sh +export OO_PS4_TOOLCHAIN="$HOME/OpenOrbis/PS4Toolchain" +export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 +``` + ## Windows ### Windows 7, Windows 8 and Windows 8.1 From 65d99aeac5a446cc4e6c025394df89a99f51b6c0 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 29 Nov 2025 22:53:31 +0000 Subject: [PATCH 002/108] fix --- .ci/ps4/build.sh | 17 +++++++++++------ CMakeModules/GenerateSCMRev.cmake | 5 ++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index f51056262e..87fd00a470 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -6,8 +6,8 @@ cat << EOF >"ps4-toolchain.cmake" set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN") -set(CMAKE_C_FLAGS "--target=x86_64-pc-freebsd12-elf -funwind-tables -fuse-ld=ldd") -set(CMAKE_CXX_FLAGS "--target=x86_64-pc-freebsd12-elf -funwind-tables -fuse-ld=lld") +set(CMAKE_C_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -funwind-tables -isystem $OO_PS4_TOOLCHAIN/include -isystem $OO_PS4_TOOLCHAIN/include/c++/v1") +set(CMAKE_CXX_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -funwind-tables -isystem $OO_PS4_TOOLCHAIN/include -isystem $OO_PS4_TOOLCHAIN/include/c++/v1") set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lc++ -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") set(CMAKE_C_LINK_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") @@ -23,6 +23,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# TODO: Why does cmake not set this? +set(CMAKE_SIZEOF_VOID_P 8) EOF export ARCH_FLAGS="$ARCH_FLAGS -O3" @@ -34,10 +37,10 @@ fi # PS4 does not, atleast not in the normal sense export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@) mkdir -p build -cd build && cmake .. -G Ninja \ +cd build +cmake .. -G Ninja \ -DCMAKE_TOOLCHAIN_FILE="ps4-toolchain.cmake" \ -DENABLE_QT_TRANSLATION=OFF \ - -DUSE_DISCORD_PRESENCE=OFF \ -DENABLE_CUBEB=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_FLAGS="$ARCH_FLAGS" \ @@ -45,8 +48,10 @@ cd build && cmake .. -G Ninja \ -DENABLE_SDL2=OFF \ -DENABLE_QT=OFF \ -DENABLE_OPENSSL=OFF \ + -DENABLE_WEB_SERVICE=OFF \ + -DUSE_DISCORD_PRESENCE=OFF \ -DCPMUTIL_FORCE_BUNDLED=ON \ + -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit - -cd build && ninja -j${NPROC} || exit +ninja -j${NPROC} || exit diff --git a/CMakeModules/GenerateSCMRev.cmake b/CMakeModules/GenerateSCMRev.cmake index 40c64fea1e..8f1e55e12c 100644 --- a/CMakeModules/GenerateSCMRev.cmake +++ b/CMakeModules/GenerateSCMRev.cmake @@ -18,10 +18,13 @@ if (DEFINED GIT_RELEASE) set(BUILD_VERSION "${GIT_TAG}") set(GIT_REFSPEC "${GIT_RELEASE}") set(IS_DEV_BUILD false) -else() +elseif(DEFINED GIT_COMMIT) string(SUBSTRING ${GIT_COMMIT} 0 10 BUILD_VERSION) set(BUILD_VERSION "${BUILD_VERSION}-${GIT_REFSPEC}") set(IS_DEV_BUILD true) +else() + set(BUILD_VERSION "NoGitInfo") + set(IS_DEV_BUILD true) endif() if (NIGHTLY_BUILD) From 2bd62841d729c424818310a284ec58bfaf0d62dd Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 5 Dec 2025 03:49:26 +0000 Subject: [PATCH 003/108] merge --- .ci/ps4/build.sh | 20 ++++++++++---------- .patch/boost/0004-openorbis.patch | 17 +++++++++++++++++ .patch/enet/0001-openorbis.patch | 13 +++++++++++++ .patch/mbedtls/0002-aesni-fix.patch | 13 +++++++++++++ .patch/spirv-tools/0003-openorbis.patch | 25 +++++++++++++++++++++++++ cpmfile.json | 3 ++- externals/cpmfile.json | 5 ++++- src/common/memory_detect.cpp | 4 ++-- 8 files changed, 86 insertions(+), 14 deletions(-) create mode 100644 .patch/boost/0004-openorbis.patch create mode 100644 .patch/enet/0001-openorbis.patch create mode 100644 .patch/mbedtls/0002-aesni-fix.patch create mode 100644 .patch/spirv-tools/0003-openorbis.patch diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 87fd00a470..b80e2a2e6f 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -3,15 +3,17 @@ # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later -cat << EOF >"ps4-toolchain.cmake" +OO_PS4_TOOLCHAIN="/home/xerix/src/ps4-sdk/prefix" + +[ -f "ps4-toolchain.cmake" ] || cat << EOF >"ps4-toolchain.cmake" set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN") -set(CMAKE_C_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -funwind-tables -isystem $OO_PS4_TOOLCHAIN/include -isystem $OO_PS4_TOOLCHAIN/include/c++/v1") -set(CMAKE_CXX_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -funwind-tables -isystem $OO_PS4_TOOLCHAIN/include -isystem $OO_PS4_TOOLCHAIN/include/c++/v1") +set(CMAKE_C_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables -nostdinc -isystem $OO_PS4_TOOLCHAIN/include/c++/v1 -isystem $OO_PS4_TOOLCHAIN/include") +set(CMAKE_CXX_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables -nostdinc -isystem $OO_PS4_TOOLCHAIN/include/c++/v1 -isystem $OO_PS4_TOOLCHAIN/include") -set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lc++ -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") -set(CMAKE_C_LINK_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") -set(CMAKE_CXX_LINK_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib -lc -lkernel -lc++ -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") +set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib") +set(CMAKE_C_LINK_FLAGS "-lc -lkernel -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") +set(CMAKE_CXX_LINK_FLAGS " -lc++") set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) @@ -36,9 +38,7 @@ fi # Normally a platform has a package manager # PS4 does not, atleast not in the normal sense export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@) -mkdir -p build -cd build -cmake .. -G Ninja \ +cmake -S . -B build -G Ninja \ -DCMAKE_TOOLCHAIN_FILE="ps4-toolchain.cmake" \ -DENABLE_QT_TRANSLATION=OFF \ -DENABLE_CUBEB=OFF \ @@ -54,4 +54,4 @@ cmake .. -G Ninja \ -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit -ninja -j${NPROC} || exit +cmake --build build --parallel diff --git a/.patch/boost/0004-openorbis.patch b/.patch/boost/0004-openorbis.patch new file mode 100644 index 0000000000..c027956500 --- /dev/null +++ b/.patch/boost/0004-openorbis.patch @@ -0,0 +1,17 @@ +diff --git a/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp b/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp +index 0129511c..10fc9b04 100644 +--- a/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp ++++ b/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp +@@ -15,6 +15,12 @@ + # pragma once + #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) + ++// hacky fix for ps4 ++#if defined(_LIBCPP_HAS_MUSL_LIBC) ++# define FIONBIO 0 ++# define FIONREAD 1 ++#endif ++ + #include + + #include diff --git a/.patch/enet/0001-openorbis.patch b/.patch/enet/0001-openorbis.patch new file mode 100644 index 0000000000..4e6dab279e --- /dev/null +++ b/.patch/enet/0001-openorbis.patch @@ -0,0 +1,13 @@ +diff --git a/unix.c b/unix.c +index 6669216..86a2faa 100644 +--- a/unix.c ++++ b/unix.c +@@ -53,7 +53,7 @@ + #include + #endif + +-#if !defined(HAS_SOCKLEN_T) && !defined(__socklen_t_defined) ++#if !defined(_LIBCPP_HAS_MUSL_LIBC) && !defined(HAS_SOCKLEN_T) && !defined(__socklen_t_defined) + typedef int socklen_t; + #endif + diff --git a/.patch/mbedtls/0002-aesni-fix.patch b/.patch/mbedtls/0002-aesni-fix.patch new file mode 100644 index 0000000000..5112ded892 --- /dev/null +++ b/.patch/mbedtls/0002-aesni-fix.patch @@ -0,0 +1,13 @@ +diff --git a/library/aesni.h b/library/aesni.h +index 754c984c79..59e27afd3e 100644 +--- a/library/aesni.h ++++ b/library/aesni.h +@@ -35,7 +35,7 @@ + /* GCC-like compilers: currently, we only support intrinsics if the requisite + * target flag is enabled when building the library (e.g. `gcc -mpclmul -msse2` + * or `clang -maes -mpclmul`). */ +-#if (defined(__GNUC__) || defined(__clang__)) && defined(__AES__) && defined(__PCLMUL__) ++#if (defined(__GNUC__) || defined(__clang__)) && !defined(_LIBCPP_HAS_MUSL_LIBC) + #define MBEDTLS_AESNI_HAVE_INTRINSICS + #endif + /* For 32-bit, we only support intrinsics */ diff --git a/.patch/spirv-tools/0003-openorbis.patch b/.patch/spirv-tools/0003-openorbis.patch new file mode 100644 index 0000000000..f2c19d893f --- /dev/null +++ b/.patch/spirv-tools/0003-openorbis.patch @@ -0,0 +1,25 @@ +diff --git a/source/opt/loop_dependence.cpp b/source/opt/loop_dependence.cpp +index e41c044..a51b53b 100644 +--- a/source/opt/loop_dependence.cpp ++++ b/source/opt/loop_dependence.cpp +@@ -12,6 +12,12 @@ + // See the License for the specific language governing permissions and + // limitations under the License. + ++// PS4: issue? ++#ifdef __PS4__ ++#pragma clang diagnostic ignored "-Wabsolute-value" ++#pragma clang diagnostic ignored "-Wshorten-64-to-32" ++#endif ++ + #include "source/opt/loop_dependence.h" + + #include +@@ -19,6 +25,7 @@ + #include + #include + #include ++#include + + #include "source/opt/instruction.h" + #include "source/opt/scalar_analysis_nodes.h" diff --git a/cpmfile.json b/cpmfile.json index ead839de2e..798e246fcb 100644 --- a/cpmfile.json +++ b/cpmfile.json @@ -17,7 +17,8 @@ "version": "1.57", "find_args": "CONFIG OPTIONAL_COMPONENTS headers context system fiber filesystem", "patches": [ - "0001-clang-cl.patch" + "0001-clang-cl.patch", + "0004-openorbis.patch" ] }, "fmt": { diff --git a/externals/cpmfile.json b/externals/cpmfile.json index 4e9356cb83..c586926e9f 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -99,7 +99,10 @@ "hash": "a0d2fa8c957704dd49e00a726284ac5ca034b50b00d2b20a94fa1bbfbb80841467834bfdc84aa0ed0d6aab894608fd6c86c3b94eee46343f0e6d9c22e391dbf9", "version": "1.3", "git_version": "1.3.18", - "find_args": "MODULE" + "find_args": "MODULE", + "patches": [ + "0001-openorbis.patch" + ] }, "spirv-headers": { "package": "SPIRV-Headers", diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp index 86a3abcc6d..a8e43a1e4b 100644 --- a/src/common/memory_detect.cpp +++ b/src/common/memory_detect.cpp @@ -8,7 +8,7 @@ // clang-format on #else #include -#if defined(__APPLE__) || defined(__FreeBSD__) +#if defined(__APPLE__) || (defined(__FreeBSD__) && !defined(_LIBCPP_HAS_MUSL_LIBC)) #include #elif defined(__linux__) #include @@ -43,7 +43,7 @@ static MemoryInfo Detect() { sysctlbyname("vm.swapusage", &vmusage, &sizeof_vmusage, nullptr, 0); mem_info.TotalPhysicalMemory = ramsize; mem_info.TotalSwapMemory = vmusage.xsu_total; -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) && !defined(_LIBCPP_HAS_MUSL_LIBC) u_long physmem, swap_total; std::size_t sizeof_u_long = sizeof(u_long); // sysctlbyname(const char *, void *, size_t *, const void *, size_t); From c110ab1e23c6037787cc6c0c15c7daebbaf477af Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 19 May 2026 08:00:31 +0000 Subject: [PATCH 004/108] merge --- .ci/ps4/build.sh | 18 +++++++++--------- .patch/boost/0004-openorbis.patch | 2 +- .patch/enet/0001-openorbis.patch | 2 +- .patch/mbedtls/0002-aesni-fix.patch | 2 +- src/common/memory_detect.cpp | 4 ++-- .../backend/exception_handler_posix.cpp | 17 +++++++++++++---- src/dynarmic/src/dynarmic/common/context.h | 5 ++++- 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index b80e2a2e6f..3b2f6e5481 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -3,23 +3,23 @@ # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later -OO_PS4_TOOLCHAIN="/home/xerix/src/ps4-sdk/prefix" - [ -f "ps4-toolchain.cmake" ] || cat << EOF >"ps4-toolchain.cmake" set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN") +set(CMAKE_STAGING_PREFIX "$OO_PS4_TOOLCHAIN") +set(CMAKE_SYSTEM_NAME "OpenOrbis") -set(CMAKE_C_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables -nostdinc -isystem $OO_PS4_TOOLCHAIN/include/c++/v1 -isystem $OO_PS4_TOOLCHAIN/include") -set(CMAKE_CXX_FLAGS "-D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables -nostdinc -isystem $OO_PS4_TOOLCHAIN/include/c++/v1 -isystem $OO_PS4_TOOLCHAIN/include") +set(CMAKE_C_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables") +set(CMAKE_CXX_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables") -set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie --script $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib") -set(CMAKE_C_LINK_FLAGS "-lc -lkernel -lSceUserService -lSceVideoOut -lSceAudioOut -lScePad -lSceSysmodule -lSceFreeType $OO_PS4_TOOLCHAIN/lib/crt1.o") -set(CMAKE_CXX_LINK_FLAGS " -lc++") +set(CMAKE_EXE_LINKER_FLAGS "-T $OO_PS4_TOOLCHAIN/link.x -L$OO_PS4_TOOLCHAIN/lib") +set(CMAKE_C_LINK_FLAGS "-T $OO_PS4_TOOLCHAIN/link.x -L$OO_PS4_TOOLCHAIN/lib") +set(CMAKE_CXX_LINK_FLAGS "-T $OO_PS4_TOOLCHAIN/link.x -L$OO_PS4_TOOLCHAIN/lib") set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) set(CMAKE_LINKER ld.lld) -set(CMAKE_C_LINK_EXECUTABLE " -o ") -set(CMAKE_CXX_LINK_EXECUTABLE " -o ") +set(CMAKE_C_LINK_EXECUTABLE " -o -lc -lkernel -lSceUserService -lSceSysmodule -lSceNet $OO_PS4_TOOLCHAIN/lib/crt1.o") +set(CMAKE_CXX_LINK_EXECUTABLE " -o -lc -lkernel -lunwind -lc++ -lc++abi -lc++experimental -lrt -lSceUserService -lSceSysmodule -lSceNet $OO_PS4_TOOLCHAIN/lib/crt1.o") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/.patch/boost/0004-openorbis.patch b/.patch/boost/0004-openorbis.patch index c027956500..09071b599c 100644 --- a/.patch/boost/0004-openorbis.patch +++ b/.patch/boost/0004-openorbis.patch @@ -7,7 +7,7 @@ index 0129511c..10fc9b04 100644 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) +// hacky fix for ps4 -+#if defined(_LIBCPP_HAS_MUSL_LIBC) ++#if defined(__OPENORBIS__) +# define FIONBIO 0 +# define FIONREAD 1 +#endif diff --git a/.patch/enet/0001-openorbis.patch b/.patch/enet/0001-openorbis.patch index 4e6dab279e..744e2f879d 100644 --- a/.patch/enet/0001-openorbis.patch +++ b/.patch/enet/0001-openorbis.patch @@ -7,7 +7,7 @@ index 6669216..86a2faa 100644 #endif -#if !defined(HAS_SOCKLEN_T) && !defined(__socklen_t_defined) -+#if !defined(_LIBCPP_HAS_MUSL_LIBC) && !defined(HAS_SOCKLEN_T) && !defined(__socklen_t_defined) ++#if !defined(__OPENORBIS__) && !defined(HAS_SOCKLEN_T) && !defined(__socklen_t_defined) typedef int socklen_t; #endif diff --git a/.patch/mbedtls/0002-aesni-fix.patch b/.patch/mbedtls/0002-aesni-fix.patch index 5112ded892..e9a1bce5e6 100644 --- a/.patch/mbedtls/0002-aesni-fix.patch +++ b/.patch/mbedtls/0002-aesni-fix.patch @@ -7,7 +7,7 @@ index 754c984c79..59e27afd3e 100644 * target flag is enabled when building the library (e.g. `gcc -mpclmul -msse2` * or `clang -maes -mpclmul`). */ -#if (defined(__GNUC__) || defined(__clang__)) && defined(__AES__) && defined(__PCLMUL__) -+#if (defined(__GNUC__) || defined(__clang__)) && !defined(_LIBCPP_HAS_MUSL_LIBC) ++#if (defined(__GNUC__) || defined(__clang__)) && !defined(__OPENORBIS__) #define MBEDTLS_AESNI_HAVE_INTRINSICS #endif /* For 32-bit, we only support intrinsics */ diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp index a8e43a1e4b..074c02a9c3 100644 --- a/src/common/memory_detect.cpp +++ b/src/common/memory_detect.cpp @@ -8,7 +8,7 @@ // clang-format on #else #include -#if defined(__APPLE__) || (defined(__FreeBSD__) && !defined(_LIBCPP_HAS_MUSL_LIBC)) +#if defined(__APPLE__) || (defined(__FreeBSD__) && !defined(__OPENORBIS__)) #include #elif defined(__linux__) #include @@ -43,7 +43,7 @@ static MemoryInfo Detect() { sysctlbyname("vm.swapusage", &vmusage, &sizeof_vmusage, nullptr, 0); mem_info.TotalPhysicalMemory = ramsize; mem_info.TotalSwapMemory = vmusage.xsu_total; -#elif defined(__FreeBSD__) && !defined(_LIBCPP_HAS_MUSL_LIBC) +#elif defined(__FreeBSD__) && !defined(__OPENORBIS__) u_long physmem, swap_total; std::size_t sizeof_u_long = sizeof(u_long); // sysctlbyname(const char *, void *, size_t *, const void *, size_t); diff --git a/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp b/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp index 224559133a..537782c883 100644 --- a/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp +++ b/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp @@ -60,12 +60,16 @@ public: signal_stack_size = std::max(SIGSTKSZ, 2 * 1024 * 1024); signal_stack_memory = mmap(nullptr, signal_stack_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +#ifdef __OPENORBIS__ + fmt::print(stderr, "no fastmem on ps4\n"); + supports_fast_mem = false; +#else stack_t signal_stack{}; signal_stack.ss_sp = signal_stack_memory; signal_stack.ss_size = signal_stack_size; signal_stack.ss_flags = 0; if (sigaltstack(&signal_stack, nullptr) != 0) { - fmt::print(stderr, "dynarmic: POSIX SigHandler: init failure at sigaltstack\n"); + fmt::print(stderr, "POSIX SigHandler: init failure at sigaltstack\n"); supports_fast_mem = false; return; } @@ -76,16 +80,17 @@ public: sa.sa_flags = SA_SIGINFO | SA_ONSTACK | SA_RESTART; sigemptyset(&sa.sa_mask); if (sigaction(SIGSEGV, &sa, &old_sa_segv) != 0) { - fmt::print(stderr, "dynarmic: POSIX SigHandler: could not set SIGSEGV handler\n"); + fmt::print(stderr, "POSIX SigHandler: could not set SIGSEGV handler\n"); supports_fast_mem = false; return; } -#ifdef __APPLE__ +# ifdef __APPLE__ if (sigaction(SIGBUS, &sa, &old_sa_bus) != 0) { - fmt::print(stderr, "dynarmic: POSIX SigHandler: could not set SIGBUS handler\n"); + fmt::print(stderr, "POSIX SigHandler: could not set SIGBUS handler\n"); supports_fast_mem = false; return; } +# endif #endif } @@ -154,6 +159,9 @@ void SigHandler::SigAction(int sig, siginfo_t* info, void* raw_context) { # error "Invalid architecture" #endif +#ifdef __OPENORBIS__ + // No fastmem +#else struct sigaction* retry_sa = sig == SIGSEGV ? &sig_handler->old_sa_segv : &sig_handler->old_sa_bus; if (retry_sa->sa_flags & SA_SIGINFO) { retry_sa->sa_sigaction(sig, info, raw_context); @@ -167,6 +175,7 @@ void SigHandler::SigAction(int sig, siginfo_t* info, void* raw_context) { return; } retry_sa->sa_handler(sig); +#endif } } // anonymous namespace diff --git a/src/dynarmic/src/dynarmic/common/context.h b/src/dynarmic/src/dynarmic/common/context.h index db7af8e0ae..58fc707e9f 100644 --- a/src/dynarmic/src/dynarmic/common/context.h +++ b/src/dynarmic/src/dynarmic/common/context.h @@ -88,7 +88,7 @@ # define CTX_Q(i) (fpctx->vregs[i]) # define CTX_FPSR (fpctx->fpsr) # define CTX_FPCR (fpctx->fpcr) -# elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) || defined(__DragonFly__) # define CTX_PC (mctx.mc_gpregs.gp_elr) # define CTX_SP (mctx.mc_gpregs.gp_sp) # define CTX_LR (mctx.mc_gpregs.gp_lr) @@ -131,6 +131,9 @@ # elif defined(__managarm__) # define CTX_PC (mctx.__pollution(gregs)[REG_RIP]) # define CTX_SP (mctx.__pollution(gregs)[REG_RSP]) +# elif defined(__OPENORBIS__) +# define CTX_RIP (mctx.gregs[REG_RIP]) +# define CTX_RSP (mctx.gregs[REG_RSP]) # else # error "unknown platform" # endif From afbe093c477d80069fb7fb6f17efdacc8562570d Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 5 Dec 2025 03:50:05 +0000 Subject: [PATCH 005/108] buildable toolchain script + fixes for ffmpeg --- .ci/ps4/build.sh | 21 ++--- .ci/ps4/make-toolchain.sh | 168 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 12 deletions(-) create mode 100644 .ci/ps4/make-toolchain.sh diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 3b2f6e5481..0dda2e9c9a 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -3,23 +3,25 @@ # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later +OO_PS4_TOOLCHAIN="/home/xerix/src/ps4-sdk/prefix" + [ -f "ps4-toolchain.cmake" ] || cat << EOF >"ps4-toolchain.cmake" set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN") set(CMAKE_STAGING_PREFIX "$OO_PS4_TOOLCHAIN") set(CMAKE_SYSTEM_NAME "OpenOrbis") -set(CMAKE_C_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables") -set(CMAKE_CXX_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -funwind-tables") +set(CMAKE_C_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -fPIC -funwind-tables") +set(CMAKE_CXX_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -fPIC -funwind-tables") -set(CMAKE_EXE_LINKER_FLAGS "-T $OO_PS4_TOOLCHAIN/link.x -L$OO_PS4_TOOLCHAIN/lib") -set(CMAKE_C_LINK_FLAGS "-T $OO_PS4_TOOLCHAIN/link.x -L$OO_PS4_TOOLCHAIN/lib") -set(CMAKE_CXX_LINK_FLAGS "-T $OO_PS4_TOOLCHAIN/link.x -L$OO_PS4_TOOLCHAIN/lib") +set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie -T $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib") +set(CMAKE_C_LINK_FLAGS "-m elf_x86_64 -pie -T $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib") +set(CMAKE_CXX_LINK_FLAGS "-m elf_x86_64 -pie -T $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib") set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) set(CMAKE_LINKER ld.lld) -set(CMAKE_C_LINK_EXECUTABLE " -o -lc -lkernel -lSceUserService -lSceSysmodule -lSceNet $OO_PS4_TOOLCHAIN/lib/crt1.o") -set(CMAKE_CXX_LINK_EXECUTABLE " -o -lc -lkernel -lunwind -lc++ -lc++abi -lc++experimental -lrt -lSceUserService -lSceSysmodule -lSceNet $OO_PS4_TOOLCHAIN/lib/crt1.o") +set(CMAKE_C_LINK_EXECUTABLE " -o -lc -lkernel -lSceUserService -lSceSysmodule -lSceNet -lSceLibcInternal $OO_PS4_TOOLCHAIN/lib/crt1.o ") +set(CMAKE_CXX_LINK_EXECUTABLE " -o -lc -lkernel -lc++ -lSceUserService -lSceSysmodule -lSceNet -lSceLibcInternal $OO_PS4_TOOLCHAIN/lib/crt1.o ") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) @@ -30,11 +32,6 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_SIZEOF_VOID_P 8) EOF -export ARCH_FLAGS="$ARCH_FLAGS -O3" -if [ -z "$NPROC" ]; then - NPROC="$(nproc)" -fi - # Normally a platform has a package manager # PS4 does not, atleast not in the normal sense export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@) diff --git a/.ci/ps4/make-toolchain.sh b/.ci/ps4/make-toolchain.sh new file mode 100644 index 0000000000..b7848f5ddb --- /dev/null +++ b/.ci/ps4/make-toolchain.sh @@ -0,0 +1,168 @@ +#!/usr/local/bin/bash -ex + +# Define global vars +# These flags are used everywhere, so let's reuse them. +export OO_PS4_TOOLCHAIN="$PWD/prefix" +export PREFIX="$OO_PS4_TOOLCHAIN" +export CC="clang" +export CXX="clang++" +export AR="llvm-ar" +export CFLAGS="-fPIC -DPS4 -D_LIBUNWIND_IS_BAREMETAL=1" +export CXXFLAGS="$CFLAGS -D__STDC_VERSION__=0" +export TARGET="x86_64-scei-ps4" +export LLVM_ROOT="$PWD/llvm-project" +export LLVM_PATH="$PWD/llvm-project/llvm" +export WORK_PATH="$PWD" + +prepare_prefix() { + [ -d OpenOrbis-PS4-Toolchain ] || git clone --depth=1 https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain + [ -d musl ] || git clone --depth=1 https://github.com/OpenOrbis/musl + [ -d llvm-project ] || git clone --depth=1 --branch openorbis/20.x https://github.com/seuros/llvm-project + [ -d create-fself ] || git clone --depth=1 https://github.com/OpenOrbis/create-fself + [ -d create-gp4 ] || git clone --depth=1 https://github.com/OpenOrbis/create-gp4 + [ -d readoelf ] || git clone --depth=1 https://github.com/OpenOrbis/readoelf + + mkdir -p $PREFIX "$PREFIX/bin" "$PREFIX/include" + [ -f "$PREFIX/include/orbis/libkernel.h" ] || cp -r OpenOrbis-PS4-Toolchain/include/* "$PREFIX/include/" + mkdir -p $PREFIX/usr + [ -L "$PREFIX/usr/include" ] || ln -s $PREFIX/include $PREFIX/usr/include || echo 1 + [ -L "$PREFIX/usr/share" ] || ln -s $PREFIX/share $PREFIX/usr/share || echo 1 + [ -L "$PREFIX/usr/lib" ] || ln -s $PREFIX/lib $PREFIX/usr/lib || echo 1 + [ -L "$PREFIX/usr/bin" ] || ln -s $PREFIX/bin $PREFIX/usr/bin || echo 1 +} + +build_musl() { + mkdir -p musl-build + cd musl-build + ../musl/configure --target=$TARGET --disable-shared CC="$CC" CFLAGS="$CFLAGS" --prefix=$PREFIX + gmake -j8 && gmake install + cd .. +} + +build_llvm() { + # Build compiler-rt + cmake "$LLVM_ROOT/compiler-rt" -B "$WORK_PATH/llvm-build/compiler-rt" \ + -DCMAKE_INSTALL_PREFIX="$PREFIX" \ + -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ + -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ + -DCMAKE_ASM_COMPILER="$CC" -DCMAKE_ASM_FLAGS="$CFLAGS -x assembler-with-cpp" \ + -DLLVM_PATH="$LLVM_PATH" -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE="$TARGET" \ + -DCOMPILER_RT_BAREMETAL_BUILD=YES -DCOMPILER_RT_BUILD_BUILTINS=ON \ + -DCOMPILER_RT_BUILD_CRT=OFF -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ + -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ + -DCOMPILER_RT_BUILD_PROFILE=OFF -DCOMPILER_RT_STANDALONE_BUILD=ON + # Build libunwind + cmake "$LLVM_ROOT/libunwind" -B "$WORK_PATH/llvm-build/libunwind" \ + -DCMAKE_INSTALL_PREFIX="$PREFIX" \ + -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ + -DCMAKE_C_FLAGS="$CFLAGS -fcxx-exceptions" -DCMAKE_CXX_FLAGS="$CXXFLAGS -fcxx-exceptions" \ + -DCMAKE_ASM_COMPILER="$CC" -DCMAKE_ASM_FLAGS="$CFLAGS -x assembler-with-cpp" \ + -DLLVM_PATH="$LLVM_PATH" -DLIBUNWIND_USE_COMPILER_RT=YES \ + -DLIBUNWIND_BUILD_32_BITS=NO -DLIBUNWIND_ENABLE_STATIC=ON \ + -DLIBUNWIND_ENABLE_SHARED=OFF -DLIBUNWIND_IS_BAREMETAL=ON + # Build libcxxabi + cmake "$LLVM_ROOT/libcxxabi" -B "$WORK_PATH/llvm-build/libcxxabi" \ + -DCMAKE_INSTALL_PREFIX="$PREFIX" \ + -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ + -DCMAKE_C_FLAGS="$CFLAGS -D_GNU_SOURCE=1 -isysroot $PREFIX -isystem $LLVM_ROOT/libcxx/include -isystem $PREFIX/include -isystem $WORK_PATH/llvm-build/libcxx/include/c++/v1" \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS -D_GNU_SOURCE=1 -isysroot $PREFIX -isystem $LLVM_ROOT/libcxx/include -isystem $PREFIX/include -isystem $WORK_PATH/llvm-build/libcxx/include/c++/v1" \ + -DCMAKE_ASM_COMPILER="$CC" -DCMAKE_ASM_FLAGS="$CFLAGS -x assembler-with-cpp" \ + -DLLVM_PATH="$LLVM_PATH" -DLIBCXXABI_ENABLE_SHARED=NO \ + -DLLVM_ENABLE_RUNTIMES="rt;libunwind" \ + -DLIBCXXABI_ENABLE_STATIC=YES -DLIBCXXABI_ENABLE_EXCEPTIONS=YES \ + -DLIBCXXABI_USE_COMPILER_RT=YES -DLIBCXXABI_USE_LLVM_UNWINDER=YES \ + -DLIBCXXABI_LIBUNWIND_PATH="$LLVM_ROOT/libunwind" \ + -DLIBCXXABI_LIBCXX_INCLUDES="$LLVM_ROOT/libcxx/include" \ + -DLIBCXXABI_ENABLE_PIC=YES + # Build libcxx + cmake "$LLVM_ROOT/libcxx" -B "$WORK_PATH/llvm-build/libcxx" \ + -DCMAKE_INSTALL_PREFIX="$PREFIX" \ + -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ + -DCMAKE_C_FLAGS="$CFLAGS -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 -isysroot $PREFIX -isystem $PREFIX/include/c++/v1 -isystem $PREFIX/include" \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 -isysroot $PREFIX -isystem $PREFIX/include/c++/v1 -isystem $PREFIX/include" \ + -DCMAKE_ASM_COMPILER="$CC" -DCMAKE_ASM_FLAGS="$CFLAGS -x assembler-with-cpp" \ + -DLLVM_PATH="$LLVM_PATH" -DLIBCXX_ENABLE_RTTI=YES \ + -DLIBCXX_HAS_MUSL_LIBC=YES -DLIBCXX_ENABLE_SHARED=NO \ + -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LLVM_ROOT/libcxxabi/include" \ + -DLIBCXX_CXX_ABI_LIBRARY_PATH="$LLVM_ROOT/libcxxabi/build/lib" + + cmake --build "$WORK_PATH/llvm-build/compiler-rt" --parallel + cmake --install "$WORK_PATH/llvm-build/compiler-rt" + + cmake --build "$WORK_PATH/llvm-build/libunwind" --parallel + cmake --install "$WORK_PATH/llvm-build/libunwind" + + cmake --build "$WORK_PATH/llvm-build/libcxxabi" --parallel + cmake --install "$WORK_PATH/llvm-build/libcxxabi" + + touch "$WORK_PATH/llvm-build/libcxx/include/c++/v1/libcxx.imp" + cmake --build "$WORK_PATH/llvm-build/libcxx" --parallel + cmake --install "$WORK_PATH/llvm-build/libcxx" +} + +build_tools() { + # Build create-fself + cd create-fself/cmd/create-fself + cp go-linux.mod go.mod + go build -o create-fself + mv ./create-fself $PREFIX/bin/create-fself + cd ../../../ + + # Build create-gp4 + cd create-gp4/cmd/create-gp4 + go build -o create-gp4 + mv ./create-gp4 $PREFIX/bin/create-gp4 + cd ../../../ + + # Build readoelf + cd readoelf/cmd/readoelf + go build -o readoelf + mv ./readoelf $PREFIX/bin/readoelf + cd ../../../ + + # Pull maxton's publishing tools (<3) + # Sadly maxton has passed on, we have forked the repository and will continue to update it in the future. RIP <3 + cd $PREFIX/bin + [ -f PkgTool.Core-linux-x64-0.2.231.zip ] || wget https://github.com/maxton/LibOrbisPkg/releases/download/v0.2/PkgTool.Core-linux-x64-0.2.231.zip + [ -f PkgTool.Core ] || unzip PkgTool.Core-linux-x64-0.2.231.zip + chmod +x PkgTool.Core +} + +finish_prefix() { + as $WORK_PATH/OpenOrbis-PS4-Toolchain/src/crt/crtlib.S -o $PREFIX/lib/crtlib.o + cp -a $WORK_PATH/OpenOrbis-PS4-Toolchain/link.x $PREFIX/ + + cp -a ~/OpenOrbis/PS4Toolchain/lib/libkernel* $PREFIX/lib/ + cp -a ~/OpenOrbis/PS4Toolchain/lib/libSce* $PREFIX/lib/ + + cp $WORK_PATH/llvm-build/compiler-rt/lib/freebsd/libclang_rt.builtins-x86_64.a $PREFIX/lib/ + + # Combine libc++, libc++abi and libunwind into a single archive + cat << EOF >"mri.txt" +CREATE $PREFIX/lib/libc++M.a +ADDLIB $PREFIX/lib/libunwind.a +ADDLIB $PREFIX/lib/libc++abi.a +ADDLIB $PREFIX/lib/libc++.a +SAVE +END +EOF + $AR -M < mri.txt + cp $PREFIX/lib/libc++M.a $PREFIX/lib/libc++.a + # Merge compiler-rt into libc + cat << EOF >"mri.txt" +CREATE $PREFIX/lib/libcM.a +ADDLIB $PREFIX/lib/libc.a +ADDLIB $PREFIX/lib/libclang_rt.builtins-x86_64.a +SAVE +END +EOF + $AR -M < mri.txt + cp $PREFIX/lib/libcM.a $PREFIX/lib/libc.a + rm mri.txt +} + +prepare_prefix +build_musl +build_llvm +build_tools +finish_prefix From ca6fa64c8ac9f3b272da86b83769c7e8a261ec14 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 02:32:31 +0000 Subject: [PATCH 006/108] exclude from vulkan surface selection --- .ci/ps4/make-toolchain.sh | 3 +++ src/video_core/vulkan_common/vulkan.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.ci/ps4/make-toolchain.sh b/.ci/ps4/make-toolchain.sh index b7848f5ddb..ca0f079d96 100644 --- a/.ci/ps4/make-toolchain.sh +++ b/.ci/ps4/make-toolchain.sh @@ -135,6 +135,9 @@ finish_prefix() { cp -a ~/OpenOrbis/PS4Toolchain/lib/libkernel* $PREFIX/lib/ cp -a ~/OpenOrbis/PS4Toolchain/lib/libSce* $PREFIX/lib/ + cp -a ~/OpenOrbis/PS4Toolchain/lib/libSDL* $PREFIX/lib/ + cp -r ~/OpenOrbis/PS4Toolchain/include/SDL2 $PREFIX/include/SDL2 + cp $WORK_PATH/llvm-build/compiler-rt/lib/freebsd/libclang_rt.builtins-x86_64.a $PREFIX/lib/ # Combine libc++, libc++abi and libunwind into a single archive diff --git a/src/video_core/vulkan_common/vulkan.h b/src/video_core/vulkan_common/vulkan.h index 2609e8dc0f..cd35fbc6ea 100644 --- a/src/video_core/vulkan_common/vulkan.h +++ b/src/video_core/vulkan_common/vulkan.h @@ -15,6 +15,8 @@ #define VK_USE_PLATFORM_ANDROID_KHR #elif defined(__HAIKU__) #define VK_USE_PLATFORM_XCB_KHR +#elif defined(__OPENORBIS__) +// No fucking vulkan on the PlayStation 4 #else #define VK_USE_PLATFORM_XLIB_KHR #define VK_USE_PLATFORM_WAYLAND_KHR From e7ecea2ac416c70fca1b1406c2d6018384849dee Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 02:51:57 +0000 Subject: [PATCH 007/108] exclude more stuff from vulkan --- src/video_core/vulkan_common/vulkan_instance.cpp | 2 ++ src/video_core/vulkan_common/vulkan_surface.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/video_core/vulkan_common/vulkan_instance.cpp b/src/video_core/vulkan_common/vulkan_instance.cpp index 398342296e..a810268c7f 100644 --- a/src/video_core/vulkan_common/vulkan_instance.cpp +++ b/src/video_core/vulkan_common/vulkan_instance.cpp @@ -59,6 +59,8 @@ namespace { case Core::Frontend::WindowSystemType::Xcb: extensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); break; +#elif defined(__OPENORBIS__) + // No vulkan #else case Core::Frontend::WindowSystemType::X11: extensions.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); diff --git a/src/video_core/vulkan_common/vulkan_surface.cpp b/src/video_core/vulkan_common/vulkan_surface.cpp index 8b9dcb4d42..7aea55fdca 100644 --- a/src/video_core/vulkan_common/vulkan_surface.cpp +++ b/src/video_core/vulkan_common/vulkan_surface.cpp @@ -76,6 +76,8 @@ vk::SurfaceKHR CreateSurface( throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED); } } +#elif defined(__OPENORBIS__) + // No native #else if (window_info.type == Core::Frontend::WindowSystemType::X11) { const VkXlibSurfaceCreateInfoKHR xlib_ci{ From 25f0c1748556407147db3681662e816c29a2a2e4 Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 5 Dec 2025 03:50:45 +0000 Subject: [PATCH 008/108] make .pkg and .self --- CMakeLists.txt | 1 + CMakeModules/OpenOrbis.cmake | 42 ++++++++++++++++++++++++++++++++++++ src/yuzu_cmd/CMakeLists.txt | 7 ++++++ src/yuzu_cmd/yuzu.cpp | 10 +++++++++ 4 files changed, 60 insertions(+) create mode 100644 CMakeModules/OpenOrbis.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f84dd539c..a86ac82818 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ include(UseCcache) include(CMakeDependentOption) include(CTest) include(CPMUtil) +include(OpenOrbis) if (NOT DEFINED ARCHITECTURE) message(FATAL_ERROR "Architecture didn't make it out of scope, did you delete DetectArchitecture.cmake?") diff --git a/CMakeModules/OpenOrbis.cmake b/CMakeModules/OpenOrbis.cmake new file mode 100644 index 0000000000..7b7b0c005c --- /dev/null +++ b/CMakeModules/OpenOrbis.cmake @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + +function(add_fself project target) + add_custom_command( + OUTPUT "${target}.self" + COMMAND ${CMAKE_SYSROOT}/bin/create-fself + -in=${CMAKE_BINARY_DIR}/bin/${target} + -out=${CMAKE_BINARY_DIR}/bin/${target}.oelf + --eboot ${CMAKE_BINARY_DIR}/bin/eboot.bin + VERBATIM + DEPENDS "${project}" + ) + add_custom_target("${project}_self" ALL DEPENDS "${target}.self") +endfunction() + +function(add_pkg project target) + set(sce_sys_dir ${CMAKE_BINARY_DIR}/sce_sys) + set(sce_sys_param ${sce_sys_dir}/param.sfo) + add_custom_command( + OUTPUT "${target}.pkg" + COMMAND mkdir -p ${sce_sys_dir} + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_new ${sce_sys_param} + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} APP_TYPE --type Integer --maxsize 4 --value 1 + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} APP_VER --type Utf8 --maxsize 8 --value '1.03' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} ATTRIBUTE --type Integer --maxsize 4 --value 0 + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CATEGORY --type Utf8 --maxsize 4 --value 'gd' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CONTENT_ID --type Utf8 --maxsize 48 --value 'IV0000-BREW00090_00-EDENEMULAT000000' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} DOWNLOAD_DATA_SIZE --type Integer --maxsize 4 --value 0 + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} SYSTEM_VER --type Integer --maxsize 4 --value 0 + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE --type Utf8 --maxsize 128 --value 'Eden Emulator' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE_ID --type Utf8 --maxsize 12 --value 'BREW00090' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} VERSION --type Utf8 --maxsize 8 --value '1.03' + VERBATIM + DEPENDS "${target}.self" + ) + add_custom_target("${project}_pkg" ALL DEPENDS "${target}.pkg") +endfunction() + +if (NOT DEFINED ENV{OO_PS4_TOOLCHAIN}) + set(ENV{OO_PS4_TOOLCHAIN} ${CMAKE_SYSROOT}) +endif () diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index 09a9bd6da1..c267ccc644 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -44,6 +44,8 @@ if (ENABLE_OPENGL) endif() if (MSVC) target_link_libraries(yuzu-cmd PRIVATE getopt) +elseif(PLATFORM_PS4) + target_link_libraries(yuzu-cmd PRIVATE SceVideoOut SceAudioOut ScePad) endif() target_link_libraries(yuzu-cmd PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) @@ -75,3 +77,8 @@ if (NOT MSVC) $<$:-Wno-unused-parameter> $<$:-Wno-missing-field-initializers>) endif() + +if (PLATFORM_PS4) + add_fself(yuzu-cmd eden-cli) + add_pkg(yuzu-cmd eden-cli) +endif() diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index d20c126159..fafe61a5e4 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -52,6 +52,16 @@ #include #endif +#ifdef __OPENORBIS__ +# define STUB_WEAK(name) extern "C" void name() { printf("called " #name); asm volatile("ud2"); } +STUB_WEAK(__cxa_thread_atexit) +STUB_WEAK(__assert) +STUB_WEAK(ZSTD_trace_compress_begin) +STUB_WEAK(ZSTD_trace_compress_end) +STUB_WEAK(ZSTD_trace_decompress_begin) +STUB_WEAK(ZSTD_trace_decompress_end) +# undef STUB_WEAK +#endif #ifdef _WIN32 extern "C" { // tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable From 5af0401a1805caff385b516f56a36b45e10e0593 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 05:08:23 +0000 Subject: [PATCH 009/108] fself + pkg stuffs --- CMakeModules/OpenOrbis.cmake | 25 ++++++++++++++----------- src/yuzu_cmd/CMakeLists.txt | 4 ++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CMakeModules/OpenOrbis.cmake b/CMakeModules/OpenOrbis.cmake index 7b7b0c005c..2ee8cb4942 100644 --- a/CMakeModules/OpenOrbis.cmake +++ b/CMakeModules/OpenOrbis.cmake @@ -1,9 +1,9 @@ # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later -function(add_fself project target) +function(create_ps4_fself project target) add_custom_command( - OUTPUT "${target}.self" + OUTPUT "${CMAKE_BINARY_DIR}/${target}.self" COMMAND ${CMAKE_SYSROOT}/bin/create-fself -in=${CMAKE_BINARY_DIR}/bin/${target} -out=${CMAKE_BINARY_DIR}/bin/${target}.oelf @@ -11,30 +11,33 @@ function(add_fself project target) VERBATIM DEPENDS "${project}" ) - add_custom_target("${project}_self" ALL DEPENDS "${target}.self") + add_custom_target("${project}_self" ALL DEPENDS ${project}) endfunction() -function(add_pkg project target) - set(sce_sys_dir ${CMAKE_BINARY_DIR}/sce_sys) +function(create_ps4_pkg project target content_id) + set(sce_sys_dir ./sce_sys) set(sce_sys_param ${sce_sys_dir}/param.sfo) add_custom_command( - OUTPUT "${target}.pkg" + OUTPUT "${CMAKE_BINARY_DIR}/${target}.pkg" COMMAND mkdir -p ${sce_sys_dir} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_new ${sce_sys_param} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} APP_TYPE --type Integer --maxsize 4 --value 1 COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} APP_VER --type Utf8 --maxsize 8 --value '1.03' COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} ATTRIBUTE --type Integer --maxsize 4 --value 0 - COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CATEGORY --type Utf8 --maxsize 4 --value 'gd' - COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CONTENT_ID --type Utf8 --maxsize 48 --value 'IV0000-BREW00090_00-EDENEMULAT000000' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CATEGORY --type Utf8 --maxsize 4 --value 'E' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CONTENT_ID --type Utf8 --maxsize 48 --value '${content_id}' COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} DOWNLOAD_DATA_SIZE --type Integer --maxsize 4 --value 0 COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} SYSTEM_VER --type Integer --maxsize 4 --value 0 - COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE --type Utf8 --maxsize 128 --value 'Eden Emulator' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE --type Utf8 --maxsize 128 --value ${target} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE_ID --type Utf8 --maxsize 12 --value 'BREW00090' COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} VERSION --type Utf8 --maxsize 8 --value '1.03' + COMMAND ${CMAKE_SYSROOT}/bin/create-gp4 -out ${target}.gp4 --content-id='${content_id}' --files "bin/eboot.bin ${sce_sys_param}" + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core pkg_build ${CMAKE_BINARY_DIR}/${target}.gp4 . VERBATIM - DEPENDS "${target}.self" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + DEPENDS ${project}_self ) - add_custom_target("${project}_pkg" ALL DEPENDS "${target}.pkg") + add_custom_target(${project}_pkg ALL DEPENDS "${CMAKE_BINARY_DIR}/${target}.pkg") endfunction() if (NOT DEFINED ENV{OO_PS4_TOOLCHAIN}) diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index c267ccc644..509aaaa392 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -79,6 +79,6 @@ if (NOT MSVC) endif() if (PLATFORM_PS4) - add_fself(yuzu-cmd eden-cli) - add_pkg(yuzu-cmd eden-cli) + create_ps4_fself(yuzu-cmd eden-cli) + create_ps4_pkg(yuzu-cmd eden-cli "IV0000-BREW00090_00-EDENEMULAT000000") endif() From db35effd3afcba5e312c34c9366d2204d2b0b36b Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 05:32:35 +0000 Subject: [PATCH 010/108] the orb --- .ci/ps4/make-toolchain.sh | 20 +++++++++++--------- CMakeModules/OpenOrbis.cmake | 36 ++++++++++++------------------------ src/yuzu_cmd/CMakeLists.txt | 3 +-- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/.ci/ps4/make-toolchain.sh b/.ci/ps4/make-toolchain.sh index ca0f079d96..727596ae36 100644 --- a/.ci/ps4/make-toolchain.sh +++ b/.ci/ps4/make-toolchain.sh @@ -21,6 +21,7 @@ prepare_prefix() { [ -d create-fself ] || git clone --depth=1 https://github.com/OpenOrbis/create-fself [ -d create-gp4 ] || git clone --depth=1 https://github.com/OpenOrbis/create-gp4 [ -d readoelf ] || git clone --depth=1 https://github.com/OpenOrbis/readoelf + [ -d LibOrbisPkg ] || git clone --depth=1 https://github.com/maxton/LibOrbisPkg mkdir -p $PREFIX "$PREFIX/bin" "$PREFIX/include" [ -f "$PREFIX/include/orbis/libkernel.h" ] || cp -r OpenOrbis-PS4-Toolchain/include/* "$PREFIX/include/" @@ -101,31 +102,32 @@ build_llvm() { } build_tools() { + # Build create-fself cd create-fself/cmd/create-fself cp go-linux.mod go.mod - go build -o create-fself + go build -ldflags "-linkmode external -extldflags -static" -o create-fself mv ./create-fself $PREFIX/bin/create-fself cd ../../../ # Build create-gp4 cd create-gp4/cmd/create-gp4 - go build -o create-gp4 + go build -ldflags "-linkmode external -extldflags -static" -o create-gp4 mv ./create-gp4 $PREFIX/bin/create-gp4 cd ../../../ # Build readoelf cd readoelf/cmd/readoelf - go build -o readoelf + go build -ldflags "-linkmode external -extldflags -static" -o readoelf mv ./readoelf $PREFIX/bin/readoelf cd ../../../ - # Pull maxton's publishing tools (<3) - # Sadly maxton has passed on, we have forked the repository and will continue to update it in the future. RIP <3 - cd $PREFIX/bin - [ -f PkgTool.Core-linux-x64-0.2.231.zip ] || wget https://github.com/maxton/LibOrbisPkg/releases/download/v0.2/PkgTool.Core-linux-x64-0.2.231.zip - [ -f PkgTool.Core ] || unzip PkgTool.Core-linux-x64-0.2.231.zip - chmod +x PkgTool.Core + # # Pull maxton's publishing tools (<3) + # # Sadly maxton has passed on, we have forked the repository and will continue to update it in the future. RIP <3 + # cd $PREFIX/bin + # [ -f PkgTool.Core-linux-x64-0.2.231.zip ] || wget https://github.com/maxton/LibOrbisPkg/releases/download/v0.2/PkgTool.Core-linux-x64-0.2.231.zip + # [ -f PkgTool.Core ] || unzip PkgTool.Core-linux-x64-0.2.231.zip + # chmod +x PkgTool.Core } finish_prefix() { diff --git a/CMakeModules/OpenOrbis.cmake b/CMakeModules/OpenOrbis.cmake index 2ee8cb4942..4e76731f6a 100644 --- a/CMakeModules/OpenOrbis.cmake +++ b/CMakeModules/OpenOrbis.cmake @@ -1,43 +1,31 @@ # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later -function(create_ps4_fself project target) - add_custom_command( - OUTPUT "${CMAKE_BINARY_DIR}/${target}.self" - COMMAND ${CMAKE_SYSROOT}/bin/create-fself - -in=${CMAKE_BINARY_DIR}/bin/${target} - -out=${CMAKE_BINARY_DIR}/bin/${target}.oelf - --eboot ${CMAKE_BINARY_DIR}/bin/eboot.bin - VERBATIM - DEPENDS "${project}" - ) - add_custom_target("${project}_self" ALL DEPENDS ${project}) -endfunction() - function(create_ps4_pkg project target content_id) - set(sce_sys_dir ./sce_sys) + set(sce_sys_dir sce_sys) set(sce_sys_param ${sce_sys_dir}/param.sfo) add_custom_command( - OUTPUT "${CMAKE_BINARY_DIR}/${target}.pkg" + OUTPUT "${target}.pkg" + COMMAND ${CMAKE_SYSROOT}/bin/create-fself -in=bin/${target} -out=${target}.oelf --eboot eboot.bin COMMAND mkdir -p ${sce_sys_dir} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_new ${sce_sys_param} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} APP_TYPE --type Integer --maxsize 4 --value 1 - COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} APP_VER --type Utf8 --maxsize 8 --value '1.03' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} APP_VER --type Utf8 --maxsize 8 --value 1.03 COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} ATTRIBUTE --type Integer --maxsize 4 --value 0 - COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CATEGORY --type Utf8 --maxsize 4 --value 'E' - COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CONTENT_ID --type Utf8 --maxsize 48 --value '${content_id}' + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CATEGORY --type Utf8 --maxsize 4 --value gd + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} CONTENT_ID --type Utf8 --maxsize 48 --value ${content_id} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} DOWNLOAD_DATA_SIZE --type Integer --maxsize 4 --value 0 COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} SYSTEM_VER --type Integer --maxsize 4 --value 0 COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE --type Utf8 --maxsize 128 --value ${target} - COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE_ID --type Utf8 --maxsize 12 --value 'BREW00090' - COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} VERSION --type Utf8 --maxsize 8 --value '1.03' - COMMAND ${CMAKE_SYSROOT}/bin/create-gp4 -out ${target}.gp4 --content-id='${content_id}' --files "bin/eboot.bin ${sce_sys_param}" - COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core pkg_build ${CMAKE_BINARY_DIR}/${target}.gp4 . + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE_ID --type Utf8 --maxsize 12 --value BREW00090 + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} VERSION --type Utf8 --maxsize 8 --value 1.03 + COMMAND ${CMAKE_SYSROOT}/bin/create-gp4 -out ${target}.gp4 --content-id=${content_id} --files "eboot.bin ${sce_sys_param}" + COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core pkg_build ${target}.gp4 . VERBATIM WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - DEPENDS ${project}_self + DEPENDS ${project} ) - add_custom_target(${project}_pkg ALL DEPENDS "${CMAKE_BINARY_DIR}/${target}.pkg") + add_custom_target(${project}_pkg ALL DEPENDS "${target}.pkg") endfunction() if (NOT DEFINED ENV{OO_PS4_TOOLCHAIN}) diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index 509aaaa392..86293c18a9 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -79,6 +79,5 @@ if (NOT MSVC) endif() if (PLATFORM_PS4) - create_ps4_fself(yuzu-cmd eden-cli) - create_ps4_pkg(yuzu-cmd eden-cli "IV0000-BREW00090_00-EDENEMULAT000000") + create_ps4_pkg(yuzu-cmd eden-cli IV0000-BREW00090_00-EDENEMULAT000000) endif() From e4a66934242b38b8dd8bb114460e5ea3860008b0 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 09:33:59 +0000 Subject: [PATCH 011/108] sysconf stub cuz crash(?) + some stderrp stuff --- .ci/ps4/build.sh | 14 +- CMakeModules/FindSDL2.cmake | 388 ++++++++++++++++++ docs/user/Basics.md | 1 + src/common/fs/path_util.cpp | 4 + src/common/host_memory.cpp | 7 +- src/common/memory_detect.cpp | 4 +- src/input_common/drivers/joycon.cpp | 13 +- src/input_common/drivers/sdl_driver.cpp | 10 + src/input_common/helpers/joycon_driver.cpp | 35 +- .../joycon_protocol/common_protocol.cpp | 52 ++- src/yuzu_cmd/yuzu.cpp | 1 + 11 files changed, 474 insertions(+), 55 deletions(-) create mode 100644 CMakeModules/FindSDL2.cmake diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 0dda2e9c9a..0bffdca680 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -3,8 +3,6 @@ # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later -OO_PS4_TOOLCHAIN="/home/xerix/src/ps4-sdk/prefix" - [ -f "ps4-toolchain.cmake" ] || cat << EOF >"ps4-toolchain.cmake" set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN") set(CMAKE_STAGING_PREFIX "$OO_PS4_TOOLCHAIN") @@ -20,8 +18,8 @@ set(CMAKE_CXX_LINK_FLAGS "-m elf_x86_64 -pie -T $OO_PS4_TOOLCHAIN/link.x --eh-fr set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) set(CMAKE_LINKER ld.lld) -set(CMAKE_C_LINK_EXECUTABLE " -o -lc -lkernel -lSceUserService -lSceSysmodule -lSceNet -lSceLibcInternal $OO_PS4_TOOLCHAIN/lib/crt1.o ") -set(CMAKE_CXX_LINK_EXECUTABLE " -o -lc -lkernel -lc++ -lSceUserService -lSceSysmodule -lSceNet -lSceLibcInternal $OO_PS4_TOOLCHAIN/lib/crt1.o ") +set(CMAKE_C_LINK_EXECUTABLE " -o -lc -lkernel -lSceUserService -lSceSysmodule -lSceNet $OO_PS4_TOOLCHAIN/lib/crt1.o ") +set(CMAKE_CXX_LINK_EXECUTABLE " -o -lc -lkernel -lc++ -lSceUserService -lSceSysmodule -lSceNet $OO_PS4_TOOLCHAIN/lib/crt1.o ") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) @@ -35,14 +33,16 @@ EOF # Normally a platform has a package manager # PS4 does not, atleast not in the normal sense export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@) -cmake -S . -B build -G Ninja \ +cmake -S . -B build -G "Unix Makefiles" \ -DCMAKE_TOOLCHAIN_FILE="ps4-toolchain.cmake" \ -DENABLE_QT_TRANSLATION=OFF \ -DENABLE_CUBEB=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_FLAGS="$ARCH_FLAGS" \ -DCMAKE_C_FLAGS="$ARCH_FLAGS" \ - -DENABLE_SDL2=OFF \ + -DENABLE_SDL2=ON \ + -DENABLE_LIBUSB=OFF \ + -DENABLE_UPDATE_CHECKER=OFF \ -DENABLE_QT=OFF \ -DENABLE_OPENSSL=OFF \ -DENABLE_WEB_SERVICE=OFF \ @@ -51,4 +51,4 @@ cmake -S . -B build -G Ninja \ -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit -cmake --build build --parallel +cmake --build build -t yuzu-cmd_pkg -- -j8 diff --git a/CMakeModules/FindSDL2.cmake b/CMakeModules/FindSDL2.cmake new file mode 100644 index 0000000000..2445d36ec5 --- /dev/null +++ b/CMakeModules/FindSDL2.cmake @@ -0,0 +1,388 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Copyright 2019 Amine Ben Hassouna +# Copyright 2000-2019 Kitware, Inc. and Contributors +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: + +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. + +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. + +# * Neither the name of Kitware, Inc. nor the names of Contributors +# may be used to endorse or promote products derived from this +# software without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#[=======================================================================[.rst: +FindSDL2 +-------- + +Locate SDL2 library + +This module defines the following 'IMPORTED' targets: + +:: + + SDL2::Core + The SDL2 library, if found. + Libraries should link to SDL2::Core + + SDL2::Main + The SDL2main library, if found. + Applications should link to SDL2::Main instead of SDL2::Core + + + +This module will set the following variables in your project: + +:: + + SDL2_LIBRARIES, the name of the library to link against + SDL2_INCLUDE_DIRS, where to find SDL.h + SDL2_FOUND, if false, do not try to link to SDL2 + SDL2MAIN_FOUND, if false, do not try to link to SDL2main + SDL2_VERSION_STRING, human-readable string containing the version of SDL2 + + + +This module responds to the following cache variables: + +:: + + SDL2_PATH + Set a custom SDL2 Library path (default: empty) + + SDL2_NO_DEFAULT_PATH + Disable search SDL2 Library in default path. + If SDL2_PATH (default: ON) + Else (default: OFF) + + SDL2_INCLUDE_DIR + SDL2 headers path. + + SDL2_LIBRARY + SDL2 Library (.dll, .so, .a, etc) path. + + SDL2MAIN_LIBRAY + SDL2main Library (.a) path. + + SDL2_BUILDING_LIBRARY + This flag is useful only when linking to SDL2_LIBRARIES insead of + SDL2::Main. It is required only when building a library that links to + SDL2_LIBRARIES, because only applications need main() (No need to also + link to SDL2main). + If this flag is defined, then no SDL2main will be added to SDL2_LIBRARIES + and no SDL2::Main target will be created. + + +Don't forget to include SDLmain.h and SDLmain.m in your project for the +OS X framework based version. (Other versions link to -lSDL2main which +this module will try to find on your behalf.) Also for OS X, this +module will automatically add the -framework Cocoa on your behalf. + + +Additional Note: If you see an empty SDL2_LIBRARY in your project +configuration, it means CMake did not find your SDL2 library +(SDL2.dll, libsdl2.so, SDL2.framework, etc). Set SDL2_LIBRARY to point +to your SDL2 library, and configure again. Similarly, if you see an +empty SDL2MAIN_LIBRARY, you should set this value as appropriate. These +values are used to generate the final SDL2_LIBRARIES variable and the +SDL2::Core and SDL2::Main targets, but when these values are unset, +SDL2_LIBRARIES, SDL2::Core and SDL2::Main does not get created. + + +$SDL2DIR is an environment variable that would correspond to the +./configure --prefix=$SDL2DIR used in building SDL2. l.e.galup 9-20-02 + + + +Created by Amine Ben Hassouna: + Adapt FindSDL.cmake to SDL2 (FindSDL2.cmake). + Add cache variables for more flexibility: + SDL2_PATH, SDL2_NO_DEFAULT_PATH (for details, see doc above). + Mark 'Threads' as a required dependency for non-OSX systems. + Modernize the FindSDL2.cmake module by creating specific targets: + SDL2::Core and SDL2::Main (for details, see doc above). + + +Original FindSDL.cmake module: + Modified by Eric Wing. Added code to assist with automated building + by using environmental variables and providing a more + controlled/consistent search behavior. Added new modifications to + recognize OS X frameworks and additional Unix paths (FreeBSD, etc). + Also corrected the header search path to follow "proper" SDL + guidelines. Added a search for SDLmain which is needed by some + platforms. Added a search for threads which is needed by some + platforms. Added needed compile switches for MinGW. + +On OSX, this will prefer the Framework version (if found) over others. +People will have to manually change the cache value of SDL2_LIBRARY to +override this selection or set the SDL2_PATH variable or the CMake +environment CMAKE_INCLUDE_PATH to modify the search paths. + +Note that the header path has changed from SDL/SDL.h to just SDL.h +This needed to change because "proper" SDL convention is #include +"SDL.h", not . This is done for portability reasons +because not all systems place things in SDL/ (see FreeBSD). +#]=======================================================================] + +# Define options for searching SDL2 Library in a custom path + +set(SDL2_PATH "" CACHE STRING "Custom SDL2 Library path") + +set(_SDL2_NO_DEFAULT_PATH OFF) +if(SDL2_PATH) + set(_SDL2_NO_DEFAULT_PATH ON) +endif() + +set(SDL2_NO_DEFAULT_PATH ${_SDL2_NO_DEFAULT_PATH} + CACHE BOOL "Disable search SDL2 Library in default path") +unset(_SDL2_NO_DEFAULT_PATH) + +set(SDL2_NO_DEFAULT_PATH_CMD) +if(SDL2_NO_DEFAULT_PATH) + set(SDL2_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH) +endif() + +# Search for the SDL2 include directory +find_path(SDL2_INCLUDE_DIR SDL.h + HINTS + ENV SDL2DIR + ${SDL2_NO_DEFAULT_PATH_CMD} + PATH_SUFFIXES SDL2 + # path suffixes to search inside ENV{SDL2DIR} + include/SDL2 include + PATHS ${SDL2_PATH} + DOC "Where the SDL2 headers can be found" +) + +set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR}") + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + +# SDL-2.0 is the name used by FreeBSD ports... +# don't confuse it for the version number. +find_library(SDL2_LIBRARY + NAMES SDL2 SDL-2.0 + HINTS + ENV SDL2DIR + ${SDL2_NO_DEFAULT_PATH_CMD} + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} + PATHS ${SDL2_PATH} + DOC "Where the SDL2 Library can be found" +) + +set(SDL2_LIBRARIES "${SDL2_LIBRARY}") + +if(NOT SDL2_BUILDING_LIBRARY) + if(NOT SDL2_INCLUDE_DIR MATCHES ".framework") + # Non-OS X framework versions expect you to also dynamically link to + # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms + # seem to provide SDL2main for compatibility even though they don't + # necessarily need it. + + if(SDL2_PATH) + set(SDL2MAIN_LIBRARY_PATHS "${SDL2_PATH}") + endif() + + if(NOT SDL2_NO_DEFAULT_PATH) + set(SDL2MAIN_LIBRARY_PATHS + /sw + /opt/local + /opt/csw + /opt + "${SDL2MAIN_LIBRARY_PATHS}" + ) + endif() + + find_library(SDL2MAIN_LIBRARY + NAMES SDL2main + HINTS + ENV SDL2DIR + ${SDL2_NO_DEFAULT_PATH_CMD} + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} + PATHS ${SDL2MAIN_LIBRARY_PATHS} + DOC "Where the SDL2main library can be found" + ) + unset(SDL2MAIN_LIBRARY_PATHS) + endif() +endif() + +# SDL2 may require threads on your system. +# The Apple build may not need an explicit flag because one of the +# frameworks may already provide it. +# But for non-OSX systems, I will use the CMake Threads package. +if(NOT APPLE) + find_package(Threads QUIET) + if(NOT Threads_FOUND) + set(SDL2_THREADS_NOT_FOUND "Could NOT find Threads (Threads is required by SDL2).") + if(SDL2_FIND_REQUIRED) + message(FATAL_ERROR ${SDL2_THREADS_NOT_FOUND}) + else() + if(NOT SDL2_FIND_QUIETLY) + message(STATUS ${SDL2_THREADS_NOT_FOUND}) + endif() + return() + endif() + unset(SDL2_THREADS_NOT_FOUND) + endif() +endif() + +# MinGW needs an additional link flag, -mwindows +# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows +if(MINGW) + set(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "link flags for MinGW") +endif() + +if(SDL2_LIBRARY) + # For SDL2main + if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY) + list(FIND SDL2_LIBRARIES "${SDL2MAIN_LIBRARY}" _SDL2_MAIN_INDEX) + if(_SDL2_MAIN_INDEX EQUAL -1) + set(SDL2_LIBRARIES "${SDL2MAIN_LIBRARY}" ${SDL2_LIBRARIES}) + endif() + unset(_SDL2_MAIN_INDEX) + endif() + + # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. + # CMake doesn't display the -framework Cocoa string in the UI even + # though it actually is there if I modify a pre-used variable. + # I think it has something to do with the CACHE STRING. + # So I use a temporary variable until the end so I can set the + # "real" variable in one-shot. + if(APPLE) + set(SDL2_LIBRARIES ${SDL2_LIBRARIES} -framework Cocoa) + endif() + + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + if(NOT APPLE) + set(SDL2_LIBRARIES ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + endif() + + # For MinGW library + if(MINGW) + set(SDL2_LIBRARIES ${MINGW32_LIBRARY} ${SDL2_LIBRARIES}) + endif() + +endif() + +# Read SDL2 version +if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h") + file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}") + set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH}) + unset(SDL2_VERSION_MAJOR_LINE) + unset(SDL2_VERSION_MINOR_LINE) + unset(SDL2_VERSION_PATCH_LINE) + unset(SDL2_VERSION_MAJOR) + unset(SDL2_VERSION_MINOR) + unset(SDL2_VERSION_PATCH) +endif() + +include(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 + REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR + VERSION_VAR SDL2_VERSION_STRING) + +if(SDL2MAIN_LIBRARY) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2main + REQUIRED_VARS SDL2MAIN_LIBRARY SDL2_INCLUDE_DIR + VERSION_VAR SDL2_VERSION_STRING) +endif() + + +mark_as_advanced(SDL2_PATH + SDL2_NO_DEFAULT_PATH + SDL2_LIBRARY + SDL2MAIN_LIBRARY + SDL2_INCLUDE_DIR + SDL2_BUILDING_LIBRARY) + + +# SDL2:: targets (SDL2::Core and SDL2::Main) +if(SDL2_FOUND) + + # SDL2::Core target + if(SDL2_LIBRARY AND NOT TARGET SDL2::Core) + add_library(SDL2::Core UNKNOWN IMPORTED) + set_target_properties(SDL2::Core PROPERTIES + IMPORTED_LOCATION "${SDL2_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}") + + if(APPLE) + # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. + # For more details, please see above. + set_property(TARGET SDL2::Core APPEND PROPERTY + INTERFACE_LINK_OPTIONS -framework Cocoa) + else() + # For threads, as mentioned Apple doesn't need this. + # For more details, please see above. + set_property(TARGET SDL2::Core APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Threads::Threads) + endif() + endif() + + # SDL2::Main target + # Applications should link to SDL2::Main instead of SDL2::Core + # For more details, please see above. + if(NOT SDL2_BUILDING_LIBRARY AND NOT TARGET SDL2::Main) + + if(SDL2_INCLUDE_DIR MATCHES ".framework" OR NOT SDL2MAIN_LIBRARY) + add_library(SDL2::Main INTERFACE IMPORTED) + set_property(TARGET SDL2::Main PROPERTY + INTERFACE_LINK_LIBRARIES SDL2::Core) + elseif(SDL2MAIN_LIBRARY) + # MinGW requires that the mingw32 library is specified before the + # libSDL2main.a static library when linking. + # The SDL2::MainInternal target is used internally to make sure that + # CMake respects this condition. + add_library(SDL2::MainInternal UNKNOWN IMPORTED) + set_property(TARGET SDL2::MainInternal PROPERTY + IMPORTED_LOCATION "${SDL2MAIN_LIBRARY}") + set_property(TARGET SDL2::MainInternal PROPERTY + INTERFACE_LINK_LIBRARIES SDL2::Core) + + add_library(SDL2::Main INTERFACE IMPORTED) + + if(MINGW) + # MinGW needs an additional link flag '-mwindows' and link to mingw32 + set_property(TARGET SDL2::Main PROPERTY + INTERFACE_LINK_LIBRARIES "mingw32" "-mwindows") + endif() + + set_property(TARGET SDL2::Main APPEND PROPERTY + INTERFACE_LINK_LIBRARIES SDL2::MainInternal) + endif() + + endif() +endif() diff --git a/docs/user/Basics.md b/docs/user/Basics.md index 794a0935d5..ce485e91bb 100644 --- a/docs/user/Basics.md +++ b/docs/user/Basics.md @@ -35,6 +35,7 @@ Eden will store configuration files in the following directories: - **Android**: Data is stored internally. - **Linux, macOS, FreeBSD, Solaris, OpenBSD**: `$XDG_DATA_HOME`, `$XDG_CACHE_HOME`, `$XDG_CONFIG_HOME`. - **HaikuOS**: `/boot/home/config/settings/eden` +- **PlayStation 4**: `/data/eden` If a `user` directory is present in the current working directory, that will override all global configuration directories and the emulator will use that instead. diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index 714e393293..3cbe6371a4 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp @@ -130,6 +130,10 @@ public: ASSERT(!eden_path.empty()); eden_path_cache = eden_path / CACHE_DIR; eden_path_config = eden_path / CONFIG_DIR; +#elif defined(__OPENORBIS__) + eden_path = "/data/eden"; + eden_path_cache = eden_path / CACHE_DIR; + eden_path_config = eden_path / CONFIG_DIR; #else eden_path = GetCurrentDir() / PORTABLE_DIR; if (!Exists(eden_path) || !IsDir(eden_path)) { diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 04f3a65778..1787cd0408 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -497,9 +497,12 @@ class HostMemory::Impl { public: explicit Impl(size_t backing_size_, size_t virtual_size_) : backing_size{backing_size_}, virtual_size{virtual_size_} { +#ifdef __OPENORBIS__ + +#else long page_size = sysconf(_SC_PAGESIZE); - ASSERT_MSG(page_size == 0x1000, "page size {:#x} is incompatible with 4K paging", - page_size); + ASSERT_MSG(page_size == 0x1000, "page size {:#x} is incompatible with 4K paging", page_size); +#endif // Backing memory initialization #if defined(__sun__) || defined(__HAIKU__) || defined(__NetBSD__) || defined(__DragonFly__) fd = shm_open_anon(O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600); diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp index 074c02a9c3..8bd544e3e2 100644 --- a/src/common/memory_detect.cpp +++ b/src/common/memory_detect.cpp @@ -43,7 +43,9 @@ static MemoryInfo Detect() { sysctlbyname("vm.swapusage", &vmusage, &sizeof_vmusage, nullptr, 0); mem_info.TotalPhysicalMemory = ramsize; mem_info.TotalSwapMemory = vmusage.xsu_total; -#elif defined(__FreeBSD__) && !defined(__OPENORBIS__) +#elif defined(__OPENORBIS__) + mem_info.TotalPhysicalMemory = mem_info.TotalSwapMemory = 0; +#elif defined(__FreeBSD__) u_long physmem, swap_total; std::size_t sizeof_u_long = sizeof(u_long); // sysctlbyname(const char *, void *, size_t *, const void *, size_t); diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index fb2d75e384..83a57f96a7 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -23,12 +23,14 @@ Joycons::Joycons(const std::string& input_engine_) : InputEngine(input_engine_) return; } LOG_INFO(Input, "Joycon driver Initialization started"); - const int init_res = SDL_hid_init(); - if (init_res == 0) { +#if SDL_VERSION_ATLEAST(2, 26, 4) + int const res = SDL_hid_init(); + if (res == 0) { Setup(); } else { - LOG_ERROR(Input, "Hidapi could not be initialized. failed with error = {}", init_res); + LOG_ERROR(Input, "Hidapi could not be initialized. failed with error = {}", res); } +#endif } Joycons::~Joycons() { @@ -55,7 +57,9 @@ void Joycons::Reset() { } device->Stop(); } +#if SDL_VERSION_ATLEAST(2, 26, 4) SDL_hid_exit(); +#endif } void Joycons::Setup() { @@ -80,9 +84,9 @@ void Joycons::Setup() { } void Joycons::ScanThread(std::stop_token stop_token) { +#if SDL_VERSION_ATLEAST(2, 26, 4) constexpr u16 nintendo_vendor_id = 0x057e; Common::SetCurrentThreadName("JoyconScanThread"); - do { SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0); SDL_hid_device_info* cur_dev = devs; @@ -98,6 +102,7 @@ void Joycons::ScanThread(std::stop_token stop_token) { SDL_hid_free_enumeration(devs); } while (Common::StoppableTimedWait(stop_token, std::chrono::seconds{5})); +#endif } bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const { diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index ad854110ef..187dba6f68 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -92,6 +92,7 @@ public: } void EnableMotion() { +#if SDL_VERSION_ATLEAST(2, 26, 4) if (!sdl_controller) { return; } @@ -174,6 +175,7 @@ public: motion.delta_timestamp = time_difference; return true; } +#endif const BasicMotion& GetMotion() const { return motion; @@ -352,6 +354,7 @@ public: } std::string GetControllerName() const { +#if SDL_VERSION_ATLEAST(2, 26, 4) if (sdl_controller) { switch (SDL_GetGamepadType(sdl_controller.get())) { case SDL_GAMEPAD_TYPE_XBOX360: @@ -365,6 +368,8 @@ public: case SDL_GAMEPAD_TYPE_PS5: return "DualSense Controller"; default: + if (auto const name = SDL_GameControllerName(sdl_controller.get()); name) + return name; break; } const auto name = SDL_GetGamepadName(sdl_controller.get()); @@ -372,6 +377,7 @@ public: return name; } } +#endif if (sdl_joystick) { const auto name = SDL_GetJoystickName(sdl_joystick.get()); @@ -639,6 +645,7 @@ void SDLDriver::CloseJoysticks() { } SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_engine_)) { +#if SDL_VERSION_ATLEAST(2, 26, 4) // Set our application name. Currently passed to DBus by SDL and visible to the user through // their desktop environment. SDL_SetHint(SDL_HINT_APP_NAME, "Eden"); @@ -677,6 +684,7 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en // Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native // driver on Linux. SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_XBOX, "0"); +#endif // If the frontend is going to manage the event loop, then we don't start one here start_thread = SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == 0; @@ -986,6 +994,7 @@ ButtonBindings SDLDriver::GetDefaultButtonBinding( auto slr_button = SDL_GAMEPAD_BUTTON_LEFT_SHOULDER; auto srr_button = SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER; +#if SDL_VERSION_ATLEAST(2, 26, 4) if (joystick->IsJoyconLeft()) { sll_button = SDL_GAMEPAD_BUTTON_LEFT_PADDLE1; srl_button = SDL_GAMEPAD_BUTTON_LEFT_PADDLE2; @@ -994,6 +1003,7 @@ ButtonBindings SDLDriver::GetDefaultButtonBinding( slr_button = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2; srr_button = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1; } +#endif return { std::pair{Settings::NativeButton::A, SDL_GAMEPAD_BUTTON_EAST}, diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index 78df802b73..eca8044383 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -41,8 +41,8 @@ Common::Input::DriverResult JoyconDriver::RequestDeviceAccess(SDL_hid_device_inf return Common::Input::DriverResult::UnsupportedControllerType; } - hidapi_handle->handle = - SDL_hid_open(device_info->vendor_id, device_info->product_id, device_info->serial_number); +#if SDL_VERSION_ATLEAST(2, 26, 4) + hidapi_handle->handle = SDL_hid_open(device_info->vendor_id, device_info->product_id, device_info->serial_number); std::memcpy(&handle_serial_number, device_info->serial_number, 15); if (!hidapi_handle->handle) { LOG_ERROR(Input, "Yuzu can't gain access to this device: ID {:04X}:{:04X}.", @@ -51,6 +51,9 @@ Common::Input::DriverResult JoyconDriver::RequestDeviceAccess(SDL_hid_device_inf } SDL_hid_set_nonblocking(hidapi_handle->handle, 1); return Common::Input::DriverResult::Success; +#else + return Common::Input::DriverResult::UnsupportedControllerType; +#endif } Common::Input::DriverResult JoyconDriver::InitializeDevice() { @@ -141,8 +144,6 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { Common::SetCurrentThreadName("JoyconInput"); input_thread_running = true; - // Max update rate is 5ms, ensure we are always able to read a bit faster - constexpr int ThreadDelay = 3; std::vector buffer(MaxBufferSize); while (!stop_token.stop_requested()) { @@ -153,14 +154,17 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { continue; } +#if SDL_VERSION_ATLEAST(2, 26, 4) + // Max update rate is 5ms, ensure we are always able to read a bit faster + int constexpr thread_delay = 3; // By disabling the input thread we can ensure custom commands will succeed as no package is // skipped if (!disable_input_thread) { - status = SDL_hid_read_timeout(hidapi_handle->handle, buffer.data(), buffer.size(), - ThreadDelay); + status = SDL_hid_read_timeout(hidapi_handle->handle, buffer.data(), buffer.size(), thread_delay); } else { - std::this_thread::sleep_for(std::chrono::milliseconds(ThreadDelay)); + std::this_thread::sleep_for(std::chrono::milliseconds(thread_delay)); } +#endif if (IsPayloadCorrect(status, buffer)) { OnNewData(buffer); @@ -693,19 +697,18 @@ void JoyconDriver::SetCallbacks(const JoyconCallbacks& callbacks) { joycon_poller->SetCallbacks(callbacks); } -Common::Input::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, - ControllerType& controller_type) { +Common::Input::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, ControllerType& controller_type) { +#if SDL_VERSION_ATLEAST(2, 26, 4) static constexpr std::array, 6> supported_devices{ std::pair{0x2006, ControllerType::Left}, {0x2007, ControllerType::Right}, {0x2009, ControllerType::Pro}, }; - constexpr u16 nintendo_vendor_id = 0x057e; + constexpr u16 nintendo_vendor_id = 0x057e; controller_type = ControllerType::None; - if (device_info->vendor_id != nintendo_vendor_id) { + if (device_info->vendor_id != nintendo_vendor_id) return Common::Input::DriverResult::UnsupportedControllerType; - } for (const auto& [product_id, type] : supported_devices) { if (device_info->product_id == static_cast(product_id)) { @@ -713,16 +716,20 @@ Common::Input::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* dev return Common::Input::DriverResult::Success; } } +#endif return Common::Input::DriverResult::UnsupportedControllerType; } -Common::Input::DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info, - SerialNumber& serial_number) { +Common::Input::DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info, SerialNumber& serial_number) { +#if SDL_VERSION_ATLEAST(2, 26, 4) if (device_info->serial_number == nullptr) { return Common::Input::DriverResult::Unknown; } std::memcpy(&serial_number, device_info->serial_number, 15); return Common::Input::DriverResult::Success; +#else + return Common::Input::DriverResult::Unknown; +#endif } } // namespace InputCommon::Joycon diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.cpp b/src/input_common/helpers/joycon_protocol/common_protocol.cpp index e825afa1b7..12b83a1805 100644 --- a/src/input_common/helpers/joycon_protocol/common_protocol.cpp +++ b/src/input_common/helpers/joycon_protocol/common_protocol.cpp @@ -18,11 +18,15 @@ u8 JoyconCommonProtocol::GetCounter() { } void JoyconCommonProtocol::SetBlocking() { +#if SDL_VERSION_ATLEAST(2, 26, 4) SDL_hid_set_nonblocking(hidapi_handle->handle, 0); +#endif } void JoyconCommonProtocol::SetNonBlocking() { +#if SDL_VERSION_ATLEAST(2, 26, 4) SDL_hid_set_nonblocking(hidapi_handle->handle, 1); +#endif } Common::Input::DriverResult JoyconCommonProtocol::GetDeviceType(ControllerType& controller_type) { @@ -38,26 +42,23 @@ Common::Input::DriverResult JoyconCommonProtocol::GetDeviceType(ControllerType& return result; } -Common::Input::DriverResult JoyconCommonProtocol::CheckDeviceAccess( - SDL_hid_device_info* device_info) { +Common::Input::DriverResult JoyconCommonProtocol::CheckDeviceAccess(SDL_hid_device_info* device_info) { ControllerType controller_type{ControllerType::None}; const auto result = GetDeviceType(controller_type); - if (result != Common::Input::DriverResult::Success || controller_type == ControllerType::None) { return Common::Input::DriverResult::UnsupportedControllerType; } - - hidapi_handle->handle = - SDL_hid_open(device_info->vendor_id, device_info->product_id, device_info->serial_number); - +#if SDL_VERSION_ATLEAST(2, 26, 4) + hidapi_handle->handle = SDL_hid_open(device_info->vendor_id, device_info->product_id, device_info->serial_number); if (!hidapi_handle->handle) { - LOG_ERROR(Input, "Yuzu can't gain access to this device: ID {:04X}:{:04X}.", - device_info->vendor_id, device_info->product_id); + LOG_ERROR(Input, "Yuzu can't gain access to this device: ID {:04X}:{:04X}.", device_info->vendor_id, device_info->product_id); return Common::Input::DriverResult::HandleInUse; } - SetNonBlocking(); return Common::Input::DriverResult::Success; +#else + return Common::Input::DriverResult::UnsupportedControllerType; +#endif } Common::Input::DriverResult JoyconCommonProtocol::SetReportMode(ReportMode report_mode) { @@ -66,21 +67,21 @@ Common::Input::DriverResult JoyconCommonProtocol::SetReportMode(ReportMode repor } Common::Input::DriverResult JoyconCommonProtocol::SendRawData(std::span buffer) { - const auto result = SDL_hid_write(hidapi_handle->handle, buffer.data(), buffer.size()); - - if (result == -1) { +#if SDL_VERSION_ATLEAST(2, 26, 4) + auto const result = SDL_hid_write(hidapi_handle->handle, buffer.data(), buffer.size()); + if (result == -1) return Common::Input::DriverResult::ErrorWritingData; - } - return Common::Input::DriverResult::Success; +#else + return Common::Input::DriverResult::ErrorWritingData; +#endif } -Common::Input::DriverResult JoyconCommonProtocol::GetSubCommandResponse( - SubCommand sc, SubCommandResponse& output) { +Common::Input::DriverResult JoyconCommonProtocol::GetSubCommandResponse(SubCommand sc, SubCommandResponse& output) { +#if SDL_VERSION_ATLEAST(2, 26, 4) constexpr int timeout_mili = 66; constexpr int MaxTries = 10; int tries = 0; - do { int result = SDL_hid_read_timeout(hidapi_handle->handle, reinterpret_cast(&output), sizeof(SubCommandResponse), timeout_mili); @@ -91,9 +92,8 @@ Common::Input::DriverResult JoyconCommonProtocol::GetSubCommandResponse( if (tries++ > MaxTries) { return Common::Input::DriverResult::Timeout; } - } while (output.input_report.report_mode != ReportMode::SUBCMD_REPLY && - output.sub_command != sc); - + } while (output.input_report.report_mode != ReportMode::SUBCMD_REPLY && output.sub_command != sc); +#endif return Common::Input::DriverResult::Success; } @@ -221,12 +221,11 @@ Common::Input::DriverResult JoyconCommonProtocol::ConfigureMCU(const MCUConfig& return result; } -Common::Input::DriverResult JoyconCommonProtocol::GetMCUDataResponse(ReportMode report_mode, - MCUCommandResponse& output) { +Common::Input::DriverResult JoyconCommonProtocol::GetMCUDataResponse(ReportMode report_mode, MCUCommandResponse& output) { +#if SDL_VERSION_ATLEAST(2, 26, 4) constexpr int TimeoutMili = 200; constexpr int MaxTries = 9; int tries = 0; - do { int result = SDL_hid_read_timeout(hidapi_handle->handle, reinterpret_cast(&output), sizeof(MCUCommandResponse), TimeoutMili); @@ -237,9 +236,8 @@ Common::Input::DriverResult JoyconCommonProtocol::GetMCUDataResponse(ReportMode if (tries++ > MaxTries) { return Common::Input::DriverResult::Timeout; } - } while (output.input_report.report_mode != report_mode || - output.mcu_report == MCUReport::EmptyAwaitingCmd); - + } while (output.input_report.report_mode != report_mode || output.mcu_report == MCUReport::EmptyAwaitingCmd); +#endif return Common::Input::DriverResult::Success; } diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index fafe61a5e4..52623c8125 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -60,6 +60,7 @@ STUB_WEAK(ZSTD_trace_compress_begin) STUB_WEAK(ZSTD_trace_compress_end) STUB_WEAK(ZSTD_trace_decompress_begin) STUB_WEAK(ZSTD_trace_decompress_end) +FILE* __stderrp = stdout; # undef STUB_WEAK #endif #ifdef _WIN32 From 5dc6ced8e96f889db402df8a78b9a527c8e9a650 Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 5 Dec 2025 03:51:05 +0000 Subject: [PATCH 012/108] try to fix the paths --- src/common/fs/fs.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/fs/fs.cpp b/src/common/fs/fs.cpp index 3858b0f0c3..cc88f5f869 100644 --- a/src/common/fs/fs.cpp +++ b/src/common/fs/fs.cpp @@ -174,11 +174,14 @@ bool CreateDir(const fs::path& path) { return false; } + // TODO: Maybe this is what causes death? +#ifndef __OPENORBIS__ if (!Exists(path.parent_path())) { LOG_ERROR(Common_Filesystem, "Parent directory of path={} does not exist", PathToUTF8String(path)); return false; } +#endif if (IsDir(path)) { LOG_DEBUG(Common_Filesystem, "Filesystem object at path={} exists and is a directory", From 4a8df8d5bfae7f4e30460b740554c3d26ca070b5 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 10:31:03 +0000 Subject: [PATCH 013/108] disable fastmem --- src/common/settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 61f9acb1e7..dee8ab0155 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -186,7 +186,7 @@ bool IsFastmemEnabled() { // Only 4kb systems support host MMU right now // TODO: Support this return getpagesize() == 4096; -#elif !defined(__APPLE__) && !defined(__ANDROID__) && !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__) +#elif defined(__OPENORBIS__) || (!defined(__APPLE__) && !defined(__ANDROID__) && !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__)) return false; #else return true; From 91dc9e41d8d11994e88f854d21abf089b9cfcc64 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 10:58:26 +0000 Subject: [PATCH 014/108] (likely) fixes for virtual dmem? --- src/common/host_memory.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 1787cd0408..d0cb8a8021 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -36,15 +36,19 @@ // FreeBSD #ifndef MAP_NORESERVE -#define MAP_NORESERVE 0 +# define MAP_NORESERVE 0 #endif // Solaris 11 and illumos #ifndef MAP_ALIGNED_SUPER -#define MAP_ALIGNED_SUPER 0 +# define MAP_ALIGNED_SUPER 0 #endif // macOS #ifndef MAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON +# define MAP_ANONYMOUS MAP_ANON +#endif +// PlayStation 4 +#ifndef MAP_SYSTEM +# define MAP_SYSTEM 0 #endif #endif // ^^^ POSIX ^^^ @@ -436,8 +440,8 @@ static void* ChooseVirtualBase(size_t virtual_size) { #else static void* ChooseVirtualBase(size_t virtual_size) { -#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) - void* virtual_base = mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER, -1, 0); +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) || defined(__OPENORBIS__) + void* virtual_base = mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER | MAP_SYSTEM, -1, 0); if (virtual_base != MAP_FAILED) return virtual_base; #endif @@ -535,13 +539,13 @@ public: } if (use_anon) { LOG_WARNING(Common_Memory, "Using private mappings instead of shared ones"); - backing_base = static_cast(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); + backing_base = static_cast(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_SYSTEM, -1, 0)); if (fd > 0) { fd = -1; close(fd); } } else { - backing_base = static_cast(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); + backing_base = static_cast(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_SYSTEM, fd, 0)); } ASSERT_MSG(backing_base != MAP_FAILED, "mmap failed: {}", strerror(errno)); From 5496119ad333f0fb74702c9fab11e7ac33a949e3 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 18:54:57 +0000 Subject: [PATCH 015/108] MAP_SYSTEM --- src/common/host_memory.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index d0cb8a8021..d67befca07 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -47,8 +47,15 @@ # define MAP_ANONYMOUS MAP_ANON #endif // PlayStation 4 +// Flag needs to be undef-ed on non PS4 since it has different semantics +// on some platforms. #ifndef MAP_SYSTEM -# define MAP_SYSTEM 0 +# ifdef __OPENORBIS__ +# define MAP_SYSTEM 0x2000 +# else +# undef MAP_SYSTEM +# define MAP_SYSTEM 0 +# endif #endif #endif // ^^^ POSIX ^^^ From 777a26c29e4a4b873fa6334b2de14fa1c3ed52c8 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 19:29:40 +0000 Subject: [PATCH 016/108] more memory shit --- src/common/host_memory.cpp | 12 +++++++++--- src/yuzu_cmd/yuzu.cpp | 3 +-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index d67befca07..1067d53e0e 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -32,6 +32,8 @@ #include #elif defined(__FreeBSD__) #include +#elif defined(__OPENORBIS__) +#include #endif // FreeBSD @@ -447,12 +449,16 @@ static void* ChooseVirtualBase(size_t virtual_size) { #else static void* ChooseVirtualBase(size_t virtual_size) { -#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) || defined(__OPENORBIS__) - void* virtual_base = mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER | MAP_SYSTEM, -1, 0); +#if defined(__OPENORBIS__) + return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_SYSTEM, -1, 0); +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) + void* virtual_base = mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER, -1, 0); if (virtual_base != MAP_FAILED) return virtual_base; -#endif return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); +#else + return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); +#endif } #endif diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 52623c8125..9e2e3eb1aa 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -62,8 +62,7 @@ STUB_WEAK(ZSTD_trace_decompress_begin) STUB_WEAK(ZSTD_trace_decompress_end) FILE* __stderrp = stdout; # undef STUB_WEAK -#endif -#ifdef _WIN32 +#elif defined(_WIN32) extern "C" { // tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable // graphics From d1f46b2963dfa97b17b6c534b9d5a2e1a1fb0b94 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 20:07:43 +0000 Subject: [PATCH 017/108] force NO fastmem --- src/common/host_memory.cpp | 19 +++++++++++------- src/common/virtual_buffer.cpp | 37 +++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 1067d53e0e..8b4a06acf9 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -448,16 +448,14 @@ static void* ChooseVirtualBase(size_t virtual_size) { #else -static void* ChooseVirtualBase(size_t virtual_size) { -#if defined(__OPENORBIS__) - return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_SYSTEM, -1, 0); -#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) - void* virtual_base = mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER, -1, 0); +static void* ChooseVirtualBase(size_t size) { +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) + void* virtual_base = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER, -1, 0); if (virtual_base != MAP_FAILED) return virtual_base; - return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); + return mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); #else - return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); + return mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); #endif } @@ -690,6 +688,12 @@ private: #endif // ^^^ POSIX ^^^ HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_) : backing_size(backing_size_), virtual_size(virtual_size_) { +#ifdef __OPENORBIS__ + LOG_WARNING(HW_Memory, "Platform doesn't support fastmem"); + fallback_buffer = std::make_unique>(backing_size); + backing_base = fallback_buffer->data(); + virtual_base = nullptr; +#else // Try to allocate a fastmem arena. // The implementation will fail with std::bad_alloc on errors. impl = std::make_unique(AlignUp(backing_size, PageAlignment), AlignUp(virtual_size, PageAlignment) + HugePageSize); @@ -700,6 +704,7 @@ HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_) : backing_siz virtual_base = reinterpret_cast(Common::AlignUp(uintptr_t(virtual_base), HugePageSize)); virtual_base_offset = virtual_base - impl->virtual_base; } +#endif } HostMemory::~HostMemory() = default; diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 55ddfc243a..ef9113c557 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -6,6 +6,8 @@ #ifdef _WIN32 #include +#elif defined(__OPENORBIS__) +#include #else #include #endif @@ -17,23 +19,38 @@ namespace Common { void* AllocateMemoryPages(std::size_t size) noexcept { #ifdef _WIN32 - void* base = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); + void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); + ASSERT(addr != nullptr); +#elif defined(__OPENORBIS__) + u64 align = 16384; + void *addr = nullptr; + off_t direct_mem_off; + int32_t rc; + if ((rc = sceKernelAllocateDirectMemory(0, sceKernelGetDirectMemorySize(), size, align, 3, &direct_mem_off)) < 0) { + ASSERT(false && "sceKernelAllocateDirectMemory"); + return nullptr; + } + if ((rc = sceKernelMapDirectMemory(&addr, size, 0x33, 0, direct_mem_off, align)) < 0) { + ASSERT(false && "sceKernelMapDirectMemory"); + return nullptr; + } + ASSERT(addr != nullptr); #else - void* base = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - if (base == MAP_FAILED) - base = nullptr; + void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); + ASSERT(addr != MAP_FAILED); #endif - ASSERT(base); - return base; + return addr; } -void FreeMemoryPages(void* base, [[maybe_unused]] std::size_t size) noexcept { - if (!base) +void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { + if (!addr) return; #ifdef _WIN32 - ASSERT(VirtualFree(base, 0, MEM_RELEASE)); + VirtualFree(addr, 0, MEM_RELEASE) +#elif defined(__OPENORBIS__) #else - ASSERT(munmap(base, size) == 0); + int rc = munmap(addr, size); + ASSERT(rc == 0); #endif } From 5f9508294df0d65fad760a9909d5f055c7f645d2 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 20:21:16 +0000 Subject: [PATCH 018/108] make virtual buffer become an optional --- src/common/host_memory.cpp | 2 +- src/common/host_memory.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 8b4a06acf9..0c65e84c70 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -690,7 +690,7 @@ private: HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_) : backing_size(backing_size_), virtual_size(virtual_size_) { #ifdef __OPENORBIS__ LOG_WARNING(HW_Memory, "Platform doesn't support fastmem"); - fallback_buffer = std::make_unique>(backing_size); + fallback_buffer.emplace(backing_size); backing_base = fallback_buffer->data(); virtual_base = nullptr; #else diff --git a/src/common/host_memory.h b/src/common/host_memory.h index 8dd30aa9de..31af3cc9f1 100644 --- a/src/common/host_memory.h +++ b/src/common/host_memory.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include "common/common_funcs.h" #include "common/common_types.h" #include "common/virtual_buffer.h" From 5c70fff3ea0cf37f51398b79c13163b8ab6a90a7 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 21:29:18 +0000 Subject: [PATCH 019/108] extra ps4 defs --- src/common/host_memory.cpp | 11 ----------- src/common/virtual_buffer.cpp | 29 +++++++++++++++-------------- src/core/device_memory.h | 13 ++++--------- 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 0c65e84c70..7d63541b63 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -48,17 +48,6 @@ #ifndef MAP_ANONYMOUS # define MAP_ANONYMOUS MAP_ANON #endif -// PlayStation 4 -// Flag needs to be undef-ed on non PS4 since it has different semantics -// on some platforms. -#ifndef MAP_SYSTEM -# ifdef __OPENORBIS__ -# define MAP_SYSTEM 0x2000 -# else -# undef MAP_SYSTEM -# define MAP_SYSTEM 0 -# endif -#endif #endif // ^^^ POSIX ^^^ diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index ef9113c557..1d4929d233 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -14,6 +14,19 @@ #include "common/assert.h" #include "common/virtual_buffer.h" +#include "common/logging/log.h" + +// PlayStation 4 +// Flag needs to be undef-ed on non PS4 since it has different semantics +// on some platforms. +#ifdef __OPENORBIS__ +# ifndef MAP_SYSTEM +# define MAP_SYSTEM 0x2000 +# endif +# ifndef MAP_VOID +# define MAP_VOID 0x100 +# endif +#endif namespace Common { @@ -22,19 +35,8 @@ void* AllocateMemoryPages(std::size_t size) noexcept { void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); ASSERT(addr != nullptr); #elif defined(__OPENORBIS__) - u64 align = 16384; - void *addr = nullptr; - off_t direct_mem_off; - int32_t rc; - if ((rc = sceKernelAllocateDirectMemory(0, sceKernelGetDirectMemorySize(), size, align, 3, &direct_mem_off)) < 0) { - ASSERT(false && "sceKernelAllocateDirectMemory"); - return nullptr; - } - if ((rc = sceKernelMapDirectMemory(&addr, size, 0x33, 0, direct_mem_off, align)) < 0) { - ASSERT(false && "sceKernelMapDirectMemory"); - return nullptr; - } - ASSERT(addr != nullptr); + void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); + ASSERT(addr != MAP_FAILED); #else void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); @@ -47,7 +49,6 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { return; #ifdef _WIN32 VirtualFree(addr, 0, MEM_RELEASE) -#elif defined(__OPENORBIS__) #else int rc = munmap(addr, size); ASSERT(rc == 0); diff --git a/src/core/device_memory.h b/src/core/device_memory.h index 11bf0e3268..b96717871c 100644 --- a/src/core/device_memory.h +++ b/src/core/device_memory.h @@ -26,27 +26,22 @@ public: template Common::PhysicalAddress GetPhysicalAddr(const T* ptr) const { - return (reinterpret_cast(ptr) - - reinterpret_cast(buffer.BackingBasePointer())) + - DramMemoryMap::Base; + return (uintptr_t(ptr) - uintptr_t(buffer.BackingBasePointer())) + DramMemoryMap::Base; } template PAddr GetRawPhysicalAddr(const T* ptr) const { - return static_cast(reinterpret_cast(ptr) - - reinterpret_cast(buffer.BackingBasePointer())); + return PAddr(uintptr_t(ptr) - uintptr_t(buffer.BackingBasePointer())); } template T* GetPointer(Common::PhysicalAddress addr) { - return reinterpret_cast(buffer.BackingBasePointer() + - (GetInteger(addr) - DramMemoryMap::Base)); + return reinterpret_cast(buffer.BackingBasePointer() + (GetInteger(addr) - DramMemoryMap::Base)); } template const T* GetPointer(Common::PhysicalAddress addr) const { - return reinterpret_cast(buffer.BackingBasePointer() + - (GetInteger(addr) - DramMemoryMap::Base)); + return reinterpret_cast(buffer.BackingBasePointer() + (GetInteger(addr) - DramMemoryMap::Base)); } template From f9830093d8bf7053abc2287da6c0b78b71e5223a Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 1 Dec 2025 21:35:01 +0000 Subject: [PATCH 020/108] evil haxx --- src/common/host_memory.cpp | 4 ++-- src/common/virtual_buffer.cpp | 2 -- src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp | 4 ++++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 7d63541b63..4f46484e10 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -539,13 +539,13 @@ public: } if (use_anon) { LOG_WARNING(Common_Memory, "Using private mappings instead of shared ones"); - backing_base = static_cast(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_SYSTEM, -1, 0)); + backing_base = static_cast(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); if (fd > 0) { fd = -1; close(fd); } } else { - backing_base = static_cast(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_SYSTEM, fd, 0)); + backing_base = static_cast(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); } ASSERT_MSG(backing_base != MAP_FAILED, "mmap failed: {}", strerror(errno)); diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 1d4929d233..5a05f12d47 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -6,8 +6,6 @@ #ifdef _WIN32 #include -#elif defined(__OPENORBIS__) -#include #else #include #endif diff --git a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp index 3343d1d282..6faeb47908 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp @@ -86,7 +86,11 @@ size_t KSystemControl::Init::GetIntendedMemorySize() { switch (GetMemorySizeForInit()) { case Smc::MemorySize_4GB: default: // All invalid modes should go to 4GB. +#ifdef __OPENORBIS__ + return 2_GiB; +#else return 4_GiB; +#endif case Smc::MemorySize_6GB: return 6_GiB; case Smc::MemorySize_8GB: From 946fbe4b2577920f765207209ccec1a4dde4a532 Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 5 Dec 2025 03:52:18 +0000 Subject: [PATCH 021/108] adapt to new master --- .patch/mbedtls/0002-aesni-fix.patch | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .patch/mbedtls/0002-aesni-fix.patch diff --git a/.patch/mbedtls/0002-aesni-fix.patch b/.patch/mbedtls/0002-aesni-fix.patch deleted file mode 100644 index e9a1bce5e6..0000000000 --- a/.patch/mbedtls/0002-aesni-fix.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/library/aesni.h b/library/aesni.h -index 754c984c79..59e27afd3e 100644 ---- a/library/aesni.h -+++ b/library/aesni.h -@@ -35,7 +35,7 @@ - /* GCC-like compilers: currently, we only support intrinsics if the requisite - * target flag is enabled when building the library (e.g. `gcc -mpclmul -msse2` - * or `clang -maes -mpclmul`). */ --#if (defined(__GNUC__) || defined(__clang__)) && defined(__AES__) && defined(__PCLMUL__) -+#if (defined(__GNUC__) || defined(__clang__)) && !defined(__OPENORBIS__) - #define MBEDTLS_AESNI_HAVE_INTRINSICS - #endif - /* For 32-bit, we only support intrinsics */ From 88e9ca05185b47dc9280549282dd66ab00055ee7 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 6 Dec 2025 20:50:36 +0000 Subject: [PATCH 022/108] fixes for mbedtls --- .patch/mbedtls/0003-openorbis.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .patch/mbedtls/0003-openorbis.patch diff --git a/.patch/mbedtls/0003-openorbis.patch b/.patch/mbedtls/0003-openorbis.patch new file mode 100644 index 0000000000..46cfbd408f --- /dev/null +++ b/.patch/mbedtls/0003-openorbis.patch @@ -0,0 +1,13 @@ +diff --git a/library/entropy_poll.c b/library/entropy_poll.c +index 611768c..8950ee4 100644 +--- a/library/entropy_poll.c ++++ b/library/entropy_poll.c +@@ -118,7 +118,7 @@ static int getrandom_wrapper(void *buf, size_t buflen, unsigned int flags) + * + * Documentation: https://netbsd.gw.com/cgi-bin/man-cgi?sysctl+7 + */ +-#if (defined(__FreeBSD__) || defined(__NetBSD__)) && !defined(HAVE_GETRANDOM) ++#if (defined(__FreeBSD__) || defined(__NetBSD__)) && !defined(HAVE_GETRANDOM) && !defined(__OPENORBIS__) + #include + #include + #if defined(KERN_ARND) From f903b24885054df54daf2057456700727b968d9c Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 6 Dec 2025 21:31:14 +0000 Subject: [PATCH 023/108] add sce_module so it loads on real hw --- CMakeModules/OpenOrbis.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeModules/OpenOrbis.cmake b/CMakeModules/OpenOrbis.cmake index 4e76731f6a..593c951e30 100644 --- a/CMakeModules/OpenOrbis.cmake +++ b/CMakeModules/OpenOrbis.cmake @@ -19,7 +19,7 @@ function(create_ps4_pkg project target content_id) COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE --type Utf8 --maxsize 128 --value ${target} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE_ID --type Utf8 --maxsize 12 --value BREW00090 COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} VERSION --type Utf8 --maxsize 8 --value 1.03 - COMMAND ${CMAKE_SYSROOT}/bin/create-gp4 -out ${target}.gp4 --content-id=${content_id} --files "eboot.bin ${sce_sys_param}" + COMMAND ${CMAKE_SYSROOT}/bin/create-gp4 -out ${target}.gp4 --content-id=${content_id} --files "eboot.bin ${sce_sys_param} sce_module/libc.prx sce_module/libSceFios2.prx" COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core pkg_build ${target}.gp4 . VERBATIM WORKING_DIRECTORY ${CMAKE_BINARY_DIR} From 711eb59aad0c9ae501fb64c1633d4e5598770426 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 6 Dec 2025 21:35:32 +0000 Subject: [PATCH 024/108] license --- .ci/ps4/make-toolchain.sh | 3 +++ CMakeModules/FindSDL2.cmake | 3 +++ src/common/memory_detect.cpp | 3 +++ src/core/device_memory.h | 3 +++ 4 files changed, 12 insertions(+) mode change 100644 => 100755 .ci/ps4/make-toolchain.sh diff --git a/.ci/ps4/make-toolchain.sh b/.ci/ps4/make-toolchain.sh old mode 100644 new mode 100755 index 727596ae36..7903a79169 --- a/.ci/ps4/make-toolchain.sh +++ b/.ci/ps4/make-toolchain.sh @@ -1,5 +1,8 @@ #!/usr/local/bin/bash -ex +# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + # Define global vars # These flags are used everywhere, so let's reuse them. export OO_PS4_TOOLCHAIN="$PWD/prefix" diff --git a/CMakeModules/FindSDL2.cmake b/CMakeModules/FindSDL2.cmake index 2445d36ec5..a7e7225dbb 100644 --- a/CMakeModules/FindSDL2.cmake +++ b/CMakeModules/FindSDL2.cmake @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp index 8bd544e3e2..b755c1a77e 100644 --- a/src/common/memory_detect.cpp +++ b/src/common/memory_detect.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/core/device_memory.h b/src/core/device_memory.h index b96717871c..17b585d67a 100644 --- a/src/core/device_memory.h +++ b/src/core/device_memory.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later From c528822a792f61433842800ee2860597ff308d4b Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 11 Dec 2025 05:01:48 +0000 Subject: [PATCH 025/108] swap handling --- src/common/host_memory.cpp | 1 + src/common/virtual_buffer.cpp | 28 +++++++++++++++++++++++++++- src/common/virtual_buffer.h | 1 + src/yuzu_cmd/yuzu.cpp | 16 ++++++++++++++-- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 4f46484e10..6ac1188a1a 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -678,6 +678,7 @@ private: HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_) : backing_size(backing_size_), virtual_size(virtual_size_) { #ifdef __OPENORBIS__ + Common::InitSwap(); LOG_WARNING(HW_Memory, "Platform doesn't support fastmem"); fallback_buffer.emplace(backing_size); backing_base = fallback_buffer->data(); diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 5a05f12d47..34f9c57463 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -10,6 +10,10 @@ #include #endif +#ifdef __OPENORBIS__ +#include +#endif + #include "common/assert.h" #include "common/virtual_buffer.h" #include "common/logging/log.h" @@ -33,7 +37,7 @@ void* AllocateMemoryPages(std::size_t size) noexcept { void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); ASSERT(addr != nullptr); #elif defined(__OPENORBIS__) - void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); + void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); #else void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); @@ -53,4 +57,26 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { #endif } +#ifdef __OPENORBIS__ +static struct sigaction old_sa_segv; +static void SwapHandler(int sig, siginfo_t* si, void* raw_context) { + void* a_addr = reinterpret_cast(uintptr_t(si->si_addr) & ~0xfff); + mmap(a_addr, 4096, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); + //mprotect(a_addr, 4096, PROT_READ | PROT_WRITE); +} + +bool InitSwap() noexcept { + struct sigaction sa; + sa.sa_handler = NULL; + sa.sa_sigaction = &SwapHandler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_SIGINFO | SA_RESTART; + return sigaction(SIGSEGV, &sa, &old_sa_segv) == 0; +} +#else +bool InitSwap() noexcept { + return true; +} +#endif + } // namespace Common diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index af96317288..7c2ee1cca7 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -12,6 +12,7 @@ namespace Common { void* AllocateMemoryPages(std::size_t size) noexcept; void FreeMemoryPages(void* base, std::size_t size) noexcept; +bool InitSwap() noexcept; template class VirtualBuffer final { diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 9e2e3eb1aa..fbba3190fa 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -53,6 +53,7 @@ #endif #ifdef __OPENORBIS__ +#include # define STUB_WEAK(name) extern "C" void name() { printf("called " #name); asm volatile("ud2"); } STUB_WEAK(__cxa_thread_atexit) STUB_WEAK(__assert) @@ -448,10 +449,20 @@ int main(int argc, char** argv) { [](VideoCore::LoadCallbackStage, size_t value, size_t total) {}); } - system.RegisterExitCallback([&] { + auto const exit_fn = [&] { +#ifdef __OPENORBIS__ + sceSystemServiceLoadExec("EXIT", nullptr); +#else // Just exit right away. exit(0); - }); +#endif + }; + system.RegisterExitCallback(exit_fn); + +#ifdef __linux__ + Common::Linux::StartGamemode(); +#endif + void(system.Run()); if (system.DebuggerEnabled()) { system.InitializeDebugger(); @@ -463,6 +474,7 @@ int main(int argc, char** argv) { void(system.Pause()); system.ShutdownMainProcess(); detached_tasks.WaitForAllTasks(); + exit_fn(); return 0; } From fc42cc3d922db0f0fe2b14820dd1540a679571ba Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 6 Dec 2025 23:02:09 +0000 Subject: [PATCH 026/108] fixes 4 stuff --- src/common/virtual_buffer.cpp | 10 +++++----- .../hle/kernel/board/nintendo/nx/k_system_control.cpp | 4 ---- .../src/dynarmic/backend/exception_handler_posix.cpp | 2 +- src/yuzu_cmd/CMakeLists.txt | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 34f9c57463..3e5f327245 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -37,7 +37,7 @@ void* AllocateMemoryPages(std::size_t size) noexcept { void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); ASSERT(addr != nullptr); #elif defined(__OPENORBIS__) - void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); + void* addr = mmap(nullptr, size, PROT_NONE, MAP_VOID | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); #else void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); @@ -60,15 +60,15 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { #ifdef __OPENORBIS__ static struct sigaction old_sa_segv; static void SwapHandler(int sig, siginfo_t* si, void* raw_context) { - void* a_addr = reinterpret_cast(uintptr_t(si->si_addr) & ~0xfff); - mmap(a_addr, 4096, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - //mprotect(a_addr, 4096, PROT_READ | PROT_WRITE); + void* aligned_addr = reinterpret_cast(uintptr_t(si->si_addr) & ~0xfff); + void* res = mmap(aligned_addr, 4096, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); + ASSERT(res != MAP_FAILED); } bool InitSwap() noexcept { struct sigaction sa; sa.sa_handler = NULL; - sa.sa_sigaction = &SwapHandler; + sa.__sa_handler.__sa_sigaction = &SwapHandler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO | SA_RESTART; return sigaction(SIGSEGV, &sa, &old_sa_segv) == 0; diff --git a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp index 6faeb47908..3343d1d282 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp @@ -86,11 +86,7 @@ size_t KSystemControl::Init::GetIntendedMemorySize() { switch (GetMemorySizeForInit()) { case Smc::MemorySize_4GB: default: // All invalid modes should go to 4GB. -#ifdef __OPENORBIS__ - return 2_GiB; -#else return 4_GiB; -#endif case Smc::MemorySize_6GB: return 6_GiB; case Smc::MemorySize_8GB: diff --git a/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp b/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp index 537782c883..c45efc6103 100644 --- a/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp +++ b/src/dynarmic/src/dynarmic/backend/exception_handler_posix.cpp @@ -61,7 +61,7 @@ public: signal_stack_memory = mmap(nullptr, signal_stack_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); #ifdef __OPENORBIS__ - fmt::print(stderr, "no fastmem on ps4\n"); + fmt::print(stderr, "no fastmem on PS4\n"); supports_fast_mem = false; #else stack_t signal_stack{}; diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index 86293c18a9..d4e431d70a 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -45,7 +45,7 @@ endif() if (MSVC) target_link_libraries(yuzu-cmd PRIVATE getopt) elseif(PLATFORM_PS4) - target_link_libraries(yuzu-cmd PRIVATE SceVideoOut SceAudioOut ScePad) + target_link_libraries(yuzu-cmd PRIVATE SceVideoOut SceAudioOut ScePad SceSystemService) endif() target_link_libraries(yuzu-cmd PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) From daf4e9749d30e4ce2fde89628b6d37dfec858648 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 7 Dec 2025 00:39:38 +0000 Subject: [PATCH 027/108] more stupid stuff --- src/common/virtual_buffer.cpp | 71 +++++++++++++++++++++++------------ src/yuzu_cmd/yuzu.cpp | 5 +++ 2 files changed, 53 insertions(+), 23 deletions(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 3e5f327245..d444e81edf 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -11,7 +11,9 @@ #endif #ifdef __OPENORBIS__ +#include #include +#include #endif #include "common/assert.h" @@ -28,10 +30,54 @@ # ifndef MAP_VOID # define MAP_VOID 0x100 # endif +// sigaction(2) has a motherfucking bug on musl where the thing isnt even properly prefixed +# undef sa_sigaction +# define sa_sigaction __sa_handler.__sa_sigaction #endif namespace Common { +#ifdef __OPENORBIS__ +static struct sigaction old_sa_segv; +static boost::container::static_vector, 16> swap_regions; +static void SwapHandler(int sig, siginfo_t* si, void* raw_context) { + if (std::ranges::find_if(swap_regions, [addr = si->si_addr](auto const& e) { + return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second; + }) != swap_regions.end()) { + size_t const page_size = 4096; + size_t const page_mask = ~0xfff; + // should replace the existing mapping... ugh + void* aligned_addr = reinterpret_cast(uintptr_t(si->si_addr) & page_mask); + void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); + ASSERT(res != MAP_FAILED); + } else { + struct sigaction* retry_sa = &old_sa_segv; + if ((retry_sa->sa_flags & SA_SIGINFO) != 0) { + retry_sa->sa_sigaction(sig, si, raw_context); + } else if (retry_sa->sa_handler == SIG_DFL) { + signal(sig, SIG_DFL); + } else if (retry_sa->sa_handler == SIG_IGN) { + // ignore? + } else { + retry_sa->sa_handler(sig); + } + } +} + +bool InitSwap() noexcept { + struct sigaction sa; + sa.sa_handler = NULL; + sa.sa_sigaction = &SwapHandler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_SIGINFO | SA_RESTART; + return sigaction(SIGSEGV, &sa, &old_sa_segv) == 0; +} +#else +bool InitSwap() noexcept { + return true; +} +#endif + void* AllocateMemoryPages(std::size_t size) noexcept { #ifdef _WIN32 void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); @@ -39,6 +85,7 @@ void* AllocateMemoryPages(std::size_t size) noexcept { #elif defined(__OPENORBIS__) void* addr = mmap(nullptr, size, PROT_NONE, MAP_VOID | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); + swap_regions.emplace_back(addr, size); #else void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); @@ -50,33 +97,11 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { if (!addr) return; #ifdef _WIN32 - VirtualFree(addr, 0, MEM_RELEASE) + VirtualFree(addr, 0, MEM_RELEASE); #else int rc = munmap(addr, size); ASSERT(rc == 0); #endif } -#ifdef __OPENORBIS__ -static struct sigaction old_sa_segv; -static void SwapHandler(int sig, siginfo_t* si, void* raw_context) { - void* aligned_addr = reinterpret_cast(uintptr_t(si->si_addr) & ~0xfff); - void* res = mmap(aligned_addr, 4096, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); - ASSERT(res != MAP_FAILED); -} - -bool InitSwap() noexcept { - struct sigaction sa; - sa.sa_handler = NULL; - sa.__sa_handler.__sa_sigaction = &SwapHandler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_SIGINFO | SA_RESTART; - return sigaction(SIGSEGV, &sa, &old_sa_segv) == 0; -} -#else -bool InitSwap() noexcept { - return true; -} -#endif - } // namespace Common diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index fbba3190fa..ec5558a107 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -239,6 +239,11 @@ int main(int argc, char** argv) { // clang-format on }; +#ifdef __OPENORBIS__ + // PS4 will use this path by default UNLESS overriden; this is so users + // can quickly launch whatever they want. + filepath = "/data/eden/games/test.nro"; +#endif while (optind < argc) { int arg = getopt_long(argc, argv, "g:fhvcip::c:u:d:", long_options, &option_index); if (arg != -1) { From d47a4b89f7333e36c6962c42f80741c157741d73 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 8 Dec 2025 03:08:25 +0000 Subject: [PATCH 028/108] proper memswap mechanism --- src/common/virtual_buffer.cpp | 101 ++++++++++++++++++++++-------- src/common/virtual_buffer.h | 2 +- src/qt_common/config/uisettings.h | 8 ++- src/yuzu_cmd/yuzu.cpp | 5 +- 4 files changed, 86 insertions(+), 30 deletions(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index d444e81edf..7a6e7b8352 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -14,6 +14,9 @@ #include #include #include +#include +typedef void (*SceKernelExceptionHandler)(int32_t, void*); +extern "C" int32_t sceKernelInstallExceptionHandler(int32_t signum, SceKernelExceptionHandler handler); #endif #include "common/assert.h" @@ -38,44 +41,90 @@ namespace Common { #ifdef __OPENORBIS__ -static struct sigaction old_sa_segv; + +namespace Orbis { +struct Ucontext { + struct Sigset { + u64 bits[2]; + } uc_sigmask; + int field1_0x10[12]; + struct Mcontext { + u64 mc_onstack; + u64 mc_rdi; + u64 mc_rsi; + u64 mc_rdx; + u64 mc_rcx; + u64 mc_r8; + u64 mc_r9; + u64 mc_rax; + u64 mc_rbx; + u64 mc_rbp; + u64 mc_r10; + u64 mc_r11; + u64 mc_r12; + u64 mc_r13; + u64 mc_r14; + u64 mc_r15; + int mc_trapno; + u16 mc_fs; + u16 mc_gs; + u64 mc_addr; + int mc_flags; + u16 mc_es; + u16 mc_ds; + u64 mc_err; + u64 mc_rip; + u64 mc_cs; + u64 mc_rflags; + u64 mc_rsp; + u64 mc_ss; + u64 mc_len; + u64 mc_fpformat; + u64 mc_ownedfp; + u64 mc_lbrfrom; + u64 mc_lbrto; + u64 mc_aux1; + u64 mc_aux2; + u64 mc_fpstate[104]; + u64 mc_fsbase; + u64 mc_gsbase; + u64 mc_spare[6]; + } uc_mcontext; + struct Ucontext* uc_link; + struct ExStack { + void* ss_sp; + std::size_t ss_size; + int ss_flags; + int _align; + } uc_stack; + int uc_flags; + int __spare[4]; + int field7_0x4f4[3]; +}; +} + static boost::container::static_vector, 16> swap_regions; -static void SwapHandler(int sig, siginfo_t* si, void* raw_context) { - if (std::ranges::find_if(swap_regions, [addr = si->si_addr](auto const& e) { +static void SwapHandler(int sig, void* raw_context) { + auto& mctx = ((Orbis::Ucontext*)raw_context)->uc_mcontext; + if (std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second; }) != swap_regions.end()) { size_t const page_size = 4096; size_t const page_mask = ~0xfff; // should replace the existing mapping... ugh - void* aligned_addr = reinterpret_cast(uintptr_t(si->si_addr) & page_mask); + void* aligned_addr = reinterpret_cast(uintptr_t(mctx.mc_addr) & page_mask); void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(res != MAP_FAILED); } else { - struct sigaction* retry_sa = &old_sa_segv; - if ((retry_sa->sa_flags & SA_SIGINFO) != 0) { - retry_sa->sa_sigaction(sig, si, raw_context); - } else if (retry_sa->sa_handler == SIG_DFL) { - signal(sig, SIG_DFL); - } else if (retry_sa->sa_handler == SIG_IGN) { - // ignore? - } else { - retry_sa->sa_handler(sig); - } + LOG_ERROR(HW_Memory, "fault in addr {:#x}", mctx.mc_addr); + sceSystemServiceLoadExec("EXIT", nullptr); } } - -bool InitSwap() noexcept { - struct sigaction sa; - sa.sa_handler = NULL; - sa.sa_sigaction = &SwapHandler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_SIGINFO | SA_RESTART; - return sigaction(SIGSEGV, &sa, &old_sa_segv) == 0; +void InitSwap() noexcept { + sceKernelInstallExceptionHandler(SIGSEGV, &SwapHandler); } #else -bool InitSwap() noexcept { - return true; -} +void InitSwap() noexcept {} #endif void* AllocateMemoryPages(std::size_t size) noexcept { @@ -83,7 +132,7 @@ void* AllocateMemoryPages(std::size_t size) noexcept { void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); ASSERT(addr != nullptr); #elif defined(__OPENORBIS__) - void* addr = mmap(nullptr, size, PROT_NONE, MAP_VOID | MAP_PRIVATE, -1, 0); + void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); swap_regions.emplace_back(addr, size); #else diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index 7c2ee1cca7..af51949a10 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -12,7 +12,7 @@ namespace Common { void* AllocateMemoryPages(std::size_t size) noexcept; void FreeMemoryPages(void* base, std::size_t size) noexcept; -bool InitSwap() noexcept; +void InitSwap() noexcept; template class VirtualBuffer final { diff --git a/src/qt_common/config/uisettings.h b/src/qt_common/config/uisettings.h index 4549a36345..2b155ef3f2 100644 --- a/src/qt_common/config/uisettings.h +++ b/src/qt_common/config/uisettings.h @@ -160,7 +160,13 @@ struct Values { Setting enable_discord_presence{linkage, false, "enable_discord_presence", Category::Ui}; // logging - Setting show_console{linkage, false, "showConsole", Category::Ui}; + Setting show_console{linkage, +#ifdef __OPENORBIS__ + true, +#else + false, +#endif + "showConsole", Category::Ui}; // Screenshots Setting enable_screenshot_save_as{linkage, true, "enable_screenshot_save_as", diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index ec5558a107..48028459d9 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -54,8 +54,10 @@ #ifdef __OPENORBIS__ #include +#include +#include <__thread/support.h> # define STUB_WEAK(name) extern "C" void name() { printf("called " #name); asm volatile("ud2"); } -STUB_WEAK(__cxa_thread_atexit) +void *__cxa_thread_atexit_impl = nullptr; STUB_WEAK(__assert) STUB_WEAK(ZSTD_trace_compress_begin) STUB_WEAK(ZSTD_trace_compress_end) @@ -238,7 +240,6 @@ int main(int argc, char** argv) { {0, 0, 0, 0}, // clang-format on }; - #ifdef __OPENORBIS__ // PS4 will use this path by default UNLESS overriden; this is so users // can quickly launch whatever they want. From 3a053224de443319dec52c58c93f116971cf2cac Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 18 Jan 2026 16:34:51 +0000 Subject: [PATCH 029/108] opengl bullshit --- src/common/settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/settings.h b/src/common/settings.h index e8877fce1e..a558eb36da 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -330,7 +330,7 @@ struct Values { // Renderer SwitchableSetting renderer_backend{linkage, -#if defined(__sun__) || defined(__managarm__) +#if defined(__sun__) || defined(__managarm__) || defined(__OPENORBIS__) RendererBackend::OpenGL_GLSL, #else RendererBackend::Vulkan, From c3f5456bacc18e371ccdf980a09bbd1dbca58ad0 Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 26 Dec 2025 12:11:05 +0000 Subject: [PATCH 030/108] fix for crashes on TLS due to openorbis being W E I R D --- src/common/settings.h | 9 ++++++++- src/common/virtual_buffer.cpp | 5 +++-- src/input_common/main.cpp | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/common/settings.h b/src/common/settings.h index a558eb36da..11d3ec1c7e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -196,7 +196,14 @@ struct Values { linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false}; // Core - SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; + SwitchableSetting use_multi_core{linkage, +#ifdef __OPENORBIS__ + // Re-enable once proper TLS support is added + false, +#else + true, +#endif + "use_multi_core", Category::Core}; SwitchableSetting memory_layout_mode{linkage, MemoryLayout::Memory_4Gb, "memory_layout_mode", diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 7a6e7b8352..a4ccd84d38 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -104,6 +104,7 @@ struct Ucontext { } static boost::container::static_vector, 16> swap_regions; +extern "C" int sceKernelRemoveExceptionHandler(s32 sig_num); static void SwapHandler(int sig, void* raw_context) { auto& mctx = ((Orbis::Ucontext*)raw_context)->uc_mcontext; if (std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { @@ -116,8 +117,8 @@ static void SwapHandler(int sig, void* raw_context) { void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(res != MAP_FAILED); } else { - LOG_ERROR(HW_Memory, "fault in addr {:#x}", mctx.mc_addr); - sceSystemServiceLoadExec("EXIT", nullptr); + LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address + sceKernelRemoveExceptionHandler(SIGSEGV); // to not catch the next signal } } void InitSwap() noexcept { diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 5f0a8af3aa..22eb5d06df 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -82,7 +82,10 @@ struct InputSubsystem::Impl { #ifdef ENABLE_LIBUSB RegisterEngine("gcpad", gcadapter); #endif +#ifndef __OPENORBIS__ + // TODO: Issue in PS4, crash for UDP_client RegisterEngine("cemuhookudp", udp_client); +#endif RegisterEngine("tas", tas_input); RegisterEngine("camera", camera); #ifdef ANDROID @@ -116,7 +119,9 @@ struct InputSubsystem::Impl { #ifdef ENABLE_LIBUSB UnregisterEngine(gcadapter); #endif +#ifndef __OPENORBIS__ UnregisterEngine(udp_client); +#endif UnregisterEngine(tas_input); UnregisterEngine(camera); #ifdef ANDROID @@ -152,6 +157,7 @@ struct InputSubsystem::Impl { auto gcadapter_devices = gcadapter->GetInputDevices(); devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end()); #endif +#ifndef __OPENORBIS__ auto udp_devices = udp_client->GetInputDevices(); devices.insert(devices.end(), udp_devices.begin(), udp_devices.end()); #ifdef HAVE_SDL3 @@ -186,6 +192,7 @@ struct InputSubsystem::Impl { return gcadapter; } #endif +#ifndef __OPENORBIS__ if (engine == udp_client->GetEngineName()) { return udp_client; } @@ -271,9 +278,11 @@ struct InputSubsystem::Impl { return true; } #endif +#ifndef __OPENORBIS__ if (engine == udp_client->GetEngineName()) { return true; } +#endif if (engine == tas_input->GetEngineName()) { return true; } @@ -300,6 +309,7 @@ struct InputSubsystem::Impl { #ifdef ENABLE_LIBUSB gcadapter->BeginConfiguration(); #endif +#ifndef __OPENORBIS__ udp_client->BeginConfiguration(); #ifdef HAVE_SDL3 sdl->BeginConfiguration(); @@ -316,6 +326,7 @@ struct InputSubsystem::Impl { #ifdef ENABLE_LIBUSB gcadapter->EndConfiguration(); #endif +#ifndef __OPENORBIS__ udp_client->EndConfiguration(); #ifdef HAVE_SDL3 sdl->EndConfiguration(); @@ -341,7 +352,9 @@ struct InputSubsystem::Impl { std::shared_ptr mouse; std::shared_ptr touch_screen; std::shared_ptr tas_input; +#ifndef __OPENORBIS__ std::shared_ptr udp_client; +#endif std::shared_ptr camera; std::shared_ptr virtual_amiibo; std::shared_ptr virtual_gamepad; @@ -470,7 +483,9 @@ bool InputSubsystem::IsStickInverted(const Common::ParamPackage& params) const { } void InputSubsystem::ReloadInputDevices() { +#ifndef __OPENORBIS__ impl->udp_client.get()->ReloadSockets(); +#endif } void InputSubsystem::BeginMapping(Polling::InputType type) { From a625fcd5b3ada1efd96ba66120d8f61d26337847 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 8 Jan 2026 22:45:20 +0000 Subject: [PATCH 031/108] fix alloc failures --- src/common/virtual_buffer.cpp | 43 +++++++++++++++---- src/core/arm/dynarmic/arm_dynarmic_32.cpp | 4 +- src/core/arm/dynarmic/arm_dynarmic_64.cpp | 4 +- .../src/dynarmic/backend/x64/a32_emit_x64.h | 6 +++ .../src/dynarmic/backend/x64/a64_emit_x64.h | 5 +++ 5 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index a4ccd84d38..407bf2e157 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -13,6 +13,7 @@ #ifdef __OPENORBIS__ #include #include +#include #include #include typedef void (*SceKernelExceptionHandler)(int32_t, void*); @@ -107,15 +108,19 @@ static boost::container::static_vector, 16> swap_region extern "C" int sceKernelRemoveExceptionHandler(s32 sig_num); static void SwapHandler(int sig, void* raw_context) { auto& mctx = ((Orbis::Ucontext*)raw_context)->uc_mcontext; - if (std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { + if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second; - }) != swap_regions.end()) { - size_t const page_size = 4096; - size_t const page_mask = ~0xfff; + }); it != swap_regions.end()) { + size_t const page_size = 4096 * 8; + size_t const page_mask = ~(page_size - 1); // should replace the existing mapping... ugh void* aligned_addr = reinterpret_cast(uintptr_t(mctx.mc_addr) & page_mask); void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); - ASSERT(res != MAP_FAILED); + if (res == MAP_FAILED) { + LOG_ERROR(HW_Memory, "FAIL mapped addr {},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second); + } else { + LOG_INFO(HW_Memory, "OK mapped addr {},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second); + } } else { LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address sceKernelRemoveExceptionHandler(SIGSEGV); // to not catch the next signal @@ -128,14 +133,36 @@ void InitSwap() noexcept { void InitSwap() noexcept {} #endif +static const char *swapfile_names[] { + "/data/eden/games/swap0.bin", + "/data/eden/games/swap1.bin", + "/data/eden/games/swap2.bin", + "/data/eden/games/swap3.bin", + "/data/eden/games/swap4.bin" +}; +static size_t swapfile_count = 0; + void* AllocateMemoryPages(std::size_t size) noexcept { #ifdef _WIN32 void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); ASSERT(addr != nullptr); #elif defined(__OPENORBIS__) - void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); - ASSERT(addr != MAP_FAILED); - swap_regions.emplace_back(addr, size); + void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); + if (addr == MAP_FAILED) { + LOG_WARNING(HW_Memory, "failed to mmap({} bytes) using swapfile {}", size, swapfile_names[swapfile_count]); + // int fd = open(swapfile_names[swapfile_count], O_TRUNC | O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); + // ASSERT(fd > 0); + // ftruncate(fd, size); + // addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); + // ASSERT(addr != MAP_FAILED); + // ++swapfile_count; + + addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); + ASSERT(addr != MAP_FAILED); + swap_regions.emplace_back(addr, size); + } else { + LOG_INFO(HW_Memory, "mmap {} bytes", size); + } #else void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index e434a31d5d..78b1dc20a8 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -199,7 +199,9 @@ void ArmDynarmic32::MakeJit(Common::PageTable* page_table) { config.enable_cycle_counting = !m_uses_wall_clock; // Code cache size -#if defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) +#if defined(__OPENORBIS__) + config.code_cache_size = std::uint32_t(32_MiB); +#elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else config.code_cache_size = std::uint32_t(512_MiB); diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index e6c7e61265..c831e3c9da 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -252,7 +252,9 @@ void ArmDynarmic64::MakeJit(Common::PageTable* page_table, std::size_t address_s config.enable_cycle_counting = !m_uses_wall_clock; // Code cache size -#if defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) +#if defined(__OPENORBIS__) + config.code_cache_size = std::uint32_t(32_MiB); +#elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else config.code_cache_size = std::uint32_t(512_MiB); diff --git a/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.h b/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.h index 8e97dc7737..6e6147e855 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.h +++ b/src/dynarmic/src/dynarmic/backend/x64/a32_emit_x64.h @@ -66,8 +66,14 @@ public: const void* code_ptr = nullptr; }; static_assert(sizeof(FastDispatchEntry) == 0x10); +#ifdef __OPENORBIS__ + static constexpr u64 fast_dispatch_table_mask = 0xFF0; + static constexpr size_t fast_dispatch_table_size = 0x100; +#else static constexpr u64 fast_dispatch_table_mask = 0xFFFF0; static constexpr size_t fast_dispatch_table_size = 0x10000; +#endif + void ClearFastDispatchTable(); void GenFastmemFallbacks(); void GenTerminalHandlers(); diff --git a/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.h b/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.h index d57b1d81b9..8bf73d7bb3 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.h +++ b/src/dynarmic/src/dynarmic/backend/x64/a64_emit_x64.h @@ -59,8 +59,13 @@ public: const void* code_ptr = nullptr; }; static_assert(sizeof(FastDispatchEntry) == 0x10); +#ifdef __OPENORBIS__ + static constexpr u64 fast_dispatch_table_mask = 0xFF0; + static constexpr size_t fast_dispatch_table_size = 0x100; +#else static constexpr u64 fast_dispatch_table_mask = 0xFFFFF0; static constexpr size_t fast_dispatch_table_size = 0x100000; +#endif void ClearFastDispatchTable(); void GenMemory128Accessors(); From 3eb6a23e4250b1825ee6092d28c454be104a56d8 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 8 Jan 2026 23:12:41 +0000 Subject: [PATCH 032/108] force running services on host --- .ci/ps4/build.sh | 4 +++- src/core/hle/service/services.cpp | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 0bffdca680..a4bfc97540 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -30,6 +30,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_SIZEOF_VOID_P 8) EOF +NPROC=$(nproc || 1) + # Normally a platform has a package manager # PS4 does not, atleast not in the normal sense export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@) @@ -51,4 +53,4 @@ cmake -S . -B build -G "Unix Makefiles" \ -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit -cmake --build build -t yuzu-cmd_pkg -- -j8 +cmake --build build -t yuzu-cmd_pkg -- -j$NPROC diff --git a/src/core/hle/service/services.cpp b/src/core/hle/service/services.cpp index 636f54ad49..7d9372e694 100644 --- a/src/core/hle/service/services.cpp +++ b/src/core/hle/service/services.cpp @@ -73,6 +73,13 @@ Services::Services(std::shared_ptr& sm, Core::System& system system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); +#ifdef __OPENORBIS__ + // PS4 requires us to run this on a single thread so we don't immediately die + bool const run_on_host = false; +#else + bool const run_on_host = true; +#endif + // Just a quick C++ lesson // Capturing lambdas will silently create new variables for the objects referenced via = // and create a `auto&` sorts of for `&`; with all your usual reference shenanigans. @@ -92,9 +99,12 @@ Services::Services(std::shared_ptr& sm, Core::System& system {"Loader", &LDR::LoopProcess}, {"nvservices", &Nvidia::LoopProcess}, {"bsdsocket", &Sockets::LoopProcess}, - }) - kernel.RunOnHostCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); }).detach(); - kernel.RunOnHostCoreProcess("vi", [&, token] { VI::LoopProcess(system, token); }).detach(); + }) { + if (run_on_host) kernel.RunOnHostCoreProcess("vi", [&, token] { VI::LoopProcess(system, token); }).detach(); + else kernel.RunOnGuestCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); }); + } + if (run_on_host) kernel.RunOnHostCoreProcess("vi", [&, token] { VI::LoopProcess(system, token); }).detach(); + else kernel.RunOnGuestCoreProcess("vi", [&, token] { VI::LoopProcess(system, token); }); // Avoid cold clones of lambdas -- succintly for (auto const& e : std::vector>{ {"sm", &SM::LoopProcess}, From d37ba6f3fc610dfbbd2a73c9d3f6707f6f8db7d9 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 13 Jan 2026 08:10:02 +0000 Subject: [PATCH 033/108] add fallback buffer back --- src/common/host_memory.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/host_memory.h b/src/common/host_memory.h index 31af3cc9f1..f26804b55b 100644 --- a/src/common/host_memory.h +++ b/src/common/host_memory.h @@ -83,6 +83,9 @@ private: u8* backing_base{}; u8* virtual_base{}; size_t virtual_base_offset{}; +#ifdef __OPENORBIS__ + std::optional> fallback_buffer; +#endif }; } // namespace Common From f5b8c8077975533e54b7e10b7fdcaeb3984ef836 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 13 Jan 2026 10:42:46 +0000 Subject: [PATCH 034/108] fibers that don't immediately crash?!!?!?!!? --- src/common/fiber.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index 69eca732eb..1b201c47af 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp @@ -33,6 +33,9 @@ struct Fiber::FiberImpl { boost::context::detail::fcontext_t context{}; boost::context::detail::fcontext_t rewind_context{}; + boost::context::detail::fcontext_t context{}; + boost::context::detail::fcontext_t rewind_context{}; + std::mutex guard; std::function entry_point; std::function rewind_point; From f29f2478699cb109f5d5ff2207b60527ad4f134f Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 13 Jan 2026 10:42:57 +0000 Subject: [PATCH 035/108] fix atexit impl --- src/yuzu_cmd/yuzu.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 48028459d9..6724ff59b9 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -57,7 +57,9 @@ #include #include <__thread/support.h> # define STUB_WEAK(name) extern "C" void name() { printf("called " #name); asm volatile("ud2"); } -void *__cxa_thread_atexit_impl = nullptr; +extern "C" void __cxa_thread_atexit_impl() { + //printf("atexit called"); +} STUB_WEAK(__assert) STUB_WEAK(ZSTD_trace_compress_begin) STUB_WEAK(ZSTD_trace_compress_end) From 876a8825e3b67826336b1fb0a0e38432e57f19ba Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 13 Jan 2026 11:26:30 +0000 Subject: [PATCH 036/108] more inline pt2 --- .../service/ns/platform_service_manager.cpp | 62 ++++++++----------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/src/core/hle/service/ns/platform_service_manager.cpp b/src/core/hle/service/ns/platform_service_manager.cpp index bf93a2edfa..4ce8e1c6ef 100644 --- a/src/core/hle/service/ns/platform_service_manager.cpp +++ b/src/core/hle/service/ns/platform_service_manager.cpp @@ -34,10 +34,10 @@ struct FontRegion { // The below data is specific to shared font data dumped from Switch on f/w 2.2 // Virtual address and offsets/sizes likely will vary by dump -[[maybe_unused]] constexpr VAddr SHARED_FONT_MEM_VADDR{0x00000009d3016000ULL}; -constexpr u32 EXPECTED_RESULT{0x7f9a0218}; // What we expect the decrypted bfttf first 4 bytes to be -constexpr u32 EXPECTED_MAGIC{0x36f81a1e}; // What we expect the encrypted bfttf first 4 bytes to be -constexpr u64 SHARED_FONT_MEM_SIZE{0x1100000}; +[[maybe_unused]] constexpr VAddr SHARED_FONT_MEM_VADDR = 0x00000009d3016000ULL; +constexpr u32 EXPECTED_RESULT = 0x7f9a0218; // What we expect the decrypted bfttf first 4 bytes to be +constexpr u32 EXPECTED_MAGIC = 0x36f81a1e; // What we expect the encrypted bfttf first 4 bytes to be +constexpr u64 SHARED_FONT_MEM_SIZE = 0x1100000; constexpr FontRegion EMPTY_REGION{0, 0}; static void DecryptSharedFont(const std::span input, std::span output, std::size_t& offset) { @@ -70,7 +70,7 @@ void EncryptSharedFont(const std::vector& input, std::vector& output, s const auto key = Common::swap32(EXPECTED_RESULT ^ EXPECTED_MAGIC); std::vector transformed_font(input.size() + 2); transformed_font[0] = Common::swap32(EXPECTED_MAGIC); - transformed_font[1] = Common::swap32(static_cast(input.size() * sizeof(u32))) ^ key; + transformed_font[1] = Common::swap32(u32(input.size() * sizeof(u32))) ^ key; std::transform(input.begin(), input.end(), transformed_font.begin() + 2, [key](u32 in) { return in ^ key; }); std::memcpy(output.data() + offset, transformed_font.data(), transformed_font.size() * sizeof(u32)); offset += transformed_font.size() * sizeof(u32); @@ -119,40 +119,30 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch // Rebuild shared fonts from data ncas or synthesize for (auto& font : SHARED_FONTS) { FileSys::VirtualFile romfs; - const auto nca = - nand->GetEntry(static_cast(font.first), FileSys::ContentRecordType::Data); - if (nca) { + if (auto const nca = nand->GetEntry(u64(font.first), FileSys::ContentRecordType::Data); nca) romfs = nca->GetRomFS(); - } - - if (!romfs) { - romfs = FileSys::SystemArchive::SynthesizeSystemArchive(static_cast(font.first)); - } - - if (!romfs) { + if (!romfs) + romfs = FileSys::SystemArchive::SynthesizeSystemArchive(u64(font.first)); + if (romfs) { + if (auto const extracted_romfs = FileSys::ExtractRomFS(romfs); extracted_romfs) { + if (auto const font_fp = extracted_romfs->GetFile(font.second); font_fp) { + std::vector font_data_u32(font_fp->GetSize() / sizeof(u32)); + font_fp->ReadBytes(font_data_u32.data(), font_fp->GetSize()); + // We need to be BigEndian as u32s for the xor encryption + std::transform(font_data_u32.begin(), font_data_u32.end(), font_data_u32.begin(), Common::swap32); + // Font offset and size do not account for the header + const FontRegion region{u32(offset + 8), u32((font_data_u32.size() * sizeof(u32)) - 8)}; + DecryptSharedFont(font_data_u32, impl->shared_font, offset); + impl->shared_font_regions.push_back(region); + } else { + LOG_ERROR(Service_NS, "{:016X} has no file \"{}\"! Skipping", font.first, font.second); + } + } else { + LOG_ERROR(Service_NS, "Failed to extract RomFS for {:016X}! Skipping", font.first); + } + } else { LOG_ERROR(Service_NS, "Failed to find or synthesize {:016X}! Skipping", font.first); - continue; } - - const auto extracted_romfs = FileSys::ExtractRomFS(romfs); - if (!extracted_romfs) { - LOG_ERROR(Service_NS, "Failed to extract RomFS for {:016X}! Skipping", font.first); - continue; - } - const auto font_fp = extracted_romfs->GetFile(font.second); - if (!font_fp) { - LOG_ERROR(Service_NS, "{:016X} has no file \"{}\"! Skipping", font.first, font.second); - continue; - } - std::vector font_data_u32(font_fp->GetSize() / sizeof(u32)); - font_fp->ReadBytes(font_data_u32.data(), font_fp->GetSize()); - // We need to be BigEndian as u32s for the xor encryption - std::transform(font_data_u32.begin(), font_data_u32.end(), font_data_u32.begin(), - Common::swap32); - // Font offset and size do not account for the header - const FontRegion region{u32(offset + 8), u32((font_data_u32.size() * sizeof(u32)) - 8)}; - DecryptSharedFont(font_data_u32, impl->shared_font, offset); - impl->shared_font_regions.push_back(region); } } From f25cf4a024ad4f2992951a31a4844747af9c6379 Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 16 Jan 2026 08:46:20 +0000 Subject: [PATCH 037/108] extra buffer precautions to not exhaust DMem, format better + perf history nerf --- src/common/fiber.cpp | 3 --- src/common/virtual_buffer.cpp | 40 +++++++++++------------------------ src/core/perf_stats.h | 4 ++++ 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index 1b201c47af..69eca732eb 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp @@ -33,9 +33,6 @@ struct Fiber::FiberImpl { boost::context::detail::fcontext_t context{}; boost::context::detail::fcontext_t rewind_context{}; - boost::context::detail::fcontext_t context{}; - boost::context::detail::fcontext_t rewind_context{}; - std::mutex guard; std::function entry_point; std::function rewind_point; diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 407bf2e157..5b9764d236 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -111,15 +111,15 @@ static void SwapHandler(int sig, void* raw_context) { if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second; }); it != swap_regions.end()) { - size_t const page_size = 4096 * 8; + size_t const page_size = 4096 * 4; //16K size_t const page_mask = ~(page_size - 1); // should replace the existing mapping... ugh void* aligned_addr = reinterpret_cast(uintptr_t(mctx.mc_addr) & page_mask); void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); if (res == MAP_FAILED) { - LOG_ERROR(HW_Memory, "FAIL mapped addr {},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second); + LOG_ERROR(HW_Memory, "{},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second); } else { - LOG_INFO(HW_Memory, "OK mapped addr {},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second); + LOG_TRACE(HW_Memory, "{},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second); } } else { LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address @@ -133,36 +133,20 @@ void InitSwap() noexcept { void InitSwap() noexcept {} #endif -static const char *swapfile_names[] { - "/data/eden/games/swap0.bin", - "/data/eden/games/swap1.bin", - "/data/eden/games/swap2.bin", - "/data/eden/games/swap3.bin", - "/data/eden/games/swap4.bin" -}; -static size_t swapfile_count = 0; - void* AllocateMemoryPages(std::size_t size) noexcept { #ifdef _WIN32 void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); ASSERT(addr != nullptr); #elif defined(__OPENORBIS__) - void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - if (addr == MAP_FAILED) { - LOG_WARNING(HW_Memory, "failed to mmap({} bytes) using swapfile {}", size, swapfile_names[swapfile_count]); - // int fd = open(swapfile_names[swapfile_count], O_TRUNC | O_RDWR | O_CREAT, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); - // ASSERT(fd > 0); - // ftruncate(fd, size); - // addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); - // ASSERT(addr != MAP_FAILED); - // ++swapfile_count; - - addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); - ASSERT(addr != MAP_FAILED); - swap_regions.emplace_back(addr, size); - } else { - LOG_INFO(HW_Memory, "mmap {} bytes", size); - } + // void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); + // if (addr == MAP_FAILED) { + LOG_WARNING(HW_Memory, "Using VoidMem for {}B area", size); + void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); + ASSERT(addr != MAP_FAILED); + swap_regions.emplace_back(addr, size); + // } else { + // LOG_INFO(HW_Memory, "mmap {} bytes", size); + // } #else void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index dd6becc02d..92910a959f 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -60,7 +60,11 @@ private: std::size_t current_index{0}; /// Stores an hour of historical frametime data useful for processing and tracking performance /// regressions with code changes. +#ifdef __OPENORBIS__ + std::array perf_history{}; +#else std::array perf_history{}; +#endif /// Point when the cumulative counters were reset Clock::time_point reset_point = Clock::now(); From d88a1518cd6bb6b411cc5d50271f8aed419127e0 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 17 Jan 2026 00:52:51 +0000 Subject: [PATCH 038/108] reduce arm codeisze, force 16x4 pages again --- src/common/virtual_buffer.cpp | 36 +++++++++++++++-------- src/core/arm/dynarmic/arm_dynarmic_32.cpp | 2 +- src/core/arm/dynarmic/arm_dynarmic_64.cpp | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 5b9764d236..f3a3a695e0 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -105,21 +105,24 @@ struct Ucontext { } static boost::container::static_vector, 16> swap_regions; +static std::mutex evil_swap_mutex; extern "C" int sceKernelRemoveExceptionHandler(s32 sig_num); static void SwapHandler(int sig, void* raw_context) { + std::unique_lock lk{evil_swap_mutex}; auto& mctx = ((Orbis::Ucontext*)raw_context)->uc_mcontext; if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second; }); it != swap_regions.end()) { - size_t const page_size = 4096 * 4; //16K + size_t const page_size = 4096 * 8; //16K size_t const page_mask = ~(page_size - 1); // should replace the existing mapping... ugh void* aligned_addr = reinterpret_cast(uintptr_t(mctx.mc_addr) & page_mask); void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0); if (res == MAP_FAILED) { - LOG_ERROR(HW_Memory, "{},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second); + LOG_ERROR(HW_Memory, "{:#x},{} @ {}:{:#x}", mctx.mc_addr, aligned_addr, it->first, it->second); + sceKernelRemoveExceptionHandler(SIGSEGV); // to not catch the next signal } else { - LOG_TRACE(HW_Memory, "{},{} @ {}:{}", mctx.mc_addr, aligned_addr, it->first, it->second); + LOG_TRACE(HW_Memory, "{:#x},{} @ {}:{:#x}", mctx.mc_addr, aligned_addr, it->first, it->second); } } else { LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address @@ -138,15 +141,17 @@ void* AllocateMemoryPages(std::size_t size) noexcept { void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); ASSERT(addr != nullptr); #elif defined(__OPENORBIS__) - // void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - // if (addr == MAP_FAILED) { - LOG_WARNING(HW_Memory, "Using VoidMem for {}B area", size); - void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); - ASSERT(addr != MAP_FAILED); - swap_regions.emplace_back(addr, size); - // } else { - // LOG_INFO(HW_Memory, "mmap {} bytes", size); - // } + void* addr; + if (size <= 8192 * 4096) { + addr = malloc(size); + LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", size, addr); + ASSERT(addr != nullptr); + } else { + addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); + LOG_WARNING(HW_Memory, "Using VoidMem for {} bytes area @ {}", size, addr); + ASSERT(addr != MAP_FAILED); + swap_regions.emplace_back(addr, size); + } #else void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); ASSERT(addr != MAP_FAILED); @@ -159,6 +164,13 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { return; #ifdef _WIN32 VirtualFree(addr, 0, MEM_RELEASE); +#elif defined(__OPENORBIS__) + if (size <= 8192 * 4096) { + free(addr); + } else { + int rc = munmap(addr, size); + ASSERT(rc == 0); + } #else int rc = munmap(addr, size); ASSERT(rc == 0); diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 78b1dc20a8..bf473eb07b 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -200,7 +200,7 @@ void ArmDynarmic32::MakeJit(Common::PageTable* page_table) { // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(32_MiB); + config.code_cache_size = std::uint32_t(8_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index c831e3c9da..88bd0cfad9 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -253,7 +253,7 @@ void ArmDynarmic64::MakeJit(Common::PageTable* page_table, std::size_t address_s // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(32_MiB); + config.code_cache_size = std::uint32_t(8_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else From 77cc5fea6f5acc20a8e26529d9457787295df183 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 18 Jan 2026 16:33:17 +0000 Subject: [PATCH 039/108] add emutls.c --- src/yuzu_cmd/CMakeLists.txt | 4 +- src/yuzu_cmd/emutls.c | 181 ++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 src/yuzu_cmd/emutls.c diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index d4e431d70a..c1d742c3ba 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -34,6 +34,7 @@ add_executable(yuzu-cmd sdl_config.cpp sdl_config.h yuzu.cpp + emutls.c yuzu.rc ${OPENGL_SOURCES} ) @@ -79,5 +80,6 @@ if (NOT MSVC) endif() if (PLATFORM_PS4) - create_ps4_pkg(yuzu-cmd eden-cli IV0000-BREW00090_00-EDENEMULAT000000) + create_ps4_eboot(yuzu-cmd eden-cli IV0000-BREW00090_00-EDENEMULAT000000) + #create_ps4_pkg(yuzu-cmd eden-cli IV0000-BREW00090_00-EDENEMULAT000000) endif() diff --git a/src/yuzu_cmd/emutls.c b/src/yuzu_cmd/emutls.c new file mode 100644 index 0000000000..3b0a0cc909 --- /dev/null +++ b/src/yuzu_cmd/emutls.c @@ -0,0 +1,181 @@ +/* ===---------- emutls.c - Implements __emutls_get_address ---------------=== + * + * The LLVM Compiler Infrastructure + * + * This file is dual licensed under the MIT and the University of Illinois Open + * Source Licenses. See LICENSE.TXT for details. + * + * ===----------------------------------------------------------------------=== + */ +#include +#include +#include +#include + +//#include "int_util.h" + +/* Default is not to use posix_memalign, so systems like Android + * can use thread local data without heavier POSIX memory allocators. + */ +#ifndef EMUTLS_USE_POSIX_MEMALIGN +#define EMUTLS_USE_POSIX_MEMALIGN 0 +#endif + +/* For every TLS variable xyz, + * there is one __emutls_control variable named __emutls_v.xyz. + * If xyz has non-zero initial value, __emutls_v.xyz's "value" + * will point to __emutls_t.xyz, which has the initial value. + */ +typedef struct __emutls_control { + size_t size; /* size of the object in bytes */ + size_t align; /* alignment of the object in bytes */ + union { + uintptr_t index; /* data[index-1] is the object address */ + void* address; /* object address, when in single thread env */ + } object; + void* value; /* null or non-zero initial value for the object */ +} __emutls_control; + +static inline void* emutls_memalign_alloc(size_t align, size_t size) { + void *base; +#if EMUTLS_USE_POSIX_MEMALIGN + if (posix_memalign(&base, align, size) != 0) + abort(); +#else + #define EXTRA_ALIGN_PTR_BYTES (align - 1 + sizeof(void*)) + char* object; + if ((object = malloc(EXTRA_ALIGN_PTR_BYTES + size)) == NULL) + abort(); + base = (void*)(((uintptr_t)(object + EXTRA_ALIGN_PTR_BYTES)) + & ~(uintptr_t)(align - 1)); + + ((void**)base)[-1] = object; +#endif + return base; +} + +static inline void emutls_memalign_free(void* base) { +#if EMUTLS_USE_POSIX_MEMALIGN + free(base); +#else + /* The mallocated address is in ((void**)base)[-1] */ + free(((void**)base)[-1]); +#endif +} + +/* Emulated TLS objects are always allocated at run-time. */ +static inline void* emutls_allocate_object(__emutls_control* control) { + /* Use standard C types, check with gcc's emutls.o. */ + //typedef unsigned int gcc_word __attribute__((mode(word))); + //typedef unsigned int gcc_pointer __attribute__((mode(pointer))); + //COMPILE_TIME_ASSERT(sizeof(size_t) == sizeof(gcc_word)); + //COMPILE_TIME_ASSERT(sizeof(uintptr_t) == sizeof(gcc_pointer)); + //COMPILE_TIME_ASSERT(sizeof(uintptr_t) == sizeof(void*)); + + size_t size = control->size; + size_t align = control->align; + if (align < sizeof(void*)) + align = sizeof(void*); + /* Make sure that align is power of 2. */ + if ((align & (align - 1)) != 0) + abort(); + + void* base = emutls_memalign_alloc(align, size); + if (control->value) + memcpy(base, control->value, size); + else + memset(base, 0, size); + return base; +} + +static pthread_mutex_t emutls_mutex = PTHREAD_MUTEX_INITIALIZER; + +static size_t emutls_num_object = 0; /* number of allocated TLS objects */ + +typedef struct emutls_address_array { + uintptr_t size; /* number of elements in the 'data' array */ + void* data[]; +} emutls_address_array; + +static pthread_key_t emutls_pthread_key; + +static void emutls_key_destructor(void* ptr) { + emutls_address_array* array = (emutls_address_array*)ptr; + uintptr_t i; + for (i = 0; i < array->size; ++i) { + if (array->data[i]) + emutls_memalign_free(array->data[i]); + } + free(ptr); +} + +static void emutls_init(void) { + if (pthread_key_create(&emutls_pthread_key, emutls_key_destructor) != 0) + abort(); +} + +/* Returns control->object.index; set index if not allocated yet. */ +static inline uintptr_t emutls_get_index(__emutls_control* control) { + uintptr_t index = __atomic_load_n(&control->object.index, __ATOMIC_ACQUIRE); + if (!index) { + static pthread_once_t once = PTHREAD_ONCE_INIT; + pthread_once(&once, emutls_init); + pthread_mutex_lock(&emutls_mutex); + index = control->object.index; + if (!index) { + index = ++emutls_num_object; + __atomic_store_n(&control->object.index, index, __ATOMIC_RELEASE); + } + pthread_mutex_unlock(&emutls_mutex); + } + return index; +} + +/* Updates newly allocated thread local emutls_address_array. */ +static inline void emutls_check_array_set_size(emutls_address_array* array, + uintptr_t size) { + if (array == NULL) + abort(); + array->size = size; + pthread_setspecific(emutls_pthread_key, (void*)array); +} + +/* Returns the new 'data' array size, number of elements, + * which must be no smaller than the given index. + */ +static inline uintptr_t emutls_new_data_array_size(uintptr_t index) { + /* Need to allocate emutls_address_array with one extra slot + * to store the data array size. + * Round up the emutls_address_array size to multiple of 16. + */ + return ((index + 1 + 15) & ~((uintptr_t)15)) - 1; +} + +/* Returns the thread local emutls_address_array. + * Extends its size if necessary to hold address at index. + */ +static inline emutls_address_array* emutls_get_address_array(uintptr_t index) { + emutls_address_array* array = pthread_getspecific(emutls_pthread_key); + if (array == NULL) { + uintptr_t new_size = emutls_new_data_array_size(index); + array = calloc(new_size + 1, sizeof(void*)); + emutls_check_array_set_size(array, new_size); + } else if (index > array->size) { + uintptr_t orig_size = array->size; + uintptr_t new_size = emutls_new_data_array_size(index); + array = realloc(array, (new_size + 1) * sizeof(void*)); + if (array) + memset(array->data + orig_size, 0, + (new_size - orig_size) * sizeof(void*)); + emutls_check_array_set_size(array, new_size); + } + return array; +} + +void* __emutls_get_address(__emutls_control* control) { + uintptr_t index = emutls_get_index(control); + emutls_address_array* array = emutls_get_address_array(index); + if (array->data[index - 1] == NULL) + array->data[index - 1] = emutls_allocate_object(control); + return array->data[index - 1]; +} From f554c9e741fae833aa912f277a5ac4481910204e Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 18 Jan 2026 16:33:50 +0000 Subject: [PATCH 040/108] temp fix for dpad --- .../service/ns/platform_service_manager.cpp | 9 ++++++- src/hid_core/resource_manager.cpp | 26 +++++++++---------- .../resources/abstracted_pad/abstract_pad.cpp | 2 +- .../resources/debug_pad/debug_pad.cpp | 2 +- .../resources/digitizer/digitizer.cpp | 2 +- src/hid_core/resources/keyboard/keyboard.cpp | 2 +- src/hid_core/resources/mouse/debug_mouse.cpp | 2 +- src/hid_core/resources/mouse/mouse.cpp | 2 +- src/hid_core/resources/npad/npad.cpp | 11 ++++---- .../resources/six_axis/console_six_axis.cpp | 2 +- src/hid_core/resources/six_axis/six_axis.cpp | 2 +- .../system_buttons/capture_button.cpp | 2 +- .../resources/system_buttons/home_button.cpp | 2 +- .../resources/system_buttons/sleep_button.cpp | 2 +- .../touch_screen/touch_screen_resource.cpp | 14 +++++----- 15 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/core/hle/service/ns/platform_service_manager.cpp b/src/core/hle/service/ns/platform_service_manager.cpp index 4ce8e1c6ef..64f0fab454 100644 --- a/src/core/hle/service/ns/platform_service_manager.cpp +++ b/src/core/hle/service/ns/platform_service_manager.cpp @@ -40,6 +40,7 @@ constexpr u32 EXPECTED_MAGIC = 0x36f81a1e; // What we expect the encrypted bftt constexpr u64 SHARED_FONT_MEM_SIZE = 0x1100000; constexpr FontRegion EMPTY_REGION{0, 0}; +#ifndef __OPENORBIS__ static void DecryptSharedFont(const std::span input, std::span output, std::size_t& offset) { ASSERT(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE && "Shared fonts exceeds 17mb!"); ASSERT(input[0] == EXPECTED_MAGIC && "Failed to derive key, unexpected magic number"); @@ -51,6 +52,7 @@ static void DecryptSharedFont(const std::span input, std::span ou std::memcpy(output.data() + offset, transformed_font.data(), transformed_font.size() * sizeof(u32)); offset += transformed_font.size() * sizeof(u32); } +#endif void DecryptSharedFontToTTF(const std::vector& input, std::vector& output) { ASSERT_MSG(input[0] == EXPECTED_MAGIC, "Failed to derive key, unexpected magic number"); @@ -83,8 +85,10 @@ struct IPlatformServiceManager::Impl { // Automatically populated based on shared_fonts dump or system archives. // 6 builtin fonts + extra 2 for whatever may come after boost::container::static_vector shared_font_regions; +#ifndef __OPENORBIS__ /// Backing memory for the shared font data std::array shared_font; +#endif }; IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const char* service_name_) @@ -111,8 +115,8 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch // clang-format on RegisterHandlers(functions); +#ifndef __OPENORBIS__ auto& fsc = system.GetFileSystemController(); - // Attempt to load shared font data from disk const auto* nand = fsc.GetSystemNANDContents(); std::size_t offset = 0; @@ -144,6 +148,7 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch LOG_ERROR(Service_NS, "Failed to find or synthesize {:016X}! Skipping", font.first); } } +#endif } IPlatformServiceManager::~IPlatformServiceManager() = default; @@ -177,8 +182,10 @@ Result IPlatformServiceManager::GetSharedMemoryNativeHandle(OutCopyHandleshared_font.data(), impl->shared_font.size()); +#endif // FIXME: this shouldn't belong to the kernel *out_shared_memory_native_handle = &kernel.GetFontSharedMem(); diff --git a/src/hid_core/resource_manager.cpp b/src/hid_core/resource_manager.cpp index 0c10d1bec9..f5a09a6537 100644 --- a/src/hid_core/resource_manager.cpp +++ b/src/hid_core/resource_manager.cpp @@ -204,7 +204,7 @@ Result ResourceManager::CreateAppletResource(u64 aruid) { } Result ResourceManager::CreateAppletResourceImpl(u64 aruid) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; return applet_resource->CreateAppletResource(aruid); } @@ -294,17 +294,17 @@ void ResourceManager::InitializeAHidSampler() { } Result ResourceManager::RegisterCoreAppletResource() { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; return applet_resource->RegisterCoreAppletResource(); } Result ResourceManager::UnregisterCoreAppletResource() { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; return applet_resource->UnregisterCoreAppletResource(); } Result ResourceManager::RegisterAppletResourceUserId(u64 aruid, bool bool_value) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; auto result = applet_resource->RegisterAppletResourceUserId(aruid, bool_value); if (result.IsSuccess()) { result = npad->RegisterAppletResourceUserId(aruid); @@ -313,40 +313,40 @@ Result ResourceManager::RegisterAppletResourceUserId(u64 aruid, bool bool_value) } void ResourceManager::UnregisterAppletResourceUserId(u64 aruid) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; applet_resource->UnregisterAppletResourceUserId(aruid); npad->UnregisterAppletResourceUserId(aruid); // palma->UnregisterAppletResourceUserId(aruid); } Result ResourceManager::GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, u64 aruid) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; return applet_resource->GetSharedMemoryHandle(out_handle, aruid); } void ResourceManager::FreeAppletResourceId(u64 aruid) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; applet_resource->FreeAppletResourceId(aruid); npad->FreeAppletResourceId(aruid); } void ResourceManager::EnableInput(u64 aruid, bool is_enabled) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; applet_resource->EnableInput(aruid, is_enabled); } void ResourceManager::EnableSixAxisSensor(u64 aruid, bool is_enabled) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; applet_resource->EnableSixAxisSensor(aruid, is_enabled); } void ResourceManager::EnablePadInput(u64 aruid, bool is_enabled) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; applet_resource->EnablePadInput(aruid, is_enabled); } void ResourceManager::EnableTouchScreen(u64 aruid, bool is_enabled) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; applet_resource->EnableTouchScreen(aruid, is_enabled); } @@ -371,7 +371,7 @@ NpadGcVibrationDevice* ResourceManager::GetGcVibrationDevice( } Result ResourceManager::SetAruidValidForVibration(u64 aruid, bool is_enabled) { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; const bool has_changed = applet_resource->SetAruidValidForVibration(aruid, is_enabled); if (has_changed) { @@ -394,7 +394,7 @@ void ResourceManager::SetForceHandheldStyleVibration(bool is_forced) { } Result ResourceManager::IsVibrationAruidActive(u64 aruid, bool& is_active) const { - std::scoped_lock lock{shared_mutex}; + //std::scoped_lock lock{shared_mutex}; is_active = applet_resource->IsVibrationAruidActive(aruid); return ResultSuccess; } diff --git a/src/hid_core/resources/abstracted_pad/abstract_pad.cpp b/src/hid_core/resources/abstracted_pad/abstract_pad.cpp index d7cf2bba9b..8ba67f131e 100644 --- a/src/hid_core/resources/abstracted_pad/abstract_pad.cpp +++ b/src/hid_core/resources/abstracted_pad/abstract_pad.cpp @@ -273,7 +273,7 @@ void AbstractPad::Update() { interface_type = properties_handler.GetInterfaceType(); - std::scoped_lock lock{*applet_resource_holder->shared_mutex}; + //std::scoped_lock lock{*applet_resource_holder->shared_mutex}; properties_handler.UpdateAllDeviceProperties(); battery_handler.UpdateCoreBatteryState(); button_handler.UpdateCoreBatteryState(); diff --git a/src/hid_core/resources/debug_pad/debug_pad.cpp b/src/hid_core/resources/debug_pad/debug_pad.cpp index 1102dad6c9..99c35d7687 100644 --- a/src/hid_core/resources/debug_pad/debug_pad.cpp +++ b/src/hid_core/resources/debug_pad/debug_pad.cpp @@ -23,7 +23,7 @@ void DebugPad::OnInit() {} void DebugPad::OnRelease() {} void DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/digitizer/digitizer.cpp b/src/hid_core/resources/digitizer/digitizer.cpp index 5d7dcadfe3..7bb5a43376 100644 --- a/src/hid_core/resources/digitizer/digitizer.cpp +++ b/src/hid_core/resources/digitizer/digitizer.cpp @@ -17,7 +17,7 @@ void Digitizer::OnInit() {} void Digitizer::OnRelease() {} void Digitizer::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/keyboard/keyboard.cpp b/src/hid_core/resources/keyboard/keyboard.cpp index 340e8a65ce..96b6ad067f 100644 --- a/src/hid_core/resources/keyboard/keyboard.cpp +++ b/src/hid_core/resources/keyboard/keyboard.cpp @@ -22,7 +22,7 @@ void Keyboard::OnInit() {} void Keyboard::OnRelease() {} void Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/mouse/debug_mouse.cpp b/src/hid_core/resources/mouse/debug_mouse.cpp index 5f6f6e8e1a..313e8ef415 100644 --- a/src/hid_core/resources/mouse/debug_mouse.cpp +++ b/src/hid_core/resources/mouse/debug_mouse.cpp @@ -21,7 +21,7 @@ void DebugMouse::OnInit() {} void DebugMouse::OnRelease() {} void DebugMouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/mouse/mouse.cpp b/src/hid_core/resources/mouse/mouse.cpp index 53a8938a1b..4531d8a6cd 100644 --- a/src/hid_core/resources/mouse/mouse.cpp +++ b/src/hid_core/resources/mouse/mouse.cpp @@ -21,7 +21,7 @@ void Mouse::OnInit() {} void Mouse::OnRelease() {} void Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index 3a191f4539..15cb62e7b0 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp @@ -74,7 +74,7 @@ Result NPad::Activate() { Result NPad::Activate(u64 aruid) { std::scoped_lock lock{mutex}; - std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; + //std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; auto* data = applet_resource_holder.applet_resource->GetAruidData(aruid); const auto aruid_index = applet_resource_holder.applet_resource->GetIndexFromAruid(aruid); @@ -400,7 +400,7 @@ void NPad::WriteEmptyEntry(NpadInternalState* npad) { } void NPad::RequestPadStateUpdate(u64 aruid, Core::HID::NpadIdType npad_id) { - std::scoped_lock lock{*applet_resource_holder.shared_mutex}; + //std::scoped_lock lock{*applet_resource_holder.shared_mutex}; auto& controller = GetControllerFromNpadIdType(aruid, npad_id); const auto controller_type = controller.device->GetNpadStyleIndex(); @@ -473,7 +473,7 @@ void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { return; } - std::scoped_lock lock{*applet_resource_holder.shared_mutex}; + //std::scoped_lock lock{*applet_resource_holder.shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) { const auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index); @@ -1231,7 +1231,7 @@ Result NPad::SetNpadSystemExtStateEnabled(u64 aruid, bool is_enabled) { const auto result = npad_resource.SetNpadSystemExtStateEnabled(aruid, is_enabled); if (result.IsSuccess()) { - std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; + //std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; // TODO: abstracted_pad->EnableAppletToGetInput(aruid); } @@ -1349,8 +1349,7 @@ void NPad::UpdateHandheldAbstractState() { void NPad::EnableAppletToGetInput(u64 aruid) { std::scoped_lock lock{mutex}; - std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; - + //std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; for (auto& abstract_pad : abstracted_pads) { abstract_pad.EnableAppletToGetInput(aruid); } diff --git a/src/hid_core/resources/six_axis/console_six_axis.cpp b/src/hid_core/resources/six_axis/console_six_axis.cpp index 4f733cc76f..85c45a2d6d 100644 --- a/src/hid_core/resources/six_axis/console_six_axis.cpp +++ b/src/hid_core/resources/six_axis/console_six_axis.cpp @@ -20,7 +20,7 @@ void ConsoleSixAxis::OnInit() {} void ConsoleSixAxis::OnRelease() {} void ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/six_axis/six_axis.cpp b/src/hid_core/resources/six_axis/six_axis.cpp index b407a5c76e..2624deaf6f 100644 --- a/src/hid_core/resources/six_axis/six_axis.cpp +++ b/src/hid_core/resources/six_axis/six_axis.cpp @@ -27,7 +27,7 @@ void SixAxis::OnInit() {} void SixAxis::OnRelease() {} void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) { const auto* data = applet_resource->GetAruidDataByIndex(aruid_index); diff --git a/src/hid_core/resources/system_buttons/capture_button.cpp b/src/hid_core/resources/system_buttons/capture_button.cpp index 95eb604241..411f4808a0 100644 --- a/src/hid_core/resources/system_buttons/capture_button.cpp +++ b/src/hid_core/resources/system_buttons/capture_button.cpp @@ -19,7 +19,7 @@ void CaptureButton::OnInit() {} void CaptureButton::OnRelease() {} void CaptureButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/system_buttons/home_button.cpp b/src/hid_core/resources/system_buttons/home_button.cpp index f665338f32..cacfb221e2 100644 --- a/src/hid_core/resources/system_buttons/home_button.cpp +++ b/src/hid_core/resources/system_buttons/home_button.cpp @@ -19,7 +19,7 @@ void HomeButton::OnInit() {} void HomeButton::OnRelease() {} void HomeButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/system_buttons/sleep_button.cpp b/src/hid_core/resources/system_buttons/sleep_button.cpp index 1596632465..6649594ef0 100644 --- a/src/hid_core/resources/system_buttons/sleep_button.cpp +++ b/src/hid_core/resources/system_buttons/sleep_button.cpp @@ -17,7 +17,7 @@ void SleepButton::OnInit() {} void SleepButton::OnRelease() {} void SleepButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - std::scoped_lock shared_lock{*shared_mutex}; + //std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp index 5d77fe5719..266acdd4c9 100644 --- a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp +++ b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp @@ -34,7 +34,7 @@ Result TouchResource::ActivateTouch() { } if (global_ref_counter == 0) { - std::scoped_lock lock{*shared_mutex}; + //std::scoped_lock lock{*shared_mutex}; const auto result = touch_driver->StartTouchSensor(); if (result.IsError()) { @@ -60,7 +60,7 @@ Result TouchResource::ActivateTouch() { } Result TouchResource::ActivateTouch(u64 aruid) { - std::scoped_lock lock{*shared_mutex}; + //std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -121,7 +121,7 @@ Result TouchResource::ActivateGesture() { } Result TouchResource::ActivateGesture(u64 aruid, u32 basic_gesture_id) { - std::scoped_lock lock{*shared_mutex}; + //std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -300,7 +300,7 @@ void TouchResource::SetTouchScreenMagnification(f32 point1_x, f32 point1_y, f32 } Result TouchResource::SetTouchScreenResolution(u32 width, u32 height, u64 aruid) { - std::scoped_lock lock{*shared_mutex}; + //std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -321,7 +321,7 @@ Result TouchResource::SetTouchScreenResolution(u32 width, u32 height, u64 aruid) Result TouchResource::SetTouchScreenConfiguration( const Core::HID::TouchScreenConfigurationForNx& touch_configuration, u64 aruid) { - std::scoped_lock lock{*shared_mutex}; + //std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -341,7 +341,7 @@ Result TouchResource::SetTouchScreenConfiguration( Result TouchResource::GetTouchScreenConfiguration( Core::HID::TouchScreenConfigurationForNx& out_touch_configuration, u64 aruid) const { - std::scoped_lock lock{*shared_mutex}; + //std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -518,7 +518,7 @@ void TouchResource::OnTouchUpdate(s64 timestamp) { gesture_handler.SetTouchState(current_touch_state.states, current_touch_state.entry_count, timestamp); - std::scoped_lock lock{*shared_mutex}; + //std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); From 6bc5efdf5e1b837c5a2f08473e06541017d4f331 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 18 Jan 2026 16:45:05 +0000 Subject: [PATCH 041/108] fix eboot --- CMakeModules/OpenOrbis.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeModules/OpenOrbis.cmake b/CMakeModules/OpenOrbis.cmake index 593c951e30..f5701ecc62 100644 --- a/CMakeModules/OpenOrbis.cmake +++ b/CMakeModules/OpenOrbis.cmake @@ -1,6 +1,19 @@ # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later +function(create_ps4_eboot project target content_id) + set(sce_sys_dir sce_sys) + set(sce_sys_param ${sce_sys_dir}/param.sfo) + add_custom_command( + OUTPUT "${target}.pkg" + COMMAND ${CMAKE_SYSROOT}/bin/create-fself -in=bin/${target} -out=${target}.oelf --eboot eboot.bin + VERBATIM + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + DEPENDS ${project} + ) + add_custom_target(${project}_pkg ALL DEPENDS "${target}.pkg") +endfunction() + function(create_ps4_pkg project target content_id) set(sce_sys_dir sce_sys) set(sce_sys_param ${sce_sys_dir}/param.sfo) From 4e003b60e9c842095635a80bd4d2bc1079380f1d Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 20 Jan 2026 00:17:46 +0000 Subject: [PATCH 042/108] bs fix --- src/hid_core/resources/debug_pad/debug_pad.cpp | 3 +++ src/hid_core/resources/digitizer/digitizer.cpp | 3 +++ src/hid_core/resources/keyboard/keyboard.cpp | 3 +++ src/hid_core/resources/mouse/debug_mouse.cpp | 3 +++ src/hid_core/resources/mouse/mouse.cpp | 3 +++ src/hid_core/resources/six_axis/console_six_axis.cpp | 3 +++ src/hid_core/resources/six_axis/six_axis.cpp | 3 +++ src/hid_core/resources/system_buttons/capture_button.cpp | 3 +++ src/hid_core/resources/system_buttons/home_button.cpp | 3 +++ src/hid_core/resources/system_buttons/sleep_button.cpp | 3 +++ 10 files changed, 30 insertions(+) diff --git a/src/hid_core/resources/debug_pad/debug_pad.cpp b/src/hid_core/resources/debug_pad/debug_pad.cpp index 99c35d7687..89e5ce86e6 100644 --- a/src/hid_core/resources/debug_pad/debug_pad.cpp +++ b/src/hid_core/resources/debug_pad/debug_pad.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/digitizer/digitizer.cpp b/src/hid_core/resources/digitizer/digitizer.cpp index 7bb5a43376..4df72fd6d0 100644 --- a/src/hid_core/resources/digitizer/digitizer.cpp +++ b/src/hid_core/resources/digitizer/digitizer.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/keyboard/keyboard.cpp b/src/hid_core/resources/keyboard/keyboard.cpp index 96b6ad067f..d82062b3c6 100644 --- a/src/hid_core/resources/keyboard/keyboard.cpp +++ b/src/hid_core/resources/keyboard/keyboard.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/mouse/debug_mouse.cpp b/src/hid_core/resources/mouse/debug_mouse.cpp index 313e8ef415..28657ee2e4 100644 --- a/src/hid_core/resources/mouse/debug_mouse.cpp +++ b/src/hid_core/resources/mouse/debug_mouse.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/mouse/mouse.cpp b/src/hid_core/resources/mouse/mouse.cpp index 4531d8a6cd..05eff94093 100644 --- a/src/hid_core/resources/mouse/mouse.cpp +++ b/src/hid_core/resources/mouse/mouse.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/six_axis/console_six_axis.cpp b/src/hid_core/resources/six_axis/console_six_axis.cpp index 85c45a2d6d..f68f639bf4 100644 --- a/src/hid_core/resources/six_axis/console_six_axis.cpp +++ b/src/hid_core/resources/six_axis/console_six_axis.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/six_axis/six_axis.cpp b/src/hid_core/resources/six_axis/six_axis.cpp index 2624deaf6f..9eb06be856 100644 --- a/src/hid_core/resources/six_axis/six_axis.cpp +++ b/src/hid_core/resources/six_axis/six_axis.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/hid_core/resources/system_buttons/capture_button.cpp b/src/hid_core/resources/system_buttons/capture_button.cpp index 411f4808a0..d8afa70a58 100644 --- a/src/hid_core/resources/system_buttons/capture_button.cpp +++ b/src/hid_core/resources/system_buttons/capture_button.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/system_buttons/home_button.cpp b/src/hid_core/resources/system_buttons/home_button.cpp index cacfb221e2..084cc6ccec 100644 --- a/src/hid_core/resources/system_buttons/home_button.cpp +++ b/src/hid_core/resources/system_buttons/home_button.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/system_buttons/sleep_button.cpp b/src/hid_core/resources/system_buttons/sleep_button.cpp index 6649594ef0..5c5cc05ed5 100644 --- a/src/hid_core/resources/system_buttons/sleep_button.cpp +++ b/src/hid_core/resources/system_buttons/sleep_button.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later From 25fb1de5507509ef033536f69fdcfe4f8c19d004 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 22 Jan 2026 19:13:56 +0000 Subject: [PATCH 043/108] restore stupid lock, make ps4sup library --- CMakeModules/OpenOrbis.cmake | 6 ++--- externals/CMakeLists.txt | 3 +++ {src/yuzu_cmd => externals/ps4sup}/emutls.c | 0 externals/ps4sup/stub.cpp | 18 +++++++++++++ src/core/perf_stats.h | 3 +++ src/dynarmic/tests/CMakeLists.txt | 6 +++++ src/hid_core/resource_manager.cpp | 26 +++++++++---------- .../resources/abstracted_pad/abstract_pad.cpp | 2 +- .../resources/debug_pad/debug_pad.cpp | 2 +- .../resources/digitizer/digitizer.cpp | 2 +- src/hid_core/resources/keyboard/keyboard.cpp | 2 +- src/hid_core/resources/mouse/debug_mouse.cpp | 2 +- src/hid_core/resources/mouse/mouse.cpp | 2 +- src/hid_core/resources/npad/npad.cpp | 10 +++---- .../resources/six_axis/console_six_axis.cpp | 2 +- src/hid_core/resources/six_axis/six_axis.cpp | 2 +- .../system_buttons/capture_button.cpp | 2 +- .../resources/system_buttons/home_button.cpp | 2 +- .../resources/system_buttons/sleep_button.cpp | 2 +- .../touch_screen/touch_screen_resource.cpp | 14 +++++----- src/yuzu_cmd/CMakeLists.txt | 6 ++--- 21 files changed, 71 insertions(+), 43 deletions(-) rename {src/yuzu_cmd => externals/ps4sup}/emutls.c (100%) create mode 100644 externals/ps4sup/stub.cpp diff --git a/CMakeModules/OpenOrbis.cmake b/CMakeModules/OpenOrbis.cmake index f5701ecc62..af2e862a7e 100644 --- a/CMakeModules/OpenOrbis.cmake +++ b/CMakeModules/OpenOrbis.cmake @@ -6,7 +6,7 @@ function(create_ps4_eboot project target content_id) set(sce_sys_param ${sce_sys_dir}/param.sfo) add_custom_command( OUTPUT "${target}.pkg" - COMMAND ${CMAKE_SYSROOT}/bin/create-fself -in=bin/${target} -out=${target}.oelf --eboot eboot.bin + COMMAND ${CMAKE_SYSROOT}/bin/create-fself -in=bin/${target} -out=${target}.oelf --eboot ${target}_eboot.bin VERBATIM WORKING_DIRECTORY ${CMAKE_BINARY_DIR} DEPENDS ${project} @@ -19,7 +19,7 @@ function(create_ps4_pkg project target content_id) set(sce_sys_param ${sce_sys_dir}/param.sfo) add_custom_command( OUTPUT "${target}.pkg" - COMMAND ${CMAKE_SYSROOT}/bin/create-fself -in=bin/${target} -out=${target}.oelf --eboot eboot.bin + COMMAND ${CMAKE_SYSROOT}/bin/create-fself -in=bin/${target} -out=${target}.oelf --eboot ${target}_eboot.bin COMMAND mkdir -p ${sce_sys_dir} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_new ${sce_sys_param} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} APP_TYPE --type Integer --maxsize 4 --value 1 @@ -32,7 +32,7 @@ function(create_ps4_pkg project target content_id) COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE --type Utf8 --maxsize 128 --value ${target} COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} TITLE_ID --type Utf8 --maxsize 12 --value BREW00090 COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core sfo_setentry ${sce_sys_param} VERSION --type Utf8 --maxsize 8 --value 1.03 - COMMAND ${CMAKE_SYSROOT}/bin/create-gp4 -out ${target}.gp4 --content-id=${content_id} --files "eboot.bin ${sce_sys_param} sce_module/libc.prx sce_module/libSceFios2.prx" + COMMAND ${CMAKE_SYSROOT}/bin/create-gp4 -out ${target}.gp4 --content-id=${content_id} --files "${target}_eboot.bin ${sce_sys_param} sce_module/libc.prx sce_module/libSceFios2.prx" COMMAND ${CMAKE_SYSROOT}/bin/PkgTool.Core pkg_build ${target}.gp4 . VERBATIM WORKING_DIRECTORY ${CMAKE_BINARY_DIR} diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 13de8f567d..26bbfc9802 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -256,6 +256,9 @@ target_include_directories(tz PUBLIC ./tz) add_library(bc_decoder bc_decoder/bc_decoder.cpp) target_include_directories(bc_decoder PUBLIC ./bc_decoder) +add_library(ps4sup ps4sup/emutls.c ps4sup/stub.cpp) +target_include_directories(ps4sup PUBLIC ./ps4sup) + if (NOT TARGET RenderDoc::API) add_library(renderdoc INTERFACE) target_include_directories(renderdoc SYSTEM INTERFACE ./renderdoc) diff --git a/src/yuzu_cmd/emutls.c b/externals/ps4sup/emutls.c similarity index 100% rename from src/yuzu_cmd/emutls.c rename to externals/ps4sup/emutls.c diff --git a/externals/ps4sup/stub.cpp b/externals/ps4sup/stub.cpp new file mode 100644 index 0000000000..f422477f20 --- /dev/null +++ b/externals/ps4sup/stub.cpp @@ -0,0 +1,18 @@ +#include + +#define STUB_WEAK(name) \ + extern "C" void name() { \ + printf("called " #name); \ + asm volatile("ud2"); \ + } + +extern "C" void __cxa_thread_atexit_impl() {} + +STUB_WEAK(__assert) +STUB_WEAK(ZSTD_trace_compress_begin) +STUB_WEAK(ZSTD_trace_compress_end) +STUB_WEAK(ZSTD_trace_decompress_begin) +STUB_WEAK(ZSTD_trace_decompress_end) +FILE* __stderrp = stdout; + +#undef STUB_WEAK diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index 92910a959f..6fbf05671a 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: 2017 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/dynarmic/tests/CMakeLists.txt b/src/dynarmic/tests/CMakeLists.txt index ca44dce593..e18a5eeadb 100644 --- a/src/dynarmic/tests/CMakeLists.txt +++ b/src/dynarmic/tests/CMakeLists.txt @@ -134,3 +134,9 @@ target_compile_options(dynarmic_tests PRIVATE ${DYNARMIC_CXX_FLAGS}) target_compile_definitions(dynarmic_tests PRIVATE FMT_USE_USER_DEFINED_LITERALS=1) add_test(NAME dynarmic_tests COMMAND dynarmic_tests --durations yes) + +if (PLATFORM_PS4) + target_link_libraries(dynarmic_tests PRIVATE SceVideoOut SceAudioOut ScePad SceSystemService) + target_link_libraries(dynarmic_tests PRIVATE ps4sup) + create_ps4_eboot(dynarmic_tests dynarmic_tests IV0000-BREW00090_00-DYNARMICTS000000) +endif() diff --git a/src/hid_core/resource_manager.cpp b/src/hid_core/resource_manager.cpp index f5a09a6537..0c10d1bec9 100644 --- a/src/hid_core/resource_manager.cpp +++ b/src/hid_core/resource_manager.cpp @@ -204,7 +204,7 @@ Result ResourceManager::CreateAppletResource(u64 aruid) { } Result ResourceManager::CreateAppletResourceImpl(u64 aruid) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; return applet_resource->CreateAppletResource(aruid); } @@ -294,17 +294,17 @@ void ResourceManager::InitializeAHidSampler() { } Result ResourceManager::RegisterCoreAppletResource() { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; return applet_resource->RegisterCoreAppletResource(); } Result ResourceManager::UnregisterCoreAppletResource() { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; return applet_resource->UnregisterCoreAppletResource(); } Result ResourceManager::RegisterAppletResourceUserId(u64 aruid, bool bool_value) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; auto result = applet_resource->RegisterAppletResourceUserId(aruid, bool_value); if (result.IsSuccess()) { result = npad->RegisterAppletResourceUserId(aruid); @@ -313,40 +313,40 @@ Result ResourceManager::RegisterAppletResourceUserId(u64 aruid, bool bool_value) } void ResourceManager::UnregisterAppletResourceUserId(u64 aruid) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; applet_resource->UnregisterAppletResourceUserId(aruid); npad->UnregisterAppletResourceUserId(aruid); // palma->UnregisterAppletResourceUserId(aruid); } Result ResourceManager::GetSharedMemoryHandle(Kernel::KSharedMemory** out_handle, u64 aruid) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; return applet_resource->GetSharedMemoryHandle(out_handle, aruid); } void ResourceManager::FreeAppletResourceId(u64 aruid) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; applet_resource->FreeAppletResourceId(aruid); npad->FreeAppletResourceId(aruid); } void ResourceManager::EnableInput(u64 aruid, bool is_enabled) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; applet_resource->EnableInput(aruid, is_enabled); } void ResourceManager::EnableSixAxisSensor(u64 aruid, bool is_enabled) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; applet_resource->EnableSixAxisSensor(aruid, is_enabled); } void ResourceManager::EnablePadInput(u64 aruid, bool is_enabled) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; applet_resource->EnablePadInput(aruid, is_enabled); } void ResourceManager::EnableTouchScreen(u64 aruid, bool is_enabled) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; applet_resource->EnableTouchScreen(aruid, is_enabled); } @@ -371,7 +371,7 @@ NpadGcVibrationDevice* ResourceManager::GetGcVibrationDevice( } Result ResourceManager::SetAruidValidForVibration(u64 aruid, bool is_enabled) { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; const bool has_changed = applet_resource->SetAruidValidForVibration(aruid, is_enabled); if (has_changed) { @@ -394,7 +394,7 @@ void ResourceManager::SetForceHandheldStyleVibration(bool is_forced) { } Result ResourceManager::IsVibrationAruidActive(u64 aruid, bool& is_active) const { - //std::scoped_lock lock{shared_mutex}; + std::scoped_lock lock{shared_mutex}; is_active = applet_resource->IsVibrationAruidActive(aruid); return ResultSuccess; } diff --git a/src/hid_core/resources/abstracted_pad/abstract_pad.cpp b/src/hid_core/resources/abstracted_pad/abstract_pad.cpp index 8ba67f131e..d7cf2bba9b 100644 --- a/src/hid_core/resources/abstracted_pad/abstract_pad.cpp +++ b/src/hid_core/resources/abstracted_pad/abstract_pad.cpp @@ -273,7 +273,7 @@ void AbstractPad::Update() { interface_type = properties_handler.GetInterfaceType(); - //std::scoped_lock lock{*applet_resource_holder->shared_mutex}; + std::scoped_lock lock{*applet_resource_holder->shared_mutex}; properties_handler.UpdateAllDeviceProperties(); battery_handler.UpdateCoreBatteryState(); button_handler.UpdateCoreBatteryState(); diff --git a/src/hid_core/resources/debug_pad/debug_pad.cpp b/src/hid_core/resources/debug_pad/debug_pad.cpp index 89e5ce86e6..831bbfdd22 100644 --- a/src/hid_core/resources/debug_pad/debug_pad.cpp +++ b/src/hid_core/resources/debug_pad/debug_pad.cpp @@ -26,7 +26,7 @@ void DebugPad::OnInit() {} void DebugPad::OnRelease() {} void DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/digitizer/digitizer.cpp b/src/hid_core/resources/digitizer/digitizer.cpp index 4df72fd6d0..87ba872dd7 100644 --- a/src/hid_core/resources/digitizer/digitizer.cpp +++ b/src/hid_core/resources/digitizer/digitizer.cpp @@ -20,7 +20,7 @@ void Digitizer::OnInit() {} void Digitizer::OnRelease() {} void Digitizer::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/keyboard/keyboard.cpp b/src/hid_core/resources/keyboard/keyboard.cpp index d82062b3c6..5627d4b4aa 100644 --- a/src/hid_core/resources/keyboard/keyboard.cpp +++ b/src/hid_core/resources/keyboard/keyboard.cpp @@ -25,7 +25,7 @@ void Keyboard::OnInit() {} void Keyboard::OnRelease() {} void Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/mouse/debug_mouse.cpp b/src/hid_core/resources/mouse/debug_mouse.cpp index 28657ee2e4..eede909eea 100644 --- a/src/hid_core/resources/mouse/debug_mouse.cpp +++ b/src/hid_core/resources/mouse/debug_mouse.cpp @@ -24,7 +24,7 @@ void DebugMouse::OnInit() {} void DebugMouse::OnRelease() {} void DebugMouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/mouse/mouse.cpp b/src/hid_core/resources/mouse/mouse.cpp index 05eff94093..8b9c6a7523 100644 --- a/src/hid_core/resources/mouse/mouse.cpp +++ b/src/hid_core/resources/mouse/mouse.cpp @@ -24,7 +24,7 @@ void Mouse::OnInit() {} void Mouse::OnRelease() {} void Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index 15cb62e7b0..a3364ad219 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp @@ -74,7 +74,7 @@ Result NPad::Activate() { Result NPad::Activate(u64 aruid) { std::scoped_lock lock{mutex}; - //std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; + std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; auto* data = applet_resource_holder.applet_resource->GetAruidData(aruid); const auto aruid_index = applet_resource_holder.applet_resource->GetIndexFromAruid(aruid); @@ -400,7 +400,7 @@ void NPad::WriteEmptyEntry(NpadInternalState* npad) { } void NPad::RequestPadStateUpdate(u64 aruid, Core::HID::NpadIdType npad_id) { - //std::scoped_lock lock{*applet_resource_holder.shared_mutex}; + std::scoped_lock lock{*applet_resource_holder.shared_mutex}; auto& controller = GetControllerFromNpadIdType(aruid, npad_id); const auto controller_type = controller.device->GetNpadStyleIndex(); @@ -473,7 +473,7 @@ void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) { return; } - //std::scoped_lock lock{*applet_resource_holder.shared_mutex}; + std::scoped_lock lock{*applet_resource_holder.shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) { const auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index); @@ -1231,7 +1231,7 @@ Result NPad::SetNpadSystemExtStateEnabled(u64 aruid, bool is_enabled) { const auto result = npad_resource.SetNpadSystemExtStateEnabled(aruid, is_enabled); if (result.IsSuccess()) { - //std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; + std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; // TODO: abstracted_pad->EnableAppletToGetInput(aruid); } @@ -1349,7 +1349,7 @@ void NPad::UpdateHandheldAbstractState() { void NPad::EnableAppletToGetInput(u64 aruid) { std::scoped_lock lock{mutex}; - //std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; + std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; for (auto& abstract_pad : abstracted_pads) { abstract_pad.EnableAppletToGetInput(aruid); } diff --git a/src/hid_core/resources/six_axis/console_six_axis.cpp b/src/hid_core/resources/six_axis/console_six_axis.cpp index f68f639bf4..62d3b4ddc2 100644 --- a/src/hid_core/resources/six_axis/console_six_axis.cpp +++ b/src/hid_core/resources/six_axis/console_six_axis.cpp @@ -23,7 +23,7 @@ void ConsoleSixAxis::OnInit() {} void ConsoleSixAxis::OnRelease() {} void ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/six_axis/six_axis.cpp b/src/hid_core/resources/six_axis/six_axis.cpp index 9eb06be856..f2aadd9ed1 100644 --- a/src/hid_core/resources/six_axis/six_axis.cpp +++ b/src/hid_core/resources/six_axis/six_axis.cpp @@ -30,7 +30,7 @@ void SixAxis::OnInit() {} void SixAxis::OnRelease() {} void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) { const auto* data = applet_resource->GetAruidDataByIndex(aruid_index); diff --git a/src/hid_core/resources/system_buttons/capture_button.cpp b/src/hid_core/resources/system_buttons/capture_button.cpp index d8afa70a58..79d75f423a 100644 --- a/src/hid_core/resources/system_buttons/capture_button.cpp +++ b/src/hid_core/resources/system_buttons/capture_button.cpp @@ -22,7 +22,7 @@ void CaptureButton::OnInit() {} void CaptureButton::OnRelease() {} void CaptureButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/system_buttons/home_button.cpp b/src/hid_core/resources/system_buttons/home_button.cpp index 084cc6ccec..2edb4557c1 100644 --- a/src/hid_core/resources/system_buttons/home_button.cpp +++ b/src/hid_core/resources/system_buttons/home_button.cpp @@ -22,7 +22,7 @@ void HomeButton::OnInit() {} void HomeButton::OnRelease() {} void HomeButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/system_buttons/sleep_button.cpp b/src/hid_core/resources/system_buttons/sleep_button.cpp index 5c5cc05ed5..3ae5883bfa 100644 --- a/src/hid_core/resources/system_buttons/sleep_button.cpp +++ b/src/hid_core/resources/system_buttons/sleep_button.cpp @@ -20,7 +20,7 @@ void SleepButton::OnInit() {} void SleepButton::OnRelease() {} void SleepButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) { - //std::scoped_lock shared_lock{*shared_mutex}; + std::scoped_lock shared_lock{*shared_mutex}; const u64 aruid = applet_resource->GetActiveAruid(); auto* data = applet_resource->GetAruidData(aruid); diff --git a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp index 266acdd4c9..5d77fe5719 100644 --- a/src/hid_core/resources/touch_screen/touch_screen_resource.cpp +++ b/src/hid_core/resources/touch_screen/touch_screen_resource.cpp @@ -34,7 +34,7 @@ Result TouchResource::ActivateTouch() { } if (global_ref_counter == 0) { - //std::scoped_lock lock{*shared_mutex}; + std::scoped_lock lock{*shared_mutex}; const auto result = touch_driver->StartTouchSensor(); if (result.IsError()) { @@ -60,7 +60,7 @@ Result TouchResource::ActivateTouch() { } Result TouchResource::ActivateTouch(u64 aruid) { - //std::scoped_lock lock{*shared_mutex}; + std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -121,7 +121,7 @@ Result TouchResource::ActivateGesture() { } Result TouchResource::ActivateGesture(u64 aruid, u32 basic_gesture_id) { - //std::scoped_lock lock{*shared_mutex}; + std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -300,7 +300,7 @@ void TouchResource::SetTouchScreenMagnification(f32 point1_x, f32 point1_y, f32 } Result TouchResource::SetTouchScreenResolution(u32 width, u32 height, u64 aruid) { - //std::scoped_lock lock{*shared_mutex}; + std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -321,7 +321,7 @@ Result TouchResource::SetTouchScreenResolution(u32 width, u32 height, u64 aruid) Result TouchResource::SetTouchScreenConfiguration( const Core::HID::TouchScreenConfigurationForNx& touch_configuration, u64 aruid) { - //std::scoped_lock lock{*shared_mutex}; + std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -341,7 +341,7 @@ Result TouchResource::SetTouchScreenConfiguration( Result TouchResource::GetTouchScreenConfiguration( Core::HID::TouchScreenConfigurationForNx& out_touch_configuration, u64 aruid) const { - //std::scoped_lock lock{*shared_mutex}; + std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); @@ -518,7 +518,7 @@ void TouchResource::OnTouchUpdate(s64 timestamp) { gesture_handler.SetTouchState(current_touch_state.states, current_touch_state.entry_count, timestamp); - //std::scoped_lock lock{*shared_mutex}; + std::scoped_lock lock{*shared_mutex}; for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; aruid_index++) { const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index); diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index c1d742c3ba..e1747a91b7 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -34,7 +34,6 @@ add_executable(yuzu-cmd sdl_config.cpp sdl_config.h yuzu.cpp - emutls.c yuzu.rc ${OPENGL_SOURCES} ) @@ -45,8 +44,6 @@ if (ENABLE_OPENGL) endif() if (MSVC) target_link_libraries(yuzu-cmd PRIVATE getopt) -elseif(PLATFORM_PS4) - target_link_libraries(yuzu-cmd PRIVATE SceVideoOut SceAudioOut ScePad SceSystemService) endif() target_link_libraries(yuzu-cmd PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) @@ -80,6 +77,7 @@ if (NOT MSVC) endif() if (PLATFORM_PS4) + target_link_libraries(yuzu-cmd PRIVATE SceVideoOut SceAudioOut ScePad SceSystemService) + target_link_libraries(yuzu-cmd PRIVATE ps4sup) create_ps4_eboot(yuzu-cmd eden-cli IV0000-BREW00090_00-EDENEMULAT000000) - #create_ps4_pkg(yuzu-cmd eden-cli IV0000-BREW00090_00-EDENEMULAT000000) endif() From 708ffa6cd0b47cb57fc923245f0bd6efb3af3210 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 22 Jan 2026 19:16:13 +0000 Subject: [PATCH 044/108] update loicense --- .ci/ps4/build.sh | 1 + .ci/ps4/make-toolchain.sh | 2 +- CMakeModules/FindSDL2.cmake | 2 +- CMakeModules/OpenOrbis.cmake | 2 +- externals/ps4sup/stub.cpp | 3 +++ src/common/host_memory.h | 2 +- src/common/memory_detect.cpp | 2 +- src/common/virtual_buffer.cpp | 2 +- src/core/device_memory.h | 2 +- src/core/hle/service/services.cpp | 2 +- src/hid_core/resources/debug_pad/debug_pad.cpp | 2 +- src/hid_core/resources/digitizer/digitizer.cpp | 2 +- src/hid_core/resources/keyboard/keyboard.cpp | 2 +- src/hid_core/resources/mouse/debug_mouse.cpp | 2 +- src/hid_core/resources/mouse/mouse.cpp | 2 +- src/hid_core/resources/six_axis/console_six_axis.cpp | 2 +- src/hid_core/resources/six_axis/six_axis.cpp | 2 +- src/hid_core/resources/system_buttons/capture_button.cpp | 2 +- src/hid_core/resources/system_buttons/home_button.cpp | 2 +- src/hid_core/resources/system_buttons/sleep_button.cpp | 2 +- src/input_common/drivers/joycon.cpp | 2 +- 21 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index a4bfc97540..2bba7e185d 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -52,5 +52,6 @@ cmake -S . -B build -G "Unix Makefiles" \ -DCPMUTIL_FORCE_BUNDLED=ON \ -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ + -DDYNARMIC_TESTS=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit cmake --build build -t yuzu-cmd_pkg -- -j$NPROC diff --git a/.ci/ps4/make-toolchain.sh b/.ci/ps4/make-toolchain.sh index 7903a79169..2b4f994b79 100755 --- a/.ci/ps4/make-toolchain.sh +++ b/.ci/ps4/make-toolchain.sh @@ -1,6 +1,6 @@ #!/usr/local/bin/bash -ex -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # Define global vars diff --git a/CMakeModules/FindSDL2.cmake b/CMakeModules/FindSDL2.cmake index a7e7225dbb..b039031b4a 100644 --- a/CMakeModules/FindSDL2.cmake +++ b/CMakeModules/FindSDL2.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # Distributed under the OSI-approved BSD 3-Clause License. See accompanying diff --git a/CMakeModules/OpenOrbis.cmake b/CMakeModules/OpenOrbis.cmake index af2e862a7e..6babccdd6d 100644 --- a/CMakeModules/OpenOrbis.cmake +++ b/CMakeModules/OpenOrbis.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later function(create_ps4_eboot project target content_id) diff --git a/externals/ps4sup/stub.cpp b/externals/ps4sup/stub.cpp index f422477f20..89dc983599 100644 --- a/externals/ps4sup/stub.cpp +++ b/externals/ps4sup/stub.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + #include #define STUB_WEAK(name) \ diff --git a/src/common/host_memory.h b/src/common/host_memory.h index f26804b55b..6095230154 100644 --- a/src/common/host_memory.h +++ b/src/common/host_memory.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp index b755c1a77e..5063b28b2d 100644 --- a/src/common/memory_detect.cpp +++ b/src/common/memory_detect.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index f3a3a695e0..48f26ec298 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project diff --git a/src/core/device_memory.h b/src/core/device_memory.h index 17b585d67a..29d2ff7a2b 100644 --- a/src/core/device_memory.h +++ b/src/core/device_memory.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project diff --git a/src/core/hle/service/services.cpp b/src/core/hle/service/services.cpp index 7d9372e694..4d04b0fdf0 100644 --- a/src/core/hle/service/services.cpp +++ b/src/core/hle/service/services.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project diff --git a/src/hid_core/resources/debug_pad/debug_pad.cpp b/src/hid_core/resources/debug_pad/debug_pad.cpp index 831bbfdd22..bab49b55f8 100644 --- a/src/hid_core/resources/debug_pad/debug_pad.cpp +++ b/src/hid_core/resources/debug_pad/debug_pad.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/hid_core/resources/digitizer/digitizer.cpp b/src/hid_core/resources/digitizer/digitizer.cpp index 87ba872dd7..e158e55e6c 100644 --- a/src/hid_core/resources/digitizer/digitizer.cpp +++ b/src/hid_core/resources/digitizer/digitizer.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/hid_core/resources/keyboard/keyboard.cpp b/src/hid_core/resources/keyboard/keyboard.cpp index 5627d4b4aa..4e929e1260 100644 --- a/src/hid_core/resources/keyboard/keyboard.cpp +++ b/src/hid_core/resources/keyboard/keyboard.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/hid_core/resources/mouse/debug_mouse.cpp b/src/hid_core/resources/mouse/debug_mouse.cpp index eede909eea..e56c1de656 100644 --- a/src/hid_core/resources/mouse/debug_mouse.cpp +++ b/src/hid_core/resources/mouse/debug_mouse.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/hid_core/resources/mouse/mouse.cpp b/src/hid_core/resources/mouse/mouse.cpp index 8b9c6a7523..80de81efe4 100644 --- a/src/hid_core/resources/mouse/mouse.cpp +++ b/src/hid_core/resources/mouse/mouse.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/hid_core/resources/six_axis/console_six_axis.cpp b/src/hid_core/resources/six_axis/console_six_axis.cpp index 62d3b4ddc2..c58c14e453 100644 --- a/src/hid_core/resources/six_axis/console_six_axis.cpp +++ b/src/hid_core/resources/six_axis/console_six_axis.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project diff --git a/src/hid_core/resources/six_axis/six_axis.cpp b/src/hid_core/resources/six_axis/six_axis.cpp index f2aadd9ed1..abda9e8e09 100644 --- a/src/hid_core/resources/six_axis/six_axis.cpp +++ b/src/hid_core/resources/six_axis/six_axis.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project diff --git a/src/hid_core/resources/system_buttons/capture_button.cpp b/src/hid_core/resources/system_buttons/capture_button.cpp index 79d75f423a..417d384e6b 100644 --- a/src/hid_core/resources/system_buttons/capture_button.cpp +++ b/src/hid_core/resources/system_buttons/capture_button.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/hid_core/resources/system_buttons/home_button.cpp b/src/hid_core/resources/system_buttons/home_button.cpp index 2edb4557c1..b0131767af 100644 --- a/src/hid_core/resources/system_buttons/home_button.cpp +++ b/src/hid_core/resources/system_buttons/home_button.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/hid_core/resources/system_buttons/sleep_button.cpp b/src/hid_core/resources/system_buttons/sleep_button.cpp index 3ae5883bfa..21e78e2d44 100644 --- a/src/hid_core/resources/system_buttons/sleep_button.cpp +++ b/src/hid_core/resources/system_buttons/sleep_button.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index 83a57f96a7..ea95693a1c 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project From c6d8898c74536a96dca025df784122e14dfb1d91 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 22 Jan 2026 19:20:22 +0000 Subject: [PATCH 045/108] ps4 icon --- dist/icon_variations/ps4.svg | 215 +++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 dist/icon_variations/ps4.svg diff --git a/dist/icon_variations/ps4.svg b/dist/icon_variations/ps4.svg new file mode 100644 index 0000000000..0ee32c660c --- /dev/null +++ b/dist/icon_variations/ps4.svg @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 1d13f6043c879b920c27410237876b9d0b020d57 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 24 Jan 2026 06:48:07 +0000 Subject: [PATCH 046/108] stub add proper iostream init --- .ci/ps4/build.sh | 2 +- externals/ps4sup/stub.cpp | 4 ++++ src/core/perf_stats.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 2bba7e185d..b792529ec7 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -1,6 +1,6 @@ #!/usr/local/bin/bash -ex -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later [ -f "ps4-toolchain.cmake" ] || cat << EOF >"ps4-toolchain.cmake" diff --git a/externals/ps4sup/stub.cpp b/externals/ps4sup/stub.cpp index 89dc983599..bee5613486 100644 --- a/externals/ps4sup/stub.cpp +++ b/externals/ps4sup/stub.cpp @@ -19,3 +19,7 @@ STUB_WEAK(ZSTD_trace_decompress_end) FILE* __stderrp = stdout; #undef STUB_WEAK + +// THIS MAKES STD::COUT AND SUCH WORK :) +#include +std::ios_base::Init init; diff --git a/src/core/perf_stats.h b/src/core/perf_stats.h index 6fbf05671a..fef83b2d4b 100644 --- a/src/core/perf_stats.h +++ b/src/core/perf_stats.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2017 Citra Emulator Project From 8289852ff4914ea0d2973b15643c3c6289126552 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 24 Jan 2026 18:34:49 +0000 Subject: [PATCH 047/108] revert input system to main --- src/hid_core/resource_manager.cpp | 3 - .../resources/debug_pad/debug_pad.cpp | 3 - .../resources/digitizer/digitizer.cpp | 3 - src/hid_core/resources/keyboard/keyboard.cpp | 3 - src/hid_core/resources/mouse/debug_mouse.cpp | 3 - src/hid_core/resources/mouse/mouse.cpp | 3 - .../resources/six_axis/console_six_axis.cpp | 3 - src/hid_core/resources/six_axis/six_axis.cpp | 3 - .../system_buttons/capture_button.cpp | 3 - .../resources/system_buttons/home_button.cpp | 3 - .../resources/system_buttons/sleep_button.cpp | 3 - src/input_common/drivers/joycon.cpp | 15 ++--- src/input_common/drivers/joycon.h | 3 - src/input_common/drivers/sdl_driver.cpp | 12 +--- src/input_common/helpers/joycon_driver.cpp | 38 +++++-------- .../joycon_protocol/common_protocol.cpp | 55 +++++++++---------- .../helpers/joycon_protocol/joycon_types.h | 3 - 17 files changed, 47 insertions(+), 112 deletions(-) diff --git a/src/hid_core/resource_manager.cpp b/src/hid_core/resource_manager.cpp index 0c10d1bec9..d6b46ae764 100644 --- a/src/hid_core/resource_manager.cpp +++ b/src/hid_core/resource_manager.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/hid_core/resources/debug_pad/debug_pad.cpp b/src/hid_core/resources/debug_pad/debug_pad.cpp index bab49b55f8..1102dad6c9 100644 --- a/src/hid_core/resources/debug_pad/debug_pad.cpp +++ b/src/hid_core/resources/debug_pad/debug_pad.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/digitizer/digitizer.cpp b/src/hid_core/resources/digitizer/digitizer.cpp index e158e55e6c..5d7dcadfe3 100644 --- a/src/hid_core/resources/digitizer/digitizer.cpp +++ b/src/hid_core/resources/digitizer/digitizer.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/keyboard/keyboard.cpp b/src/hid_core/resources/keyboard/keyboard.cpp index 4e929e1260..340e8a65ce 100644 --- a/src/hid_core/resources/keyboard/keyboard.cpp +++ b/src/hid_core/resources/keyboard/keyboard.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/mouse/debug_mouse.cpp b/src/hid_core/resources/mouse/debug_mouse.cpp index e56c1de656..5f6f6e8e1a 100644 --- a/src/hid_core/resources/mouse/debug_mouse.cpp +++ b/src/hid_core/resources/mouse/debug_mouse.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/mouse/mouse.cpp b/src/hid_core/resources/mouse/mouse.cpp index 80de81efe4..53a8938a1b 100644 --- a/src/hid_core/resources/mouse/mouse.cpp +++ b/src/hid_core/resources/mouse/mouse.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/six_axis/console_six_axis.cpp b/src/hid_core/resources/six_axis/console_six_axis.cpp index c58c14e453..4f733cc76f 100644 --- a/src/hid_core/resources/six_axis/console_six_axis.cpp +++ b/src/hid_core/resources/six_axis/console_six_axis.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/six_axis/six_axis.cpp b/src/hid_core/resources/six_axis/six_axis.cpp index abda9e8e09..b407a5c76e 100644 --- a/src/hid_core/resources/six_axis/six_axis.cpp +++ b/src/hid_core/resources/six_axis/six_axis.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/hid_core/resources/system_buttons/capture_button.cpp b/src/hid_core/resources/system_buttons/capture_button.cpp index 417d384e6b..95eb604241 100644 --- a/src/hid_core/resources/system_buttons/capture_button.cpp +++ b/src/hid_core/resources/system_buttons/capture_button.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/system_buttons/home_button.cpp b/src/hid_core/resources/system_buttons/home_button.cpp index b0131767af..f665338f32 100644 --- a/src/hid_core/resources/system_buttons/home_button.cpp +++ b/src/hid_core/resources/system_buttons/home_button.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/hid_core/resources/system_buttons/sleep_button.cpp b/src/hid_core/resources/system_buttons/sleep_button.cpp index 21e78e2d44..1596632465 100644 --- a/src/hid_core/resources/system_buttons/sleep_button.cpp +++ b/src/hid_core/resources/system_buttons/sleep_button.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index ea95693a1c..fb2d75e384 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project @@ -23,14 +23,12 @@ Joycons::Joycons(const std::string& input_engine_) : InputEngine(input_engine_) return; } LOG_INFO(Input, "Joycon driver Initialization started"); -#if SDL_VERSION_ATLEAST(2, 26, 4) - int const res = SDL_hid_init(); - if (res == 0) { + const int init_res = SDL_hid_init(); + if (init_res == 0) { Setup(); } else { - LOG_ERROR(Input, "Hidapi could not be initialized. failed with error = {}", res); + LOG_ERROR(Input, "Hidapi could not be initialized. failed with error = {}", init_res); } -#endif } Joycons::~Joycons() { @@ -57,9 +55,7 @@ void Joycons::Reset() { } device->Stop(); } -#if SDL_VERSION_ATLEAST(2, 26, 4) SDL_hid_exit(); -#endif } void Joycons::Setup() { @@ -84,9 +80,9 @@ void Joycons::Setup() { } void Joycons::ScanThread(std::stop_token stop_token) { -#if SDL_VERSION_ATLEAST(2, 26, 4) constexpr u16 nintendo_vendor_id = 0x057e; Common::SetCurrentThreadName("JoyconScanThread"); + do { SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0); SDL_hid_device_info* cur_dev = devs; @@ -102,7 +98,6 @@ void Joycons::ScanThread(std::stop_token stop_token) { SDL_hid_free_enumeration(devs); } while (Common::StoppableTimedWait(stop_token, std::chrono::seconds{5})); -#endif } bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const { diff --git a/src/input_common/drivers/joycon.h b/src/input_common/drivers/joycon.h index 820c4b2eaa..92ebf0c813 100644 --- a/src/input_common/drivers/joycon.h +++ b/src/input_common/drivers/joycon.h @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 187dba6f68..981d37e36d 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2018 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -92,7 +92,6 @@ public: } void EnableMotion() { -#if SDL_VERSION_ATLEAST(2, 26, 4) if (!sdl_controller) { return; } @@ -175,7 +174,6 @@ public: motion.delta_timestamp = time_difference; return true; } -#endif const BasicMotion& GetMotion() const { return motion; @@ -354,7 +352,6 @@ public: } std::string GetControllerName() const { -#if SDL_VERSION_ATLEAST(2, 26, 4) if (sdl_controller) { switch (SDL_GetGamepadType(sdl_controller.get())) { case SDL_GAMEPAD_TYPE_XBOX360: @@ -368,8 +365,6 @@ public: case SDL_GAMEPAD_TYPE_PS5: return "DualSense Controller"; default: - if (auto const name = SDL_GameControllerName(sdl_controller.get()); name) - return name; break; } const auto name = SDL_GetGamepadName(sdl_controller.get()); @@ -377,7 +372,6 @@ public: return name; } } -#endif if (sdl_joystick) { const auto name = SDL_GetJoystickName(sdl_joystick.get()); @@ -645,7 +639,6 @@ void SDLDriver::CloseJoysticks() { } SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_engine_)) { -#if SDL_VERSION_ATLEAST(2, 26, 4) // Set our application name. Currently passed to DBus by SDL and visible to the user through // their desktop environment. SDL_SetHint(SDL_HINT_APP_NAME, "Eden"); @@ -684,7 +677,6 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en // Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native // driver on Linux. SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_XBOX, "0"); -#endif // If the frontend is going to manage the event loop, then we don't start one here start_thread = SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == 0; @@ -994,7 +986,6 @@ ButtonBindings SDLDriver::GetDefaultButtonBinding( auto slr_button = SDL_GAMEPAD_BUTTON_LEFT_SHOULDER; auto srr_button = SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER; -#if SDL_VERSION_ATLEAST(2, 26, 4) if (joystick->IsJoyconLeft()) { sll_button = SDL_GAMEPAD_BUTTON_LEFT_PADDLE1; srl_button = SDL_GAMEPAD_BUTTON_LEFT_PADDLE2; @@ -1003,7 +994,6 @@ ButtonBindings SDLDriver::GetDefaultButtonBinding( slr_button = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2; srr_button = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1; } -#endif return { std::pair{Settings::NativeButton::A, SDL_GAMEPAD_BUTTON_EAST}, diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index eca8044383..fca09af55f 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -41,8 +38,8 @@ Common::Input::DriverResult JoyconDriver::RequestDeviceAccess(SDL_hid_device_inf return Common::Input::DriverResult::UnsupportedControllerType; } -#if SDL_VERSION_ATLEAST(2, 26, 4) - hidapi_handle->handle = SDL_hid_open(device_info->vendor_id, device_info->product_id, device_info->serial_number); + hidapi_handle->handle = + SDL_hid_open(device_info->vendor_id, device_info->product_id, device_info->serial_number); std::memcpy(&handle_serial_number, device_info->serial_number, 15); if (!hidapi_handle->handle) { LOG_ERROR(Input, "Yuzu can't gain access to this device: ID {:04X}:{:04X}.", @@ -51,9 +48,6 @@ Common::Input::DriverResult JoyconDriver::RequestDeviceAccess(SDL_hid_device_inf } SDL_hid_set_nonblocking(hidapi_handle->handle, 1); return Common::Input::DriverResult::Success; -#else - return Common::Input::DriverResult::UnsupportedControllerType; -#endif } Common::Input::DriverResult JoyconDriver::InitializeDevice() { @@ -144,6 +138,8 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { Common::SetCurrentThreadName("JoyconInput"); input_thread_running = true; + // Max update rate is 5ms, ensure we are always able to read a bit faster + constexpr int ThreadDelay = 3; std::vector buffer(MaxBufferSize); while (!stop_token.stop_requested()) { @@ -154,17 +150,14 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { continue; } -#if SDL_VERSION_ATLEAST(2, 26, 4) - // Max update rate is 5ms, ensure we are always able to read a bit faster - int constexpr thread_delay = 3; // By disabling the input thread we can ensure custom commands will succeed as no package is // skipped if (!disable_input_thread) { - status = SDL_hid_read_timeout(hidapi_handle->handle, buffer.data(), buffer.size(), thread_delay); + status = SDL_hid_read_timeout(hidapi_handle->handle, buffer.data(), buffer.size(), + ThreadDelay); } else { - std::this_thread::sleep_for(std::chrono::milliseconds(thread_delay)); + std::this_thread::sleep_for(std::chrono::milliseconds(ThreadDelay)); } -#endif if (IsPayloadCorrect(status, buffer)) { OnNewData(buffer); @@ -697,18 +690,19 @@ void JoyconDriver::SetCallbacks(const JoyconCallbacks& callbacks) { joycon_poller->SetCallbacks(callbacks); } -Common::Input::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, ControllerType& controller_type) { -#if SDL_VERSION_ATLEAST(2, 26, 4) +Common::Input::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, + ControllerType& controller_type) { static constexpr std::array, 6> supported_devices{ std::pair{0x2006, ControllerType::Left}, {0x2007, ControllerType::Right}, {0x2009, ControllerType::Pro}, }; - constexpr u16 nintendo_vendor_id = 0x057e; + controller_type = ControllerType::None; - if (device_info->vendor_id != nintendo_vendor_id) + if (device_info->vendor_id != nintendo_vendor_id) { return Common::Input::DriverResult::UnsupportedControllerType; + } for (const auto& [product_id, type] : supported_devices) { if (device_info->product_id == static_cast(product_id)) { @@ -716,20 +710,16 @@ Common::Input::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* dev return Common::Input::DriverResult::Success; } } -#endif return Common::Input::DriverResult::UnsupportedControllerType; } -Common::Input::DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info, SerialNumber& serial_number) { -#if SDL_VERSION_ATLEAST(2, 26, 4) +Common::Input::DriverResult JoyconDriver::GetSerialNumber(SDL_hid_device_info* device_info, + SerialNumber& serial_number) { if (device_info->serial_number == nullptr) { return Common::Input::DriverResult::Unknown; } std::memcpy(&serial_number, device_info->serial_number, 15); return Common::Input::DriverResult::Success; -#else - return Common::Input::DriverResult::Unknown; -#endif } } // namespace InputCommon::Joycon diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.cpp b/src/input_common/helpers/joycon_protocol/common_protocol.cpp index 12b83a1805..fe229752f8 100644 --- a/src/input_common/helpers/joycon_protocol/common_protocol.cpp +++ b/src/input_common/helpers/joycon_protocol/common_protocol.cpp @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -18,15 +15,11 @@ u8 JoyconCommonProtocol::GetCounter() { } void JoyconCommonProtocol::SetBlocking() { -#if SDL_VERSION_ATLEAST(2, 26, 4) SDL_hid_set_nonblocking(hidapi_handle->handle, 0); -#endif } void JoyconCommonProtocol::SetNonBlocking() { -#if SDL_VERSION_ATLEAST(2, 26, 4) SDL_hid_set_nonblocking(hidapi_handle->handle, 1); -#endif } Common::Input::DriverResult JoyconCommonProtocol::GetDeviceType(ControllerType& controller_type) { @@ -42,23 +35,26 @@ Common::Input::DriverResult JoyconCommonProtocol::GetDeviceType(ControllerType& return result; } -Common::Input::DriverResult JoyconCommonProtocol::CheckDeviceAccess(SDL_hid_device_info* device_info) { +Common::Input::DriverResult JoyconCommonProtocol::CheckDeviceAccess( + SDL_hid_device_info* device_info) { ControllerType controller_type{ControllerType::None}; const auto result = GetDeviceType(controller_type); + if (result != Common::Input::DriverResult::Success || controller_type == ControllerType::None) { return Common::Input::DriverResult::UnsupportedControllerType; } -#if SDL_VERSION_ATLEAST(2, 26, 4) - hidapi_handle->handle = SDL_hid_open(device_info->vendor_id, device_info->product_id, device_info->serial_number); + + hidapi_handle->handle = + SDL_hid_open(device_info->vendor_id, device_info->product_id, device_info->serial_number); + if (!hidapi_handle->handle) { - LOG_ERROR(Input, "Yuzu can't gain access to this device: ID {:04X}:{:04X}.", device_info->vendor_id, device_info->product_id); + LOG_ERROR(Input, "Yuzu can't gain access to this device: ID {:04X}:{:04X}.", + device_info->vendor_id, device_info->product_id); return Common::Input::DriverResult::HandleInUse; } + SetNonBlocking(); return Common::Input::DriverResult::Success; -#else - return Common::Input::DriverResult::UnsupportedControllerType; -#endif } Common::Input::DriverResult JoyconCommonProtocol::SetReportMode(ReportMode report_mode) { @@ -67,21 +63,21 @@ Common::Input::DriverResult JoyconCommonProtocol::SetReportMode(ReportMode repor } Common::Input::DriverResult JoyconCommonProtocol::SendRawData(std::span buffer) { -#if SDL_VERSION_ATLEAST(2, 26, 4) - auto const result = SDL_hid_write(hidapi_handle->handle, buffer.data(), buffer.size()); - if (result == -1) + const auto result = SDL_hid_write(hidapi_handle->handle, buffer.data(), buffer.size()); + + if (result == -1) { return Common::Input::DriverResult::ErrorWritingData; + } + return Common::Input::DriverResult::Success; -#else - return Common::Input::DriverResult::ErrorWritingData; -#endif } -Common::Input::DriverResult JoyconCommonProtocol::GetSubCommandResponse(SubCommand sc, SubCommandResponse& output) { -#if SDL_VERSION_ATLEAST(2, 26, 4) +Common::Input::DriverResult JoyconCommonProtocol::GetSubCommandResponse( + SubCommand sc, SubCommandResponse& output) { constexpr int timeout_mili = 66; constexpr int MaxTries = 10; int tries = 0; + do { int result = SDL_hid_read_timeout(hidapi_handle->handle, reinterpret_cast(&output), sizeof(SubCommandResponse), timeout_mili); @@ -92,8 +88,9 @@ Common::Input::DriverResult JoyconCommonProtocol::GetSubCommandResponse(SubComma if (tries++ > MaxTries) { return Common::Input::DriverResult::Timeout; } - } while (output.input_report.report_mode != ReportMode::SUBCMD_REPLY && output.sub_command != sc); -#endif + } while (output.input_report.report_mode != ReportMode::SUBCMD_REPLY && + output.sub_command != sc); + return Common::Input::DriverResult::Success; } @@ -221,11 +218,12 @@ Common::Input::DriverResult JoyconCommonProtocol::ConfigureMCU(const MCUConfig& return result; } -Common::Input::DriverResult JoyconCommonProtocol::GetMCUDataResponse(ReportMode report_mode, MCUCommandResponse& output) { -#if SDL_VERSION_ATLEAST(2, 26, 4) +Common::Input::DriverResult JoyconCommonProtocol::GetMCUDataResponse(ReportMode report_mode, + MCUCommandResponse& output) { constexpr int TimeoutMili = 200; constexpr int MaxTries = 9; int tries = 0; + do { int result = SDL_hid_read_timeout(hidapi_handle->handle, reinterpret_cast(&output), sizeof(MCUCommandResponse), TimeoutMili); @@ -236,8 +234,9 @@ Common::Input::DriverResult JoyconCommonProtocol::GetMCUDataResponse(ReportMode if (tries++ > MaxTries) { return Common::Input::DriverResult::Timeout; } - } while (output.input_report.report_mode != report_mode || output.mcu_report == MCUReport::EmptyAwaitingCmd); -#endif + } while (output.input_report.report_mode != report_mode || + output.mcu_report == MCUReport::EmptyAwaitingCmd); + return Common::Input::DriverResult::Success; } diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h index dd3bd4398c..439becb2ed 100644 --- a/src/input_common/helpers/joycon_protocol/joycon_types.h +++ b/src/input_common/helpers/joycon_protocol/joycon_types.h @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later From b19b23197fc387d26ff85fba214e65efa2df21e9 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 24 Jan 2026 19:03:04 +0000 Subject: [PATCH 048/108] Use updated SDL2 --- .ci/ps4/build.sh | 1 + externals/cpmfile.json | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index b792529ec7..b167b65ef5 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -53,5 +53,6 @@ cmake -S . -B build -G "Unix Makefiles" \ -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ -DDYNARMIC_TESTS=ON \ + -DYUZU_USE_EXTERNAL_SDL2=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit cmake --build build -t yuzu-cmd_pkg -- -j$NPROC diff --git a/externals/cpmfile.json b/externals/cpmfile.json index c586926e9f..c7f90a33cd 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -167,6 +167,14 @@ "git_version": "3.4.8", "version": "3.2.10" }, + "sdl2_ps4": { + "package": "SDL2", + "repo": "xinitrcn1/SDL", + "sha": "f577141fc4", + "key": "ps4", + "bundled": true, + "skip_updates": true + }, "moltenvk": { "repo": "V380-Ori/Ryujinx.MoltenVK", "tag": "v%VERSION%-ryujinx", From 752bdcb9bcf1977a881150ec95ce86a007750bf4 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 24 Jan 2026 20:02:12 +0000 Subject: [PATCH 049/108] make a bit more mergeable --- .ci/ps4/build.sh | 1 + src/audio_core/CMakeLists.txt | 2 +- src/hid_core/resources/npad/npad.cpp | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index b167b65ef5..2fdcd01c68 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -52,6 +52,7 @@ cmake -S . -B build -G "Unix Makefiles" \ -DCPMUTIL_FORCE_BUNDLED=ON \ -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ + -DDYNARMIC_ENABLE_NO_EXECUTE_SUPPORT=OFF \ -DDYNARMIC_TESTS=ON \ -DYUZU_USE_EXTERNAL_SDL2=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index 4d0b130afc..c76073a4db 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2018 yuzu Emulator Project diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index a3364ad219..9aaacf8ecb 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -1350,6 +1350,7 @@ void NPad::UpdateHandheldAbstractState() { void NPad::EnableAppletToGetInput(u64 aruid) { std::scoped_lock lock{mutex}; std::scoped_lock shared_lock{*applet_resource_holder.shared_mutex}; + for (auto& abstract_pad : abstracted_pads) { abstract_pad.EnableAppletToGetInput(aruid); } From b0df4db00dcd06c223d140a048985601328fbbe9 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 24 Jan 2026 20:37:16 +0000 Subject: [PATCH 050/108] fix2 --- CMakeModules/FindSDL2.cmake | 391 ------------------------------------ 1 file changed, 391 deletions(-) delete mode 100644 CMakeModules/FindSDL2.cmake diff --git a/CMakeModules/FindSDL2.cmake b/CMakeModules/FindSDL2.cmake deleted file mode 100644 index b039031b4a..0000000000 --- a/CMakeModules/FindSDL2.cmake +++ /dev/null @@ -1,391 +0,0 @@ -# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -# SPDX-License-Identifier: GPL-3.0-or-later - -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -# Copyright 2019 Amine Ben Hassouna -# Copyright 2000-2019 Kitware, Inc. and Contributors -# All rights reserved. - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: - -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. - -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. - -# * Neither the name of Kitware, Inc. nor the names of Contributors -# may be used to endorse or promote products derived from this -# software without specific prior written permission. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#[=======================================================================[.rst: -FindSDL2 --------- - -Locate SDL2 library - -This module defines the following 'IMPORTED' targets: - -:: - - SDL2::Core - The SDL2 library, if found. - Libraries should link to SDL2::Core - - SDL2::Main - The SDL2main library, if found. - Applications should link to SDL2::Main instead of SDL2::Core - - - -This module will set the following variables in your project: - -:: - - SDL2_LIBRARIES, the name of the library to link against - SDL2_INCLUDE_DIRS, where to find SDL.h - SDL2_FOUND, if false, do not try to link to SDL2 - SDL2MAIN_FOUND, if false, do not try to link to SDL2main - SDL2_VERSION_STRING, human-readable string containing the version of SDL2 - - - -This module responds to the following cache variables: - -:: - - SDL2_PATH - Set a custom SDL2 Library path (default: empty) - - SDL2_NO_DEFAULT_PATH - Disable search SDL2 Library in default path. - If SDL2_PATH (default: ON) - Else (default: OFF) - - SDL2_INCLUDE_DIR - SDL2 headers path. - - SDL2_LIBRARY - SDL2 Library (.dll, .so, .a, etc) path. - - SDL2MAIN_LIBRAY - SDL2main Library (.a) path. - - SDL2_BUILDING_LIBRARY - This flag is useful only when linking to SDL2_LIBRARIES insead of - SDL2::Main. It is required only when building a library that links to - SDL2_LIBRARIES, because only applications need main() (No need to also - link to SDL2main). - If this flag is defined, then no SDL2main will be added to SDL2_LIBRARIES - and no SDL2::Main target will be created. - - -Don't forget to include SDLmain.h and SDLmain.m in your project for the -OS X framework based version. (Other versions link to -lSDL2main which -this module will try to find on your behalf.) Also for OS X, this -module will automatically add the -framework Cocoa on your behalf. - - -Additional Note: If you see an empty SDL2_LIBRARY in your project -configuration, it means CMake did not find your SDL2 library -(SDL2.dll, libsdl2.so, SDL2.framework, etc). Set SDL2_LIBRARY to point -to your SDL2 library, and configure again. Similarly, if you see an -empty SDL2MAIN_LIBRARY, you should set this value as appropriate. These -values are used to generate the final SDL2_LIBRARIES variable and the -SDL2::Core and SDL2::Main targets, but when these values are unset, -SDL2_LIBRARIES, SDL2::Core and SDL2::Main does not get created. - - -$SDL2DIR is an environment variable that would correspond to the -./configure --prefix=$SDL2DIR used in building SDL2. l.e.galup 9-20-02 - - - -Created by Amine Ben Hassouna: - Adapt FindSDL.cmake to SDL2 (FindSDL2.cmake). - Add cache variables for more flexibility: - SDL2_PATH, SDL2_NO_DEFAULT_PATH (for details, see doc above). - Mark 'Threads' as a required dependency for non-OSX systems. - Modernize the FindSDL2.cmake module by creating specific targets: - SDL2::Core and SDL2::Main (for details, see doc above). - - -Original FindSDL.cmake module: - Modified by Eric Wing. Added code to assist with automated building - by using environmental variables and providing a more - controlled/consistent search behavior. Added new modifications to - recognize OS X frameworks and additional Unix paths (FreeBSD, etc). - Also corrected the header search path to follow "proper" SDL - guidelines. Added a search for SDLmain which is needed by some - platforms. Added a search for threads which is needed by some - platforms. Added needed compile switches for MinGW. - -On OSX, this will prefer the Framework version (if found) over others. -People will have to manually change the cache value of SDL2_LIBRARY to -override this selection or set the SDL2_PATH variable or the CMake -environment CMAKE_INCLUDE_PATH to modify the search paths. - -Note that the header path has changed from SDL/SDL.h to just SDL.h -This needed to change because "proper" SDL convention is #include -"SDL.h", not . This is done for portability reasons -because not all systems place things in SDL/ (see FreeBSD). -#]=======================================================================] - -# Define options for searching SDL2 Library in a custom path - -set(SDL2_PATH "" CACHE STRING "Custom SDL2 Library path") - -set(_SDL2_NO_DEFAULT_PATH OFF) -if(SDL2_PATH) - set(_SDL2_NO_DEFAULT_PATH ON) -endif() - -set(SDL2_NO_DEFAULT_PATH ${_SDL2_NO_DEFAULT_PATH} - CACHE BOOL "Disable search SDL2 Library in default path") -unset(_SDL2_NO_DEFAULT_PATH) - -set(SDL2_NO_DEFAULT_PATH_CMD) -if(SDL2_NO_DEFAULT_PATH) - set(SDL2_NO_DEFAULT_PATH_CMD NO_DEFAULT_PATH) -endif() - -# Search for the SDL2 include directory -find_path(SDL2_INCLUDE_DIR SDL.h - HINTS - ENV SDL2DIR - ${SDL2_NO_DEFAULT_PATH_CMD} - PATH_SUFFIXES SDL2 - # path suffixes to search inside ENV{SDL2DIR} - include/SDL2 include - PATHS ${SDL2_PATH} - DOC "Where the SDL2 headers can be found" -) - -set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR}") - -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(VC_LIB_PATH_SUFFIX lib/x64) -else() - set(VC_LIB_PATH_SUFFIX lib/x86) -endif() - -# SDL-2.0 is the name used by FreeBSD ports... -# don't confuse it for the version number. -find_library(SDL2_LIBRARY - NAMES SDL2 SDL-2.0 - HINTS - ENV SDL2DIR - ${SDL2_NO_DEFAULT_PATH_CMD} - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} - PATHS ${SDL2_PATH} - DOC "Where the SDL2 Library can be found" -) - -set(SDL2_LIBRARIES "${SDL2_LIBRARY}") - -if(NOT SDL2_BUILDING_LIBRARY) - if(NOT SDL2_INCLUDE_DIR MATCHES ".framework") - # Non-OS X framework versions expect you to also dynamically link to - # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms - # seem to provide SDL2main for compatibility even though they don't - # necessarily need it. - - if(SDL2_PATH) - set(SDL2MAIN_LIBRARY_PATHS "${SDL2_PATH}") - endif() - - if(NOT SDL2_NO_DEFAULT_PATH) - set(SDL2MAIN_LIBRARY_PATHS - /sw - /opt/local - /opt/csw - /opt - "${SDL2MAIN_LIBRARY_PATHS}" - ) - endif() - - find_library(SDL2MAIN_LIBRARY - NAMES SDL2main - HINTS - ENV SDL2DIR - ${SDL2_NO_DEFAULT_PATH_CMD} - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} - PATHS ${SDL2MAIN_LIBRARY_PATHS} - DOC "Where the SDL2main library can be found" - ) - unset(SDL2MAIN_LIBRARY_PATHS) - endif() -endif() - -# SDL2 may require threads on your system. -# The Apple build may not need an explicit flag because one of the -# frameworks may already provide it. -# But for non-OSX systems, I will use the CMake Threads package. -if(NOT APPLE) - find_package(Threads QUIET) - if(NOT Threads_FOUND) - set(SDL2_THREADS_NOT_FOUND "Could NOT find Threads (Threads is required by SDL2).") - if(SDL2_FIND_REQUIRED) - message(FATAL_ERROR ${SDL2_THREADS_NOT_FOUND}) - else() - if(NOT SDL2_FIND_QUIETLY) - message(STATUS ${SDL2_THREADS_NOT_FOUND}) - endif() - return() - endif() - unset(SDL2_THREADS_NOT_FOUND) - endif() -endif() - -# MinGW needs an additional link flag, -mwindows -# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows -if(MINGW) - set(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "link flags for MinGW") -endif() - -if(SDL2_LIBRARY) - # For SDL2main - if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY) - list(FIND SDL2_LIBRARIES "${SDL2MAIN_LIBRARY}" _SDL2_MAIN_INDEX) - if(_SDL2_MAIN_INDEX EQUAL -1) - set(SDL2_LIBRARIES "${SDL2MAIN_LIBRARY}" ${SDL2_LIBRARIES}) - endif() - unset(_SDL2_MAIN_INDEX) - endif() - - # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. - # CMake doesn't display the -framework Cocoa string in the UI even - # though it actually is there if I modify a pre-used variable. - # I think it has something to do with the CACHE STRING. - # So I use a temporary variable until the end so I can set the - # "real" variable in one-shot. - if(APPLE) - set(SDL2_LIBRARIES ${SDL2_LIBRARIES} -framework Cocoa) - endif() - - # For threads, as mentioned Apple doesn't need this. - # In fact, there seems to be a problem if I used the Threads package - # and try using this line, so I'm just skipping it entirely for OS X. - if(NOT APPLE) - set(SDL2_LIBRARIES ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) - endif() - - # For MinGW library - if(MINGW) - set(SDL2_LIBRARIES ${MINGW32_LIBRARY} ${SDL2_LIBRARIES}) - endif() - -endif() - -# Read SDL2 version -if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h") - file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}") - set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH}) - unset(SDL2_VERSION_MAJOR_LINE) - unset(SDL2_VERSION_MINOR_LINE) - unset(SDL2_VERSION_PATCH_LINE) - unset(SDL2_VERSION_MAJOR) - unset(SDL2_VERSION_MINOR) - unset(SDL2_VERSION_PATCH) -endif() - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 - REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR - VERSION_VAR SDL2_VERSION_STRING) - -if(SDL2MAIN_LIBRARY) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2main - REQUIRED_VARS SDL2MAIN_LIBRARY SDL2_INCLUDE_DIR - VERSION_VAR SDL2_VERSION_STRING) -endif() - - -mark_as_advanced(SDL2_PATH - SDL2_NO_DEFAULT_PATH - SDL2_LIBRARY - SDL2MAIN_LIBRARY - SDL2_INCLUDE_DIR - SDL2_BUILDING_LIBRARY) - - -# SDL2:: targets (SDL2::Core and SDL2::Main) -if(SDL2_FOUND) - - # SDL2::Core target - if(SDL2_LIBRARY AND NOT TARGET SDL2::Core) - add_library(SDL2::Core UNKNOWN IMPORTED) - set_target_properties(SDL2::Core PROPERTIES - IMPORTED_LOCATION "${SDL2_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}") - - if(APPLE) - # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. - # For more details, please see above. - set_property(TARGET SDL2::Core APPEND PROPERTY - INTERFACE_LINK_OPTIONS -framework Cocoa) - else() - # For threads, as mentioned Apple doesn't need this. - # For more details, please see above. - set_property(TARGET SDL2::Core APPEND PROPERTY - INTERFACE_LINK_LIBRARIES Threads::Threads) - endif() - endif() - - # SDL2::Main target - # Applications should link to SDL2::Main instead of SDL2::Core - # For more details, please see above. - if(NOT SDL2_BUILDING_LIBRARY AND NOT TARGET SDL2::Main) - - if(SDL2_INCLUDE_DIR MATCHES ".framework" OR NOT SDL2MAIN_LIBRARY) - add_library(SDL2::Main INTERFACE IMPORTED) - set_property(TARGET SDL2::Main PROPERTY - INTERFACE_LINK_LIBRARIES SDL2::Core) - elseif(SDL2MAIN_LIBRARY) - # MinGW requires that the mingw32 library is specified before the - # libSDL2main.a static library when linking. - # The SDL2::MainInternal target is used internally to make sure that - # CMake respects this condition. - add_library(SDL2::MainInternal UNKNOWN IMPORTED) - set_property(TARGET SDL2::MainInternal PROPERTY - IMPORTED_LOCATION "${SDL2MAIN_LIBRARY}") - set_property(TARGET SDL2::MainInternal PROPERTY - INTERFACE_LINK_LIBRARIES SDL2::Core) - - add_library(SDL2::Main INTERFACE IMPORTED) - - if(MINGW) - # MinGW needs an additional link flag '-mwindows' and link to mingw32 - set_property(TARGET SDL2::Main PROPERTY - INTERFACE_LINK_LIBRARIES "mingw32" "-mwindows") - endif() - - set_property(TARGET SDL2::Main APPEND PROPERTY - INTERFACE_LINK_LIBRARIES SDL2::MainInternal) - endif() - - endif() -endif() From 0efc3483d291837411fc49313727f28198203c55 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 28 Jan 2026 18:04:31 +0000 Subject: [PATCH 051/108] mark codeblocks as noexcept --- docs/Caveats.md | 6 +++++- .../src/dynarmic/backend/x64/block_of_code.cpp | 12 ++++++------ .../src/dynarmic/backend/x64/block_of_code.h | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/Caveats.md b/docs/Caveats.md index 9a8de81fb3..abeed7e019 100644 --- a/docs/Caveats.md +++ b/docs/Caveats.md @@ -249,10 +249,14 @@ When CMake invokes certain file syscalls - it may sometimes cause crashes or cor ## PlayStation 4 ```sh -export OO_PS4_TOOLCHAIN="$HOME/OpenOrbis/PS4Toolchain" +export OO_PS4_TOOLCHAIN="$HOME/OpenOrbis/PS4Toolchain/prefix" export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 ``` +```sh +cp $OO_PS4_TOOLCHAIN/include/endian.h $OO_PS4_TOOLCHAIN/include/sys/endian.h +``` + ## Windows ### Windows 7, Windows 8 and Windows 8.1 diff --git a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp index f41bea6c83..5b27b9eb94 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp @@ -239,12 +239,12 @@ static const auto default_cg_mode = Xbyak::DontSetProtectRWE; static const auto default_cg_mode = nullptr; //Allow RWE #endif -BlockOfCode::BlockOfCode(RunCodeCallbacks cb, JitStateInfo jsi, size_t total_code_size, std::function rcp) - : Xbyak::CodeGenerator(total_code_size, default_cg_mode, &s_allocator) - , cb(std::move(cb)) - , jsi(jsi) - , constant_pool(*this, CONSTANT_POOL_SIZE) - , host_features(GetHostFeatures()) { +BlockOfCode::BlockOfCode(RunCodeCallbacks cb, JitStateInfo jsi, size_t total_code_size, std::function rcp) noexcept + : Xbyak::CodeGenerator(total_code_size, default_cg_mode, &s_allocator) + , cb(std::move(cb)) + , jsi(jsi) + , constant_pool(*this, CONSTANT_POOL_SIZE) + , host_features(GetHostFeatures()) { EnableWriting(); EnsureMemoryCommitted(PRELUDE_COMMIT_SIZE); GenRunCode(rcp); diff --git a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.h b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.h index 857b1a4484..e19b6fac4d 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.h +++ b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.h @@ -38,8 +38,8 @@ struct RunCodeCallbacks { class BlockOfCode final : public Xbyak::CodeGenerator { public: - BlockOfCode(RunCodeCallbacks cb, JitStateInfo jsi, size_t total_code_size, std::function rcp); - BlockOfCode(const BlockOfCode&) = delete; + BlockOfCode(RunCodeCallbacks cb, JitStateInfo jsi, size_t total_code_size, std::function rcp) noexcept; + BlockOfCode(const BlockOfCode&) noexcept = delete; /// Call when external emitters have finished emitting their preludes. void PreludeComplete(); From d6830c979a4b73e309c07daa0700813db17f57bf Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 28 Jan 2026 19:03:55 +0000 Subject: [PATCH 052/108] use newer sdl2, make bigger stack --- externals/cpmfile.json | 9 ++++++--- src/common/fiber.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/externals/cpmfile.json b/externals/cpmfile.json index c7f90a33cd..8691eafae7 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -169,11 +169,14 @@ }, "sdl2_ps4": { "package": "SDL2", - "repo": "xinitrcn1/SDL", - "sha": "f577141fc4", + "repo": "libsdl-org/SDL", + "sha": "0c7042477a", "key": "ps4", "bundled": true, - "skip_updates": true + "skip_updates": true, + "patches": [ + "0001-ps4.patch" + ] }, "moltenvk": { "repo": "V380-Ori/Ryujinx.MoltenVK", diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index 69eca732eb..0c9bd4fb4d 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp @@ -16,7 +16,7 @@ namespace Common { #ifdef __OPENORBIS__ -constexpr size_t DEFAULT_STACK_SIZE = 128 * 4096; +constexpr size_t DEFAULT_STACK_SIZE = 256 * 4096; #else constexpr size_t DEFAULT_STACK_SIZE = 512 * 4096; #endif From 68784b901597e4a17f9e84e9ae88b69284a2f1d1 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 28 Jan 2026 19:15:51 +0000 Subject: [PATCH 053/108] SDL2 PS4 patch --- .patch/sdl2_ps4/0001-ps4.patch | 359 +++++++++++++++++++++++++++++++++ 1 file changed, 359 insertions(+) create mode 100644 .patch/sdl2_ps4/0001-ps4.patch diff --git a/.patch/sdl2_ps4/0001-ps4.patch b/.patch/sdl2_ps4/0001-ps4.patch new file mode 100644 index 0000000000..cb5ed901cb --- /dev/null +++ b/.patch/sdl2_ps4/0001-ps4.patch @@ -0,0 +1,359 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7c230473ac..b1275edb61 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -331,6 +331,13 @@ if(CYGWIN) + list(APPEND SDL_CFLAGS "-I/usr/include/mingw") + endif() + ++######### *FIXME* ++if(PS4 OR ORBIS) ++ set(USE_GENERATED_CONFIG Off) ++else() ++ set(USE_GENERATED_CONFIG On) ++endif() ++ + # General includes + target_compile_definitions(sdl-build-options INTERFACE "-DUSING_GENERATED_CONFIG_H") + target_include_directories(sdl-build-options BEFORE INTERFACE "${SDL2_BINARY_DIR}/include" "${SDL2_BINARY_DIR}/include-config-$>") +@@ -359,6 +366,15 @@ if(EMSCRIPTEN) + set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF) + endif() + ++if(PS4 OR ORBIS) ++ set(SDL_ATOMIC_ENABLED_BY_DEFAULT ON) ++ set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) ++ set(SDL_THREADS_ENABLED_BY_DEFAULT ON) ++ set(SDL_PTHREADS_ENABLED_BY_DEFAULT ON) ++ set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) ++ set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF) ++endif() ++ + if(VITA OR PSP OR PS2 OR N3DS) + set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) + set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) +@@ -1478,7 +1494,42 @@ elseif(EMSCRIPTEN) + + CheckPTHREAD() + CheckLibUnwind() ++elseif(PS4 OR ORBIS) ++ CheckPTHREAD() ++ if(SDL_AUDIO) ++ set(SDL_AUDIO_DRIVER_PS4 1) ++ file(GLOB PS4_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/ps4/*.c) ++ set(SOURCE_FILES ${SOURCE_FILES} ${PS4_AUDIO_SOURCES}) ++ set(HAVE_SDL_AUDIO TRUE) ++ endif() ++# if(SDL_FILESYSTEM) ++# set(SDL_FILESYSTEM_PS4 1) ++# file(GLOB PS4_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/ps4/*.c) ++# set(SOURCE_FILES ${SOURCE_FILES} ${PS4_FILESYSTEM_SOURCES}) ++# set(HAVE_SDL_FILESYSTEM TRUE) ++# endif() ++ if(SDL_JOYSTICK) ++ set(SDL_JOYSTICK_PS4 1) ++ file(GLOB PS4_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/ps4/*.c) ++ set(SOURCE_FILES ${SOURCE_FILES} ${PS4_JOYSTICK_SOURCES}) ++ set(HAVE_SDL_JOYSTICK TRUE) ++ endif() ++ if(SDL_TIMERS) ++ set(SDL_TIMER_UNIX 1) ++ file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c) ++ set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES}) ++ set(HAVE_SDL_TIMERS TRUE) + ++ if(CLOCK_GETTIME) ++ set(HAVE_CLOCK_GETTIME 1) ++ endif() ++ endif() ++ if(SDL_VIDEO) ++ set(SDL_VIDEO_DRIVER_PS4 1) ++ file(GLOB PS4_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/ps4/*.c) ++ set(SOURCE_FILES ${SOURCE_FILES} ${PS4_VIDEO_SOURCES}) ++ set(HAVE_SDL_VIDEO TRUE) ++ endif() + elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) + if(SDL_AUDIO) + if(SYSV5 OR SOLARIS OR HPUX) +@@ -3039,7 +3090,7 @@ endif() + # We always need to have threads and timers around + if(NOT HAVE_SDL_THREADS) + # The emscripten platform has been carefully vetted to work without threads +- if (EMSCRIPTEN) ++ if (EMSCRIPTEN OR PS4 OR ORBIS) + set(SDL_THREADS_DISABLED 1) + file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c) + list(APPEND SOURCE_FILES ${THREADS_SOURCES}) +diff --git a/README.md b/README.md +index fa7f7ba0b5..8d5a375694 100644 +--- a/README.md ++++ b/README.md +@@ -1,5 +1,5 @@ + +-# Simple DirectMedia Layer (SDL) Version 2.0 ++# Simple DirectMedia Layer (SDL) Version 2.0 (For OpenOrbis PS4 SDK) + + https://www.libsdl.org/ + +diff --git a/include/SDL_config.h b/include/SDL_config.h +index a628d86252..a101532d16 100644 +--- a/include/SDL_config.h ++++ b/include/SDL_config.h +@@ -41,6 +41,10 @@ + #include "SDL_config_iphoneos.h" + #elif defined(__ANDROID__) + #include "SDL_config_android.h" ++#elif defined(__PSP__) ++#include "SDL_config_psp.h" ++#elif defined(__OPENORBIS__) ++#include "SDL_config_ps4.h" + #elif defined(__OS2__) + #include "SDL_config_os2.h" + #elif defined(__EMSCRIPTEN__) +diff --git a/include/SDL_platform.h b/include/SDL_platform.h +index 36df782a4e..0cc20dc4e2 100644 +--- a/include/SDL_platform.h ++++ b/include/SDL_platform.h +@@ -214,6 +214,10 @@ + #if defined(PS2) + #define __PS2__ 1 + #endif ++#if defined(__OPENORBIS__) ++#undef __PS4__ ++#define __PS4__ 1 ++#endif + + /* The NACL compiler defines __native_client__ and __pnacl__ + * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi +diff --git a/src/SDL.c b/src/SDL.c +index cfeea077e7..33fce965c0 100644 +--- a/src/SDL.c ++++ b/src/SDL.c +@@ -642,6 +642,8 @@ const char *SDL_GetPlatform(void) + return "Nokia N-Gage"; + #elif defined(__3DS__) + return "Nintendo 3DS"; ++#elif defined(__PS4__) ++ return "PlayStation4"; + #else + return "Unknown (see SDL_platform.h)"; + #endif +diff --git a/src/SDL_error.c b/src/SDL_error.c +index 993f5bac55..083ebf3027 100644 +--- a/src/SDL_error.c ++++ b/src/SDL_error.c +@@ -50,11 +50,14 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) + va_end(ap); + } + } +- ++#ifndef __OPENORBIS__ // Yeah this is stupid but whatever + if (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) { ++#endif + /* If we are in debug mode, print out the error message */ + SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str); ++#ifndef __OPENORBIS__ // Yeah this is stupid but whatever + } ++#endif + } + + return -1; +diff --git a/src/SDL_log.c b/src/SDL_log.c +index 7a5f1dbc03..a7f3d85782 100644 +--- a/src/SDL_log.c ++++ b/src/SDL_log.c +@@ -390,10 +390,12 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va + int len; + va_list aq; + ++#ifndef __OPENORBIS__ + /* Nothing to do if we don't have an output function */ + if (!SDL_log_function) { + return; + } ++#endif + + /* Make sure we don't exceed array bounds */ + if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { +@@ -442,7 +444,11 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va + } + + SDL_LockMutex(log_function_mutex); ++#ifdef __OPENORBIS__ ++ printf("%s\n", message); // just fucking do it ++#else + SDL_log_function(SDL_log_userdata, category, priority, message); ++#endif + SDL_UnlockMutex(log_function_mutex); + + /* Free only if dynamically allocated */ +diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c +index 421adbc76a..82d087a2f8 100644 +--- a/src/audio/SDL_audio.c ++++ b/src/audio/SDL_audio.c +@@ -114,7 +114,10 @@ static const AudioBootStrap *const bootstrap[] = { + #ifdef SDL_AUDIO_DRIVER_N3DS + &N3DSAUDIO_bootstrap, + #endif +-#ifdef SDL_AUDIO_DRIVER_EMSCRIPTEN ++#if SDL_AUDIO_DRIVER_PS4 ++ &PS4AUDIO_bootstrap, ++#endif ++#if SDL_AUDIO_DRIVER_EMSCRIPTEN + &EMSCRIPTENAUDIO_bootstrap, + #endif + #ifdef SDL_AUDIO_DRIVER_JACK +diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h +index 87387692ce..b1c00ba9dc 100644 +--- a/src/audio/SDL_sysaudio.h ++++ b/src/audio/SDL_sysaudio.h +@@ -207,6 +207,7 @@ extern AudioBootStrap PS2AUDIO_bootstrap; + extern AudioBootStrap PSPAUDIO_bootstrap; + extern AudioBootStrap VITAAUD_bootstrap; + extern AudioBootStrap N3DSAUDIO_bootstrap; ++extern AudioBootStrap PS4AUDIO_bootstrap; + extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap; + extern AudioBootStrap OS2AUDIO_bootstrap; + +diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h +index 178218c053..a6e298a9fe 100644 +--- a/src/dynapi/SDL_dynapi.h ++++ b/src/dynapi/SDL_dynapi.h +@@ -69,6 +69,8 @@ + #define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */ + #elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN) + #define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */ ++#elif defined(__OPENORBIS__) // Apparently __PS4__ getting defined is missed somewhere, I get broken static builds so force the issue ++#define SDL_DYNAMIC_API 0 + #endif + + /* everyone else. This is where we turn on the API if nothing forced it off. */ +diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c +index 60b0daf790..34433166e8 100644 +--- a/src/joystick/SDL_joystick.c ++++ b/src/joystick/SDL_joystick.c +@@ -106,6 +106,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { + #ifdef SDL_JOYSTICK_N3DS + &SDL_N3DS_JoystickDriver + #endif ++#ifdef SDL_JOYSTICK_PS4 ++ &SDL_PS4_JoystickDriver, ++#endif + #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) + &SDL_DUMMY_JoystickDriver + #endif +diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h +index d36f784143..6671aff2fd 100644 +--- a/src/joystick/SDL_sysjoystick.h ++++ b/src/joystick/SDL_sysjoystick.h +@@ -243,6 +243,7 @@ extern SDL_JoystickDriver SDL_HAIKU_JoystickDriver; + extern SDL_JoystickDriver SDL_HIDAPI_JoystickDriver; + extern SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver; + extern SDL_JoystickDriver SDL_IOS_JoystickDriver; ++extern SDL_JoystickDriver SDL_PS4_JoystickDriver; + extern SDL_JoystickDriver SDL_LINUX_JoystickDriver; + extern SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver; + extern SDL_JoystickDriver SDL_WGI_JoystickDriver; +diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c +index 35f80664ab..cd8f9d3615 100644 +--- a/src/render/SDL_render.c ++++ b/src/render/SDL_render.c +@@ -137,6 +137,10 @@ static const SDL_RenderDriver *render_drivers[] = { + #if SDL_VIDEO_RENDER_VITA_GXM + &VITA_GXM_RenderDriver, + #endif ++#if SDL_VIDEO_RENDER_PS4 && 0 // *FIXME* PS4_RenderDriver Disabled, it's software anyhow lets not reinvent... ++#error Use SoftRender for PS4 currently! ++ &PS4_RenderDriver, ++#endif + #if SDL_VIDEO_RENDER_SW + &SW_RenderDriver + #endif +diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h +index ac5426b676..d9b5bfbc39 100644 +--- a/src/render/SDL_sysrender.h ++++ b/src/render/SDL_sysrender.h +@@ -307,6 +307,7 @@ extern SDL_RenderDriver DirectFB_RenderDriver; + extern SDL_RenderDriver METAL_RenderDriver; + extern SDL_RenderDriver PS2_RenderDriver; + extern SDL_RenderDriver PSP_RenderDriver; ++extern SDL_RenderDriver PS4_RenderDriver; + extern SDL_RenderDriver SW_RenderDriver; + extern SDL_RenderDriver VITA_GXM_RenderDriver; + +diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c +index 212fe9c000..a920afba0b 100644 +--- a/src/thread/pthread/SDL_systhread.c ++++ b/src/thread/pthread/SDL_systhread.c +@@ -29,8 +29,10 @@ + #include + #endif + ++#ifdef HAVE_SIGNAL_H + #include + #include ++#endif + + #ifdef __LINUX__ + #include +@@ -60,7 +62,7 @@ + #endif + + +-#ifndef __NACL__ ++#if !defined(__NACL__) && !defined(__OPENORBIS__) + /* List of signals to mask in the subthreads */ + static const int sig_list[] = { + SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, +@@ -162,7 +164,7 @@ void SDL_SYS_SetupThread(const char *name) + } + + /* NativeClient does not yet support signals.*/ +-#if !defined(__NACL__) ++#if !defined(__NACL__) && !defined(__OPENORBIS__) + /* Mask asynchronous signals for this thread */ + sigemptyset(&mask); + for (i = 0; sig_list[i]; ++i) { +diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h +index badb1a3edc..e17beb9f5c 100644 +--- a/src/video/SDL_sysvideo.h ++++ b/src/video/SDL_sysvideo.h +@@ -471,6 +471,7 @@ extern VideoBootStrap PSP_bootstrap; + extern VideoBootStrap VITA_bootstrap; + extern VideoBootStrap RISCOS_bootstrap; + extern VideoBootStrap N3DS_bootstrap; ++extern VideoBootStrap PS4_bootstrap; + extern VideoBootStrap RPI_bootstrap; + extern VideoBootStrap KMSDRM_bootstrap; + extern VideoBootStrap KMSDRM_LEGACY_bootstrap; +diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c +index 134cc05e13..f40d6104e2 100644 +--- a/src/video/SDL_video.c ++++ b/src/video/SDL_video.c +@@ -121,6 +121,9 @@ static VideoBootStrap *bootstrap[] = { + #ifdef SDL_VIDEO_DRIVER_N3DS + &N3DS_bootstrap, + #endif ++#ifdef SDL_VIDEO_DRIVER_PS4 ++ &PS4_bootstrap, ++#endif + #ifdef SDL_VIDEO_DRIVER_KMSDRM + &KMSDRM_bootstrap, + #endif +@@ -241,6 +244,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U + SDL_GetWindowSizeInPixels(window, &w, &h); + + if (!data) { ++ + SDL_Renderer *renderer = NULL; + const char *render_driver = NULL; + const char *hint; +@@ -297,7 +301,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U + SDL_assert(renderer != NULL); /* should have explicitly checked this above. */ + + /* Create the data after we successfully create the renderer (bug #1116) */ +- data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); ++ data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(SDL_WindowTextureData)); + if (!data) { + SDL_DestroyRenderer(renderer); + return SDL_OutOfMemory(); From d8ce333e9814aca3d7e2dce9b17e65367c043c35 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 28 Jan 2026 19:51:50 +0000 Subject: [PATCH 054/108] fixup shit --- externals/CMakeLists.txt | 6 ++++-- src/core/device_memory.h | 16 +++++++++------- src/input_common/CMakeLists.txt | 2 +- src/yuzu_cmd/yuzu.cpp | 17 +---------------- 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 26bbfc9802..923241d892 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -256,8 +256,10 @@ target_include_directories(tz PUBLIC ./tz) add_library(bc_decoder bc_decoder/bc_decoder.cpp) target_include_directories(bc_decoder PUBLIC ./bc_decoder) -add_library(ps4sup ps4sup/emutls.c ps4sup/stub.cpp) -target_include_directories(ps4sup PUBLIC ./ps4sup) +if (PLATFORM_PS4) + add_library(ps4sup ps4sup/emutls.c ps4sup/stub.cpp) + target_include_directories(ps4sup PUBLIC ./ps4sup) +endif() if (NOT TARGET RenderDoc::API) add_library(renderdoc INTERFACE) diff --git a/src/core/device_memory.h b/src/core/device_memory.h index 29d2ff7a2b..11bf0e3268 100644 --- a/src/core/device_memory.h +++ b/src/core/device_memory.h @@ -1,6 +1,3 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later - // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -29,22 +26,27 @@ public: template Common::PhysicalAddress GetPhysicalAddr(const T* ptr) const { - return (uintptr_t(ptr) - uintptr_t(buffer.BackingBasePointer())) + DramMemoryMap::Base; + return (reinterpret_cast(ptr) - + reinterpret_cast(buffer.BackingBasePointer())) + + DramMemoryMap::Base; } template PAddr GetRawPhysicalAddr(const T* ptr) const { - return PAddr(uintptr_t(ptr) - uintptr_t(buffer.BackingBasePointer())); + return static_cast(reinterpret_cast(ptr) - + reinterpret_cast(buffer.BackingBasePointer())); } template T* GetPointer(Common::PhysicalAddress addr) { - return reinterpret_cast(buffer.BackingBasePointer() + (GetInteger(addr) - DramMemoryMap::Base)); + return reinterpret_cast(buffer.BackingBasePointer() + + (GetInteger(addr) - DramMemoryMap::Base)); } template const T* GetPointer(Common::PhysicalAddress addr) const { - return reinterpret_cast(buffer.BackingBasePointer() + (GetInteger(addr) - DramMemoryMap::Base)); + return reinterpret_cast(buffer.BackingBasePointer() + + (GetInteger(addr) - DramMemoryMap::Base)); } template diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index 91dd8558ab..21315eb9c3 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2018 yuzu Emulator Project diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 6724ff59b9..6bc309afcd 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -52,22 +52,7 @@ #include #endif -#ifdef __OPENORBIS__ -#include -#include -#include <__thread/support.h> -# define STUB_WEAK(name) extern "C" void name() { printf("called " #name); asm volatile("ud2"); } -extern "C" void __cxa_thread_atexit_impl() { - //printf("atexit called"); -} -STUB_WEAK(__assert) -STUB_WEAK(ZSTD_trace_compress_begin) -STUB_WEAK(ZSTD_trace_compress_end) -STUB_WEAK(ZSTD_trace_decompress_begin) -STUB_WEAK(ZSTD_trace_decompress_end) -FILE* __stderrp = stdout; -# undef STUB_WEAK -#elif defined(_WIN32) +#if defined(_WIN32) extern "C" { // tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable // graphics From b17cc8198db1d8c5c016750d40d5d873b87303c9 Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 30 Jan 2026 10:01:26 +0000 Subject: [PATCH 055/108] fix --- .ci/ps4/build.sh | 2 ++ src/yuzu_cmd/yuzu.cpp | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 2fdcd01c68..60e8359efd 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -3,6 +3,8 @@ # SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later +[ -z ${OO_PS4_TOOLCHAIN+x} ] && exit + [ -f "ps4-toolchain.cmake" ] || cat << EOF >"ps4-toolchain.cmake" set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN") set(CMAKE_STAGING_PREFIX "$OO_PS4_TOOLCHAIN") diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 6bc309afcd..641030a4d1 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -452,10 +452,6 @@ int main(int argc, char** argv) { }; system.RegisterExitCallback(exit_fn); -#ifdef __linux__ - Common::Linux::StartGamemode(); -#endif - void(system.Run()); if (system.DebuggerEnabled()) { system.InitializeDebugger(); From cf8cb81e66cda9a9617a74a55932590ab146299f Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 30 Jan 2026 10:19:34 +0000 Subject: [PATCH 056/108] add hash --- externals/cpmfile.json | 1 + 1 file changed, 1 insertion(+) diff --git a/externals/cpmfile.json b/externals/cpmfile.json index 8691eafae7..aa9977d859 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -171,6 +171,7 @@ "package": "SDL2", "repo": "libsdl-org/SDL", "sha": "0c7042477a", + "hash": "91d897257fe1134e65234618a96bc8f4f9b61dd3ba42241a65c293cd406139e308a6c79eadfa7c3969271c88d73149e75c4310fff37c79387c80d9c982c1f322", "key": "ps4", "bundled": true, "skip_updates": true, From 2c30ac4c6a357104255101cc7a40efcc8930af4f Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 31 Jan 2026 12:34:57 +0000 Subject: [PATCH 057/108] force ankerl + fixup for OO with prelude commits --- .patch/xbyak/0001-macro-stl.patch | 21 +++++++++++++ .patch/xbyak_sun/0001-macro-stl.patch | 21 +++++++++++++ src/core/arm/dynarmic/arm_dynarmic_32.cpp | 2 +- src/core/arm/dynarmic/arm_dynarmic_64.cpp | 2 +- .../dynarmic/backend/x64/block_of_code.cpp | 31 ++++++++++++++----- 5 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 .patch/xbyak/0001-macro-stl.patch create mode 100644 .patch/xbyak_sun/0001-macro-stl.patch diff --git a/.patch/xbyak/0001-macro-stl.patch b/.patch/xbyak/0001-macro-stl.patch new file mode 100644 index 0000000000..5cfb9eeec6 --- /dev/null +++ b/.patch/xbyak/0001-macro-stl.patch @@ -0,0 +1,21 @@ +diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h +index ed7706a..51b520d 100644 +--- a/xbyak/xbyak.h ++++ b/xbyak/xbyak.h +@@ -37,6 +37,7 @@ + #define XBYAK_GNUC_PREREQ(major, minor) 0 + #endif + ++#if !defined(XBYAK_STD_UNORDERED_SET) + // This covers -std=(gnu|c)++(0x|11|1y), -stdlib=libc++, and modern Microsoft. + #if ((defined(_MSC_VER) && (_MSC_VER >= 1600)) || defined(_LIBCPP_VERSION) ||\ + ((__cplusplus >= 201103) || defined(__GXX_EXPERIMENTAL_CXX0X__))) +@@ -71,6 +72,8 @@ + #define XBYAK_STD_UNORDERED_MAP std::map + #define XBYAK_STD_UNORDERED_MULTIMAP std::multimap + #endif ++#endif ++ + #ifdef _WIN32 + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN diff --git a/.patch/xbyak_sun/0001-macro-stl.patch b/.patch/xbyak_sun/0001-macro-stl.patch new file mode 100644 index 0000000000..5cfb9eeec6 --- /dev/null +++ b/.patch/xbyak_sun/0001-macro-stl.patch @@ -0,0 +1,21 @@ +diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h +index ed7706a..51b520d 100644 +--- a/xbyak/xbyak.h ++++ b/xbyak/xbyak.h +@@ -37,6 +37,7 @@ + #define XBYAK_GNUC_PREREQ(major, minor) 0 + #endif + ++#if !defined(XBYAK_STD_UNORDERED_SET) + // This covers -std=(gnu|c)++(0x|11|1y), -stdlib=libc++, and modern Microsoft. + #if ((defined(_MSC_VER) && (_MSC_VER >= 1600)) || defined(_LIBCPP_VERSION) ||\ + ((__cplusplus >= 201103) || defined(__GXX_EXPERIMENTAL_CXX0X__))) +@@ -71,6 +72,8 @@ + #define XBYAK_STD_UNORDERED_MAP std::map + #define XBYAK_STD_UNORDERED_MULTIMAP std::multimap + #endif ++#endif ++ + #ifdef _WIN32 + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index bf473eb07b..78b1dc20a8 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -200,7 +200,7 @@ void ArmDynarmic32::MakeJit(Common::PageTable* page_table) { // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(8_MiB); + config.code_cache_size = std::uint32_t(32_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 88bd0cfad9..c831e3c9da 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -253,7 +253,7 @@ void ArmDynarmic64::MakeJit(Common::PageTable* page_table, std::size_t address_s // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(8_MiB); + config.code_cache_size = std::uint32_t(32_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else diff --git a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp index 5b27b9eb94..be55632062 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp @@ -58,8 +58,13 @@ const std::array BlockOfCode::ABI_PARAMS = {Block namespace { +#ifdef __OPENORBIS__ +constexpr size_t CONSTANT_POOL_SIZE = 8 * 4096; +constexpr size_t PRELUDE_COMMIT_SIZE = 8 * 4096; +#else constexpr size_t CONSTANT_POOL_SIZE = 2 * 1024 * 1024; constexpr size_t PRELUDE_COMMIT_SIZE = 16 * 1024 * 1024; +#endif class CustomXbyakAllocator : public Xbyak::Allocator { public: @@ -67,8 +72,12 @@ public: uint8_t* alloc(size_t size) override { void* p = VirtualAlloc(nullptr, size, MEM_RESERVE, PAGE_READWRITE); if (p == nullptr) { +#ifndef XBYAK_NO_EXCEPTION using Xbyak::Error; XBYAK_THROW(Xbyak::ERR_CANT_ALLOC); +#else + std::abort(); +#endif } return static_cast(p); } @@ -106,8 +115,12 @@ public: #endif void* p = mmap(nullptr, size, prot, mode, -1, 0); if (p == MAP_FAILED) { +#ifndef XBYAK_NO_EXCEPTION using Xbyak::Error; XBYAK_THROW(Xbyak::ERR_CANT_ALLOC); +#else + std::abort(); +#endif } std::memcpy(p, &size, sizeof(size_t)); return static_cast(p) + DYNARMIC_PAGE_SIZE; @@ -233,14 +246,14 @@ bool IsUnderRosetta() { } // anonymous namespace -#ifdef DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT -static const auto default_cg_mode = Xbyak::DontSetProtectRWE; -#else -static const auto default_cg_mode = nullptr; //Allow RWE -#endif - BlockOfCode::BlockOfCode(RunCodeCallbacks cb, JitStateInfo jsi, size_t total_code_size, std::function rcp) noexcept - : Xbyak::CodeGenerator(total_code_size, default_cg_mode, &s_allocator) +#ifdef __OPENORBIS__ + : Xbyak::CodeGenerator(total_code_size, Xbyak::AutoGrow, &s_allocator) +#elif defined(DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT) + : Xbyak::CodeGenerator(total_code_size, Xbyak::DontSetProtectRWE, &s_allocator) +#else + : Xbyak::CodeGenerator(total_code_size, nullptr, &s_allocator) +#endif , cb(std::move(cb)) , jsi(jsi) , constant_pool(*this, CONSTANT_POOL_SIZE) @@ -533,8 +546,12 @@ size_t BlockOfCode::GetTotalCodeSize() const { void* BlockOfCode::AllocateFromCodeSpace(size_t alloc_size) { if (size_ + alloc_size >= maxSize_) { +#ifndef XBYAK_NO_EXCEPTION using Xbyak::Error; XBYAK_THROW(Xbyak::ERR_CODE_IS_TOO_BIG); +#else + std::abort(); +#endif } EnsureMemoryCommitted(alloc_size); From a63a27c8778c886d9318ed917050498db5ef5116 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 1 Feb 2026 03:39:22 +0000 Subject: [PATCH 058/108] use dmem for swap buffers, restore full jit sizes --- src/common/virtual_buffer.cpp | 12 +++++++++--- src/core/arm/dynarmic/arm_dynarmic_32.cpp | 2 +- src/core/arm/dynarmic/arm_dynarmic_64.cpp | 2 +- .../src/dynarmic/backend/x64/block_of_code.cpp | 9 +-------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 48f26ec298..bd647b0acf 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -16,6 +16,7 @@ #include #include #include +#include typedef void (*SceKernelExceptionHandler)(int32_t, void*); extern "C" int32_t sceKernelInstallExceptionHandler(int32_t signum, SceKernelExceptionHandler handler); #endif @@ -143,8 +144,13 @@ void* AllocateMemoryPages(std::size_t size) noexcept { #elif defined(__OPENORBIS__) void* addr; if (size <= 8192 * 4096) { - addr = malloc(size); - LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", size, addr); + size_t align = 16384; + size_t len = (size + align - 1) / align * align; + off_t offset = 0; + ASSERT(sceKernelAllocateDirectMemory(0, ORBIS_KERNEL_MAIN_DMEM_SIZE, len, align, ORBIS_KERNEL_WB_ONION, &offset) == 0); + ASSERT(sceKernelMapDirectMemory(&addr, len, ORBIS_KERNEL_PROT_CPU_RW, 0, offset, len) == 0); + ASSERT(sceKernelMprotect(addr, len, VM_PROT_ALL) == 0); + LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", len, addr); ASSERT(addr != nullptr); } else { addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); @@ -166,7 +172,7 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { VirtualFree(addr, 0, MEM_RELEASE); #elif defined(__OPENORBIS__) if (size <= 8192 * 4096) { - free(addr); + sceKernelCheckedReleaseDirectMemory(off_t(addr), size_t(size)); } else { int rc = munmap(addr, size); ASSERT(rc == 0); diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 78b1dc20a8..fb8e27e0ec 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -200,7 +200,7 @@ void ArmDynarmic32::MakeJit(Common::PageTable* page_table) { // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(32_MiB); + config.code_cache_size = std::uint32_t(128_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index c831e3c9da..20f925f85c 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -253,7 +253,7 @@ void ArmDynarmic64::MakeJit(Common::PageTable* page_table, std::size_t address_s // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(32_MiB); + config.code_cache_size = std::uint32_t(128_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else diff --git a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp index be55632062..a85122b5ad 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp @@ -58,13 +58,8 @@ const std::array BlockOfCode::ABI_PARAMS = {Block namespace { -#ifdef __OPENORBIS__ -constexpr size_t CONSTANT_POOL_SIZE = 8 * 4096; -constexpr size_t PRELUDE_COMMIT_SIZE = 8 * 4096; -#else constexpr size_t CONSTANT_POOL_SIZE = 2 * 1024 * 1024; constexpr size_t PRELUDE_COMMIT_SIZE = 16 * 1024 * 1024; -#endif class CustomXbyakAllocator : public Xbyak::Allocator { public: @@ -247,9 +242,7 @@ bool IsUnderRosetta() { } // anonymous namespace BlockOfCode::BlockOfCode(RunCodeCallbacks cb, JitStateInfo jsi, size_t total_code_size, std::function rcp) noexcept -#ifdef __OPENORBIS__ - : Xbyak::CodeGenerator(total_code_size, Xbyak::AutoGrow, &s_allocator) -#elif defined(DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT) +#if defined(DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT) : Xbyak::CodeGenerator(total_code_size, Xbyak::DontSetProtectRWE, &s_allocator) #else : Xbyak::CodeGenerator(total_code_size, nullptr, &s_allocator) From a2c7df87f7e2034ce69d493f7a626bab65ae5cff Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 1 Feb 2026 03:39:53 +0000 Subject: [PATCH 059/108] fix yuzu cpp --- src/yuzu_cmd/yuzu.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 641030a4d1..9a8b809656 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -52,7 +52,10 @@ #include #endif -#if defined(_WIN32) +#if defined(__OPENORBIS__) +#include +#include +#elif defined(_WIN32) extern "C" { // tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable // graphics From 6f1b5f680370ee144f790e7fd320f3e9e2151c54 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 2 Feb 2026 07:30:19 +0000 Subject: [PATCH 060/108] reduce fiber sizes --- src/common/fiber.cpp | 2 +- src/core/arm/dynarmic/arm_dynarmic_32.cpp | 2 +- src/core/arm/dynarmic/arm_dynarmic_64.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index 0c9bd4fb4d..4f3dad7e88 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp @@ -16,7 +16,7 @@ namespace Common { #ifdef __OPENORBIS__ -constexpr size_t DEFAULT_STACK_SIZE = 256 * 4096; +constexpr size_t DEFAULT_STACK_SIZE = 32 * 4096; #else constexpr size_t DEFAULT_STACK_SIZE = 512 * 4096; #endif diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index fb8e27e0ec..bf473eb07b 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -200,7 +200,7 @@ void ArmDynarmic32::MakeJit(Common::PageTable* page_table) { // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(128_MiB); + config.code_cache_size = std::uint32_t(8_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 20f925f85c..88bd0cfad9 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -253,7 +253,7 @@ void ArmDynarmic64::MakeJit(Common::PageTable* page_table, std::size_t address_s // Code cache size #if defined(__OPENORBIS__) - config.code_cache_size = std::uint32_t(128_MiB); + config.code_cache_size = std::uint32_t(8_MiB); #elif defined(ARCHITECTURE_arm64) || defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) config.code_cache_size = std::uint32_t(128_MiB); #else From e671b32d21b8670eab3ae61b457975d292c9fe3c Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 2 Feb 2026 11:43:45 +0000 Subject: [PATCH 061/108] use btver2 --- .ci/ps4/build.sh | 6 ++++-- src/common/host_memory.cpp | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 60e8359efd..cec9876dcd 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -10,8 +10,8 @@ set(CMAKE_SYSROOT "$OO_PS4_TOOLCHAIN") set(CMAKE_STAGING_PREFIX "$OO_PS4_TOOLCHAIN") set(CMAKE_SYSTEM_NAME "OpenOrbis") -set(CMAKE_C_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -fPIC -funwind-tables") -set(CMAKE_CXX_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=x86-64 -march=x86-64 -fPIC -funwind-tables") +set(CMAKE_C_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=btver2 -march=btver2 -fPIC -funwind-tables") +set(CMAKE_CXX_FLAGS " -D__OPENORBIS__ -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 --target=x86_64-pc-freebsd12-elf -mtune=btver2 -march=btver2 -fPIC -funwind-tables") set(CMAKE_EXE_LINKER_FLAGS "-m elf_x86_64 -pie -T $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib") set(CMAKE_C_LINK_FLAGS "-m elf_x86_64 -pie -T $OO_PS4_TOOLCHAIN/link.x --eh-frame-hdr -L$OO_PS4_TOOLCHAIN/lib") @@ -59,3 +59,5 @@ cmake -S . -B build -G "Unix Makefiles" \ -DYUZU_USE_EXTERNAL_SDL2=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit cmake --build build -t yuzu-cmd_pkg -- -j$NPROC +#cmake --build build -t dynarmic_tests_pkg -- -j$NPROC +#cmake --build build -t testps4_pkg -- -j$NPROC diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 6ac1188a1a..fa03b6d211 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -501,9 +501,7 @@ class HostMemory::Impl { public: explicit Impl(size_t backing_size_, size_t virtual_size_) : backing_size{backing_size_}, virtual_size{virtual_size_} { -#ifdef __OPENORBIS__ - -#else +#if !defined(__OPENORBIS__) && !defined(__APPLE__) long page_size = sysconf(_SC_PAGESIZE); ASSERT_MSG(page_size == 0x1000, "page size {:#x} is incompatible with 4K paging", page_size); #endif From 7d50c070b8f916c2983882e2e8f1b6fa369fd24b Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 2 Feb 2026 12:55:01 +0000 Subject: [PATCH 062/108] immediately terminate in OO, use 2MB swap handler --- src/common/virtual_buffer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index bd647b0acf..409f3efefa 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -114,7 +114,7 @@ static void SwapHandler(int sig, void* raw_context) { if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second; }); it != swap_regions.end()) { - size_t const page_size = 4096 * 8; //16K + size_t const page_size = 0x200000; //2M size_t const page_mask = ~(page_size - 1); // should replace the existing mapping... ugh void* aligned_addr = reinterpret_cast(uintptr_t(mctx.mc_addr) & page_mask); @@ -149,7 +149,6 @@ void* AllocateMemoryPages(std::size_t size) noexcept { off_t offset = 0; ASSERT(sceKernelAllocateDirectMemory(0, ORBIS_KERNEL_MAIN_DMEM_SIZE, len, align, ORBIS_KERNEL_WB_ONION, &offset) == 0); ASSERT(sceKernelMapDirectMemory(&addr, len, ORBIS_KERNEL_PROT_CPU_RW, 0, offset, len) == 0); - ASSERT(sceKernelMprotect(addr, len, VM_PROT_ALL) == 0); LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", len, addr); ASSERT(addr != nullptr); } else { From 7f84b4758de482d70aadcfec353ce0ee7aa661d5 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 2 Feb 2026 23:11:31 +0000 Subject: [PATCH 063/108] restore protection --- src/common/virtual_buffer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 409f3efefa..cd269cb997 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -149,6 +149,7 @@ void* AllocateMemoryPages(std::size_t size) noexcept { off_t offset = 0; ASSERT(sceKernelAllocateDirectMemory(0, ORBIS_KERNEL_MAIN_DMEM_SIZE, len, align, ORBIS_KERNEL_WB_ONION, &offset) == 0); ASSERT(sceKernelMapDirectMemory(&addr, len, ORBIS_KERNEL_PROT_CPU_RW, 0, offset, len) == 0); + ASSERT(sceKernelMprotect(addr, len, VM_PROT_ALL) == 0); LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", len, addr); ASSERT(addr != nullptr); } else { From 299876e92dde95007357c55f21b236ab62ad240c Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 2 Feb 2026 23:12:17 +0000 Subject: [PATCH 064/108] leave pending param package stuff --- src/common/param_package.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index b2803a4fcf..c4cded8735 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp @@ -78,7 +78,9 @@ std::string ParamPackage::Serialize() const { std::string ParamPackage::Get(const std::string& key, const std::string& default_value) const { auto pair = data.find(key); if (pair == data.end()) { +#ifndef __OPENORBIS__ LOG_TRACE(Common, "key '{}' not found", key); +#endif return default_value; } @@ -88,7 +90,9 @@ std::string ParamPackage::Get(const std::string& key, const std::string& default int ParamPackage::Get(const std::string& key, int default_value) const { auto pair = data.find(key); if (pair == data.end()) { +#ifndef __OPENORBIS__ LOG_TRACE(Common, "key '{}' not found", key); +#endif return default_value; } @@ -103,7 +107,9 @@ int ParamPackage::Get(const std::string& key, int default_value) const { float ParamPackage::Get(const std::string& key, float default_value) const { auto pair = data.find(key); if (pair == data.end()) { +#ifndef __OPENORBIS__ LOG_TRACE(Common, "key {} not found", key); +#endif return default_value; } From d960f9c67f52febd7e0a2314abf5d0f0f5eac6a9 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 2 Feb 2026 23:14:39 +0000 Subject: [PATCH 065/108] let it rip --- src/common/param_package.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index c4cded8735..b2803a4fcf 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp @@ -78,9 +78,7 @@ std::string ParamPackage::Serialize() const { std::string ParamPackage::Get(const std::string& key, const std::string& default_value) const { auto pair = data.find(key); if (pair == data.end()) { -#ifndef __OPENORBIS__ LOG_TRACE(Common, "key '{}' not found", key); -#endif return default_value; } @@ -90,9 +88,7 @@ std::string ParamPackage::Get(const std::string& key, const std::string& default int ParamPackage::Get(const std::string& key, int default_value) const { auto pair = data.find(key); if (pair == data.end()) { -#ifndef __OPENORBIS__ LOG_TRACE(Common, "key '{}' not found", key); -#endif return default_value; } @@ -107,9 +103,7 @@ int ParamPackage::Get(const std::string& key, int default_value) const { float ParamPackage::Get(const std::string& key, float default_value) const { auto pair = data.find(key); if (pair == data.end()) { -#ifndef __OPENORBIS__ LOG_TRACE(Common, "key {} not found", key); -#endif return default_value; } From ac17c11f6d664170c340a7c243fec3f6c7f3808b Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 18 Feb 2026 19:49:28 +0000 Subject: [PATCH 066/108] FX --- src/input_common/drivers/sdl_driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 981d37e36d..ad854110ef 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2018 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later From bbfac0d6c978e08c519ee27b9630a3f140408de0 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 25 Feb 2026 15:25:16 +0000 Subject: [PATCH 067/108] disable stdio buffering --- src/yuzu_cmd/yuzu.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 9a8b809656..34b8a1530d 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -186,6 +186,11 @@ int main(int argc, char** argv) { freopen("CONOUT$", "wb", stderr); } #endif +#ifdef __OPENORBIS__ + // May prevent spurious crashes on swap handlers... + setvbuf(stdout, nullptr, _IONBF, 0); + setvbuf(stderr, nullptr, _IONBF, 0); +#endif Common::Log::Initialize(); Common::Log::SetColorConsoleBackendEnabled(true); From 5257a9e0f3c36b665a33bdf70fcadb8edbfe2ed3 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 26 Feb 2026 01:07:06 +0000 Subject: [PATCH 068/108] fix openssl --- .ci/ps4/build.sh | 4 ++++ externals/ps4sup/stub.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index cec9876dcd..c7bb54deaa 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -52,6 +52,10 @@ cmake -S . -B build -G "Unix Makefiles" \ -DENABLE_WEB_SERVICE=OFF \ -DUSE_DISCORD_PRESENCE=OFF \ -DCPMUTIL_FORCE_BUNDLED=ON \ + -DOPENSSL_ROOT_DIR="$OO_PS4_TOOLCHAIN" \ + -DOPENSSL_SSL_LIBRARY="$OO_PS4_TOOLCHAIN/lib/libssl.a" \ + -DOPENSSL_CRYPTO_LIBRARY="$OO_PS4_TOOLCHAIN/lib/libcrypto.a" \ + -DOPENSSL_INCLUDE_DIR="$OO_PS4_TOOLCHAIN/include/openssl" \ -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ -DDYNARMIC_ENABLE_NO_EXECUTE_SUPPORT=OFF \ diff --git a/externals/ps4sup/stub.cpp b/externals/ps4sup/stub.cpp index bee5613486..562fbd4a38 100644 --- a/externals/ps4sup/stub.cpp +++ b/externals/ps4sup/stub.cpp @@ -16,7 +16,17 @@ STUB_WEAK(ZSTD_trace_compress_begin) STUB_WEAK(ZSTD_trace_compress_end) STUB_WEAK(ZSTD_trace_decompress_begin) STUB_WEAK(ZSTD_trace_decompress_end) + FILE* __stderrp = stdout; +FILE* __stdinp = stdin; + +extern "C" { +struct _RuneLocale; +thread_local const _RuneLocale *_ThreadRuneLocale = NULL; +const _RuneLocale *_CurrentRuneLocale = NULL; +int __isthreaded = 0; +int __mb_sb_limit = 0; +} #undef STUB_WEAK From cb35ddef832b9a330da3b7a120d6d19717de15d3 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 5 Mar 2026 22:01:58 +0000 Subject: [PATCH 069/108] fix virtual buffers --- src/common/virtual_buffer.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index cd269cb997..8acb75fc57 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -142,17 +142,32 @@ void* AllocateMemoryPages(std::size_t size) noexcept { void* addr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); ASSERT(addr != nullptr); #elif defined(__OPENORBIS__) - void* addr; + bool use_void_mem = true; + void* addr = nullptr; if (size <= 8192 * 4096) { size_t align = 16384; - size_t len = (size + align - 1) / align * align; - off_t offset = 0; - ASSERT(sceKernelAllocateDirectMemory(0, ORBIS_KERNEL_MAIN_DMEM_SIZE, len, align, ORBIS_KERNEL_WB_ONION, &offset) == 0); - ASSERT(sceKernelMapDirectMemory(&addr, len, ORBIS_KERNEL_PROT_CPU_RW, 0, offset, len) == 0); - ASSERT(sceKernelMprotect(addr, len, VM_PROT_ALL) == 0); - LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", len, addr); - ASSERT(addr != nullptr); - } else { + off_t offset; + int32_t res; + size = (size + align - 1) / align * align; + if ((res = sceKernelAllocateDirectMemory(0, ORBIS_KERNEL_MAIN_DMEM_SIZE, size, align, ORBIS_KERNEL_WB_ONION, &offset)) == 0) { + if ((res = sceKernelMapDirectMemory(&addr, size, ORBIS_KERNEL_PROT_CPU_READ | ORBIS_KERNEL_PROT_CPU_WRITE, 0, offset, size)) == 0) { + if ((res = sceKernelMprotect(addr, size, VM_PROT_ALL)) == 0 && addr != nullptr) { + LOG_WARNING(HW_Memory, "Using DMem for {} bytes area @ {}", size, addr); + use_void_mem = false; //Memory properly mapped + } else { + sceKernelReleaseDirectMemory(offset, size); + LOG_ERROR(HW_Memory, "{} = sceKernelMprotect({}, {})", res, offset, size); + } + } else { + sceKernelReleaseDirectMemory(offset, size); + LOG_ERROR(HW_Memory, "{} = sceKernelMapDirectMemory({}, {})", res, offset, size); + } + } else { + sceKernelReleaseDirectMemory(offset, size); + LOG_ERROR(HW_Memory, "{} = sceKernelAllocateDirectMemory({}, {}, {})", res, size, align, offset); + } + } + if (use_void_mem) { addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_VOID | MAP_PRIVATE, -1, 0); LOG_WARNING(HW_Memory, "Using VoidMem for {} bytes area @ {}", size, addr); ASSERT(addr != MAP_FAILED); From 630efd7f13d3a4bd45c2d1db771f8e9dea7c15b6 Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 6 Mar 2026 20:22:37 +0000 Subject: [PATCH 070/108] init audio --- src/yuzu_cmd/yuzu.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 34b8a1530d..5c8a76fcf3 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -15,6 +15,7 @@ #include "common/logging.h" #include "common/scm_rev.h" #include "common/settings.h" +#include "common/settings_enums.h" #include "common/string_util.h" #include "core/core.h" #include "core/core_timing.h" @@ -55,6 +56,8 @@ #if defined(__OPENORBIS__) #include #include +#include +#include #elif defined(_WIN32) extern "C" { // tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable From 712be375cbc0db6132c1fa715b138fdc4e585fcd Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 7 Mar 2026 21:07:14 +0000 Subject: [PATCH 071/108] native ps4 audio sink --- src/audio_core/CMakeLists.txt | 6 ++ src/audio_core/sink/ps4_sink.cpp | 156 +++++++++++++++++++++++++++ src/audio_core/sink/ps4_sink.h | 43 ++++++++ src/audio_core/sink/sink_details.cpp | 17 ++- src/common/settings_enums.h | 3 +- src/core/hle/service/services.cpp | 2 +- 6 files changed, 224 insertions(+), 3 deletions(-) create mode 100644 src/audio_core/sink/ps4_sink.cpp create mode 100644 src/audio_core/sink/ps4_sink.h diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index c76073a4db..52df259479 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -254,4 +254,10 @@ else() target_compile_definitions(audio_core PRIVATE HAVE_SDL3) endif() +if(PLATFORM_PS4) + target_sources(audio_core PRIVATE + sink/ps4_sink.cpp + sink/ps4_sink.h) +endif() + create_target_directory_groups(audio_core) diff --git a/src/audio_core/sink/ps4_sink.cpp b/src/audio_core/sink/ps4_sink.cpp new file mode 100644 index 0000000000..42b151f49f --- /dev/null +++ b/src/audio_core/sink/ps4_sink.cpp @@ -0,0 +1,156 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include +#include +#include + +#include + +#include "audio_core/common/common.h" +#include "audio_core/sink/ps4_sink.h" +#include "audio_core/sink/sink_stream.h" +#include "common/logging/log.h" +#include "common/scope_exit.h" +#include "core/core.h" + +namespace AudioCore::Sink { + +/// @brief PS4 sink stream, responsible for sinking samples to hardware. +struct PS4SinkStream final : public SinkStream { + /// @brief Create a new sink stream. + /// @param device_channels_ - Number of channels supported by the hardware. + /// @param system_channels_ - Number of channels the audio systems expect. + /// @param output_device - Name of the output device to use for this stream. + /// @param input_device - Name of the input device to use for this stream. + /// @param type_ - Type of this stream. + /// @param system_ - Core system. + /// @param event - Event used only for audio renderer, signalled on buffer consume. + PS4SinkStream(u32 device_channels_, u32 system_channels_, const std::string& output_device, const std::string& input_device, StreamType type_, Core::System& system_) + : SinkStream{system_, type_} + { + system_channels = system_channels_; + device_channels = device_channels_; + + auto const length = 0x800; + auto const sample_rate = 48000; + auto const num_channels = this->GetDeviceChannels(); + output_buffer.resize(length * num_channels * sizeof(s16)); + + auto const param_type = num_channels == 1 ? ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO : ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO; + audio_dev = sceAudioOutOpen(ORBIS_USER_SERVICE_USER_ID_SYSTEM, ORBIS_AUDIO_OUT_PORT_TYPE_MAIN, 0, length, sample_rate, param_type); + if (audio_dev > 0) { + audio_thread = std::jthread([=, this](std::stop_token stop_token) { + while (!stop_token.stop_requested()) { + if (this->type == StreamType::In) { + // this->ProcessAudioIn(input_buffer, length); + } else { + sceAudioOutOutput(audio_dev, nullptr); + this->ProcessAudioOutAndRender(output_buffer, length); + sceAudioOutOutput(audio_dev, output_buffer.data()); + } + } + }); + } else { + LOG_ERROR(Service_Audio, "Failed to create audio device! {:#x}", uint32_t(audio_dev)); + } + } + + ~PS4SinkStream() override { + LOG_DEBUG(Service_Audio, "Destroying PS4 stream {}", name); + sceAudioOutClose(audio_dev); + if (audio_thread.joinable()) { + audio_thread.request_stop(); + audio_thread.join(); + } + } + + void Finalize() override { + if (audio_dev > 0) { + Stop(); + sceAudioOutClose(audio_dev); + } + } + + void Start(bool resume = false) override { + if (audio_dev > 0 && paused) { + paused = false; + } + } + + void Stop() override { + if (audio_dev > 0 && !paused) { + + } + } + + std::vector output_buffer; + std::jthread audio_thread; + int32_t audio_dev{}; +}; + +PS4Sink::PS4Sink(std::string_view target_device_name) { + int32_t rc = sceAudioOutInit(); + if (rc == 0 || unsigned(rc) == ORBIS_AUDIO_OUT_ERROR_ALREADY_INIT) { + if (target_device_name != auto_device_name && !target_device_name.empty()) { + output_device = target_device_name; + } else { + output_device.clear(); + } + device_channels = 2; + } else { + LOG_ERROR(Service_Audio, "Unable to open audio out! {:#x}", uint32_t(rc)); + } +} + +PS4Sink::~PS4Sink() = default; + +/// @brief Create a new sink stream. +/// @param system - Core system. +/// @param system_channels - Number of channels the audio system expects. May differ from the device's channel count. +/// @param name - Name of this stream. +/// @param type - Type of this stream, render/in/out. +/// @return A pointer to the created SinkStream +SinkStream* PS4Sink::AcquireSinkStream(Core::System& system, u32 system_channels_, const std::string&, StreamType type) { + system_channels = system_channels_; + SinkStreamPtr& stream = sink_streams.emplace_back(std::make_unique(device_channels, system_channels, output_device, input_device, type, system)); + return stream.get(); +} + +void PS4Sink::CloseStream(SinkStream* stream) { + for (size_t i = 0; i < sink_streams.size(); i++) { + if (sink_streams[i].get() == stream) { + sink_streams[i].reset(); + sink_streams.erase(sink_streams.begin() + i); + break; + } + } +} + +void PS4Sink::CloseStreams() { + sink_streams.clear(); +} + +f32 PS4Sink::GetDeviceVolume() const { + return sink_streams.size() > 0 ? sink_streams[0]->GetDeviceVolume() : 1.f; +} + +void PS4Sink::SetDeviceVolume(f32 volume) { + for (auto& stream : sink_streams) + stream->SetDeviceVolume(volume); +} + +void PS4Sink::SetSystemVolume(f32 volume) { + for (auto& stream : sink_streams) + stream->SetSystemVolume(volume); +} + +std::vector ListPS4SinkDevices(bool capture) { + return {{"Default"}}; +} + +u32 GetPS4Latency() { + return TargetSampleCount * 2; +} + +} // namespace AudioCore::Sink diff --git a/src/audio_core/sink/ps4_sink.h b/src/audio_core/sink/ps4_sink.h new file mode 100644 index 0000000000..cfc8c293bb --- /dev/null +++ b/src/audio_core/sink/ps4_sink.h @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include + +#include "audio_core/sink/sink.h" + +namespace Core { +class System; +} + +namespace AudioCore::Sink { +class SinkStream; + +/// @brief PS4 backend sink, holds multiple output streams and is responsible for sinking samples to +/// hardware. Used by Audio Render, Audio In and Audio Out. +struct PS4Sink final : public Sink { + explicit PS4Sink(std::string_view device_id); + ~PS4Sink() override; + SinkStream* AcquireSinkStream(Core::System& system, u32 system_channels, const std::string& name, StreamType type) override; + void CloseStream(SinkStream* stream) override; + void CloseStreams() override; + f32 GetDeviceVolume() const override; + void SetDeviceVolume(f32 volume) override; + void SetSystemVolume(f32 volume) override; + /// Name of the output device used by streams + std::string output_device; + /// Name of the input device used by streams + std::string input_device; + /// Vector of streams managed by this sink + std::vector sink_streams; +}; + +std::vector ListPS4SinkDevices(bool capture); +u32 GetPS4Latency(); + +} // namespace AudioCore::Sink diff --git a/src/audio_core/sink/sink_details.cpp b/src/audio_core/sink/sink_details.cpp index 1b737eb12e..9fe182d6fa 100644 --- a/src/audio_core/sink/sink_details.cpp +++ b/src/audio_core/sink/sink_details.cpp @@ -19,6 +19,9 @@ #ifdef HAVE_SDL3 #include "audio_core/sink/sdl3_sink.h" #endif +#ifdef __OPENORBIS__ +#include "audio_core/sink/ps4_sink.h" +#endif #include "audio_core/sink/null_sink.h" #include "common/logging.h" #include "common/settings_enums.h" @@ -51,6 +54,16 @@ struct SinkDetails { // sink_details is ordered in terms of desirability, with the best choice at the top. constexpr SinkDetails sink_details[] = { +#ifdef __OPENORBIS__ + SinkDetails{ + Settings::AudioEngine::Ps4, + [](std::string_view device_id) -> std::unique_ptr { + return std::make_unique(device_id); + }, + &ListPS4SinkDevices, + &GetPS4Latency, + }, +#endif #ifdef HAVE_OBOE SinkDetails{ Settings::AudioEngine::Oboe, @@ -115,7 +128,9 @@ const SinkDetails& GetOutputSinkDetails(Settings::AudioEngine sink_id) { // BEGIN REINTRODUCED FROM 3833 - REPLACED CODE BLOCK ABOVE - DIABLO 3 FIX // Auto-select a backend. Prefer CubeB, but it may report a large minimum latency which // causes audio issues, in that case go with SDL. -#if defined(HAVE_CUBEB) && defined(HAVE_SDL3) +#if defined(__OPENORBIS__) + iter = find_backend(Settings::AudioEngine::Ps4); +#elif defined(HAVE_CUBEB) && defined(HAVE_SDL3) iter = find_backend(Settings::AudioEngine::Cubeb); if (iter->latency() > TargetSampleCount * 3) { iter = find_backend(Settings::AudioEngine::Sdl3); diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 9a406e432b..331b4c51f6 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -92,7 +92,7 @@ struct EnumMetadata { // AudioEngine must be specified discretely due to having existing but slightly different // canonicalizations // TODO (lat9nq): Remove explicit definition of AudioEngine/sink_id -enum class AudioEngine : u32 { Auto, Cubeb, Sdl3, Null, Oboe, }; +enum class AudioEngine : u32 { Auto, Cubeb, Sdl3, Null, Oboe, Ps4, }; template<> inline std::vector> EnumMetadata::Canonicalizations() { return { @@ -100,6 +100,7 @@ inline std::vector> EnumMetadata& sm, Core::System& system {"nvservices", &Nvidia::LoopProcess}, {"bsdsocket", &Sockets::LoopProcess}, }) { - if (run_on_host) kernel.RunOnHostCoreProcess("vi", [&, token] { VI::LoopProcess(system, token); }).detach(); + if (run_on_host) kernel.RunOnHostCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); }).detach(); else kernel.RunOnGuestCoreProcess(std::string(e.first), [&system, f = e.second] { f(system); }); } if (run_on_host) kernel.RunOnHostCoreProcess("vi", [&, token] { VI::LoopProcess(system, token); }).detach(); From fe7a9de48ebeaecf580cc25d7bd6accdbc649903 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 8 Mar 2026 23:07:56 +0000 Subject: [PATCH 072/108] try fix musl 2 --- externals/ps4sup/stub.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/externals/ps4sup/stub.cpp b/externals/ps4sup/stub.cpp index 562fbd4a38..ebaef27acc 100644 --- a/externals/ps4sup/stub.cpp +++ b/externals/ps4sup/stub.cpp @@ -9,7 +9,11 @@ asm volatile("ud2"); \ } -extern "C" void __cxa_thread_atexit_impl() {} +extern "C" int __pthread_cxa_finalize(); +extern "C" void __cxa_thread_atexit_impl() { + //printf("__cxa_thread_atexit_impl called!\n"); + //__pthread_cxa_finalize(); +} STUB_WEAK(__assert) STUB_WEAK(ZSTD_trace_compress_begin) @@ -20,14 +24,6 @@ STUB_WEAK(ZSTD_trace_decompress_end) FILE* __stderrp = stdout; FILE* __stdinp = stdin; -extern "C" { -struct _RuneLocale; -thread_local const _RuneLocale *_ThreadRuneLocale = NULL; -const _RuneLocale *_CurrentRuneLocale = NULL; -int __isthreaded = 0; -int __mb_sb_limit = 0; -} - #undef STUB_WEAK // THIS MAKES STD::COUT AND SUCH WORK :) From 728ac85ba4b022fc3daeaac8900b3f38ce444a55 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 8 Mar 2026 23:08:18 +0000 Subject: [PATCH 073/108] needs libscienternal --- .ci/ps4/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index c7bb54deaa..8a5a64c5ec 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -20,8 +20,8 @@ set(CMAKE_CXX_LINK_FLAGS "-m elf_x86_64 -pie -T $OO_PS4_TOOLCHAIN/link.x --eh-fr set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) set(CMAKE_LINKER ld.lld) -set(CMAKE_C_LINK_EXECUTABLE " -o -lc -lkernel -lSceUserService -lSceSysmodule -lSceNet $OO_PS4_TOOLCHAIN/lib/crt1.o ") -set(CMAKE_CXX_LINK_EXECUTABLE " -o -lc -lkernel -lc++ -lSceUserService -lSceSysmodule -lSceNet $OO_PS4_TOOLCHAIN/lib/crt1.o ") +set(CMAKE_C_LINK_EXECUTABLE " -o -lc -lkernel -lSceUserService -lSceSysmodule -lSceNet -lSceLibcInternal $OO_PS4_TOOLCHAIN/lib/crt1.o ") +set(CMAKE_CXX_LINK_EXECUTABLE " -o -lc -lkernel -lc++ -lSceUserService -lSceSysmodule -lSceNet -lSceLibcInternal $OO_PS4_TOOLCHAIN/lib/crt1.o ") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) From 344a2ff0098434b02b354a603239a73cde602960 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 16 Mar 2026 21:38:52 +0000 Subject: [PATCH 074/108] disable openssl and register user --- externals/cpmfile.json | 2 +- src/yuzu_cmd/yuzu.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/externals/cpmfile.json b/externals/cpmfile.json index aa9977d859..45d775cb1e 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -36,7 +36,7 @@ "0002-fix-zstd.patch" ], "options": [ - "HTTPLIB_REQUIRE_OPENSSL ON", + "HTTPLIB_REQUIRE_OPENSSL OFF", "HTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES ON" ] }, diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 5c8a76fcf3..fc431ef439 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -193,6 +193,8 @@ int main(int argc, char** argv) { // May prevent spurious crashes on swap handlers... setvbuf(stdout, nullptr, _IONBF, 0); setvbuf(stderr, nullptr, _IONBF, 0); + + sceUserServiceInitialize(nullptr); #endif Common::Log::Initialize(); From 10959165ca0f3e6c3be757fc2205068140e928e8 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 16 Mar 2026 21:39:17 +0000 Subject: [PATCH 075/108] fix nproc --- .ci/ps4/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 8a5a64c5ec..9f8c586be1 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -32,7 +32,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_SIZEOF_VOID_P 8) EOF -NPROC=$(nproc || 1) +[ -z ${NPROC+x} ] && NPROC=$(nproc || 1) # Normally a platform has a package manager # PS4 does not, atleast not in the normal sense From 7141216685a349a20531d3d158fcb2fbaeb7ec65 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 16 Mar 2026 22:34:46 +0000 Subject: [PATCH 076/108] fix shit --- src/audio_core/sink/ps4_sink.cpp | 2 +- src/common/virtual_buffer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio_core/sink/ps4_sink.cpp b/src/audio_core/sink/ps4_sink.cpp index 42b151f49f..f7a54254b5 100644 --- a/src/audio_core/sink/ps4_sink.cpp +++ b/src/audio_core/sink/ps4_sink.cpp @@ -10,7 +10,7 @@ #include "audio_core/common/common.h" #include "audio_core/sink/ps4_sink.h" #include "audio_core/sink/sink_stream.h" -#include "common/logging/log.h" +#include "common/logging.h" #include "common/scope_exit.h" #include "core/core.h" diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 8acb75fc57..3183bb98c0 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -23,7 +23,7 @@ extern "C" int32_t sceKernelInstallExceptionHandler(int32_t signum, SceKernelExc #include "common/assert.h" #include "common/virtual_buffer.h" -#include "common/logging/log.h" +#include "common/logging.h" // PlayStation 4 // Flag needs to be undef-ed on non PS4 since it has different semantics From 6f559f972e02fd42c384f76a067083c64e09dca7 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 31 Mar 2026 07:55:10 +0000 Subject: [PATCH 077/108] httplib partial thing --- .ci/ps4/build.sh | 3 ++- externals/cpmfile.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 9f8c586be1..db182f3aa4 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -59,7 +59,8 @@ cmake -S . -B build -G "Unix Makefiles" \ -DYUZU_USE_EXTERNAL_FFMPEG=ON \ -DYUZU_USE_CPM=ON \ -DDYNARMIC_ENABLE_NO_EXECUTE_SUPPORT=OFF \ - -DDYNARMIC_TESTS=ON \ + -DDYNARMIC_TESTS=OFF \ + -DYUZU_TESTS=OFF \ -DYUZU_USE_EXTERNAL_SDL2=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit cmake --build build -t yuzu-cmd_pkg -- -j$NPROC diff --git a/externals/cpmfile.json b/externals/cpmfile.json index 45d775cb1e..0d9ab5ff80 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -37,7 +37,8 @@ ], "options": [ "HTTPLIB_REQUIRE_OPENSSL OFF", - "HTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES ON" + "HTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES ON", + "HTTPLIB_USE_OPENSSL_IF_AVAILABLE OFF" ] }, "cpp-jwt": { From f977052fed47ee1a56ad0906184b47b7c51b499b Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 31 Mar 2026 08:12:57 +0000 Subject: [PATCH 078/108] random stray devices ugh --- src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp index 3343d1d282..9d318d814d 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp @@ -9,6 +9,7 @@ #include "common/literals.h" #include "common/random.h" #include "common/settings.h" +#include "common/random.h" #include "core/hle/kernel/board/nintendo/nx/k_system_control.h" #include "core/hle/kernel/board/nintendo/nx/secure_monitor.h" From 1fda417d7ed2809ed800529540a5bee2edb24fc7 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 31 Mar 2026 08:24:12 +0000 Subject: [PATCH 079/108] fucking rng --- src/core/hle/kernel/k_page_bitmap.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/hle/kernel/k_page_bitmap.h b/src/core/hle/kernel/k_page_bitmap.h index 27bd682c5c..b4c5f19ae4 100644 --- a/src/core/hle/kernel/k_page_bitmap.h +++ b/src/core/hle/kernel/k_page_bitmap.h @@ -16,6 +16,7 @@ #include "common/tiny_mt.h" #include "common/random.h" #include "core/hle/kernel/k_system_control.h" +#include "common/random.h" namespace Kernel { From 5376215417ed94588500967c7907aeaac04f9134 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 31 Mar 2026 09:01:00 +0000 Subject: [PATCH 080/108] ryujinx was never ported to PS4 --- src/common/fs/path_util.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index 3cbe6371a4..62e765aa6c 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp @@ -173,12 +173,11 @@ public: #ifdef _WIN32 GenerateLegacyPath(EmuPath::RyujinxDir, GetAppDataRoamingDirectory() / RYUJINX_DIR); -#else +#elif !defined(__OPENORBIS__) // In Ryujinx's infinite wisdom, it places EVERYTHING in the config directory on UNIX // This is incredibly stupid and violates a million XDG standards, but whatever GenerateLegacyPath(EmuPath::RyujinxDir, GetDataDirectory("XDG_CONFIG_HOME") / RYUJINX_DIR); #endif - } private: @@ -340,36 +339,33 @@ fs::path GetAppDataRoamingDirectory() { return fs_appdata_roaming_path; } +#elif defined(__OPENORBIS__) + +// Not required/defined + #else fs::path GetHomeDirectory() { const char* home_env_var = getenv("HOME"); - if (home_env_var) { return fs::path{home_env_var}; } - LOG_INFO(Common_Filesystem, - "$HOME is not defined in the environment variables, " - "attempting to query passwd to get the home path of the current user"); - + "$HOME is not defined in the environment variables, " + "attempting to query passwd to get the home path of the current user"); const auto* pw = getpwuid(getuid()); - if (!pw) { LOG_ERROR(Common_Filesystem, "Failed to get the home path of the current user"); return {}; } - return fs::path{pw->pw_dir}; } fs::path GetDataDirectory(const std::string& env_name) { const char* data_env_var = getenv(env_name.c_str()); - if (data_env_var) { return fs::path{data_env_var}; } - if (env_name == "XDG_DATA_HOME") { return GetHomeDirectory() / ".local/share"; } else if (env_name == "XDG_CACHE_HOME") { @@ -377,7 +373,6 @@ fs::path GetDataDirectory(const std::string& env_name) { } else if (env_name == "XDG_CONFIG_HOME") { return GetHomeDirectory() / ".config"; } - return {}; } From 7266942413bc49bd395a0b4d316331a9b2e094b6 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 31 Mar 2026 09:33:52 +0000 Subject: [PATCH 081/108] remove thread remnants --- src/core/memory.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 38e77e863f..7f8922a71b 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -761,7 +761,6 @@ struct Memory::Impl { Core::System& system; Tegra::MaxwellDeviceMemoryManager* gpu_device_memory{}; Common::PageTable* current_page_table = nullptr; - std::array rasterizer_read_areas{}; std::array rasterizer_write_areas{}; std::array, Core::Hardware::NUM_CPU_CORES> scratch_buffers{}; From 939ca7430052ca4e7356f0c2cad99120811899e5 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 1 Apr 2026 00:48:24 +0000 Subject: [PATCH 082/108] skip exception handler register on PS4 and use xbyak::inner:getpagesize --- .../src/dynarmic/backend/x64/block_of_code.cpp | 13 +++++++------ src/dynarmic/src/dynarmic/backend/x64/emit_x64.cpp | 5 +++-- src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp index a85122b5ad..96f348955d 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/block_of_code.cpp @@ -7,6 +7,7 @@ */ #include "dynarmic/backend/x64/block_of_code.h" +#include "xbyak/xbyak.h" #ifdef _WIN32 # define WIN32_LEAN_AND_MEAN @@ -83,13 +84,12 @@ public: bool useProtect() const override { return false; } #else - static constexpr size_t DYNARMIC_PAGE_SIZE = 4096; - // Can't subclass Xbyak::MmapAllocator because it is not a pure interface // and doesn't expose its construtor uint8_t* alloc(size_t size) override { + auto const page_size = Xbyak::inner::getPageSize(); // Waste a page to store the size - size += DYNARMIC_PAGE_SIZE; + size += page_size; int mode = MAP_PRIVATE; #if defined(MAP_ANONYMOUS) @@ -118,13 +118,14 @@ public: #endif } std::memcpy(p, &size, sizeof(size_t)); - return static_cast(p) + DYNARMIC_PAGE_SIZE; + return static_cast(p) + page_size; } void free(uint8_t* p) override { + auto const page_size = Xbyak::inner::getPageSize(); size_t size; - std::memcpy(&size, p - DYNARMIC_PAGE_SIZE, sizeof(size_t)); - munmap(p - DYNARMIC_PAGE_SIZE, size); + std::memcpy(&size, p - page_size, sizeof(size_t)); + munmap(p - page_size, size); } # ifdef DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64.cpp b/src/dynarmic/src/dynarmic/backend/x64/emit_x64.cpp index 3d28365b1c..a4a13a4870 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64.cpp @@ -40,9 +40,10 @@ EmitContext::EmitContext(RegAlloc& reg_alloc, IR::Block& block, boost::container EmitContext::~EmitContext() = default; -EmitX64::EmitX64(BlockOfCode& code) - : code(code) { +EmitX64::EmitX64(BlockOfCode& code) : code(code) { +#ifndef __OPENORBIS__ exception_handler.Register(code); +#endif } EmitX64::~EmitX64() = default; diff --git a/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp b/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp index 1a80ae638a..00ce444429 100644 --- a/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp +++ b/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp @@ -13,6 +13,7 @@ #include "dynarmic/backend/x64/abi.h" #include "dynarmic/backend/x64/hostloc.h" #include "dynarmic/common/spin_lock.h" +#include "xbyak/xbyak.h" #ifdef DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT static const auto default_cg_mode = Xbyak::DontSetProtectRWE; @@ -78,7 +79,7 @@ namespace { struct SpinLockImpl { void Initialize() noexcept; static void GlobalInitialize() noexcept; - Xbyak::CodeGenerator code = Xbyak::CodeGenerator(4096, default_cg_mode); + Xbyak::CodeGenerator code = Xbyak::CodeGenerator(Xbyak::inner::getPageSize(), default_cg_mode); void (*lock)(volatile int*) = nullptr; void (*unlock)(volatile int*) = nullptr; }; From 4053c424119312670a9880e7752ef8b9bc8b6be4 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 1 Apr 2026 00:48:41 +0000 Subject: [PATCH 083/108] proper virtual base, remove uneeded sysconf things --- src/common/host_memory.cpp | 3 +-- src/common/memory_detect.cpp | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index fa03b6d211..2f08d58b3b 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -438,7 +438,7 @@ static void* ChooseVirtualBase(size_t virtual_size) { #else static void* ChooseVirtualBase(size_t size) { -#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) || defined(__OPENORBIS__) void* virtual_base = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER, -1, 0); if (virtual_base != MAP_FAILED) return virtual_base; @@ -676,7 +676,6 @@ private: HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_) : backing_size(backing_size_), virtual_size(virtual_size_) { #ifdef __OPENORBIS__ - Common::InitSwap(); LOG_WARNING(HW_Memory, "Platform doesn't support fastmem"); fallback_buffer.emplace(backing_size); backing_base = fallback_buffer->data(); diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp index 5063b28b2d..65af4c9cc8 100644 --- a/src/common/memory_detect.cpp +++ b/src/common/memory_detect.cpp @@ -46,8 +46,6 @@ static MemoryInfo Detect() { sysctlbyname("vm.swapusage", &vmusage, &sizeof_vmusage, nullptr, 0); mem_info.TotalPhysicalMemory = ramsize; mem_info.TotalSwapMemory = vmusage.xsu_total; -#elif defined(__OPENORBIS__) - mem_info.TotalPhysicalMemory = mem_info.TotalSwapMemory = 0; #elif defined(__FreeBSD__) u_long physmem, swap_total; std::size_t sizeof_u_long = sizeof(u_long); From 613aba26a9858115f42d468d0702bfc036d43e5b Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 1 Apr 2026 00:49:01 +0000 Subject: [PATCH 084/108] exclude tests that dont work --- src/tests/CMakeLists.txt | 5 + src/tests/common/host_memory.cpp | 154 ++++++++++-------- .../calibration_configuration_job.cpp | 4 +- src/tests/video_core/memory_tracker.cpp | 2 + 4 files changed, 99 insertions(+), 66 deletions(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 875c40604c..2cf669a669 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -37,3 +37,8 @@ if (NOT MSVC) $<$:-Wno-unused-parameter> $<$:-Wno-missing-field-initializers>) endif() + +if (PLATFORM_PS4) + target_link_libraries(tests PRIVATE SceVideoOut SceAudioOut ScePad SceSystemService ps4sup) + create_ps4_eboot(tests tests IV0000-BREW00090_00-DYNARMICTS000000) +endif() diff --git a/src/tests/common/host_memory.cpp b/src/tests/common/host_memory.cpp index cb040c942d..b41383d0df 100644 --- a/src/tests/common/host_memory.cpp +++ b/src/tests/common/host_memory.cpp @@ -14,13 +14,21 @@ static constexpr size_t BACKING_SIZE = 4_GiB; static constexpr auto PERMS = Common::MemoryPermission::ReadWrite; static constexpr auto HEAP = false; +#ifndef __OPENORBIS__ TEST_CASE("HostMemory: Initialize and deinitialize", "[common]") { - { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); } - { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); } + { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + } + { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + } } TEST_CASE("HostMemory: Simple map", "[common]") { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); mem.Map(0x5000, 0x8000, 0x1000, PERMS, HEAP); volatile u8* const data = mem.VirtualBasePointer() + 0x5000; @@ -30,6 +38,7 @@ TEST_CASE("HostMemory: Simple map", "[common]") { TEST_CASE("HostMemory: Simple mirror map", "[common]") { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); mem.Map(0x5000, 0x3000, 0x2000, PERMS, HEAP); mem.Map(0x8000, 0x4000, 0x1000, PERMS, HEAP); @@ -41,6 +50,7 @@ TEST_CASE("HostMemory: Simple mirror map", "[common]") { TEST_CASE("HostMemory: Simple unmap", "[common]") { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); mem.Map(0x5000, 0x3000, 0x2000, PERMS, HEAP); volatile u8* const data = mem.VirtualBasePointer() + 0x5000; @@ -52,6 +62,7 @@ TEST_CASE("HostMemory: Simple unmap", "[common]") { TEST_CASE("HostMemory: Simple unmap and remap", "[common]") { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); mem.Map(0x5000, 0x3000, 0x2000, PERMS, HEAP); volatile u8* const data = mem.VirtualBasePointer() + 0x5000; @@ -67,71 +78,9 @@ TEST_CASE("HostMemory: Simple unmap and remap", "[common]") { REQUIRE(data[0x3000] == 50); } -TEST_CASE("HostMemory: Nieche allocation", "[common]") { - HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); - mem.Map(0x0000, 0, 0x20000, PERMS, HEAP); - mem.Unmap(0x0000, 0x4000, HEAP); - mem.Map(0x1000, 0, 0x2000, PERMS, HEAP); - mem.Map(0x3000, 0, 0x1000, PERMS, HEAP); - mem.Map(0, 0, 0x1000, PERMS, HEAP); -} - -TEST_CASE("HostMemory: Full unmap", "[common]") { - HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); - mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); - mem.Unmap(0x8000, 0x4000, HEAP); - mem.Map(0x6000, 0, 0x16000, PERMS, HEAP); -} - -TEST_CASE("HostMemory: Right out of bounds unmap", "[common]") { - HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); - mem.Map(0x0000, 0, 0x4000, PERMS, HEAP); - mem.Unmap(0x2000, 0x4000, HEAP); - mem.Map(0x2000, 0x80000, 0x4000, PERMS, HEAP); -} - -TEST_CASE("HostMemory: Left out of bounds unmap", "[common]") { - HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); - mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); - mem.Unmap(0x6000, 0x4000, HEAP); - mem.Map(0x8000, 0, 0x2000, PERMS, HEAP); -} - -TEST_CASE("HostMemory: Multiple placeholder unmap", "[common]") { - HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); - mem.Map(0x0000, 0, 0x4000, PERMS, HEAP); - mem.Map(0x4000, 0, 0x1b000, PERMS, HEAP); - mem.Unmap(0x3000, 0x1c000, HEAP); - mem.Map(0x3000, 0, 0x20000, PERMS, HEAP); -} - -TEST_CASE("HostMemory: Unmap between placeholders", "[common]") { - HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); - mem.Map(0x0000, 0, 0x4000, PERMS, HEAP); - mem.Map(0x4000, 0, 0x4000, PERMS, HEAP); - mem.Unmap(0x2000, 0x4000, HEAP); - mem.Map(0x2000, 0, 0x4000, PERMS, HEAP); -} - -TEST_CASE("HostMemory: Unmap to origin", "[common]") { - HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); - mem.Map(0x4000, 0, 0x4000, PERMS, HEAP); - mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); - mem.Unmap(0x4000, 0x4000, HEAP); - mem.Map(0, 0, 0x4000, PERMS, HEAP); - mem.Map(0x4000, 0, 0x4000, PERMS, HEAP); -} - -TEST_CASE("HostMemory: Unmap to right", "[common]") { - HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); - mem.Map(0x4000, 0, 0x4000, PERMS, HEAP); - mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); - mem.Unmap(0x8000, 0x4000, HEAP); - mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); -} - TEST_CASE("HostMemory: Partial right unmap check bindings", "[common]") { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); mem.Map(0x4000, 0x10000, 0x4000, PERMS, HEAP); volatile u8* const ptr = mem.VirtualBasePointer() + 0x4000; @@ -144,6 +93,7 @@ TEST_CASE("HostMemory: Partial right unmap check bindings", "[common]") { TEST_CASE("HostMemory: Partial left unmap check bindings", "[common]") { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); mem.Map(0x4000, 0x10000, 0x4000, PERMS, HEAP); volatile u8* const ptr = mem.VirtualBasePointer() + 0x4000; @@ -158,6 +108,7 @@ TEST_CASE("HostMemory: Partial left unmap check bindings", "[common]") { TEST_CASE("HostMemory: Partial middle unmap check bindings", "[common]") { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); mem.Map(0x4000, 0x10000, 0x4000, PERMS, HEAP); volatile u8* const ptr = mem.VirtualBasePointer() + 0x4000; @@ -172,6 +123,7 @@ TEST_CASE("HostMemory: Partial middle unmap check bindings", "[common]") { TEST_CASE("HostMemory: Partial sparse middle unmap and check bindings", "[common]") { HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); mem.Map(0x4000, 0x10000, 0x2000, PERMS, HEAP); mem.Map(0x6000, 0x20000, 0x2000, PERMS, HEAP); @@ -184,3 +136,75 @@ TEST_CASE("HostMemory: Partial sparse middle unmap and check bindings", "[common REQUIRE(ptr[0x0000] == 19); REQUIRE(ptr[0x3fff] == 12); } +#endif + +TEST_CASE("HostMemory: Nieche allocation", "[common]") { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + mem.Map(0x0000, 0, 0x20000, PERMS, HEAP); + mem.Unmap(0x0000, 0x4000, HEAP); + mem.Map(0x1000, 0, 0x2000, PERMS, HEAP); + mem.Map(0x3000, 0, 0x1000, PERMS, HEAP); + mem.Map(0, 0, 0x1000, PERMS, HEAP); +} + +TEST_CASE("HostMemory: Full unmap", "[common]") { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); + mem.Unmap(0x8000, 0x4000, HEAP); + mem.Map(0x6000, 0, 0x16000, PERMS, HEAP); +} + +TEST_CASE("HostMemory: Right out of bounds unmap", "[common]") { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + mem.Map(0x0000, 0, 0x4000, PERMS, HEAP); + mem.Unmap(0x2000, 0x4000, HEAP); + mem.Map(0x2000, 0x80000, 0x4000, PERMS, HEAP); +} + +TEST_CASE("HostMemory: Left out of bounds unmap", "[common]") { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); + mem.Unmap(0x6000, 0x4000, HEAP); + mem.Map(0x8000, 0, 0x2000, PERMS, HEAP); +} + +TEST_CASE("HostMemory: Multiple placeholder unmap", "[common]") { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + mem.Map(0x0000, 0, 0x4000, PERMS, HEAP); + mem.Map(0x4000, 0, 0x1b000, PERMS, HEAP); + mem.Unmap(0x3000, 0x1c000, HEAP); + mem.Map(0x3000, 0, 0x20000, PERMS, HEAP); +} + +TEST_CASE("HostMemory: Unmap between placeholders", "[common]") { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + mem.Map(0x0000, 0, 0x4000, PERMS, HEAP); + mem.Map(0x4000, 0, 0x4000, PERMS, HEAP); + mem.Unmap(0x2000, 0x4000, HEAP); + mem.Map(0x2000, 0, 0x4000, PERMS, HEAP); +} + +TEST_CASE("HostMemory: Unmap to origin", "[common]") { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + mem.Map(0x4000, 0, 0x4000, PERMS, HEAP); + mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); + mem.Unmap(0x4000, 0x4000, HEAP); + mem.Map(0, 0, 0x4000, PERMS, HEAP); + mem.Map(0x4000, 0, 0x4000, PERMS, HEAP); +} + +TEST_CASE("HostMemory: Unmap to right", "[common]") { + HostMemory mem(BACKING_SIZE, VIRTUAL_SIZE); + REQUIRE(mem.BackingBasePointer() != nullptr); + mem.Map(0x4000, 0, 0x4000, PERMS, HEAP); + mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); + mem.Unmap(0x8000, 0x4000, HEAP); + mem.Map(0x8000, 0, 0x4000, PERMS, HEAP); +} diff --git a/src/tests/input_common/calibration_configuration_job.cpp b/src/tests/input_common/calibration_configuration_job.cpp index 6ded0dfc86..570a062f42 100644 --- a/src/tests/input_common/calibration_configuration_job.cpp +++ b/src/tests/input_common/calibration_configuration_job.cpp @@ -15,7 +15,8 @@ #include "input_common/drivers/udp_client.h" #include "input_common/helpers/udp_protocol.h" - +// PS4 doesn't support cemuhook +#ifndef __OPENORBIS__ class FakeCemuhookServer { public: FakeCemuhookServer() @@ -132,3 +133,4 @@ TEST_CASE("CalibrationConfigurationJob completed", "[input_common]") { REQUIRE(max_x == 200); REQUIRE(max_y == 200); } +#endif diff --git a/src/tests/video_core/memory_tracker.cpp b/src/tests/video_core/memory_tracker.cpp index 5fd8037446..70a469586f 100644 --- a/src/tests/video_core/memory_tracker.cpp +++ b/src/tests/video_core/memory_tracker.cpp @@ -573,6 +573,7 @@ TEST_CASE("MemoryTracker: FlushCachedWrites batching") { REQUIRE(std::get<1>(calls[0]) == PAGE * 3); } +#if 0 TEST_CASE("DeviceMemoryManager: UpdatePagesCachedBatch basic") { Core::DeviceMemory device_memory; Tegra::MaxwellDeviceMemoryManager manager(device_memory); @@ -587,3 +588,4 @@ TEST_CASE("DeviceMemoryManager: UpdatePagesCachedBatch basic") { manager.UpdatePagesCachedBatch(ranges, 1); SUCCEED("UpdatePagesCachedBatch executed without error"); } +#endif From 307146c58ea4bb4f147a95820e936bcee9337a48 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 1 Apr 2026 00:49:24 +0000 Subject: [PATCH 085/108] properly define orbis page size --- src/common/virtual_buffer.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 3183bb98c0..881bf9e29e 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -45,6 +45,8 @@ namespace Common { #ifdef __OPENORBIS__ namespace Orbis { +constexpr size_t ORBIS_PAGE_SIZE = 16384; + struct Ucontext { struct Sigset { u64 bits[2]; @@ -114,7 +116,7 @@ static void SwapHandler(int sig, void* raw_context) { if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second; }); it != swap_regions.end()) { - size_t const page_size = 0x200000; //2M + size_t const page_size = Orbis::ORBIS_PAGE_SIZE; //16K size_t const page_mask = ~(page_size - 1); // should replace the existing mapping... ugh void* aligned_addr = reinterpret_cast(uintptr_t(mctx.mc_addr) & page_mask); @@ -144,8 +146,8 @@ void* AllocateMemoryPages(std::size_t size) noexcept { #elif defined(__OPENORBIS__) bool use_void_mem = true; void* addr = nullptr; - if (size <= 8192 * 4096) { - size_t align = 16384; + if (size < 4294967296ull) { + size_t align = Orbis::ORBIS_PAGE_SIZE; off_t offset; int32_t res; size = (size + align - 1) / align * align; @@ -163,7 +165,6 @@ void* AllocateMemoryPages(std::size_t size) noexcept { LOG_ERROR(HW_Memory, "{} = sceKernelMapDirectMemory({}, {})", res, offset, size); } } else { - sceKernelReleaseDirectMemory(offset, size); LOG_ERROR(HW_Memory, "{} = sceKernelAllocateDirectMemory({}, {}, {})", res, size, align, offset); } } @@ -186,11 +187,13 @@ void FreeMemoryPages(void* addr, [[maybe_unused]] std::size_t size) noexcept { #ifdef _WIN32 VirtualFree(addr, 0, MEM_RELEASE); #elif defined(__OPENORBIS__) - if (size <= 8192 * 4096) { - sceKernelCheckedReleaseDirectMemory(off_t(addr), size_t(size)); - } else { + if (auto const it = std::ranges::find_if(swap_regions, [=](auto const& e) { + return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second; + }); it != swap_regions.end()) { int rc = munmap(addr, size); ASSERT(rc == 0); + } else { + sceKernelCheckedReleaseDirectMemory(off_t(addr), size_t(size)); } #else int rc = munmap(addr, size); From 690d16982173b732adb75e7a5f8ca14727e583d4 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 1 Apr 2026 07:59:13 +0000 Subject: [PATCH 086/108] file loggin is safe now, settings too --- src/common/host_memory.cpp | 2 +- src/common/logging.cpp | 8 -------- src/common/settings.cpp | 9 +++------ src/dynarmic/tests/CMakeLists.txt | 3 +-- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 2f08d58b3b..88f6a8758e 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -438,7 +438,7 @@ static void* ChooseVirtualBase(size_t virtual_size) { #else static void* ChooseVirtualBase(size_t size) { -#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) || defined(__OPENORBIS__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__) || defined(__AIX__) void* virtual_base = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER, -1, 0); if (virtual_base != MAP_FAILED) return virtual_base; diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 68e033b129..cca2663b51 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -243,7 +243,6 @@ struct ColorConsoleBackend final : public Backend { #endif }; -#ifndef __OPENORBIS__ /// @brief Backend that writes to a file passed into the constructor struct FileBackend final : public Backend { explicit FileBackend(const std::filesystem::path& filename) noexcept { @@ -307,7 +306,6 @@ private: std::size_t bytes_written = 0; bool enabled = true; }; -#endif #ifdef _WIN32 /// @brief Backend that writes to Visual Studio's output window @@ -352,10 +350,8 @@ struct Impl { template void ForEachBackend(F&& lambda) noexcept { lambda(static_cast(color_console_backend)); -#ifndef __OPENORBIS__ if (file_backend) lambda(static_cast(*file_backend)); -#endif #ifdef _WIN32 lambda(static_cast(debugger_backend)); #endif @@ -366,9 +362,7 @@ struct Impl { Filter filter; ColorConsoleBackend color_console_backend{}; -#ifndef __OPENORBIS__ std::optional file_backend; -#endif #ifdef _WIN32 DebuggerBackend debugger_backend{}; #endif @@ -389,12 +383,10 @@ void Initialize() { } else { logging_instance.emplace(); logging_instance->filter.ParseFilterString(Settings::values.log_filter.GetValue()); -#ifndef __OPENORBIS__ using namespace Common::FS; const auto& log_dir = GetEdenPath(EdenPath::LogDir); void(CreateDir(log_dir)); logging_instance->file_backend.emplace(log_dir / LOG_FILE); -#endif } } diff --git a/src/common/settings.cpp b/src/common/settings.cpp index dee8ab0155..813bda5713 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -27,7 +27,7 @@ #include "common/settings.h" #include "common/time_zone.h" -#if defined(__linux__ ) && defined(ARCHITECTURE_arm64) +#ifdef __unix__ #include #endif @@ -182,12 +182,9 @@ bool IsFastmemEnabled() { return bool(values.cpuopt_fastmem); else if (values.cpu_accuracy.GetValue() == CpuAccuracy::Unsafe) return bool(values.cpuopt_unsafe_host_mmu); -#if defined(__linux__) && defined(ARCHITECTURE_arm64) - // Only 4kb systems support host MMU right now - // TODO: Support this +#if defined(__unix__) + // TODO: Support this since only 4kb systems support host MMU right now return getpagesize() == 4096; -#elif defined(__OPENORBIS__) || (!defined(__APPLE__) && !defined(__ANDROID__) && !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__)) - return false; #else return true; #endif diff --git a/src/dynarmic/tests/CMakeLists.txt b/src/dynarmic/tests/CMakeLists.txt index e18a5eeadb..3beacaf568 100644 --- a/src/dynarmic/tests/CMakeLists.txt +++ b/src/dynarmic/tests/CMakeLists.txt @@ -136,7 +136,6 @@ target_compile_definitions(dynarmic_tests PRIVATE FMT_USE_USER_DEFINED_LITERALS= add_test(NAME dynarmic_tests COMMAND dynarmic_tests --durations yes) if (PLATFORM_PS4) - target_link_libraries(dynarmic_tests PRIVATE SceVideoOut SceAudioOut ScePad SceSystemService) - target_link_libraries(dynarmic_tests PRIVATE ps4sup) + target_link_libraries(dynarmic_tests PRIVATE SceVideoOut SceAudioOut ScePad SceSystemService ps4sup) create_ps4_eboot(dynarmic_tests dynarmic_tests IV0000-BREW00090_00-DYNARMICTS000000) endif() From 41e7352111598a947e68b140e8400969b3333ccb Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 1 Apr 2026 08:19:09 +0000 Subject: [PATCH 087/108] put swap proper --- src/yuzu_cmd/yuzu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index fc431ef439..0353054e2b 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -17,6 +17,7 @@ #include "common/settings.h" #include "common/settings_enums.h" #include "common/string_util.h" +#include "common/virtual_buffer.h" #include "core/core.h" #include "core/core_timing.h" #include "core/cpu_manager.h" From c3f33f796aa1ca862b50975fb434f7417e1c6339 Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 10 Apr 2026 07:17:57 +0000 Subject: [PATCH 088/108] remove outdated make-toolchain --- .ci/ps4/make-toolchain.sh | 176 -------------------------------------- 1 file changed, 176 deletions(-) delete mode 100755 .ci/ps4/make-toolchain.sh diff --git a/.ci/ps4/make-toolchain.sh b/.ci/ps4/make-toolchain.sh deleted file mode 100755 index 2b4f994b79..0000000000 --- a/.ci/ps4/make-toolchain.sh +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/local/bin/bash -ex - -# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -# SPDX-License-Identifier: GPL-3.0-or-later - -# Define global vars -# These flags are used everywhere, so let's reuse them. -export OO_PS4_TOOLCHAIN="$PWD/prefix" -export PREFIX="$OO_PS4_TOOLCHAIN" -export CC="clang" -export CXX="clang++" -export AR="llvm-ar" -export CFLAGS="-fPIC -DPS4 -D_LIBUNWIND_IS_BAREMETAL=1" -export CXXFLAGS="$CFLAGS -D__STDC_VERSION__=0" -export TARGET="x86_64-scei-ps4" -export LLVM_ROOT="$PWD/llvm-project" -export LLVM_PATH="$PWD/llvm-project/llvm" -export WORK_PATH="$PWD" - -prepare_prefix() { - [ -d OpenOrbis-PS4-Toolchain ] || git clone --depth=1 https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain - [ -d musl ] || git clone --depth=1 https://github.com/OpenOrbis/musl - [ -d llvm-project ] || git clone --depth=1 --branch openorbis/20.x https://github.com/seuros/llvm-project - [ -d create-fself ] || git clone --depth=1 https://github.com/OpenOrbis/create-fself - [ -d create-gp4 ] || git clone --depth=1 https://github.com/OpenOrbis/create-gp4 - [ -d readoelf ] || git clone --depth=1 https://github.com/OpenOrbis/readoelf - [ -d LibOrbisPkg ] || git clone --depth=1 https://github.com/maxton/LibOrbisPkg - - mkdir -p $PREFIX "$PREFIX/bin" "$PREFIX/include" - [ -f "$PREFIX/include/orbis/libkernel.h" ] || cp -r OpenOrbis-PS4-Toolchain/include/* "$PREFIX/include/" - mkdir -p $PREFIX/usr - [ -L "$PREFIX/usr/include" ] || ln -s $PREFIX/include $PREFIX/usr/include || echo 1 - [ -L "$PREFIX/usr/share" ] || ln -s $PREFIX/share $PREFIX/usr/share || echo 1 - [ -L "$PREFIX/usr/lib" ] || ln -s $PREFIX/lib $PREFIX/usr/lib || echo 1 - [ -L "$PREFIX/usr/bin" ] || ln -s $PREFIX/bin $PREFIX/usr/bin || echo 1 -} - -build_musl() { - mkdir -p musl-build - cd musl-build - ../musl/configure --target=$TARGET --disable-shared CC="$CC" CFLAGS="$CFLAGS" --prefix=$PREFIX - gmake -j8 && gmake install - cd .. -} - -build_llvm() { - # Build compiler-rt - cmake "$LLVM_ROOT/compiler-rt" -B "$WORK_PATH/llvm-build/compiler-rt" \ - -DCMAKE_INSTALL_PREFIX="$PREFIX" \ - -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ - -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ - -DCMAKE_ASM_COMPILER="$CC" -DCMAKE_ASM_FLAGS="$CFLAGS -x assembler-with-cpp" \ - -DLLVM_PATH="$LLVM_PATH" -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE="$TARGET" \ - -DCOMPILER_RT_BAREMETAL_BUILD=YES -DCOMPILER_RT_BUILD_BUILTINS=ON \ - -DCOMPILER_RT_BUILD_CRT=OFF -DCOMPILER_RT_BUILD_SANITIZERS=OFF \ - -DCOMPILER_RT_BUILD_XRAY=OFF -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ - -DCOMPILER_RT_BUILD_PROFILE=OFF -DCOMPILER_RT_STANDALONE_BUILD=ON - # Build libunwind - cmake "$LLVM_ROOT/libunwind" -B "$WORK_PATH/llvm-build/libunwind" \ - -DCMAKE_INSTALL_PREFIX="$PREFIX" \ - -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ - -DCMAKE_C_FLAGS="$CFLAGS -fcxx-exceptions" -DCMAKE_CXX_FLAGS="$CXXFLAGS -fcxx-exceptions" \ - -DCMAKE_ASM_COMPILER="$CC" -DCMAKE_ASM_FLAGS="$CFLAGS -x assembler-with-cpp" \ - -DLLVM_PATH="$LLVM_PATH" -DLIBUNWIND_USE_COMPILER_RT=YES \ - -DLIBUNWIND_BUILD_32_BITS=NO -DLIBUNWIND_ENABLE_STATIC=ON \ - -DLIBUNWIND_ENABLE_SHARED=OFF -DLIBUNWIND_IS_BAREMETAL=ON - # Build libcxxabi - cmake "$LLVM_ROOT/libcxxabi" -B "$WORK_PATH/llvm-build/libcxxabi" \ - -DCMAKE_INSTALL_PREFIX="$PREFIX" \ - -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ - -DCMAKE_C_FLAGS="$CFLAGS -D_GNU_SOURCE=1 -isysroot $PREFIX -isystem $LLVM_ROOT/libcxx/include -isystem $PREFIX/include -isystem $WORK_PATH/llvm-build/libcxx/include/c++/v1" \ - -DCMAKE_CXX_FLAGS="$CXXFLAGS -D_GNU_SOURCE=1 -isysroot $PREFIX -isystem $LLVM_ROOT/libcxx/include -isystem $PREFIX/include -isystem $WORK_PATH/llvm-build/libcxx/include/c++/v1" \ - -DCMAKE_ASM_COMPILER="$CC" -DCMAKE_ASM_FLAGS="$CFLAGS -x assembler-with-cpp" \ - -DLLVM_PATH="$LLVM_PATH" -DLIBCXXABI_ENABLE_SHARED=NO \ - -DLLVM_ENABLE_RUNTIMES="rt;libunwind" \ - -DLIBCXXABI_ENABLE_STATIC=YES -DLIBCXXABI_ENABLE_EXCEPTIONS=YES \ - -DLIBCXXABI_USE_COMPILER_RT=YES -DLIBCXXABI_USE_LLVM_UNWINDER=YES \ - -DLIBCXXABI_LIBUNWIND_PATH="$LLVM_ROOT/libunwind" \ - -DLIBCXXABI_LIBCXX_INCLUDES="$LLVM_ROOT/libcxx/include" \ - -DLIBCXXABI_ENABLE_PIC=YES - # Build libcxx - cmake "$LLVM_ROOT/libcxx" -B "$WORK_PATH/llvm-build/libcxx" \ - -DCMAKE_INSTALL_PREFIX="$PREFIX" \ - -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \ - -DCMAKE_C_FLAGS="$CFLAGS -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 -isysroot $PREFIX -isystem $PREFIX/include/c++/v1 -isystem $PREFIX/include" \ - -DCMAKE_CXX_FLAGS="$CXXFLAGS -D_LIBCPP_HAS_MUSL_LIBC=1 -D_GNU_SOURCE=1 -isysroot $PREFIX -isystem $PREFIX/include/c++/v1 -isystem $PREFIX/include" \ - -DCMAKE_ASM_COMPILER="$CC" -DCMAKE_ASM_FLAGS="$CFLAGS -x assembler-with-cpp" \ - -DLLVM_PATH="$LLVM_PATH" -DLIBCXX_ENABLE_RTTI=YES \ - -DLIBCXX_HAS_MUSL_LIBC=YES -DLIBCXX_ENABLE_SHARED=NO \ - -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LLVM_ROOT/libcxxabi/include" \ - -DLIBCXX_CXX_ABI_LIBRARY_PATH="$LLVM_ROOT/libcxxabi/build/lib" - - cmake --build "$WORK_PATH/llvm-build/compiler-rt" --parallel - cmake --install "$WORK_PATH/llvm-build/compiler-rt" - - cmake --build "$WORK_PATH/llvm-build/libunwind" --parallel - cmake --install "$WORK_PATH/llvm-build/libunwind" - - cmake --build "$WORK_PATH/llvm-build/libcxxabi" --parallel - cmake --install "$WORK_PATH/llvm-build/libcxxabi" - - touch "$WORK_PATH/llvm-build/libcxx/include/c++/v1/libcxx.imp" - cmake --build "$WORK_PATH/llvm-build/libcxx" --parallel - cmake --install "$WORK_PATH/llvm-build/libcxx" -} - -build_tools() { - - # Build create-fself - cd create-fself/cmd/create-fself - cp go-linux.mod go.mod - go build -ldflags "-linkmode external -extldflags -static" -o create-fself - mv ./create-fself $PREFIX/bin/create-fself - cd ../../../ - - # Build create-gp4 - cd create-gp4/cmd/create-gp4 - go build -ldflags "-linkmode external -extldflags -static" -o create-gp4 - mv ./create-gp4 $PREFIX/bin/create-gp4 - cd ../../../ - - # Build readoelf - cd readoelf/cmd/readoelf - go build -ldflags "-linkmode external -extldflags -static" -o readoelf - mv ./readoelf $PREFIX/bin/readoelf - cd ../../../ - - # # Pull maxton's publishing tools (<3) - # # Sadly maxton has passed on, we have forked the repository and will continue to update it in the future. RIP <3 - # cd $PREFIX/bin - # [ -f PkgTool.Core-linux-x64-0.2.231.zip ] || wget https://github.com/maxton/LibOrbisPkg/releases/download/v0.2/PkgTool.Core-linux-x64-0.2.231.zip - # [ -f PkgTool.Core ] || unzip PkgTool.Core-linux-x64-0.2.231.zip - # chmod +x PkgTool.Core -} - -finish_prefix() { - as $WORK_PATH/OpenOrbis-PS4-Toolchain/src/crt/crtlib.S -o $PREFIX/lib/crtlib.o - cp -a $WORK_PATH/OpenOrbis-PS4-Toolchain/link.x $PREFIX/ - - cp -a ~/OpenOrbis/PS4Toolchain/lib/libkernel* $PREFIX/lib/ - cp -a ~/OpenOrbis/PS4Toolchain/lib/libSce* $PREFIX/lib/ - - cp -a ~/OpenOrbis/PS4Toolchain/lib/libSDL* $PREFIX/lib/ - cp -r ~/OpenOrbis/PS4Toolchain/include/SDL2 $PREFIX/include/SDL2 - - cp $WORK_PATH/llvm-build/compiler-rt/lib/freebsd/libclang_rt.builtins-x86_64.a $PREFIX/lib/ - - # Combine libc++, libc++abi and libunwind into a single archive - cat << EOF >"mri.txt" -CREATE $PREFIX/lib/libc++M.a -ADDLIB $PREFIX/lib/libunwind.a -ADDLIB $PREFIX/lib/libc++abi.a -ADDLIB $PREFIX/lib/libc++.a -SAVE -END -EOF - $AR -M < mri.txt - cp $PREFIX/lib/libc++M.a $PREFIX/lib/libc++.a - # Merge compiler-rt into libc - cat << EOF >"mri.txt" -CREATE $PREFIX/lib/libcM.a -ADDLIB $PREFIX/lib/libc.a -ADDLIB $PREFIX/lib/libclang_rt.builtins-x86_64.a -SAVE -END -EOF - $AR -M < mri.txt - cp $PREFIX/lib/libcM.a $PREFIX/lib/libc.a - rm mri.txt -} - -prepare_prefix -build_musl -build_llvm -build_tools -finish_prefix From 2b68b055cf8bd4f20055c1127add4eeeef3826bc Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 10 Apr 2026 07:19:19 +0000 Subject: [PATCH 089/108] update license --- src/audio_core/CMakeLists.txt | 2 +- src/audio_core/sink/ps4_sink.cpp | 2 +- src/audio_core/sink/ps4_sink.h | 2 +- src/hid_core/resource_manager.cpp | 3 +++ src/hid_core/resources/npad/npad.cpp | 2 +- src/input_common/CMakeLists.txt | 2 +- src/input_common/helpers/joycon_driver.cpp | 3 +++ src/input_common/helpers/joycon_protocol/common_protocol.cpp | 3 +++ src/tests/common/host_memory.cpp | 3 +++ src/yuzu_cmd/yuzu.cpp | 1 + 10 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index 52df259479..afe7f9cc99 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2018 yuzu Emulator Project diff --git a/src/audio_core/sink/ps4_sink.cpp b/src/audio_core/sink/ps4_sink.cpp index f7a54254b5..99734d876a 100644 --- a/src/audio_core/sink/ps4_sink.cpp +++ b/src/audio_core/sink/ps4_sink.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later #include diff --git a/src/audio_core/sink/ps4_sink.h b/src/audio_core/sink/ps4_sink.h index cfc8c293bb..944e7f9b7a 100644 --- a/src/audio_core/sink/ps4_sink.h +++ b/src/audio_core/sink/ps4_sink.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/hid_core/resource_manager.cpp b/src/hid_core/resource_manager.cpp index d6b46ae764..0c10d1bec9 100644 --- a/src/hid_core/resource_manager.cpp +++ b/src/hid_core/resource_manager.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index 9aaacf8ecb..3a191f4539 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index 21315eb9c3..91dd8558ab 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2018 yuzu Emulator Project diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index fca09af55f..78df802b73 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.cpp b/src/input_common/helpers/joycon_protocol/common_protocol.cpp index fe229752f8..e825afa1b7 100644 --- a/src/input_common/helpers/joycon_protocol/common_protocol.cpp +++ b/src/input_common/helpers/joycon_protocol/common_protocol.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/tests/common/host_memory.cpp b/src/tests/common/host_memory.cpp index b41383d0df..527e35397a 100644 --- a/src/tests/common/host_memory.cpp +++ b/src/tests/common/host_memory.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 0353054e2b..7158e42f63 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -196,6 +196,7 @@ int main(int argc, char** argv) { setvbuf(stderr, nullptr, _IONBF, 0); sceUserServiceInitialize(nullptr); + Common::InitSwap(); #endif Common::Log::Initialize(); From 1c1b2bf54a83b51ba64716fee8ba7cbb96aa44f2 Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 10 Apr 2026 07:30:06 +0000 Subject: [PATCH 090/108] disable openssl on httplib hdr --- src/common/httplib.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/httplib.h b/src/common/httplib.h index 57bc4eeb93..b600b6739e 100644 --- a/src/common/httplib.h +++ b/src/common/httplib.h @@ -3,8 +3,14 @@ #pragma once +// TODO: httplib port can't use OpenSSL because of package misconfigs on OO toolchain +// right now the solution is to tell httplib that OpenSSL doesn't exist, but that's bad +// and the issue is a bit more of how OpenSSL lacks some essential functionality +// which is a bit annoying to reconfigure atm. +#ifndef __OPENORBIS__ #define CPPHTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES 1 #define CPPHTTPLIB_OPENSSL_SUPPORT 1 +#endif #ifdef __GNUC__ #pragma GCC diagnostic push From 8984f5ccb8f4e76dd22d83d41e08951733ad1906 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 30 Apr 2026 15:50:44 +0000 Subject: [PATCH 091/108] make fiber bigger, build.sh --- .ci/ps4/build.sh | 1 + externals/cpmfile.json | 1 - src/common/fiber.cpp | 2 +- src/yuzu_cmd/yuzu.cpp | 2 ++ 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index db182f3aa4..0536ca34bb 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -63,6 +63,7 @@ cmake -S . -B build -G "Unix Makefiles" \ -DYUZU_TESTS=OFF \ -DYUZU_USE_EXTERNAL_SDL2=ON \ "${EXTRA_CMAKE_FLAGS[@]}" || exit + cmake --build build -t yuzu-cmd_pkg -- -j$NPROC #cmake --build build -t dynarmic_tests_pkg -- -j$NPROC #cmake --build build -t testps4_pkg -- -j$NPROC diff --git a/externals/cpmfile.json b/externals/cpmfile.json index 0d9ab5ff80..563e48b419 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -37,7 +37,6 @@ ], "options": [ "HTTPLIB_REQUIRE_OPENSSL OFF", - "HTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES ON", "HTTPLIB_USE_OPENSSL_IF_AVAILABLE OFF" ] }, diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index 4f3dad7e88..ef635aa307 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp @@ -16,7 +16,7 @@ namespace Common { #ifdef __OPENORBIS__ -constexpr size_t DEFAULT_STACK_SIZE = 32 * 4096; +constexpr size_t DEFAULT_STACK_SIZE = 64 * 4096; #else constexpr size_t DEFAULT_STACK_SIZE = 512 * 4096; #endif diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 7158e42f63..acb80788bc 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -367,6 +367,8 @@ int main(int argc, char** argv) { // Apply the command line arguments system.ApplySettings(); + Settings::values.renderer_backend.SetValue(Settings::RendererBackend::Null); + Common::Log::SetGlobalFilter(Common::Log::Filter(Common::Log::Level::Trace)); std::unique_ptr emu_window; switch (Settings::values.renderer_backend.GetValue()) { From dca3d7d784b94ec5f8998fdceb7ba8b1d0c8a7cb Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 6 May 2026 15:14:39 +0000 Subject: [PATCH 092/108] oopsie --- src/common/virtual_buffer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index af51949a10..adfdbb75d4 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -39,7 +39,8 @@ public: VirtualBuffer& operator=(const VirtualBuffer&) = delete; VirtualBuffer(VirtualBuffer&& other) noexcept - : alloc_size{std::exchange(other.alloc_size, 0)}, base_ptr{std::exchange(other.base_ptr), nullptr} + : alloc_size{std::exchange(other.alloc_size, 0)} + , base_ptr{std::exchange(other.base_ptr, nullptr)} {} VirtualBuffer& operator=(VirtualBuffer&& other) noexcept { From b7d13bf67ffbacfe7503842f6f6b683a3e215c15 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 6 May 2026 15:47:35 +0000 Subject: [PATCH 093/108] checkout useless changs --- src/common/virtual_buffer.h | 3 +-- src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp | 1 - src/core/hle/kernel/k_page_bitmap.h | 1 - src/core/memory.cpp | 1 + 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index adfdbb75d4..af51949a10 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -39,8 +39,7 @@ public: VirtualBuffer& operator=(const VirtualBuffer&) = delete; VirtualBuffer(VirtualBuffer&& other) noexcept - : alloc_size{std::exchange(other.alloc_size, 0)} - , base_ptr{std::exchange(other.base_ptr, nullptr)} + : alloc_size{std::exchange(other.alloc_size, 0)}, base_ptr{std::exchange(other.base_ptr), nullptr} {} VirtualBuffer& operator=(VirtualBuffer&& other) noexcept { diff --git a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp index 9d318d814d..3343d1d282 100644 --- a/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp +++ b/src/core/hle/kernel/board/nintendo/nx/k_system_control.cpp @@ -9,7 +9,6 @@ #include "common/literals.h" #include "common/random.h" #include "common/settings.h" -#include "common/random.h" #include "core/hle/kernel/board/nintendo/nx/k_system_control.h" #include "core/hle/kernel/board/nintendo/nx/secure_monitor.h" diff --git a/src/core/hle/kernel/k_page_bitmap.h b/src/core/hle/kernel/k_page_bitmap.h index b4c5f19ae4..27bd682c5c 100644 --- a/src/core/hle/kernel/k_page_bitmap.h +++ b/src/core/hle/kernel/k_page_bitmap.h @@ -16,7 +16,6 @@ #include "common/tiny_mt.h" #include "common/random.h" #include "core/hle/kernel/k_system_control.h" -#include "common/random.h" namespace Kernel { diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 7f8922a71b..38e77e863f 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -761,6 +761,7 @@ struct Memory::Impl { Core::System& system; Tegra::MaxwellDeviceMemoryManager* gpu_device_memory{}; Common::PageTable* current_page_table = nullptr; + std::array rasterizer_read_areas{}; std::array rasterizer_write_areas{}; std::array, Core::Hardware::NUM_CPU_CORES> scratch_buffers{}; From 74b5d259029a21ac3fc0bf961dc56993d3aa67da Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 6 May 2026 17:01:54 +0000 Subject: [PATCH 094/108] fix std exchange, fix host mem unused funcs --- src/common/host_memory.cpp | 24 +++++++++++++++++------- src/common/virtual_buffer.h | 3 ++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 88f6a8758e..876ed03a10 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -393,6 +393,10 @@ private: ankerl::unordered_dense::map placeholder_host_pointers; ///< Placeholder backing offset }; +#elif defined(__OPENORBIS__) +// None of the luxuries of POSIX +class Impl { +}; #else // ^^^ Windows ^^^ vvv POSIX vvv #ifdef ARCHITECTURE_arm64 @@ -700,30 +704,32 @@ HostMemory::HostMemory(HostMemory&&) noexcept = default; HostMemory& HostMemory::operator=(HostMemory&&) noexcept = default; -void HostMemory::Map(size_t virtual_offset, size_t host_offset, size_t length, - MemoryPermission perms, bool separate_heap) { +void HostMemory::Map(size_t virtual_offset, size_t host_offset, size_t length, MemoryPermission perms, bool separate_heap) { +#ifndef __OPENORBIS__ ASSERT(virtual_offset % PageAlignment == 0); ASSERT(host_offset % PageAlignment == 0); ASSERT(length % PageAlignment == 0); ASSERT(virtual_offset + length <= virtual_size); ASSERT(host_offset + length <= backing_size); - if (length == 0 || !virtual_base || !impl) { + if (length == 0 || !virtual_base || !impl) return; - } impl->Map(virtual_offset + virtual_base_offset, host_offset, length, perms); +#endif } void HostMemory::Unmap(size_t virtual_offset, size_t length, bool separate_heap) { +#ifndef __OPENORBIS__ ASSERT(virtual_offset % PageAlignment == 0); ASSERT(length % PageAlignment == 0); ASSERT(virtual_offset + length <= virtual_size); - if (length == 0 || !virtual_base || !impl) { + if (length == 0 || !virtual_base || !impl) return; - } impl->Unmap(virtual_offset + virtual_base_offset, length); +#endif } void HostMemory::Protect(size_t virtual_offset, size_t length, MemoryPermission perm) { +#ifndef __OPENORBIS__ ASSERT(virtual_offset % PageAlignment == 0); ASSERT(length % PageAlignment == 0); ASSERT(virtual_offset + length <= virtual_size); @@ -734,17 +740,21 @@ void HostMemory::Protect(size_t virtual_offset, size_t length, MemoryPermission const bool write = True(perm & MemoryPermission::Write); const bool execute = True(perm & MemoryPermission::Execute); impl->Protect(virtual_offset + virtual_base_offset, length, read, write, execute); +#endif } void HostMemory::ClearBackingRegion(size_t physical_offset, size_t length, u32 fill_value) { - std::memset(backing_base + physical_offset, fill_value, length); + if (!impl) + std::memset(backing_base + physical_offset, fill_value, length); } void HostMemory::EnableDirectMappedAddress() { +#ifndef __OPENORBIS__ if (impl) { impl->EnableDirectMappedAddress(); virtual_size += reinterpret_cast(virtual_base); } +#endif } } // namespace Common diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index af51949a10..adfdbb75d4 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -39,7 +39,8 @@ public: VirtualBuffer& operator=(const VirtualBuffer&) = delete; VirtualBuffer(VirtualBuffer&& other) noexcept - : alloc_size{std::exchange(other.alloc_size, 0)}, base_ptr{std::exchange(other.base_ptr), nullptr} + : alloc_size{std::exchange(other.alloc_size, 0)} + , base_ptr{std::exchange(other.base_ptr, nullptr)} {} VirtualBuffer& operator=(VirtualBuffer&& other) noexcept { From a89735d7dec37c681520c63a5e9862951596a5f3 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 17 May 2026 19:23:18 +0000 Subject: [PATCH 095/108] fix stat being wrong --- src/common/fs/file.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/common/fs/file.cpp b/src/common/fs/file.cpp index 854090e7b2..96fb483dbf 100644 --- a/src/common/fs/file.cpp +++ b/src/common/fs/file.cpp @@ -20,6 +20,9 @@ #else #include #endif +#ifdef __OPENORBIS__ +#include +#endif #ifdef _MSC_VER #define fileno _fileno @@ -402,28 +405,27 @@ u64 IOFile::GetSize() const { file_size = Android::GetSize(file_path); } else { std::error_code ec; - file_size = fs::file_size(file_path, ec); - if (ec) { - LOG_ERROR(Common_Filesystem, - "Failed to retrieve the file size of path={}, ec_message={}", - PathToUTF8String(file_path), ec.message()); + LOG_ERROR(Common_Filesystem, "Failed to retrieve the file size of path={}, ec_message={}", PathToUTF8String(file_path), ec.message()); return 0; } } +#elif defined(__OPENORBIS__) + // TODO: implementation of fs::file_size() is buggy on PS4, why? + // probably toolchain issue... ugh + OrbisKernelStat st{}; + stat(file_path.c_str(), reinterpret_cast(std::addressof(st))); + auto const file_size = st.st_size; + LOG_DEBUG(Common_Filesystem, "size for {} = {}", file_path.c_str(), file_size); #else std::error_code ec; - const auto file_size = fs::file_size(file_path, ec); - if (ec) { - LOG_ERROR(Common_Filesystem, "Failed to retrieve the file size of path={}, ec_message={}", - PathToUTF8String(file_path), ec.message()); + LOG_ERROR(Common_Filesystem, "Failed to retrieve the file size of path={}, ec_message={}", PathToUTF8String(file_path), ec.message()); return 0; } #endif - return file_size; } From 5f36961240cc5dcd2c57eee70ac8d102aafe3bfc Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 17 May 2026 19:29:47 +0000 Subject: [PATCH 096/108] fix timestamps due to wrong stat --- src/core/file_sys/vfs/vfs_real.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/core/file_sys/vfs/vfs_real.cpp b/src/core/file_sys/vfs/vfs_real.cpp index 1eafff6c06..60997a8a65 100644 --- a/src/core/file_sys/vfs/vfs_real.cpp +++ b/src/core/file_sys/vfs/vfs_real.cpp @@ -449,8 +449,19 @@ std::vector RealVfsDirectory::GetFiles() const { FileTimeStampRaw RealVfsDirectory::GetFileTimeStamp(std::string_view path_) const { const auto full_path = FS::SanitizePath(path + '/' + std::string(path_)); +#ifdef __OPENORBIS__ + // DO NOT USE NORMAL STAT, it's bugged on OO toolchain + OrbisKernelStat st{}; + const auto stat_result = stat(full_path.c_str(), reinterpret_cast(std::addressof(st))); + if (stat_result != 0) + return {}; + return { + .created{u64(st.st_ctime)}, + .accessed{u64(st.st_atime)}, + .modified{u64(st.st_mtime)}, + }; +#else const auto fs_path = std::filesystem::path{FS::ToU8String(full_path)}; - #ifdef _WIN32 struct _stat64 file_status; const auto stat_result = _wstat64(fs_path.c_str(), &file_status); @@ -458,16 +469,14 @@ FileTimeStampRaw RealVfsDirectory::GetFileTimeStamp(std::string_view path_) cons struct stat file_status; const auto stat_result = stat(fs_path.c_str(), &file_status); #endif - - if (stat_result != 0) { + if (stat_result != 0) return {}; - } - return { - .created{static_cast(file_status.st_ctime)}, - .accessed{static_cast(file_status.st_atime)}, - .modified{static_cast(file_status.st_mtime)}, + .created{u64(file_status.st_ctime)}, + .accessed{u64(file_status.st_atime)}, + .modified{u64(file_status.st_mtime)}, }; +#endif } std::vector RealVfsDirectory::GetSubdirectories() const { From 7974ce1771ce65721a149bb58fbbfc68499039d8 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 17 May 2026 19:41:56 +0000 Subject: [PATCH 097/108] fix pagesize --- src/common/virtual_buffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 881bf9e29e..57bcf3e873 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -125,7 +125,7 @@ static void SwapHandler(int sig, void* raw_context) { LOG_ERROR(HW_Memory, "{:#x},{} @ {}:{:#x}", mctx.mc_addr, aligned_addr, it->first, it->second); sceKernelRemoveExceptionHandler(SIGSEGV); // to not catch the next signal } else { - LOG_TRACE(HW_Memory, "{:#x},{} @ {}:{:#x}", mctx.mc_addr, aligned_addr, it->first, it->second); + LOG_DEBUG(HW_Memory, "{:#x},{} @ {}:{:#x}", mctx.mc_addr, aligned_addr, it->first, it->second); } } else { LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address From a616fbb1bcb2b9fd4a0d5d67eccdfc4ef6918086 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 17 May 2026 20:40:48 +0000 Subject: [PATCH 098/108] hostmem doesn't exist? --- src/audio_core/sink/ps4_sink.cpp | 15 ++++++++------- src/common/host_memory.cpp | 10 +++++----- src/common/host_memory.h | 7 ++++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/audio_core/sink/ps4_sink.cpp b/src/audio_core/sink/ps4_sink.cpp index 99734d876a..7e8b3be06e 100644 --- a/src/audio_core/sink/ps4_sink.cpp +++ b/src/audio_core/sink/ps4_sink.cpp @@ -32,24 +32,28 @@ struct PS4SinkStream final : public SinkStream { system_channels = system_channels_; device_channels = device_channels_; - auto const length = 0x800; + auto const length = 240 * 2; auto const sample_rate = 48000; auto const num_channels = this->GetDeviceChannels(); - output_buffer.resize(length * num_channels * sizeof(s16)); auto const param_type = num_channels == 1 ? ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO : ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO; audio_dev = sceAudioOutOpen(ORBIS_USER_SERVICE_USER_ID_SYSTEM, ORBIS_AUDIO_OUT_PORT_TYPE_MAIN, 0, length, sample_rate, param_type); if (audio_dev > 0) { audio_thread = std::jthread([=, this](std::stop_token stop_token) { + std::vector output_buffer(length * num_channels); while (!stop_token.stop_requested()) { if (this->type == StreamType::In) { // this->ProcessAudioIn(input_buffer, length); } else { + int err = 0; sceAudioOutOutput(audio_dev, nullptr); this->ProcessAudioOutAndRender(output_buffer, length); - sceAudioOutOutput(audio_dev, output_buffer.data()); + if ((err = sceAudioOutOutput(audio_dev, output_buffer.data())) < 0) { + LOG_ERROR(Service_Audio, "{}", err); + } } } + sceAudioOutClose(audio_dev); }); } else { LOG_ERROR(Service_Audio, "Failed to create audio device! {:#x}", uint32_t(audio_dev)); @@ -58,7 +62,6 @@ struct PS4SinkStream final : public SinkStream { ~PS4SinkStream() override { LOG_DEBUG(Service_Audio, "Destroying PS4 stream {}", name); - sceAudioOutClose(audio_dev); if (audio_thread.joinable()) { audio_thread.request_stop(); audio_thread.join(); @@ -67,8 +70,7 @@ struct PS4SinkStream final : public SinkStream { void Finalize() override { if (audio_dev > 0) { - Stop(); - sceAudioOutClose(audio_dev); + } } @@ -84,7 +86,6 @@ struct PS4SinkStream final : public SinkStream { } } - std::vector output_buffer; std::jthread audio_thread; int32_t audio_dev{}; }; diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 876ed03a10..d60df0fd5a 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -395,8 +395,6 @@ private: #elif defined(__OPENORBIS__) // None of the luxuries of POSIX -class Impl { -}; #else // ^^^ Windows ^^^ vvv POSIX vvv #ifdef ARCHITECTURE_arm64 @@ -678,7 +676,10 @@ private: #endif // ^^^ POSIX ^^^ -HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_) : backing_size(backing_size_), virtual_size(virtual_size_) { +HostMemory::HostMemory(size_t backing_size_, size_t virtual_size_) + : backing_size(backing_size_) + , virtual_size(virtual_size_) +{ #ifdef __OPENORBIS__ LOG_WARNING(HW_Memory, "Platform doesn't support fastmem"); fallback_buffer.emplace(backing_size); @@ -744,8 +745,7 @@ void HostMemory::Protect(size_t virtual_offset, size_t length, MemoryPermission } void HostMemory::ClearBackingRegion(size_t physical_offset, size_t length, u32 fill_value) { - if (!impl) - std::memset(backing_base + physical_offset, fill_value, length); + std::memset(backing_base + physical_offset, fill_value, length); } void HostMemory::EnableDirectMappedAddress() { diff --git a/src/common/host_memory.h b/src/common/host_memory.h index 6095230154..2a908e71b4 100644 --- a/src/common/host_memory.h +++ b/src/common/host_memory.h @@ -74,12 +74,13 @@ public: } private: - size_t backing_size{}; - size_t virtual_size{}; - // Low level handler for the platform dependent memory routines +#ifndef __OPENORBIS__ class Impl; std::unique_ptr impl; +#endif + size_t backing_size{}; + size_t virtual_size{}; u8* backing_base{}; u8* virtual_base{}; size_t virtual_base_offset{}; From d6f1b1a2cdd17cba75713d12d57d657e3465d154 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 17 May 2026 20:41:26 +0000 Subject: [PATCH 099/108] wait after audio process --- src/audio_core/sink/ps4_sink.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/audio_core/sink/ps4_sink.cpp b/src/audio_core/sink/ps4_sink.cpp index 7e8b3be06e..c205cac73c 100644 --- a/src/audio_core/sink/ps4_sink.cpp +++ b/src/audio_core/sink/ps4_sink.cpp @@ -46,11 +46,10 @@ struct PS4SinkStream final : public SinkStream { // this->ProcessAudioIn(input_buffer, length); } else { int err = 0; - sceAudioOutOutput(audio_dev, nullptr); this->ProcessAudioOutAndRender(output_buffer, length); - if ((err = sceAudioOutOutput(audio_dev, output_buffer.data())) < 0) { + sceAudioOutOutput(audio_dev, nullptr); + if ((err = sceAudioOutOutput(audio_dev, output_buffer.data())) < 0) LOG_ERROR(Service_Audio, "{}", err); - } } } sceAudioOutClose(audio_dev); From c3b7bdd6160006337ae092d95b4ca9c88253da45 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 17 May 2026 20:41:40 +0000 Subject: [PATCH 100/108] restore old audio size --- src/audio_core/sink/ps4_sink.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio_core/sink/ps4_sink.cpp b/src/audio_core/sink/ps4_sink.cpp index c205cac73c..60808dba9b 100644 --- a/src/audio_core/sink/ps4_sink.cpp +++ b/src/audio_core/sink/ps4_sink.cpp @@ -32,7 +32,7 @@ struct PS4SinkStream final : public SinkStream { system_channels = system_channels_; device_channels = device_channels_; - auto const length = 240 * 2; + auto const length = 0x800; auto const sample_rate = 48000; auto const num_channels = this->GetDeviceChannels(); From de07799d1e1538dc875f50395d17a637d1e64f82 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 17 May 2026 20:41:53 +0000 Subject: [PATCH 101/108] use 16k pages again --- src/common/virtual_buffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/virtual_buffer.cpp b/src/common/virtual_buffer.cpp index 57bcf3e873..3ef23d6537 100644 --- a/src/common/virtual_buffer.cpp +++ b/src/common/virtual_buffer.cpp @@ -116,7 +116,7 @@ static void SwapHandler(int sig, void* raw_context) { if (auto const it = std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) { return uintptr_t(addr) >= uintptr_t(e.first) && uintptr_t(addr) < uintptr_t(e.first) + e.second; }); it != swap_regions.end()) { - size_t const page_size = Orbis::ORBIS_PAGE_SIZE; //16K + size_t const page_size = Orbis::ORBIS_PAGE_SIZE * 128; //128K size_t const page_mask = ~(page_size - 1); // should replace the existing mapping... ugh void* aligned_addr = reinterpret_cast(uintptr_t(mctx.mc_addr) & page_mask); From b47a82feb18d27079946cae3a4ff5a4f1c15af54 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 17 May 2026 23:28:08 +0000 Subject: [PATCH 102/108] adjust samples to PS4<->switch --- src/audio_core/sink/ps4_sink.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/audio_core/sink/ps4_sink.cpp b/src/audio_core/sink/ps4_sink.cpp index 60808dba9b..99fe636282 100644 --- a/src/audio_core/sink/ps4_sink.cpp +++ b/src/audio_core/sink/ps4_sink.cpp @@ -10,6 +10,7 @@ #include "audio_core/common/common.h" #include "audio_core/sink/ps4_sink.h" #include "audio_core/sink/sink_stream.h" +#include "common/alignment.h" #include "common/logging.h" #include "common/scope_exit.h" #include "core/core.h" @@ -32,25 +33,26 @@ struct PS4SinkStream final : public SinkStream { system_channels = system_channels_; device_channels = device_channels_; - auto const length = 0x800; - auto const sample_rate = 48000; - auto const num_channels = this->GetDeviceChannels(); - - auto const param_type = num_channels == 1 ? ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO : ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO; - audio_dev = sceAudioOutOpen(ORBIS_USER_SERVICE_USER_ID_SYSTEM, ORBIS_AUDIO_OUT_PORT_TYPE_MAIN, 0, length, sample_rate, param_type); + audio_dev = sceAudioOutOpen(ORBIS_USER_SERVICE_USER_ID_SYSTEM, ORBIS_AUDIO_OUT_PORT_TYPE_MAIN, 0, Common::AlignUp(TargetSampleCount, 0x100), TargetSampleRate, device_channels > 1 ? ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_STEREO : ORBIS_AUDIO_OUT_PARAM_FORMAT_S16_MONO); if (audio_dev > 0) { audio_thread = std::jthread([=, this](std::stop_token stop_token) { - std::vector output_buffer(length * num_channels); + std::array buffer; while (!stop_token.stop_requested()) { if (this->type == StreamType::In) { - // this->ProcessAudioIn(input_buffer, length); + this->ProcessAudioIn(buffer, TargetSampleCount); + (void)buffer; // TODO: microphone support } else { int err = 0; - this->ProcessAudioOutAndRender(output_buffer, length); + std::fill(buffer.begin(), buffer.end(), 0); + this->ProcessAudioOutAndRender(buffer, TargetSampleCount); sceAudioOutOutput(audio_dev, nullptr); - if ((err = sceAudioOutOutput(audio_dev, output_buffer.data())) < 0) + if ((err = sceAudioOutOutput(audio_dev, buffer.data())) < 0) LOG_ERROR(Service_Audio, "{}", err); } + // Wait for pause, we don't really have a native pause + // so this is the best i can do + while (paused && !stop_token.stop_requested()) + ; } sceAudioOutClose(audio_dev); }); @@ -81,7 +83,7 @@ struct PS4SinkStream final : public SinkStream { void Stop() override { if (audio_dev > 0 && !paused) { - + SignalPause(); } } @@ -150,7 +152,7 @@ std::vector ListPS4SinkDevices(bool capture) { } u32 GetPS4Latency() { - return TargetSampleCount * 2; + return TargetSampleCount; } } // namespace AudioCore::Sink From 79fd4992f9f150b26ccd40e34d5953705b359071 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 19 May 2026 08:35:16 +0000 Subject: [PATCH 103/108] SDL3 port --- .patch/sdl2_ps4/0001-ps4.patch | 359 --------------------------------- .patch/sdl3/0001-ps4.patch | 166 +++++++++++++++ 2 files changed, 166 insertions(+), 359 deletions(-) delete mode 100644 .patch/sdl2_ps4/0001-ps4.patch create mode 100644 .patch/sdl3/0001-ps4.patch diff --git a/.patch/sdl2_ps4/0001-ps4.patch b/.patch/sdl2_ps4/0001-ps4.patch deleted file mode 100644 index cb5ed901cb..0000000000 --- a/.patch/sdl2_ps4/0001-ps4.patch +++ /dev/null @@ -1,359 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 7c230473ac..b1275edb61 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -331,6 +331,13 @@ if(CYGWIN) - list(APPEND SDL_CFLAGS "-I/usr/include/mingw") - endif() - -+######### *FIXME* -+if(PS4 OR ORBIS) -+ set(USE_GENERATED_CONFIG Off) -+else() -+ set(USE_GENERATED_CONFIG On) -+endif() -+ - # General includes - target_compile_definitions(sdl-build-options INTERFACE "-DUSING_GENERATED_CONFIG_H") - target_include_directories(sdl-build-options BEFORE INTERFACE "${SDL2_BINARY_DIR}/include" "${SDL2_BINARY_DIR}/include-config-$>") -@@ -359,6 +366,15 @@ if(EMSCRIPTEN) - set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF) - endif() - -+if(PS4 OR ORBIS) -+ set(SDL_ATOMIC_ENABLED_BY_DEFAULT ON) -+ set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) -+ set(SDL_THREADS_ENABLED_BY_DEFAULT ON) -+ set(SDL_PTHREADS_ENABLED_BY_DEFAULT ON) -+ set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) -+ set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF) -+endif() -+ - if(VITA OR PSP OR PS2 OR N3DS) - set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) - set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) -@@ -1478,7 +1494,42 @@ elseif(EMSCRIPTEN) - - CheckPTHREAD() - CheckLibUnwind() -+elseif(PS4 OR ORBIS) -+ CheckPTHREAD() -+ if(SDL_AUDIO) -+ set(SDL_AUDIO_DRIVER_PS4 1) -+ file(GLOB PS4_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/ps4/*.c) -+ set(SOURCE_FILES ${SOURCE_FILES} ${PS4_AUDIO_SOURCES}) -+ set(HAVE_SDL_AUDIO TRUE) -+ endif() -+# if(SDL_FILESYSTEM) -+# set(SDL_FILESYSTEM_PS4 1) -+# file(GLOB PS4_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/ps4/*.c) -+# set(SOURCE_FILES ${SOURCE_FILES} ${PS4_FILESYSTEM_SOURCES}) -+# set(HAVE_SDL_FILESYSTEM TRUE) -+# endif() -+ if(SDL_JOYSTICK) -+ set(SDL_JOYSTICK_PS4 1) -+ file(GLOB PS4_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/ps4/*.c) -+ set(SOURCE_FILES ${SOURCE_FILES} ${PS4_JOYSTICK_SOURCES}) -+ set(HAVE_SDL_JOYSTICK TRUE) -+ endif() -+ if(SDL_TIMERS) -+ set(SDL_TIMER_UNIX 1) -+ file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c) -+ set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES}) -+ set(HAVE_SDL_TIMERS TRUE) - -+ if(CLOCK_GETTIME) -+ set(HAVE_CLOCK_GETTIME 1) -+ endif() -+ endif() -+ if(SDL_VIDEO) -+ set(SDL_VIDEO_DRIVER_PS4 1) -+ file(GLOB PS4_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/ps4/*.c) -+ set(SOURCE_FILES ${SOURCE_FILES} ${PS4_VIDEO_SOURCES}) -+ set(HAVE_SDL_VIDEO TRUE) -+ endif() - elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) - if(SDL_AUDIO) - if(SYSV5 OR SOLARIS OR HPUX) -@@ -3039,7 +3090,7 @@ endif() - # We always need to have threads and timers around - if(NOT HAVE_SDL_THREADS) - # The emscripten platform has been carefully vetted to work without threads -- if (EMSCRIPTEN) -+ if (EMSCRIPTEN OR PS4 OR ORBIS) - set(SDL_THREADS_DISABLED 1) - file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c) - list(APPEND SOURCE_FILES ${THREADS_SOURCES}) -diff --git a/README.md b/README.md -index fa7f7ba0b5..8d5a375694 100644 ---- a/README.md -+++ b/README.md -@@ -1,5 +1,5 @@ - --# Simple DirectMedia Layer (SDL) Version 2.0 -+# Simple DirectMedia Layer (SDL) Version 2.0 (For OpenOrbis PS4 SDK) - - https://www.libsdl.org/ - -diff --git a/include/SDL_config.h b/include/SDL_config.h -index a628d86252..a101532d16 100644 ---- a/include/SDL_config.h -+++ b/include/SDL_config.h -@@ -41,6 +41,10 @@ - #include "SDL_config_iphoneos.h" - #elif defined(__ANDROID__) - #include "SDL_config_android.h" -+#elif defined(__PSP__) -+#include "SDL_config_psp.h" -+#elif defined(__OPENORBIS__) -+#include "SDL_config_ps4.h" - #elif defined(__OS2__) - #include "SDL_config_os2.h" - #elif defined(__EMSCRIPTEN__) -diff --git a/include/SDL_platform.h b/include/SDL_platform.h -index 36df782a4e..0cc20dc4e2 100644 ---- a/include/SDL_platform.h -+++ b/include/SDL_platform.h -@@ -214,6 +214,10 @@ - #if defined(PS2) - #define __PS2__ 1 - #endif -+#if defined(__OPENORBIS__) -+#undef __PS4__ -+#define __PS4__ 1 -+#endif - - /* The NACL compiler defines __native_client__ and __pnacl__ - * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi -diff --git a/src/SDL.c b/src/SDL.c -index cfeea077e7..33fce965c0 100644 ---- a/src/SDL.c -+++ b/src/SDL.c -@@ -642,6 +642,8 @@ const char *SDL_GetPlatform(void) - return "Nokia N-Gage"; - #elif defined(__3DS__) - return "Nintendo 3DS"; -+#elif defined(__PS4__) -+ return "PlayStation4"; - #else - return "Unknown (see SDL_platform.h)"; - #endif -diff --git a/src/SDL_error.c b/src/SDL_error.c -index 993f5bac55..083ebf3027 100644 ---- a/src/SDL_error.c -+++ b/src/SDL_error.c -@@ -50,11 +50,14 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) - va_end(ap); - } - } -- -+#ifndef __OPENORBIS__ // Yeah this is stupid but whatever - if (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) { -+#endif - /* If we are in debug mode, print out the error message */ - SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str); -+#ifndef __OPENORBIS__ // Yeah this is stupid but whatever - } -+#endif - } - - return -1; -diff --git a/src/SDL_log.c b/src/SDL_log.c -index 7a5f1dbc03..a7f3d85782 100644 ---- a/src/SDL_log.c -+++ b/src/SDL_log.c -@@ -390,10 +390,12 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va - int len; - va_list aq; - -+#ifndef __OPENORBIS__ - /* Nothing to do if we don't have an output function */ - if (!SDL_log_function) { - return; - } -+#endif - - /* Make sure we don't exceed array bounds */ - if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { -@@ -442,7 +444,11 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va - } - - SDL_LockMutex(log_function_mutex); -+#ifdef __OPENORBIS__ -+ printf("%s\n", message); // just fucking do it -+#else - SDL_log_function(SDL_log_userdata, category, priority, message); -+#endif - SDL_UnlockMutex(log_function_mutex); - - /* Free only if dynamically allocated */ -diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c -index 421adbc76a..82d087a2f8 100644 ---- a/src/audio/SDL_audio.c -+++ b/src/audio/SDL_audio.c -@@ -114,7 +114,10 @@ static const AudioBootStrap *const bootstrap[] = { - #ifdef SDL_AUDIO_DRIVER_N3DS - &N3DSAUDIO_bootstrap, - #endif --#ifdef SDL_AUDIO_DRIVER_EMSCRIPTEN -+#if SDL_AUDIO_DRIVER_PS4 -+ &PS4AUDIO_bootstrap, -+#endif -+#if SDL_AUDIO_DRIVER_EMSCRIPTEN - &EMSCRIPTENAUDIO_bootstrap, - #endif - #ifdef SDL_AUDIO_DRIVER_JACK -diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h -index 87387692ce..b1c00ba9dc 100644 ---- a/src/audio/SDL_sysaudio.h -+++ b/src/audio/SDL_sysaudio.h -@@ -207,6 +207,7 @@ extern AudioBootStrap PS2AUDIO_bootstrap; - extern AudioBootStrap PSPAUDIO_bootstrap; - extern AudioBootStrap VITAAUD_bootstrap; - extern AudioBootStrap N3DSAUDIO_bootstrap; -+extern AudioBootStrap PS4AUDIO_bootstrap; - extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap; - extern AudioBootStrap OS2AUDIO_bootstrap; - -diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h -index 178218c053..a6e298a9fe 100644 ---- a/src/dynapi/SDL_dynapi.h -+++ b/src/dynapi/SDL_dynapi.h -@@ -69,6 +69,8 @@ - #define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */ - #elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN) - #define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */ -+#elif defined(__OPENORBIS__) // Apparently __PS4__ getting defined is missed somewhere, I get broken static builds so force the issue -+#define SDL_DYNAMIC_API 0 - #endif - - /* everyone else. This is where we turn on the API if nothing forced it off. */ -diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c -index 60b0daf790..34433166e8 100644 ---- a/src/joystick/SDL_joystick.c -+++ b/src/joystick/SDL_joystick.c -@@ -106,6 +106,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { - #ifdef SDL_JOYSTICK_N3DS - &SDL_N3DS_JoystickDriver - #endif -+#ifdef SDL_JOYSTICK_PS4 -+ &SDL_PS4_JoystickDriver, -+#endif - #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) - &SDL_DUMMY_JoystickDriver - #endif -diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h -index d36f784143..6671aff2fd 100644 ---- a/src/joystick/SDL_sysjoystick.h -+++ b/src/joystick/SDL_sysjoystick.h -@@ -243,6 +243,7 @@ extern SDL_JoystickDriver SDL_HAIKU_JoystickDriver; - extern SDL_JoystickDriver SDL_HIDAPI_JoystickDriver; - extern SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver; - extern SDL_JoystickDriver SDL_IOS_JoystickDriver; -+extern SDL_JoystickDriver SDL_PS4_JoystickDriver; - extern SDL_JoystickDriver SDL_LINUX_JoystickDriver; - extern SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver; - extern SDL_JoystickDriver SDL_WGI_JoystickDriver; -diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c -index 35f80664ab..cd8f9d3615 100644 ---- a/src/render/SDL_render.c -+++ b/src/render/SDL_render.c -@@ -137,6 +137,10 @@ static const SDL_RenderDriver *render_drivers[] = { - #if SDL_VIDEO_RENDER_VITA_GXM - &VITA_GXM_RenderDriver, - #endif -+#if SDL_VIDEO_RENDER_PS4 && 0 // *FIXME* PS4_RenderDriver Disabled, it's software anyhow lets not reinvent... -+#error Use SoftRender for PS4 currently! -+ &PS4_RenderDriver, -+#endif - #if SDL_VIDEO_RENDER_SW - &SW_RenderDriver - #endif -diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h -index ac5426b676..d9b5bfbc39 100644 ---- a/src/render/SDL_sysrender.h -+++ b/src/render/SDL_sysrender.h -@@ -307,6 +307,7 @@ extern SDL_RenderDriver DirectFB_RenderDriver; - extern SDL_RenderDriver METAL_RenderDriver; - extern SDL_RenderDriver PS2_RenderDriver; - extern SDL_RenderDriver PSP_RenderDriver; -+extern SDL_RenderDriver PS4_RenderDriver; - extern SDL_RenderDriver SW_RenderDriver; - extern SDL_RenderDriver VITA_GXM_RenderDriver; - -diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c -index 212fe9c000..a920afba0b 100644 ---- a/src/thread/pthread/SDL_systhread.c -+++ b/src/thread/pthread/SDL_systhread.c -@@ -29,8 +29,10 @@ - #include - #endif - -+#ifdef HAVE_SIGNAL_H - #include - #include -+#endif - - #ifdef __LINUX__ - #include -@@ -60,7 +62,7 @@ - #endif - - --#ifndef __NACL__ -+#if !defined(__NACL__) && !defined(__OPENORBIS__) - /* List of signals to mask in the subthreads */ - static const int sig_list[] = { - SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, -@@ -162,7 +164,7 @@ void SDL_SYS_SetupThread(const char *name) - } - - /* NativeClient does not yet support signals.*/ --#if !defined(__NACL__) -+#if !defined(__NACL__) && !defined(__OPENORBIS__) - /* Mask asynchronous signals for this thread */ - sigemptyset(&mask); - for (i = 0; sig_list[i]; ++i) { -diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h -index badb1a3edc..e17beb9f5c 100644 ---- a/src/video/SDL_sysvideo.h -+++ b/src/video/SDL_sysvideo.h -@@ -471,6 +471,7 @@ extern VideoBootStrap PSP_bootstrap; - extern VideoBootStrap VITA_bootstrap; - extern VideoBootStrap RISCOS_bootstrap; - extern VideoBootStrap N3DS_bootstrap; -+extern VideoBootStrap PS4_bootstrap; - extern VideoBootStrap RPI_bootstrap; - extern VideoBootStrap KMSDRM_bootstrap; - extern VideoBootStrap KMSDRM_LEGACY_bootstrap; -diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c -index 134cc05e13..f40d6104e2 100644 ---- a/src/video/SDL_video.c -+++ b/src/video/SDL_video.c -@@ -121,6 +121,9 @@ static VideoBootStrap *bootstrap[] = { - #ifdef SDL_VIDEO_DRIVER_N3DS - &N3DS_bootstrap, - #endif -+#ifdef SDL_VIDEO_DRIVER_PS4 -+ &PS4_bootstrap, -+#endif - #ifdef SDL_VIDEO_DRIVER_KMSDRM - &KMSDRM_bootstrap, - #endif -@@ -241,6 +244,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U - SDL_GetWindowSizeInPixels(window, &w, &h); - - if (!data) { -+ - SDL_Renderer *renderer = NULL; - const char *render_driver = NULL; - const char *hint; -@@ -297,7 +301,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U - SDL_assert(renderer != NULL); /* should have explicitly checked this above. */ - - /* Create the data after we successfully create the renderer (bug #1116) */ -- data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); -+ data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(SDL_WindowTextureData)); - if (!data) { - SDL_DestroyRenderer(renderer); - return SDL_OutOfMemory(); diff --git a/.patch/sdl3/0001-ps4.patch b/.patch/sdl3/0001-ps4.patch new file mode 100644 index 0000000000..8949d8763e --- /dev/null +++ b/.patch/sdl3/0001-ps4.patch @@ -0,0 +1,166 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8872895..00613c3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1770,7 +1770,6 @@ elseif(EMSCRIPTEN) + + CheckPTHREAD() + CheckLibUnwind() +- + elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) + + set(SDL_DISABLE_DLOPEN_NOTES TRUE) +@@ -3647,10 +3646,17 @@ if(NOT HAVE_CAMERA) + ) + endif() + ++# Always on? ++if (PLATFORM_PS4) ++ set(HAVE_SDL_THREADS TRUE) ++ set(HAVE_SDL_TIMERS TRUE) ++ set(SDL_THREAD_PTHREAD 1) ++endif () ++ + # We always need to have threads and timers around + if(NOT HAVE_SDL_THREADS) + # The Emscripten and N-Gage platform has been carefully vetted to work without threads +- if(EMSCRIPTEN OR NGAGE) ++ if(EMSCRIPTEN OR NGAGE OR PLATFORM_PS4) + set(SDL_THREADS_DISABLED 1) + sdl_glob_sources( + "${SDL3_SOURCE_DIR}/src/thread/generic/*.c" +diff --git a/build-scripts/rename_macros.py b/build-scripts/rename_macros.py +index 978120c..b6063dd 100755 +--- a/build-scripts/rename_macros.py ++++ b/build-scripts/rename_macros.py +@@ -124,6 +124,7 @@ RENAMED_MACROS = { + "__RISCOS__": "SDL_PLATFORM_RISCOS", + "__SOLARIS__": "SDL_PLATFORM_SOLARIS", + "__PSP__": "SDL_PLATFORM_PSP", ++ "__PS4__": "SDL_PLATFORM_PS4", + "__PS2__": "SDL_PLATFORM_PS2", + "__VITA__": "SDL_PLATFORM_VITA", + "__3DS__": "SDL_PLATFORM_3DS", +diff --git a/include/SDL3/SDL_platform_defines.h b/include/SDL3/SDL_platform_defines.h +index 7963149..7465530 100644 +--- a/include/SDL3/SDL_platform_defines.h ++++ b/include/SDL3/SDL_platform_defines.h +@@ -442,6 +442,16 @@ + #define SDL_PLATFORM_PSP 1 + #endif + ++#if defined(__PS4__) || defined(__OPENROBIS__) ++ ++/** ++ * A preprocessor macro that is only defined if compiling for Sony PSP. ++ * ++ * \since This macro is available since SDL 3.2.0. ++ */ ++#define SDL_PLATFORM_PS4 1 ++#endif ++ + #if defined(__PS2__) || defined(PS2) + + /** +diff --git a/src/SDL.c b/src/SDL.c +index b1a1a56..e6563ee 100644 +--- a/src/SDL.c ++++ b/src/SDL.c +@@ -813,6 +813,8 @@ const char *SDL_GetPlatform(void) + return "tvOS"; + #elif defined(SDL_PLATFORM_PS2) + return "PlayStation 2"; ++#elif defined(SDL_PLATFORM_PS4) ++ return "PlayStation 4"; + #elif defined(SDL_PLATFORM_PSP) + return "PlayStation Portable"; + #elif defined(SDL_PLATFORM_VITA) +diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c +index c1e4241..2393b3f 100644 +--- a/src/audio/SDL_audio.c ++++ b/src/audio/SDL_audio.c +@@ -80,7 +80,10 @@ static const AudioBootStrap *const bootstrap[] = { + #ifdef SDL_AUDIO_DRIVER_NGAGE + &NGAGEAUDIO_bootstrap, + #endif +-#ifdef SDL_AUDIO_DRIVER_EMSCRIPTEN ++#if SDL_AUDIO_DRIVER_PS4 ++ &PS4AUDIO_bootstrap, ++#endif ++#if SDL_AUDIO_DRIVER_EMSCRIPTEN + &EMSCRIPTENAUDIO_bootstrap, + #endif + #ifdef SDL_AUDIO_DRIVER_JACK +diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c +index 60c9743..2d12c3a 100644 +--- a/src/joystick/SDL_joystick.c ++++ b/src/joystick/SDL_joystick.c +@@ -106,6 +106,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { + #ifdef SDL_JOYSTICK_N3DS + &SDL_N3DS_JoystickDriver, + #endif ++#ifdef SDL_JOYSTICK_PS4 ++ &SDL_PS4_JoystickDriver, ++#endif + #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) + &SDL_DUMMY_JoystickDriver + #endif +diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h +index 47ce42c..42ab9de 100644 +--- a/src/joystick/SDL_sysjoystick.h ++++ b/src/joystick/SDL_sysjoystick.h +@@ -253,6 +253,7 @@ extern SDL_JoystickDriver SDL_HAIKU_JoystickDriver; + extern SDL_JoystickDriver SDL_HIDAPI_JoystickDriver; + extern SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver; + extern SDL_JoystickDriver SDL_IOS_JoystickDriver; ++extern SDL_JoystickDriver SDL_PS4_JoystickDriver; + extern SDL_JoystickDriver SDL_LINUX_JoystickDriver; + extern SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver; + extern SDL_JoystickDriver SDL_WGI_JoystickDriver; +diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h +index a1bb44a..51843c4 100644 +--- a/src/render/SDL_sysrender.h ++++ b/src/render/SDL_sysrender.h +@@ -381,6 +381,7 @@ extern SDL_RenderDriver NGAGE_RenderDriver; + extern SDL_RenderDriver VULKAN_RenderDriver; + extern SDL_RenderDriver PS2_RenderDriver; + extern SDL_RenderDriver PSP_RenderDriver; ++extern SDL_RenderDriver PS4_RenderDriver; + extern SDL_RenderDriver SW_RenderDriver; + extern SDL_RenderDriver VITA_GXM_RenderDriver; + extern SDL_RenderDriver GPU_RenderDriver; +diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c +index 4a870f6..68dc7e1 100644 +--- a/src/stdlib/SDL_string.c ++++ b/src/stdlib/SDL_string.c +@@ -38,6 +38,8 @@ + #define SDL_SIZEOF_WCHAR_T 2 + #elif defined(SDL_PLATFORM_WINDOWS) + #define SDL_SIZEOF_WCHAR_T 2 ++#elif defined(SDL_PLATFORM_PS4) ++#define SDL_SIZEOF_WCHAR_T 2 + #else // assume everything else is UTF-32 (add more tests if compiler-assert fails below!) + #define SDL_SIZEOF_WCHAR_T 4 + #endif +diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c +index f650f27..e23424f 100644 +--- a/src/video/SDL_video.c ++++ b/src/video/SDL_video.c +@@ -131,6 +131,9 @@ static VideoBootStrap *bootstrap[] = { + #ifdef SDL_VIDEO_DRIVER_NGAGE + &NGAGE_bootstrap, + #endif ++#ifdef SDL_VIDEO_DRIVER_PS4 ++ &PS4_bootstrap, ++#endif + #ifdef SDL_VIDEO_DRIVER_KMSDRM + &KMSDRM_bootstrap, + #endif +@@ -314,6 +317,7 @@ static bool SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, + SDL_GetWindowSizeInPixels(window, &w, &h); + + if (!data) { ++ + SDL_Renderer *renderer = NULL; + const char *render_driver = NULL; + From a9cb1f9194395d304dc6681b935f8be230bdd12b Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 19 May 2026 09:12:44 +0000 Subject: [PATCH 104/108] sdl3 compiles now --- .patch/sdl3/0001-ps4.patch | 68 +++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/.patch/sdl3/0001-ps4.patch b/.patch/sdl3/0001-ps4.patch index 8949d8763e..3b94af77d1 100644 --- a/.patch/sdl3/0001-ps4.patch +++ b/.patch/sdl3/0001-ps4.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 8872895..00613c3 100644 +index 8872895..b0eeca8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1770,7 +1770,6 @@ elseif(EMSCRIPTEN) @@ -10,14 +10,27 @@ index 8872895..00613c3 100644 elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) set(SDL_DISABLE_DLOPEN_NOTES TRUE) -@@ -3647,10 +3646,17 @@ if(NOT HAVE_CAMERA) +@@ -3647,10 +3646,30 @@ if(NOT HAVE_CAMERA) ) endif() +# Always on? +if (PLATFORM_PS4) ++ sdl_sources( ++ "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c" ++ "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c" # Can be faked, if necessary ++ "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c" # Can be faked, if necessary ++ "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_sysrwlock.c" # Can be faked, if necessary ++ "${SDL3_SOURCE_DIR}/src/thread/pthread/SDL_systls.c" ++ "${SDL3_SOURCE_DIR}/src/thread/generic/SDL_syssem.c" ++ ) ++ sdl_glob_sources("${SDL3_SOURCE_DIR}/src/time/unix/*.c") ++ sdl_glob_sources("${SDL3_SOURCE_DIR}/src/timer/unix/*.c") + set(HAVE_SDL_THREADS TRUE) + set(HAVE_SDL_TIMERS TRUE) ++ set(HAVE_SDL_TIME TRUE) ++ set(SDL_TIME_UNIX 1) ++ set(SDL_TIMER_UNIX 1) + set(SDL_THREAD_PTHREAD 1) +endif () + @@ -42,14 +55,14 @@ index 978120c..b6063dd 100755 "__VITA__": "SDL_PLATFORM_VITA", "__3DS__": "SDL_PLATFORM_3DS", diff --git a/include/SDL3/SDL_platform_defines.h b/include/SDL3/SDL_platform_defines.h -index 7963149..7465530 100644 +index 7963149..6c0dd5d 100644 --- a/include/SDL3/SDL_platform_defines.h +++ b/include/SDL3/SDL_platform_defines.h @@ -442,6 +442,16 @@ #define SDL_PLATFORM_PSP 1 #endif -+#if defined(__PS4__) || defined(__OPENROBIS__) ++#if defined(__PS4__) || defined(__OPENORBIS__) + +/** + * A preprocessor macro that is only defined if compiling for Sony PSP. @@ -63,9 +76,18 @@ index 7963149..7465530 100644 /** diff --git a/src/SDL.c b/src/SDL.c -index b1a1a56..e6563ee 100644 +index b1a1a56..0a3fec6 100644 --- a/src/SDL.c +++ b/src/SDL.c +@@ -714,7 +714,7 @@ void SDL_Quit(void) + SDL_DBus_Quit(); + #endif + +-#if defined(SDL_PLATFORM_UNIX) && !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_PLATFORM_EMSCRIPTEN) && !defined(SDL_PLATFORM_PRIVATE) ++#if defined(SDL_PLATFORM_UNIX) && !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_PLATFORM_EMSCRIPTEN) && !defined(SDL_PLATFORM_PRIVATE) && !defined(SDL_PLATFORM_PS4) + SDL_Gtk_Quit(); + #endif + @@ -813,6 +813,8 @@ const char *SDL_GetPlatform(void) return "tvOS"; #elif defined(SDL_PLATFORM_PS2) @@ -76,21 +98,19 @@ index b1a1a56..e6563ee 100644 return "PlayStation Portable"; #elif defined(SDL_PLATFORM_VITA) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c -index c1e4241..2393b3f 100644 +index c1e4241..65b1e6d 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c -@@ -80,7 +80,10 @@ static const AudioBootStrap *const bootstrap[] = { +@@ -80,6 +80,9 @@ static const AudioBootStrap *const bootstrap[] = { #ifdef SDL_AUDIO_DRIVER_NGAGE &NGAGEAUDIO_bootstrap, #endif --#ifdef SDL_AUDIO_DRIVER_EMSCRIPTEN -+#if SDL_AUDIO_DRIVER_PS4 ++#ifdef SDL_AUDIO_DRIVER_PS4 + &PS4AUDIO_bootstrap, +#endif -+#if SDL_AUDIO_DRIVER_EMSCRIPTEN + #ifdef SDL_AUDIO_DRIVER_EMSCRIPTEN &EMSCRIPTENAUDIO_bootstrap, #endif - #ifdef SDL_AUDIO_DRIVER_JACK diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 60c9743..2d12c3a 100644 --- a/src/joystick/SDL_joystick.c @@ -130,18 +150,28 @@ index a1bb44a..51843c4 100644 extern SDL_RenderDriver VITA_GXM_RenderDriver; extern SDL_RenderDriver GPU_RenderDriver; diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c -index 4a870f6..68dc7e1 100644 +index 4a870f6..69ca1db 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c -@@ -38,6 +38,8 @@ - #define SDL_SIZEOF_WCHAR_T 2 - #elif defined(SDL_PLATFORM_WINDOWS) - #define SDL_SIZEOF_WCHAR_T 2 -+#elif defined(SDL_PLATFORM_PS4) +@@ -32,7 +32,9 @@ + + #include "SDL_casefolding.h" + +-#if defined(__SIZEOF_WCHAR_T__) ++#if defined(SDL_PLATFORM_PS4) +#define SDL_SIZEOF_WCHAR_T 2 - #else // assume everything else is UTF-32 (add more tests if compiler-assert fails below!) - #define SDL_SIZEOF_WCHAR_T 4 ++#elif defined(__SIZEOF_WCHAR_T__) + #define SDL_SIZEOF_WCHAR_T __SIZEOF_WCHAR_T__ + #elif defined(SDL_PLATFORM_NGAGE) + #define SDL_SIZEOF_WCHAR_T 2 +@@ -43,7 +45,6 @@ #endif + SDL_COMPILE_TIME_ASSERT(sizeof_wchar_t, sizeof(wchar_t) == SDL_SIZEOF_WCHAR_T); + +- + char *SDL_UCS4ToUTF8(Uint32 codepoint, char *dst) + { + if (!dst) { diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index f650f27..e23424f 100644 --- a/src/video/SDL_video.c From aa8d71719c94137f66e73c49766f5beee94cd32a Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 19 May 2026 09:33:56 +0000 Subject: [PATCH 105/108] random fixes --- .ci/ps4/build.sh | 2 +- src/input_common/main.cpp | 4 ++++ src/yuzu_cmd/emu_window/emu_window_sdl3.cpp | 13 ++++--------- src/yuzu_cmd/yuzu.cpp | 8 +++++++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.ci/ps4/build.sh b/.ci/ps4/build.sh index 0536ca34bb..ae0ffd3aef 100755 --- a/.ci/ps4/build.sh +++ b/.ci/ps4/build.sh @@ -37,7 +37,7 @@ EOF # Normally a platform has a package manager # PS4 does not, atleast not in the normal sense export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@) -cmake -S . -B build -G "Unix Makefiles" \ +[ -f "build/Makefile" ] || cmake -S . -B build -G "Unix Makefiles" \ -DCMAKE_TOOLCHAIN_FILE="ps4-toolchain.cmake" \ -DENABLE_QT_TRANSLATION=OFF \ -DENABLE_CUBEB=OFF \ diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 22eb5d06df..9c89d092c0 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -160,6 +160,7 @@ struct InputSubsystem::Impl { #ifndef __OPENORBIS__ auto udp_devices = udp_client->GetInputDevices(); devices.insert(devices.end(), udp_devices.begin(), udp_devices.end()); +#endif #ifdef HAVE_SDL3 auto joycon_devices = joycon->GetInputDevices(); devices.insert(devices.end(), joycon_devices.begin(), joycon_devices.end()); @@ -196,6 +197,7 @@ struct InputSubsystem::Impl { if (engine == udp_client->GetEngineName()) { return udp_client; } +#endif #ifdef HAVE_SDL3 if (engine == sdl->GetEngineName()) { return sdl; @@ -311,6 +313,7 @@ struct InputSubsystem::Impl { #endif #ifndef __OPENORBIS__ udp_client->BeginConfiguration(); +#endif #ifdef HAVE_SDL3 sdl->BeginConfiguration(); joycon->BeginConfiguration(); @@ -328,6 +331,7 @@ struct InputSubsystem::Impl { #endif #ifndef __OPENORBIS__ udp_client->EndConfiguration(); +#endif #ifdef HAVE_SDL3 sdl->EndConfiguration(); joycon->EndConfiguration(); diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp index cd390d29f9..05c17dbff1 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp @@ -165,11 +165,11 @@ void EmuWindow_SDL3::Fullscreen() { void EmuWindow_SDL3::WaitEvent() { // Called on main thread - SDL_Event event; + SDL_Event event{}; - if (!SDL_WaitEvent(&event)) { + if (!SDL_WaitEventTimeout(&event, -1)) { const char* error = SDL_GetError(); - if (!error || strcmp(error, "") == 0) { + if (!error || strlen(error) == 0) { // https://github.com/libsdl-org/SDL/issues/5780 // Sometimes SDL will return without actually having hit an error condition; // just ignore it in this case. @@ -236,12 +236,7 @@ void EmuWindow_SDL3::WaitEvent() { const u32 current_time = SDL_GetTicks(); if (current_time > last_time + 2000) { const auto results = system.GetAndResetPerfStats(); - const auto title = fmt::format("{} | {}-{} | FPS: {:.0f} ({:.0f}%)", - Common::g_build_fullname, - Common::g_scm_branch, - Common::g_scm_desc, - results.average_game_fps, - results.emulation_speed * 100.0); + const auto title = fmt::format("{} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc, results.average_game_fps, results.emulation_speed * 100.0); SDL_SetWindowTitle(render_window, title.c_str()); last_time = current_time; } diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index acb80788bc..1b81e9793b 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -220,13 +220,19 @@ int main(int argc, char** argv) { std::optional selected_user{}; std::optional override_gdb_port{}; bool use_multiplayer = false; - bool fullscreen = false; std::string nickname{}; std::string password{}; std::string address{}; std::string input_profile{}; u16 port = Network::DefaultRoomPort; + // Platforms that start with fullscreen +#if defined(__OPENORBIS__) || defined(__ANDROID__) + bool fullscreen = true; +#else + bool fullscreen = false; +#endif + static struct option long_options[] = { // clang-format off {"debug", no_argument, 0, 'd'}, From 9ebc020e8e377baf04867b539f496f30c20a0987 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 19 May 2026 09:35:48 +0000 Subject: [PATCH 106/108] novideo --- src/yuzu_cmd/emu_window/emu_window_sdl3.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp index 05c17dbff1..e2aa68113f 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl3.cpp @@ -22,10 +22,17 @@ EmuWindow_SDL3::EmuWindow_SDL3(InputCommon::InputSubsystem* input_subsystem_, Core::System& system_) : input_subsystem{input_subsystem_}, system{system_} { input_subsystem->Initialize(); +#ifdef __OPENORBIS__ + if (!SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD)) { + LOG_CRITICAL(Frontend, "Failed to initialize SDL3: {}, Exiting...", SDL_GetError()); + exit(1); + } +#else if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD)) { LOG_CRITICAL(Frontend, "Failed to initialize SDL3: {}, Exiting...", SDL_GetError()); exit(1); } +#endif } EmuWindow_SDL3::~EmuWindow_SDL3() { From 9b60260ec8557f831d5c3b22cc9e4f41cc06d844 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 20 May 2026 15:04:16 +0000 Subject: [PATCH 107/108] license fix? --- src/input_common/drivers/joycon.h | 3 +++ src/input_common/helpers/joycon_protocol/joycon_types.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/input_common/drivers/joycon.h b/src/input_common/drivers/joycon.h index 92ebf0c813..820c4b2eaa 100644 --- a/src/input_common/drivers/joycon.h +++ b/src/input_common/drivers/joycon.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h index 439becb2ed..dd3bd4398c 100644 --- a/src/input_common/helpers/joycon_protocol/joycon_types.h +++ b/src/input_common/helpers/joycon_protocol/joycon_types.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later From 786d49c5a7b3514fe13e430f69a8a6fcabdd08aa Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 20 May 2026 15:31:45 +0000 Subject: [PATCH 108/108] bye bye sdl2 --- externals/cpmfile.json | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/externals/cpmfile.json b/externals/cpmfile.json index 563e48b419..35b60e13eb 100644 --- a/externals/cpmfile.json +++ b/externals/cpmfile.json @@ -165,16 +165,7 @@ "tag": "release-%VERSION%", "hash": "df5a323af7ac366661a3c0e887969c72584d232f3cc211419d59b0487b620b6b2859d4549c9e8df002ee489290062e466fcfddf7edc0872a37b1f2845e81c0f3", "git_version": "3.4.8", - "version": "3.2.10" - }, - "sdl2_ps4": { - "package": "SDL2", - "repo": "libsdl-org/SDL", - "sha": "0c7042477a", - "hash": "91d897257fe1134e65234618a96bc8f4f9b61dd3ba42241a65c293cd406139e308a6c79eadfa7c3969271c88d73149e75c4310fff37c79387c80d9c982c1f322", - "key": "ps4", - "bundled": true, - "skip_updates": true, + "version": "3.2.10", "patches": [ "0001-ps4.patch" ]