From ee96a1b8cabe8f30f988cf66bb8dbe5ae550bab8 Mon Sep 17 00:00:00 2001 From: Baptiste MOINE Date: Thu, 5 Nov 2026 23:57:10 +0100 Subject: [PATCH] Fix the Windows and CI builds --- README.md | 4 ++-- emu_state.h | 23 +++++++++++++---------- linux/build.sh | 15 ++++++++++++--- tests/kernelcpu/build.sh | 15 ++++++++++++--- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7339880..c5e30ca 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ real consoles. Details in [DESIGN.md](DESIGN.md#ccplex-cpu0). way a bootloader would hand over to it: ```bash -linux/build.sh # linux/boot.bin (devkitARM + devkitA64) +linux/build.sh # linux/boot.bin (arm-none-eabi + aarch64 gcc) linux/mkdtb.sh tegra210-odin.dtb odin-emu.dtb # console on UART-B, one CPU linux/run.sh Image odin-emu.dtb boot.log 120 ``` @@ -228,7 +228,7 @@ initialisation. ## Tests ```bash -make test # CCPLEX, kernel CPU, SE, USB + display regression payloads (arm-none-eabi-gcc, devkitA64, python3) +make test # CCPLEX, kernel CPU, SE, USB + display regression payloads (arm-none-eabi-gcc, aarch64 gcc, python3) tests/hwtest/build.sh build-hwtest # build hwtest-rcm (+ gcc-aarch64-linux-gnu) tests/hwtest/run.sh ./rcm_emu build-hwtest/hwtest-rcm/build/hwtest.bin ``` diff --git a/emu_state.h b/emu_state.h index ec7e0b7..c4a4882 100644 --- a/emu_state.h +++ b/emu_state.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include @@ -260,20 +259,24 @@ struct EmuState { // Framebuffer snapshots asked for by the input script (SNAP), written by // the display thread from the next frame it shows. CPU thread produces, - // display thread consumes. - std::mutex snap_mtx; + // display thread consumes. A spin lock, not std::mutex: the Windows + // build's MinGW uses the win32 thread model, which has none. + std::atomic snap_busy{false}; std::vector snap_paths; void snap_request(const std::string &path) { - std::lock_guard lk(snap_mtx); + while (snap_busy.exchange(true, std::memory_order_acquire)) {} snap_paths.push_back(path); + snap_busy.store(false, std::memory_order_release); } bool snap_take(std::string *path) { - std::lock_guard lk(snap_mtx); - if (snap_paths.empty()) - return false; - *path = snap_paths.front(); - snap_paths.erase(snap_paths.begin()); - return true; + while (snap_busy.exchange(true, std::memory_order_acquire)) {} + bool got = !snap_paths.empty(); + if (got) { + *path = snap_paths.front(); + snap_paths.erase(snap_paths.begin()); + } + snap_busy.store(false, std::memory_order_release); + return got; } // last_rot mirrors the rotation last applied by sdl_display_update. // Read from the SDL event handler to invert the display→window transform. diff --git a/linux/build.sh b/linux/build.sh index 544db60..2ce378a 100755 --- a/linux/build.sh +++ b/linux/build.sh @@ -1,9 +1,18 @@ #!/bin/sh -# Builds linux/boot.bin: shim.S (devkitA64) embedded in the BPMP payload. +# Builds linux/boot.bin: shim.S (an AArch64 assembler) embedded in the BPMP payload. set -e D=$(dirname "$0") -A64=${A64:-/opt/devkitpro/devkitA64/bin/aarch64-none-elf-} -ARM=${ARM:-/opt/devkitpro/devkitARM/bin/arm-none-eabi-} +# devkitPro when it is installed, else the distribution's cross compilers +# (gcc-aarch64-linux-gnu, gcc-arm-none-eabi), as on CI. +DKP=${DEVKITPRO:-/opt/devkitpro} +if [ -z "$A64" ]; then + A64=aarch64-linux-gnu- + if [ -x "$DKP/devkitA64/bin/aarch64-none-elf-gcc" ]; then A64=$DKP/devkitA64/bin/aarch64-none-elf-; fi +fi +if [ -z "$ARM" ]; then + ARM=arm-none-eabi- + if [ -x "$DKP/devkitARM/bin/arm-none-eabi-gcc" ]; then ARM=$DKP/devkitARM/bin/arm-none-eabi-; fi +fi ${A64}gcc -c -o "$D/shim.o" "$D/shim.S" ${A64}ld -Ttext=0xA0000000 -o "$D/shim.elf" "$D/shim.o" ${A64}objcopy -O binary "$D/shim.elf" "$D/shim.bin" diff --git a/tests/kernelcpu/build.sh b/tests/kernelcpu/build.sh index 45fb20f..06242fb 100755 --- a/tests/kernelcpu/build.sh +++ b/tests/kernelcpu/build.sh @@ -1,10 +1,19 @@ #!/bin/sh -# Builds tests/kernelcpu/payload.bin: cpu0.S with devkitA64's assembler, +# Builds tests/kernelcpu/payload.bin: cpu0.S with an AArch64 assembler, # embedded as a word array into the BPMP payload built with arm-none-eabi. set -e D=$(dirname "$0") -A64=${A64:-/opt/devkitpro/devkitA64/bin/aarch64-none-elf-} -ARM=${ARM:-/opt/devkitpro/devkitARM/bin/arm-none-eabi-} +# devkitPro when it is installed, else the distribution's cross compilers +# (gcc-aarch64-linux-gnu, gcc-arm-none-eabi), as on CI. +DKP=${DEVKITPRO:-/opt/devkitpro} +if [ -z "$A64" ]; then + A64=aarch64-linux-gnu- + if [ -x "$DKP/devkitA64/bin/aarch64-none-elf-gcc" ]; then A64=$DKP/devkitA64/bin/aarch64-none-elf-; fi +fi +if [ -z "$ARM" ]; then + ARM=arm-none-eabi- + if [ -x "$DKP/devkitARM/bin/arm-none-eabi-gcc" ]; then ARM=$DKP/devkitARM/bin/arm-none-eabi-; fi +fi ${A64}gcc -c -o "$D/cpu0.o" "$D/cpu0.S" ${A64}ld -Ttext=0xA0000000 -o "$D/cpu0.elf" "$D/cpu0.o" ${A64}objcopy -O binary "$D/cpu0.elf" "$D/cpu0.bin"