240 changed files with 2529 additions and 9195 deletions

No files matched your search

+6 -6
View File
@@ -34,21 +34,21 @@ jobs:
include:
- platform: TEGRAX1
type: Release
os: ubuntu-20.04
os: ubuntu-18.04
- platform: TEGRAX1
type: Trace
os: ubuntu-20.04
os: ubuntu-18.04
- platform: TEGRAX1ARM32
type: Release
os: ubuntu-20.04
os: ubuntu-18.04
- platform: TEGRAX1ARM32
type: Trace
os: ubuntu-20.04
os: ubuntu-18.04
runs-on: ${{ matrix.os }}
steps:
- name: "Checkout Box86 Repository"
uses: actions/checkout@v3
uses: actions/checkout@v2
- name: "Environment preparation"
run: |
@@ -111,7 +111,7 @@ jobs:
ctest -j$(nproc)
- name: "Upload Artifact"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v2
with:
name: box86-${{ matrix.platform }}-${{ matrix.type }}
path: build/box86
+1 -2
View File
@@ -5,5 +5,4 @@ build*/
src/git_head.h
backup/
box86_update.sh
restore_backup.sh
.cache
restore_backup.sh
+4 -41
View File
@@ -5,12 +5,10 @@ option(PYRA "Set to ON if targeting an OpenPandora device" ${PYRA})
option(RPI2 "Set to ON if targeting an RaspberryPI2 device" ${RPI2})
option(RPI3 "Set to ON if targeting an RaspberryPI3 device" ${RPI3})
option(RPI4 "Set to ON if targeting an RaspberryPI4 device" ${RPI4})
option(RPI3ARM64 "Set to ON if targeting an RaspberryPI3 device with multiarch arm64 and armhf" ${RPI3ARM64})
option(RPI4ARM64 "Set to ON if targeting an RaspberryPI4 device with multiarch arm64 and armhf" ${RPI4ARM64})
option(GOA_CLONE "Set to ON if targeting GO Advance clones, like RG351p/v, Gameforce Chi, RGB10..." ${GOA_CLONE})
option(RK3288 "Set to ON if targeting an Rockchip RK3288 based device" ${RK3288})
option(RK3399 "Set to ON if targeting an Rockchip RK3399 based device" ${RK3399})
option(RK3588 "Set to ON if targeting an Rockchip RK3588 / RK3588S based device" ${RK3588})
option(ODROIDN2 "Set to ON if targeting an Odroid-N2 device" ${ODROIDN2})
option(TEGRAX1 "Set to ON if targeting an Tegra X1 (ARM64) based device" ${TEGRAX1})
option(TEGRAX1ARM32 "Set to ON if targeting an Tegra X1 (ARM32) based device" ${TEGRAX1ARM32})
@@ -20,8 +18,6 @@ option(ODROID "Set to ON if targeting an ODroid device" ${ODROID})
option(POWER9 "Set to ON if targeting a POWER9 processor" ${POWER9})
option(SD845 "Set to ON if targeting a Snapragon 845 based device" ${SD845})
option(A64 "Set to ON if targeting an Allwinner A64 based device" ${A64})
option(ARM64 "Set to ON if targeting a generic ARM64 based device" ${ARM64})
option(BAD_SIGNAL "Set to ON to activate the workaround for incoherent si_info on SIGSEGV" ${BAD_SIGNAL})
option(LX2160A "Set to ON if targeting an LX2160A based device" ${LX2160A})
option(ANDROID "Set to ON if targeting an Android device" ${ANDROID})
option(USE_CCACHE "Set to ON to use ccache if present in the system" ${USE_CCACHE})
@@ -29,13 +25,10 @@ option(HAVE_TRACE "Set to ON to have Trace ability (needs ZydisInfo library)" ${
option(NOLOADADDR "Set to ON to avoid fixing the load address of Box86" ${NO_LOADAADR})
option(NOGETCLOCK "Set to ON to avoid using clock_gettime with CLOCK_MONOTONIC_COARSE for RDTSC opcode (use gltimeofday instead)" ${NOGETCLOCK})
option(NOGIT "Set to ON if not building from a git clone repo (like when building from a zip download from github)" ${NOGIT})
if(PANDORA OR PYRA OR RPI2 OR RPI3 OR RPI4 OR GAMESHELL OR ODROID OR GOA_CLONE OR RK3288 OR RK3399 OR ODROIDN2 OR TEGRAX1 OR TEGRAX1ARM32 OR RPI3ARM64 OR RPI4ARM64 OR PHYTIUM OR SD845 OR A64 OR LX2160A OR ARM64 OR RK3588)
if(PANDORA OR PYRA OR RPI2 OR RPI3 OR RPI4 OR GAMESHELL OR ODROID OR GOA_CLONE OR RK3288 OR RK3399 OR ODROIDN2 OR TEGRAX1 OR TEGRAX1ARM32 OR RPI4ARM64 OR PHYTIUM OR SD845 OR A64 OR LX2160A)
set(LD80BITS OFF CACHE BOOL "")
set(NOALIGN OFF CACHE BOOL "")
set(ARM_DYNAREC ON CACHE BOOL "")
if(RK3588)
set(BAD_SIGNAL ON CACHE BOOL "")
endif()
endif()
if(ANDROID)
set(NOLOADADDR ON CACHE BOOL "")
@@ -68,7 +61,7 @@ string(COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "x86_64" _x86_64)
string(COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "aarch64" _aarch64)
string(COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "armhf" _armhf)
if(_aarch64 AND (RK3399 OR ODROIDN2 OR TEGRAX1 OR RPI3ARM64 OR RPI4ARM64 OR PHYTIUM OR SD845 OR A64 OR LX2160A OR RK3588 OR ARM64))
if(_aarch64 AND (RK3399 OR ODROIDN2 OR TEGRAX1 OR RPI4ARM64 OR PHYTIUM OR SD845 OR A64 OR LX2160A))
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
#set(CMAKE_ASM_COMPILER arm-linux-gnueabihf-as) #will use gcc in fact
set(CMAKE_C_COMPILER_TARGET arm-linux-gnueabihf)
@@ -88,7 +81,6 @@ endif()
if(PANDORA)
add_definitions(-DPANDORA)
#add_definitions(-mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -fsingle-precision-constant -ffast-math)
set(CMAKE_ASM_FLAGS "-marm -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp")
elseif(GAMESHELL)
add_definitions(-DGAMESHELL)
add_definitions(-marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard)
@@ -112,11 +104,6 @@ elseif(RPI4)
add_definitions(-DRPI4)
add_definitions(-marm -march=armv8-a+crc -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard)
set(CMAKE_ASM_FLAGS "-marm -march=armv8-a+crc -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard")
elseif(RPI3ARM64)
add_definitions(-DRPI)
add_definitions(-DRPI3ARM64)
add_definitions(-marm -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard)
set(CMAKE_ASM_FLAGS "-marm -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard")
elseif(RPI4ARM64)
add_definitions(-DRPI)
add_definitions(-DRPI4ARM64)
@@ -146,15 +133,6 @@ elseif(RK3399)
add_definitions(-DRK3399)
add_definitions(-pipe -march=armv8-a+crc+simd+crypto -mcpu=cortex-a72+crypto -mfpu=neon-fp-armv8 -mfloat-abi=hard)
set(CMAKE_ASM_FLAGS "-pipe -march=armv8-a+crc+simd+crypto -mcpu=cortex-a72+crypto -mfpu=neon-fp-armv8 -mfloat-abi=hard")
elseif(RK3588)
add_definitions(-DRK3588)
add_definitions(-pipe -mcpu=cortex-a76.cortex-a55+crypto -mfpu=neon-fp-armv8 -mfloat-abi=hard)
add_definitions(-DBAD_SIGNAL)
set(CMAKE_ASM_FLAGS "-pipe -mcpu=cortex-a76.cortex-a55+crypto -mfpu=neon-fp-armv8 -mfloat-abi=hard")
elseif(ARM64)
add_definitions(-DARM64)
add_definitions(-pipe -march=armv8-a+crc+simd+crypto -mfpu=neon-fp-armv8 -mfloat-abi=hard)
set(CMAKE_ASM_FLAGS "-pipe -march=armv8-a+crc+simd+crypto -mfpu=neon-fp-armv8 -mfloat-abi=hard")
elseif(ODROIDN2)
add_definitions(-DODROIDN2)
add_definitions(-pipe -march=armv8-a+crc+simd+crypto -mcpu=cortex-a73.cortex-a53+crypto -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard)
@@ -182,10 +160,6 @@ elseif(ARM_DYNAREC)
set(CMAKE_ASM_FLAGS "-pipe -march=armv7-a+simd -mfpu=neon")
endif()
if(BAD_SIGNAL)
add_definitions(-DBAD_SIGNAL)
endif()
if(POWER9)
add_definitions(-mcpu=power9 -mtune=power9)
endif()
@@ -286,7 +260,6 @@ set(ELFLOADER_SRC
"${BOX86_ROOT}/src/tools/box86stack.c"
"${BOX86_ROOT}/src/tools/my_cpuid.c"
"${BOX86_ROOT}/src/tools/gtkclass.c"
"${BOX86_ROOT}/src/tools/rcfile.c"
"${BOX86_ROOT}/src/tools/wine_tools.c"
"${BOX86_ROOT}/src/elfs/elfloader.c"
"${BOX86_ROOT}/src/elfs/elfparser.c"
@@ -354,7 +327,6 @@ set(WRAPPEDS
"${BOX86_ROOT}/src/wrapped/wrappedpng16.c"
"${BOX86_ROOT}/src/wrapped/wrappedlibxxf86vm.c"
"${BOX86_ROOT}/src/wrapped/wrappedlibxrandr.c"
"${BOX86_ROOT}/src/wrapped/wrappedlibxpresent.c"
"${BOX86_ROOT}/src/wrapped/wrappedlibxext.c"
"${BOX86_ROOT}/src/wrapped/wrappedxinerama.c"
"${BOX86_ROOT}/src/wrapped/wrappedlibxfixes.c"
@@ -436,7 +408,6 @@ set(WRAPPEDS
"${BOX86_ROOT}/src/wrapped/wrappedgsttag.c"
"${BOX86_ROOT}/src/wrapped/wrappedgstbase.c"
"${BOX86_ROOT}/src/wrapped/wrappedgstapp.c"
"${BOX86_ROOT}/src/wrapped/wrappedlibibus.c"
"${BOX86_ROOT}/src/wrapped/wrappeddbusmenugtk.c"
"${BOX86_ROOT}/src/wrapped/wrappeddbusmenuglib.c"
"${BOX86_ROOT}/src/wrapped/wrappedappindicator.c"
@@ -447,7 +418,6 @@ set(WRAPPEDS
"${BOX86_ROOT}/src/wrapped/wrappedpangocairo.c"
"${BOX86_ROOT}/src/wrapped/wrappedgthread2.c"
"${BOX86_ROOT}/src/wrapped/wrappedcairo.c"
"${BOX86_ROOT}/src/wrapped/wrappedcairogobject.c"
"${BOX86_ROOT}/src/wrapped/wrappedpango.c"
"${BOX86_ROOT}/src/wrapped/wrappeddbusglib1.c"
"${BOX86_ROOT}/src/wrapped/wrappedgudev1.c"
@@ -546,6 +516,7 @@ if(ARM_DYNAREC)
"${BOX86_ROOT}/src/dynarec/dynarec_arm.c"
"${BOX86_ROOT}/src/dynarec/dynarec_arm_functions.c"
"${BOX86_ROOT}/src/dynarec/arm_printer.c"
"${BOX86_ROOT}/src/dynarec/arm_jmpnext.c"
"${BOX86_ROOT}/src/dynarec/arm_prolog.S"
"${BOX86_ROOT}/src/dynarec/arm_epilog.S"
@@ -685,7 +656,6 @@ if(NOT _x86 AND NOT _x86_64)
install(FILES ${CMAKE_SOURCE_DIR}/x86lib/libstdc++.so.5 DESTINATION /usr/lib/i386-linux-gnu/)
install(FILES ${CMAKE_SOURCE_DIR}/x86lib/libgcc_s.so.1 DESTINATION /usr/lib/i386-linux-gnu/)
install(FILES ${CMAKE_SOURCE_DIR}/x86lib/libpng12.so.0 DESTINATION /usr/lib/i386-linux-gnu/)
install(FILES ${CMAKE_SOURCE_DIR}/system/box86.box86rc DESTINATION /etc/)
endif()
if(NOT TARGET uninstall)
@@ -815,7 +785,7 @@ add_test(NAME sse COMMAND ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/$
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref17.txt
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
set_tests_properties(sse PROPERTIES ENVIRONMENT "BOX86_DYNAREC_FASTNAN=0;BOX86_DYNAREC_FASTROUND=0")
set_tests_properties(sse PROPERTIES ENVIRONMENT "BOX86_DYNAREC_FASTNAN=0")
add_test(NAME longjumpInSignals COMMAND ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test18 -D TEST_OUTPUT=tmpfile18.txt
@@ -841,11 +811,4 @@ foreach(file ${extension_tests})
-P ${CMAKE_SOURCE_DIR}/runTest.cmake)
endforeach()
add_test(NAME sse_optimized COMMAND ${CMAKE_COMMAND} -D TEST_PROGRAM=${CMAKE_BINARY_DIR}/${BOX86}
-D TEST_ARGS=${CMAKE_SOURCE_DIR}/tests/test17_o2 -D TEST_OUTPUT=tmpfile17_o2.txt
-D TEST_REFERENCE=${CMAKE_SOURCE_DIR}/tests/ref17_o2.txt
-P ${CMAKE_SOURCE_DIR}/runTest.cmake )
set_tests_properties(sse_optimized PROPERTIES ENVIRONMENT "BOX86_DYNAREC_FASTNAN=0;BOX86_DYNAREC_FASTROUND=0")
endif(BOX86LIB)
-61
View File
@@ -1,64 +1,3 @@
box86 (0.3.0) unstable; urgency=low
* Added rcfile handling: box86 now read "/etc/box86.box86rc" and "~/.box86rc" and apply per process parameters
* Added BOX86_DYNAREC_FORWARD to allow bigger Dynarec block to be build
* Refactored Strong Memory Model emulation (faster and more accurate)
* Box86 now return a custom name for the CPU instal of P4, build with Box86 and the cpu name it's running on
* Improved memory protection tracking and signal handling, again
* More wrapped libs (especially on the gtk familly)
* More wrapped functions
* Added support for CreateDeviceEx in d3dadapter9, for better gallium nine support
* Improved dladdr/dladdr1 wrapped function
* Some fixes to flags handling in the Dynarec on some special cases
* Added specific suppport for RK3588 board (needed some hack in signal handling, probably due to the use of a non mainlined kernel)
* Lots of improvment in the Rounding of float & double (Dynarec and Interpretor), and proper handling of denormals when converting to/from 80 bits long double
* Added specific suppport for RK3588 board (needed some hack in signal handling, probably due to the use of a non mainlined kernel)
-- Sebastien Chevalier <[email protected]> Thu, 10 Mar 2023 10:20:33 -0500
box86 (0.2.8) unstable; urgency=low
* Wrapped more Vulkan functions, dxvk2.0 now works
* Added support for overridden malloc/free functions
* Improved elf loader
* Improved dlsym handling with RTLD_NEXT
* Added BOX86_DYNAREC_SAFEFLAGS to allow finetuning Dynarec generated code handling of flags accross function calls and returns.
* Added BOX86_BASH to setup x86 bash binary, so shell script can be run in x86 world
* Added BOX86_ROLLING_LOG to have details log only on crash
* Improved TLS Size handling (Unity3D games now works)
* Improved execv family of function to have better box86 integration
* Added a few more wrapped libs, like FAudio
* Improved gtk, SDL2, GL, vulkan (and more) wrapping
* Improved Signal Handling and memory protection traking
* Added some basic support for statically linked program. Thread are not working yet, but memory allocation and file access does.
* add LX2160A config by @lizthegrey in #612
* Grammar and formatting COMPILE.md by @Radiicall in #615
* Update README.md by @everypizza1 in #617
* docs: add instructions for Debian-based Linux by @ryanfortner in #622
* Fix typoes in readme by @ryanfortner in #621
* Various improvements to install_steam.sh by @ryanfortner in #620
* docs: remove unnecessary newline by @ryanfortner in #624
* fix: the first parameter of realpath may be null by @ye-yeshun in #630
* Add 6 wrapped function to libdrm, and 2 to libexpat. by @cjy880927 in #632
* Fix #610 by @rajdakin in #634
* some floating point instructions by @ye-yeshun in #637
* Fix Typo in readme x86_64 -> x86 by @Jai-JAP in #642
* Fix grammar by @Jai-JAP in #645
* Test wine preload by @ptitSeb in #649
* Align address when call mprotect by @wannacu in #651
* Added 66 0F 7D HSUBPD opcode by @wannacu in #652
* add TEGRAX1 and TEGRAX1ARM32 targets on ubuntu-18.04 by @theofficialgman in #654
* automatically install 32 bit libraries if 64 bit OS is detected in install_steam.sh by @Moldytzu in #659
* mention gcc-arm-linux-gnueabihf in compile.md by @Moldytzu in #660
* Add libc6:armhf install to RPi4 aarch64 build info by @WheezyE in #685
* Updated wine install for RPiOS bullseye 32/64bit by @WheezyE in #689
* Add atomic add opcodes by @Trass3r in #695
* steam: disable modern login and pass arguments to client by @Moldytzu in #700
* Modify sizeof(instsize_t) to 1 byte by @liuli0217 in #721
* Add MOV GS:od, AL by @liuli0217 in #722
-- Sebastien Chevalier <[email protected]> Thu, 17 Nov 2022 11:20:33 -0500
box86 (0.2.6) unstable; urgency=low
* Added an option to get generated -NAN on SSE2 operation
-37
View File
@@ -1,40 +1,3 @@
v0.3.0
======
* Added rcfile handling: box86 now read `/etc/box86.box86rc` and `~/.box86rc` and apply per process parameters
=> Every program can be finetuned, for speed or just to make them work
* Added BOX86_DYNAREC_FORWARD to allow bigger Dynarec block to be build
* Refactored Strong Memory Model emulation (faster and more accurate)
* Box86 now return a custom name for the CPU instal of P4, build with Box86 and the cpu name it's running on
* Improved memory protection tracking and signal handling, again
* More wrapped libs (especially on the gtk familly)
* More wrapped functions
* Added support for CreateDeviceEx in d3dadapter9, for better gallium nine support
* Improved dladdr/dladdr1 wrapped function
* Some fixes to flags handling in the Dynarec on some special cases
* Added specific suppport for RK3588 board (needed some hack in signal handling, probably due to the use of a non mainlined kernel)
* Lots of improvment in the Rounding of float & double (Dynarec and Interpretor), and proper handling of denormals when converting to/from 80 bits long double
* Added specific suppport for RK3588 board (needed some hack in signal handling, probably due to the use of a non mainlined kernel)
v0.2.8
======
* Wrapped more vulkan function, dxvk 2.0 now works
* Added support for overriden malloc/free functions
* Improved elf loader
* Improved dlsym handling with RTLD_NEXT
* Added BOX86_DYNAREC_SAFEFLAGS to allow finetuning Dynarec generated code handling of flags accross function calls and returns.
* Added BOX86_BASH to setup x86 bash binary, so shell script can be run in x86 world
* Added BOX86_ROLLING_LOG to have details log only on crash
* Improved TLS Size handling (Unity3D games now works)
* Improved `execv` family of function to have better box86 integration
* Added a few more wrapped libs, like FAudio
* Improved gtk, SDL2, GL, vulkan (and more) wrapping
* Improved Signal Handling and memory protection traking
* Added some basic support for statically linked program. Thread are not working yet, but memory allocation and file access does.
=> with the use of the new SafeFlags, some C# Windows program now runs fine (it's forced when the Vara family of software is detected)
=> With the basic support of statcaly linked program, old emulator like modeler for linux works. Program with threads like mugen for linux still doesn't
=> The bash integration is usefull for device with no binfmt integration or for script that check the machine it's running on
v0.2.6
======
* Added an option to get generated -NAN on SSE2 operation
+1 -32
View File
@@ -10,8 +10,6 @@ wget -qO- https://itai-nelken.github.io/weekly-box86-debs/debian/KEY.gpg | sudo
sudo apt update && sudo apt install box86 -y
```
**Note:** On a 64bit OS, install the `box86:armhf` package.
Alternatively, you can generate your own package using the [instructions below](https://github.com/ptitSeb/box86/blob/master/docs/COMPILE.md#debian-packaging).
#### for Pandora
@@ -54,7 +52,7 @@ _Build box86:armhf on RPiOS 64-bit ARM (aarch64)_
sudo apt install gcc-arm-linux-gnueabihf # building 32-bit ARM code on aarch64 requires this armhf gcc cross-compiler toolchain
git clone https://github.com/ptitSeb/box86
cd box86
mkdir build; cd build; cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo # -DRPI4ARM64=1 for Pi4 aarch64 (use `-DRPI3ARM64=1` for a PI3 model)
mkdir build; cd build; cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo # -DRPI4ARM64=1 for Pi4 aarch64 (use `-DRPI2ARM64=1` etc for other models)
make -j2
sudo make install
sudo systemctl restart systemd-binfmt
@@ -72,22 +70,6 @@ As most RK3399 devices run an AARCH64 OS, you'll need an `armhf` multiarch envir
Also, on armbian, you may need to install `libc6-dev-armhf-cross` or you may have an issue with `crt1.o` and a few other files not included with box86.
#### for RK3588 / RK3588S
`mkdir build; cd build; cmake .. -DRK3588=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo; make -j4`
As most RK3588 devices run an AARCH64 OS, you'll need an `armhf` multiarch environment, and an armhf gcc: On debian, install it with `sudo apt install gcc-arm-linux-gnueabihf`.
Also, on armbian, you may need to install `libc6-dev-armhf-cross` or you may have an issue with `crt1.o` and a few other files not included with box86.
#### for ODROID N2/N2+
`mkdir build; cd build; cmake .. -DODROIDN2=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo; make -j3`
As most ODROID N2/N2+ devices run an AARCH64 OS, you'll need an `armhf` multiarch environment, and an armhf gcc: On debian, install it with `sudo apt install gcc-arm-linux-gnueabihf`.
Also, on armbian, you may need to install `libc6-dev-armhf-cross` or you may have an issue with `crt1.o` and a few other files not included with box86.
#### for Tinker Board (1/1S) or RK3288
`mkdir build; cd build; cmake .. -DRK3288=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo; make -j3`
@@ -112,25 +94,12 @@ As most Snapdragon 845 devices run an AARCH64 OS, you'll need an `armhf` multiar
As most Phytium (D2000 or FT2000/4) devices run an AARCH64 OS, you'll need an `armhf` multiarch environment, and an armhf gcc: On debian, install it with `sudo apt install gcc-arm-linux-gnueabihf`.
Also, on armbian, you may need to install `libc6-dev-armhf-cross` or you may have an issue with `crt1.o` and a few other files not included with box86.
#### for Other ARM64 64bits Linux platform
`mkdir build; cd build; cmake .. -DARM64 -DCMAKE_BUILD_TYPE=RelWithDebInfo; make -j3`
You can also add `-DBAD_SIGNAL=ON` to the cmake command if you are on Linux Kernel mixed with Android, like on RK3588 or maybe Termux
You'll need an `armhf` multiarch environment, and an armhf gcc: On debian, install it with `sudo apt install gcc-arm-linux-gnueabihf`.
Also, on armbian, you may need to install `libc6-dev-armhf-cross` or you may have an issue with `crt1.o` and a few other files not included with box86.
#### for Other ARM Linux platforms
`mkdir build; cd build; cmake .. -DARM_DYNAREC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo; make -j3`
You can also add `-DBAD_SIGNAL=ON` to the cmake command if you are on Linux Kernel mixed with Android, like on RK3588 or maybe Termux
#### for x86 Linux
`mkdir build; cd build; cmake .. -DCMAKE_C_FLAGS="-m32" -DLD80BITS=1 -DNOALIGN=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo; make -j3`
+15 -27
View File
@@ -12,13 +12,13 @@ Box86 lets you run x86 Linux programs (such as games) on non-x86 Linux systems,
You *NEED* a 32-bit subsystem to run and build Box86. Box86 is useless on 64-bit only systems. Also, you *NEED* a 32-bit toolchain to build Box86. A toolchain that only supports 64-bit will not compile Box86, and you'll get errors (typically on aarch64, you get "-marm" not recognized, and you'll need a multiarch or chroot environment).
Because Box86 uses the native versions of some "system" libraries, like libc, libm, SDL, and OpenGL, it's easy to integrate and use with most applications, and performance can be surprisingly high in many cases. Take a look at those bench analysis for an example [here](https://box86.org/index.php/2021/06/game-performances/). That also means that you will need a 32bits userspace on 64bits OS, like `armhf` on top an `aarch64` 64bits OS.
Because Box86 uses the native versions of some "system" libraries, like libc, libm, SDL, and OpenGL, it's easy to integrate and use with most applications, and performance can be surprisingly high in many cases. Take a look at those bench analysis for an example [here](https://box86.org/index.php/2021/06/game-performances/).
Most x86 Games need OpenGL, so on ARM platforms a solution like [gl4es](https://github.com/ptitSeb/gl4es) might be necessary. (Some ARM platforms only support OpenGL ES and/or their OpenGL implementation is dodgy. (see OpenGL on Android))
Most x86 Games need OpenGL, so on ARM platforms a solution like [gl4es](https://github.com/ptitSeb/gl4es) is usually necessary. (Most ARM platforms only support OpenGL ES and/or their OpenGL implementation is dodgy (see OpenGL on Android).)
Box86 now integrates a DynaRec (dynamic recompiler) for the ARM platform, providing a speed boost between 5 to 10 times faster than only using the interpreter. Some high level information on how the Dynarec work can be found [here](https://box86.org/2021/07/inner-workings-a-high%e2%80%91level-view-of-box86-and-a-low%e2%80%91level-view-of-the-dynarec/).
Many games just work without much tweaking, for example: WorldOfGoo, Airline Tycoon Deluxe, and FTL. Many of the GameMaker Linux games also run fine. (there's a long list, among them are UNDERTALE, A Risk of Rain, and Cook Serve Delicious). Unity3D games also works fine, but the OpenGL requirement might be an issue on some ARM platforms.
Many games already work without much tweaking, for example: WorldOfGoo, Airline Tycoon Deluxe, and FTL. Many of the GameMaker Linux games also run fine. (there's a long list, among them are UNDERTALE, A Risk of Rain, and Cook Serve Delicious)
If you are serious about developing Box86, you should install ccache and build Box86 with it. (Use ccmake for example.)
To enable TRACE (i.e. dumping to stdout all individual x86 instructions executed, with dump of registers), you'll also need [Zydis library](https://github.com/zyantific/zydis) available on your system.
@@ -56,7 +56,7 @@ There are a few environment variables to control the behaviour of Box86.
See [here](USAGE.md) for all environment variables and what they do.
Note: Box86's Dynarec uses a mechanism with Memory Protection and a SegFault signal handler to handle JIT code. In simpler terms, if you want to use GDB to debug a running program that use JIT'd code (like mono/Unity3D), you will still have many "normal" segfaults triggering. It is suggested to use something like `handle SIGSEGV nostop` in GDB to not stop at each segfault, and maybe put a breakpoint inside `my_box86signalhandler` in `signals.c` if you want to trap SegFaults.
Note: Box86's Dynarec uses a mechanism with Memory Protection and a SegFault signal handler to handle JIT code. In simpler terms, if you want to use GDB to debug a running program that use JIT'd code (like mono/Unity3D), you will still have many "normal" segfaults triggering. It is suggested to use something like `handle SIGSEGV nostop` in GDB to not stop at each segfault, and maybe put a breakpoint inside `my_memprotectionhandler` in `signals.c` if you want to trap SegFaults.
----
@@ -76,40 +76,28 @@ If you look at a 64bits version of box86, look at [Box64](https://github.com/pti
----
Notes about Box86 configuration
----
Box86 now have configurations files. There are 2 files loaded. `/etc/box4.box86rc` and `~/.box86rc`. Both files have the same syntax, and is basicaly an ini files. Section in square brakets define the process name, and the rest is the env. var. to set. Looke at [Usage](USAGE.md) for detail on what parameters can be put. Box86 comes with a default file that should be installed for better stability. The file in in `system/box86.box86rc` and should be installed to `/etc/box86.box86rc` If, for some reasons, you don't want to install that file here, at least copy it to `~/.box86rc` or some game may not function correctly.
Note that the priority is: `~/.bashrc` > `/etc/box86.box86rc` > command line
So, your settings in `~/.bashrc` may override the setting from your command line...
----
Notes about Unity game emulation
----
Running Unity games shoudl generaly work now, but you should also note that many Unity3D games require OpenGL 3+ which can be tricky to provide on ARM SBC (single-board computers) for now.
Hint: on Pi4, use `MESA_GL_VERSION_OVERRIDE=3.2` and with Panfrost use `PAN_MESA_DEBUG=gl3` to use higher profile if the game starts then quits before showing anything.
Running Unity games is a hit or miss for now. Unity uses Mono (which uses signals that are not well emulated enough), and a runtime embedded in the main binary. A solution would be to use a native version of the libmono library used by Unity (it can be found here: https://github.com/Unity-Technologies/mono and needs to be built from source). But the wrapping of this lib is tricky, and not done for now, so the only solution is to emulate everything. The tricky part is to emulate the "JIT" code emitted by Mono, however with the new "protected memory" mechanism implemented it should be running with correct performance now.
You should also note that some Unity3D games require OpenGL 3+ which can be tricky to provide on ARM SBC (single-board computers) for now.
TL;DR: Not all Unity games work and can require a high OpenGL profile, but the speed, for the ones running, should be correct now.
----
Notes about Steam
----
Linux Steam's can run now with box86. but you also need box64 for it to completly usable.
It is advised to run steam in the Small mode, as it use the less memory, but steamwebhelper (a 64bits process) will still be loaded even if not used.
The login screen cannot run without steamwebhelper, and will just show a blank windows without box64 properly setup in the system.
File note, Steam will use a lot of memory, and barely fit on system with 4GB of RAM. It will not work anymore on system with less memory (as a workaround, create a swap file, login and check "remember me", the use box64rc to disable steamwebhelper and run only in small mode without swap after the 1st login)
Final note: the Steam BigPicture will work, but also need steamwebhelper (and so box64), and lots of memory. It will not start on system with only 4GB of RAM without swap.
Linux Steam's can run now with box86. But it's still a bit unstable, and not everything works:
- First problem is Steam crashing after the sign-in window, if you encounter this issue, you may need to add libappindicator. To install it on Debian, run `sudo apt install libappindicator1`.
- If you select to "Remember password", Steam is crashing on subsequent starts, unless you have libnm installed. To install it on Debian, run `sudo apt install libnm0`.
- If you have trouble installing Steam, you can find `install_steam.sh` in the root folder of the box86 repo. This simple script will download and install steam in your home folder, and then create a shortcut to steam in `/usr/local/bin` (and for this it will ask for sudo permission). Simply use `steam` to launch once it's installed. Note that the installation, being in the Home folder, will only work for a single user. Don't use this script if you need a multi-user installation.
- Once open, Steam will only work on "Small Mode" and in "Big Picture", not in the regular "Large Mode". This is because some Steam components used in the browser view are only 64-bit now. So go in the "View" menu and switch to "Small view", else the list will stay empty. Alternatively, Steam can be started in small mode directly by using `+open steam://open/minigameslist` command line arguments.
- To avoid the "libc.so.6 is absent" message, you can use `STEAMOS=1` and `STEAM_RUNTIME=1` as environment variables (it's automatically there if you used the `install_steam.sh` script)
- Some Steam games (most Source engine games, like "Portal" or "Half-Life 2") use libtcmalloc. Box86 will detect it and will try to LD_PRELOAD it, for better compatibility. While it should work without the aforementioned feature, it is safer to add it to your system if you intend to play those games. To install it on Debian, run `sudo apt install libtcmalloc-minimal4`.
to disable `steamwebhelper` when box64 installed and running, create (or edit) `~/.box64rc` and add:
```
[steamwebhelper]
BOX64_EXIT=1
```
in it and it will be disable. Comment with a `#` those 2 lines to enable it again
Steam for Windows installs fine but doesn't work yet.
----
@@ -124,7 +112,7 @@ Note: if you plan to use box86 with Wine on Raspberry Pi 3 or earlier, those mod
Notes about Vulkan
----
Box86 already wrap Vulkan. If your system has a 32bits Vulkan driver, box86 will use it when needed. Profile 1.0, 1.1, 1.2 and 1.3, with some extensions, should be OK. DXVK, including the 2.0, works. I know some demos work on Pi4 (Sascha Willems demos build for x86 work the same as if build on armhf directly). Note that the Vulkan driver of the Pi4 DOES NOT support dxvk for now (wine DirectX->Vulkan wrapper). It's not a box86 issue, it's missing extensions (hardware support) and a few other things that make dxvk not working on pi4. On Panfrost side, PanVK is a bit young and I haven't tested dxvk with it yet.
Box86 already wrap Vulkan. If your system has a 32bits Vulkan driver, box86 will use it when needed. Note that Vulkan wrapping has not been tested much, due to the limited Vulkan support on the hardware I currently own. Profile 1.0 and 1.1, with some extension, should be OK. 1.2 is not really wrapped. I know some demos work on Pi4 (Sascha Willems demos build for x86 work the same as if build on armhf directly). Note that the Vulkan driver of the Pi4 DOES NOT support dxvk for now (wine DirectX->Vulkan wrapper). It's not a box86 issue, it's missing extensions (hardware support) and a few other things that make dxvk not working on pi4. On Panfrost side, PanVK is a bit young and I haven't tested dxvk with it yet.
----
Final word
+44 -85
View File
@@ -3,233 +3,196 @@ Usage
----
There are many environment variables to control Box86 behaviour.
Env. var with * can also be put inside box64rc files
#### BOX86_LOG *
#### BOX86_LOG
Controls the Verbosity level of the logs
* 0: NONE : No message (except some fatal error). (Default.)
* 1: INFO : Show some minimum log (Example: librairies not found)
* 2: DEBUG : Details a lot of stuff (Example: relocations or functions called).
* 3: DUMP : All DEBUG plus DUMP of all ELF Info (so same as `BOX86_LOG=2 BOX86_DUMP=1`)
#### BOX86_DUMP *
#### BOX86_DUMP
Controls the Dump of elf content
* 0: No dump of elf information (Default)
* 1: Dump elf sections and relocations and other information (also active if using `BOX86_LOG=3`)
#### BOX86_ROLLING_LOG *
#### BOX86_ROLLING_LOG
Show last few wrapped function call when a Signal is caught
* 0: No last function call printed (Default.)
* 1: Last 16 wrapped functions calls printed when a signal is printed. Incompatible with BOX86_LOG>1 (may need BOX86_SHOWSEGV=1 also)
* N: Last N wrapped functions calls printed when a signal is printed. Incompatible with BOX86_LOG>1 (may need BOX86_SHOWSEGV=1 also)
* 1: Last few wrapped function call printed when a signal is printed. Incompatible with BOX86_LOG>1 (may need BOX86_SHOWSEGV=1 also)
#### BOX86_NOBANNER
Disables Box86 printing its version and build
* 0 : Enable printing its banner. (Default.)
* 1 : Disable printing its banner.
#### BOX86_LD_LIBRARY_PATH *
#### BOX86_LD_LIBRARY_PATH
Path to look for x86 libraries. Default is current folder and `lib` in current folder.
Also, `/usr/lib/i386-linux-gnu` and `/lib/i386-linux-gnu` are added if they exist.
#### BOX86_PATH *
#### BOX86_PATH
Path to look for x86 executable. Default is current folder and `bin` in current folder.
#### BOX86_DLSYM_ERROR *
#### BOX86_DLSYM_ERROR
Enables/Disables the logging of `dlsym` errors.
* 0 : Don't log `dlsym` errors. (Default.)
* 1 : Log dlsym errors.
#### BOX86_TRACE_FILE *
#### BOX86_TRACE_FILE
Send all log and trace to a file instead of `stdout`
Also, if name contains `%pid` then this is replaced by the actual PID of box86 instance
Use `stderr` to use this instead of default `stdout`
#### BOX86_TRACE *
#### BOX86_TRACE
Only on build with trace enabled. Trace allow the logging of all instruction executed, along with register dump
* 0 : No trace. (Default.)
* 1 : Trace enabled. Trace start after the initialisation of all depending libraries is done.
* symbolname : Trace only `symbolname` (trace is disable if the symbol is not found).
* 0xXXXXXXX-0xYYYYYYY : Trace only between the 2 addresses.
#### BOX86_TRACE_INIT *
#### BOX86_TRACE_INIT
Use BOX86_TRACE_INIT instead of BOX_TRACE to start trace before the initialisation of libraries and the running program
* 0 : No trace. (Default.)
* 1 : Trace enabled. The trace start with the initialisation of all depending libraries is done.
#### BOX86_TRACE_START *
#### BOX86_TRACE_START
Only on builds with trace enabled.
* NNNNNNN : Start trace only after NNNNNNNN opcode execute (number is an `uint64_t`).
#### BOX86_TRACE_XMM *
#### BOX86_TRACE_XMM
Only on builds with trace enabled.
* 0 : The XMM (i.e. SSE/SSE2) register will not be logged with the general and x86 registers. (Default.)
* 1 : Dump the XMM registers.
#### BOX86_TRACE_EMM *
Only on builds with trace enabled.
* 0 : The EMM (i.e. MMX) register will not be logged with the general and x86 registers. (Default.)
* 1 : Dump the EMM registers.
#### BOX86_LOAD_ADDR *
#### BOX86_LOAD_ADDR
Try to load at 0xXXXXXX main binary (if binary is a PIE)
* 0xXXXXXXXX : The load address . (Only active on PIE programs.)
#### BOX86_NOSIGSEGV *
#### BOX86_NOSIGSEGV
Disable handling of SigSEGV. (Very useful for debugging.)
* 0 : Let the x86 program set sighandler for SEGV (Default.)
* 1 : Disable the handling of SigSEGV.
#### BOX86_NOSIGILL *
#### BOX86_NOSIGILL
Disable handling of SigILL (to ease debugging mainly).
* 0 : Let x86 program set sighandler for Illegal Instruction
* 1 : Disables the handling of SigILL
#### BOX86_X11COLOR16 *
#### BOX86_X11COLOR16
PANDORA only: Try converting X11 color from 32 bits to 16 bits (to avoid light green on light cyan windows).
* 0 : Don't touch X11 colors. (Default.)
* 1 : Change colors arguments in XSetForeground, XSetBackground and XCreateGC.
#### BOX86_X11THREADS *
#### BOX86_X11THREADS
Call XInitThreads when loading X11. (This is mostly for old Loki games with the Loki_Compat library.)
* 0 : Don't force call XInitThreads. (Default.)
* 1 : Call XInitThreads as soon as libX11 is loaded.
#### BOX86_X11GLX *
#### BOX86_X11GLX
Force libX11's GLX extension to be present.
* 0 : Do not force libX11's GLX extension to be present.
* 1 : GLX will always be present when using XQueryExtension. (Default.)
#### BOX86_DYNAREC_DUMP *
#### BOX86_DYNAREC_DUMP
Enables/disables Box86's Dynarec's dump.
* 0 : Disable Dynarec's blocks dump. (Default.)
* 1 : Enable Dynarec's blocks dump.
* 2 : Enable Dynarec's blocks dump with some colors.
#### BOX86_DYNAREC_LOG *
#### BOX86_DYNAREC_LOG
Set the level of DynaRec's logs.
* 0 : NONE : No Logs for DynaRec. (Default.)
* 1 :INFO : Minimum Dynarec Logs (only unimplemented OpCode).
* 2 : DEBUG : Debug Logs for Dynarec (with details on block created / executed).
* 3 : VERBOSE : All of the above plus more.
#### BOX86_DYNAREC *
#### BOX86_DYNAREC
Enables/Disables Box86's Dynarec.
* 0 : Disables Dynarec.
* 1 : Enable Dynarec. (Default.)
#### BOX86_DYNAREC_TRACE *
#### BOX86_DYNAREC_TRACE
Enables/Disables trace for generated code.
* 0 : Disable trace for generated code. (Default.)
* 1 : Enable trace for generated code (like regular Trace, this will slow down the program a lot and generate huge logs).
#### BOX86_NODYNAREC *
#### BOX86_NODYNAREC
Forbid dynablock creation in the interval specified (helpfull for debugging behaviour difference between Dynarec and Interpretor)
* 0xXXXXXXXX-0xYYYYYYYY : define the interval where dynablock cannot start (inclusive-exclusive)
#### BOX86_DYNAREC_BIGBLOCK *
#### BOX86_DYNAREC_BIGBLOCK
Enables/Disables Box86's Dynarec building BigBlock.
* 0 : Don't try to build block as big as possible (can help program using lots of thread and a JIT, like C#/Unity) (Default when libmonobdwgc-2.0.so is loaded)
* 1 : Build Dynarec block as big as possible (Default.)
* 2 : Build Dynarec block bigger (don't stop when block overlaps)
#### BOX86_DYNAREC_FORWARD *
Define Box86's Dynarec max allowed forward value when building Block.
* 0 : No forward value. When current block end, don't try to go further even if there are previous forward jumps
* XXX : Allow up to XXXX bytes of gap when building a Block after the block end to next forward jump (Default: 128)
#### BOX86_DYNAREC_STRONGMEM *
#### BOX86_DYNAREC_STRONGMEM
Enable/Disable simulation of Strong Memory model
* 0 : Don't try anything special (Default.)
* 1 : Enable some Memory Barrier when reading from memory (on some MOV opcode) to simulate Strong Memory Model while trying to limit performance impact (Default when libmonobdwgc-2.0.so is loaded)
* 2 : Enable some Memory Barrier when reading from memory (on some MOV opcode) to simulate Strong Memory Model
#### BOX86_DYNAREC_X87DOUBLE *
#### BOX86_DYNAREC_X87DOUBLE
Force the use of Double for x87 emulation
* 0 : Try to use float when possible for x87 emulation (faster, Default)
* 1 : Only use Double for x87 emulation (slower, may be needed for some specific games, like Crysis were it's enable automatically)
#### BOX86_DYNAREC_FASTNAN *
#### BOX86_DYNAREC_FASTNAN
Enable/Disable generation of -NAN
* 0 : Generate -NAN like on x86 (slower, more x86 accurate)
* 1 : Don't do anything special with NAN, to go as fast as possible (Default)
#### BOX86_DYNAREC_FASTROUND *
Enable/Disable generation of precise x86 rounding
* 0 : Generate float/double -> int rounding like on x86
* 1 : Don't do anything special with edge case Rounding, to go as fast as possible (no INF/NAN/Overflow -> MIN_INT conversion) (faster, Default)
#### BOX86_DYNAREC_SAFEFLAGS *
#### BOX86_DYNAREC_SAFEFLAGS
Handling of flags on CALL/RET opcodes
* 0 : Treat CALL/RET as if it never needs any flags (faster but may have side-effects)
* 1 : most of RET will need flags, most of CALLS will not (Default)
* 2 : All CALL/RET will need flags (slower, but might be needed. Automatically enabled for Vara.exe)
#### BOX86_DYNAREC_HOTPAGE *
Handling of HotPage (Page beeing both executed and writen)
* 0 : Don't track hotpage
* 1-255 : Trak HotPage, and disable execution of a page beeing writen for N attempts (default is 16)
#### BOX86_DYNAREC_BLEEDING_EDGE *
Detect MonoBleedingEdge and apply conservative settings
* 0 : Don't detect MonoBleedingEdge
* 1 : Detect MonoBleedingEdge, and apply BIGBLOCK=0 STRONGMEM=1 if detected (Default)
#### BOX86_SSE_FLUSHTO0 *
Handling of SSE Flush to 0 flags
* 0 : Just track the flag (Default)
* 1 : Direct apply of SSE Flush to 0 flag
#### BOX86_X87_NO80BITS *
Handling of x87 80bits long double
* 0 : Try to handle 80bits long double as precise as possible (Default)
* 1 : Handle them as double
#### BOX86_LIBGL *
#### BOX86_LIBGL
* libXXXX set the name for libGL (defaults to libGL.so.1).
* /PATH/TO/libGLXXX : Sets the name and path for libGL
You can also use SDL_VIDEO_GL_DRIVER
#### BOX86_LD_PRELOAD *
#### BOX86_LD_PRELOAD
* XXXX[:YYYYY] force loading XXXX (and YYYY...) libraries with the binary
PreLoaded libs can be emulated or native, and are treated the same way as if they were comming from the binary (not that using this inside a rcfile might not work if the process needs to be renamed, for example for Wine process)
PreLoaded libs can be emulated or native, and are treated the same way as if they were comming from the binary
#### BOX86_EMULATED_LIBS *
#### BOX86_EMULATED_LIBS
* XXXX[:YYYYY] force lib XXXX (and YYYY...) to be emulated (and not wrapped)
Some games uses an old version of some libraries, with an ABI incompatible with native version.
Note that LittleInferno for example is auto detected, and libvorbis.so.0 is automatical added to emulated libs, and same for Don't Starve (and Together / Server variant) that use an old SDL2 too
#### BOX86_ALLOWMISSING_LIBS *
#### BOX86_ALLOWMISSING_LIBS
Allow Box86 to continue even if a library is missing (renamed from BOX86_ALLOWMISSINGLIBS).
* 0 : Box86 will stop if a library cannot be loaded. (Default.)
* 1 : Continue even if a needed library cannot be loaded. Unadvised, this will, in most cases, crash later on.
#### BOX86_ALLOWMISSING_SYMBOLS *
#### BOX86_ALLOWMISSING_SYMBOLS
Allow dlopen with RTLD_NOW flag to not resolve all symbols.
* 0 : Box86 will stop if a library have unresolved symbols. (Default.)
* 1 : Continue even if a needed library have unresolved symbols (like symbols not yet wrapped).
#### BOX86_PREFER_WRAPPED *
#### BOX86_PREFER_WRAPPED
Box86 will use wrapped libs even if the lib is specified with absolute path
* 0 : Try to use emulated libs when they are defined with absolute path (Default.)
* 1 : Use Wrapped native libs even if path is absolute
#### BOX86_PREFER_EMULATED *
#### BOX86_PREFER_EMULATED
Box86 will prefer emulated libs first (execpt for glibc, alsa, pulse, GL, vulkan and X11
* 0 : Native libs are prefered (Default.)
* 1 : Emulated libs are prefered (Default for program running inside pressure-vessel)
#### BOX86_NOPULSE *
#### BOX86_NOPULSE
Disables the load of pulseaudio libraries.
* 0 : Load pulseaudio libraries if found. (Default.)
* 1 : Disables the load of pulse audio libraries (libpulse and libpulse-simple), both the native library and the x86 library
#### BOX86_NOGTK *
#### BOX86_NOGTK
Disables the loading of wrapped GTK libraries.
* 0 : Load wrapped GTK libraries if found. (Default.)
* 1 : Disables loading wrapped GTK libraries.
#### BOX86_NOVULKAN *
#### BOX86_NOVULKAN
Disables the load of vulkan libraries.
* 0 : Load vulkan libraries if found.
* 1 : Disables the load of vulkan libraries, both the native and the i386 version (can be useful on Pi4, where the vulkan driver is not quite there yet.)
@@ -242,22 +205,22 @@ Disables the load of vulkan libraries.
* XXX=yyyy
will add XXX=yyyy env. var. and continue with BOX86_ENV2 ... until var doesn't exist
#### BOX86_FIX_64BIT_INODES *
#### BOX86_FIX_64BIT_INODES
Fix/Don't fix 64bit inodes
* 0 : Don't fix 64bit inodes. (Default.)
* 1 : Fix 64bit inodes. Helps when running on Filesystems with 64bit inodes. Is useful when a program uses API functions which doesn't support it and the program doesn't use inodes information.
#### BOX86_SHOWSEGV *
#### BOX86_SHOWSEGV
Show Segfault signal even if a signal handler is present
* 0 : Don't force segfault details when a signal handler is install (Default, to limit message spamming)
* 1 : Show segfault details
#### BOX86_SHOWBT *
#### BOX86_BACKTRACE
Show a backtrace (native and emulated) on Signal
* 0 : Don't show any backtrace (Default.)
* 1 : Show native backtrace when a signal is dumped (not available on Andoid build)
#### BOX86_BASH *
#### BOX86_BASH
Define x86 bash to launch script
* yyyy
Will use yyyy as x86 bash to launch script. yyyy needs to be a full path to a valid x86 version of bash. Note that is Box64 is available, an x86_64 version of bash can also be used. Also, BOX64_BASH env. var. will also be read if BOX86_BASH is not defined.
@@ -266,8 +229,7 @@ Will use yyyy as x86 bash to launch script. yyyy needs to be a full path to a va
Define where to find box64 binary
* yyyy
Will use yyyy as x86_64 interpretor, to launch x64_64 binaries
#### BOX86_JITGDB *
#### BOX86_JITGDB
* 0 : Just print the Segfault message on segfault (default)
* 1 : Launch `gdb` when a segfault, bus error or illegal instruction signal is trapped, attached to the offending process and go in an endless loop, waiting.
@@ -278,6 +240,3 @@ Will use yyyy as x86_64 interpretor, to launch x64_64 binaries
* 2 : Launch `gdbserver` when a segfault, bus error or illegal instruction signal is trapped, attached to the offending process, and go in an endless loop, waiting.
Use `gdb /PATH/TO/box86` and then `target remote 127.0.0.1:1234` to connect to the gdbserver (or use actual IP if not on the machine). After that, the procedure is the same as with ` BOX86_JITGDB=1`.
This mode can be usefullwhen programs redirect all console output to a file (like Unity3D Games)
#### BOX86_NORCFILES
If the env var exist, no rc files (like /etc/box86.box86rc and ~/.box86rc) will be loaded
+1 -3
View File
@@ -21,7 +21,6 @@ cd ../ && rm -rf ./tmp/
echo "#!/bin/bash
export STEAMOS=1
export STEAM_RUNTIME=1
export DBUS_FATAL_WARNINGS=0
~/steam/bin/steam -noreactlogin steam://open/minigameslist $@" > steam
# make script executable and move
@@ -34,8 +33,7 @@ if [ ${MACHINE_TYPE} == 'aarch64' ] && [ -f '/etc/debian_version' ]; then
echo "Detected 64 bit ARM Debian. Installing 32 bit libraries"
sudo dpkg --add-architecture armhf # enable installation of armhf libraries
sudo apt update # update package lists with the newly added arch
# install the libraries that Steam requires
sudo apt install libc6:armhf libncurses5:armhf libsdl2-2.0-0:armhf libsdl2-image-2.0-0:armhf libsdl2-mixer-2.0-0:armhf libsdl2-ttf-2.0-0:armhf libopenal1:armhf libpng16-16:armhf libfontconfig1:armhf libxcomposite1:armhf libbz2-1.0:armhf libxtst6:armhf
sudo apt install libc6:armhf libncurses5:armhf libsdl2*:armhf libopenal*:armhf libpng*:armhf libfontconfig*:armhf libXcomposite*:armhf libbz2-dev:armhf libXtst*:armhf # install the libraries that Steam requires
echo "Don't forget to compile/install Box64!"
fi
+1 -1
View File
@@ -1249,7 +1249,7 @@ def generate_files(root: str, files: Iterable[str], ver: str, gbls: SortedGlobal
f.write("void {0}(x86emu_t *emu, uintptr_t fcn) {2} {1} fn = ({1})fcn; ".format(N.orig, W, "{"))
if N.orig == 'vFv':
f.write("(void)emu; ")
f.write("(void)fcn; ")
args = N.orig[2:]
if args == 'Ev': args = 'E'
+22 -55
View File
@@ -22,7 +22,6 @@
#include <sys/mman.h>
#include "custommem.h"
#include "dictionnary.h"
#include "rcfile.h"
#ifdef DYNAREC
#include "dynablock.h"
#include "dynarec/arm_lock_helper.h"
@@ -49,7 +48,6 @@ void finiAllHelpers(box86context_t* context)
static int finied = 0;
if(finied)
return;
DeleteParams();
fini_pthread_helper(context);
fini_signal_helper();
fini_bridge_helper();
@@ -84,20 +82,11 @@ int unlockMutex()
{
int ret = unlockCustommemMutex();
int i;
#ifdef DYNAREC
void* tid = (void*)GetTID();
#define GO(A, B) \
i = (arm_lock_storeifref2(&A, NULL, tid)==tid); \
if(i) { \
ret|=(1<<B); \
}
#else
#define GO(A, B) \
i = checkUnlockMutex(&A); \
if(i) { \
ret|=(1<<B); \
}
#endif
GO(my_context->mutex_once, 5)
GO(my_context->mutex_once2, 6)
@@ -111,6 +100,7 @@ int unlockMutex()
GO(my_context->mutex_thread, 10)
GO(my_context->mutex_bridge, 11)
#undef GO
return ret;
}
@@ -118,7 +108,7 @@ void relockMutex(int locks)
{
#define GO(A, B) \
if(locks&(1<<B)) \
mutex_lock(&A); \
pthread_mutex_lock(&A); \
GO(my_context->mutex_once, 5)
GO(my_context->mutex_once2, 6)
@@ -137,29 +127,22 @@ void relockMutex(int locks)
static void init_mutexes(box86context_t* context)
{
#ifdef DYNAREC
arm_lock_stored(&context->mutex_dyndump, 0);
arm_lock_stored(&context->mutex_once, 0);
arm_lock_stored(&context->mutex_once2, 0);
arm_lock_stored(&context->mutex_trace, 0);
arm_lock_stored(&context->mutex_tls, 0);
arm_lock_stored(&context->mutex_thread, 0);
arm_lock_stored(&context->mutex_bridge, 0);
#else
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
pthread_mutex_init(&context->mutex_once, &attr);
pthread_mutex_init(&context->mutex_once2, &attr);
pthread_mutex_init(&context->mutex_trace, &attr);
#ifdef DYNAREC
pthread_mutex_init(&context->mutex_dyndump, &attr);
#else
pthread_mutex_init(&context->mutex_lock, &attr);
#endif
pthread_mutex_init(&context->mutex_tls, &attr);
pthread_mutex_init(&context->mutex_thread, &attr);
pthread_mutex_init(&context->mutex_bridge, &attr);
pthread_mutex_init(&context->mutex_lock, &attr);
pthread_mutexattr_destroy(&attr);
#endif
}
static void atfork_child_box64context(void)
@@ -168,31 +151,6 @@ static void atfork_child_box64context(void)
init_mutexes(my_context);
}
void freeCycleLog(box86context_t* ctx)
{
if(cycle_log) {
for(int i=0; i<cycle_log; ++i) {
box_free(ctx->log_call[i]);
box_free(ctx->log_ret[i]);
}
box_free(ctx->log_call);
box_free(ctx->log_ret);
ctx->log_call = NULL;
ctx->log_ret = NULL;
}
}
void initCycleLog(box86context_t* context)
{
if(cycle_log) {
context->log_call = (char**)box_calloc(cycle_log, sizeof(char*));
context->log_ret = (char**)box_calloc(cycle_log, sizeof(char*));
for(int i=0; i<cycle_log; ++i) {
context->log_call[i] = (char*)box_calloc(256, 1);
context->log_ret[i] = (char*)box_calloc(128, 1);
}
}
}
EXPORTDYN
box86context_t *NewBox86Context(int argc)
{
@@ -205,8 +163,11 @@ box86context_t *NewBox86Context(int argc)
// init and put default values
box86context_t *context = my_context = (box86context_t*)box_calloc(1, sizeof(box86context_t));
initCycleLog(context);
if(cycle_log)
for(int i=0; i<CYCLE_LOG; ++i) {
context->log_call[i] = (char*)box_calloc(256, 1);
context->log_ret[i] = (char*)box_calloc(128, 1);
}
#ifdef BUILD_LIB
context->deferedInit = 0;
#else
@@ -359,17 +320,23 @@ void FreeBox86Context(box86context_t** context)
finiAllHelpers(ctx);
#ifndef DYNAREC
pthread_mutex_destroy(&ctx->mutex_once);
pthread_mutex_destroy(&ctx->mutex_once2);
pthread_mutex_destroy(&ctx->mutex_trace);
#ifdef DYNAREC
pthread_mutex_destroy(&ctx->mutex_dyndump);
#else
pthread_mutex_destroy(&ctx->mutex_lock);
#endif
pthread_mutex_destroy(&ctx->mutex_tls);
pthread_mutex_destroy(&ctx->mutex_thread);
pthread_mutex_destroy(&ctx->mutex_bridge);
pthread_mutex_destroy(&ctx->mutex_lock);
#endif
freeCycleLog(ctx);
if(cycle_log)
for(int i=0; i<CYCLE_LOG; ++i) {
box_free(ctx->log_call[i]);
box_free(ctx->log_ret[i]);
}
box_free(ctx);
}
+2 -2
View File
@@ -2,7 +2,7 @@
#define __BOX86_VERSION_H_
#define BOX86_MAJOR 0
#define BOX86_MINOR 3
#define BOX86_REVISION 0
#define BOX86_MINOR 2
#define BOX86_REVISION 7
#endif //__BOX86_VERSION_H_
+292 -317
View File
File diff suppressed because it is too large. Load diff
+2 -4
View File
@@ -391,6 +391,8 @@ Op is 20-27
// ldrd reg, reg+1, [addr, +rm], reg must be even, reg+1 is implicit
#define LDRD_REG(reg, addr, rm) EMIT(c__ | 0b000<<25 | 1<<24 | 1<<23 | 0<<22 | 0<<21 | 0<<20 | ((reg) << 12) | ((addr) << 16) | 0b1101<<4 | (rm) )
#define LDR_litteral(reg, imm12) EMIT(c__ | 0b010<<25 | 0<<24 | ((imm12<0)?0:1)<<23 | 0<<22 | 0<<21 | 1<<20 | 0b1111<<16 | (reg)<<12 | (abs(imm12)))
// str reg, [addr, #+/-imm9]
#define STR_IMM9(reg, addr, imm9) EMIT(0xe5000000 | (((imm9)<0)?0:1)<<23 | ((reg) << 12) | ((addr) << 16) | brIMM(imm9) )
// str with cond reg, [addr, #+/-imm9]
@@ -820,8 +822,6 @@ Op is 20-27
#define VLD1_32(Dd, Rn) EMIT(Vxx1gen(1, ((Dd)>>4)&1, Rn, ((Dd)&0x0f), 0b0111, 2, 0, 15))
// Load [Rn]! => Dd. Align is 4
#define VLD1_32_W(Dd, Rn) EMIT(Vxx1gen(1, ((Dd)>>4)&1, Rn, ((Dd)&0x0f), 0b0111, 2, 0, 13))
// Load [Rn]! => Dd. Align is 8
#define VLD1_64_W(Dd, Rn) EMIT(Vxx1gen(1, ((Dd)>>4)&1, Rn, ((Dd)&0x0f), 0b0111, 3, 0, 13))
// Load [Rn]! => Dd/Dd+1. Align is 4
#define VLD1Q_32_W(Dd, Rn) EMIT(Vxx1gen(1, ((Dd)>>4)&1, Rn, ((Dd)&0x0f), 0b1010, 2, 0, 13))
// Load [Rn, Rm]! => Dd/Dd+1. If Rm==15, no writeback, Rm ignored, else writeback Rn <- Rn+Rm. Align is 4
@@ -843,8 +843,6 @@ Op is 20-27
// Store [Rn]! => Dd. Align is 4
#define VST1_32_W(Dd, Rn) EMIT(Vxx1gen(0, ((Dd)>>4)&1, Rn, ((Dd)&0x0f), 0b0111, 2, 0, 13))
// Store [Rn]! => Dd. Align is 8
#define VST1_64_W(Dd, Rn) EMIT(Vxx1gen(0, ((Dd)>>4)&1, Rn, ((Dd)&0x0f), 0b0111, 3, 0, 13))
// Store [Rn] => Dd/Dd+1. Align is 4
#define VST1Q_32(Dd, Rn) EMIT(Vxx1gen(0, ((Dd)>>4)&1, Rn, ((Dd)&0x0f), 0b1010, 2, 0, 15))
// Store [Rn]! => Dd/Dd+1. Align is 4
+12
View File
@@ -0,0 +1,12 @@
#include <stdint.h>
#include <stdlib.h>
#include "arm_emitter.h"
#define EMIT(A) *block = (A); ++block
void CreateJmpNextTo(void* addr, void* tonext)
{
uint32_t* block = (uint32_t*)addr;
MOV32(x3, (uintptr_t)tonext);
BX(x3);
}
+40 -83
View File
@@ -16,14 +16,12 @@
.global arm_lock_xchg
.global arm_lock_storeifnull
.global arm_lock_storeifref
.global arm_lock_storeifref2
.global arm_lock_decifnot0b
.global arm_lock_incb
.global arm_lock_incif0b
.global arm_lock_stored
.global arm_lock_storeb
.global arm_lock_storeif0b
.global arm_lock_readb
.global arm_lock_store_xchg
.global arm_lock_dec
.global arm_lock_dec_b
.global arm_lock_store
.global arm_lock_store_b
arm_lock_read_b:
// address is r0, return is r0
@@ -90,117 +88,76 @@ arm_lock_xchg:
bx lr
arm_lock_storeifnull:
// address is r0, value is r1, r1 store to r0 only if [r0] is 0. return old [r0] value
// address is r0, value is r1, r1 store to r0 only if [r0] is 0. return new [r0] value (so r1 or old value)
// r0 needs to be aligned
dmb ish
ldrex r2, [r0]
cmp r2, #0
bne arm_lock_storeifnull_exit
strex r3, r1, [r0]
mov r2, r1
strex r3, r2, [r0]
cmp r3, #1
beq arm_lock_storeifnull
arm_lock_storeifnull_exit:
mov r0, r2
bx lr
arm_lock_storeifref2:
dmb ish
arm_lock_storeifref2_loop:
// address is r0, value is r1, r1 store to r0 only if [r0] is r2. return old [r0] value (so r2 or old value)
ldrex r3, [r0]
cmp r3, r2
movne r0, r3
bne arm_lock_storeifref2_exit
strex r3, r1, [r0]
cmp r3, #1
beq arm_lock_storeifref_loop
mov r0, r2
arm_lock_storeifref2_exit:
bx lr
arm_lock_storeifref:
push {r4}
dmb ish
arm_lock_storeifref_loop:
// address is r0, value is r1, r1 store to r0 only if [r0] is r2. return new [r0] value (so r1 or old value)
ldrex r3, [r0]
cmp r3, r2
movne r0, r3
bne arm_lock_storeifref_exit
strex r3, r1, [r0]
cmp r3, #1
mov r3, r1
strex r4, r3, [r0]
cmp r4, #1
beq arm_lock_storeifref_loop
mov r0, r1
arm_lock_storeifref_exit:
mov r0, r3
pop {r4}
bx lr
arm_lock_decifnot0b:
arm_lock_store_xchg:
// address is r0, value is r1, r1 store to r0 only if [r0] is 0. return new [r0] value (so r1 or old value)
// r0 needs to be aligned
ldrex r2, [r0]
cmp r2, #0
bne arm_lock_store_xchg_exit
mov r2, r1
strex r3, r2, [r0]
cmp r3, #1
beq arm_lock_store_xchg
mov r2, #0
arm_lock_store_xchg_exit:
mov r0, r2
bx lr
arm_lock_dec:
dmb ish
arm_lock_decifnot0b_0:
ldrexb r1, [r0]
cmp r1, #0
subne r3, r1, #1
moveq r3, r1
strexb r2, r3, [r0]
ldrex r1, [r0]
sub r1, r1, #1
strex r2, r1, [r0]
cmp r2, #1
beq arm_lock_decifnot0b_0
dmb ish
mov r0, r1
beq arm_lock_dec
bx lr
arm_lock_incb:
arm_lock_dec_b:
dmb ish
arm_lock_incb_0:
ldrexb r1, [r0]
add r1, r1, #1
sub r1, r1, #1
strexb r2, r1, [r0]
cmp r2, #1
beq arm_lock_incb_0
arm_lock_incb_exit:
dmb ish
beq arm_lock_dec_b
bx lr
arm_lock_incif0b:
dmb ish
arm_lock_incif0b_0:
ldrexb r1, [r0]
cmp r1, #0
addeq r3, r1, #1
movne r3, r1
strexb r2, r3, [r0]
cmp r2, #1
beq arm_lock_incif0b_0
dmb ish
mov r0, r1
bx lr
arm_lock_stored:
dmb ish
arm_lock_store:
str r1, [r0]
dmb ish
bx lr
arm_lock_storeb:
dmb ish
arm_lock_store_b:
strb r1, [r0]
dmb ish
bx lr
arm_lock_storeif0b:
dmb ish
arm_lock_storeif0b_0:
ldrexb r2, [r0]
cmp r2, #0
bne arm_lock_storeif0b_exit
strexb r3, r1, [r0]
cmp r3, #1
beq arm_lock_storeif0b_0
mov r2, #0
dmb ish
arm_lock_storeif0b_exit:
mov r0, r2
bx lr
arm_lock_readb:
dmb ish
ldrb r0, [r0]
bx lr
+11 -20
View File
@@ -25,34 +25,25 @@ extern int arm_lock_write_dd(uint32_t a, uint32_t b, void* addr);
// Atomically exchange value at [p] with val, return old p
extern uintptr_t arm_lock_xchg(void* p, uintptr_t val);
// Atomically store value to [p] only if [p] is NULL. Return old [p] value
// Atomically store value to [p] only if [p] is NULL. Return new [p] value (so val or old)
extern void* arm_lock_storeifnull(void* p, void* val);
// Atomically store value to [p] only if [p] is ref. Return new [p] value (so val or old)
extern void* arm_lock_storeifref(void* p, void* val, void* ref);
// Atomically store value to [p] only if [p] is ref. Return old [p] value
extern void* arm_lock_storeifref2(void* p, void* val, void* ref);
// Atomically store value to [p] only if [p] is NULL. Return old [p] value
extern void* arm_lock_store_xchg(void* p, void* val);
// decrement atomicaly the byte at [p] (but only if p not 0). Return old [p] value
extern int arm_lock_decifnot0b(void*p);
// will decrease *p atomicaly
extern void arm_lock_dec_b(uint8_t* p);
// increment atomicaly the byte at [p]
extern void arm_lock_incb(void*p);
// will decrease *p atomicaly
extern void arm_lock_dec(int* p);
// increment atomicaly the byte at [p] only if it was 0. Return the old value of [p]
extern int arm_lock_incif0b(void*p);
// store value, with data memory barrier
extern void arm_lock_store_b(uint8_t* p, uint8_t val);
// atomic store (with memory barrier)
extern void arm_lock_stored(void*p, uint32_t d);
// atomic store (with memory barrier)
extern void arm_lock_storeb(void*p, uint8_t b);
// atomic store (with memory barrier) only if it was 0. Return the old value of [p]
extern int arm_lock_storeif0b(void*p, uint8_t b);
// atomic load (with memory barrier)
extern int arm_lock_readb(void*p);
// store value, with data memory barrier
extern void arm_lock_store(int* p, int val);
#endif //__ARM_LOCK_HELPER__H__
+97 -289
View File
@@ -4,6 +4,7 @@
#include <errno.h>
#include <sys/mman.h>
#include <setjmp.h>
#include <sys/mman.h>
#include "debug.h"
#include "box86context.h"
@@ -41,108 +42,36 @@ uint32_t X31_hash_code(void* addr, int len)
return (uint32_t)h;
}
dynablocklist_t* NewDynablockList(uintptr_t text, int textsz, int direct)
{
if(!textsz) {
printf_log(LOG_NONE, "Error, creating a NULL sized Dynablock\n");
return NULL;
}
dynablocklist_t* ret = (dynablocklist_t*)box_calloc(1, sizeof(dynablocklist_t));
ret->text = text;
ret->textsz = textsz;
if(direct && textsz) {
ret->direct = (dynablock_t**)box_calloc(textsz, sizeof(dynablock_t*));
if(!ret->direct) {printf_log(LOG_NONE, "Warning, fail to create direct block for dynablock @%p\n", (void*)text);}
}
dynarec_log(LOG_DEBUG, "New Dynablocklist %p, from %p->%p\n", ret, (void*)text, (void*)(text+textsz));
return ret;
}
void FreeDynablock(dynablock_t* db, int need_lock)
{
if(db) {
if(db->gone)
return; // already in the process of deletion!
dynarec_log(LOG_DEBUG, "FreeDynablock(%p), db->block=%p x86=%p:%p father=%p, with %d son(s) already gone=%d\n", db, db->block, db->x86_addr, db->x86_addr+db->x86_size, db->father, db->sons_size, db->gone);
dynarec_log(LOG_DEBUG, "FreeDynablock(%p), db->block=%p x86=%p:%p already gone=%d\n", db, db->block, db->x86_addr, db->x86_addr+db->x86_size, db->gone);
if(need_lock)
mutex_lock(&my_context->mutex_dyndump);
db->done = 0;
db->gone = 1;
// remove from direct if there
uintptr_t startdb = db->parent->text;
uintptr_t enddb = db->parent->text + db->parent->textsz;
if(db->parent->direct) {
uintptr_t addr = (uintptr_t)db->x86_addr;
if(addr>=startdb && addr<enddb)
db->parent->direct[addr-startdb] = NULL;
}
pthread_mutex_lock(&my_context->mutex_dyndump);
// remove jumptable
setJumpTableDefault(db->x86_addr);
// remove and free the sons
for (int i=0; i<db->sons_size; ++i) {
dynablock_t *son = (dynablock_t*)arm_lock_xchg(&db->sons[i], 0);
FreeDynablock(son, 0);
}
// only the father free the DynarecMap
if(!db->father) {
dynarec_log(LOG_DEBUG, " -- FreeDyrecMap(%p, %d)\n", db->block, db->size);
FreeDynarecMap(db, (uintptr_t)db->block, db->size);
box_free(db->sons);
box_free(db->instsize);
}
dynarec_log(LOG_DEBUG, " -- FreeDyrecMap(%p, %d)\n", db->actual_block, db->size);
db->done = 0;
db->gone = 1;
FreeDynarecMap(db, (uintptr_t)db->actual_block, db->size);
box_free(db);
if(need_lock)
mutex_unlock(&my_context->mutex_dyndump);
pthread_mutex_unlock(&my_context->mutex_dyndump);
}
}
void FreeDynablockList(dynablocklist_t** dynablocks)
{
if(!dynablocks)
return;
if(!*dynablocks)
return;
dynarec_log(LOG_DEBUG, "Free Dynablocklist %p, with Direct Blocks %p\n", *dynablocks, (*dynablocks)->direct);
if((*dynablocks)->direct) {
for (int i=0; i<(*dynablocks)->textsz; ++i) {
if((*dynablocks)->direct[i] && !(*dynablocks)->direct[i]->father)
FreeDynablock((*dynablocks)->direct[i], my_context?1:0);
}
box_free((*dynablocks)->direct);
}
(*dynablocks)->direct = NULL;
box_free(*dynablocks);
*dynablocks = NULL;
}
void MarkDynablock(dynablock_t* db)
{
if(db) {
if(db->father)
db = db->father; // mark only father
if(db->need_test)
return; // already done
db->need_test = 1;
setJumpTableDefault(db->x86_addr);
for(int i=0; i<db->sons_size; ++i)
setJumpTableDefault(db->sons[i]->x86_addr);
}
}
uintptr_t StartDynablockList(dynablocklist_t* db)
{
if(db)
return db->text;
return 0;
}
uintptr_t EndDynablockList(dynablocklist_t* db)
{
if(db)
return db->text+db->textsz-1;
return 0;
}
int IntervalIntersects(uintptr_t start1, uintptr_t end1, uintptr_t start2, uintptr_t end2)
{
if(start1 > end2 || start2 > end1)
@@ -150,81 +79,27 @@ int IntervalIntersects(uintptr_t start1, uintptr_t end1, uintptr_t start2, uintp
return 1;
}
void MarkDirectDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t size)
void MarkRangeDynablock(dynablock_t* db, uintptr_t addr, uintptr_t size)
{
if(!dynablocks)
if(!db)
return;
if(!dynablocks->direct)
return;
uintptr_t startdb = dynablocks->text;
uintptr_t enddb = startdb + dynablocks->textsz -1;
uintptr_t start = addr;
uintptr_t end = addr+size-1;
if(start<startdb)
start = startdb;
if(end>enddb)
end = enddb;
dynablock_t *db;
if(end>startdb && start<enddb)
for(uintptr_t i = start; i<end; ++i)
if((db=dynablocks->direct[i-startdb]))
if(IntervalIntersects((uintptr_t)db->x86_addr, (uintptr_t)db->x86_addr+db->x86_size-1, addr, addr+size+1))
MarkDynablock(db);
dynarec_log(LOG_DEBUG, "MarkRangeDynablock %p-%p .. startdb=%p, sizedb=%p\n", (void*)addr, (void*)addr+size-1, (void*)db->x86_addr, (void*)db->x86_size);
if(!db->need_test)
if(IntervalIntersects((uintptr_t)db->x86_addr, (uintptr_t)db->x86_addr+db->x86_size-1, addr, addr+size+1))
MarkDynablock(db);
}
void FreeRangeDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t size)
int FreeRangeDynablock(dynablock_t* db, uintptr_t addr, uintptr_t size)
{
if(!dynablocks)
return;
if(!db)
return 1;
if(dynablocks->direct) {
int need_lock = my_context?1:0;
dynablock_t* db;
int ret;
khint_t k;
kh_dynablocks_t *blocks = kh_init(dynablocks);
// copy in a temporary list
if(dynablocks->direct) {
uintptr_t startdb = dynablocks->text;
uintptr_t enddb = startdb + dynablocks->textsz;
uintptr_t start = addr;
uintptr_t end = addr+size;
if(start<startdb)
start = startdb;
if(end>enddb)
end = enddb;
if(end>startdb && start<enddb)
for(uintptr_t i = start; i<end; ++i) {
db = (dynablock_t*)arm_lock_xchg(&dynablocks->direct[i-startdb], 0);
if(db) {
if(db->father)
db = db->father;
if(db->parent==dynablocks) {
k = kh_put(dynablocks, blocks, (uintptr_t)db, &ret);
kh_value(blocks, k) = db;
}
}
}
}
// purge the list
kh_foreach_value(blocks, db,
FreeDynablock(db, need_lock);
);
kh_destroy(dynablocks, blocks);
}
}
void MarkRangeDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t size)
{
if(!dynablocks)
return;
if(dynablocks->direct) {
uintptr_t new_addr = addr - dynablocks->maxsz;
uintptr_t new_size = size + dynablocks->maxsz;
MarkDirectDynablock(dynablocks, new_addr, new_size);
// the blocks check before
for(int idx=(new_addr)>>DYNAMAP_SHIFT; idx<(addr>>DYNAMAP_SHIFT); ++idx)
MarkDirectDynablock(getDB(idx), new_addr, new_size);
int need_lock = my_context?1:0;
if(IntervalIntersects((uintptr_t)db->x86_addr, (uintptr_t)db->x86_addr+db->x86_size-1, addr, addr+size+1)) {
FreeDynablock(db, need_lock);
return 0;
}
return 1;
}
dynablock_t* FindDynablockDynablocklist(void* addr, kh_dynablocks_t* dynablocks)
@@ -236,64 +111,27 @@ dynablock_t* FindDynablockDynablocklist(void* addr, kh_dynablocks_t* dynablocks)
const uintptr_t s = (uintptr_t)db->block;
const uintptr_t e = (uintptr_t)db->block+db->size;
if((uintptr_t)addr>=s && (uintptr_t)addr<e)
return db->father?db->father:db;
return db;
)
return NULL;
}
static dynablocklist_t* getDBFromAddress(uintptr_t addr)
dynablock_t *AddNewDynablock(uintptr_t addr)
{
const int idx = (addr>>DYNAMAP_SHIFT);
return getDB(idx);
}
dynablock_t *AddNewDynablock(dynablocklist_t* dynablocks, uintptr_t addr, int* created)
{
if(!dynablocks) {
dynarec_log(LOG_INFO, "Warning: Ask to create a dynablock with a NULL dynablocklist (addr=%p)\n", (void*)addr);
*created = 0;
dynablock_t* block;
#if 0
// check if memory as the correct flags
int prot = getProtection(addr);
if(!(prot&(PROT_EXEC|PROT_DYNAREC|PROT_DYNAREC_R))) {
dynarec_log(LOG_VERBOSE, "Block asked on a memory with no execution flags 0x%02X\n", prot);
return NULL;
}
if((addr<dynablocks->text) || (addr>=(dynablocks->text+dynablocks->textsz))) {
// this should be useless
//dynarec_log(LOG_INFO, "Warning: Refused to create a Direct Block that is out-of-bound: dynablocks=%p (%p:%p), addr=%p\n", dynablocks, (void*)(dynablocks->text), (void*)(dynablocks->text+dynablocks->textsz), (void*)addr);
//*created = 0;
//return NULL;
return AddNewDynablock(getDBFromAddress(addr), addr, created);
}
dynablock_t* block = NULL;
// first, check if it exist in direct access mode
if(dynablocks->direct) {
block = dynablocks->direct[addr-dynablocks->text];
if(block) {
dynarec_log(LOG_VERBOSE, "Block already exist in Direct Map\n");
*created = 0;
return block;
}
}
if (!*created)
return block;
if(!dynablocks->direct) {
dynablock_t** p = (dynablock_t**)box_calloc(dynablocks->textsz, sizeof(dynablock_t*));
if(arm_lock_storeifnull(&dynablocks->direct, p)!=NULL)
box_free(p); // someone already create the direct array, too late...
}
#endif
pthread_mutex_lock(&my_context->mutex_dyndump);
// create and add new block
dynarec_log(LOG_VERBOSE, "Ask for DynaRec Block creation @%p\n", (void*)addr);
block = (dynablock_t*)box_calloc(1, sizeof(dynablock_t));
block->parent = dynablocks;
dynablock_t* tmp = (dynablock_t*)arm_lock_storeifref(&dynablocks->direct[addr-dynablocks->text], block, NULL);
if(tmp != block) {
// a block appeard!
box_free(block);
*created = 0;
return tmp;
}
*created = 1;
pthread_mutex_unlock(&my_context->mutex_dyndump);
return block;
}
@@ -309,121 +147,93 @@ void cancelFillBlock()
return NULL if block is not found / cannot be created.
Don't create if create==0
*/
static dynablock_t* internalDBGetBlock(x86emu_t* emu, uintptr_t addr, uintptr_t filladdr, int create, dynablock_t* current, int need_lock)
static dynablock_t* internalDBGetBlock(x86emu_t* emu, uintptr_t addr, uintptr_t filladdr, int create, int need_lock)
{
if(hasAlternate((void*)addr))
return NULL;
// try the quickest way first: get parent of current and check if ok!
dynablocklist_t *dynablocks = NULL;
dynablock_t* block = NULL;
if(current && current->done) {
dynablocks = current->parent;
if(dynablocks && !(addr>=dynablocks->text && addr<(dynablocks->text+dynablocks->textsz)))
dynablocks = NULL;
}
// nope, lets do the long way
if(!dynablocks) {
dynablocks = getDBFromAddress(addr);
if(!dynablocks) {
dynablocks = GetDynablocksFromAddress(emu->context, addr);
if(!dynablocks)
return NULL;
}
}
// check direct first, without lock
if(dynablocks->direct/* && (addr>=dynablocks->text) && (addr<(dynablocks->text+dynablocks->textsz))*/)
if((block = dynablocks->direct[addr-dynablocks->text]))
return block;
dynablock_t* block = getDB(addr);
if(block || !create)
return block;
int created = create;
if(need_lock)
mutex_lock(&my_context->mutex_dyndump);
block = AddNewDynablock(dynablocks, addr, &created);
if(!created) {
pthread_mutex_lock(&my_context->mutex_dyndump);
block = getDB(addr); // just in case
if(block) {
if(need_lock)
mutex_unlock(&my_context->mutex_dyndump);
return block; // existing block...
pthread_mutex_unlock(&my_context->mutex_dyndump);
return block;
}
block = AddNewDynablock(addr);
// fill the block
block->x86_addr = (void*)addr;
if(sigsetjmp(&dynarec_jmpbuf, 1)) {
printf_log(LOG_INFO, "FillBlock at %p triggered a segfault, cancelling\n", (void*)addr);
if(need_lock)
mutex_unlock(&my_context->mutex_dyndump);
pthread_mutex_unlock(&my_context->mutex_dyndump);
return NULL;
}
void* ret = FillBlock(block, filladdr);
if(need_lock)
mutex_unlock(&my_context->mutex_dyndump);
pthread_mutex_unlock(&my_context->mutex_dyndump);
if(!ret) {
dynarec_log(LOG_DEBUG, "Fillblock of block %p for %p returned an error\n", block, (void*)addr);
void* old = (void*)arm_lock_storeifref(&dynablocks->direct[addr-dynablocks->text], 0, block);
if(old!=block && old) { // put it back in place, strange things are happening here!
dynarec_log(LOG_INFO, "Warning, a wild block appeared at %p: %p\n", (void*)addr, old);
// Doing nothing else, the block has not been written
}
box_free(block);
block = NULL;
}
// check size
if(block && block->x86_size) {
if(block && (block->x86_size || (!block->x86_size && !block->done))) {
int blocksz = block->x86_size;
if(dynablocks->maxsz<blocksz) {
dynablocks->maxsz = blocksz;
for(int idx=(addr>>DYNAMAP_SHIFT)+1; idx<=((addr+blocksz)>>DYNAMAP_SHIFT); ++idx) {
dynablocklist_t* dblist;
if((dblist = getDB(idx)))
if(dblist->maxsz<blocksz)
dblist->maxsz = blocksz;
}
}
//protectDB((uintptr_t)block->x86_addr, block->x86_size); // already protected in FillBlock
// but check if it already need test
if(block->need_test || (block->father && block->father->need_test))
return NULL;
if(blocksz>my_context->max_db_size)
my_context->max_db_size = blocksz;
// fill-in jumptable
addJumpTableIfDefault(block->x86_addr, block->block);
for(int i=0; i<block->sons_size; ++i)
addJumpTableIfDefault(block->sons[i]->x86_addr, block->sons[i]->block);
if(!addJumpTableIfDefault(block->x86_addr, block->block)) {
FreeDynablock(block, 1);
block = getDB(addr);
} else {
if(block->x86_size)
block->done = 1; // don't validate the block if the size is null, but keep the block
}
}
if(need_lock)
pthread_mutex_unlock(&my_context->mutex_dyndump);
dynarec_log(LOG_DEBUG, " --- DynaRec Block %s @%p:%p (%p, 0x%x bytes, with %d son(s))\n", created?"created":"recycled", (void*)addr, (void*)(addr+((block)?block->x86_size:0)), (block)?block->block:0, (block)?block->size:0, (block)?block->sons_size:0);
dynarec_log(LOG_DEBUG, " --- DynaRec Block created @%p:%p (%p, 0x%x bytes)\n", (void*)addr, (void*)(addr+((block)?block->x86_size:0)), (block)?block->block:0, (block)?block->size:0);
return block;
}
dynablock_t* DBGetBlock(x86emu_t* emu, uintptr_t addr, int create, dynablock_t** current)
dynablock_t* DBGetBlock(x86emu_t* emu, uintptr_t addr, int create)
{
dynablock_t *db = internalDBGetBlock(emu, addr, addr, create, *current, 1);
if(db && db->done && db->block && (db->need_test || (db->father && db->father->need_test))) {
dynablock_t *db = internalDBGetBlock(emu, addr, addr, create, 1);
if(db && db->done && db->block && db->need_test) {
if(AreaInHotPage((uintptr_t)db->x86_addr, (uintptr_t)db->x86_addr + db->x86_size - 1)) {
dynarec_log(LOG_DEBUG, "Not running block %p from %p:%p with for %p because it's in a hotpage\n", db, db->x86_addr, db->x86_addr+db->x86_size-1, (void*)addr);
return NULL;
}
if(mutex_trylock(&my_context->mutex_dyndump))
uint32_t hash = X31_hash_code(db->x86_addr, db->x86_size);
if(pthread_mutex_trylock(&my_context->mutex_dyndump)) {
dynarec_log(LOG_DEBUG, "mutex_dyndump not available when trying to validate block %p from %p:%p (hash:%X) for %p\n", db, db->x86_addr, db->x86_addr+db->x86_size-1, db->hash, (void*)addr);
return NULL;
dynablock_t *father = db->father?db->father:db;
uint32_t hash = (getProtection((uintptr_t)father->x86_addr)&PROT_READ)?X31_hash_code(father->x86_addr, father->x86_size):0;
if(hash!=father->hash) {
dynarec_log(LOG_DEBUG, "Invalidating block %p from %p:%p (hash:%X/%X) with %d son(s) for %p\n", father, father->x86_addr, father->x86_addr+father->x86_size, hash, father->hash, father->sons_size, (void*)addr);
// no more current if it gets invalidated too
if(*current && father->x86_addr>=(*current)->x86_addr && (father->x86_addr+father->x86_size)<(*current)->x86_addr)
*current = NULL;
// Free father, it's now invalid!
FreeDynablock(father, 0);
// start again... (will create a new block)
db = internalDBGetBlock(emu, addr, addr, create, *current, 0);
} else {
father->need_test = 0;
protectDB((uintptr_t)father->x86_addr, father->x86_size);
// fill back jumptable
addJumpTableIfDefault(father->x86_addr, father->block);
for(int i=0; i<father->sons_size; ++i)
addJumpTableIfDefault(father->sons[i]->x86_addr, father->sons[i]->block);
}
mutex_unlock(&my_context->mutex_dyndump);
}
if(hash!=db->hash) {
db->done = 0; // invalidating the block
dynarec_log(LOG_DEBUG, "Invalidating block %p from %p:%p (hash:%X/%X) for %p\n", db, db->x86_addr, db->x86_addr+db->x86_size-1, hash, db->hash, (void*)addr);
// Free db, it's now invalid!
FreeDynablock(db, 0);
// start again... (will create a new block)
db = internalDBGetBlock(emu, addr, addr, create, 0);
} else {
db->need_test = 0;
dynarec_log(LOG_DEBUG, "Validating block %p from %p:%p (hash:%X) for %p\n", db, db->x86_addr, db->x86_addr+db->x86_size-1, db->hash, (void*)addr);
protectDB((uintptr_t)db->x86_addr, db->x86_size);
// fill back jumptable
setJumpTableIfRef(db->x86_addr, db->block, db->jmpnext);
}
pthread_mutex_unlock(&my_context->mutex_dyndump);
}
return db;
}
@@ -431,27 +241,25 @@ dynablock_t* DBAlternateBlock(x86emu_t* emu, uintptr_t addr, uintptr_t filladdr)
{
dynarec_log(LOG_DEBUG, "Creating AlternateBlock at %p for %p\n", (void*)addr, (void*)filladdr);
int create = 1;
dynablock_t *db = internalDBGetBlock(emu, addr, filladdr, create, NULL, 1);
if(db && db->done && db->block && (db->need_test || (db->father && db->father->need_test))) {
if(mutex_trylock(&my_context->mutex_dyndump))
dynablock_t *db = internalDBGetBlock(emu, addr, filladdr, create, 1);
if(db && db->done && db->block && db->need_test) {
if(pthread_mutex_trylock(&my_context->mutex_dyndump))
return NULL;
dynablock_t *father = db->father?db->father:db;
uint32_t hash = (getProtection((uintptr_t)father->x86_addr)&PROT_READ)?X31_hash_code(father->x86_addr, father->x86_size):0;
if(hash!=father->hash) {
dynarec_log(LOG_DEBUG, "Invalidating alt block %p from %p:%p (hash:%X/%X) with %d son(s) for %p\n", father, father->x86_addr, father->x86_addr+father->x86_size, hash, father->hash, father->sons_size, (void*)addr);
// Free father, it's now invalid!
FreeDynablock(father, 0);
uint32_t hash = X31_hash_code(db->x86_addr, db->x86_size);
if(hash!=db->hash) {
db->done = 0; // invalidating the block
dynarec_log(LOG_DEBUG, "Invalidating alt block %p from %p:%p (hash:%X/%X) for %p\n", db, db->x86_addr, db->x86_addr+db->x86_size, hash, db->hash, (void*)addr);
// Free db, it's now invalid!
FreeDynablock(db, 0);
// start again... (will create a new block)
db = internalDBGetBlock(emu, addr, filladdr, create, NULL, 0);
db = internalDBGetBlock(emu, addr, filladdr, create, 0);
} else {
father->need_test = 0;
protectDB((uintptr_t)father->x86_addr, father->x86_size);
db->need_test = 0;
protectDB((uintptr_t)db->x86_addr, db->x86_size);
// fill back jumptable
addJumpTableIfDefault(father->x86_addr, father->block);
for(int i=0; i<father->sons_size; ++i)
addJumpTableIfDefault(father->sons[i]->x86_addr, father->sons[i]->block);
addJumpTableIfDefault(db->x86_addr, db->block);
}
mutex_unlock(&my_context->mutex_dyndump);
pthread_mutex_unlock(&my_context->mutex_dyndump);
}
return db;
}
}
+3 -13
View File
@@ -1,7 +1,6 @@
#ifndef __DYNABLOCK_PRIVATE_H_
#define __DYNABLOCK_PRIVATE_H_
typedef struct dynablocklist_s dynablocklist_t;
typedef struct instsize_s {
unsigned char x86:4;
@@ -9,8 +8,8 @@ typedef struct instsize_s {
} instsize_t;
typedef struct dynablock_s {
dynablocklist_t* parent;
void* block;
void* block; // block-sizeof(void*) == self
void* actual_block; // the actual start of the block (so block-sizeof(void*))
int size;
void* x86_addr;
uintptr_t x86_size;
@@ -20,17 +19,8 @@ typedef struct dynablock_s {
uint8_t gone;
uint8_t dummy;
int isize;
dynablock_t** sons; // sons (kind-of dummy dynablock...)
int sons_size;
dynablock_t* father; // set only in the case of a son
instsize_t* instsize;
void* jmpnext; // a branch jmpnext code when block is marked
} dynablock_t;
typedef struct dynablocklist_s {
uintptr_t text;
int textsz;
int maxsz; // maxblock size (for this block or previous block)
dynablock_t** direct; // direct mapping (waste of space, so the array is created at first write)
} dynablocklist_t;
#endif //__DYNABLOCK_PRIVATE_H_
+7 -18
View File
@@ -20,12 +20,7 @@
#include "dynablock.h"
#include "dynablock_private.h"
#include "bridge.h"
#endif
#ifdef ARM
void arm_prolog(x86emu_t* emu, void* addr) EXPORTDYN;
void arm_epilog() EXPORTDYN;
void arm_epilog_fast() EXPORTDYN;
#include "dynarec_next.h"
#endif
#ifdef DYNAREC
@@ -44,9 +39,8 @@ void* LinkNext(x86emu_t* emu, uintptr_t addr, void* x2)
printf_log(LOG_NONE, "Warning, jumping to NULL address from %p (db=%p, x86addr=%p/%s)\n", x2, db, x86addr, pcname);
}
#endif
dynablock_t* current = NULL;
void * jblock;
dynablock_t* block = DBGetBlock(emu, addr, 1, &current);
dynablock_t* block = DBGetBlock(emu, addr, 1);
if(!block) {
// no block, let link table as is...
if(hasAlternate((void*)addr)) {
@@ -54,7 +48,7 @@ void* LinkNext(x86emu_t* emu, uintptr_t addr, void* x2)
addr = (uintptr_t)getAlternate((void*)addr);
R_EIP = addr;
printf_log(LOG_INFO, " -> %p\n", (void*)addr);
block = DBGetBlock(emu, addr, 1, &current);
block = DBGetBlock(emu, addr, 1);
}
if(!block) {
#ifdef HAVE_TRACE
@@ -114,18 +108,15 @@ void DynaCall(x86emu_t* emu, uintptr_t addr)
PushExit(emu);
R_EIP = addr;
emu->df = d_none;
dynablock_t* block = NULL;
dynablock_t* current = NULL;
while(!emu->quit) {
block = DBGetBlock(emu, R_EIP, 1, &current);
current = block;
dynablock_t* block = DBGetBlock(emu, R_EIP, 1);
if(!block || !block->block || !block->done) {
// no block, of block doesn't have DynaRec content (yet, temp is not null)
// Use interpreter (should use single instruction step...)
dynarec_log(LOG_DEBUG, "%04d|Calling Interpretor @%p, emu=%p\n", GetTID(), (void*)R_EIP, emu);
Run(emu, 1);
} else {
dynarec_log(LOG_DEBUG, "%04d|Calling DynaRec Block @%p (%p) of %d x86 instructions (father=%p) emu=%p\n", GetTID(), (void*)R_EIP, block->block, block->isize ,block->father, emu);
dynarec_log(LOG_DEBUG, "%04d|Calling DynaRec Block @%p (%p) of %d x86 instructions emu=%p\n", GetTID(), (void*)R_EIP, block->block, block->isize ,emu);
CHECK_FLAGS(emu);
// block is here, let's run it!
#ifdef ARM
@@ -200,17 +191,15 @@ int DynaRun(x86emu_t* emu)
#ifdef DYNAREC
else {
dynablock_t* block = NULL;
dynablock_t* current = NULL;
while(!emu->quit) {
block = DBGetBlock(emu, R_EIP, 1, &current);
current = block;
block = DBGetBlock(emu, R_EIP, 1);
if(!block || !block->block || !block->done) {
// no block, of block doesn't have DynaRec content (yet, temp is not null)
// Use interpreter (should use single instruction step...)
dynarec_log(LOG_DEBUG, "%04d|Running Interpretor @%p, emu=%p\n", GetTID(), (void*)R_EIP, emu);
Run(emu, 1);
} else {
dynarec_log(LOG_DEBUG, "%04d|Running DynaRec Block @%p (%p) of %d x86 insts (father=%p) emu=%p\n", GetTID(), (void*)R_EIP, block->block, block->isize, block->father, emu);
dynarec_log(LOG_DEBUG, "%04d|Running DynaRec Block @%p (%p) of %d x86 insts emu=%p\n", GetTID(), (void*)R_EIP, block->block, block->isize, emu);
// block is here, let's run it!
#ifdef ARM
arm_prolog(emu, block->block);
+66 -85
View File
@@ -23,6 +23,7 @@
#include "dynarec_arm_private.h"
#include "dynarec_arm_functions.h"
#include "elfloader.h"
#include "dynarec_next.h"
void printf_x86_instruction(zydis_dec_t* dec, instruction_x86_t* inst, const char* name) {
uint8_t *ip = (uint8_t*)inst->addr;
@@ -298,15 +299,12 @@ static void fillPredecessors(dynarec_arm_t* dyn)
}
// fill pred
for(int i=0; i<dyn->size; ++i) {
if((i!=dyn->size-1) && dyn->insts[i].x86.has_next)
if(i!=dyn->size-1 && dyn->insts[i].x86.has_next && (!i || dyn->insts[i].pred_sz))
dyn->insts[i+1].pred[dyn->insts[i+1].pred_sz++] = i;
if(dyn->insts[i].x86.jmp && (dyn->insts[i].x86.jmp_insts!=-1)) {
int j = dyn->insts[i].x86.jmp_insts;
dyn->insts[j].pred[dyn->insts[j].pred_sz++] = i;
}
if(dyn->insts[i].x86.jmp && dyn->insts[i].x86.jmp_insts!=-1)
dyn->insts[dyn->insts[i].x86.jmp_insts].pred[dyn->insts[dyn->insts[i].x86.jmp_insts].pred_sz++] = i;
}
}
// updateNeed goes backward, from last intruction to top
@@ -361,7 +359,7 @@ uintptr_t arm_pass1(dynarec_arm_t* dyn, uintptr_t addr);
uintptr_t arm_pass2(dynarec_arm_t* dyn, uintptr_t addr);
uintptr_t arm_pass3(dynarec_arm_t* dyn, uintptr_t addr);
void* current_helper = NULL;
__thread void* current_helper = NULL;
void CancelBlock()
{
@@ -371,17 +369,34 @@ void CancelBlock()
return;
box_free(helper->next);
box_free(helper->insts);
box_free(helper->instsize);
box_free(helper->predecessor);
if(helper->dynablock && helper->dynablock->block)
FreeDynarecMap(helper->dynablock, (uintptr_t)helper->dynablock->block, helper->dynablock->size);
if(helper->dynablock && helper->dynablock->actual_block)
FreeDynarecMap(helper->dynablock, (uintptr_t)helper->dynablock->actual_block, helper->dynablock->size);
else if(helper->dynablock && helper->block)
FreeDynarecMap(helper->dynablock, (uintptr_t)helper->block-sizeof(void*), helper->dynablock->size);
}
void* CreateEmptyBlock(dynablock_t* block, uintptr_t addr) {
block->isize = 0;
block->done = 0;
block->size = 0;
block->block = NULL;
size_t sz = 4*sizeof(void*);
void* actual_p = (void*)AllocDynarecMap(block, sz);
void* p = actual_p + sizeof(void*);
if(actual_p==NULL) {
dynarec_log(LOG_INFO, "AllocDynarecMap(%p, %zu) failed, cancelling block\n", block, sz);
CancelBlock();
return NULL;
}
block->size = sz;
block->actual_block = actual_p;
block->block = p;
block->jmpnext = p;
*(dynablock_t**)actual_p = block;
CreateJmpNextTo(block->jmpnext, arm_epilog);
block->need_test = 0;
// all done...
__clear_cache(actual_p, actual_p+sz); // need to clear the cache before execution...
return block;
}
@@ -392,19 +407,13 @@ dynarec_log(LOG_DEBUG, "Asked to Fill block %p with %p\n", block, (void*)addr);
return NULL;
}
if(addr>=box86_nodynarec_start && addr<box86_nodynarec_end) {
dynarec_log(LOG_DEBUG, "Asked to fill a block in fobidden zone\n");
dynarec_log(LOG_INFO, "Create empty block in no-dynarec zone\n");
return CreateEmptyBlock(block, addr);
}
if(!isJumpTableDefault((void*)addr)) {
dynarec_log(LOG_DEBUG, "Asked to fill a block at %p, but JumpTable is not default\n", (void*)addr);
return NULL;
}
if(current_helper) {
dynarec_log(LOG_DEBUG, "Cancelling dynarec FillBlock at %p as anothor one is going on\n", (void*)addr);
return NULL;
}
// protect the 1st page
protectDB(addr, 1);
// init the helper
dynarec_arm_t helper = {0};
current_helper = &helper;
@@ -423,24 +432,16 @@ dynarec_log(LOG_DEBUG, "Asked to Fill block %p with %p\n", block, (void*)addr);
if(!helper.size) {
dynarec_log(LOG_DEBUG, "Warning, null-sized dynarec block (%p)\n", (void*)addr);
CancelBlock();
return (void*)block;
}
if(!isprotectedDB(addr, 1)) {
dynarec_log(LOG_INFO, "Warning, write on current page on pass0, aborting dynablock creation (%p)\n", (void*)addr);
AddHotPage(addr);
CancelBlock();
return NULL;
return CreateEmptyBlock(block, addr);
}
// already protect the block and compute hash signature
// protect the block of it goes over the 1st page
if((addr&~box86_pagesize)!=(end&~box86_pagesize)) // need to protect some other pages too
protectDB(addr, end-addr); //end is 1byte after actual end
protectDB(addr, end-addr); //end is 1byte after actual end
uint32_t hash = X31_hash_code((void*)addr, end-addr);
// calculate barriers
for(int i=0; i<helper.size; ++i)
if(helper.insts[i].x86.jmp) {
uintptr_t j = helper.insts[i].x86.jmp;
if(j<start || j>=end || j==helper.insts[i].x86.addr) {
if(j<start || j>=end) {
helper.insts[i].x86.jmp_insts = -1;
helper.insts[i].x86.need_after |= X_PEND;
} else {
@@ -467,29 +468,44 @@ dynarec_log(LOG_DEBUG, "Asked to Fill block %p with %p\n", block, (void*)addr);
// pass 2, instruction size
arm_pass2(&helper, addr);
// ok, now allocate mapped memory, with executable flag on
int sz = helper.arm_size;
void* p = (void*)AllocDynarecMap(block, sz);
if(p==NULL) {
// keep size of instructions for signal handling
size_t insts_ursize = 0;
{
size_t insts_size = 0;
size_t cap = 1;
for(int i=0; i<helper.size; ++i)
cap += 1 + ((helper.insts[i].x86.size>helper.insts[i].size)?helper.insts[i].x86.size:helper.insts[i].size)/15;
helper.instsize = (instsize_t*)box_calloc(cap, sizeof(instsize_t));
for(int i=0; i<helper.size; ++i)
helper.instsize = addInst(helper.instsize, &insts_size, &cap, helper.insts[i].x86.size, helper.insts[i].size/4);
helper.instsize = addInst(helper.instsize, &insts_size, &cap, 0, 0); // add a "end of block" mark, just in case
insts_ursize = insts_size*sizeof(instsize_t);
}
size_t insts_rsize = (insts_ursize+7)&~7; // round the size...
size_t sz = sizeof(void*) + helper.arm_size + 4*sizeof(void*) + insts_rsize;
// dynablock_t* block (arm insts) jmpnext code instsize
void* actual_p = (void*)AllocDynarecMap(block, sz);
void* p = actual_p + sizeof(void*);
void* next = p + helper.arm_size;
void* instsize = next + 4*sizeof(void*);
if(actual_p==NULL) {
dynarec_log(LOG_DEBUG, "AllocDynarecMap(%p, %d) failed, cancelling block\n", block, sz);
CancelBlock();
return NULL;
}
helper.block = p;
helper.arm_start = (uintptr_t)p;
if(helper.sons_size) {
helper.sons_x86 = (uintptr_t*)alloca(helper.sons_size*sizeof(uintptr_t));
helper.sons_arm = (void**)alloca(helper.sons_size*sizeof(void*));
}
*(dynablock_t**)actual_p = block;
// pass 3, emit (log emit arm opcode)
if(box86_dynarec_dump) {
dynarec_log(LOG_NONE, "%s%04d|Emitting %d bytes for %d x86 bytes", (box86_dynarec_dump>1)?"\e[01;36m":"", GetTID(), helper.arm_size, helper.isize);
printFunctionAddr(helper.start, " => ");
dynarec_log(LOG_NONE, "%s\n", (box86_dynarec_dump>1)?"\e[m":"");
}
size_t oldarmsize = helper.arm_size;
helper.arm_size = 0;
arm_pass3(&helper, addr);
if(sz!=helper.arm_size) {
if(oldarmsize!=helper.arm_size) {
printf_log(LOG_NONE, "BOX86: Warning, size difference in block between pass2 (%d) & pass3 (%d)!\n", sz, helper.arm_size);
uint8_t *dump = (uint8_t*)helper.start;
printf_log(LOG_NONE, "Dump of %d x86 opcodes:\n", helper.size);
@@ -501,74 +517,39 @@ dynarec_log(LOG_DEBUG, "Asked to Fill block %p with %p\n", block, (void*)addr);
}
printf_log(LOG_NONE, " ------------\n");
}
// all done...
__clear_cache(p, p+sz); // need to clear the cache before execution...
// keep size of instructions for signal handling
{
size_t cap = 1;
for(int i=0; i<helper.size; ++i)
cap += 1 + ((helper.insts[i].x86.size>helper.insts[i].size)?helper.insts[i].x86.size:helper.insts[i].size)/15;
size_t size = 0;
block->instsize = (instsize_t*)box_calloc(cap, sizeof(instsize_t));
for(int i=0; i<helper.size; ++i)
block->instsize = addInst(block->instsize, &size, &cap, helper.insts[i].x86.size, helper.insts[i].size/4);
block->instsize = addInst(block->instsize, &size, &cap, 0, 0); // add a "end of block" mark, just in case
}
memcpy(instsize, helper.instsize, insts_ursize);
block->instsize = instsize;
// ok, free the helper now
box_free(helper.insts);
helper.insts = NULL;
box_free(helper.next);
helper.next = NULL;
box_free(helper.instsize);
helper.instsize = NULL;
box_free(helper.predecessor);
helper.predecessor = NULL;
block->size = sz;
block->isize = helper.size;
block->actual_block = actual_p;
block->block = p;
block->jmpnext = next+sizeof(void*);
*(dynablock_t**)next = block;
CreateJmpNextTo(block->jmpnext, arm_next);
block->need_test = 0;
//block->x86_addr = (void*)start;
block->x86_size = end-start;
if(box86_dynarec_largest<block->x86_size)
box86_dynarec_largest = block->x86_size;
// all done...
__clear_cache(actual_p, actual_p+sz); // need to clear the cache before execution...
block->hash = X31_hash_code(block->x86_addr, block->x86_size);
// Check if something changed, to abbort if it as
if(block->hash != hash) {
dynarec_log(LOG_INFO, "Warning, a block changed while beeing processed hash(%p:%d)=%x/%x\n", block->x86_addr, block->x86_size, block->hash, hash);
CancelBlock();
AddHotPage(addr);
return NULL;
}
if(!isprotectedDB(addr, end-addr)) {
dynarec_log(LOG_DEBUG, "Warning, block unprotected while beeing processed %p:%zd, cancelling\n", block->x86_addr, block->x86_size);
AddHotPage(addr);
block->need_test = 1;
//protectDB(addr, end-addr);
}
// fill sons if any
dynablock_t** sons = NULL;
int sons_size = 0;
if(helper.sons_size) {
sons = (dynablock_t**)box_calloc(helper.sons_size, sizeof(dynablock_t*));
for (int i=0; i<helper.sons_size; ++i) {
int created = 1;
dynablock_t *son = AddNewDynablock(block->parent, helper.sons_x86[i], &created);
if(created) { // avoid breaking a working block!
son->block = helper.sons_arm[i];
son->x86_addr = (void*)helper.sons_x86[i];
son->x86_size = end-helper.sons_x86[i];
if(!son->x86_size) {printf_log(LOG_NONE, "Warning, son with null x86 size! (@%p / ARM=%p)", son->x86_addr, son->block);}
son->father = block;
son->done = 1;
sons[sons_size++] = son;
if(!son->parent)
son->parent = block->parent;
}
}
if(sons_size) {
block->sons = sons;
block->sons_size = sons_size;
} else
box_free(sons);
}
box_free(helper.predecessor);
helper.predecessor = NULL;
current_helper = NULL;
block->done = 1;
return (void*)block;
+26 -25
View File
@@ -581,12 +581,16 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 0x57:
INST_NAME("PUSH reg");
gd = xEAX+(opcode&0x07);
#ifdef RPI2
if(gd==xESP) {
MOV_REG(x1, gd);
PUSH1(x1);
} else {
PUSH1(gd);
}
#else
PUSH1(gd);
#endif
break;
case 0x58:
case 0x59:
@@ -661,7 +665,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
i32 = F32S;
if(PK(0)==0xC3) {
MESSAGE(LOG_DUMP, "PUSH then RET, using indirect\n");
MOV32(x3, addr-4);
MOV32(x3, ip+1);
LDR_IMM9(x1, x3, 0);
PUSH1(x1);
} else {
@@ -1011,7 +1015,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
BFI(eb1, x14, eb2*8, 8);
} else {
GETGB(x14);
SMDMB();
DMB_ISH();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 0, LOCK_LOCK);
MARKLOCK;
// do the swap with exclusive locking
@@ -1021,7 +1025,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
BFI(gb1, x1, gb2*8, 8);
SMDMB();
DMB_ISH();
}
break;
case 0x87:
@@ -1037,7 +1041,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
} else {
GETGD;
SMDMB();
DMB_ISH();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 1, LOCK_LOCK);
if(!fixedaddress) {
TSTS_IMM8(ed, 3);
@@ -1061,7 +1065,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if(!fixedaddress) {
MARK2;
}
SMDMB();
DMB_ISH();
MOV_REG(gd, x1);
}
break;
@@ -1085,7 +1089,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 4095, 0, 0, &lock);
STRB_IMM9(gd, ed, fixedaddress);
SMWRITELOCK(lock);
if(lock) {DMB_ISH();}
}
break;
case 0x89:
@@ -1097,7 +1101,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else { // mem <= reg
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 4095, 0, 0, &lock);
STR_IMM9(gd, ed, fixedaddress);
SMWRITELOCK(lock);
if(lock) {DMB_ISH();}
}
break;
case 0x8A:
@@ -1119,10 +1123,10 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
if(box86_dynarec_strongmem &&
(dyn->insts[ninst].x86.barrier || !ninst || (box86_dynarec_strongmem>1) || (ninst && dyn->insts[ninst-1].x86.barrier))) {
SMDMB();
DMB_ISH();
}
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095, 0, 0, &lock);
SMREADLOCK(lock);
if(lock) {DMB_ISH();}
LDRB_IMM9(x14, wback, fixedaddress);
ed = x14;
}
@@ -1136,7 +1140,10 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOV_REG(gd, xEAX+(nextop&7));
} else { // mem <= reg
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 4095, 0, 0, &lock);
SMREADLOCK(lock);
if(lock || (box86_dynarec_strongmem &&
(dyn->insts[ninst].x86.barrier || !ninst || (box86_dynarec_strongmem>1) || (ninst && dyn->insts[ninst-1].x86.barrier)))) {
DMB_ISH();
}
LDR_IMM9(gd, ed, fixedaddress);
}
break;
@@ -1150,7 +1157,6 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 0, NULL);
LDRH_REG(x3, xEmu, x3);
STRH_IMM8(x3, ed, fixedaddress);
SMWRITE2();
}
break;
case 0x8D:
@@ -1278,14 +1284,12 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
u32 = F32;
MOV32(x2, u32);
STRB_IMM9(xEAX, x2, 0);
SMWRITE();
break;
case 0xA3:
INST_NAME("MOV Od, EAX");
u32 = F32;
MOV32(x2, u32);
STR_IMM9(xEAX, x2, 0);
SMWRITE();
break;
case 0xA4:
INST_NAME("MOVSB");
@@ -1518,7 +1522,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
u8 = F8;
MOVW(x2, u8);
CALL_(rcl32, ed, (1<<x14));
WBACK;
WBACK; // no SBACK here because ret value is ed directly
break;
case 3:
INST_NAME("RCR Ed, Ib");
@@ -1549,13 +1553,13 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
BFC_COND(cCC, xFlags, F_CF, 1);
}
WBACK;
WBACK; // no SBACK here because ed has been used all along and not x1
} else if(u8>1) {
MESSAGE(LOG_DUMP, "Need Optimization RCR\n");
SETFLAGS(X_OF|X_CF, SF_SET);
MOVW(x2, u8);
CALL_(rcr32, ed, (1<<x14));
WBACK;
WBACK; // no SBACK here because ret value is ed directly
}
break;
case 4:
@@ -1629,7 +1633,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
u8 = F8;
MOVW(x3, u8);
STRB_IMM9(x3, ed, fixedaddress);
SMWRITELOCK(lock);
if(lock) {DMB_ISH();}
}
break;
case 0xC7:
@@ -1644,7 +1648,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
i32 = F32S;
MOV32(x3, i32);
STR_IMM9(x3, ed, fixedaddress);
SMWRITELOCK(lock);
if(lock) {DMB_ISH();}
}
break;
@@ -1715,7 +1719,6 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
break;
case 0xCD:
SETFLAGS(X_ALL, SF_SET); // Hack, set all flags (to an unknown state...)
SMEND();
if(PK(0)==0x80) {
INST_NAME("Syscall");
u8 = F8;
@@ -1881,7 +1884,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOVW(x2, 1);
GETEDW(x14, x1);
CALL_(rcl32, ed, (1<<x14));
WBACK;
WBACK; // no SBACK here because ret value is ed directly
break;
case 3:
INST_NAME("RCR Ed, 1");
@@ -1991,7 +1994,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
AND_IMM8(x2, xECX, 0x1f);
GETEDW(x14, x1);
CALL_(rcl32, ed, (1<<x14));
WBACK;
WBACK; // no SBACK here because ret value is ed directly
break;
case 3:
INST_NAME("RCR Ed, CL");
@@ -2001,7 +2004,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
AND_IMM8(x2, xECX, 0x1f);
GETEDW(x14, x1);
CALL_(rcr32, ed, (1<<x14));
WBACK;
WBACK; // no SBACK here because ret value is ed directly
break;
case 4:
case 6:
@@ -2062,7 +2065,6 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 0xD7:
INST_NAME("XLAT");
UBFX(x1, xEAX, 0, 8); // x1 = AL
SMREAD();
LDRB_REG_LSL_IMM5(x1, xEBX, x1, 0); //x1 = byte ptr[EBX+AL]
BFI(xEAX, x1, 0, 8);
break;
@@ -2839,8 +2841,7 @@ uintptr_t dynarec00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
break;
case 4: // JMP Ed
INST_NAME("JMP Ed");
READFLAGS(X_PEND);
BARRIER(BARRIER_FLOAT);
BARRIER(BARRIER_FULL);
GETEDH(xEIP);
jump_to_next(dyn, 0, ed, ninst);
*need_epilog = 0;
+10 -69
View File
@@ -31,7 +31,6 @@
if((nextop&0xC0)==0xC0) { \
a = sse_get_reg(dyn, ninst, x1, nextop&7, w); \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL); \
a = fpu_get_scratch_quad(dyn); \
VLD1Q_64(a, ed); \
@@ -43,7 +42,6 @@
if((nextop&0xC0)==0xC0) { \
a = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7); \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL); \
a = fpu_get_scratch_double(dyn); \
VLD1_64(a, ed); \
@@ -51,7 +49,6 @@
#define PUTEM(a) \
if((nextop&0xC0)!=0xC0) { \
VST1_64(a, ed); \
SMWRITE2(); \
}
uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst, int* ok, int* need_epilog)
@@ -115,7 +112,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
VMOVQ(v0, v1);
} else {
SMREAD();
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-12, 0, 0, NULL);
//LDRD also have alignment requirements
@@ -144,7 +140,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
VMOVfrV_D(x2, x3, v0+1);
STR_IMM9(x2, ed, fixedaddress+8);
STR_IMM9(x3, ed, fixedaddress+12);
SMWRITE2();
}
break;
case 0x12:
@@ -157,7 +152,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
INST_NAME("MOVLPS Gx,Ex");
GETGX(v0, 1);
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-4, 0, 0, NULL);
LDR_IMM9(x2, ed, fixedaddress);
LDR_IMM9(x3, ed, fixedaddress+4);
@@ -176,13 +170,12 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VST1_32(v0, ed); // better to use VST1 than VSTR_64, to avoid NEON->VFPU transfert I assume
SMWRITE2();
} else {
VMOVfrV_D(x2, x3, v0);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-4, 0, 0, NULL);
STR_IMM9(x2, ed, fixedaddress);
STR_IMM9(x3, ed, fixedaddress+4);
SMWRITE2();
}
}
break;
@@ -219,7 +212,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
INST_NAME("MOVHPS Gx,Ex");
GETGX(v0, 1);
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VLD1_64(v0+1, ed);
}
@@ -236,13 +228,12 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VST1_64(v0+1, ed); // better to use VST1 than VSTR_64, to avoid NEON->VFPU transfert I assume
SMWRITE2();
} else {
VMOVfrV_D(x2, x3, v0+1);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-4, 0, 0, NULL);
STR_IMM9(x2, ed, fixedaddress);
STR_IMM9(x3, ed, fixedaddress+4);
SMWRITE2();
}
}
break;
@@ -287,7 +278,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
VMOVQ(v0, v1);
} else {
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VLD1Q_32(v0, ed);
}
@@ -303,7 +293,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VST1Q_32(v0, ed);
SMWRITE2();
}
break;
case 0x2A:
@@ -314,7 +303,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) {
v1 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
v1 = fpu_get_scratch_double(dyn);
VLD1_32(v1, ed);
@@ -342,7 +330,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) {
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
v1 = fpu_get_scratch_double(dyn);
VLD1_32(v1, ed);
@@ -357,7 +344,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) {
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
v1 = fpu_get_scratch_double(dyn);
VLD1_32(v1, ed);
@@ -397,7 +383,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
s0 = d0*2;
} else {
SMREAD();
parity = getedparity(dyn, ninst, addr, nextop, 2);
s0 = fpu_get_scratch_single(dyn);
if(parity) {
@@ -467,7 +452,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) { // reg <= reg
REV(gd, xEAX+(nextop&7));
} else { // mem <= reg
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 4095, 0, 0, NULL);
LDR_IMM9(gd, ed, fixedaddress);
REV(gd, gd);
@@ -483,7 +467,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 4095, 0, 0, NULL);
REV(x1, gd);
STR_IMM9(gd, ed, fixedaddress);
SMWRITE();
}
break;
@@ -525,7 +508,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7); \
MOV_REG_COND(YES, gd, ed); \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 4095, 0, 0, NULL); \
LDR_IMM9_COND(YES, gd, ed, fixedaddress); \
}
@@ -638,7 +620,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
BFI(gd, x3, 3, 1);
} else {
// EX is memory
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4096-16, 0, 0, NULL);
LDR_IMM9(x2, ed, fixedaddress+0);
UBFX(x3, x2, 31, 1);
@@ -1024,7 +1005,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) {
d0 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
d0 = fpu_get_scratch_quad(dyn);
VLD1_16(d0, ed);
@@ -1038,7 +1018,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
if((nextop&0xC0)!=0xC0) {
VST1_16(d0, ed);
SMWRITE2();
}
}
break;
@@ -1047,7 +1026,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) {
d0 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
d0 = fpu_get_scratch_quad(dyn);
VLD1_16(d0, ed);
@@ -1058,7 +1036,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
if((nextop&0xC0)!=0xC0) {
VST1_16(d0, ed);
SMWRITE2();
}
break;
case 6:
@@ -1066,7 +1043,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) {
d0 = mmx_get_reg(dyn, ninst, x1, x2, x3, nextop&7);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
d0 = fpu_get_scratch_quad(dyn);
VLD1_16(d0, ed);
@@ -1080,7 +1056,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
if((nextop&0xC0)!=0xC0) {
VST1_16(d0, ed);
SMWRITE2();
}
}
break;
@@ -1090,7 +1065,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
break;
case 0x72:
nextop = F8;
SMREAD();
GETEM(v0);
switch((nextop>>3)&7) {
case 2:
@@ -1132,7 +1106,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 0x73:
nextop = F8;
GETEM(v0);
SMREAD();
switch((nextop>>3)&7) {
case 2:
INST_NAME("PSRLQ Em, Ib");
@@ -1198,7 +1171,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
VMOVfrDx_32(x2, v0, 0); // there can be some bus error is storing the VFPU reg directly
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095, 0, 0, NULL);
STR_IMM9(x2, ed, fixedaddress);
SMWRITE2();
}
break;
case 0x7F:
@@ -1213,13 +1185,11 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VSTR_64(v0, ed, fixedaddress);
SMWRITE2();
} else {
VMOVfrV_D(x2, x3, v0);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-4, 0, 0, NULL);
STR_IMM9(x2, ed, fixedaddress);
STR_IMM9(x3, ed, fixedaddress+4);
SMWRITE2();
}
}
break;
@@ -1337,7 +1307,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
, cNE, cEQ, X_SF|X_OF|X_ZF)
break;
#undef GO
#define GO(GETFLAGS, NO, YES, F) \
READFLAGS(F); \
GETFLAGS; \
@@ -1352,8 +1321,8 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else { \
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 4095, 0, 0, NULL);\
STRB_IMM9(x3, ed, fixedaddress); \
SMWRITE(); \
}
case 0x90:
INST_NAME("SETO Eb");
GO( TSTS_IMM8_ROR(xFlags, 0b10, 0x0b)
@@ -1474,7 +1443,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x3, &fixedaddress, 4095, 0, 0, NULL);
MOV_REG_ASR_IMM5(x1, gd, 5); // r1 = (gd>>5);
ADD_REG_LSL_IMM5(x1, ed, x1, 2); //(&ed)+=r1*4;
@@ -1531,7 +1499,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
wback = 0;
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095, 0, 0, NULL);
MOV_REG_ASR_IMM5(x1, gd, 5); // r1 = (gd>>5);
ADD_REG_LSL_IMM5(x3, wback, x1, 2); //(&ed)+=r1*4;
@@ -1550,7 +1517,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ORR_REG_LSL_REG(ed, ed, x14, x2);
if(wback) {
STR_IMM9(ed, wback, fixedaddress);
SMWRITE();
}
break;
case 0xAC:
@@ -1578,15 +1544,15 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
// xFENCE -> DMB is approximative, but should be good enough
if((nextop&0xF8)==0xE8) {
INST_NAME("LFENCE");
SMDMB();
DMB_ISH();
} else
if((nextop&0xF8)==0xF0) {
INST_NAME("MFENCE");
SMDMB();
DMB_ISH();
} else
if((nextop&0xF8)==0xF8) {
INST_NAME("SFENCE");
SMDMB();
DMB_ISH();
} else {
switch((nextop>>3)&7) {
case 0:
@@ -1618,12 +1584,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
INST_NAME("LDMXCSR Md");
GETED;
STR_IMM9(ed, xEmu, offsetof(x86emu_t, mxcsr));
if(box86_sse_flushto0) {
VMRS(x14); // get fpscr
MOV_REG_LSR_IMM5(x3, ed, 15); // get FZ bit
BFI(x14, x3, 24, 1); // inject FZ bit
VMSR(x14); // put new fpscr
}
break;
case 3:
INST_NAME("STMXCSR Md");
@@ -1714,7 +1674,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
wback = 0;
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095, 0, 0, NULL);
MOV_REG_ASR_IMM5(x1, gd, 5); // r1 = (gd>>5);
ADD_REG_LSL_IMM5(x3, wback, x1, 2); //(&ed)+=r1*4;
@@ -1733,7 +1692,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
XOR_REG_LSL_REG(ed, ed, x14, x2);
if(wback) {
STR_IMM9(ed, wback, fixedaddress);
SMWRITE();
}
MARK3;
break;
@@ -1748,7 +1706,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
eb2 = (ed&4)>>2; // L or H
UXTB(gd, eb1, eb2);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 4095, 0, 0, NULL);
LDRB_IMM9(gd, ed, fixedaddress);
}
@@ -1761,7 +1718,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
UXTH(gd, ed, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, NULL);
LDRH_IMM8(gd, ed, fixedaddress);
}
@@ -1778,7 +1734,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095, 0, 0, NULL);
LDR_IMM9(x1, wback, fixedaddress);
ed = x1;
@@ -1799,7 +1754,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
wback = 0;
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095, 0, 0, NULL);
LDR_IMM9(x1, wback, fixedaddress);
ed = x1;
@@ -1820,7 +1774,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
XOR_REG_LSL_IMM5(ed, ed, x14, u8);
if(wback) {
STR_IMM9(ed, wback, fixedaddress);
SMWRITE();
}
break;
case 6:
@@ -1831,7 +1784,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
wback = 0;
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095, 0, 0, NULL);
LDR_IMM9(x1, wback, fixedaddress);
ed = x1;
@@ -1852,7 +1804,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
XOR_REG_LSL_IMM5(ed, ed, x14, u8);
if(wback) {
STR_IMM9(ed, wback, fixedaddress);
SMWRITE();
}
break;
case 7:
@@ -1863,7 +1814,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
wback = 0;
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095, 0, 0, NULL);
LDR_IMM9(x1, wback, fixedaddress);
ed = x1;
@@ -1885,7 +1835,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
XOR_REG_LSL_IMM5(ed, ed, x14, u8);
if(wback) {
STR_IMM9(ed, wback, fixedaddress);
SMWRITE();
}
MARK3;
break;
@@ -1903,7 +1852,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
wback = 0;
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095, 0, 0, NULL);
MOV_REG_ASR_IMM5(x1, gd, 5); // r1 = (gd>>5);
ADD_REG_LSL_IMM5(x3, wback, x1, 2); //(&ed)+=r1*4;
@@ -1920,7 +1868,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
XOR_REG_LSL_REG(ed, ed, x14, x2);
if(wback) {
STR_IMM9(ed, wback, fixedaddress);
SMWRITE();
}
break;
case 0xBC:
@@ -1977,7 +1924,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
eb2 = (ed&4)>>2; // L or H
SXTB(gd, eb1, eb2);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, NULL);
LDRSB_IMM8(gd, ed, fixedaddress);
}
@@ -1990,7 +1936,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
SXTH(gd, ed, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, NULL);
LDRSH_IMM8(gd, ed, fixedaddress);
}
@@ -2011,11 +1956,12 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
nextop = F8;
GETGD;
GETED;
MOV_REG(x1, gd);
if(gd!=ed) {
MOV_REG(gd, ed);
XOR_REG_LSL_IMM5(gd, gd, ed, 0); // swap gd, ed
XOR_REG_LSL_IMM5(ed, gd, ed, 0);
XOR_REG_LSL_IMM5(gd, gd, ed, 0);
}
emit_add32(dyn, ninst, ed, x1, x3, x14);
emit_add32(dyn, ninst, ed, gd, x3, x14);
WBACK;
break;
case 0xC2:
@@ -2070,7 +2016,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
VMOVtoDx_16(d0, u8, ed);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 0, 0, 0, NULL);
u8 = (F8)&3;
VLD1LANE_16(d0, wback, u8);
@@ -2085,7 +2030,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
u8 = (F8)&3;
VMOVfrDx_U16(gd, d0, u8);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255-8, 0, 0, NULL);
u8 = (F8)&3;
LDRH_IMM8(gd, wback, fixedaddress+u8*2);
@@ -2099,7 +2043,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETGX(v0, 1);
v2 = fpu_get_scratch_double(dyn);
if((nextop&0xC0)!=0xC0) {
SMREAD();
// from memory
addr = geted(dyn, addr, ninst, nextop, &wback, x1, &fixedaddress, 0, 0, 0, NULL);
u8 = F8;
@@ -2251,7 +2194,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 1:
INST_NAME("CMPXCHG8B Gq, Eq");
SETFLAGS(X_ZF, SF_SUBSET);
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095-4, 0, 0, NULL);
LDR_IMM9(x1, wback, fixedaddress+0);
LDR_IMM9(x2, wback, fixedaddress+4);
@@ -2269,7 +2211,6 @@ uintptr_t dynarec0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOVW(x1, 0);
MARK3;
BFI(xFlags, x1, F_ZF, 1);
SMWRITE();
break;
default:
DEFAULT;
-16
View File
@@ -103,7 +103,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
addr = geted16(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0);
STRH_REG(gd, x14, ed);
SMWRITE2();
}
break;
@@ -115,7 +114,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) { // reg <= reg
MOV_REG(gd, xEAX+(nextop&7));
} else { // mem <= reg
SMREAD();
addr = geted16(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0);
LDR_REG_LSL_IMM5(gd, ed, x14, 0);
}
@@ -131,7 +129,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
addr = geted16(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
POP1(x2);
STR_REG_LSL_IMM5(x2, x1, x14, 0);
SMWRITE2();
}
break;
@@ -143,7 +140,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOV32(x2, u32);
ADD_REG_LSL_IMM5(x1, x1, x2, 0);
}
SMREAD();
LDR_IMM9(xEAX, x1, 0);
break;
@@ -156,7 +152,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ADD_REG_LSL_IMM5(x1, x1, x2, 0);
}
STR_IMM9(xEAX, x1, 0);
SMWRITE2();
break;
case 0xFF:
@@ -168,7 +163,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) { // reg
DEFAULT;
} else { // mem <= i32
SMREAD();
addr = geted16(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0);
LDR_REG_LSL_IMM5(x3, ed, x14, 0);
PUSH1(x3);
@@ -193,7 +187,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else { // mem <= reg
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 0, NULL);
STR_REG_LSL_IMM5(gd, ed, x14, 0);
SMWRITE2();
}
break;
@@ -205,7 +198,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) { // reg <= reg
MOV_REG(gd, xEAX+(nextop&7));
} else { // mem <= reg
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 0, NULL);
LDR_REG_LSL_IMM5(gd, ed, x14, 0);
}
@@ -221,7 +213,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
POP1(x2);
STR_REG_LSL_IMM5(x2, ed, x14, 0);
SMWRITE2();
}
break;
@@ -233,7 +224,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
LDRB_IMM9(xEAX, x1, i32);
} else {
MOV32(x2, i32);
SMREAD();
LDRB_REG_LSL_IMM5(xEAX, x1, x2, 0);
}
break;
@@ -245,7 +235,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
LDR_IMM9(xEAX, x1, i32);
} else {
MOV32(x2, i32);
SMREAD();
LDR_REG_LSL_IMM5(xEAX, x1, x2, 0);
}
break;
@@ -258,7 +247,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
MOV32(x2, i32);
STRB_REG_LSL_IMM5(xEAX, x1, x2, 0);
SMWRITE2();
}
break;
case 0xA3:
@@ -267,11 +255,9 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
i32 = F32S;
if(i32>-4096 && i32<4096) {
STR_IMM9(xEAX, x1, i32);
SMWRITE2();
} else {
MOV32(x2, i32);
STR_REG_LSL_IMM5(xEAX, x2, x1, 0);
SMWRITE2();
}
break;
@@ -297,7 +283,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
i32 = F32S;
MOV32(x3, i32);
STR_REG_LSL_IMM5(x3, ed, x14, 0);
SMWRITE2();
}
break;
@@ -336,7 +321,6 @@ uintptr_t dynarecFS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) { // reg
DEFAULT;
} else { // mem <= i32
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 0, NULL);
LDR_REG_LSL_IMM5(x3, ed, x14, 0);
PUSH1(x3);
+39 -53
View File
@@ -50,7 +50,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETGD;
GETEDO2(x14);
emit_add32(dyn, ninst, ed, gd, x3, x14);
WBACK2;
WBACK;
break;
case 0x03:
@@ -97,7 +97,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETGD;
GETEDO2(x14);
emit_and32(dyn, ninst, ed, gd, x3, x14);
WBACK2;
WBACK;
break;
case 0x23:
@@ -118,7 +118,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETGD;
GETEDO2(x14);
emit_sub32(dyn, ninst, ed, gd, x3, x14);
WBACK2;
WBACK;
break;
case 0x2B:
@@ -139,7 +139,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETGD;
GETEDO2(x14);
emit_xor32(dyn, ninst, gd, ed, x3, x14);
WBACK2;
WBACK;
break;
case 0x33:
@@ -202,7 +202,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEBO(x1);
u8 = F8;
emit_add8c(dyn, ninst, x1, u8, x2, x14);
EBBACK2;
EBBACK;
break;
case 1: //OR
INST_NAME("OR GS:Eb, Ib");
@@ -211,7 +211,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEBO(x1);
u8 = F8;
emit_or8c(dyn, ninst, x1, u8, x2, x14);
EBBACK2;
EBBACK;
break;
case 2: //ADC
INST_NAME("ADC GS:Eb, Ib");
@@ -221,7 +221,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEBO(x1);
u8 = F8;
emit_adc8c(dyn, ninst, x1, u8, x2, x14);
EBBACK2;
EBBACK;
break;
case 3: //SBB
INST_NAME("SBB GS:Eb, Ib");
@@ -231,7 +231,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEBO(x1);
u8 = F8;
emit_sbb8c(dyn, ninst, x1, u8, x2, x14);
EBBACK2;
EBBACK;
break;
case 4: //AND
INST_NAME("AND GS:Eb, Ib");
@@ -240,7 +240,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEBO(x1);
u8 = F8;
emit_and8c(dyn, ninst, x1, u8, x2, x14);
EBBACK2;
EBBACK;
break;
case 5: //SUB
INST_NAME("SUB GS:Eb, Ib");
@@ -249,7 +249,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEBO(x1);
u8 = F8;
emit_sub8c(dyn, ninst, x1, u8, x2, x14);
EBBACK2;
EBBACK;
break;
case 6: //XOR
INST_NAME("XOR GS:Eb, Ib");
@@ -258,7 +258,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEBO(x1);
u8 = F8;
emit_xor8c(dyn, ninst, x1, u8, x2, x14);
EBBACK2;
EBBACK;
break;
case 7: //CMP
INST_NAME("CMP GS:Eb, Ib");
@@ -290,7 +290,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEDO2(x14);
if(opcode==0x81) i32 = F32S; else i32 = F8S;
emit_add32c(dyn, ninst, ed, i32, x3, x14);
WBACK2;
WBACK;
break;
case 1: //OR
if(opcode==0x81) {INST_NAME("OR Ed, Id");} else {INST_NAME("OR Ed, Ib");}
@@ -299,7 +299,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEDO2(x14);
if(opcode==0x81) i32 = F32S; else i32 = F8S;
emit_or32c(dyn, ninst, ed, i32, x3, x14);
WBACK2;
WBACK;
break;
case 2: //ADC
if(opcode==0x81) {INST_NAME("ADC Ed, Id");} else {INST_NAME("ADC Ed, Ib");}
@@ -309,7 +309,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEDO2(x14);
if(opcode==0x81) i32 = F32S; else i32 = F8S;
emit_adc32c(dyn, ninst, ed, i32, x3, x14);
WBACK2;
WBACK;
break;
case 3: //SBB
if(opcode==0x81) {INST_NAME("SBB Ed, Id");} else {INST_NAME("SBB Ed, Ib");}
@@ -319,7 +319,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEDO2(x14);
if(opcode==0x81) i32 = F32S; else i32 = F8S;
emit_sbb32c(dyn, ninst, ed, i32, x3, x14);
WBACK2;
WBACK;
break;
case 4: //AND
if(opcode==0x81) {INST_NAME("AND Ed, Id");} else {INST_NAME("AND Ed, Ib");}
@@ -328,7 +328,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEDO2(x14);
if(opcode==0x81) i32 = F32S; else i32 = F8S;
emit_and32c(dyn, ninst, ed, i32, x3, x14);
WBACK2;
WBACK;
break;
case 5: //SUB
if(opcode==0x81) {INST_NAME("SUB Ed, Id");} else {INST_NAME("SUB Ed, Ib");}
@@ -337,7 +337,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEDO2(x14);
if(opcode==0x81) i32 = F32S; else i32 = F8S;
emit_sub32c(dyn, ninst, ed, i32, x3, x14);
WBACK2;
WBACK;
break;
case 6: //XOR
if(opcode==0x81) {INST_NAME("XOR Ed, Id");} else {INST_NAME("XOR Ed, Ib");}
@@ -346,7 +346,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEDO2(x14);
if(opcode==0x81) i32 = F32S; else i32 = F8S;
emit_xor32c(dyn, ninst, ed, i32, x3, x14);
WBACK2;
WBACK;
break;
case 7: //CMP
if(opcode==0x81) {INST_NAME("CMP Ed, Id");} else {INST_NAME("CMP Ed, Ib");}
@@ -374,7 +374,6 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else { // mem <= reg
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 0, NULL);
STR_REG_LSL_IMM5(gd, ed, x14, 0);
SMWRITE2();
}
break;
@@ -386,7 +385,6 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) { // reg <= reg
MOV_REG(gd, xEAX+(nextop&7));
} else { // mem <= reg
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 0, NULL);
LDR_REG_LSL_IMM5(gd, ed, x14, 0);
}
@@ -402,7 +400,6 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
POP1(x2);
STR_REG_LSL_IMM5(x2, ed, x14, 0);
SMWRITE2();
}
break;
@@ -410,7 +407,6 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
INST_NAME("MOV EAX, GS:Id");
grab_tlsdata(dyn, addr, ninst, x1);
i32 = F32S;
SMREAD();
if(i32>-4096 && i32<4096) {
LDR_IMM9(xEAX, x1, i32);
} else {
@@ -420,16 +416,6 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
break;
case 0xA2:
INST_NAME("MOV GS:Od, AL");
grab_tlsdata(dyn, addr, ninst, x1);
u32 = F32;
MOV32(x2, u32);
ADD_REG_LSL_IMM5(x2, x1, x2, 0);
STRB_IMM9(xEAX, x2, 0);
SMWRITE2();
break;
case 0xA3:
INST_NAME("MOV GS:Od, EAX");
grab_tlsdata(dyn, addr, ninst, x1);
@@ -437,7 +423,6 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOV32(x2, u32);
ADD_REG_LSL_IMM5(x2, x1, x2, 0);
STR_IMM9(xEAX, x2, 0);
SMWRITE2();
break;
case 0xC6:
@@ -456,7 +441,6 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
u8 = F8;
MOVW(x3, u8);
STRB_REG_LSL_IMM5(x3, ed, x14, 0);
SMWRITE2();
}
break;
case 0xC7:
@@ -472,7 +456,6 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
i32 = F32S;
MOV32(x3, i32);
STR_REG_LSL_IMM5(x3, ed, x14, 0);
SMWRITE2();
}
break;
@@ -485,14 +468,14 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SETFLAGS(X_OF|X_CF, SF_SUBSET_PENDING);
GETEDO2(x14);
emit_rol32c(dyn, ninst, ed, 1, x3, x14);
WBACK2;
WBACK;
break;
case 1:
INST_NAME("ROR Ed, 1");
SETFLAGS(X_OF|X_CF, SF_SUBSET_PENDING);
GETEDO2(x14);
emit_ror32c(dyn, ninst, ed, 1, x3, x14);
WBACK2;
WBACK;
break;
case 2:
INST_NAME("RCL Ed, 1");
@@ -501,9 +484,10 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SETFLAGS(X_OF|X_CF, SF_SET);
MOVW(x2, 1);
GETEDO2(x14);
wb = ed;
if(ed!=x1) {MOV_REG(x1, ed); wb = x1;}
CALL_(rcl32, ed, (1<<x2));
WBACK2;
CALL_(rcl32, ed, (1<<x14));
SBACK(wb);
break;
case 3:
INST_NAME("RCR Ed, 1");
@@ -511,9 +495,10 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
READFLAGS(X_CF);
SETFLAGS(X_OF|X_CF, SF_SET);
MOVW(x2, 1);
wb = ed;
if(ed!=x1) {MOV_REG(x1, ed); wb = x1;}
CALL_(rcr32, ed, (1<<x2));
WBACK2;
CALL_(rcr32, ed, (1<<x14));
SBACK(wb);
break;
case 4:
case 6:
@@ -521,21 +506,21 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SETFLAGS(X_ALL, SF_SET_PENDING); // some flags are left undefined
GETEDO2(x14);
emit_shl32c(dyn, ninst, ed, 1, x3, x14);
WBACK2;
WBACK;
break;
case 5:
INST_NAME("SHR Ed, 1");
SETFLAGS(X_ALL, SF_SET_PENDING); // some flags are left undefined
GETEDO2(x14);
emit_shr32c(dyn, ninst, ed, 1, x3, x14);
WBACK2;
WBACK;
break;
case 7:
INST_NAME("SAR Ed, 1");
SETFLAGS(X_ALL, SF_SET_PENDING); // some flags are left undefined
GETEDO2(x14);
emit_sar32c(dyn, ninst, ed, 1, x3, x14);
WBACK2;
WBACK;
break;
}
break;
@@ -552,7 +537,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
RSB_IMM8(x3, x3, 0x20);
GETEDO2(x14);
MOV_REG_ROR_REG(ed, ed, x3);
WBACK2;
WBACK;
UFLAG_IF { // calculate flags directly
CMPS_IMM8(x3, 31);
B_MARK(cNE);
@@ -573,7 +558,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
B_MARK2(cEQ);
GETEDO2(x14);
MOV_REG_ROR_REG(ed, ed, x3);
WBACK2;
WBACK;
UFLAG_IF { // calculate flags directly
CMPS_IMM8(x3, 1);
B_MARK(cNE);
@@ -593,9 +578,10 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
READFLAGS(X_CF);
SETFLAGS(X_OF|X_CF, SF_SET);
AND_IMM8(x2, xECX, 0x1f);
wb = ed;
if(ed!=x1) {MOV_REG(x1, ed); wb = x1;}
CALL_(rcl32, ed, (1<<x2));
WBACK2;
CALL_(rcl32, ed, (1<<x14));
SBACK(wb);
break;
case 3:
INST_NAME("RCR Ed, CL");
@@ -603,9 +589,10 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
READFLAGS(X_CF);
SETFLAGS(X_OF|X_CF, SF_SET);
AND_IMM8(x2, xECX, 0x1f);
wb = ed;
if(ed!=x1) {MOV_REG(x1, ed); wb = x1;}
CALL_(rcr32, ed, (1<<x14));
WBACK2;
SBACK(wb);
break;
case 4:
case 6:
@@ -614,7 +601,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
AND_IMM8(x3, xECX, 0x1f);
GETEDO2(x14);
emit_shl32(dyn, ninst, ed, x3, x3, x14);
WBACK2;
WBACK;
break;
case 5:
INST_NAME("SHR Ed, CL");
@@ -622,7 +609,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
AND_IMM8(x3, xECX, 0x1f);
GETEDO2(x14);
emit_shr32(dyn, ninst, ed, x3, x3, x14);
WBACK2;
WBACK;
break;
case 7:
INST_NAME("SAR Ed, CL");
@@ -631,7 +618,7 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
GETEDO2(x14);
UFLAG_OP12(ed, x3);
MOV_REG_ASR_REG(ed, ed, x3);
WBACK2;
WBACK;
UFLAG_RES(ed);
UFLAG_DF(x3, d_sar32);
break;
@@ -653,7 +640,6 @@ uintptr_t dynarecGS(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) { // reg
DEFAULT;
} else { // mem <= i32
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 0, NULL);
LDR_REG_LSL_IMM5(x3, ed, x14, 0);
PUSH1(x3);
+3 -9
View File
@@ -505,7 +505,7 @@ uintptr_t dynarec66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
break;
case 0x87:
INST_NAME("(LOCK) XCHG Ew, Gw");
INST_NAME("XCHG Ew, Gw");
nextop = F8;
if((nextop&0xC0)==0xC0) {
GETGD;
@@ -518,7 +518,6 @@ uintptr_t dynarec66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
GETGD;
UXTH(x14, gd, 0);
SMDMB();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0, 0, LOCK_LOCK);
#if 0
MARKLOCK;
@@ -532,7 +531,6 @@ uintptr_t dynarec66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
LDRH_IMM8(x1, ed, fixedaddress);
STRH_IMM8(x14, ed, fixedaddress);
#endif
SMDMB();
BFI(gd, x1, 0, 16);
}
break;
@@ -549,7 +547,7 @@ uintptr_t dynarec66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, &lock);
STRH_IMM8(gd, ed, fixedaddress);
SMWRITELOCK(lock);
if(lock) {DMB_ISH();}
}
break;
case 0x8B:
@@ -563,7 +561,7 @@ uintptr_t dynarec66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, &lock);
SMREADLOCK(lock);
if(lock) {DMB_ISH();}
LDRH_IMM8(x1, ed, fixedaddress);
BFI(gd, x1, 0, 16);
}
@@ -579,7 +577,6 @@ uintptr_t dynarec66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, NULL);
STRH_IMM8(x1, ed, fixedaddress);
SMWRITE2();
}
break;
@@ -591,7 +588,6 @@ uintptr_t dynarec66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOV32(x2, offsetof(x86emu_t, segs[(nextop&0x38)>>3]));
STRH_REG(ed, xEmu, x2);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, NULL);
LDRH_IMM8(x1, ed, fixedaddress);
MOV32(x2, offsetof(x86emu_t, segs[(nextop&0x38)>>3]));
@@ -649,7 +645,6 @@ uintptr_t dynarec66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
INST_NAME("MOV, AX, Od");
u32 = F32;
MOV32(x2, u32);
SMREAD();
LDRH_IMM8(x2, x2, 0);
BFI(xEAX, x2, 0, 16);
break;
@@ -658,7 +653,6 @@ uintptr_t dynarec66(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
u32 = F32;
MOV32(x2, u32);
STRH_IMM8(xEAX, x2, 0);
SMWRITE();
break;
case 0xA5:
INST_NAME("MOVSW");
+39 -117
View File
@@ -27,10 +27,9 @@
if((nextop&0xC0)==0xC0) { \
a = sse_get_reg(dyn, ninst, x1, nextop&7, w); \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL); \
a = fpu_get_scratch_quad(dyn); \
VLD1Q_8(a, ed); \
VLD1Q_8(a, ed); \
}
#define GETGX(a, w) \
gd = (nextop&0x38)>>3; \
@@ -71,7 +70,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
VMOVQ(v0, v1);
} else {
SMREAD();
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-12, 0, 0, NULL);
LDR_IMM9(x2, ed, fixedaddress+0);
@@ -98,7 +96,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
VMOVfrV_D(x2, x3, v0+1);
STR_IMM9(x2, ed, fixedaddress+8);
STR_IMM9(x3, ed, fixedaddress+12);
SMWRITE2();
}
break;
case 0x12:
@@ -111,7 +108,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
return addr;
}
parity = getedparity(dyn, ninst, addr, nextop, 3);
SMREAD();
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VLDR_64(v0, ed, fixedaddress);
@@ -141,7 +137,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
STR_IMM9(x2, ed, fixedaddress);
STR_IMM9(x3, ed, fixedaddress+4);
}
SMWRITE2();
break;
case 0x14:
INST_NAME("UNPCKLPD Gx, Ex");
@@ -151,7 +146,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
VMOVD(v0+1, v1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VLDR_64(v0+1, ed, fixedaddress);
}
@@ -165,7 +159,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
VMOVD(v0+1, v1+1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023-4, 3, 0, NULL);
VLDR_64(v0+1, ed, fixedaddress+4);
}
@@ -180,7 +173,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
return addr;
}
parity = getedparity(dyn, ninst, addr, nextop, 3);
SMREAD();
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VLDR_64(v0+1, ed, fixedaddress); // vfpu opcode here
@@ -210,7 +202,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
STR_IMM9(x2, ed, fixedaddress);
STR_IMM9(x3, ed, fixedaddress+4);
}
SMWRITE2();
break;
case 0x1F:
@@ -231,7 +222,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VLD1Q_32(v0, ed);
SMWRITE2();
}
break;
case 0x29:
@@ -245,7 +235,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VST1Q_32(v0, ed);
SMWRITE2();
}
break;
@@ -273,7 +262,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
v0 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VLD1Q_64(q1, ed);
v0 = q1;
@@ -481,7 +469,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) { \
ed = xEAX+(nextop&7); \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, NULL);\
LDRH_IMM8_COND(YES, x1, ed, fixedaddress); \
ed = x1; \
@@ -700,26 +687,8 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
nextop = F8;
GETGX(v0, 1);
GETEX(v1, 0);
if(v0>15)
q0 = fpu_get_scratch_quad(dyn);
else
q0 = v0;
if(v1>15) {
q1 = fpu_get_scratch_quad(dyn);
VMOVQ(q1, v1);
} else
q1 = v1;
// need rounding!
//VCVTQ_S32_F32(v0, v1);
u8 = sse_setround(dyn, ninst, x1, x2, x14);
VCVTR_S32_F32(q0*2+0, q1*2+0);
VCVTR_S32_F32(q0*2+1, q1*2+1);
VCVTR_S32_F32(q0*2+2, q1*2+2);
VCVTR_S32_F32(q0*2+3, q1*2+3);
if(q0!=v0) {
VMOVQ(v0, q0);
}
x87_restoreround(dyn, ninst, u8);
// need rounding?
VCVTQ_S32_F32(v0, v1);
break;
case 0x5C:
INST_NAME("SUBPD Gx, Ex");
@@ -924,7 +893,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
VMOVD(v0+1, v1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VLDR_64(v0+1, ed, fixedaddress);
}
@@ -938,7 +906,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
q1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
VMOVD(q0+1, q1+1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023-8, 3, 0, NULL);
VLDR_64(q0+1, ed, fixedaddress+8);
}
@@ -961,7 +928,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
VMOVQ(v0, v1);
} else {
SMREAD();
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VLD1Q_64(v0, ed);
@@ -1077,7 +1043,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
VMOVQ(v0, q0);
}
} else {
SMREAD();
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
u8 = F8;
@@ -1106,7 +1071,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_16(q0, ed);
@@ -1120,7 +1084,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_16(q0, ed);
SMWRITE2();
}
}
break;
@@ -1129,7 +1092,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_16(q0, ed);
@@ -1140,7 +1102,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_16(q0, ed);
SMWRITE2();
}
break;
case 6:
@@ -1148,7 +1109,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_16(q0, ed);
@@ -1162,7 +1122,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_16(q0, ed);
SMWRITE2();
}
}
break;
@@ -1179,7 +1138,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_32(q0, ed);
@@ -1193,7 +1151,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_32(q0, ed);
SMWRITE2();
}
}
break;
@@ -1202,7 +1159,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_32(q0, ed);
@@ -1213,7 +1169,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_32(q0, ed);
SMWRITE2();
}
break;
case 6:
@@ -1221,7 +1176,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_32(q0, ed);
@@ -1235,7 +1189,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_32(q0, ed);
SMWRITE2();
}
}
break;
@@ -1251,7 +1204,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_64(q0, ed);
@@ -1265,7 +1217,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_64(q0, ed);
SMWRITE2();
}
}
break;
@@ -1274,7 +1225,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_64(q0, ed);
@@ -1290,7 +1240,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_64(q0, ed);
SMWRITE2();
}
}
break;
@@ -1299,7 +1248,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_64(q0, ed);
@@ -1313,7 +1261,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_64(q0, ed);
SMWRITE2();
}
}
break;
@@ -1322,7 +1269,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q0 = sse_get_reg(dyn, ninst, x1, nextop&7, 1);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q0 = fpu_get_scratch_quad(dyn);
VLD1Q_64(q0, ed);
@@ -1338,7 +1284,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
if((nextop&0xC0)!=0xC0) {
VST1Q_64(q0, ed);
SMWRITE2();
}
}
break;
@@ -1380,7 +1325,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
VMOVfrDx_32(x2, v0, 0); // to avoid Bus Error, using regular store
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095, 0, 0, NULL);
STR_IMM9(x2, ed, fixedaddress);
SMWRITE2();
}
break;
case 0x7F:
@@ -1393,7 +1337,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VST1Q_32(v0, ed);
SMWRITE2();
}
break;
@@ -1406,7 +1349,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7); // no need for extract
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x3, &fixedaddress, 255, 0, 0, NULL);
SBFX(x1, gd, 4, 12); // r1 = (gw>>4);
ADD_REG_LSL_IMM5(x1, ed, x1, 1); //(&ed)+=r1*2;
@@ -1449,7 +1391,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
ed = xEAX+(nextop&7);
wback = 0; // no need for extract
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL);
SBFX(x14, gd, 4, 12); // r14 = (gw>>4);
ADD_REG_LSL_IMM5(x3, wback, x14, 1); //(&ew)+=r14*2;
@@ -1466,7 +1407,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
ORR_REG_LSL_REG(ed, ed, x1, x2);
if(wback) {
STRH_IMM8(ed, wback, fixedaddress);
SMWRITE();
}
break;
case 0xAC:
@@ -1519,7 +1459,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
ed = xEAX+(nextop&7);
wback = 0; // no need for extract
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL);
SBFX(x14, gd, 4, 12); // r14 = (gw>>4);
ADD_REG_LSL_IMM5(x3, wback, x14, 1); //(&ew)+=r14*2;
@@ -1536,7 +1475,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
XOR_REG_LSL_REG(ed, ed, x1, x2);
if(wback) {
STRH_IMM8(ed, wback, fixedaddress);
SMWRITE();
}
break;
@@ -1550,7 +1488,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
eb2 = (ed&4)>>2; // L or H
UXTB(x1, eb1, eb2);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 4095, 0, 0, NULL);
LDRB_IMM9(x1, ed, fixedaddress);
}
@@ -1564,7 +1501,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
ed = xEAX + (nextop&7);
UXTH(x1, ed, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, NULL);
LDRH_IMM8(x1, ed, fixedaddress);
}
@@ -1581,7 +1517,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL);
LDRH_IMM8(x1, wback, fixedaddress);
ed = x1;
@@ -1602,7 +1537,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
ed = xEAX+(nextop&7);
wback = 0;
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL);
LDRH_IMM8(x1, wback, fixedaddress);
ed = x1;
@@ -1621,7 +1555,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
XOR_REG_LSL_IMM5(ed, ed, x14, u8);
if(wback) {
STRH_IMM8(ed, wback, fixedaddress);
SMWRITE();
}
MARK3;
break;
@@ -1633,7 +1566,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
ed = xEAX+(nextop&7);
wback = 0;
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL);
LDRH_IMM8(x1, wback, fixedaddress);
ed = x1;
@@ -1652,7 +1584,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
XOR_REG_LSL_IMM5(ed, ed, x14, u8);
if(wback) {
STRH_IMM8(ed, wback, fixedaddress);
SMWRITE();
}
MARK3;
break;
@@ -1664,7 +1595,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
ed = xEAX+(nextop&7);
wback = 0;
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL);
LDRH_IMM8(x1, wback, fixedaddress);
ed = x1;
@@ -1682,7 +1612,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
XOR_REG_LSL_IMM5(ed, ed, x14, u8);
if(wback) {
STRH_IMM8(ed, wback, fixedaddress);
SMWRITE();
}
MARK3;
break;
@@ -1700,7 +1629,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
ed = xEAX+(nextop&7);
wback = 0; // no need for extract
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL);
SBFX(x14, gd, 4, 12); // r14 = (gw>>4);
ADD_REG_LSL_IMM5(x3, wback, x14, 1); //(&ew)+=r14*2;
@@ -1715,7 +1643,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
XOR_REG_LSL_REG(ed, ed, x1, x2);
if(wback) {
STRH_IMM8(ed, wback, fixedaddress);
SMWRITE();
}
break;
case 0xBC:
@@ -1761,7 +1688,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
eb2 = (ed&4)>>2; // L or H
SXTB(x1, eb1, eb2);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 255, 0, 0, NULL);
LDRSB_IMM8(x1, ed, fixedaddress);
}
@@ -1833,7 +1759,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
ed = xEAX+(nextop&7);
VMOVtoDx_16(v0+(u8/4), u8&3, ed);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 0, 0, 0, NULL);
u8 = (F8)&7;
VLD1LANE_16(v0+(u8/4), wback, u8&3);
@@ -1848,7 +1773,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
u8 = (F8)&7;
VMOVfrDx_U16(gd, v0+(u8/4), (u8&3));
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255-14, 0, 0, NULL);
u8 = (F8)&7;
LDRH_IMM8(gd, wback, fixedaddress+u8*2);
@@ -1906,11 +1830,8 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
GETGX(q0, 1);
GETEX(q1, 0);
v0 = fpu_get_scratch_quad(dyn);
VQMOVN_S64(v0, q1);
VQMOVN_S32(v0, v0);
VQMOVN_S16(v0, v0);
VDUPQ_8(v0, v0, 0); // only 8 bits are taken
VNEGNQ_8(v0, v0); // because we want SHR and not SHL
VDUPQ_16(v0, q1, 0);
VNEGNQ_16(v0, v0); // because we want SHR and not SHL
VSHLQ_U16(q0, q0, v0);
break;
case 0xD2:
@@ -1919,11 +1840,11 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
GETGX(q0, 1);
GETEX(q1, 0);
v0 = fpu_get_scratch_quad(dyn);
VQMOVN_S64(v0, q1);
VQMOVN_S32(v0, v0);
VQMOVN_S16(v0, v0);
VDUPQ_8(v0, v0, 0); // only 8 bits are taken
VNEGNQ_8(v0, v0); // because we want SHR and not SHL
VMOVD(v0, q1);
VMOVD(v0+1, q1);
VQMOVN_S64(v0, v0); // 2*q1 in 32bits now
VNEGN_32(v0, v0); // because we want SHR and not SHL
VMOVD(v0+1, v0);
VSHLQ_U32(q0, q0, v0);
break;
case 0xD3:
@@ -1932,11 +1853,11 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
GETGX(q0, 1);
GETEX(q1, 0);
v0 = fpu_get_scratch_quad(dyn);
VQMOVN_S64(v0, q1);
VQMOVN_S32(v0, v0);
VQMOVN_S16(v0, v0);
VDUPQ_8(v0, v0, 0); // only 8 bits are taken
VNEGNQ_8(v0, v0); // because we want SHR and not SHL
VMOVD(v0, q1);
VMOVD(v0+1, q1);
VQMOVN_S64(v0, v0); // 2*q1 in 32bits now
VNEGN_32(v0, v0); // because we want SHR and not SHL
VMOVL_S32(v0, v0); // 2*q1 in 64 bits now
VSHLQ_U64(q0, q0, v0);
break;
case 0xD4:
@@ -1973,7 +1894,6 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
STR_IMM9(x2, ed, fixedaddress+0);
STR_IMM9(x3, ed, fixedaddress+4);
}
SMWRITE2();
}
break;
case 0xD7:
@@ -2079,11 +1999,13 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
GETGX(q0, 1);
GETEX(q1, 0);
v0 = fpu_get_scratch_quad(dyn);
VQMOVN_S64(v0, q1);
VQMOVN_S32(v0, v0);
VQMOVN_S16(v0, v0);
VDUPQ_8(v0, v0, 0); // only 8 bits are taken
VNEGNQ_8(v0, v0); // because we want SHR and not SHL
VMOVD(v0, q1);
VMOVD(v0+1, q1);
VQMOVN_S64(v0, v0); // 2*q1 in 32bits now
VMOVD(v0+1, v0);
VQMOVN_S32(v0, v0); // 4*q1 in 16bits now
VNEGN_16(v0, v0); // because we want SHR and not SHL
VMOVD(v0+1, v0);
VSHLQ_S16(q0, q0, v0);
break;
case 0xE2:
@@ -2092,11 +2014,11 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
GETGX(q0, 1);
GETEX(q1, 0);
v0 = fpu_get_scratch_quad(dyn);
VQMOVN_S64(v0, q1);
VQMOVN_S32(v0, v0);
VQMOVN_S16(v0, v0);
VDUPQ_8(v0, v0, 0); // only 8 bits are taken
VNEGNQ_8(v0, v0); // because we want SHR and not SHL
VMOVD(v0, q1);
VMOVD(v0+1, q1);
VQMOVN_S64(v0, v0); // 2*q1 in 32bits now
VNEGN_32(v0, v0); // because we want SHR and not SHL
VMOVD(v0+1, v0);
VSHLQ_S32(q0, q0, v0);
break;
case 0xE3:
@@ -2226,10 +2148,12 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
GETGX(q0, 1);
GETEX(q1, 0);
v0 = fpu_get_scratch_quad(dyn);
VQMOVN_S64(v0, q1);
VQMOVN_S32(v0, v0);
VQMOVN_S16(v0, v0);
VDUPQ_8(v0, v0, 0); // only 8 bits are taken
VMOVD(v0, q1);
VMOVD(v0+1, q1);
VQMOVN_S64(v0, v0); // 2*q1 in 32bits now
VMOVD(v0+1, v0);
VQMOVN_S32(v0, v0); // 4*q1 in 16bits now
VMOVD(v0+1, v0);
VSHLQ_U16(q0, q0, v0);
break;
case 0xF2:
@@ -2238,10 +2162,10 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
GETGX(q0, 1);
GETEX(q1, 0);
v0 = fpu_get_scratch_quad(dyn);
VQMOVN_S64(v0, q1);
VQMOVN_S32(v0, v0);
VQMOVN_S16(v0, v0);
VDUPQ_8(v0, v0, 0); // only 8 bits are taken
VMOVD(v0, q1);
VMOVD(v0+1, q1);
VQMOVN_S64(v0, v0); // 2*q1 in 32bits now
VMOVD(v0+1, v0);
VSHLQ_U32(q0, q0, v0);
break;
case 0xF3:
@@ -2250,10 +2174,8 @@ uintptr_t dynarec660F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
GETGX(q0, 1);
GETEX(q1, 0);
v0 = fpu_get_scratch_quad(dyn);
VQMOVN_S64(v0, q1);
VQMOVN_S32(v0, v0);
VQMOVN_S16(v0, v0);
VDUPQ_8(v0, v0, 0); // only 8 bits are taken
VMOVD(v0, q1);
VMOVD(v0+1, q1);
VSHLQ_U64(q0, q0, v0);
break;
case 0xF4:
+9 -9
View File
@@ -41,7 +41,7 @@ uintptr_t dynarec66F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
case 0x81:
case 0x83:
nextop = F8;
SMDMB();
DMB_ISH();
switch((nextop>>3)&7) {
case 0: //ADD
if(opcode==0x81) {
@@ -50,7 +50,7 @@ uintptr_t dynarec66F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
INST_NAME("LOCK ADD Ew, Ib");
}
SETFLAGS(X_ALL, SF_SET_PENDING);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
if(opcode==0x81) i16 = F16S; else i16 = F8S;
ed = xEAX+(nextop&7);
@@ -71,7 +71,7 @@ uintptr_t dynarec66F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
B_MARKLOCK(cNE);
}
if(!fixedaddress) {
SMDMB();
DMB_ISH();
B_NEXT(c__);
}
if(!fixedaddress || (fixedaddress && (fixedaddress&1))) {
@@ -85,17 +85,17 @@ uintptr_t dynarec66F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
B_MARK(cNE);
STRH_IMM8(x1, wback, 0); // put the whole value
}
SMDMB();
DMB_ISH();
}
break;
default:
DEFAULT;
}
SMDMB();
DMB_ISH();
break;
case 0xFF:
nextop = F8;
SMDMB();
DMB_ISH();
switch((nextop>>3)&7)
{
case 0: // INC Ew
@@ -120,7 +120,7 @@ uintptr_t dynarec66F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
B_MARKLOCK(cNE);
}
if(!fixedaddress) {
SMDMB();
DMB_ISH();
B_NEXT(c__);
}
if(!fixedaddress || (fixedaddress && (fixedaddress&1))) {
@@ -158,7 +158,7 @@ uintptr_t dynarec66F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
B_MARKLOCK(cNE);
}
if(!fixedaddress) {
SMDMB();
DMB_ISH();
B_NEXT(c__);
}
if(!fixedaddress || (fixedaddress && (fixedaddress&3))) {
@@ -178,7 +178,7 @@ uintptr_t dynarec66F0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
// default to NO LOCK
addr-=2;
}
SMDMB();
DMB_ISH();
break;
default:
DEFAULT;
-6
View File
@@ -58,7 +58,6 @@ uintptr_t dynarec67(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
addr = geted16(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0);
STRH_REG(gd, x14, ed);
SMWRITE2();
}
break;
@@ -73,7 +72,6 @@ uintptr_t dynarec67(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
BFI(gd, ed, 0, 16);
}
} else { // mem <= reg
SMREAD();
addr = geted16(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0);
LDR_REG_LSL_IMM5(gd, x14, ed, 0);
}
@@ -89,7 +87,6 @@ uintptr_t dynarec67(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
addr = geted16(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0);
POP1(x2);
STR_REG_LSL_IMM5(x2, x14, ed, 0);
SMWRITE2();
}
break;
@@ -101,7 +98,6 @@ uintptr_t dynarec67(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOV32(x2, u32);
ADD_REG_LSL_IMM5(x1, x1, x2, 0);
}
SMREAD();
LDR_IMM9(xEAX, x1, 0);
break;
@@ -114,7 +110,6 @@ uintptr_t dynarec67(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ADD_REG_LSL_IMM5(x1, x1, x2, 0);
}
STR_IMM9(xEAX, x1, 0);
SMWRITE2();
break;
case 0xFF:
@@ -126,7 +121,6 @@ uintptr_t dynarec67(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
if((nextop&0xC0)==0xC0) { // reg
DEFAULT;
} else { // mem <= i32
SMREAD();
addr = geted16(dyn, addr, ninst, nextop, &ed, x2, &fixedaddress, 0, 0);
LDR_REG_LSL_IMM5(x3, ed, x14, 0);
PUSH1(x3);
+88 -108
View File
@@ -223,7 +223,7 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 2:
INST_NAME("FIST Ed, ST0");
v1 = x87_get_st(dyn, ninst, x1, x2, 0, NEON_CACHE_ST_D);
u8 = x87_setround_reset(dyn, ninst, x1, x2, x14); // x1 have the modified RPSCR reg
u8 = x87_setround(dyn, ninst, x1, x2, x14); // x1 have the modified RPSCR reg
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
wback = 0;
@@ -233,6 +233,10 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
s0 = fpu_get_scratch_single(dyn);
MSR_nzcvq_0();
// x1 already have FPCSR reg to clear exceptions flags
ORR_IMM8(x3, x1, 0b010, 9); // enable exceptions
BIC_IMM8(x3, x3, 0b10011111, 0);
VMSR(x3);
VCVTR_S32_F64(s0, v1);
VMRS(x3); // get the FPCSR reg and test FPU execption (invalid operation only)
VMOVfrV(ed, s0);
@@ -244,7 +248,7 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 3:
INST_NAME("FISTP Ed, ST0");
v1 = x87_get_st(dyn, ninst, x1, x2, 0, NEON_CACHE_ST_D);
u8 = x87_setround_reset(dyn, ninst, x1, x2, x14); // x1 have the modified RPSCR reg
u8 = x87_setround(dyn, ninst, x1, x2, x14); // x1 have the modified RPSCR reg
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
wback = 0;
@@ -254,6 +258,10 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
s0 = fpu_get_scratch_single(dyn);
MSR_nzcvq_0();
// The FPCSR reg to clear exceptions flags
ORR_IMM8(x3, x1, 0b010, 9); // enable exceptions
BIC_IMM8(x3, x3, 0b10011111, 0);
VMSR(x3);
VCVTR_S32_F64(s0, v1);
VMRS(x3); // get the FPCSR reg and test FPU execption (denormal and overflow only)
VMOVfrV(ed, s0);
@@ -279,89 +287,17 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
STR_IMM9(x2, ed, 0);
STR_IMM9(x3, ed, 4);
STRH_IMM8(x14, ed, 8);
} else {
if(box86_x87_no80bits) {
v1 = x87_do_push(dyn, ninst, x1, NEON_CACHE_ST_D);
parity = getedparity(dyn, ninst, addr, nextop, 3);
if (parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VLDR_64(v1, ed, fixedaddress);
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-4, 0, 0, NULL);
LDR_IMM9(x2, ed, fixedaddress);
LDR_IMM9(x3, ed, fixedaddress + 4);
VMOVtoV_D(v1, x2, x3);
}
} else {
#if 0
MESSAGE(LOG_DUMP, "Need Optimization\n");
if(ed!=x1) {
MOV_REG(x1, ed);
}
x87_do_push_empty(dyn, ninst, x3);
CALL(arm_fld, -1, 0);
#else
v1 = x87_do_push(dyn, ninst, x2, NEON_CACHE_ST_D);
// copy 10bytes of *ED to STld(0)
LDR_IMM9(x3, xEmu, offsetof(x86emu_t, top));
int a = -dyn->n.x87stack;
if(a) {
if(a<0) {
SUB_IMM8(x3, x3, -a);
} else {
ADD_IMM8(x3, x3, a);
}
AND_IMM8(x3, x3, 7);
}
ADD_IMM8(x2, xEmu, offsetof(x86emu_t, fpu_ld)+offsetof(fpu_ld_t, ld));
MOVW(x14, sizeof(fpu_ld_t));
MLA(x2, x3, x14, x2);
LDR_IMM9(x14, ed, 0);
STR_IMM9(x14, x2, 0);
LDR_IMM9(x14, ed, 4);
STR_IMM9(x14, x2, 4);
LDRH_IMM8(x14, ed, 8);
STRH_IMM8(x14, x2, 8);
// convert 10bytes -> double
CALL_1RD(FromLD, ed, x2, (1<<x3)|(1<<xFlags)|(1<<x2));
// store ref to STld(0).uref, but can be unaligned...
VMOVfrV_D(x3, x14, 0);
// also, store result to ST0
VMOVD(v1, 0);
STR_IMM9(x3, x2, offsetof(fpu_ld_t, uref)-offsetof(fpu_ld_t, ld));
STR_IMM9(x14, x2, offsetof(fpu_ld_t, uref)-offsetof(fpu_ld_t, ld)+4);
#endif
}
}
break;
case 7:
INST_NAME("FSTP tbyte");
if(box86_x87_no80bits) {
v1 = x87_get_st(dyn, ninst, x1, x2, 0, NEON_CACHE_ST_D);
parity = getedparity(dyn, ninst, addr, nextop, 3);
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VSTR_64(v1, ed, fixedaddress);
} else {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-4, 0, 0, NULL);
VMOVfrV_D(x2, x3, v1);
STR_IMM9(x2, ed, fixedaddress);
STR_IMM9(x3, ed, fixedaddress+4);
}
} else {
#if 0
MESSAGE(LOG_DUMP, "Need Optimization\n");
x87_forget(dyn, ninst, x1, x3, 0);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
if(ed!=x1) {
MOV_REG(x1, ed);
}
CALL(arm_fstp, -1, 0);
x87_do_push_empty(dyn, ninst, x3);
CALL(arm_fld, -1, 0);
#else
v1 = x87_get_st(dyn, ninst, x1, x2, 0, NEON_CACHE_ST_D);
v2 = fpu_get_scratch_double(dyn);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
// get top in x3
v1 = x87_do_push(dyn, ninst, x2, NEON_CACHE_ST_D);
// copy 10bytes of *ED to STld(0)
LDR_IMM9(x3, xEmu, offsetof(x86emu_t, top));
int a = -dyn->n.x87stack;
if(a) {
@@ -372,41 +308,85 @@ uintptr_t dynarecDB(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
AND_IMM8(x3, x3, 7);
}
// get STld(0)
ADD_IMM8(x2, xEmu, offsetof(x86emu_t, fpu_ld)+offsetof(fpu_ld_t, ld));
MOVW(x14, sizeof(fpu_ld_t));
MLA(x2, x3, x14, x2);
// compare uref with actual value, top is not used anymore, so x3 is free
LDR_IMM9(x14, x2, offsetof(fpu_ld_t, uref)-offsetof(fpu_ld_t, ld));
LDR_IMM9(x3, x2, offsetof(fpu_ld_t, uref)-offsetof(fpu_ld_t, ld)+4);
VMOVtoV_D(v2, x14, x3);
VCEQ_32(v2, v2, v1); // same?
VMOVfrV_D(x14, x3, v2);
TSTS_REG_LSL_IMM5(x14, x3, 0);
B_MARK(cEQ); // different, do the conversion
// same... copy STld(0).ld
LDR_IMM9(x14, x2, 0);
LDR_IMM9(x3, x2, 4);
STR_IMM9(x14, ed, 0);
STR_IMM9(x3, ed, 4);
LDRH_IMM8(x14, x2, 8);
STRH_IMM8(x14, ed, 8);
B_MARK2(c__);
MARK;
// different, call D2LD
SUB_IMM8(xSP, xSP, 8);
VSTR_64(v1, xSP, 0);
PUSH(xSP, (1<<xEmu)|(1<<xFlags));
ADD_IMM8(0, xSP, 8); //1st arg is &d
if(ed!=x1) {
MOV_REG_LSL_IMM5(x1, ed, 0); //2nd arg is ed
}
CALL_S(D2LD, -2, 0);
POP(xSP, (1<<xEmu)|(1<<xFlags));
ADD_IMM8(xSP, xSP, 8);
MARK2;
LDR_IMM9(x14, ed, 0);
STR_IMM9(x14, x2, 0);
LDR_IMM9(x14, ed, 4);
STR_IMM9(x14, x2, 4);
LDRH_IMM8(x14, ed, 8);
STRH_IMM8(x14, x2, 8);
// convert 10bytes -> double
CALL_1RD(FromLD, ed, x2, (1<<x3)|(1<<xFlags)|(1<<x2));
// store ref to STld(0).uref, but can be unaligned...
VMOVfrV_D(x3, x14, 0);
// also, store result to ST0
VMOVD(v1, 0);
STR_IMM9(x3, x2, offsetof(fpu_ld_t, uref)-offsetof(fpu_ld_t, ld));
STR_IMM9(x14, x2, offsetof(fpu_ld_t, uref)-offsetof(fpu_ld_t, ld)+4);
#endif
}
break;
case 7:
INST_NAME("FSTP tbyte");
#if 0
MESSAGE(LOG_DUMP, "Need Optimization\n");
x87_forget(dyn, ninst, x1, x3, 0);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
if(ed!=x1) {
MOV_REG(x1, ed);
}
CALL(arm_fstp, -1, 0);
#else
v1 = x87_get_st(dyn, ninst, x1, x2, 0, NEON_CACHE_ST_D);
v2 = fpu_get_scratch_double(dyn);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
// get top in x3
LDR_IMM9(x3, xEmu, offsetof(x86emu_t, top));
int a = -dyn->n.x87stack;
if(a) {
if(a<0) {
SUB_IMM8(x3, x3, -a);
} else {
ADD_IMM8(x3, x3, a);
}
AND_IMM8(x3, x3, 7);
}
// get STld(0)
ADD_IMM8(x2, xEmu, offsetof(x86emu_t, fpu_ld)+offsetof(fpu_ld_t, ld));
MOVW(x14, sizeof(fpu_ld_t));
MLA(x2, x3, x14, x2);
// compare uref with actual value, top is not used anymore, so x3 is free
LDR_IMM9(x14, x2, offsetof(fpu_ld_t, uref)-offsetof(fpu_ld_t, ld));
LDR_IMM9(x3, x2, offsetof(fpu_ld_t, uref)-offsetof(fpu_ld_t, ld)+4);
VMOVtoV_D(v2, x14, x3);
VCEQ_32(v2, v2, v1); // same?
VMOVfrV_D(x14, x3, v2);
TSTS_REG_LSL_IMM5(x14, x3, 0);
B_MARK(cEQ); // different, do the conversion
// same... copy STld(0).ld
LDR_IMM9(x14, x2, 0);
LDR_IMM9(x3, x2, 4);
STR_IMM9(x14, ed, 0);
STR_IMM9(x3, ed, 4);
LDRH_IMM8(x14, x2, 8);
STRH_IMM8(x14, ed, 8);
B_MARK2(c__);
MARK;
// different, call D2LD
SUB_IMM8(xSP, xSP, 8);
VSTR_64(v1, xSP, 0);
PUSH(xSP, (1<<xEmu)|(1<<xFlags));
ADD_IMM8(0, xSP, 8); //1st arg is &d
if(ed!=x1) {
MOV_REG_LSL_IMM5(x1, ed, 0); //2nd arg is ed
}
CALL_S(D2LD, -2, 0);
POP(xSP, (1<<xEmu)|(1<<xFlags));
ADD_IMM8(xSP, xSP, 8);
MARK2;
#endif
x87_do_pop(dyn, ninst, x3);
break;
default:
+10 -2
View File
@@ -203,11 +203,15 @@ uintptr_t dynarecDF(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 2:
INST_NAME("FIST Ew, ST0");
v1 = x87_get_st(dyn, ninst, x1, x2, 0, NEON_CACHE_ST_F);
u8 = x87_setround_reset(dyn, ninst, x1, x2, x14);
u8 = x87_setround(dyn, ninst, x1, x2, x14);
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, 255, 0, 0, NULL);
ed = x1;
s0 = fpu_get_scratch_single(dyn);
MSR_nzcvq_0();
// x1 already have FPCSR reg to clear exceptions flags
ORR_IMM8(x3, x1, 0b010, 9); // enable exceptions
BIC_IMM8(x3, x3, 0b10011111, 0);
VMSR(x3);
if(ST_IS_F(0)) {
VCVTR_S32_F32(s0, v1);
} else {
@@ -225,11 +229,15 @@ uintptr_t dynarecDF(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 3:
INST_NAME("FISTP Ew, ST0");
v1 = x87_get_st(dyn, ninst, x1, x2, 0, NEON_CACHE_ST_F);
u8 = x87_setround_reset(dyn, ninst, x1, x2, x14);
u8 = x87_setround(dyn, ninst, x1, x2, x14);
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, 255, 0, 0, NULL);
ed = x1;
s0 = fpu_get_scratch_single(dyn);
MSR_nzcvq_0();
// x1 already have FPCSR reg to clear exceptions flags
ORR_IMM8(x3, x1, 0b010, 9); // enable exceptions
BIC_IMM8(x3, x3, 0b10011111, 0);
VMSR(x3);
if(ST_IS_F(0)) {
VCVTR_S32_F32(s0, v1);
} else {
+69 -69
View File
@@ -42,7 +42,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGB(x2);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
wback = (nextop&7);
wb2 = (wback>>2);
@@ -59,14 +59,14 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE); // write failed, try again
}
SMDMB();
DMB_ISH();
break;
case 0x01:
INST_NAME("LOCK ADD Ed, Gd");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
emit_add32(dyn, ninst, ed, gd, x3, x14);
@@ -79,13 +79,13 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 0x08:
INST_NAME("LOCK OR Eb, Gb");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
GETGB(x2);
wback = (nextop&7);
@@ -104,14 +104,14 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE); // write failed, try again
}
SMDMB();
DMB_ISH();
break;
case 0x09:
INST_NAME("LOCK OR Ed, Gd");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
emit_or32(dyn, ninst, ed, gd, x3, x14);
@@ -124,7 +124,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 0x10:
INST_NAME("LOCK ADC Eb, Gb");
@@ -132,7 +132,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGB(x2);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
wback = (nextop&7);
wb2 = (wback>>2);
@@ -149,7 +149,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE); // write failed, try again
}
SMDMB();
DMB_ISH();
break;
case 0x11:
INST_NAME("LOCK ADC Ed, Gd");
@@ -157,7 +157,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
emit_adc32(dyn, ninst, ed, gd, x3, x14);
@@ -170,7 +170,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 0x18:
INST_NAME("LOCK SBB Eb, Gb");
@@ -178,7 +178,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGB(x2);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
wback = (nextop&7);
wb2 = (wback>>2);
@@ -195,7 +195,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE); // write failed, try again
}
SMDMB();
DMB_ISH();
break;
case 0x19:
INST_NAME("LOCK SBB Ed, Gd");
@@ -203,7 +203,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
emit_sbb32(dyn, ninst, ed, gd, x3, x14);
@@ -216,13 +216,13 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 0x20:
INST_NAME("LOCK AND Eb, Gb");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
GETGB(x2);
wback = (nextop&7);
@@ -241,14 +241,14 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE); // write failed, try again
}
SMDMB();
DMB_ISH();
break;
case 0x21:
INST_NAME("LOCK AND Ed, Gd");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
emit_and32(dyn, ninst, ed, gd, x3, x14);
@@ -261,14 +261,14 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 0x28:
INST_NAME("LOCK SUB Eb, Gb");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGB(x2);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
wback = (nextop&7);
wb2 = (wback>>2);
@@ -285,14 +285,14 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE); // write failed, try again
}
SMDMB();
DMB_ISH();
break;
case 0x29:
INST_NAME("LOCK SUB Ed, Gd");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
emit_sub32(dyn, ninst, ed, gd, x3, x14);
@@ -305,13 +305,13 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 0x38:
INST_NAME("LOCK XOR Eb, Gb");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
GETGB(x2);
wback = (nextop&7);
@@ -330,14 +330,14 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE); // write failed, try again
}
SMDMB();
DMB_ISH();
break;
case 0x39:
INST_NAME("LOCK XOR Ed, Gd");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
emit_xor32(dyn, ninst, ed, gd, x3, x14);
@@ -350,7 +350,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 0x66:
@@ -368,7 +368,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
INST_NAME("LOCK ADD Ed, Ib");
}
SETFLAGS(X_ALL, SF_SET_PENDING);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
if(opcode==0x81) i32 = F32S; else i32 = F8S;
ed = xEAX+(nextop&7);
@@ -389,7 +389,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
B_MARKLOCK(cNE);
}
if(!fixedaddress) {
SMDMB();
DMB_ISH();
B_NEXT(c__);
}
if(!fixedaddress || (fixedaddress && (fixedaddress&3))) {
@@ -403,13 +403,13 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
B_MARK(cNE);
STR_IMM9(x1, wback, 0); // put the whole value
}
SMDMB();
DMB_ISH();
}
break;
case 1: //OR
if(opcode==0x81) {INST_NAME("LOCK OR Ed, Id");} else {INST_NAME("LOCK OR Ed, Ib");}
SETFLAGS(X_ALL, SF_SET_PENDING);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
if(opcode==0x81) i32 = F32S; else i32 = F8S;
ed = xEAX+(nextop&7);
@@ -424,13 +424,13 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 2: //ADC
if(opcode==0x81) {INST_NAME("LOCK ADC Ed, Id");} else {INST_NAME("LOCK ADC Ed, Ib");}
READFLAGS(X_CF);
SETFLAGS(X_ALL, SF_SET_PENDING);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
if(opcode==0x81) i32 = F32S; else i32 = F8S;
ed = xEAX+(nextop&7);
@@ -445,13 +445,13 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 3: //SBB
if(opcode==0x81) {INST_NAME("LOCK SBB Ed, Id");} else {INST_NAME("LOCK SBB Ed, Ib");}
READFLAGS(X_CF);
SETFLAGS(X_ALL, SF_SET_PENDING);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
if(opcode==0x81) i32 = F32S; else i32 = F8S;
ed = xEAX+(nextop&7);
@@ -466,12 +466,12 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 4: //AND
if(opcode==0x81) {INST_NAME("LOCK AND Ed, Id");} else {INST_NAME("LOCK AND Ed, Ib");}
SETFLAGS(X_ALL, SF_SET_PENDING);
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
if(opcode==0x81) i32 = F32S; else i32 = F8S;
ed = xEAX+(nextop&7);
@@ -486,7 +486,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 5: //SUB
if(opcode==0x81) {INST_NAME("LOCK SUB Ed, Id");} else {INST_NAME("LOCK SUB Ed, Ib");}
@@ -496,7 +496,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
emit_sub32c(dyn, ninst, ed, i32, x3, x14);
} else {
SMDMB();
DMB_ISH();
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, 0, 0, 1, LOCK_LOCK);
if(opcode==0x81) i32 = F32S; else i32 = F8S;
if(!fixedaddress) {
@@ -512,7 +512,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
B_MARKLOCK(cNE);
}
if(!fixedaddress) {
SMDMB();
DMB_ISH();
B_NEXT(c__);
}
if(!fixedaddress || (fixedaddress && (fixedaddress&3))) {
@@ -526,7 +526,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
B_MARK(cNE);
STR_IMM9(x1, wback, 0); // put the whole value
}
SMDMB();
DMB_ISH();
}
break;
case 6: //XOR
@@ -537,7 +537,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
ed = xEAX+(nextop&7);
emit_xor32c(dyn, ninst, ed, i32, x3, x14);
} else {
SMDMB();
DMB_ISH();
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, 0, 0, 0, LOCK_LOCK);
if(opcode==0x81) i32 = F32S; else i32 = F8S;
MARKLOCK;
@@ -546,13 +546,13 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
STREX(x3, x1, wback);
CMPS_IMM8(x3, 0);
B_MARKLOCK(cNE);
SMDMB();
DMB_ISH();
}
break;
case 7: //CMP
if(opcode==0x81) {INST_NAME("(LOCK) CMP Ed, Id");} else {INST_NAME("(LOCK) CMP Ed, Ib");}
SETFLAGS(X_ALL, SF_SET_PENDING);
SMDMB();
DMB_ISH();
GETEDH(x1);
// No need to LOCK, this is readonly
if(opcode==0x81) i32 = F32S; else i32 = F8S;
@@ -582,7 +582,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
#undef GO
case 0x86: // for this two, the lock is already done by the opcode, so just ignoring it
case 0x87:
SMDMB();
DMB_ISH();
--addr;
break;
case 0x90: // This is xchg reg, reg, so let's ignore the LOCK prefix...
@@ -593,7 +593,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 0x95:
case 0x96:
case 0x97:
SMDMB();
DMB_ISH();
--addr;
break;
@@ -603,7 +603,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 0xB0:
INST_NAME("LOCK CMPXCHG Eb, Gb");
SETFLAGS(X_ALL, SF_SET_PENDING);
SMDMB();
DMB_ISH();
nextop = F8;
if((nextop&0xC0)==0xC0) {
wback = (nextop&7);
@@ -640,7 +640,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
// AL != Eb
BFI(xEAX, ed, 0, 8);
MARK3;
SMDMB();
DMB_ISH();
// done, do the cmp now
UFLAG_IF {emit_cmp8(dyn, ninst, x1, x2, x3, x14);}
break;
@@ -649,7 +649,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
// same as no lock, all in regs...
@@ -679,7 +679,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
B_MARK(cNE);
// EAX == Ed
STREX(x14, gd, wback);
SMDMB();
DMB_ISH();
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE);
B_MARK(c__);
@@ -695,7 +695,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x14, 0);
B_MARK2(cNE);
STR_IMM9(gd, wback, 0);
SMDMB();
DMB_ISH();
} else {
MARKLOCK;
// alignment is good
@@ -706,7 +706,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
STREX(x14, gd, wback);
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE);
SMDMB();
DMB_ISH();
}
// end of EAX == Ed or EAX != Ed
MARK;
@@ -721,7 +721,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SET_DFNONE(x1);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
wback = 0;
@@ -747,12 +747,12 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
B_MARKLOCK(cNE);
}
MARK3;
SMDMB();
DMB_ISH();
break;
case 0xBA:
nextop = F8;
SMDMB();
DMB_ISH();
switch((nextop>>3)&7) {
case 4:
INST_NAME("(LOCK) BT Ed, Ib");
@@ -839,7 +839,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
default:
DEFAULT;
}
SMDMB();
DMB_ISH();
break;
case 0xBB:
INST_NAME("LOCK BTC Ed, Gd");
@@ -847,7 +847,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
SET_DFNONE(x1);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
wback = 0;
@@ -870,14 +870,14 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
CMPS_IMM8(x14, 0);
B_MARKLOCK(cNE);
}
SMDMB();
DMB_ISH();
break;
case 0xC0:
INST_NAME("LOCK XADD Gb, Eb");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
SMDMB();
DMB_ISH();
GETGB(x1);
if((nextop&0xC0)==0xC0) {
wback = (nextop&7);
@@ -902,14 +902,14 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
} else {
BFI(wback, ed, wb2*8, 8);
}
SMDMB();
DMB_ISH();
break;
case 0xC1:
INST_NAME("LOCK XADD Gd, Ed");
SETFLAGS(X_ALL, SF_SET_PENDING);
nextop = F8;
GETGD;
SMDMB();
DMB_ISH();
if((nextop&0xC0)==0xC0) {
ed = xEAX+(nextop&7);
if(gd!=ed) {
@@ -955,7 +955,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
}
MOV_REG(gd, x1);
}
SMDMB();
DMB_ISH();
break;
case 0xC7:
@@ -964,7 +964,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 1:
INST_NAME("LOCK CMPXCHG8B Gq, Eq");
SETFLAGS(X_ZF, SF_SUBSET);
SMDMB();
DMB_ISH();
addr = geted(dyn, addr, ninst, nextop, &wback, x1, &fixedaddress, 0, 0, 1, LOCK_LOCK);
MARKLOCK;
if(!fixedaddress || (fixedaddress && (fixedaddress&7))) {
@@ -1001,7 +1001,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
MOV_REG(xEDX, x3);
MOVW(x1, 0);
MARK3;
SMDMB();
DMB_ISH();
BFI(xFlags, x1, F_ZF, 1);
break;
default:
@@ -1017,7 +1017,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
case 0xFF:
nextop = F8;
SMDMB();
DMB_ISH();
switch((nextop>>3)&7)
{
case 0: // INC Ed
@@ -1041,7 +1041,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
B_MARKLOCK(cNE);
}
if(!fixedaddress) {
SMDMB();
DMB_ISH();
B_NEXT(c__);
}
if(!fixedaddress || (fixedaddress && (fixedaddress&3))) {
@@ -1078,7 +1078,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
B_MARKLOCK(cNE);
}
if(!fixedaddress) {
SMDMB();
DMB_ISH();
B_NEXT(c__);
}
if(!fixedaddress || (fixedaddress && (fixedaddress&3))) {
@@ -1098,7 +1098,7 @@ uintptr_t dynarecF0(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int ninst,
// default to NO LOCK
addr-=2;
}
SMDMB();
DMB_ISH();
break;
default:
+1 -57
View File
@@ -29,7 +29,6 @@
} else { \
parity = getedparity(dyn, ninst, addr, nextop, 3); \
a = fpu_get_scratch_double(dyn); \
SMREAD(); \
if(parity) { \
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL); \
VLDR_64(a, ed, fixedaddress); \
@@ -73,7 +72,6 @@ uintptr_t dynarecF20F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
d0 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
VMOVD(v0, d0);
} else {
SMREAD();
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-4, 0, 0, NULL);
LDR_IMM9(x2, ed, fixedaddress+0);
@@ -95,7 +93,6 @@ uintptr_t dynarecF20F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-4, 0, 0, NULL);
STR_IMM9(x2, ed, fixedaddress+0);
STR_IMM9(x3, ed, fixedaddress+4);
SMWRITE2();
}
break;
case 0x12:
@@ -107,7 +104,6 @@ uintptr_t dynarecF20F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
VMOVD(v0, d0);
} else {
SMREAD();
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-4, 0, 0, NULL);
LDR_IMM9(x2, ed, fixedaddress+0);
@@ -136,50 +132,28 @@ uintptr_t dynarecF20F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
d0 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
d0 = fpu_get_scratch_double(dyn);
VLDR_64(d0, ed, fixedaddress);
}
if(!box86_dynarec_fastround) {
VMRS(x14); // Get FPCSR reg to clear exceptions flags
ORR_IMM8(x3, x14, 0b010, 9); // enable exceptions
BIC_IMM8(x3, x3, 0b10011111, 0);
VMSR(x3);
}
VCVT_S32_F64(s0, d0);
VMOVfrV(gd, s0);
if(!box86_dynarec_fastround) {
VMRS(x3); // get the FPCSR reg and test FPU exception (IO only)
TSTS_IMM8_ROR(x3, 0b00000001, 0);
MOV_IMM_COND(cNE, gd, 0b10, 1); // 0x80000000
VMSR(x14); // put back values
}
break;
case 0x2D:
INST_NAME("CVTSD2SI Gd, Ex");
if(!box86_dynarec_fastround)
u8 = sse_setround_reset(dyn, ninst, x1, x2, x14);
else
u8 = sse_setround(dyn, ninst, x1, x2, x14);
u8 = sse_setround(dyn, ninst, x1, x2, x14);
nextop = F8;
GETGD;
s0 = fpu_get_scratch_single(dyn);
if((nextop&0xC0)==0xC0) {
d0 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
d0 = fpu_get_scratch_double(dyn);
VLDR_64(d0, ed, fixedaddress);
}
VCVTR_S32_F64(s0, d0);
VMOVfrV(gd, s0);
if(!box86_dynarec_fastround) {
VMRS(x3); // get the FPCSR reg and test FPU exception (IO only)
TSTS_IMM8_ROR(x3, 0b00000001, 0);
MOV_IMM_COND(cNE, gd, 0b10, 1); // 0x80000000
}
x87_restoreround(dyn, ninst, u8);
break;
@@ -331,7 +305,6 @@ uintptr_t dynarecF20F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
v1 = fpu_get_scratch_quad(dyn);
VLD1Q_64(v1, ed);
@@ -367,7 +340,6 @@ uintptr_t dynarecF20F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
v1 = fpu_get_scratch_quad(dyn);
VLD1Q_64(v1, ed);
@@ -429,33 +401,6 @@ uintptr_t dynarecF20F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
VMOV_64(v0, v1);
break;
case 0xE6:
INST_NAME("CVTPD2DQ Gx, Ex");
nextop = F8;
gd = (nextop&0x38)>>3;
v0 = sse_get_reg(dyn, ninst, x1, gd, 1);
if((nextop&0xC0)==0xC0) {
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
v1 = fpu_get_scratch_quad(dyn);
VLD1Q_8(v1, ed);
}
u8 = sse_setround(dyn, ninst, x1, x2, x14);
if(v0<16) {
VCVTR_S32_F64(v0*2, v1);
VCVTR_S32_F64(v0*2+1, v1+1);
} else {
d0 = fpu_get_scratch_double(dyn);
VCVTR_S32_F64(d0*2, v1);
VCVTR_S32_F64(d0*2+1, v1+1);
VMOVD(v0, d0);
}
x87_restoreround(dyn, ninst, u8);
VEOR(v0+1, v0+1, v0+1);
break;
case 0xF0:
INST_NAME("LDDQ Gx,Ex");
nextop = F8;
@@ -465,7 +410,6 @@ uintptr_t dynarecF20F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
VMOVQ(v0, v1);
} else {
SMREAD();
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-12, 0, 0, NULL);
LDR_IMM9(x2, ed, fixedaddress+0);
+2 -36
View File
@@ -37,7 +37,6 @@
b = fpu_get_scratch_double(dyn); \
a = b*2; \
parity = getedparity(dyn, ninst, addr, nextop, 2); \
SMREAD(); \
if(parity) { \
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 0, 0, NULL); \
VLDR_32(a, ed, fixedaddress); \
@@ -103,7 +102,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
} else {
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
parity = getedparity(dyn, ninst, addr, nextop, 2);
SMREAD();
if(parity && (v0<16)) {
VEORQ(v0, v0, v0);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 0, 0, NULL);
@@ -149,7 +147,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095, 0, 0, NULL);
STR_IMM9(x2, ed, fixedaddress);
}
SMWRITE2();
}
break;
case 0x12:
@@ -159,7 +156,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q1 = fpu_get_scratch_quad(dyn);
VLD1Q_64(q1, ed);
@@ -176,7 +172,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
q1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
q1 = fpu_get_scratch_quad(dyn);
VLD1Q_64(q1, ed);
@@ -234,7 +229,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
VMOV_32(s0, d0*2);
} else {
parity = getedparity(dyn, ninst, addr, nextop, 3);
SMREAD();
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VLDR_32(s0, ed, fixedaddress);
@@ -244,27 +238,12 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
VMOVtoV(s0, x2);
}
}
if(!box86_dynarec_fastround) {
VMRS(x14); // Get FPCSR reg to clear exceptions flags
ORR_IMM8(x3, x14, 0b010, 9); // enable exceptions
BIC_IMM8(x3, x3, 0b10011111, 0);
VMSR(x3);
}
VCVT_S32_F32(s0, s0);
VMOVfrV(gd, s0);
if(!box86_dynarec_fastround) {
VMRS(x3); // get the FPCSR reg and test FPU exception (IO only)
TSTS_IMM8_ROR(x3, 0b00000001, 0);
MOV_IMM_COND(cNE, gd, 0b10, 1); // 0x80000000
VMSR(x14); // put back values
}
break;
case 0x2D:
INST_NAME("CVTSS2SI Gd, Ex");
if(!box86_dynarec_fastround)
u8 = sse_setround_reset(dyn, ninst, x1, x2, x14);
else
u8 = sse_setround(dyn, ninst, x1, x2, x14);
u8 = sse_setround(dyn, ninst, x1, x2, x14);
nextop = F8;
GETGD;
s0 = fpu_get_scratch_single(dyn);
@@ -279,7 +258,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
VMOV_32(s0, d0*2);
} else {
parity = getedparity(dyn, ninst, addr, nextop, 3);
SMREAD();
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VLDR_32(s0, ed, fixedaddress);
@@ -291,11 +269,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
}
VCVTR_S32_F32(s0, s0);
VMOVfrV(gd, s0);
if(!box86_dynarec_fastround) {
VMRS(x3); // get the FPCSR reg and test FPU exception (IO only)
TSTS_IMM8_ROR(x3, 0b00000001, 0);
MOV_IMM_COND(cNE, gd, 0b10, 1); // 0x80000000
}
x87_restoreround(dyn, ninst, u8);
break;
@@ -423,7 +396,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
if((nextop&0xC0)==0xC0) {
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
v1 = fpu_get_scratch_quad(dyn);
VLD1Q_64(v1, ed);
@@ -528,7 +500,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
VMOVQ(v0, v1);
} else {
SMREAD();
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 4095-12, 0, 0, NULL);
LDR_IMM9(x2, ed, fixedaddress+0);
@@ -543,15 +514,14 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
INST_NAME("PSHUFHW Gx, Ex, Ib");
nextop = F8;
gd = (nextop&0x38)>>3;
v0 = sse_get_reg(dyn, ninst, x1, gd, 1);
if((nextop&0xC0)==0xC0) {
v1 = sse_get_reg(dyn, ninst, x1, nextop&7, 0);
} else {
SMREAD();
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
v1 = fpu_get_scratch_quad(dyn);
VLD1Q_64(v1, ed);
}
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
u8 = F8;
// only high part need to be shuffled. VTBL only handle 8bits value, so the 16bits shuffles need to be changed in 8bits
u32 = 0;
@@ -584,7 +554,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
VMOVD(v0, v1);
} else {
SMREAD();
v0 = sse_get_reg_empty(dyn, ninst, x1, gd);
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 0, 0, 0, NULL);
VLD1_64(v0, ed);
@@ -607,7 +576,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
VMOVfrV_D(x2, x3, v0+1);
STR_IMM9(x2, ed, fixedaddress+8);
STR_IMM9(x3, ed, fixedaddress+12);
SMWRITE2();
}
break;
@@ -672,7 +640,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
VMOV_64(v0, v1);
} else {
parity = getedparity(dyn, ninst, addr, nextop, 3);
SMREAD();
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VLDR_64(v0, ed, fixedaddress); // vfpu opcode here
@@ -699,7 +666,6 @@ uintptr_t dynarecF30F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nins
} else {
v0 = fpu_get_scratch_double(dyn);
parity = getedparity(dyn, ninst, addr, nextop, 3);
SMREAD();
if(parity) {
addr = geted(dyn, addr, ninst, nextop, &ed, x1, &fixedaddress, 1023, 3, 0, NULL);
VLDR_64(v0, ed, fixedaddress); // vfpu opcode here
+12 -45
View File
@@ -251,7 +251,6 @@ void jump_to_epilog(dynarec_arm_t* dyn, uintptr_t ip, int reg, int ninst)
}
PASS3(void* epilog = arm_epilog);
MOV32_(2, (uintptr_t)epilog);
SMEND();
BX(2);
}
@@ -278,7 +277,6 @@ void jump_to_next(dynarec_arm_t* dyn, uintptr_t ip, int reg, int ninst)
#ifdef HAVE_TRACE
MOV_REG(x2, 15); // move current PC to x2, for tracing
#endif
SMEND();
BX(x3);
}
@@ -295,7 +293,6 @@ void ret_to_epilog(dynarec_arm_t* dyn, int ninst)
#ifdef HAVE_TRACE
MOV_REG(x2, 15); // move current PC to x2, for tracing
#endif
SMEND();
BX(x3);
}
@@ -318,7 +315,6 @@ void retn_to_epilog(dynarec_arm_t* dyn, int ninst, int n)
#ifdef HAVE_TRACE
MOV_REG(x2, 15); // move current PC to x2, for tracing
#endif
SMEND();
BX(x3);
}
@@ -341,7 +337,6 @@ void iret_to_epilog(dynarec_arm_t* dyn, int ninst)
SET_DFNONE(x1);
// Ret....
MOV32_(x2, (uintptr_t)arm_epilog); // epilog on purpose, CS might have changed!
SMEND();
BX(x2);
}
@@ -483,7 +478,7 @@ void call_rd(dynarec_arm_t* dyn, int ninst, void* fnc, int reg, int s1, uint32_t
if(s1!=xFlags) mask=1<<xFlags; else mask=1<<x3;
}
PUSH(xSP, (1<<xEmu) | mask);
fpu_pushcache(dyn, ninst, s1);
fpu_pushcache(dyn, ninst, reg);
if(saveflags) {
STR_IMM9(xFlags, xEmu, offsetof(x86emu_t, eflags));
}
@@ -495,7 +490,7 @@ void call_rd(dynarec_arm_t* dyn, int ninst, void* fnc, int reg, int s1, uint32_t
#ifdef ARM_SOFTFP
VMOVtoV_64(0, 0, 1); // load r0:r1 to D0 to simulate hardfo
#endif
fpu_popcache(dyn, ninst, s1);
fpu_popcache(dyn, ninst, reg);
POP(xSP, (1<<xEmu) | mask);
if(saveflags) {
LDR_IMM9(xFlags, xEmu, offsetof(x86emu_t, eflags));
@@ -1071,13 +1066,15 @@ void x87_reget_st(dynarec_arm_t* dyn, int ninst, int s1, int s2, int st)
MESSAGE(LOG_DUMP, "\t-------x87 Cache for ST%d\n", st);
}
static int round_map[] = {0, 2, 1, 3}; // map x86 -> arm round flag
// Set rounding according to cw flags, return reg to restore flags
int x87_setround(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3)
{
LDRH_IMM8(s1, xEmu, offsetof(x86emu_t, cw)); // hopefully cw is not too far for an imm8
UBFX(s1, s1, 10, 2); // extract round...
UBFX(s2, s1, 1, 1); // swap bits 0 and 1
BFI(s2, s1, 1, 1);
UBFX(s2, s1, 10, 2); // extract round...
MOV32(s1, round_map);
LDR_REG_LSL_IMM5(s2, s1, s2, 2);
VMRS(s1); // get fpscr
MOV_REG(s3, s1);
BFI(s1, s2, 22, 2); // inject new round
@@ -1085,21 +1082,6 @@ int x87_setround(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3)
return s3;
}
// Set rounding according to cw flags, also enable exception and reset counter, return reg to restore flags
int x87_setround_reset(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3)
{
LDRH_IMM8(s1, xEmu, offsetof(x86emu_t, cw)); // hopefully cw is not too far for an imm8
UBFX(s1, s1, 10, 2); // extract round...
UBFX(s2, s1, 1, 1); // swap bits 0 and 1
BFI(s2, s1, 1, 1);
VMRS(s3); // get fpscr
ORR_IMM8(s1, s3, 0b010, 9); // enable exceptions
BIC_IMM8(s1, s1, 0b10011111, 0); // reset counters
BFI(s1, s2, 22, 2); // inject new round
VMSR(s1); // put new fpscr
return s3;
}
void x87_swapreg(dynarec_arm_t* dyn, int ninst, int s1, int s2, int a, int b)
{
int i1, i2, i3;
@@ -1124,9 +1106,9 @@ void x87_swapreg(dynarec_arm_t* dyn, int ninst, int s1, int s2, int a, int b)
int sse_setround(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3)
{
LDR_IMM9(s1, xEmu, offsetof(x86emu_t, mxcsr));
UBFX(s1, s1, 13, 2); // extract round...
UBFX(s2, s1, 1, 1); // swap bits 0 and 1
BFI(s2, s1, 1, 1);
UBFX(s2, s1, 13, 2); // extract round...
MOV32(s1, round_map);
LDR_REG_LSL_IMM5(s2, s1, s2, 2);
VMRS(s1); // get fpscr
MOV_REG(s3, s1);
BFI(s1, s2, 22, 2); // inject new round
@@ -1134,21 +1116,6 @@ int sse_setround(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3)
return s3;
}
// Set rounding according to mxcsr flags, also enable exception and reset counter, return reg to restore flags
int sse_setround_reset(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3)
{
LDR_IMM9(s1, xEmu, offsetof(x86emu_t, mxcsr));
UBFX(s1, s1, 13, 2); // extract round...
UBFX(s2, s1, 1, 1); // swap bits 0 and 1
BFI(s2, s1, 1, 1);
VMRS(s3); // get fpscr
ORR_IMM8(s1, s3, 0b010, 9); // enable exceptions
BIC_IMM8(s1, s1, 0b10011111, 0); // reset counters
BFI(s1, s2, 22, 2); // inject new round
VMSR(s1); // put new fpscr
return s3;
}
// Restore round flag
void x87_restoreround(dynarec_arm_t* dyn, int ninst, int s1)
{
@@ -1366,7 +1333,7 @@ void fpu_pushcache(dynarec_arm_t* dyn, int ninst, int s1)
MOV_REG(s1, xSP);
for (int i=16; i<32; ++i) { // should use VSTM?
if(dyn->n.fpuused[i-8]) {
VST1_64_W(i, s1);
VST1_32_W(i, s1);
}
}
MESSAGE(LOG_DUMP, "\t------- Push FPU Cache (%d)\n", n);
@@ -1385,7 +1352,7 @@ void fpu_popcache(dynarec_arm_t* dyn, int ninst, int s1)
MOV_REG(s1, xSP);
for (int i=16; i<32; ++i) {
if(dyn->n.fpuused[i-8]) {
VLD1_64_W(i, s1);
VLD1_32_W(i, s1);
}
}
if(n>=8) {
+8 -51
View File
@@ -27,30 +27,6 @@
#define PKip(a) *(uint8_t*)(ip+a)
#define PKa(a) *(uint8_t*)(a)
// Strong mem emulation helpers
// Sequence of Read will trigger a DMB on "first" read if strongmem is 2
// Squence of Write will trigger a DMB on "last" write if strongmem is 1
// Opcode will read
#define SMREAD() if(!dyn->smread && box86_dynarec_strongmem>1) {SMDMB();}
// Opcode will read with option forced lock
#define SMREADLOCK(lock) if(lock || (!dyn->smread && box86_dynarec_strongmem>1)) {SMDMB();}
// Opcode migh read (depend on nextop)
#define SMMIGHTREAD() if(!MODREG) {SMREAD();}
// Opcode has wrote
#define SMWRITE() dyn->smwrite=1
// Opcode has wrote (strongmem>1 only)
#define SMWRITE2() if(box86_dynarec_strongmem>1) dyn->smwrite=1
// Opcode has wrote with option forced lock
#define SMWRITELOCK(lock) if(lock) {SMDMB();} else dyn->smwrite=1
// Opcode migh have wrote (depend on nextop)
#define SMMIGHTWRITE() if(!MODREG) {SMWRITE();}
// Start of sequence
#define SMSTART() SMEND()
// End of sequence
#define SMEND() if(dyn->smwrite && box86_dynarec_strongmem) {DMB_ISH();} dyn->smwrite=0; dyn->smread=0;
// Force a Data memory barrier (for LOCK: prefix)
#define SMDMB() DMB_ISH(); dyn->smwrite=0; dyn->smread=1
//LOCK_* define
#define LOCK_LOCK (int*)1
@@ -61,7 +37,6 @@
ed = xEAX+(nextop&7); \
wback = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, 4095, 0, 0, NULL); \
LDR_IMM9(x1, wback, fixedaddress); \
ed = x1; \
@@ -71,7 +46,6 @@
ed = xEAX+(nextop&7); \
wback = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, (hint==x2)?x1:x2, &fixedaddress, 4095, 0, 0, NULL); \
LDR_IMM9(hint, wback, fixedaddress); \
ed = hint; \
@@ -82,21 +56,19 @@
MOV_REG(ret, ed); \
wback = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, hint, &fixedaddress, 4095, 0, 0, NULL); \
ed = ret; \
LDR_IMM9(ed, wback, fixedaddress); \
}
// Write back ed in wback (if wback not 0)
#define WBACK if(wback) {STR_IMM9(ed, wback, fixedaddress); SMWRITE();}
// Write back ed in wback (if wback not 0) (SMWRITE2 version)
#define WBACK2 if(wback) {STR_IMM9(ed, wback, fixedaddress); SMWRITE2();}
#define WBACK if(wback) {STR_IMM9(ed, wback, fixedaddress);}
// Send back wb to either ed or wback
#define SBACK(wb) if(wback) {STR_IMM9(wb, wback, fixedaddress);} else {MOV_REG(ed, wb);}
//GETEDO can use r1 for ed, and r2 for wback. wback is 0 if ed is xEAX..xEDI
#define GETEDO(O) if((nextop&0xC0)==0xC0) { \
ed = xEAX+(nextop&7); \
wback = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, 0, 0, 0, NULL); \
LDR_REG_LSL_IMM5(x1, wback, O, 0); \
ed = x1; \
@@ -106,14 +78,13 @@
ed = xEAX+(nextop&7); \
wback = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, 0, 0, 0, NULL); \
ADD_REG_LSL_IMM5(x2, wback, O, 0); \
if(wback != x2) wback = x2; \
LDR_IMM9(x1, wback, 0); \
ed = x1; \
}
#define WBACKO(O) if(wback) {STR_REG_LSL_IMM5(ed, wback, O, 0); SMWRITE();}
#define WBACKO(O) if(wback) {STR_REG_LSL_IMM5(ed, wback, O, 0);}
//FAKEELike GETED, but doesn't get anything
#define FAKEED if((nextop&0xC0)!=0xC0) { \
addr = fakeed(dyn, addr, ninst, nextop); \
@@ -127,7 +98,6 @@
ed = i; \
wb1 = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, w, &fixedaddress, 255, 0, 0, NULL); \
LDRH_IMM8(i, wback, fixedaddress); \
ed = i; \
@@ -140,7 +110,6 @@
ed = i; \
wb1 = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL); \
LDRH_IMM8(i, wback, fixedaddress); \
ed = i; \
@@ -153,16 +122,15 @@
ed = i; \
wb1 = 0; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL); \
LDRSH_IMM8(i, wback, fixedaddress);\
ed = i; \
wb1 = 1; \
}
// Write ed back to original register / memory
#define EWBACK if(wb1) {STRH_IMM8(ed, wback, fixedaddress); SMWRITE();} else {BFI(wback, ed, 0, 16);}
#define EWBACK if(wb1) {STRH_IMM8(ed, wback, fixedaddress);} else {BFI(wback, ed, 0, 16);}
// Write w back to original register / memory
#define EWBACKW(w) if(wb1) {STRH_IMM8(w, wback, fixedaddress); SMWRITE();} else {BFI(wback, w, 0, 16);}
#define EWBACKW(w) if(wb1) {STRH_IMM8(w, wback, fixedaddress);} else {BFI(wback, w, 0, 16);}
// Write back gd in correct register
#define GWBACK BFI((xEAX+((nextop&0x38)>>3)), gd, 0, 16);
//GETEB will use i for ed, and can use r3 for wback.
@@ -174,7 +142,6 @@
wb1 = 0; \
ed = i; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 4095, 0, 0, NULL); \
LDRB_IMM9(i, wback, fixedaddress); \
wb1 = 1; \
@@ -189,7 +156,6 @@
wb1 = 0; \
ed = i; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 0, 0, 0, NULL); \
ADD_REG_LSL_IMM5(x3, wback, i, 0); \
if(wback!=x3) wback = x3; \
@@ -206,16 +172,13 @@
wb1 = 0; \
ed = i; \
} else { \
SMREAD(); \
addr = geted(dyn, addr, ninst, nextop, &wback, x3, &fixedaddress, 255, 0, 0, NULL); \
LDRSB_IMM8(i, wback, fixedaddress);\
wb1 = 1; \
ed = i; \
}
// Write eb (ed) back to original register / memory
#define EBBACK if(wb1) {STRB_IMM9(ed, wback, fixedaddress); SMWRITE();} else {BFI(wback, ed, wb2*8, 8);}
// Write eb (ed) back to original register / memory (SMWRITE2 version)
#define EBBACK2 if(wb1) {STRB_IMM9(ed, wback, fixedaddress); SMWRITE2();} else {BFI(wback, ed, wb2*8, 8);}
#define EBBACK if(wb1) {STRB_IMM9(ed, wback, fixedaddress);} else {BFI(wback, ed, wb2*8, 8);}
//GETGB will use i for gd
#define GETGB(i) gd = (nextop&0x38)>>3; \
gb2 = ((gd&4)>>2); \
@@ -343,7 +306,7 @@
#ifndef READFLAGS
#define READFLAGS(A) \
if(((A)!=X_PEND && dyn->f.pending!=SF_SET) \
if((dyn->f.pending!=SF_SET) \
&& (dyn->f.pending!=SF_SET_PENDING)) { \
if(dyn->f.pending!=SF_PENDING) { \
LDR_IMM9(x3, xEmu, offsetof(x86emu_t, df)); \
@@ -534,11 +497,9 @@ void* arm_next(x86emu_t* emu, uintptr_t addr);
#define x87_reget_st STEPNAME(x87_reget_st)
#define x87_stackcount STEPNAME(x87_stackcount)
#define x87_setround STEPNAME(x87_setround)
#define x87_setround_reset STEPNAME(x87_setround_reset)
#define x87_restoreround STEPNAME(x87_restoreround)
#define x87_swapreg STEPNAME(x87_swapreg)
#define sse_setround STEPNAME(sse_setround)
#define sse_setround_reset STEPNAME(sse_setround_reset)
#define mmx_get_reg STEPNAME(mmx_get_reg)
#define mmx_get_reg_empty STEPNAME(mmx_get_reg_empty)
#define sse_get_reg STEPNAME(sse_get_reg)
@@ -683,16 +644,12 @@ void x87_forget(dynarec_arm_t* dyn, int ninst, int s1, int s2, int st);
void x87_reget_st(dynarec_arm_t* dyn, int ninst, int s1, int s2, int st);
// Set rounding according to cw flags, return reg to restore flags
int x87_setround(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3);
// Set rounding according to cw flags, return reg to restore flags, also enable exceptions and reset counters
int x87_setround_reset(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3);
// Restore round flag
void x87_restoreround(dynarec_arm_t* dyn, int ninst, int s1);
// swap 2 x87 regs
void x87_swapreg(dynarec_arm_t* dyn, int ninst, int s1, int s2, int a, int b);
// Set rounding according to mxcsr flags, return reg to restore flags
int sse_setround(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3);
// Set rounding according to mxcsr flags, return reg to restore flags, also enable exceptions and reset counters
int sse_setround_reset(dynarec_arm_t* dyn, int ninst, int s1, int s2, int s3);
void CacheTransform(dynarec_arm_t* dyn, int ninst, int cacheupd, int s1, int s2, int s3);
+9 -43
View File
@@ -21,7 +21,6 @@
#include "dynarec_arm_functions.h"
#include "dynarec_arm_helper.h"
#include "custommem.h"
#include "elfloader.h"
#ifndef STEP
#error No STEP defined
@@ -36,17 +35,12 @@ uintptr_t arm_pass(dynarec_arm_t* dyn, uintptr_t addr)
uintptr_t init_addr = addr;
MAYUSE(init_addr);
int need_epilog = 1;
dyn->sons_size = 0;
// Clean up (because there are multiple passes)
dyn->f.pending = 0;
dyn->f.dfnone = 0;
dyn->forward = 0;
dyn->forward_to = 0;
dyn->forward_size = 0;
dyn->forward_ninst = 0;
fpu_reset(dyn);
int reset_n = -1;
int stopblock = 2+(FindElfAddress(my_context, addr)?0:1); // if block is in elf_memory, it can be extended with bligblocks==2, else it needs 3 // ok, go now
// ok, go now
INIT;
while(ok) {
ip = addr;
@@ -124,7 +118,6 @@ uintptr_t arm_pass(dynarec_arm_t* dyn, uintptr_t addr)
dyn->n.stack_push = 0;
dyn->n.swapped = 0;
NEW_INST;
if(dyn->insts[ninst].pred_sz>1) {SMSTART();}
fpu_reset_scratch(dyn);
if((dyn->insts[ninst].x86.need_before&~X_PEND) && !dyn->insts[ninst].pred_sz) {
READFLAGS(dyn->insts[ninst].x86.need_before&~X_PEND);
@@ -183,33 +176,13 @@ uintptr_t arm_pass(dynarec_arm_t* dyn, uintptr_t addr)
#ifndef PROT_READ
#define PROT_READ 1
#endif
if(dyn->forward) {
if(dyn->forward_to == addr) {
// we made it!
if(box86_dynarec_dump) dynarec_log(LOG_NONE, "Forward extend block %p -> %p\n", (void*)dyn->forward, (void*)dyn->forward_to);
dyn->forward = 0;
dyn->forward_to = 0;
dyn->forward_size = 0;
dyn->forward_ninst = 0;
} else if ((dyn->forward_to < addr) || !ok) {
// something when wrong! rollback
if(box86_dynarec_dump) dynarec_log(LOG_NONE, "Could not forward extend block %p -> %p\n", (void*)dyn->forward, (void*)dyn->forward_to);
ok = 0;
dyn->size = dyn->forward_size;
ninst = dyn->forward_ninst;
addr = dyn->forward;
dyn->forward = 0;
dyn->forward_to = 0;
dyn->forward_size = 0;
dyn->forward_ninst = 0;
}
// else just continue
} else if(!ok && !need_epilog && box86_dynarec_bigblock && (getProtection(addr+3)&PROT_READ))
if(!ok && !need_epilog && box86_dynarec_bigblock && (getProtection(addr+3)&PROT_READ))
if(*(uint32_t*)addr!=0) { // check if need to continue (but is next 4 bytes are 0, stop)
uintptr_t next = get_closest_next(dyn, addr);
if(next && (
(((next-addr)<15) && is_nops(dyn, addr, next-addr))
/*&& box86_dynarec_bigblock*/))
&& (((box86_dynarec_bigblock<2) && isJumpTableDefault((void*)next)) || (box86_dynarec_bigblock>1))
/*||(((next-addr)<30) && is_instructions(dyn, addr, next-addr))*/ ))
{
ok = 1;
// need to find back that instruction to copy the caches, as previous version cannot be used anymore
@@ -220,23 +193,16 @@ uintptr_t arm_pass(dynarec_arm_t* dyn, uintptr_t addr)
ii=ninst;
}
if(box86_dynarec_dump) dynarec_log(LOG_NONE, "Extend block %p, %p -> %p (ninst=%d, jump from %d)\n", dyn, (void*)addr, (void*)next, ninst, reset_n);
} else if(next && (next-addr<box86_dynarec_forward)
&& (getProtection(next)&PROT_READ)/*box86_dynarec_bigblock>=forwardblock*/) {
dyn->forward = addr;
dyn->forward_to = next;
dyn->forward_size = dyn->size;
dyn->forward_ninst = ninst;
reset_n = -2;
ok = 1;
} else if(next && (next-addr)<30) {
if(box86_dynarec_dump) dynarec_log(LOG_NONE, "Cannot extend block %p -> %p (%02X %02X %02X %02X %02X %02X %02X %02x)\n", (void*)addr, (void*)next, PK(0), PK(1), PK(2), PK(3), PK(4), PK(5), PK(6), PK(7));
}
}
#endif
if(ok<0) {ok = 0; need_epilog=1;}
++ninst;
#if STEP == 0
if(ok && (((box86_dynarec_bigblock<stopblock) && !isJumpTableDefault((void*)addr))
|| (addr>=box86_nodynarec_start && addr<box86_nodynarec_end)
/*|| (dyn->size >= 2000)*/)) // is this still needed? maybe it should be a parameter?
if((ok && !isJumpTableDefault((void*)addr) && (box86_dynarec_bigblock<2)) ||
(ok && dyn->size >= 2000))
#else
if(ok && (ninst==dyn->size))
#endif
@@ -262,6 +228,6 @@ uintptr_t arm_pass(dynarec_arm_t* dyn, uintptr_t addr)
jump_to_epilog(dyn, ip, 0, ninst); // no linker here, it's an unknow instruction
}
FINI;
MESSAGE(LOG_DUMP, "---- END OF BLOCK ---- (%d, %d sons)\n", dyn->size, dyn->sons_size);
MESSAGE(LOG_DUMP, "---- END OF BLOCK ---- (%d)\n", dyn->size);
return addr;
}
+1 -1
View File
@@ -34,7 +34,7 @@
#define INST_EPILOG \
dyn->insts[ninst].f_exit = dyn->f; \
dyn->insts[ninst].n = dyn->n; \
dyn->insts[ninst].x86.has_next = (ok>0)?1:0;
dyn->insts[ninst].x86.has_next = ok;
#define INST_NAME(name)
#define DEFAULT \
--dyn->size; \
-2
View File
@@ -6,8 +6,6 @@
#define NEW_INST \
if(ninst) { \
dyn->insts[ninst].address = (dyn->insts[ninst-1].address+dyn->insts[ninst-1].size); \
if(ninst && isInstClean(dyn, ninst)) \
++dyn->sons_size; \
}
#define INST_EPILOG dyn->insts[ninst].epilog = dyn->arm_size;
#define INST_NAME(name)
+2 -9
View File
@@ -8,18 +8,12 @@
#define MESSAGE(A, ...) if(box86_dynarec_dump) dynarec_log(LOG_NONE, __VA_ARGS__)
#define NEW_INST \
if(ninst && isInstClean(dyn, ninst)) { \
dyn->sons_x86[dyn->sons_size] = (uintptr_t)ip; \
dyn->sons_arm[dyn->sons_size] = dyn->block; \
MESSAGE(LOG_DUMP, "----> potential Son here %p/%p\n", (void*)ip, dyn->block); \
++dyn->sons_size; \
}
#define INST_EPILOG
#define INST_NAME(name) \
if(box86_dynarec_dump) {\
printf_x86_instruction(my_context->dec, &dyn->insts[ninst].x86, name); \
dynarec_log(LOG_NONE, "%s%p: %d emited opcodes, inst=%d, barrier=%d state=%d/%d(%d), %s=%X/%X, use=%X, need=%X/%X sm=%d/%d", \
dynarec_log(LOG_NONE, "%s%p: %d emited opcodes, inst=%d, barrier=%d state=%d/%d(%d), %s=%X/%X, use=%X, need=%X/%X", \
(box86_dynarec_dump>1)?"\e[32m":"", \
(void*)(dyn->arm_start+dyn->insts[ninst].address), \
dyn->insts[ninst].size/4, \
@@ -33,8 +27,7 @@
dyn->insts[ninst].x86.gen_flags, \
dyn->insts[ninst].x86.use_flags, \
dyn->insts[ninst].x86.need_before, \
dyn->insts[ninst].x86.need_after, \
dyn->smread, dyn->smwrite); \
dyn->insts[ninst].x86.need_after); \
if(dyn->insts[ninst].pred_sz) { \
dynarec_log(LOG_NONE, ", pred="); \
for(int ii=0; ii<dyn->insts[ninst].pred_sz; ++ii)\
+6 -12
View File
@@ -5,6 +5,7 @@
typedef struct x86emu_s x86emu_t;
typedef struct dynablock_s dynablock_t;
typedef struct instsize_s instsize_t;
#define BARRIER_MAYBE 8
@@ -18,12 +19,12 @@ typedef struct dynablock_s dynablock_t;
typedef union neon_cache_s {
int8_t v;
struct {
uint8_t t:4; // reg type
uint8_t n:4; // reg number
unsigned int t:4; // reg type
unsigned int n:4; // reg number
};
} neon_cache_t;
typedef union sse_cache_s {
int8_t v;
int v;
struct {
uint8_t reg;
uint8_t write;
@@ -95,22 +96,15 @@ typedef struct dynarec_arm_s {
uintptr_t* next; // variable array of "next" jump address
int next_sz;
int next_cap;
uintptr_t* sons_x86; // the x86 address of potential dynablock sons
void** sons_arm; // the arm address of potential dynablock sons
int sons_size; // number of potential dynablock sons
int* predecessor;// single array of all predecessor
dynablock_t* dynablock;
uint8_t smread; // for strongmem model emulation
uint8_t smwrite; // for strongmem model emulation
uintptr_t forward; // address of the last end of code while testing forward
uintptr_t forward_to; // address of the next jump to (to check if everything is ok)
int32_t forward_size; // size at the forward point
int forward_ninst; // ninst at the forward point
instsize_t* instsize;
} dynarec_arm_t;
void add_next(dynarec_arm_t *dyn, uintptr_t addr);
uintptr_t get_closest_next(dynarec_arm_t *dyn, uintptr_t addr);
int is_nops(dynarec_arm_t *dyn, uintptr_t addr, int n);
int is_instructions(dynarec_arm_t *dyn, uintptr_t addr, int n);
void CreateJmpNextTo(void* addr, void* tonext);
#endif //__DYNAREC_ARM_PRIVATE_H_
+8
View File
@@ -0,0 +1,8 @@
#ifndef __DYNAREC_NEXT_H__
#define __DYNAREC_NEXT_H__
void arm_next(void) EXPORTDYN;
void arm_prolog(x86emu_t* emu, void* addr) EXPORTDYN;
void arm_epilog() EXPORTDYN;
#endif //__DYNAREC_NEXT_H__
+7 -7
View File
@@ -235,12 +235,12 @@ void DumpMainHeader(Elf32_Ehdr *header, elfheader_t *h)
printf_dump(LOG_NEVER, "ELF Dump ==========\n");
printf_dump(LOG_NEVER, "ELF Dump PEntries (%d)\n", h->numSHEntries);
for (uint16_t i=0; i<h->numPHEntries; ++i)
for (int i=0; i<h->numPHEntries; ++i)
printf_dump(LOG_NEVER, " PHEntry %04d : %s\n", i, DumpPHEntry(h->PHEntries+i));
printf_dump(LOG_NEVER, "ELF Dump PEntries ====\n");
printf_dump(LOG_NEVER, "ELF Dump Sections (%d)\n", h->numSHEntries);
for (uint16_t i=0; i<h->numSHEntries; ++i)
for (int i=0; i<h->numSHEntries; ++i)
printf_dump(LOG_NEVER, " Section %04d : %s\n", i, DumpSection(h->SHEntries+i, h->SHStrTab));
printf_dump(LOG_NEVER, "ELF Dump Sections ====\n");
}
@@ -251,7 +251,7 @@ void DumpSymTab(elfheader_t *h)
if(box86_dump && h->SymTab) {
const char* name = ElfName(h);
printf_dump(LOG_NEVER, "ELF Dump SymTab(%d)=\n", h->numSymTab);
for (uint32_t i=0; i<h->numSymTab; ++i)
for (int i=0; i<h->numSymTab; ++i)
printf_dump(LOG_NEVER, " %s:SymTab[%d] = \"%s\", value=%p, size=%d, info/other=%d/%d index=%d\n", name,
i, h->StrTab+h->SymTab[i].st_name, (void*)h->SymTab[i].st_value, h->SymTab[i].st_size,
h->SymTab[i].st_info, h->SymTab[i].st_other, h->SymTab[i].st_shndx);
@@ -263,7 +263,7 @@ void DumpDynamicSections(elfheader_t *h)
{
if(box86_dump && h->Dynamic) {
printf_dump(LOG_NEVER, "ELF Dump Dynamic(%d)=\n", h->numDynamic);
for (uint32_t i=0; i<h->numDynamic; ++i)
for (int i=0; i<h->numDynamic; ++i)
printf_dump(LOG_NEVER, " Dynamic %04d : %s\n", i, DumpDynamic(h->Dynamic+i));
printf_dump(LOG_NEVER, "ELF Dump Dynamic=====\n");
}
@@ -274,7 +274,7 @@ void DumpDynSym(elfheader_t *h)
if(box86_dump && h->DynSym) {
const char* name = ElfName(h);
printf_dump(LOG_NEVER, "ELF Dump DynSym(%d)=\n", h->numDynSym);
for (uint32_t i=0; i<h->numDynSym; ++i) {
for (int i=0; i<h->numDynSym; ++i) {
int version = h->VerSym?((Elf32_Half*)((uintptr_t)h->VerSym+h->delta))[i]:-1;
printf_dump(LOG_NEVER, " %s:DynSym[%d] = %s\n", name, i, DumpSym(h, h->DynSym+i, version));
}
@@ -286,7 +286,7 @@ void DumpDynamicNeeded(elfheader_t *h)
{
if(box86_dump && h->DynStrTab) {
printf_dump(LOG_NEVER, "ELF Dump DT_NEEDED=====\n");
for (uint32_t i=0; i<h->numDynamic; ++i)
for (int i=0; i<h->numDynamic; ++i)
if(h->Dynamic[i].d_tag==DT_NEEDED) {
printf_dump(LOG_NEVER, " Needed : %s\n", h->DynStrTab+h->Dynamic[i].d_un.d_val + h->delta);
}
@@ -298,7 +298,7 @@ void DumpDynamicRPath(elfheader_t *h)
{
if(box86_dump && h->DynStrTab) {
printf_dump(LOG_NEVER, "ELF Dump DT_RPATH/DT_RUNPATH=====\n");
for (uint32_t i=0; i<h->numDynamic; ++i) {
for (int i=0; i<h->numDynamic; ++i) {
if(h->Dynamic[i].d_tag==DT_RPATH) {
printf_dump(LOG_NEVER, " RPATH : %s\n", h->DynStrTab+h->Dynamic[i].d_un.d_val + h->delta);
}
+43 -99
View File
@@ -1,4 +1,4 @@
#define _GNU_SOURCE
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -355,7 +355,6 @@ int LoadElfMemory(FILE* f, box86context_t* context, elfheader_t* head)
int ReloadElfMemory(FILE* f, box86context_t* context, elfheader_t* head)
{
(void)context;
for (int i=0; i<head->numPHEntries; ++i) {
if(head->PHEntries[i].p_type == PT_LOAD) {
Elf32_Phdr * e = &head->PHEntries[i];
@@ -384,7 +383,7 @@ int ReloadElfMemory(FILE* f, box86context_t* context, elfheader_t* head)
// TLS data are just a copy, no need to re-load it
return 0;
}
int FindR386COPYRel(elfheader_t* h, const char* name, uintptr_t *offs, uint32_t** p, size_t size, int version, const char* vername)
int FindR386COPYRel(elfheader_t* h, const char* name, uintptr_t *offs, uint32_t** p, int version, const char* vername)
{
if(!h)
return 0;
@@ -397,7 +396,7 @@ int FindR386COPYRel(elfheader_t* h, const char* name, uintptr_t *offs, uint32_t*
int t = ELF32_R_TYPE(rel[i].r_info);
Elf32_Sym *sym = &h->DynSym[ELF32_R_SYM(rel[i].r_info)];
const char* symname = SymName(h, sym);
if(t==R_386_COPY && symname && !strcmp(symname, name) && sym->st_size==size) {
if(t==R_386_COPY && symname && !strcmp(symname, name)) {
int version2 = h->VerSym?((Elf32_Half*)((uintptr_t)h->VerSym+h->delta))[ELF32_R_SYM(rel[i].r_info)]:-1;
if(version2!=-1) version2 &= 0x7fff;
if(version && !version2) version2=-1; // match a versionned symbol against a global "local" symbol
@@ -417,7 +416,7 @@ int FindR386COPYRel(elfheader_t* h, const char* name, uintptr_t *offs, uint32_t*
int t = ELF32_R_TYPE(rela[i].r_info);
Elf32_Sym *sym = &h->DynSym[ELF32_R_SYM(rela[i].r_info)];
const char* symname = SymName(h, sym);
if(t==R_386_COPY && symname && !strcmp(symname, name) && sym->st_size==size) {
if(t==R_386_COPY && symname && !strcmp(symname, name)) {
int version2 = h->VerSym?((Elf32_Half*)((uintptr_t)h->VerSym+h->delta))[ELF32_R_SYM(rela[i].r_info)]:-1;
if(version2!=-1) version2 &= 0x7fff;
if(version && !version2) version2=-1; // match a versionned symbol against a global "local" symbol
@@ -445,22 +444,14 @@ int RelocateElfREL(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t*
uint32_t *p = (uint32_t*)(rel[i].r_offset + head->delta);
uintptr_t offs = 0;
uintptr_t end = 0;
size_t size = sym->st_size;
elfheader_t* h_tls = NULL;//head;
int version = head->VerSym?((Elf32_Half*)((uintptr_t)head->VerSym+head->delta))[ELF32_R_SYM(rel[i].r_info)]:-1;
if(version!=-1) version &=0x7fff;
const char* vername = GetSymbolVersion(head, version);
const char* defver = GetDefaultVersion((bind==STB_WEAK)?my_context->weakdefver:my_context->globaldefver, symname);
if(bind==STB_LOCAL) {
if(!symname || !symname[0]) {
offs = sym->st_value + head->delta;
end = offs + sym->st_size;
} else {
if(!offs && !end && local_maplib)
GetLocalSymbolStartEnd(local_maplib, symname, &offs, &end, head, version, vername);
if(!offs && !end)
GetLocalSymbolStartEnd(maplib, symname, &offs, &end, head, version, vername);
}
offs = sym->st_value + head->delta;
end = offs + sym->st_size;
} else {
// this is probably very very wrong. A proprer way to get reloc need to be writen, but this hack seems ok for now
// at least it work for half-life, unreal, ut99, zsnes, Undertale, ColinMcRae Remake, FTL, ShovelKnight...
@@ -503,11 +494,11 @@ int RelocateElfREL(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t*
globoffs = offs;
globend = end;
offs = end = 0;
GetSizedSymbolStartEnd(GetGlobalData(maplib), symname, &offs, &end, size, version, vername, 1, defver); // try globaldata symbols first
GetSymbolStartEnd(GetGlobalData(maplib), symname, &offs, &end, version, vername, 1, defver); // try globaldata symbols first
if(!offs && local_maplib)
GetNoSelfSymbolStartEnd(local_maplib, symname, &offs, &end, head, size, version, vername);
GetNoSelfSymbolStartEnd(local_maplib, symname, &offs, &end, head, version, vername);
if(!offs)
GetNoSelfSymbolStartEnd(maplib, symname, &offs, &end, head, size, version, vername);
GetNoSelfSymbolStartEnd(maplib, symname, &offs, &end, head, version, vername);
if(!offs) {offs = globoffs; end = globend;}
if(offs) {
// add r_addend to p?
@@ -519,7 +510,7 @@ int RelocateElfREL(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t*
}
break;
case R_386_GLOB_DAT:
if(head!=my_context->elfs[0] && !IsGlobalNoWeakSymbolInNative(maplib, symname, version, vername) && FindR386COPYRel(my_context->elfs[0], symname, &globoffs, &globp, size, version, vername)) {
if(head!=my_context->elfs[0] && !IsGlobalNoWeakSymbolInNative(maplib, symname, version, vername) && FindR386COPYRel(my_context->elfs[0], symname, &globoffs, &globp, version, vername)) {
// set global offs / size for the symbol
offs = sym->st_value + head->delta;
end = offs + sym->st_size;
@@ -584,10 +575,8 @@ int RelocateElfREL(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t*
break;
case R_386_32:
if (!offs) {
if(strcmp(symname, "__gmon_start__") && strcmp(symname, "data_start") && strcmp(symname, "__data_start")) {
printf_log(LOG_NONE, "Error: Symbol sym=%s(%s%s%s/version %d) not found, cannot apply R_386_32 %p (%p) in %s\n", symname, symname, vername?"@":"", vername?vername:"", version, p, *(void**)p, head->name);
ret_ok = 1;
}
printf_log(LOG_NONE, "Error: Symbol sym=%s(%s%s%s/version %d) not found, cannot apply R_386_32 %p (%p) in %s\n", symname, symname, vername?"@":"", vername?vername:"", version, p, *(void**)p, head->name);
ret_ok = 1;
} else {
printf_dump(LOG_NEVER, "Apply %s R_386_32 %p with sym=%s (ver=%d/%s) (%p -> %p)\n", (bind==STB_LOCAL)?"Local":((bind==STB_WEAK)?"Weak":"Global"), p, symname, version, vername?vername:"(none)", *(void**)p, (void*)(offs+*(uint32_t*)p));
*p += offs;
@@ -596,7 +585,7 @@ int RelocateElfREL(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t*
case R_386_TLS_TPOFF:
// Negated offset in static TLS block
{
if(!symname || !symname[0] || bind==STB_LOCAL) {
if(!symname || !symname[0]) {
h_tls = head;
offs = sym->st_value;
} else {
@@ -666,12 +655,12 @@ int RelocateElfREL(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t*
printf_log(LOG_NONE, "Error: Symbol %s not found, cannot apply R_386_TLS_DTPOFF32 %p (%p) in %s\n", symname, p, *(void**)p, head->name);
}
} else {
if(!symname || !symname[0]) {
offs = (uintptr_t)((intptr_t)(head->tlsaddr + head->delta) - (intptr_t)offs); // negative offset
}
if(h_tls)
offs = sym->st_value;
if(p) {
printf_dump(LOG_NEVER, "Apply %s R_386_TLS_DTPOFF32 %p with sym=%s (ver=%d/%s) (%zd -> %zd)\n", (bind==STB_LOCAL)?"Local":((bind==STB_WEAK)?"Weak":"Global"), p, symname, version, vername?vername:"(none)", (intptr_t)*p, (intptr_t)offs);
*p = offs;
int tlsoffset = offs; // it's not an offset in elf memory
printf_dump(LOG_NEVER, "Apply %s R_386_TLS_DTPOFF32 %p with sym=%s (%p -> %p)\n", (bind==STB_LOCAL)?"Local":((bind==STB_WEAK)?"Weak":"Global"), p, symname, (void*)tlsoffset, (void*)offs);
*p = tlsoffset;
} else {
printf_log(LOG_NONE, "Warning, Symbol %s found, but R_386_TLS_DTPOFF32 Slot Offset is NULL \n", symname);
}
@@ -696,22 +685,14 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t
uint32_t *p = (uint32_t*)(rela[i].r_offset + head->delta);
uintptr_t offs = 0;
uintptr_t end = 0;
size_t size = sym->st_size;
elfheader_t* h_tls = NULL;//head;
int version = head->VerSym?((Elf32_Half*)((uintptr_t)head->VerSym+head->delta))[ELF32_R_SYM(rela[i].r_info)]:-1;
if(version!=-1) version &=0x7fff;
const char* vername = GetSymbolVersion(head, version);
const char* defver = GetDefaultVersion((bind==STB_WEAK)?my_context->weakdefver:my_context->globaldefver, symname);
if(bind==STB_LOCAL) {
if(!symname || !symname[0]) {
offs = sym->st_value + head->delta;
end = offs + sym->st_size;
} else {
if(!offs && !end && local_maplib)
GetLocalSymbolStartEnd(local_maplib, symname, &offs, &end, head, version, vername);
if(!offs && !end)
GetLocalSymbolStartEnd(maplib, symname, &offs, &end, head, version, vername);
}
offs = sym->st_value + head->delta;
end = offs + sym->st_size;
} else {
// this is probably very very wrong. A proprer way to get reloc need to be writen, but this hack seems ok for now
// at least it work for half-life, unreal, ut99, zsnes, Undertale, ColinMcRae Remake, FTL, ShovelKnight...
@@ -755,9 +736,9 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t
offs = end = 0;
GetSymbolStartEnd(GetGlobalData(maplib), symname, &offs, &end, version, vername, 1, defver); // try globaldata symbols first
if(!offs && local_maplib)
GetNoSelfSymbolStartEnd(local_maplib, symname, &offs, &end, head, size, version, vername);
GetNoSelfSymbolStartEnd(local_maplib, symname, &offs, &end, head, version, vername);
if(!offs)
GetNoSelfSymbolStartEnd(maplib, symname, &offs, &end, head, size, version, vername);
GetNoSelfSymbolStartEnd(maplib, symname, &offs, &end, head, version, vername);
if(!offs) {offs = globoffs; end = globend;}
if(offs) {
// add r_addend to p?
@@ -769,7 +750,7 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t
}
break;
case R_386_GLOB_DAT:
if(head!=my_context->elfs[0] && !IsGlobalNoWeakSymbolInNative(maplib, symname, version, vername) && FindR386COPYRel(my_context->elfs[0], symname, &globoffs, &globp, size, version, vername)) {
if(head!=my_context->elfs[0] && !IsGlobalNoWeakSymbolInNative(maplib, symname, version, vername) && FindR386COPYRel(my_context->elfs[0], symname, &globoffs, &globp, version, vername)) {
// set global offs / size for the symbol
offs = sym->st_value + head->delta;
end = offs + sym->st_size;
@@ -844,7 +825,7 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t
case R_386_TLS_TPOFF:
// Negated offset in static TLS block
{
if(!symname || !symname[0] || bind==STB_LOCAL) {
if(!symname || !symname[0]) {
h_tls = head;
offs = sym->st_value;
} else {
@@ -914,9 +895,8 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t
printf_log(LOG_NONE, "Error: Symbol %s not found, cannot apply R_386_TLS_DTPOFF32 %p (%p) in %s\n", symname, p, *(void**)p, head->name);
}
} else {
if(!symname || !symname[0]) {
offs = (uintptr_t)((intptr_t)(head->tlsaddr + head->delta) - (intptr_t)offs); // negative offset
}
if(h_tls)
offs = sym->st_value;
if(p) {
int tlsoffset = offs; // it's not an offset in elf memory
printf_dump(LOG_NEVER, "Apply %s R_386_TLS_DTPOFF32 %p with sym=%s (%p -> %p)\n", (bind==STB_LOCAL)?"Local":((bind==STB_WEAK)?"Weak":"Global"), p, symname, (void*)tlsoffset, (void*)offs);
@@ -970,7 +950,7 @@ int RelocateElfPlt(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t*
return -1;
}
if(need_resolver) {
if(pltResolver==~(uintptr_t)0) {
if(pltResolver==~0) {
pltResolver = AddBridge(my_context->system, vFEv, PltResolver, 0, "(PltResolver)");
}
if(head->pltgot) {
@@ -988,7 +968,7 @@ int RelocateElfPlt(lib_t *maplib, lib_t *local_maplib, int bindnow, elfheader_t*
return 0;
}
void CalcStack(elfheader_t* elf, uint32_t* stacksz, uint32_t* stackalign)
void CalcStack(elfheader_t* elf, uint32_t* stacksz, int* stackalign)
{
if(*stacksz < elf->stacksz)
*stacksz = elf->stacksz;
@@ -999,7 +979,7 @@ void CalcStack(elfheader_t* elf, uint32_t* stacksz, uint32_t* stackalign)
Elf32_Sym* GetFunction(elfheader_t* h, const char* name)
{
// TODO: create a hash on named to avoid this loop
for (uint32_t i=0; i<h->numSymTab; ++i) {
for (int i=0; i<h->numSymTab; ++i) {
int type = ELF32_ST_TYPE(h->SymTab[i].st_info);
if(type==STT_FUNC) {
const char * symname = h->StrTab+h->SymTab[i].st_name;
@@ -1013,7 +993,7 @@ Elf32_Sym* GetFunction(elfheader_t* h, const char* name)
Elf32_Sym* GetElfObject(elfheader_t* h, const char* name)
{
for (uint32_t i=0; i<h->numSymTab; ++i) {
for (int i=0; i<h->numSymTab; ++i) {
int type = ELF32_ST_TYPE(h->SymTab[i].st_info);
if(type==STT_OBJECT) {
const char * symname = h->StrTab+h->SymTab[i].st_name;
@@ -1035,7 +1015,6 @@ uintptr_t GetFunctionAddress(elfheader_t* h, const char* name)
uintptr_t GetEntryPoint(lib_t* maplib, elfheader_t* h)
{
(void)maplib;
uintptr_t ep = h->entrypoint + h->delta;
printf_log(LOG_DEBUG, "Entry Point is %p\n", (void*)ep);
if(box86_dump) {
@@ -1082,7 +1061,7 @@ void AddSymbols(lib_t *maplib, kh_mapsymbols_t* mapsymbols, kh_mapsymbols_t* wea
printf_dump(LOG_NEVER, "Adding %s Default Version \"%s\" for Symbol\"%s\"\n", (bind==STB_WEAK)?"Weak":"Global", vername, symname);
}
if((type==STT_OBJECT || type==STT_FUNC || type==STT_COMMON || type==STT_TLS || type==STT_NOTYPE)
&& (vis==STV_DEFAULT || vis==STV_PROTECTED || (vis==STV_HIDDEN && bind==STB_LOCAL)) && (h->SymTab[i].st_shndx!=0)) {
&& (vis==STV_DEFAULT || vis==STV_PROTECTED) && (h->SymTab[i].st_shndx!=0)) {
if(strstr(symname, "@@")) {
char symnameversionned[strlen(symname)+1];
strcpy(symnameversionned, symname);
@@ -1129,7 +1108,7 @@ void AddSymbols(lib_t *maplib, kh_mapsymbols_t* mapsymbols, kh_mapsymbols_t* wea
int type = ELF32_ST_TYPE(h->DynSym[i].st_info);
int vis = h->DynSym[i].st_other&0x3;
if((type==STT_OBJECT || type==STT_FUNC || type==STT_COMMON || type==STT_TLS || type==STT_NOTYPE)
&& (vis==STV_DEFAULT || vis==STV_PROTECTED || (vis==STV_HIDDEN && bind==STB_LOCAL)) && (h->DynSym[i].st_shndx!=0 && h->DynSym[i].st_shndx<=65521)) {
&& (vis==STV_DEFAULT || vis==STV_PROTECTED) && (h->DynSym[i].st_shndx!=0 && h->DynSym[i].st_shndx<=65521)) {
uintptr_t offs = (type==STT_TLS)?h->DynSym[i].st_value:(h->DynSym[i].st_value + h->delta);
size_t sz = h->DynSym[i].st_size;
int version = h->VerSym?((Elf32_Half*)((uintptr_t)h->VerSym+h->delta))[i]:-1;
@@ -1175,7 +1154,7 @@ int LoadNeededLibs(elfheader_t* h, lib_t* maplib, needed_libs_t* neededlibs, lib
{
DumpDynamicRPath(h);
// update RPATH first
for (uint32_t i=0; i<h->numDynamic; ++i)
for (int i=0; i<h->numDynamic; ++i)
if(h->Dynamic[i].d_tag==DT_RPATH || h->Dynamic[i].d_tag==DT_RUNPATH) {
char *rpathref = h->DynStrTab+h->delta+h->Dynamic[i].d_un.d_val;
char* rpath = rpathref;
@@ -1232,12 +1211,12 @@ int LoadNeededLibs(elfheader_t* h, lib_t* maplib, needed_libs_t* neededlibs, lib
DumpDynamicNeeded(h);
int cnt = 0;
for (uint32_t i=0; i<h->numDynamic; ++i)
for (int i=0; i<h->numDynamic; ++i)
if(h->Dynamic[i].d_tag==DT_NEEDED)
++cnt;
const char* nlibs[cnt];
int j=0;
for (uint32_t i=0; i<h->numDynamic; ++i)
for (int i=0; i<h->numDynamic; ++i)
if(h->Dynamic[i].d_tag==DT_NEEDED)
nlibs[j++] = h->DynStrTab+h->delta+h->Dynamic[i].d_un.d_val;
@@ -1254,7 +1233,7 @@ int ElfCheckIfUseTCMallocMinimal(elfheader_t* h)
{
if(!h)
return 0;
for (uint32_t i=0; i<h->numDynamic; ++i)
for (int i=0; i<h->numDynamic; ++i)
if(h->Dynamic[i].d_tag==DT_NEEDED) {
char *needed = h->DynStrTab+h->delta+h->Dynamic[i].d_un.d_val;
if(!strcmp(needed, "libtcmalloc_minimal.so.4")) // tcmalloc needs to be the 1st lib loaded
@@ -1289,34 +1268,6 @@ void MarkElfInitDone(elfheader_t* h)
if(h)
h->init_done = 1;
}
void RunElfInitPltResolver(elfheader_t* h, x86emu_t *emu)
{
if(!h || h->init_done)
return;
uintptr_t p = h->initentry + h->delta;
h->init_done = 1;
for(int i=0; i<h->neededlibs->size; ++i) {
library_t *lib = h->neededlibs->libs[i];
elfheader_t *lib_elf = GetElf(lib);
if(lib_elf)
RunElfInitPltResolver(lib_elf, emu);
}
printf_log(LOG_DEBUG, "Calling Init for %s %p\n", ElfName(h), (void*)p);
if(h->initentry)
RunSafeFunction(my_context, p, 3, my_context->argc, my_context->argv, my_context->envv);
printf_log(LOG_DEBUG, "Done Init for %s\n", ElfName(h));
// and check init array now
Elf32_Addr *addr = (Elf32_Addr*)(h->initarray + h->delta);
for (int i=0; i<h->initarray_sz; ++i) {
printf_log(LOG_DEBUG, "Calling Init[%d] for %s %p\n", i, ElfName(h), (void*)addr[i]);
RunSafeFunction(my_context, (uintptr_t)addr[i], 3, my_context->argc, my_context->argv, my_context->envv);
}
h->fini_done = 0; // can be fini'd now (in case it was re-inited)
printf_log(LOG_DEBUG, "All Init Done for %s\n", ElfName(h));
return;
}
void RunElfInit(elfheader_t* h, x86emu_t *emu)
{
if(!h || h->init_done)
@@ -1453,7 +1404,7 @@ const char* FindNearestSymbolName(elfheader_t* h, void* p, uintptr_t* start, uin
if(!h)
return ret;
for (uint32_t i=0; (i<h->numSymTab) && (distance!=0); ++i) {
for (int i=0; (i<h->numSymTab) && (distance!=0); ++i) {
const char * symname = h->StrTab+h->SymTab[i].st_name;
uintptr_t offs = h->SymTab[i].st_value + h->delta;
@@ -1466,7 +1417,7 @@ const char* FindNearestSymbolName(elfheader_t* h, void* p, uintptr_t* start, uin
}
}
}
for (uint32_t i=0; (i<h->numDynSym) && (distance!=0); ++i) {
for (int i=0; (i<h->numDynSym) && (distance!=0); ++i) {
const char * symname = h->DynStr+h->DynSym[i].st_name;
uintptr_t offs = h->DynSym[i].st_value + h->delta;
@@ -1587,7 +1538,7 @@ void* ElfSetBrk(void* newbrk)
printf_log(LOG_NONE, "Error, using brk on multi-part memory elf is not allowed for now");
} else {
printf_log(LOG_DEBUG, "brk change, start=%p with reserve=0x%x, was 0x%x long, will be 0x%x now => %p\n", my_context->brk, h->reserve, my_context->brksz, added, my_context->brk+added);
if(added>0 && (uint32_t)added<h->reserve) {
if(added>0 && added<h->reserve) {
my_context->brksz = added;
return newbrk;
}
@@ -1607,7 +1558,7 @@ void* ElfSetBrk(void* newbrk)
}
#ifdef DYNAREC
dynablocklist_t* GetDynablocksFromAddress(box86context_t *context, uintptr_t addr)
dynablock_t* GetDynablocksFromAddress(box86context_t *context, uintptr_t addr)
{
// if we are here, the there is not block in standard "space"
/*dynablocklist_t* ret = getDBFromAddress(addr);
@@ -1616,7 +1567,7 @@ dynablocklist_t* GetDynablocksFromAddress(box86context_t *context, uintptr_t add
}*/
if(box86_dynarec_forced) {
addDBFromAddressRange(addr, 1);
return getDB(addr>>DYNAMAP_SHIFT);
return getDB(addr);
}
//check if address is in an elf... if yes, grant a block (should I warn)
Dl_info info;
@@ -1720,7 +1671,7 @@ EXPORT int my_dl_iterate_phdr(x86emu_t *emu, void* F, void *data) {
void ResetSpecialCaseMainElf(elfheader_t* h)
{
Elf32_Sym *sym = NULL;
for (uint32_t i=0; i<h->numDynSym; ++i) {
for (int i=0; i<h->numDynSym; ++i) {
if(h->DynSym[i].st_info == 17) {
sym = h->DynSym+i;
const char * symname = h->DynStr+sym->st_name;
@@ -1808,7 +1759,6 @@ typedef struct search_symbol_s{
} search_symbol_t;
int dl_iterate_phdr_findsymbol(struct dl_phdr_info* info, size_t size, void* data)
{
(void)size;
search_symbol_t* s = (search_symbol_t*)data;
for(int j = 0; j<info->dlpi_phnum; ++j) {
@@ -1873,7 +1823,7 @@ void* GetNativeSymbolUnversionned(void* lib, const char* name)
return s.addr;
}
uintptr_t pltResolver = ~(uintptr_t)0;
uintptr_t pltResolver = ~0;
EXPORT void PltResolver(x86emu_t* emu)
{
uintptr_t addr = Pop32(emu);
@@ -1905,12 +1855,6 @@ EXPORT void PltResolver(x86emu_t* emu)
emu->quit = 1;
return;
} else {
elfheader_t* sym_elf = FindElfAddress(my_context, offs);
if(sym_elf && sym_elf!=my_context->elfs[0] && !sym_elf->init_done) {
printf_dump(LOG_DEBUG, "symbol %s from %s but elf not initialized yet, run Init now (from %s)\n", symname, ElfName(sym_elf), ElfName(h));
RunElfInitPltResolver(sym_elf, emu);
}
if(p) {
printf_dump(LOG_DEBUG, " Apply %s R_386_JMP_SLOT %p with sym=%s(ver %d: %s%s%s) (%p -> %p / %s)\n", (bind==STB_LOCAL)?"Local":((bind==STB_WEAK)?"Weak":"Global"), p, symname, version, symname, vername?"@":"", vername?vername:"",*(void**)p, (void*)offs, ElfName(FindElfAddress(my_context, offs)));
*p = offs;
+9 -13
View File
@@ -1,10 +1,6 @@
#ifndef __ELFLOADER_PRIVATE_H_
#define __ELFLOADER_PRIVATE_H_
#ifdef DYNAREC
typedef struct dynablocklist_s dynablocklist_t;
#endif
typedef struct library_s library_t;
typedef struct needed_libs_s needed_libs_t;
typedef struct kh_mapsymbols_s kh_mapsymbols_t;
@@ -15,21 +11,21 @@ typedef struct kh_mapsymbols_s kh_mapsymbols_t;
struct elfheader_s {
char* name;
char* path; // Resolved path to file
uint16_t numPHEntries;
int numPHEntries;
Elf32_Phdr *PHEntries;
uint16_t numSHEntries;
int numSHEntries;
Elf32_Shdr *SHEntries;
int SHIdx;
int numSST;
char* SHStrTab;
char* StrTab;
Elf32_Sym* SymTab;
uint32_t numSymTab;
int numSymTab;
char* DynStr;
Elf32_Sym* DynSym;
uint32_t numDynSym;
int numDynSym;
Elf32_Dyn* Dynamic;
uint32_t numDynamic;
int numDynamic;
char* DynStrTab;
int szDynStrTab;
Elf32_Half* VerSym;
@@ -73,15 +69,15 @@ struct elfheader_s {
uintptr_t paddr;
uintptr_t vaddr;
uint32_t align;
int align;
uint32_t memsz;
uint32_t reserve;
uint32_t stacksz;
uint32_t stackalign;
int stackalign;
uintptr_t tlsaddr;
uint32_t tlssize;
uint32_t tlsfilesize;
uint32_t tlsalign;
int tlsalign;
int32_t tlsbase; // the base of the tlsdata in the global tlsdata (always negative)
@@ -116,4 +112,4 @@ struct elfheader_s {
elfheader_t* ParseElfHeader(FILE* f, const char* name, int exec);
#endif //__ELFLOADER_PRIVATE_H_
#endif //__ELFLOADER_PRIVATE_H_
+3 -3
View File
@@ -43,7 +43,7 @@ int FindSection(Elf32_Shdr *s, int n, char* SHStrTab, const char* name)
return 0;
}
void LoadNamedSection(FILE *f, Elf32_Shdr *s, int size, char* SHStrTab, const char* name, const char* clearname, uint32_t type, void** what, uint32_t* num)
void LoadNamedSection(FILE *f, Elf32_Shdr *s, int size, char* SHStrTab, const char* name, const char* clearname, uint32_t type, void** what, int* num)
{
int n = FindSection(s, size, SHStrTab, name);
printf_dump(LOG_DEBUG, "Loading %s (idx = %d)\n", clearname, n);
@@ -136,7 +136,7 @@ elfheader_t* ParseElfHeader(FILE* f, const char* name, int exec)
h->numSHEntries = section.sh_size;
}
// now read all section headers
printf_dump(LOG_DEBUG, "Read %u Section header\n", h->numSHEntries);
printf_dump(LOG_DEBUG, "Read %d Section header\n", h->numSHEntries);
h->SHEntries = (Elf32_Shdr*)box_calloc(h->numSHEntries, sizeof(Elf32_Shdr));
fseeko64(f, header.e_shoff ,SEEK_SET);
if(fread(h->SHEntries, sizeof(Elf32_Shdr), h->numSHEntries, f)!=h->numSHEntries) {
@@ -188,7 +188,7 @@ elfheader_t* ParseElfHeader(FILE* f, const char* name, int exec)
// grab DT_REL & DT_RELA stuffs
// also grab the DT_STRTAB string table
{
for (uint32_t i=0; i<h->numDynamic; ++i) {
for (int i=0; i<h->numDynamic; ++i) {
Elf32_Dyn d = h->Dynamic[i];
Elf32_Word val = d.d_un.d_val;
Elf32_Addr ptr = d.d_un.d_ptr;
+30 -34
View File
@@ -144,12 +144,16 @@
break;
}
NEXT;
_0f_0x19: /* HINT_NOP (multi-byte) */
_0f_0x1A: /* NOP (multi-byte) / ignored BNDLDX */
nextop = F8;
GET_ED;
NEXT;
_0f_0x1B: /* NOP (multi-byte) / ignored BNDSTX */
_0f_0x1C: /* HINT_NOP (multi-byte) */
_0f_0x1D: /* HINT_NOP (multi-byte) */
_0f_0x1E: /* HINT_NOP (multi-byte) */
nextop = F8;
GET_ED;
NEXT;
_0f_0x1F: /* NOP (multi-byte) */
nextop = F8;
GET_ED;
@@ -182,37 +186,31 @@
_0f_0x2C: /* CVTTPS2PI Gm, Ex */
nextop = F8;
GET_EX;
if(isnanf(EX->f[1]) || isinff(EX->f[1]) || EX->f[1]>0x7fffffff)
GM.sd[1] = 0x80000000;
else
GM.sd[1] = EX->f[1];
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>0x7fffffff)
GM.sd[0] = 0x80000000;
else
GM.sd[0] = EX->f[0];
GM.sd[1] = EX->f[1];
GM.sd[0] = EX->f[0];
NEXT;
_0f_0x2D: /* CVTPS2PI Gm, Ex */
// rounding should be done; and indefinite integer should also be assigned if overflow or NaN/Inf
nextop = F8;
GET_EX;
for(int i=1; i>=0; --i)
if(isnanf(EX->f[i]) || isinff(EX->f[i]) || EX->f[i]>0x7fffffff)
GM.sd[i] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {
case ROUND_Nearest:
GM.sd[i] = nearbyintf(EX->f[i]);
break;
case ROUND_Down:
GM.sd[i] = floorf(EX->f[i]);
break;
case ROUND_Up:
GM.sd[i] = ceilf(EX->f[i]);
break;
case ROUND_Chop:
GM.sd[i] = EX->f[i];
break;
}
switch((emu->mxcsr>>13)&3) {
case ROUND_Nearest:
GM.sd[1] = floorf(EX->f[1]+0.5f);
GM.sd[0] = floorf(EX->f[0]+0.5f);
break;
case ROUND_Down:
GM.sd[1] = floorf(EX->f[1]);
GM.sd[0] = floorf(EX->f[0]);
break;
case ROUND_Up:
GM.sd[1] = ceilf(EX->f[1]);
GM.sd[0] = ceilf(EX->f[0]);
break;
case ROUND_Chop:
GM.sd[1] = EX->f[1];
GM.sd[0] = EX->f[0];
break;
}
NEXT;
_0f_0x2E: /* UCOMISS Gx, Ex */
// same for now
@@ -902,12 +900,10 @@
fpu_fxrstor(emu, ED);
break;
case 2: /* LDMXCSR Md */
emu->mxcsr.x32 = ED->dword[0];
emu->mxcsr = ED->dword[0];
break;
case 3: /* STMXCSR Md */
ED->dword[0] = emu->mxcsr.x32;
if(box86_sse_flushto0)
applyFlushTo0(emu);
ED->dword[0] = emu->mxcsr;
break;
default:
goto _default;
+34 -53
View File
@@ -30,31 +30,25 @@
case 0x2C: /* CVTTSD2SI Gd, Ex */
nextop = F8;
GET_EX;
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
GD.dword[0] = 0x80000000;
else
GD.sdword[0] = EX->d[0];
GD.sdword[0] = EX->d[0];
break;
case 0x2D: /* CVTSD2SI Gd, Ex */
nextop = F8;
GET_EX;
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
GD.dword[0] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {
case ROUND_Nearest:
GD.sdword[0] = nearbyint(EX->d[0]);
break;
case ROUND_Down:
GD.sdword[0] = floor(EX->d[0]);
break;
case ROUND_Up:
GD.sdword[0] = ceil(EX->d[0]);
break;
case ROUND_Chop:
GD.sdword[0] = EX->d[0];
break;
}
switch((emu->mxcsr>>13)&3) {
case ROUND_Nearest:
GD.sdword[0] = floor(EX->d[0]+0.5);
break;
case ROUND_Down:
GD.sdword[0] = floor(EX->d[0]);
break;
case ROUND_Up:
GD.sdword[0] = ceil(EX->d[0]);
break;
case ROUND_Chop:
GD.sdword[0] = EX->d[0];
break;
}
break;
case 0x51: /* SQRTSD Gx, Ex */
nextop = F8;
@@ -125,7 +119,7 @@
case 0x5F: /* MAXSD Gx, Ex */
nextop = F8;
GET_EX;
if (isnan(GX.d[0]) || isnan(EX->d[0]) || isgreaterequal(EX->d[0], GX.d[0]))
if (isnan(GX.d[0]) || isnan(EX->d[0]) || isgreater(EX->d[0], GX.d[0]))
GX.d[0] = EX->d[0];
break;
@@ -157,19 +151,6 @@
GX.f[3] = EX->f[2] + EX->f[3];
}
break;
case 0x7D: /* HSUBPS Gx, Ex */
nextop = F8;
GET_EX;
GX.f[0] -= GX.f[1];
GX.f[1] = GX.f[2] - GX.f[3];
if(EX==&GX) {
GX.f[2] = GX.f[0];
GX.f[3] = GX.f[1];
} else {
GX.f[2] = EX->f[0] - EX->f[1];
GX.f[3] = EX->f[2] - EX->f[3];
}
break;
#define GOCOND(BASE, PREFIX, CONDITIONAL) \
case BASE+0: \
@@ -294,24 +275,24 @@
case 0xE6: /* CVTPD2DQ Gx, Ex */
nextop = F8;
GET_EX;
for(int i=0; i<2; ++i)
if(isnan(EX->d[i]) || isinf(EX->d[i]) || EX->d[i]>0x7fffffff)
GX.ud[i] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {
case ROUND_Nearest:
GX.sd[i] = nearbyint(EX->d[i]);
break;
case ROUND_Down:
GX.sd[i] = floor(EX->d[i]);
break;
case ROUND_Up:
GX.sd[i] = ceil(EX->d[i]);
break;
case ROUND_Chop:
GX.sd[i] = EX->d[i];
break;
}
switch((emu->mxcsr>>13)&3) {
case ROUND_Nearest:
GX.sd[0] = floor(EX->d[0]+0.5);
GX.sd[1] = floor(EX->d[1]+0.5);
break;
case ROUND_Down:
GX.sd[0] = floor(EX->d[0]);
GX.sd[1] = floor(EX->d[1]);
break;
case ROUND_Up:
GX.sd[0] = ceil(EX->d[0]);
GX.sd[1] = ceil(EX->d[1]);
break;
case ROUND_Chop:
GX.sd[0] = EX->d[0];
GX.sd[1] = EX->d[1];
break;
}
GX.q[1] = 0;
break;
+21 -28
View File
@@ -47,31 +47,25 @@
case 0x2C: /* CVTTSS2SI Gd, Ex */
nextop = F8;
GET_EX;
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>0x7fffffff)
GD.dword[0] = 0x80000000;
else
GD.sdword[0] = EX->f[0];
GD.sdword[0] = EX->f[0];
break;
case 0x2D: /* CVTSS2SI Gd, Ex */
nextop = F8;
GET_EX;
if(isnanf(EX->f[0]) || isinff(EX->f[0]) || EX->f[0]>0x7fffffff)
GD.dword[0] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {
case ROUND_Nearest:
GD.sdword[0] = nearbyintf(EX->f[0]);
break;
case ROUND_Down:
GD.sdword[0] = floorf(EX->f[0]);
break;
case ROUND_Up:
GD.sdword[0] = ceilf(EX->f[0]);
break;
case ROUND_Chop:
GD.sdword[0] = EX->f[0];
break;
}
switch((emu->mxcsr>>13)&3) {
case ROUND_Nearest:
GD.sdword[0] = floor(EX->f[0]+0.5);
break;
case ROUND_Down:
GD.sdword[0] = floor(EX->f[0]);
break;
case ROUND_Up:
GD.sdword[0] = ceil(EX->f[0]);
break;
case ROUND_Chop:
GD.sdword[0] = EX->f[0];
break;
}
break;
case 0x51: /* SQRTSS Gx, Ex */
@@ -108,11 +102,10 @@
case 0x5B: /* CVTTPS2DQ Gx, Ex */
nextop = F8;
GET_EX;
for(int i=0; i<4; ++i)
if(isnanf(EX->f[i]) || isinff(EX->f[i]) || EX->f[i]>0x7fffffff)
GX.ud[i] = 0x80000000;
else
GX.sd[i] = EX->f[i];
GX.sd[0] = EX->f[0];
GX.sd[1] = EX->f[1];
GX.sd[2] = EX->f[2];
GX.sd[3] = EX->f[3];
break;
case 0x5C: /* SUBSS Gx, Ex */
@@ -123,7 +116,7 @@
case 0x5D: /* MINSS Gx, Ex */
nextop = F8;
GET_EX;
if(isnan(GX.f[0]) || isnan(EX->f[0]) || islessequal(EX->f[0], GX.f[0]))
if(isnan(GX.f[0]) || isnan(EX->f[0]) || isless(EX->f[0], GX.f[0]))
GX.f[0] = EX->f[0];
break;
case 0x5E: /* DIVSS Gx, Ex */
@@ -134,7 +127,7 @@
case 0x5F: /* MAXSS Gx, Ex */
nextop = F8;
GET_EX;
if (isnan(GX.f[0]) || isnan(EX->f[0]) || isgreaterequal(EX->f[0], GX.f[0]))
if (isnan(GX.f[0]) || isnan(EX->f[0]) || isgreater(EX->f[0], GX.f[0]))
GX.f[0] = EX->f[0];
break;
+3 -28
View File
@@ -23,13 +23,6 @@
#ifdef DYNAREC
#include "custommem.h"
#endif
// for the applyFlushTo0
#ifdef __i386__
#include <immintrin.h>
#elif defined(__arm__)
#else
#warning Architecture cannot follow SSE Flush to 0 flag
#endif
typedef struct cleanup_s {
void* f;
@@ -88,13 +81,13 @@ static void internalX86Setup(x86emu_t* emu, box86context_t *context, uintptr_t s
emu->segs[_GS] = 0x33;
// setup fpu regs
reset_fpu(emu);
emu->mxcsr.x32 = 0x1f80;
emu->mxcsr = 0x1f80;
}
EXPORTDYN
x86emu_t *NewX86Emu(box86context_t *context, uintptr_t start, uintptr_t stack, int stacksize, int ownstack)
{
printf_log(LOG_DEBUG, "%04d|Allocate a new X86 Emu, with EIP=%p and Stack=%p/0x%X\n", GetTID(), (void*)start, (void*)stack, stacksize);
printf_log(LOG_DEBUG, "Allocate a new X86 Emu, with EIP=%p and Stack=%p/0x%X\n", (void*)start, (void*)stack, stacksize);
x86emu_t *emu = (x86emu_t*)box_calloc(1, sizeof(x86emu_t));
@@ -105,7 +98,7 @@ x86emu_t *NewX86Emu(box86context_t *context, uintptr_t start, uintptr_t stack, i
x86emu_t *NewX86EmuFromStack(x86emu_t* emu, box86context_t *context, uintptr_t start, uintptr_t stack, int stacksize, int ownstack)
{
printf_log(LOG_DEBUG, "%04d|New X86 Emu from stack, with EIP=%p and Stack=%p/0x%X\n", GetTID(), (void*)start, (void*)stack, stacksize);
printf_log(LOG_DEBUG, "New X86 Emu from stack, with EIP=%p and Stack=%p/0x%X\n", (void*)start, (void*)stack, stacksize);
internalX86Setup(emu, context, start, stack, stacksize, ownstack);
@@ -115,7 +108,6 @@ x86emu_t *NewX86EmuFromStack(x86emu_t* emu, box86context_t *context, uintptr_t s
EXPORTDYN
void SetupX86Emu(x86emu_t *emu)
{
(void)emu;
printf_log(LOG_DEBUG, "Setup X86 Emu\n");
}
@@ -136,7 +128,6 @@ void SetTraceEmu(uintptr_t start, uintptr_t end)
void AddCleanup(x86emu_t *emu, void *p)
{
(void)emu;
if(my_context->clean_sz == my_context->clean_cap) {
my_context->clean_cap += 4;
my_context->cleanups = (cleanup_t*)box_realloc(my_context->cleanups, sizeof(cleanup_t)*my_context->clean_cap);
@@ -148,7 +139,6 @@ void AddCleanup(x86emu_t *emu, void *p)
void AddCleanup1Arg(x86emu_t *emu, void *p, void* a)
{
(void)emu;
if(my_context->clean_sz == my_context->clean_cap) {
my_context->clean_cap += 4;
my_context->cleanups = (cleanup_t*)box_realloc(my_context->cleanups, sizeof(cleanup_t)*my_context->clean_cap);
@@ -468,7 +458,6 @@ static inline void init_perfcounters (int32_t do_reset, int32_t enable_divider)
uint64_t ReadTSC(x86emu_t* emu)
{
(void)emu;
// Read the TimeStamp Counter as 64bits.
// this is supposed to be the number of instructions executed since last reset
#if defined(__i386__)
@@ -508,17 +497,3 @@ void ResetSegmentsCache(x86emu_t *emu)
return;
memset(emu->segs_serial, 0, sizeof(emu->segs_serial));
}
void applyFlushTo0(x86emu_t* emu)
{
#ifdef __i386__
_mm_setcsr(_mm_getcsr() | (emu->mxcsr.x32&0x8040));
#elif defined(__arm__)
uint64_t fpscr = __builtin_arm_get_fpscr();
fpscr &= ~(1<<24); // clear bit FZ (24)
fpscr |= (emu->mxcsr.f.MXCSR_FZ)<<24; // set FZ as mxcsr FZ
__builtin_arm_set_fpscr(fpscr);
#else
(void)emu;
#endif
}
+1 -3
View File
@@ -40,7 +40,7 @@ typedef struct x86emu_s {
fpu_p_reg_t p_regs[8];
// sse
sse_regs_t xmm[8];
mmxcontrol_t mxcsr;
uint32_t mxcsr;
uintptr_t old_ip;
// defered flags
defered_flags_t df;
@@ -88,6 +88,4 @@ typedef struct x86emu_s {
//#define INTR_RAISE_DIV0(emu) {emu->error |= ERR_DIVBY0; emu->quit=1;}
#define INTR_RAISE_DIV0(emu) {emu->error |= ERR_DIVBY0;} // should rise a SIGFPE and not quit
void applyFlushTo0(x86emu_t* emu);
#endif //__X86EMU_PRIVATE_H_
+76 -103
View File
@@ -10,7 +10,6 @@
#include <sys/types.h>
#include <pthread.h>
#include <signal.h>
#include <wait.h>
#include "debug.h"
#include "box86stack.h"
@@ -54,10 +53,7 @@ x86emu_t* x86emu_fork(x86emu_t* emu, int forktype)
for (int i=0; i<my_context->atfork_sz; --i)
if(my_context->atforks[i].parent)
EmuCall(emu, my_context->atforks[i].parent);
if(forktype==3) {
// vfork, the parent wait the end or execve of the son
waitpid(v, NULL, WEXITED);
}
} else if(v==0) {
// execute atforks child functions
for (int i=0; i<my_context->atfork_sz; --i)
@@ -91,8 +87,6 @@ void x86Int3(x86emu_t* emu)
if(h && strstr(ElfName(h), "libMiles")) have_trace = 1;*/
if(box86_log>=LOG_DEBUG || cycle_log) {
int tid = GetTID();
const char *s = NULL;
s = GetNativeName((void*)addr);
char t_buff[256] = "\0";
char buff2[64] = "\0";
char buff3[64] = "\0";
@@ -100,220 +94,213 @@ void x86Int3(x86emu_t* emu)
char* buffret = cycle_log?my_context->log_ret[my_context->current_line]:NULL;
if(buffret) buffret[0] = '\0';
if(cycle_log)
my_context->current_line = (my_context->current_line+1)%cycle_log;
my_context->current_line = (my_context->current_line+1)&(CYCLE_LOG-1);
char *tmp;
int post = 0;
int perr = 0;
uint32_t *pu32 = NULL;
const char *s = NULL;
s = GetNativeName((void*)addr);
if(addr==(uintptr_t)PltResolver) {
snprintf(buff, 256, "%s", cycle_log?"PltResolver ":" ... ");
} else
if(strstr(s, "SDL_RWFromFile")==s || strstr(s, "SDL_RWFromFile")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%s, %s)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%s, %s)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(strstr(s, "glColor4f")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%f, %f, %f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8), *(float*)(R_ESP+12), *(float*)(R_ESP+16));
snprintf(buff, 255, "%04d|%p: Calling %s(%f, %f, %f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8), *(float*)(R_ESP+12), *(float*)(R_ESP+16));
} else if(strstr(s, "glTexCoord2f")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8));
} else if(strstr(s, "glVertex2f")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8));
} else if(strstr(s, "glVertex3f")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%f, %f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8), *(float*)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%f, %f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8), *(float*)(R_ESP+12));
} else if(strstr(s, "__open64")==s || strcmp(s, "open64")==0) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", %d, %d)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(int*)(R_ESP+8), *(int*)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", %d, %d)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(int*)(R_ESP+8), *(int*)(R_ESP+12));
perr = 1;
} else if(!strcmp(s, "opendir")) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
perr = 1;
} else if(strstr(s, "__open")==s || !strcmp(s, "open") || !strcmp(s, "my_open64")) {
tmp = *(char**)(R_ESP+4);
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", %d (,%d))", tid, *(void**)(R_ESP), s, (tmp)?tmp:"(nil)", *(int*)(R_ESP+8), *(int*)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", %d (,%d))", tid, *(void**)(R_ESP), s, (tmp)?tmp:"(nil)", *(int*)(R_ESP+8), *(int*)(R_ESP+12));
perr = 1;
} else if(!strcmp(s, "shm_open")) {
tmp = *(char**)(R_ESP+4);
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", %d, %d)", tid, *(void**)(R_ESP), s, (tmp)?tmp:"(nil)", *(int*)(R_ESP+8), *(int*)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", %d, %d)", tid, *(void**)(R_ESP), s, (tmp)?tmp:"(nil)", *(int*)(R_ESP+8), *(int*)(R_ESP+12));
perr = 1;
} else if(strcmp(s, "mkdir")==0) {
tmp = *(char**)(R_ESP+4);
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", %d)", tid, *(void**)(R_ESP), s, (tmp)?tmp:"(nil)", *(int*)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", %d)", tid, *(void**)(R_ESP), s, (tmp)?tmp:"(nil)", *(int*)(R_ESP+8));
perr = 1;
} else if(!strcmp(s, "fopen")) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", \"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", \"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
perr = 2;
} else if(!strcmp(s, "freopen")) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", \"%s\", %p)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", \"%s\", %p)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
perr = 2;
} else if(!strcmp(s, "fopen64")) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", \"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", \"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
perr = 2;
} else if(!strcmp(s, "chdir")) {
pu32=*(uint32_t**)(R_ESP+4);
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, pu32?((pu32==(uint32_t*)1)?"/1/":(char*)pu32):"/0/");
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, pu32?((pu32==(uint32_t*)1)?"/1/":(char*)pu32):"/0/");
} else if(strstr(s, "getenv")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
post = 2;
} else if(strstr(s, "putenv")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
} else if(strstr(s, "pread")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%d, %p, %u, %d)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(void**)(R_ESP+8), *(uint32_t*)(R_ESP+12), *(int32_t*)(R_ESP+16));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p, %u, %d)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(void**)(R_ESP+8), *(uint32_t*)(R_ESP+12), *(int32_t*)(R_ESP+16));
perr = 1;
} else if(!strcmp(s, "read")) {
snprintf(buff, 256, "%04d|%p: Calling %s(%d, %p, %u)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(void**)(R_ESP+8), *(uint32_t*)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p, %u)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(void**)(R_ESP+8), *(uint32_t*)(R_ESP+12));
perr = 1;
} else if(strstr(s, "ioctl")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%d, 0x%x, %p)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(int32_t*)(R_ESP+8), *(void**)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, 0x%x, %p)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(int32_t*)(R_ESP+8), *(void**)(R_ESP+12));
perr = 1;
} else if(strstr(s, "statvfs64")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p(\"%s\"), %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+4), *(void**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%p(\"%s\"), %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+4), *(void**)(R_ESP+8));
} else if(strstr(s, "index")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p(\"%s\"), %i(%c))", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+4), *(int32_t*)(R_ESP+8), *(int32_t*)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%p(\"%s\"), %i(%c))", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+4), *(int32_t*)(R_ESP+8), *(int32_t*)(R_ESP+8));
} else if(strstr(s, "rindex")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p(\"%s\"), %i(%c))", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+4), *(int32_t*)(R_ESP+8), *(int32_t*)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%p(\"%s\"), %i(%c))", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+4), *(int32_t*)(R_ESP+8), *(int32_t*)(R_ESP+8));
} else if(strstr(s, "__xstat64")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%d, %p(\"%s\"), %p)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(char**)(R_ESP+8), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p(\"%s\"), %p)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(char**)(R_ESP+8), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
perr = 1;
} else if(strcmp(s, "__xstat")==0) {
snprintf(buff, 256, "%04d|%p: Calling %s(%d, %p(\"%s\"), %p)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(char**)(R_ESP+8), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p(\"%s\"), %p)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(char**)(R_ESP+8), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
perr = 1;
} else if(strstr(s, "__lxstat64")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%d, %p(\"%s\"), %p)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(char**)(R_ESP+8), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p(\"%s\"), %p)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(char**)(R_ESP+8), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
perr = 1;
} else if(strstr(s, "sem_timedwait")==s) {
pu32 = *(uint32_t**)(R_ESP+8);
snprintf(buff, 256, "%04d|%p: Calling %s(%p, %p[%d sec %d ns])", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(void**)(R_ESP+8), pu32?(int32_t)pu32[0]:-1, pu32?(int32_t)pu32[1]:-1);
snprintf(buff, 255, "%04d|%p: Calling %s(%p, %p[%d sec %d ns])", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(void**)(R_ESP+8), pu32?pu32[0]:-1, pu32?pu32[1]:-1);
perr = 1;
} else if(strstr(s, "waitpid")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%d, %p, 0x%x)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(void**)(R_ESP+8), *(uint32_t*)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p, 0x%x)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(void**)(R_ESP+8), *(uint32_t*)(R_ESP+12));
perr = 1;
} else if(strstr(s, "clock_gettime")==s || strstr(s, "__clock_gettime")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%d, %p)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), *(void**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), *(void**)(R_ESP+8));
post = 1;
pu32 = *(uint32_t**)(R_ESP+8);
} else if(strstr(s, "semop")==s) {
int16_t* p16 = *(int16_t**)(R_ESP+8);
snprintf(buff, 256, "%04d|%p: Calling %s(%d, %p[%u/%d/0x%x], %d)", tid, *(void**)(R_ESP), s, *(int*)(R_ESP+4), p16, p16[0], p16[1], p16[2], *(int*)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p[%u/%d/0x%x], %d)", tid, *(void**)(R_ESP), s, *(int*)(R_ESP+4), p16, p16[0], p16[1], p16[2], *(int*)(R_ESP+12));
perr = 1;
} else if(!strcmp(s, "mmap64")) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, 0x%x, %d, 0x%x, %d, %lld)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(int*)(R_ESP+12), *(int*)(R_ESP+16), *(int*)(R_ESP+20), *(int64_t*)(R_ESP+24));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, 0x%x, %d, 0x%x, %d, %lld)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(int*)(R_ESP+12), *(int*)(R_ESP+16), *(int*)(R_ESP+20), *(int64_t*)(R_ESP+24));
perr = 3;
} else if(!strcmp(s, "mmap")) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, 0x%x, %d, 0x%x, %d, %d)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(int*)(R_ESP+12), *(int*)(R_ESP+16), *(int*)(R_ESP+20), *(int*)(R_ESP+24));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, 0x%x, %d, 0x%x, %d, %d)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(int*)(R_ESP+12), *(int*)(R_ESP+16), *(int*)(R_ESP+20), *(int*)(R_ESP+24));
perr = 3;
} else if(strstr(s, "strcasecmp")==s || strstr(s, "__strcasecmp")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", \"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", \"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(strstr(s, "gtk_signal_connect_full")) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, \"%s\", %p, %p, %p, %p, %d, %d)", tid, *(void**)(R_ESP), "gtk_signal_connect_full", *(void**)(R_ESP+4), *(char**)(R_ESP+8), *(void**)(R_ESP+12), *(void**)(R_ESP+16), *(void**)(R_ESP+20), *(void**)(R_ESP+24), *(int32_t*)(R_ESP+28), *(int32_t*)(R_ESP+32));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\", %p, %p, %p, %p, %d, %d)", tid, *(void**)(R_ESP), "gtk_signal_connect_full", *(void**)(R_ESP+4), *(char**)(R_ESP+8), *(void**)(R_ESP+12), *(void**)(R_ESP+16), *(void**)(R_ESP+20), *(void**)(R_ESP+24), *(int32_t*)(R_ESP+28), *(int32_t*)(R_ESP+32));
} else if(strstr(s, "strcmp")==s || strstr(s, "__strcmp")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", \"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", \"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(strstr(s, "strstr")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%.127s\", \"%.127s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%.127s\", \"%.127s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(strstr(s, "strlen")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p(\"%s\"))", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), ((R_ESP+4))?(*(char**)(R_ESP+4)):"nil");
snprintf(buff, 255, "%04d|%p: Calling %s(%p(\"%s\"))", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), ((R_ESP+4))?(*(char**)(R_ESP+4)):"nil");
} else if(strstr(s, "vsnprintf")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%08X, %u, %p(\"%s\")...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), *(uint32_t*)(R_ESP+8), *(void**)(R_ESP+12), *(char**)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%08X, %u, %08X...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), *(uint32_t*)(R_ESP+8), *(uint32_t*)(R_ESP+12));
pu32 = *(uint32_t**)(R_ESP+4);
post = 3;
} else if(strstr(s, "vsprintf")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, \"%s\", %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\", %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8), *(void**)(R_ESP+12));
pu32 = *(uint32_t**)(R_ESP+4);
post = 3;
} else if(strstr(s, "__vsprintf_chk")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, %d, %zu, \"%s\", %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(int*)(R_ESP+8), *(size_t*)(R_ESP+12), *(char**)(R_ESP+16), *(void**)(R_ESP+20));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, %d, %zu, \"%s\", %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(int*)(R_ESP+8), *(size_t*)(R_ESP+12), *(char**)(R_ESP+16), *(void**)(R_ESP+20));
pu32 = *(uint32_t**)(R_ESP+4);
post = 3;
} else if(strstr(s, "__snprintf_chk")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, %zu, %d, %d, \"%s\", %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(int*)(R_ESP+12), *(int*)(R_ESP+16), *(char**)(R_ESP+20), *(void**)(R_ESP+24));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, %zu, %d, %d, \"%s\", %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(int*)(R_ESP+12), *(int*)(R_ESP+16), *(char**)(R_ESP+20), *(void**)(R_ESP+24));
pu32 = *(uint32_t**)(R_ESP+4);
post = 3;
} else if(strstr(s, "snprintf")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, %zu, \"%s\", ...)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(char**)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, %zu, \"%s\", ...)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(char**)(R_ESP+12));
pu32 = *(uint32_t**)(R_ESP+4);
post = 3;
} else if(strstr(s, "sprintf")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%08X, %08X...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), *(uint32_t*)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%08X, %08X...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), *(uint32_t*)(R_ESP+8));
pu32 = *(uint32_t**)(R_ESP+4);
post = 3;
} else if(strstr(s, "printf")==s) {
pu32 = *(uint32_t**)(R_ESP+4);
if(((uintptr_t)pu32)<0x5) // probably a _chk function
pu32 = *(uint32_t**)(R_ESP+8);
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\"...)", tid, *(void**)(R_ESP), s, pu32?((char*)(pu32)):"nil");
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\"...)", tid, *(void**)(R_ESP), s, pu32?((char*)(pu32)):"nil");
} else if(strstr(s, "wprintf")==s) {
pu32 = *(uint32_t**)(R_ESP+4);
if(((uintptr_t)pu32)<0x5) // probably a _chk function
pu32 = *(uint32_t**)(R_ESP+8);
snprintf(buff, 256, "%04d|%p: Calling %s(\"%S\"...)", tid, *(void**)(R_ESP), s, pu32?((wchar_t*)(pu32)):L"nil");
snprintf(buff, 255, "%04d|%p: Calling %s(\"%S\"...)", tid, *(void**)(R_ESP), s, pu32?((wchar_t*)(pu32)):L"nil");
} else if(strstr(s, "__vswprintf")==s) {
if(*(size_t*)(R_ESP+12)<2) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, %zu, %p, %p, %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(void**)(R_ESP+12), *(void**)(R_ESP+16), *(void**)(R_ESP+20));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, %zu, %p, %p, %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(void**)(R_ESP+12), *(void**)(R_ESP+16), *(void**)(R_ESP+20));
} else {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, %zu, \"%S\", %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(wchar_t**)(R_ESP+12), *(void**)(R_ESP+16));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, %zu, \"%S\", %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(size_t*)(R_ESP+8), *(wchar_t**)(R_ESP+12), *(void**)(R_ESP+16));
pu32 = *(uint32_t**)(R_ESP+4);
post = 6;
}
} else if(strstr(s, "puts")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\"...)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\"...)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
} else if(strstr(s, "fputs")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", %p...)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(void**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", %p...)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(void**)(R_ESP+8));
} else if(strstr(s, "fprintf")==s) {
pu32 = *(uint32_t**)(R_ESP+8);
if(((uintptr_t)pu32)<0x5) // probably a __fprint_chk
pu32 = *(uint32_t**)(R_ESP+12);
snprintf(buff, 256, "%04d|%p: Calling %s(%08X, \"%s\", ...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), pu32?((char*)(pu32)):"nil");
snprintf(buff, 255, "%04d|%p: Calling %s(%08X, \"%s\", ...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), pu32?((char*)(pu32)):"nil");
} else if(strstr(s, "vfprintf")==s) {
pu32 = *(uint32_t**)(R_ESP+8);
if(((uintptr_t)pu32)<0x5) // probably a _chk function
pu32 = *(uint32_t**)(R_ESP+12);
snprintf(buff, 256, "%04d|%p: Calling %s(%08X, \"%s\", ...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), pu32?((char*)(pu32)):"nil");
snprintf(buff, 255, "%04d|%p: Calling %s(%08X, \"%s\", ...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), pu32?((char*)(pu32)):"nil");
} else if(strstr(s, "vkGetInstanceProcAddr")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, \"%s\")", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\")", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(strstr(s, "vkGetDeviceProcAddr")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, \"%s\")", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\")", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(strstr(s, "glXGetProcAddress")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4));
} else if(strstr(s, "sscanf")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", \"%s\", ...)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", \"%s\", ...)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(!strcmp(s, "vsscanf")) {
snprintf(buff, 256, "%04d|%p: Calling %s(\"%s\", \"%s\", ...)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", \"%s\", ...)", tid, *(void**)(R_ESP), s, *(char**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(strstr(s, "XCreateWindow")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, %p, %d, %d, %u, %u, %u, %d, %u, %p, %u, %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(void**)(R_ESP+8), *(int*)(R_ESP+12), *(int*)(R_ESP+16), *(uint32_t*)(R_ESP+20), *(uint32_t*)(R_ESP+24), *(uint32_t*)(R_ESP+28), *(int32_t*)(R_ESP+32), *(uint32_t*)(R_ESP+36), *(void**)(R_ESP+40), *(uint32_t*)(R_ESP+44), *(void**)(R_ESP+48));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, %p, %d, %d, %u, %u, %u, %d, %u, %p, %u, %p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(void**)(R_ESP+8), *(int*)(R_ESP+12), *(int*)(R_ESP+16), *(uint32_t*)(R_ESP+20), *(uint32_t*)(R_ESP+24), *(uint32_t*)(R_ESP+28), *(int32_t*)(R_ESP+32), *(uint32_t*)(R_ESP+36), *(void**)(R_ESP+40), *(uint32_t*)(R_ESP+44), *(void**)(R_ESP+48));
} else if(strstr(s, "XLoadQueryFont")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, \"%s\")", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\")", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(strstr(s, "pthread_mutex_lock")==s) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4));
snprintf(buff, 255, "%04d|%p: Calling %s(%p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4));
} else if(!strcmp(s, "fmodf")) {
post = 4;
snprintf(buff, 256, "%04d|%p: Calling %s(%f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%f, %f)", tid, *(void**)(R_ESP), s, *(float*)(R_ESP+4), *(float*)(R_ESP+8));
} else if(!strcmp(s, "fmod")) {
post = 4;
snprintf(buff, 256, "%04d|%p: Calling %s(%f, %f)", tid, *(void**)(R_ESP), s, *(double*)(R_ESP+4), *(double*)(R_ESP+12));
snprintf(buff, 255, "%04d|%p: Calling %s(%f, %f)", tid, *(void**)(R_ESP), s, *(double*)(R_ESP+4), *(double*)(R_ESP+12));
} else if(strstr(s, "SDL_GetWindowSurface")==s) {
post = 5;
snprintf(buff, 256, "%04d|%p: Calling %s(%p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4));
snprintf(buff, 255, "%04d|%p: Calling %s(%p)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4));
} else if(strstr(s, "udev_monitor_new_from_netlink")==s) {
post = 5;
snprintf(buff, 256, "%04d|%p: Calling %s(%p, \"%s\")", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8));
snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\")", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(char**)(R_ESP+8));
} else if(!strcmp(s, "syscall")) {
snprintf(buff, 256, "%04d|%p: Calling %s(%d, %p, %p, %p...)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(void**)(R_ESP+8), *(void**)(R_ESP+12), *(void**)(R_ESP+16));
snprintf(buff, 255, "%04d|%p: Calling %s(%d, %p, %p, %p...)", tid, *(void**)(R_ESP), s, *(int32_t*)(R_ESP+4), *(void**)(R_ESP+8), *(void**)(R_ESP+12), *(void**)(R_ESP+16));
perr = 1;
} else if(strstr(s, "___tls_get_addr")) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p[%d, %d])", tid, *(void**)(R_ESP), s, (void*)(R_EAX), ((int*)(R_EAX))[0], ((int*)(R_EAX))[1]);
} else if(strstr(s, "__tls_get_addr")) {
pu32 = *(uint32_t**)(R_ESP+4);
snprintf(buff, 256, "%04d|%p: Calling %s(%p[%d, %d])", tid, *(void**)(R_ESP), s, pu32, pu32[0], pu32[1]);
} else if (!strcmp(s, "XDrawImageString")) {
snprintf(buff, 256, "%04d|%p: Calling %s(%p, %p, %p, %i, %i, %p\"%s\", %d)", tid, *(void**)(R_ESP), s, *(void**)(R_ESP+4), *(void**)(R_ESP+8), *(void**)(R_ESP+12), *(int*)(R_ESP+16), *(int*)(R_ESP+20), *(char**)(R_ESP+24), *(char**)(R_ESP+24), *(int*)(R_ESP+28));
} else {
snprintf(buff, 256, "%04d|%p: Calling %s (%08X, %08X, %08X...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), *(uint32_t*)(R_ESP+8), *(uint32_t*)(R_ESP+12));
}
if(!cycle_log) {
mutex_lock(&emu->context->mutex_trace);
printf_log(LOG_NONE, "%s =>", buff);
mutex_unlock(&emu->context->mutex_trace);
snprintf(buff, 255, "%04d|%p: Calling %s (%08X, %08X, %08X...)", tid, *(void**)(R_ESP), s, *(uint32_t*)(R_ESP+4), *(uint32_t*)(R_ESP+8), *(uint32_t*)(R_ESP+12));
}
pthread_mutex_lock(&emu->context->mutex_trace);
if(!cycle_log) printf_log(LOG_NONE, "%s =>", buff);
pthread_mutex_unlock(&emu->context->mutex_trace);
w(emu, addr); // some function never come back, so unlock the mutex first!
if(post)
switch(post) {
case 1: snprintf(buff2, 63, " [%d sec %d nsec]", pu32?(int32_t)pu32[0]:-1, pu32?(int32_t)pu32[1]:-1);
case 1: snprintf(buff2, 63, " [%d sec %d nsec]", pu32?pu32[0]:-1, pu32?pu32[1]:-1);
break;
case 2: snprintf(buff2, 63, "(%s)", R_EAX?((char*)R_EAX):"nil");
break;
@@ -338,13 +325,12 @@ void x86Int3(x86emu_t* emu)
snprintf(buff3, 63, " (errno=%d:\"%s\")", errno, strerror(errno));
else if(perr==3 && ((int)R_EAX)==-1)
snprintf(buff3, 63, " (errno=%d:\"%s\")", errno, strerror(errno));
pthread_mutex_lock(&emu->context->mutex_trace);
if(cycle_log)
snprintf(buffret, 127, "0x%X%s%s", R_EAX, buff2, buff3);
else {
mutex_lock(&emu->context->mutex_trace);
else
printf_log(LOG_NONE, " return 0x%08X%s%s\n", R_EAX, buff2, buff3);
mutex_unlock(&emu->context->mutex_trace);
}
pthread_mutex_unlock(&emu->context->mutex_trace);
} else
w(emu, addr);
}
@@ -360,17 +346,4 @@ void x86Int3(x86emu_t* emu)
int GetTID()
{
return syscall(SYS_gettid);
}
void print_cycle_log(int loglevel) {
if(cycle_log) {
printf_log(LOG_INFO, "Last calls\n");
int j = (my_context->current_line+1)%cycle_log;
for (int i=0; i<cycle_log; ++i) {
int k = (i+j)%cycle_log;
if(my_context->log_call[k][0]) {
printf_log(loglevel, "%s => return %s\n", my_context->log_call[k], my_context->log_ret[k]);
}
}
}
}
}
+8 -8
View File
@@ -1044,14 +1044,14 @@ Implements the SBB instruction and side effects.
****************************************************************************/
uint16_t sbb16(x86emu_t *emu, uint16_t d, uint16_t s)
{
uint32_t res; /* all operands in native machine order */
uint32_t bc;
uint32_t res; /* all operands in native machine order */
uint32_t bc;
CHECK_FLAGS(emu);
if (ACCESS_FLAG(F_CF))
res = d - s - 1;
else
res = d - s;
res = d - s - 1;
else
res = d - s;
CONDITIONAL_SET_FLAG(res & 0x8000, F_SF);
CONDITIONAL_SET_FLAG((res & 0xffff) == 0, F_ZF);
CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
@@ -1075,9 +1075,9 @@ uint32_t sbb32(x86emu_t *emu, uint32_t d, uint32_t s)
CHECK_FLAGS(emu);
if (ACCESS_FLAG(F_CF))
res = d - s - 1;
else
res = d - s;
res = d - s - 1;
else
res = d - s;
CONDITIONAL_SET_FLAG(res & 0x80000000, F_SF);
CONDITIONAL_SET_FLAG(!res, F_ZF);
CONDITIONAL_SET_FLAG(PARITY(res & 0xff), F_PF);
-3
View File
@@ -247,7 +247,6 @@ Implements the NOT instruction
****************************************************************************/
static inline uint8_t not8(x86emu_t *emu, uint8_t s)
{
(void)emu;
return ~s;
}
@@ -257,7 +256,6 @@ Implements the NOT instruction
****************************************************************************/
static inline uint16_t not16(x86emu_t *emu, uint16_t s)
{
(void)emu;
return ~s;
}
@@ -267,7 +265,6 @@ Implements the NOT instruction
****************************************************************************/
static inline uint32_t not32(x86emu_t *emu, uint32_t s)
{
(void)emu;
return ~s;
}
+3 -19
View File
@@ -93,7 +93,7 @@ int Run(x86emu_t *emu, int step)
&&_0xB0, &&_0xB1, &&_0xB2, &&_0xB3, &&_0xB4, &&_0xB5, &&_0xB6, &&_0xB7,
&&_0xB8, &&_0xB9, &&_0xBA, &&_0xBB, &&_0xBC, &&_0xBD, &&_0xBE, &&_0xBF,
&&_0xC0, &&_0xC1, &&_0xC2, &&_0xC3, &&_0xC4, &&_0xC5, &&_0xC6, &&_0xC7,
&&_0xC8, &&_0xC9, &&_default, &&_0xCB, &&_0xCC, &&_0xCD, &&_0xCE, &&_0xCF, //0xC8-0xCF
&&_0xC8, &&_0xC9, &&_default, &&_0xCB, &&_0xCC, &&_0xCD, &&_default, &&_0xCF, //0xC8-0xCF
&&_0xD0, &&_0xD1, &&_0xD2, &&_0xD3, &&_0xD4, &&_0xD5, &&_0xD6, &&_0xD7,
&&_0xD8, &&_0xD9, &&_0xDA, &&_0xDB, &&_0xDC, &&_0xDD, &&_0xDE, &&_0xDF,
&&_0xE0, &&_0xE1, &&_0xE2, &&_0xE3, &&_0xE4, &&_0xE5, &&_0xE6, &&_0xE7,
@@ -106,7 +106,7 @@ int Run(x86emu_t *emu, int step)
&&_0f_0x00, &&_0f_0x01, &&_default, &&_default, &&_default ,&&_default, &&_default, &&_default, //0x00-0x07
&&_default, &&_default, &&_default, &&_0f_0x0B, &&_default ,&&_0f_0x0D, &&_0f_0x0E, &&_default, //0x08-0x0F
&&_0f_0x10, &&_0f_0x11, &&_0f_0x12, &&_0f_0x13, &&_0f_0x14, &&_0f_0x15, &&_0f_0x16, &&_0f_0x17, //0x10-0x17
&&_0f_0x18, &&_0f_0x19, &&_0f_0x1A, &&_0f_0x1B, &&_0f_0x1C ,&&_0f_0x1D, &&_0f_0x1E, &&_0f_0x1F, //0x18-0x1F
&&_0f_0x18, &&_default, &&_0f_0x1A, &&_0f_0x1B, &&_default ,&&_default, &&_default, &&_0f_0x1F, //0x18-0x1F
&&_default, &&_default, &&_default, &&_default, &&_default ,&&_default, &&_default, &&_default, //0x20-0x27
&&_0f_0x28, &&_0f_0x29, &&_0f_0x2A, &&_0f_0x2B, &&_0f_0x2C, &&_0f_0x2D, &&_0f_0x2E, &&_0f_0x2F,
&&_default, &&_0f_0x31, &&_default, &&_default, &&_default ,&&_default, &&_default, &&_default, //0x30-0x37
@@ -979,14 +979,7 @@ _trace:
goto fini;
}
NEXT;
_0xCE: /* INTO */
emu->old_ip = R_EIP;
R_EIP = ip;
emit_signal(emu, SIGFPE, (void*)R_EIP, FPE_INTOVF);
ip = R_EIP;
if(emu->quit) goto fini;
STEP;
NEXT;
_0xCF: /* IRET */
ip = Pop(emu);
emu->segs[_CS] = Pop(emu)&0xffff;
@@ -1313,15 +1306,6 @@ _trace:
NEXT;
case 0x90: /* PAUSE */
NEXT;
case 0x64: {
nextop = F8;
switch (nextop) {
case 0xF1: /* INT1 */
NEXT;
default:
goto _default;
}
}
case 0xA4: /* REP MOVSB */
while(tmp32u) {
--tmp32u;
+1 -35
View File
@@ -1233,7 +1233,6 @@ void RunFS(x86emu_t *emu)
nextop = F8;
GET_ED_OFFS(tlsdata);
ED->dword[0] = adc32(emu, ED->dword[0], GD.dword[0]);
break;
case 0x2B: /* SUB Gd, FS:Ed */
nextop = F8;
@@ -1463,39 +1462,6 @@ void RunFS(x86emu_t *emu)
case 7: cmp32(emu, ED->dword[0], tmp32u); break;
}
break;
case 0x87:
nextop = F8;
#ifdef DYNAREC
GET_ED_OFFS(tlsdata);
if((nextop&0xC0)==0xC0) {
tmp32u = GD.dword[0];
GD.dword[0] = ED->dword[0];
ED->dword[0] = tmp32u;
} else {
if(((uintptr_t)ED)&3)
{
// not aligned, dont't try to "LOCK"
tmp32u = ED->dword[0];
ED->dword[0] = GD.dword[0];
GD.dword[0] = tmp32u;
} else {
// XCHG is supposed to automaticaly LOCK memory bus
GD.dword[0] = arm_lock_xchg(ED, GD.dword[0]);
}
}
#else
GET_ED_OFFS(tlsdata);
if((nextop&0xC0)!=0xC0)
pthread_mutex_lock(&emu->context->mutex_lock); // XCHG always LOCK (but when accessing memory only)
tmp32u = GD.dword[0];
GD.dword[0] = ED->dword[0];
ED->dword[0] = tmp32u;
if((nextop&0xC0)!=0xC0)
pthread_mutex_unlock(&emu->context->mutex_lock);
#endif
break;
case 0x89: /* MOV Ed,Gd */
nextop = F8;
GET_ED_OFFS(tlsdata);
@@ -1688,4 +1654,4 @@ void RunGS0F(x86emu_t *emu, uintptr_t tlsdata)
UnimpOpcode(emu);
}
R_EIP = ip;
}
}
+53 -57
View File
@@ -224,36 +224,30 @@ void Run660F(x86emu_t *emu)
case 0x2C: /* CVTTPD2PI Gm, Ex */
nextop = F8;
GET_EX;
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
GM.ud[0] = 0x80000000;
else
GM.sd[0] = EX->d[0];
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>0x7fffffff)
GM.ud[1] = 0x80000000;
else
GM.sd[1] = EX->d[1];
GM.sd[0] = EX->d[0];
GM.sd[1] = EX->d[1];
break;
case 0x2D: /* CVTPD2PI Gm, Ex */
nextop = F8;
GET_EX;
for(int i=0; i<2; ++i)
if(isnan(EX->d[i]) || isinf(EX->d[i]) || EX->d[i]>0x7fffffff)
GM.ud[i] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {
case ROUND_Nearest:
GM.sd[i] = nearbyint(EX->d[i]);
break;
case ROUND_Down:
GM.sd[i] = floor(EX->d[i]);
break;
case ROUND_Up:
GM.sd[i] = ceil(EX->d[i]);
break;
case ROUND_Chop:
GM.sd[i] = EX->d[i];
break;
}
switch((emu->mxcsr>>13)&3) {
case ROUND_Nearest:
GM.sd[0] = floor(EX->d[0]+0.5);
GM.sd[1] = floor(EX->d[1]+0.5);
break;
case ROUND_Down:
GM.sd[0] = floor(EX->d[0]);
GM.sd[1] = floor(EX->d[1]);
break;
case ROUND_Up:
GM.sd[0] = ceil(EX->d[0]);
GM.sd[1] = ceil(EX->d[1]);
break;
case ROUND_Chop:
GM.sd[0] = EX->d[0];
GM.sd[1] = EX->d[1];
break;
}
break;
case 0x2E: /* UCOMISD Gx, Ex */
// no special check...
@@ -525,7 +519,7 @@ void Run660F(x86emu_t *emu)
nextop = F8;
GET_EX;
tmp8u = F8;
switch((tmp8u & 4) ? (emu->mxcsr.f.MXCSR_RC) : (tmp8u & 3))
switch((tmp8u & 4) ? ((emu->mxcsr >> 13) & 3) : (tmp8u & 3))
{
case ROUND_Nearest:
GX.f[0] = nearbyint(EX->f[0]);
@@ -557,7 +551,7 @@ void Run660F(x86emu_t *emu)
nextop = F8;
GET_EX;
tmp8u = F8;
switch((tmp8u & 4) ? (emu->mxcsr.f.MXCSR_RC) : (tmp8u & 3))
switch((tmp8u & 4) ? ((emu->mxcsr >> 13) & 3) : (tmp8u & 3))
{
case ROUND_Nearest:
GX.d[0] = nearbyint(EX->d[0]);
@@ -581,7 +575,7 @@ void Run660F(x86emu_t *emu)
nextop = F8;
GET_EX;
tmp8u = F8;
switch((tmp8u & 4) ? (emu->mxcsr.f.MXCSR_RC) : (tmp8u & 3))
switch((tmp8u & 4) ? ((emu->mxcsr >> 13) & 3) : (tmp8u & 3))
{
case ROUND_Nearest:
GX.f[0] = nearbyint(EX->f[0]);
@@ -601,7 +595,7 @@ void Run660F(x86emu_t *emu)
nextop = F8;
GET_EX;
tmp8u = F8;
switch((tmp8u & 4) ? (emu->mxcsr.f.MXCSR_RC) : (tmp8u & 3))
switch((tmp8u & 4) ? ((emu->mxcsr >> 13) & 3) : (tmp8u & 3))
{
case ROUND_Nearest:
GX.d[0] = nearbyint(EX->d[0]);
@@ -781,24 +775,32 @@ void Run660F(x86emu_t *emu)
case 0x5B: /* CVTPS2DQ Gx, Ex */
nextop = F8;
GET_EX;
for(int i=0; i<4; ++i)
if(isnanf(EX->f[i]) || isinff(EX->f[i]) || EX->f[i]>0x7fffffff)
GX.sd[i] = 0x80000000;
else
switch(emu->mxcsr.f.MXCSR_RC) {
case ROUND_Nearest:
GX.sd[i] = nearbyintf(EX->f[i]);
break;
case ROUND_Down:
GX.sd[i] = floorf(EX->f[i]);
break;
case ROUND_Up:
GX.sd[i] = ceilf(EX->f[i]);
break;
case ROUND_Chop:
GX.sd[i] = EX->f[i];
break;
}
switch((emu->mxcsr>>13)&3) {
case ROUND_Nearest:
GX.sd[0] = floorf(EX->f[0]+0.5f);
GX.sd[1] = floorf(EX->f[1]+0.5f);
GX.sd[2] = floorf(EX->f[2]+0.5f);
GX.sd[3] = floorf(EX->f[3]+0.5f);
break;
case ROUND_Down:
GX.sd[0] = floorf(EX->f[0]);
GX.sd[1] = floorf(EX->f[1]);
GX.sd[2] = floorf(EX->f[2]);
GX.sd[3] = floorf(EX->f[3]);
break;
case ROUND_Up:
GX.sd[0] = ceilf(EX->f[0]);
GX.sd[1] = ceilf(EX->f[1]);
GX.sd[2] = ceilf(EX->f[2]);
GX.sd[3] = ceilf(EX->f[3]);
break;
case ROUND_Chop:
GX.sd[0] = EX->f[0];
GX.sd[1] = EX->f[1];
GX.sd[2] = EX->f[2];
GX.sd[3] = EX->f[3];
break;
}
break;
case 0x5C: /* SUBPD Gx, Ex */
nextop = F8;
@@ -1588,7 +1590,7 @@ void Run660F(x86emu_t *emu)
case 0xE2: /* PSRAD Gx, Ex */
nextop = F8;
GET_EX;
tmp8u=(EX->q[0]>31)?31:EX->ub[0];
tmp8u=(EX->q[0]>31)?32:EX->ub[0];
for (int i=0; i<4; ++i)
GX.sd[i] >>= tmp8u;
break;
@@ -1617,14 +1619,8 @@ void Run660F(x86emu_t *emu)
case 0xE6: /* CVTTPD2DQ Gx, Ex */
nextop = F8;
GET_EX;
if(isnan(EX->d[0]) || isinf(EX->d[0]) || EX->d[0]>0x7fffffff)
GX.sd[0] = 0x80000000;
else
GX.sd[0] = EX->d[0];
if(isnan(EX->d[1]) || isinf(EX->d[1]) || EX->d[1]>0x7fffffff)
GX.sd[1] = 0x80000000;
else
GX.sd[1] = EX->d[1];
GX.sd[0] = EX->d[0];
GX.sd[1] = EX->d[1];
GX.q[1] = 0;
break;
case 0xE7: /* MOVNTDQ Ex, Gx */
+3 -4
View File
@@ -50,7 +50,6 @@ void EXPORT my___libc_init(x86emu_t* emu, void* raw_args __unused, void (*onexit
#else
int32_t EXPORT my___libc_start_main(x86emu_t* emu, int *(main) (int, char * *, char * *), int argc, char * * ubp_av, void (*init) (void), void (*fini) (void), void (*rtld_fini) (void), void (* stack_end))
{
(void)argc; (void)ubp_av; (void)fini; (void)rtld_fini; (void)stack_end;
// let's cheat and set all args...
Push(emu, (uint32_t)my_context->envv);
Push(emu, (uint32_t)my_context->argv);
@@ -819,7 +818,7 @@ uintptr_t evalED(x86emu_t* emu, uintptr_t ip) {
if((nextop&7)==4) {
uint8_t sib = PK(0);
++ip;
uintptr_t base = ((sib&0x7)==5)?(uint32_t)(PK32(0)):(emu->regs[(sib&0x7)].dword[0]);
uintptr_t base = ((sib&0x7)==5)?(PK32(0)):(emu->regs[(sib&0x7)].dword[0]);
base += (emu->sbiidx[(sib>>3)&7]->sdword[0] << (sib>>6)); \
return *(uintptr_t*)base;
} else if((nextop&7)==5) {
@@ -853,7 +852,7 @@ void PrintTrace(x86emu_t* emu, uintptr_t ip, int dynarec)
(trace_end == 0)
|| ((ip >= trace_start) && (ip < trace_end))) ) {
int tid = syscall(SYS_gettid);
mutex_lock(&my_context->mutex_trace);
pthread_mutex_lock(&my_context->mutex_trace);
#ifdef DYNAREC
if((my_context->trace_tid != tid) || (my_context->trace_dynarec!=dynarec)) {
printf_log(LOG_NONE, "Thread %04d| (%s) |\n", tid, dynarec?"dyn":"int");
@@ -896,7 +895,7 @@ void PrintTrace(x86emu_t* emu, uintptr_t ip, int dynarec)
}
printf_log(LOG_NONE, "\n");
}
mutex_unlock(&my_context->mutex_trace);
pthread_mutex_unlock(&my_context->mutex_trace);
}
}
+41 -123
View File
@@ -73,17 +73,16 @@ void* my_mmap64(x86emu_t* emu, void *addr, unsigned long length, int prot, int f
int my_munmap(x86emu_t* emu, void* addr, unsigned long length);
int my_mprotect(x86emu_t* emu, void *addr, unsigned long len, int prot);
void* ElfSetBrk(void* newbrk);
int my_vfork(x86emu_t* emu);
// cannot include <fcntl.h>, it conflict with some asm includes...
#ifndef O_NONBLOCK
#define O_NONBLOCK 04000
#endif
int my_fcntl(x86emu_t* emu, int fd, int cmd, ... /* arg */ );
int my_fcntl(int fd, int cmd, ... /* arg */ );
// Syscall table for x86 can be found here: http://shell-storm.org/shellcode/files/syscalls.html
typedef struct scwrap_s {
uint32_t x86s;
int x86s;
int nats;
int nbpars;
} scwrap_t;
@@ -388,8 +387,6 @@ void EXPORT x86Syscall(x86emu_t *emu)
emu->quit = 1;
return;
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
printf_log(LOG_DEBUG, " => 0x%x\n", R_EAX);
return;
}
@@ -403,31 +400,21 @@ void EXPORT x86Syscall(x86emu_t *emu)
break;
case 3: // sys_read
R_EAX = (uint32_t)read((int)R_EBX, (void*)R_ECX, (size_t)R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 4: // sys_write
R_EAX = (uint32_t)write((int)R_EBX, (void*)R_ECX, (size_t)R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 5: // sys_open
if(s==5) {printf_log(LOG_DEBUG, " => sys_open(\"%s\", %d, %d)", (char*)R_EBX, of_convert(R_ECX), R_EDX);};
//R_EAX = (uint32_t)open((void*)R_EBX, of_convert(R_ECX), R_EDX);
R_EAX = (uint32_t)my_open(emu, (void*)R_EBX, of_convert(R_ECX), R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 6: // sys_close
R_EAX = (uint32_t)close((int)R_EBX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#ifndef __NR_waitpid
case 7: //sys_waitpid
R_EAX = waitpid((pid_t)R_EBX, (int*)R_ECX, (int)R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#endif
case 11: // sys_execve
@@ -438,43 +425,29 @@ void EXPORT x86Syscall(x86emu_t *emu)
printf_log(LOG_DEBUG, " => sys_execve(\"%s\", %p(\"%s\", \"%s\", \"%s\"...), %p)\n", prog, argv, (argv && argv[0])?argv[0]:"nil", (argv && argv[0] && argv[1])?argv[1]:"nil", (argv && argv[0] && argv[1] && argv[2])?argv[2]:"nil", envv);
R_EAX = my_execve(emu, (const char*)R_EBX, (void*)R_ECX, (void*)R_EDX);
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#ifndef __NR_time
case 13: // sys_time (it's deprecated and remove on ARM EABI it seems)
R_EAX = time(NULL);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#endif
case 45: // sys_brk
R_EAX = (uintptr_t)ElfSetBrk((void*)R_EBX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 54: // sys_ioctl
R_EAX = (uint32_t)ioctl((int)R_EBX, R_ECX, R_EDX, R_ESI, R_EDI);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 55: // sys_fcntl
R_EAX = (uint32_t)my_fcntl(emu, (int)R_EBX, (int)R_ECX, R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
R_EAX = (uint32_t)my_fcntl((int)R_EBX, (int)R_ECX, R_EDX);
break;
#ifndef __NR_getrlimit
case 76: // sys_getrlimit... this is the old version, using the new one. Maybe some tranform is needed?
R_EAX = getrlimit(R_EBX, (void*)R_ECX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#endif
#ifndef __NR_select
case 82: // select
R_EAX = select(R_EBX, (fd_set*)R_ECX, (fd_set*)R_EDX, (fd_set*)R_ESI, (struct timeval*)R_EDI);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#endif
case 90: // old_mmap
@@ -482,13 +455,9 @@ void EXPORT x86Syscall(x86emu_t *emu)
struct mmap_arg_struct *st = (struct mmap_arg_struct*)R_EBX;
R_EAX = (uintptr_t)my_mmap(emu, (void*)st->addr, st->len, st->prot, st->flags, st->fd, st->offset);
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 91: // munmap
R_EAX = my_munmap(emu, (void*)R_EBX, (unsigned long)R_ECX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#ifndef __NR_socketcall
case 102: {
@@ -519,10 +488,8 @@ void EXPORT x86Syscall(x86emu_t *emu)
#endif
default:
printf_log(LOG_DEBUG, "BOX86 Error on Syscall 102: Unknown Soket command %d\n", R_EBX);
R_EAX = -EINVAL;
R_EAX = -1;
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
}
break;
#endif
@@ -539,8 +506,6 @@ void EXPORT x86Syscall(x86emu_t *emu)
memcpy(old->version, un.version, 9);
strcpy(old->machine, "i686");
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
}
break;
#endif
@@ -552,8 +517,6 @@ void EXPORT x86Syscall(x86emu_t *emu)
#ifndef __NR_ipc
case 117: // ipc
R_EAX = (uint32_t)my_ipc(R_EBX, (int)R_ECX, (int)R_EDX, (int)R_ESI, (void*)R_EDI, (long)R_EBP);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#endif
case 119: // sys_sigreturn
@@ -562,53 +525,44 @@ void EXPORT x86Syscall(x86emu_t *emu)
case 120: // clone
// x86 raw syscall is long clone(unsigned long flags, void *stack, int *parent_tid, unsigned long tls, int *child_tid);
// so flags=R_EBX, stack=R_ECX, parent_tid=R_EDX, tls=R_ESI, child_tid=R_EDI
if((R_EBX&~0xff)==0x4100) {
// this is a case of vfork...
R_EAX = my_vfork(emu);
if(R_EAX==0xffffffff)
R_EAX = (uint32_t)-errno;
} else {
if(R_ECX)
{
void* stack_base = (void*)R_ECX;
int stack_size = 0;
if(!R_ECX) {
// allocate a new stack...
int currstack = 0;
if((R_ESP>=(uintptr_t)emu->init_stack) && (R_ESP<=((uintptr_t)emu->init_stack+emu->size_stack)))
currstack = 1;
stack_size = (currstack)?emu->size_stack:(1024*1024);
stack_base = mmap(NULL, stack_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0);
// copy value from old stack to new stack
if(currstack)
memcpy(stack_base, emu->init_stack, stack_size);
else {
int size_to_copy = (uintptr_t)emu->init_stack + emu->size_stack - (R_ESP);
memcpy(stack_base+stack_size-size_to_copy, (void*)R_ESP, size_to_copy);
}
if(R_ECX)
{
void* stack_base = (void*)R_ECX;
int stack_size = 0;
if(!R_ECX) {
// allocate a new stack...
int currstack = 0;
if((R_ESP>=(uintptr_t)emu->init_stack) && (R_ESP<=((uintptr_t)emu->init_stack+emu->size_stack)))
currstack = 1;
stack_size = (currstack)?emu->size_stack:(1024*1024);
stack_base = mmap(NULL, stack_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0);
// copy value from old stack to new stack
if(currstack)
memcpy(stack_base, emu->init_stack, stack_size);
else {
int size_to_copy = (uintptr_t)emu->init_stack + emu->size_stack - (R_ESP);
memcpy(stack_base+stack_size-size_to_copy, (void*)R_ESP, size_to_copy);
}
x86emu_t * newemu = NewX86Emu(emu->context, R_EIP, (uintptr_t)stack_base, stack_size, (R_ECX)?0:1);
SetupX86Emu(newemu);
CloneEmu(newemu, emu);
Push32(newemu, 0);
PushExit(newemu);
void* mystack = NULL;
if(my_context->stack_clone_used) {
mystack = box_malloc(1024*1024); // stack for own process... memory leak, but no practical way to remove it
} else {
if(!my_context->stack_clone)
my_context->stack_clone = box_malloc(1024*1024);
mystack = my_context->stack_clone;
my_context->stack_clone_used = 1;
}
long ret = clone(clone_fn, (void*)((uintptr_t)mystack+1024*1024), R_EBX, newemu, R_EDX, R_ESI, R_EDI);
R_EAX = (uint32_t)ret;
}
else
R_EAX = (uint32_t)syscall(__NR_clone, R_EBX, R_ECX, R_EDX, R_ESI, R_EDI);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
x86emu_t * newemu = NewX86Emu(emu->context, R_EIP, (uintptr_t)stack_base, stack_size, (R_ECX)?0:1);
SetupX86Emu(newemu);
CloneEmu(newemu, emu);
Push32(newemu, 0);
PushExit(newemu);
void* mystack = NULL;
if(my_context->stack_clone_used) {
mystack = box_malloc(1024*1024); // stack for own process... memory leak, but no practical way to remove it
} else {
if(!my_context->stack_clone)
my_context->stack_clone = box_malloc(1024*1024);
mystack = my_context->stack_clone;
my_context->stack_clone_used = 1;
}
long ret = clone(clone_fn, (void*)((uintptr_t)mystack+1024*1024), R_EBX, newemu, R_EDX, R_ESI, R_EDI);
R_EAX = (uint32_t)ret;
}
else
R_EAX = (uint32_t)syscall(__NR_clone, R_EBX, R_ECX, R_EDX, R_ESI, R_EDI);
break;
case 122: // uname
{
@@ -623,23 +577,15 @@ void EXPORT x86Syscall(x86emu_t *emu)
strcpy(old->machine, "i686");
}
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 123: // SYS_modify_ldt
R_EAX = my_modify_ldt(emu, R_EBX, (thread_area_t*)R_ECX, R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 125: // mprotect
R_EAX = my_mprotect(emu, (void*)R_EBX, (unsigned long)R_ECX, R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 168: // sys_poll
R_EAX = (uint32_t)poll((void*)R_EBX, R_ECX, (int)R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 173: // sys_rt_sigreturn
emu->quit = 1; // we should be inside a DynaCall in a sigaction callback....
@@ -647,16 +593,12 @@ void EXPORT x86Syscall(x86emu_t *emu)
case 174: // sys_rt_sigaction
//printf_log(LOG_NONE, "Warning, Ignoring sys_rt_sigaction(0x%02X, %p, %p)\n", R_EBX, (void*)R_ECX, (void*)R_EDX);
R_EAX = my_syscall_sigaction(emu, R_EBX, (void*)R_ECX, (void*)R_EDX, R_ESI);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 190: // vfork
{
int r = my_vfork(emu);
int r = vfork();
R_EAX = r;
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 192: // mmap2
R_EAX = (uint32_t)my_mmap64(emu, (void*)R_EBX, (unsigned long)R_ECX, R_EDX, R_ESI, R_EDI, R_EBP);
@@ -669,8 +611,6 @@ void EXPORT x86Syscall(x86emu_t *emu)
R_EAX = r;
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 196: // lstat64
{
@@ -680,8 +620,6 @@ void EXPORT x86Syscall(x86emu_t *emu)
R_EAX = r;
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 197: // fstat64
{
@@ -691,60 +629,40 @@ void EXPORT x86Syscall(x86emu_t *emu)
R_EAX = r;
}
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 221: // sys_fcntl64
R_EAX = (uint32_t)my_fcntl(emu, (int)R_EBX, (int)R_ECX, R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
R_EAX = (uint32_t)my_fcntl((int)R_EBX, (int)R_ECX, R_EDX);
break;
case 243: // set_thread_area
R_EAX = my_set_thread_area((thread_area_t*)R_EBX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#ifndef NOALIGN
case 254: // epoll_create
R_EAX = my_epoll_create(emu, (int)R_EBX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 255: // epoll_ctl
R_EAX = my_epoll_ctl(emu, (int)R_EBX, (int)R_ECX, (int)R_EDX, (void*)R_ESI);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
case 256: // epoll_wait
R_EAX = my_epoll_wait(emu, (int)R_EBX, (void*)R_ECX, (int)R_EDX, (int)R_ESI);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#endif
case 270: // tgkill
R_EAX = syscall(__NR_tgkill, R_EBX, R_ECX, R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#ifndef NOALIGN
case 329: // epoll_create1
R_EAX = my_epoll_create1(emu, of_convert(R_EBX));
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#endif
#ifndef __NR_getrandom
case 355: // getrandom
R_EAX = my_getrandom(emu, (void*)R_EBX, R_ECX, R_EDX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#endif
#ifndef __NR_memfd_create
case 356: // memfd_create
R_EAX = my_memfd_create(emu, (void*)R_EBX, R_ECX);
if(R_EAX==0xffffffff && errno>0)
R_EAX = (uint32_t)-errno;
break;
#endif
default:
+26 -60
View File
@@ -24,37 +24,19 @@ typedef struct thread_area_s
unsigned int useable:1;
} thread_area_t;
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4) \
GO(5) \
GO(6) \
GO(7) \
GO(8) \
GO(9) \
GO(10) \
GO(11) \
GO(12) \
GO(13) \
GO(14) \
GO(15) \
GO(16) \
GO(17) \
GO(18) \
static pthread_once_t thread_key_once0 = PTHREAD_ONCE_INIT;
static pthread_once_t thread_key_once1 = PTHREAD_ONCE_INIT;
static pthread_once_t thread_key_once2 = PTHREAD_ONCE_INIT;
#define GO(A) static pthread_once_t thread_key_once##A = PTHREAD_ONCE_INIT;
SUPER()
#undef GO
#define GO(A)\
static void thread_key_alloc##A() { \
pthread_key_create(&my_context->segtls[A].key, NULL); \
static void thread_key_alloc0() {
pthread_key_create(&my_context->segtls[0].key, NULL);
}
static void thread_key_alloc1() {
pthread_key_create(&my_context->segtls[1].key, NULL);
}
static void thread_key_alloc2() {
pthread_key_create(&my_context->segtls[2].key, NULL);
}
SUPER()
#undef GO
uint32_t my_set_thread_area(thread_area_t* td)
{
@@ -99,11 +81,11 @@ uint32_t my_set_thread_area(thread_area_t* td)
my_context->segtls[idx-7].base = td->base_addr;
my_context->segtls[idx-7].limit = td->limit;
my_context->segtls[idx-7].present = 1;
#define GO(A) case A: pthread_once(&thread_key_once##A, thread_key_alloc##A); break;
switch (idx-7) {
SUPER()
case 0: pthread_once(&thread_key_once0, thread_key_alloc0); break;
case 1: pthread_once(&thread_key_once1, thread_key_alloc1); break;
case 2: pthread_once(&thread_key_once2, thread_key_alloc2); break;
}
#undef GO
pthread_setspecific(my_context->segtls[idx-7].key, (void*)my_context->segtls[idx-7].base);
@@ -114,45 +96,32 @@ uint32_t my_set_thread_area(thread_area_t* td)
EXPORT uint32_t my_modify_ldt(x86emu_t* emu, int op, thread_area_t* td, int size)
{
(void)emu;
printf_log(/*LOG_DEBUG*/LOG_INFO, "modify_ldt(0x%x, %p[0x%x/base=%p/limit=%u/32bits:%u/%u/%u...], %d)\n", op, td, td->entry_number, (void*)td->base_addr, td->limit_in_pages, td->seg_32bit, td->contents, td->read_exec_only, size);
if(!td) {
errno = EFAULT;
return (uint32_t)-1;
}
if(op==0 && size==8) {
td->entry_number = 6;
td->base_addr = (uintptr_t)GetSegmentBase(6<<3);
return 8;
}
if(op!=0x11) {
errno = ENOSYS;
return (uint32_t)-1;
}
if(!td->seg_32bit && td->base_addr) {
if(!td->seg_32bit) {
// not handling 16bits segments for now
errno = EINVAL;
return (uint32_t)-1;
}
int idx = td->entry_number - 7;
if(td->entry_number>=0x1ff0) idx=td->entry_number-0x1ff0+3;
if(idx<0 || idx>16+3-1) {
printf_log(LOG_DEBUG, "modify_ldt: idx out of range: %d\n", idx);
if(idx<0 || idx>2) {
errno = EINVAL;
return (uint32_t)-1;
}
/*
my_context->segtls[idx].base = td->base_addr;
my_context->segtls[idx].limit = td->limit;
my_context->segtls[idx].present = td->base_addr?1:0;
#define GO(A) case A: pthread_once(&thread_key_once##A, thread_key_alloc##A); break;
switch (idx-7) {
SUPER()
}
#undef GO
pthread_setspecific(my_context->segtls[idx].key, (void*)my_context->segtls[idx].base);
*/
ResetSegmentsCache(thread_get_emu());
@@ -167,7 +136,7 @@ static int sizeDTS(box86context_t* context)
}
static int sizeTLSData(int s)
{
uint32_t mask = 0xffff/*box64_nogtk?0xffff:0x1fff*/; // x86 does the mapping per 64K blocks, so it makes sense to have it this large
uint32_t mask = box86_nogtk?0xffff:0x1fff;
return (s+mask)&~mask;
}
@@ -206,15 +175,15 @@ static tlsdatasize_t* setupTLSData(box86context_t* context)
void* fillTLSData(box86context_t *context)
{
mutex_lock(&context->mutex_tls);
pthread_mutex_lock(&context->mutex_tls);
tlsdatasize_t *data = setupTLSData(context);
mutex_unlock(&context->mutex_tls);
pthread_mutex_unlock(&context->mutex_tls);
return data;
}
void* resizeTLSData(box86context_t *context, void* oldptr)
{
mutex_lock(&context->mutex_tls);
pthread_mutex_lock(&context->mutex_tls);
tlsdatasize_t* oldata = (tlsdatasize_t*)oldptr;
if(sizeTLSData(oldata->tlssize)!=sizeTLSData(context->tlssize) || (oldata->n_elfs/0xff)!=(context->elfsize/0xff)) {
printf_log(LOG_INFO, "Warning, resizing of TLS occured! size: %d->%d / n_elfs: %d->%d\n", sizeTLSData(oldata->tlssize), sizeTLSData(context->tlssize), 1+(oldata->n_elfs/0xff), 1+(context->elfsize/0xff));
@@ -222,7 +191,7 @@ void* resizeTLSData(box86context_t *context, void* oldptr)
// copy the relevent old part, in case something changed
memcpy((void*)((uintptr_t)data->data-oldata->tlssize), (void*)((uintptr_t)oldata->data-oldata->tlssize), oldata->tlssize);
// all done, update new size, free old pointer and exit
mutex_unlock(&context->mutex_tls);
pthread_mutex_unlock(&context->mutex_tls);
free_tlsdatasize(oldptr);
return data;
} else {
@@ -244,7 +213,7 @@ void* resizeTLSData(box86context_t *context, void* oldptr)
}
oldata->n_elfs = context->elfsize;
}
mutex_unlock(&context->mutex_tls);
pthread_mutex_unlock(&context->mutex_tls);
return oldata;
}
}
@@ -273,14 +242,11 @@ void* GetSegmentBase(uint32_t desc)
if(base==0x6)
return GetSeg33Base();
if(base>=0x1ff0)
base = base - 0x1ff0 + 3 + 7;
if(base>6 && base<16+3+7 && my_context->segtls[base-7].present) {
if(base>6 && base<10 && my_context->segtls[base-7].present) {
void* ptr = pthread_getspecific(my_context->segtls[base-7].key);
return ptr;
}
printf_log(LOG_NONE, "Warning, accessing segment unknown 0x%x (%d) or unset\n", desc, base);
printf_log(LOG_NONE, "Warning, accessing segment unknown 0x%x or unset\n", desc);
return NULL;
}
+4 -32
View File
@@ -73,10 +73,6 @@ void fpu_fbld(x86emu_t* emu, uint8_t* s) {
// long double (80bits) -> double (64bits)
void LD2D(void* ld, void* d)
{
if(box86_x87_no80bits) {
*(uint64_t*)d = *(uint64_t*)ld;
return;
}
FPU_t result;
#pragma pack(push, 1)
struct {
@@ -116,7 +112,7 @@ void LD2D(void* ld, void* d)
*(uint64_t*)d = result.q;
return;
}
if(((uint32_t)(val.b&0x7fff)==0) || (exp64<-1074)) {
if(((uint32_t)(val.b&0x7fff)==0) || (exp64<=0)) {
//if(val.f.ll==0)
// zero
//if(val.f.ll!=0)
@@ -128,18 +124,6 @@ void LD2D(void* ld, void* d)
return;
}
if(exp64<=0 && val.f.q) {
// try to see if it can be a denormal
int one = -exp64-1022;
uint64_t r = 0;
if(val.b&0x8000)
r |= 0x8000000000000000L;
r |= val.f.q>>one;
*(uint64_t*)d = r;
return;
}
if(exp64>=0x7ff) {
// to big value...
result.d = HUGE_VAL;
@@ -160,10 +144,6 @@ void LD2D(void* ld, void* d)
// double (64bits) -> long double (80bits)
void D2LD(void* d, void* ld)
{
if(box86_x87_no80bits) {
*(uint64_t*)ld = *(uint64_t*)d;
return;
}
#pragma pack(push, 1)
struct {
FPU_t f;
@@ -200,12 +180,6 @@ void D2LD(void* d, void* ld)
if(exp80!=0){
mant80final |= 0x8000000000000000LL;
exp80final += (BIAS80 - BIAS64);
} else if(mant80final!=0) {
// denormals -> normal
exp80final = BIAS80-1023;
int one = __builtin_clz(mant80final) + 1;
exp80final -= one;
mant80final<<=one;
}
}
val.b = ((int16_t)(sign80)<<15)| (int16_t)(exp80final);
@@ -217,9 +191,7 @@ void D2LD(void* d, void* ld)
double FromLD(void* ld)
{
if(box86_x87_no80bits)
return *(double*)ld;
double ret; // cannot add = 0;
double ret;
LD2D(ld, &ret);
return ret;
}
@@ -306,7 +278,7 @@ void fpu_fxsave(x86emu_t* emu, void* ed)
p->StatusWord = emu->sw.x16;
uint8_t tags = 0;
for (int i=0; i<8; ++i)
tags |= (emu->p_regs[i].tag==0b11)?0:(1<<(i*2));
tags |= ((emu->p_regs[i].tag)<<(i*2)==0b11)?0:1;
p->TagWord = tags;
p->ErrorOpcode = 0;
p->ErrorOffset = 0;
@@ -330,7 +302,7 @@ void fpu_fxrstor(x86emu_t* emu, void* ed)
emu->top = emu->sw.f.F87_TOP;
uint8_t tags = p->TagWord;
for(int i=0; i<8; ++i)
emu->p_regs[i].tag = ((tags>>(i*2))&0b1)?0:0b11;
emu->p_regs[i].tag = (tags>>(i*2))?0:0b11;
// copy back MMX regs...
int top = emu->top&7;
int stack = 8-top;
+12 -36
View File
@@ -4,9 +4,6 @@
#include <pthread.h>
#include "pathcoll.h"
#include "dictionnary.h"
#ifdef DYNAREC
#include "dynarec/arm_lock_helper.h"
#endif
typedef struct elfheader_s elfheader_t;
typedef struct cleanup_s cleanup_t;
@@ -30,7 +27,6 @@ typedef struct atfork_fnc_s {
} atfork_fnc_t;
#ifdef DYNAREC
typedef struct dynablock_s dynablock_t;
typedef struct dynablocklist_s dynablocklist_t;
typedef struct mmaplist_s mmaplist_t;
typedef struct kh_dynablocks_s kh_dynablocks_t;
#endif
@@ -43,6 +39,7 @@ typedef void* (*procaddess_t)(const char* name);
typedef void* (*vkprocaddess_t)(void* instance, const char* name);
#define MAX_SIGNAL 64
#define CYCLE_LOG 16
typedef struct tlsdatasize_s {
int tlssize;
@@ -93,7 +90,7 @@ typedef struct box86context_s {
char* bashpath; // path of x86 bash (defined with BOX86_BASH or by running bash directly)
uint32_t stacksz;
uint32_t stackalign;
int stackalign;
void* stack; // alocated stack
elfheader_t **elfs; // elf headers and memory
@@ -126,24 +123,19 @@ typedef struct box86context_s {
kh_defaultversion_t *weakdefver; // the weak default version for symbols (the XXX@@vvvv of symbols)
vkprocaddess_t vkprocaddress;
#ifndef DYNAREC
pthread_mutex_t mutex_once;
pthread_mutex_t mutex_once2;
pthread_mutex_t mutex_trace;
#ifndef DYNAREC
pthread_mutex_t mutex_lock; // dynarec build will use their own mecanism
#else
pthread_mutex_t mutex_dyndump;
uintptr_t max_db_size; // the biggest (in x86_64 instructions bytes) built dynablock
int trace_dynarec;
#endif
pthread_mutex_t mutex_tls;
pthread_mutex_t mutex_thread;
pthread_mutex_t mutex_bridge;
pthread_mutex_t mutex_lock;
#else
uint32_t mutex_once;
uint32_t mutex_once2;
uint32_t mutex_trace;
uint32_t mutex_tls;
uint32_t mutex_thread;
uint32_t mutex_bridge;
uint32_t mutex_dyndump;
int trace_dynarec;
#endif
library_t *libclib; // shortcut to libc library (if loaded, so probably yes)
library_t *sdl1mixerlib;
@@ -165,7 +157,7 @@ typedef struct box86context_s {
pthread_key_t tlskey; // then tls key to have actual tlsdata
void* tlsdata; // the initial global tlsdata
int32_t tlssize; // wanted size of tlsdata
base_segment_t segtls[3+16]; // only handling 0/1/2 descriptors + some special cases
base_segment_t segtls[3]; // only handling 0/1/2 descriptors
uintptr_t *auxval_start;
@@ -196,32 +188,16 @@ typedef struct box86context_s {
int stack_clone_used;
// rolling logs
char* *log_call;
char* *log_ret;
char* log_call[CYCLE_LOG];
char* log_ret[CYCLE_LOG];
int current_line;
} box86context_t;
#ifndef DYNAREC
#define mutex_lock(A) pthread_mutex_lock(A)
#define mutex_trylock(A) pthread_mutex_trylock(A)
#define mutex_unlock(A) pthread_mutex_unlock(A)
#else
int GetTID();
#define mutex_lock(A) {int tid = GetTID(); while(arm_lock_storeifnull(A, (void*)tid)) sched_yield();}
#define mutex_trylock(A) arm_lock_storeifnull(A, (void*)GetTID())
#define mutex_unlock(A) arm_lock_storeifref(A, NULL, (void*)GetTID())
#endif
extern box86context_t *my_context; // global context
box86context_t *NewBox86Context(int argc);
void FreeBox86Context(box86context_t** context);
// Cycle log handling
void freeCycleLog(box86context_t* ctx);
void initCycleLog(box86context_t* context);
void print_cycle_log(int loglevel);
// return the index of the added header
int AddElfHeader(box86context_t* ctx, elfheader_t* head);
-1
View File
@@ -12,7 +12,6 @@ void FreeBridge(bridge_t** bridge);
uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* name);
uintptr_t CheckBridged(bridge_t* bridge, void* fnc);
int IsBridge(void* func);
uintptr_t AddCheckBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* name);
uintptr_t AddAutomaticBridge(x86emu_t* emu, bridge_t* bridge, wrapper_t w, void* fnc, int N);
void* GetNativeFnc(uintptr_t fnc);
-1
View File
@@ -11,5 +11,4 @@ uint64_t RunFunction64(box86context_t *context, uintptr_t fnc, int nargs, ...);
// use emu state to run function
uint32_t RunFunctionWithEmu(x86emu_t *emu, int QuitOnLongJump, uintptr_t fnc, int nargs, ...);
uint32_t RunSafeFunction(box86context_t *context, uintptr_t fnc, int nargs, ...);
#endif //__CALLBACK_H__
+5 -4
View File
@@ -18,7 +18,6 @@ void customFree(void* p);
#ifdef DYNAREC
typedef struct dynablock_s dynablock_t;
typedef struct dynablocklist_s dynablocklist_t;
// custom protection flag to mark Page that are Write protected for Dynarec purpose
uintptr_t AllocDynarecMap(dynablock_t* db, int size);
void FreeDynarecMap(dynablock_t* db, uintptr_t addr, uint32_t size);
@@ -26,12 +25,15 @@ void FreeDynarecMap(dynablock_t* db, uintptr_t addr, uint32_t size);
void addDBFromAddressRange(uintptr_t addr, uintptr_t size);
void cleanDBFromAddressRange(uintptr_t addr, uintptr_t size, int destroy);
dynablocklist_t* getDB(uintptr_t idx);
void addJumpTableIfDefault(void* addr, void* jmp);
dynablock_t* getDB(uintptr_t addr);
int addJumpTableIfDefault(void* addr, void* jmp); // return 1 if write was succesfull
void setJumpTableIfRef(void* addr, void* jmp, void* ref); // return 1 if write was succesfull
void setJumpTableDefault(void* addr);
void setJumpTableDefaultRef(void* addr, void* jmp);
int isJumpTableDefault(void* addr);
uintptr_t getJumpTable();
uintptr_t getJumpTableAddress(uintptr_t addr);
uintptr_t getJumpAddress(uintptr_t addr);
#endif
#define PROT_DYNAREC 0x80
@@ -47,7 +49,6 @@ void loadProtectionFromMap();
#ifdef DYNAREC
void protectDB(uintptr_t addr, uintptr_t size);
void unprotectDB(uintptr_t addr, uintptr_t size, int mark); // if mark==0, the blocks are not marked as potentially dirty
int isprotectedDB(uintptr_t addr, size_t size);
int IsInHotPage(uintptr_t addr);
int AreaInHotPage(uintptr_t start, uintptr_t end);
void AddHotPage(uintptr_t addr);
+2 -14
View File
@@ -7,24 +7,20 @@ extern int box86_log; // log level
extern int box86_dump; // dump elf or not
extern int box86_dynarec_log;
extern int box86_dynarec;
extern uintptr_t box86_pagesize;
extern int box86_pagesize;
extern uintptr_t box86_load_addr;
extern int box86_showbt;
extern int box86_backtrace;
#ifdef DYNAREC
extern int box86_dynarec_dump;
extern int box86_dynarec_trace;
extern int box86_dynarec_forced;
extern int box86_dynarec_largest;
extern int box86_dynarec_bigblock;
extern int box86_dynarec_forward;
extern int box86_dynarec_strongmem;
extern int box86_dynarec_x87double;
extern int box86_dynarec_safeflags;
extern uintptr_t box86_nodynarec_start, box86_nodynarec_end;
extern int box86_dynarec_fastnan;
extern int box86_dynarec_fastround;
extern int box86_dynarec_hotpage;
extern int box86_dynarec_bleeding_edge;
#ifdef ARM
extern int arm_vfp; // vfp version (3 or 4), with 32 registers is mendatory
extern int arm_swap;
@@ -35,8 +31,6 @@ extern int dlsym_error; // log dlsym error
extern int cycle_log; // if using rolling logs
extern int trace_xmm; // include XMM reg in trace?
extern int trace_emm; // include EMM reg in trace?
extern int box86_sse_flushto0;
extern int box86_x87_no80bits;
extern int allow_missing_libs;
extern int box86_prefer_wrapped;
extern int box86_prefer_emulated;
@@ -50,16 +44,10 @@ extern int box86_showsegv;
extern int allow_missing_symbols;
extern uintptr_t trace_start, trace_end;
extern char* trace_func;
extern char* trace_init;
extern char* box86_trace;
extern uint64_t start_cnt;
extern uintptr_t fmod_smc_start, fmod_smc_end; // to handle libfmod (from Unreal) SMC (self modifying code)
extern uint32_t default_fs;
extern int jit_gdb; // launch gdb when a segfault is trapped
extern int box86_tcmalloc_minimal; // when using tcmalloc_minimal
extern int box86_x11threads;
extern int box86_x11glx;
extern char* box86_libGL;
#define LOG_NONE 0
#define LOG_INFO 1
#define LOG_DEBUG 2
+3 -13
View File
@@ -3,31 +3,21 @@
typedef struct x86emu_s x86emu_t;
typedef struct dynablock_s dynablock_t;
typedef struct dynablocklist_s dynablocklist_t;
typedef struct kh_dynablocks_s kh_dynablocks_t;
uint32_t X31_hash_code(void* addr, int len);
dynablocklist_t* NewDynablockList(uintptr_t text, int textsz, int direct);
void FreeDynablockList(dynablocklist_t** dynablocks);
void FreeDynablock(dynablock_t* db, int need_lock);
void MarkDynablock(dynablock_t* db);
void FreeRangeDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t size);
void MarkRangeDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t size);
void MarkRangeDynablock(dynablock_t* db, uintptr_t addr, uintptr_t size);
int FreeRangeDynablock(dynablock_t* db, uintptr_t addr, uintptr_t size);
dynablock_t* FindDynablockFromNativeAddress(void* addr); // defined in box86context.h
dynablock_t* FindDynablockDynablocklist(void* addr, kh_dynablocks_t* dynablocks);
uintptr_t StartDynablockList(dynablocklist_t* db);
uintptr_t EndDynablockList(dynablocklist_t* db);
void MarkDirectDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t size);
// Handling of Dynarec block (i.e. an exectable chunk of x86 translated code)
dynablock_t* DBGetBlock(x86emu_t* emu, uintptr_t addr, int create, dynablock_t** current); // return NULL if block is not found / cannot be created. Don't create if create==0
dynablock_t* DBGetBlock(x86emu_t* emu, uintptr_t addr, int create); // return NULL if block is not found / cannot be created. Don't create if create==0
dynablock_t* DBAlternateBlock(x86emu_t* emu, uintptr_t addr, uintptr_t filladdr);
// Create and Add an new dynablock in the list, handling direct/map
dynablock_t *AddNewDynablock(dynablocklist_t* dynablocks, uintptr_t addr, int* created);
// for use in signal handler
void cancelFillBlock();
+3 -4
View File
@@ -10,7 +10,7 @@ typedef struct box86context_s box86context_t;
typedef struct x86emu_s x86emu_t;
typedef struct needed_libs_s needed_libs_t;
#ifdef DYNAREC
typedef struct dynablocklist_s dynablocklist_t;
typedef struct dynablock_s dynablock_t;
#endif
elfheader_t* LoadAndCheckElfHeader(FILE* f, const char* name, int exec); // exec : 0 = lib, 1 = exec
@@ -26,7 +26,7 @@ int LoadElfMemory(FILE* f, box86context_t* context, elfheader_t* head);
int ReloadElfMemory(FILE* f, box86context_t* context, elfheader_t* head);
int RelocateElf(lib_t* maplib, lib_t* local_maplib, int bindnow, elfheader_t* head);
int RelocateElfPlt(lib_t* maplib, lib_t* local_maplib, int bindnow, elfheader_t* head);
void CalcStack(elfheader_t* h, uint32_t* stacksz, uint32_t* stackalign);
void CalcStack(elfheader_t* h, uint32_t* stacksz, int* stackalign);
uintptr_t GetEntryPoint(lib_t* maplib, elfheader_t* h);
uintptr_t GetLastByte(elfheader_t* h);
void AddSymbols(lib_t* maplib, kh_mapsymbols_t* mapsymbols, kh_mapsymbols_t* weaksymbols, kh_mapsymbols_t* localsymbols, elfheader_t* h);
@@ -49,8 +49,7 @@ uint32_t GetTLSSize(elfheader_t* h);
void* GetTLSPointer(box86context_t* context, elfheader_t* h);
void* GetDTatOffset(box86context_t* context, int index, int offset);
#ifdef DYNAREC
dynablocklist_t* GetDynablocksFromAddress(box86context_t* context, uintptr_t addr);
dynablocklist_t* GetDynablocksFromElf(elfheader_t* h);
dynablock_t* GetDynablocksFromAddress(box86context_t *context, uintptr_t addr);
#endif
void ResetSpecialCaseMainElf(elfheader_t* h);
void CreateMemorymapFile(box86context_t* context, int fd);
+2 -5
View File
@@ -21,11 +21,8 @@ int FileIsShell(const char* filename);
// return temp folder (will return /tmp if nothing is correct)
const char* GetTmpDir();
// will lower case the string and return a copy. Nothing fancy here, just A..Z transformed to a..z, rest is untouched
char* LowerCase(const char* s);
#if defined(RPI) || defined(RK3399) || defined(GOA_CLONE) || defined(PYRA)
#if defined(RPI) || defined(RK3399) || defined(GOA_CLONE)
void sanitize_mojosetup_gtk_background();
#endif
#endif //__FILEUTILS_H_
#endif //__FILEUTILS_H_
+1 -1
View File
@@ -26,7 +26,7 @@ int AddNeededLib(lib_t* maplib, needed_libs_t* neededlibs, library_t* deplib, in
library_t* GetLibMapLib(lib_t* maplib, const char* name);
library_t* GetLibInternal(const char* name);
uintptr_t FindGlobalSymbol(lib_t *maplib, const char* name, int version, const char* vername);
int GetNoSelfSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, elfheader_t* self, size_t size, int version, const char* vername);
int GetNoSelfSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, elfheader_t* self, int version, const char* vername);
int GetGlobalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, elfheader_t *self, int version, const char* vername);
int GetGlobalNoWeakSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, int version, const char* vername);
int GetLocalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, elfheader_t *self, int version, const char* vername);
+3 -3
View File
@@ -24,9 +24,9 @@ void Free1Library(library_t **lib, x86emu_t* emu);
char* GetNameLib(library_t *lib);
int IsSameLib(library_t* lib, const char* path); // check if lib is same (path -> name)
int GetLibGlobalSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, size_t size, int *weak, int version, const char* vername, int local);
int GetLibWeakSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, size_t size, int* weak, int version, const char* vername, int local);
int GetLibLocalSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, size_t size, int* weak, int version, const char* vername, int local);
int GetLibGlobalSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, int *weak, int version, const char* vername, int local);
int GetLibWeakSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, int* weak, int version, const char* vername, int local);
int GetLibLocalSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, int* weak, int version, const char* vername, int local);
void fillGLProcWrapper(box86context_t* context);
void freeGLProcWrapper(box86context_t* context);
void fillALProcWrapper(box86context_t* context);
-10
View File
@@ -1,10 +0,0 @@
#ifndef __RCFILE_H__
#define __RCFILE_H__
typedef struct path_collection_s path_collection_t;
void LoadRCFile(const char* filename);
void DeleteParams();
void ApplyParams(const char* name, path_collection_t* preload);
#endif //__RCFILE_H__
+25 -47
View File
@@ -178,63 +178,41 @@ typedef enum {
typedef union {
struct __attribute__ ((__packed__)) {
uint16_t F87_IE:1;
uint16_t F87_DE:1;
uint16_t F87_ZE:1;
uint16_t F87_OE:1;
uint16_t F87_UE:1;
uint16_t F87_PE:1;
uint16_t F87_SF:1;
uint16_t F87_ES:1;
uint16_t F87_C0:1;
uint16_t F87_C1:1;
uint16_t F87_C2:1;
uint16_t F87_TOP:3;
uint16_t F87_C3:1;
uint16_t F87_B:1;
unsigned int F87_IE:1;
unsigned int F87_DE:1;
unsigned int F87_ZE:1;
unsigned int F87_OE:1;
unsigned int F87_UE:1;
unsigned int F87_PE:1;
unsigned int F87_SF:1;
unsigned int F87_ES:1;
unsigned int F87_C0:1;
unsigned int F87_C1:1;
unsigned int F87_C2:1;
unsigned int F87_TOP:3;
unsigned int F87_C3:1;
unsigned int F87_B:1;
} f;
uint16_t x16;
} x87flags_t;
typedef union {
struct __attribute__ ((__packed__)) {
uint16_t C87_IM:1; // interupt masks
uint16_t C87_DM:1;
uint16_t C87_ZM:1;
uint16_t C87_OM:1;
uint16_t C87_UM:1;
uint16_t C87_PM:1;
uint16_t C87_R1:2; // reserved
uint16_t C87_PC:2; // precision control (24bits, reserved, 53bits, 64bits)
uint16_t C87_RD:2; // Rounds
uint16_t C87_IC:1;
uint16_t C87_R2:3; // reserved
unsigned int C87_IM:1; // interupt masks
unsigned int C87_DM:1;
unsigned int C87_ZM:1;
unsigned int C87_OM:1;
unsigned int C87_UM:1;
unsigned int C87_PM:1;
unsigned int C87_R1:2; // reserved
unsigned int C87_PC:2; // precision control (24bits, reserved, 53bits, 64bits)
unsigned int C87_RD:2; // Rounds
unsigned int C87_IC:1;
unsigned int C87_R2:3; // reserved
} f;
uint16_t x16;
} x87control_t;
typedef union {
struct __attribute__ ((__packed__)) {
uint32_t MXCSR_IE:1;
uint32_t MXCSR_DE:1;
uint32_t MXCSR_ZE:1;
uint32_t MXCSR_OE:1;
uint32_t MXCSR_UE:1;
uint32_t MXCSR_PE:1;
uint32_t MXCSR_DAZ:1;
uint32_t MXCSR_IM:1;
uint32_t MXCSR_DM:1;
uint32_t MXCSR_ZM:1;
uint32_t MXCSR_OM:1;
uint32_t MXCSR_UM:1;
uint32_t MXCSR_PM:1;
uint32_t MXCSR_RC:2;
uint32_t MXCSR_FZ:1;
uint32_t MXCSR_RES:16;
} f;
uint32_t x32;
} mmxcontrol_t;
typedef union {
uint64_t q;
int64_t sq;
-1
View File
@@ -18,7 +18,6 @@ uintptr_t FindSymbol(kh_mapsymbols_t *mapsymbols, const char* name, int ver, con
// don't add if already there
void AddUniqueSymbol(kh_mapsymbols_t *mapsymbols, const char* name, uintptr_t addr, uint32_t sz, int ver, const char* vername);
int GetSymbolStartEnd(kh_mapsymbols_t* mapsymbols, const char* name, uintptr_t* start, uintptr_t* end, int ver, const char* vername, int local, const char* defver);
int GetSizedSymbolStartEnd(kh_mapsymbols_t* mapsymbols, const char* name, uintptr_t* start, uintptr_t* end, size_t size, int ver, const char* vername, int local, const char* defver);
const char* GetSymbolName(kh_mapsymbols_t* mapsymbols, void* p, uintptr_t* offs, uint32_t* sz, const char** vername);
// default version handling
-2
View File
@@ -20,9 +20,7 @@ void fini_pthread_helper(box86context_t* context);
// prepare an "emuthread structure" in pet and return address of function pointer for a "thread creation routine"
void* my_prepare_thread(x86emu_t *emu, void* f, void* arg, int ssize, void** pet);
#ifndef DYNAREC
//check and unlock if a mutex is locked by current thread (works only for PTHREAD_MUTEX_ERRORCHECK typed mutex)
int checkUnlockMutex(void* m);
#endif
#endif //_THREADS_H_
+1 -1
View File
@@ -7,7 +7,7 @@ typedef struct box86context_s box86context_t;
typedef int (*wrappedlib_init_t)(library_t * lib, box86context_t* box86); // 0 = success
typedef void (*wrappedlib_fini_t)(library_t * lib);
typedef int (*wrappedlib_get_t)(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, size_t size, int* weak, int version, const char* vername, int local);
typedef int (*wrappedlib_get_t)(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, int* weak, int version, const char* vername, int local);
void setNeededLibs(library_t* lib, int n, ...);
#define SETALT(A) lib->w.altmy = box_strdup(#A)
+16 -25
View File
@@ -20,7 +20,6 @@ KHASH_MAP_IMPL_INT(mapoffsets, cstr_t);
lib_t *NewLibrarian(box86context_t* context, int ownlibs)
{
(void)context;
lib_t *maplib = (lib_t*)box_calloc(1, sizeof(lib_t));
maplib->mapoffsets = kh_init(mapoffsets);
@@ -111,7 +110,6 @@ void FreeLibrarian(lib_t **maplib, x86emu_t *emu)
box86context_t* GetLibrarianContext(lib_t* maplib)
{
(void)maplib;
return my_context;
}
@@ -296,7 +294,6 @@ int AddNeededLib_add(lib_t* maplib, needed_libs_t* neededlibs, library_t* deplib
int AddNeededLib_init(lib_t* maplib, needed_libs_t* neededlibs, library_t* deplib, int local, int bindnow, library_t* lib, box86context_t* box86, x86emu_t* emu)
{
(void)neededlibs; (void)deplib;
if(!maplib)
maplib = (local)?lib->maplib:my_context->maplib;
@@ -388,7 +385,7 @@ static int isLocal(elfheader_t* self, library_t* l)
return 0;
}
int GetNoSelfSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, elfheader_t* self, size_t size, int version, const char* vername)
int GetNoSelfSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, elfheader_t* self, int version, const char* vername)
{
assert(self); // need self for this one
//search for the self, to start "next"
@@ -402,13 +399,13 @@ int GetNoSelfSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, u
go = 0; // not found...
for(int i=go; i<maplib->libsz; ++i) {
if(GetElfIndex(maplib->libraries[i])==-1 || (my_context->elfs[GetElfIndex(maplib->libraries[i])]!=self))
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, start, end, size, &weak, version, vername, 0))
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, start, end, &weak, version, vername, 0))
if(*start)
return 1;
}
for(int i=go; i<maplib->libsz; ++i)
if(GetElfIndex(maplib->libraries[i])==-1 || (my_context->elfs[GetElfIndex(maplib->libraries[i])]!=self))
GetLibWeakSymbolStartEnd(maplib->libraries[i], name, start, end, size, &weak, version, vername, 0);
GetLibWeakSymbolStartEnd(maplib->libraries[i], name, start, end, &weak, version, vername, 0);
// loop done, weak symbol found
if(weak && *start)
return 1;
@@ -416,23 +413,23 @@ int GetNoSelfSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, u
if(self) {
if(my_context->elfs[0]!=self) {
const char* defver = GetDefaultVersion(my_context->globaldefver, name);
if(GetSizedSymbolStartEnd(GetMapSymbols(my_context->elfs[0]), name, start, end, size, version, vername, 1, defver))
if(GetSymbolStartEnd(GetMapSymbols(my_context->elfs[0]), name, start, end, version, vername, 1, defver))
if(*start)
return 1;
defver = GetDefaultVersion(my_context->weakdefver, name);
if(GetSizedSymbolStartEnd(GetWeakSymbols(my_context->elfs[0]), name, start, end, size, version, vername, 1, defver))
if(GetSymbolStartEnd(GetWeakSymbols(my_context->elfs[0]), name, start, end, version, vername, 1, defver))
if(*start)
weak = 1;
}
for(int i=0; i<go; ++i) {
if(GetElfIndex(maplib->libraries[i])==-1 || (my_context->elfs[GetElfIndex(maplib->libraries[i])]!=self))
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, start, end, size, &weak, version, vername, 1))
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, start, end, &weak, version, vername, 1))
if(*start)
return 1;
}
for(int i=0; i<go; ++i) {
if(GetElfIndex(maplib->libraries[i])==-1 || (my_context->elfs[GetElfIndex(maplib->libraries[i])]!=self))
GetLibWeakSymbolStartEnd(maplib->libraries[i], name, start, end, size, &weak, version, vername, 1);
GetLibWeakSymbolStartEnd(maplib->libraries[i], name, start, end, &weak, version, vername, 1);
}
if(weak && *start)
return 1;
@@ -443,7 +440,6 @@ int GetNoSelfSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, u
static int GetGlobalSymbolStartEnd_internal(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, elfheader_t* self, int version, const char* vername)
{
int weak = 0;
size_t size = 0;
// check with default version...
const char* defver = GetDefaultVersion(my_context->globaldefver, name);
// search non-weak symbol, from older to newer (first GLOBAL object wins)
@@ -453,12 +449,12 @@ static int GetGlobalSymbolStartEnd_internal(lib_t *maplib, const char* name, uin
// TODO: create a temporary map to search lib only 1 time, and in order of needed...
// search in needed libs from neededlibs first, in order
for(int i=0; i<my_context->neededlibs.size; ++i)
if(GetLibGlobalSymbolStartEnd(my_context->neededlibs.libs[i], name, start, end, size, &weak, version, vername, isLocal(self, my_context->neededlibs.libs[i])))
if(GetLibGlobalSymbolStartEnd(my_context->neededlibs.libs[i], name, start, end, &weak, version, vername, isLocal(self, my_context->neededlibs.libs[i])))
if(*start)
return 1;
// search in global symbols
for(int i=0; i<maplib->libsz; ++i) {
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, start, end, size, &weak, version, vername, isLocal(self, maplib->libraries[i])))
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, start, end, &weak, version, vername, isLocal(self, maplib->libraries[i])))
if(*start)
return 1;
}
@@ -472,7 +468,7 @@ static int GetGlobalSymbolStartEnd_internal(lib_t *maplib, const char* name, uin
ok = 1;
for(int i=0; i<maplib->libsz; ++i) {
if(GetLibWeakSymbolStartEnd(maplib->libraries[i], name, start, end, size, &weak, version, vername, isLocal(self, maplib->libraries[i])))
if(GetLibWeakSymbolStartEnd(maplib->libraries[i], name, start, end, &weak, version, vername, isLocal(self, maplib->libraries[i])))
if(*start)
ok = 1;
}
@@ -518,7 +514,6 @@ elfheader_t* GetGlobalSymbolElf(lib_t *maplib, const char* name, int version, co
{
uintptr_t start = 0;
uintptr_t end = 0;
size_t size = 0;
int weak = 0;
elfheader_t* ret = NULL;
// check with default version...
@@ -527,7 +522,7 @@ elfheader_t* GetGlobalSymbolElf(lib_t *maplib, const char* name, int version, co
if(GetSymbolStartEnd(GetMapSymbols(my_context->elfs[0]), name, &start, &end, version, vername, 1, defver))
return my_context->elfs[0];
for(int i=0; i<maplib->libsz; ++i) {
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, &start, &end, size, &weak, version, vername, 1)) {
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, &start, &end, &weak, version, vername, 1)) {
int idx = GetElfIndex(maplib->libraries[i]);
if(idx==-1) {
printf_log(LOG_NONE, "Warning, getting Elf info for a native symbol \"%s\" from lib \"%s\"\n", name, GetNameLib(maplib->libraries[i]));
@@ -544,7 +539,7 @@ elfheader_t* GetGlobalSymbolElf(lib_t *maplib, const char* name, int version, co
if(GetSymbolStartEnd(GetWeakSymbols(my_context->elfs[0]), name, &start, &end, version, vername, 1, defver))
ret = my_context->elfs[0];
for(int i=0; i<maplib->libsz; ++i) {
if(GetLibWeakSymbolStartEnd(maplib->libraries[i], name, &start, &end, size, &weak, version, vername, 1)) {
if(GetLibWeakSymbolStartEnd(maplib->libraries[i], name, &start, &end, &weak, version, vername, 1)) {
int idx = GetElfIndex(maplib->libraries[i]);
if(idx==-1) {
printf_log(LOG_NONE, "Warning, getting Elf info for a native symbol \"%s\" from lib \"%s\"\n", name, GetNameLib(maplib->libraries[i]));
@@ -563,7 +558,6 @@ elfheader_t* GetGlobalSymbolElf(lib_t *maplib, const char* name, int version, co
int GetGlobalNoWeakSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, int version, const char* vername)
{
int weak = 0;
size_t size = 0;
// check with default version...
const char* defver = GetDefaultVersion(my_context->globaldefver, name);
@@ -571,7 +565,7 @@ int GetGlobalNoWeakSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* st
if(*start || *end)
return 1;
for(int i=0; i<maplib->libsz; ++i)
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, start, end, size, &weak, version, vername, 1))
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, start, end, &weak, version, vername, 1))
if(*start || *end)
return 1;
// nope, not found
@@ -581,12 +575,11 @@ int GetGlobalNoWeakSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* st
int IsGlobalNoWeakSymbolInNative(lib_t *maplib, const char* name, int version, const char* vername)
{
uintptr_t start, end;
size_t size = 0;
int weak;
// check with default version...
for(int i=0; i<maplib->libsz; ++i)
if(GetElfIndex(maplib->libraries[i])==-1)
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, &start, &end, size, &weak, version, vername, 1))
if(GetLibGlobalSymbolStartEnd(maplib->libraries[i], name, &start, &end, &weak, version, vername, 1))
if(start || end)
return 1;
// nope, not found
@@ -598,7 +591,6 @@ int GetLocalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, ui
{
// check with default version...
int weak;
size_t size = 0;
if(my_context->elfs[0]==self || !self) {
if(GetSymbolStartEnd(GetLocalSymbols(my_context->elfs[0]), name, start, end, version, vername, 1, NULL))
@@ -609,8 +601,8 @@ int GetLocalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, ui
}
for(int i=0; i<maplib->libsz; ++i) {
if(GetElfIndex(maplib->libraries[i])!=-1 && (!self || my_context->elfs[GetElfIndex(maplib->libraries[i])]==self)) {
if(GetLibLocalSymbolStartEnd(maplib->libraries[i], name, start, end, size, &weak, version, vername, 1))
if(*start || *end)
if(GetLibLocalSymbolStartEnd(maplib->libraries[i], name, start, end, &weak, version, vername, 1))
if(*start)
return 1;
if(self)
return 0;
@@ -623,7 +615,6 @@ int GetLocalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, ui
const char* FindSymbolName(lib_t *maplib, void* p, void** start, uint32_t* sz, const char** libname, void** base, library_t** lib)
{
(void)maplib;
// first, search in self...
const char* ret = NULL;
uintptr_t offs = 0;
+48 -54
View File
@@ -101,7 +101,6 @@ void WrappedLib_CommonInit(library_t* lib)
void EmuLib_Fini(library_t* lib)
{
(void)lib;
}
void WrappedLib_FinishFini(library_t* lib)
{
@@ -118,13 +117,12 @@ void WrappedLib_FinishFini(library_t* lib)
FreeBridge(&lib->w.bridge);
}
int WrappedLib_GetWeak(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, size_t asked_size, int *weak, int version, const char* vername, int local)
int WrappedLib_GetWeak(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, int *weak, int version, const char* vername, int local)
{
// ignoring asked size on wrapped libs
(void)asked_size;
uintptr_t addr = 0;
uint32_t size = 0;
int wk = 0;
void* symbol = NULL;
if (!getSymbolInMaps(lib, name, 0, &addr, &size, &wk, version, vername, local)) {
return 0;
}
@@ -137,12 +135,12 @@ int WrappedLib_GetWeak(library_t* lib, const char* name, uintptr_t *offs, uint32
*weak = wk;
return 1;
}
int EmuLib_GetWeak(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, size_t asked_size, int* weak, int version, const char* vername, int local)
int EmuLib_GetWeak(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, int* weak, int version, const char* vername, int local)
{
uintptr_t start, end;
const char* defver = GetDefaultVersion(my_context->weakdefver, name);
// weak symbols...
if(GetSizedSymbolStartEnd(GetWeakSymbols(lib->e.elf), name, &start, &end, asked_size, version, vername, local, defver))
if(GetSymbolStartEnd(GetWeakSymbols(lib->e.elf), name, &start, &end, version, vername, local, defver))
{
*offs = start;
*sz = end-start;
@@ -151,13 +149,12 @@ int EmuLib_GetWeak(library_t* lib, const char* name, uintptr_t *offs, uint32_t *
}
return 0;
}
int WrappedLib_GetGlobal(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, size_t asked_size, int* weak, int version, const char* vername, int local)
int WrappedLib_GetGlobal(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, int* weak, int version, const char* vername, int local)
{
// ignoring asked size on wrapped libs
(void)asked_size;
uintptr_t addr = 0;
uint32_t size = 0;
int wk = 0;
void* symbol = NULL;
if (!getSymbolInMaps(lib, name, 1, &addr, &size, &wk, version, vername, local)) {
return 0;
}
@@ -170,11 +167,11 @@ int WrappedLib_GetGlobal(library_t* lib, const char* name, uintptr_t *offs, uint
*weak = 0;
return 1;
}
int EmuLib_GetGlobal(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, size_t asked_size, int *weak, int version, const char* vername, int local)
int EmuLib_GetGlobal(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, int *weak, int version, const char* vername, int local)
{
uintptr_t start, end;
const char* defver = GetDefaultVersion(my_context->globaldefver, name);
if(GetSizedSymbolStartEnd(GetMapSymbols(lib->e.elf), name, &start, &end, asked_size, version, vername, local, defver))
if(GetSymbolStartEnd(GetMapSymbols(lib->e.elf), name, &start, &end, version, vername, local, defver))
{
*offs = start;
*sz = end-start;
@@ -183,12 +180,12 @@ int EmuLib_GetGlobal(library_t* lib, const char* name, uintptr_t *offs, uint32_t
}
return 0;
}
int EmuLib_GetLocal(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, size_t asked_size, int *weak, int version, const char* vername, int local)
int EmuLib_GetLocal(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, int *weak, int version, const char* vername, int local)
{
uintptr_t start, end;
const char* defver = GetDefaultVersion(my_context->globaldefver, name);
if(!defver) defver = GetDefaultVersion(my_context->weakdefver, name);
if(GetSizedSymbolStartEnd(GetLocalSymbols(lib->e.elf), name, &start, &end, asked_size, version, vername, local, defver))
if(GetSymbolStartEnd(GetLocalSymbols(lib->e.elf), name, &start, &end, version, vername, local, defver))
{
*offs = start;
*sz = end-start;
@@ -198,9 +195,8 @@ int EmuLib_GetLocal(library_t* lib, const char* name, uintptr_t *offs, uint32_t
return 0;
}
int WrappedLib_GetLocal(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, size_t asked_size, int* weak, int version, const char* vername, int local)
int WrappedLib_GetLocal(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz, int* weak, int version, const char* vername, int local)
{
(void)lib; (void)name; (void)offs; (void)sz; (void)asked_size; (void)weak; (void)version; (void)vername; (void)local;
return 0;
}
@@ -308,23 +304,12 @@ static int loadEmulatedLib(const char* libname, library_t *lib, box86context_t*
printf_log(LOG_INFO, "Using emulated %s\n", libname);
#ifdef DYNAREC
if(libname && box86_dynarec_bleeding_edge && strstr(libname, "libmonobdwgc-2.0.so")) {
if(libname && strstr(libname, "libmonobdwgc-2.0.so")) {
printf_log(LOG_INFO, "MonoBleedingEdge detected, disable Dynarec BigBlock and enable Dynarec StrongMem\n");
box86_dynarec_bigblock = 0;
box86_dynarec_strongmem = 1;
}
#endif
// spacial case for spd_readdir, to allow override a few symbols
if(libname && strstr(libname, "spd_readdir.so")) {
printf_log(LOG_INFO, "spd_readdir detected, hacking wrapped libc\n");
const char* symbols[] = {"opendir", "readdir", "readdir_r", "readdir64", "closedir", "telldir", "seekdir", "dirfd"};
for(unsigned int i=0; i<sizeof(symbols)/sizeof(symbols[0]); ++i) {
const char* symname = AddDictionnary(my_context->versym, symbols[i]);
const char* vername = AddDictionnary(my_context->versym, "GLIBC_2.0");
AddDefaultVersion(my_context->globaldefver, symname, vername);
}
}
return 1;
}
return 0;
@@ -361,12 +346,13 @@ static const char* essential_libs[] = {
"ld-linux-x86-64.so.2", "crashhandler.so", "libtcmalloc_minimal.so.0", "libtcmalloc_minimal.so.4"
};
static int isEssentialLib(const char* name) {
for (unsigned int i=0; i<sizeof(essential_libs)/sizeof(essential_libs[0]); ++i)
for (int i=0; i<sizeof(essential_libs)/sizeof(essential_libs[0]); ++i)
if(!strcmp(name, essential_libs[i]))
return 1;
return 0;
}
extern char* libGL;
library_t *NewLibrary(const char* path, box86context_t* context)
{
printf_log(LOG_DEBUG, "Trying to load \"%s\"\n", path);
@@ -374,7 +360,7 @@ library_t *NewLibrary(const char* path, box86context_t* context)
lib->path = box_realpath(path, NULL);
if(!lib->path)
lib->path = box_strdup(path);
if(box86_libGL && !strcmp(path, box86_libGL))
if(libGL && !strcmp(path, libGL))
lib->name = box_strdup("libGL.so.1");
else
lib->name = Path2Name(path);
@@ -434,7 +420,6 @@ library_t *NewLibrary(const char* path, box86context_t* context)
}
int AddSymbolsLibrary(lib_t *maplib, library_t* lib, x86emu_t* emu)
{
(void)emu;
lib->active = 1;
if(lib->type==LIB_EMULATED) {
elfheader_t *elf_header = lib->e.elf;
@@ -466,7 +451,7 @@ int FinalizeLibrary(library_t* lib, lib_t* local_maplib, int bindnow, x86emu_t*
printf_log(LOG_INFO, "TRACE on %s only (%p-%p)\n", trace_func, (void*)trace_start, (void*)trace_end);
box_free(trace_func);
trace_func = NULL;
} else if(GetLibLocalSymbolStartEnd(lib, trace_func, &trace_start, &trace_end, 0, &weak, -1, NULL, 0)) {
} else if(GetLibLocalSymbolStartEnd(lib, trace_func, &trace_start, &trace_end, &weak, -1, NULL, 0)) {
SetTraceEmu(trace_start, trace_end);
printf_log(LOG_INFO, "TRACE on %s only (%p-%p)\n", trace_func, (void*)trace_start, (void*)trace_end);
box_free(trace_func);
@@ -636,24 +621,34 @@ int IsSameLib(library_t* lib, const char* path)
box_free(name);
return ret;
}
int GetLibWeakSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, size_t size, int* weak, int version, const char* vername, int local)
int GetLibWeakSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, int* weak, int version, const char* vername, int local)
{
if(!name[0] || !lib || !lib->active)
return 0;
khint_t k;
// get a new symbol
if(lib->getweak(lib, name, start, end, size, weak, version, vername, local)) {
*end += *start; // lib->get(...) gives size, not end
kh_bridgemap_t *map = local?lib->lbridgemap:((*weak)?lib->wbridgemap:lib->gbridgemap);
// check first if already in the map
k = kh_get(bridgemap, map, VersionnedName(name, version, vername));
if(k!=kh_end(map)) {
*start = kh_value(map, k).start;
*end = kh_value(map, k).end;
// check first if already in the map
k = kh_get(bridgemap, lib->wbridgemap, VersionnedName(name, version, vername));
if(k!=kh_end(lib->wbridgemap)) {
*start = kh_value(lib->wbridgemap, k).start;
*end = kh_value(lib->wbridgemap, k).end;
*weak = 1;
return 1;
}
if(local) {
k = kh_get(bridgemap, lib->lbridgemap, VersionnedName(name, version, vername));
if(k!=kh_end(lib->lbridgemap)) {
*start = kh_value(lib->lbridgemap, k).start;
*end = kh_value(lib->lbridgemap, k).end;
*weak = 0;
return 1;
}
}
// get a new symbol
if(lib->getweak(lib, name, start, end, weak, version, vername, local)) {
*end += *start; // lib->get(...) gives size, not end
char* symbol = box_strdup(VersionnedName(name, version, vername));
int ret;
kh_bridgemap_t *map = local?lib->lbridgemap:((*weak)?lib->wbridgemap:lib->gbridgemap);
k = kh_put(bridgemap, map, symbol, &ret);
kh_value(map, k).name = symbol;
kh_value(map, k).start = *start;
@@ -663,13 +658,13 @@ int GetLibWeakSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start,
// nope
return 0;
}
int GetLibGlobalSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, size_t size, int *weak, int version, const char* vername, int local)
int GetLibGlobalSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, int *weak, int version, const char* vername, int local)
{
if(!name[0] || !lib || !lib->active)
return 0;
khint_t k;
// get a new symbol
if(lib->getglobal(lib, name, start, end, size, weak, version, vername, local)) {
if(lib->getglobal(lib, name, start, end, weak, version, vername, local)) {
*end += *start; // lib->get(...) gives size, not end
kh_bridgemap_t *map = local?lib->lbridgemap:((*weak)?lib->wbridgemap:lib->gbridgemap);
// check if already in the map
@@ -690,21 +685,21 @@ int GetLibGlobalSymbolStartEnd(library_t* lib, const char* name, uintptr_t* star
// nope
return 0;
}
int GetLibLocalSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, size_t size, int* weak, int version, const char* vername, int local)
int GetLibLocalSymbolStartEnd(library_t* lib, const char* name, uintptr_t* start, uintptr_t* end, int* weak, int version, const char* vername, int local)
{
if(!name[0] || !lib || !lib->active)
return 0;
khint_t k;
// check first if already in the map
k = kh_get(bridgemap, lib->lbridgemap, VersionnedName(name, version, vername));
if(k!=kh_end(lib->lbridgemap)) {
*start = kh_value(lib->lbridgemap, k).start;
*end = kh_value(lib->lbridgemap, k).end;
return 1;
}
// get a new symbol
if(lib->getlocal(lib, name, start, end, size, weak, version, vername, local)) {
if(lib->getlocal(lib, name, start, weak, end, version, vername, local)) {
*end += *start; // lib->get(...) gives size, not end
// check first if already in the map
k = kh_get(bridgemap, lib->lbridgemap, VersionnedName(name, version, vername));
if(k!=kh_end(lib->lbridgemap)) {
*start = kh_value(lib->lbridgemap, k).start;
*end = kh_value(lib->lbridgemap, k).end;
return 1;
}
char* symbol = box_strdup(VersionnedName(name, version, vername));
int ret;
k = kh_put(bridgemap, lib->lbridgemap, symbol, &ret);
@@ -939,7 +934,6 @@ static int getSymbolInSymbolMaps(library_t*lib, const char* name, int noweak, ui
int getSymbolInMaps(library_t*lib, const char* name, int noweak, uintptr_t *addr, uint32_t *size, int* weak, int version, const char* vername, int local)
{
(void)local;
if(!lib->active)
return 0;
if(version==-2) // don't send global native symbol for a version==-2 search
@@ -1103,4 +1097,4 @@ void setNeededLibs(library_t* lib, int n, ...)
lib->w.neededlibs[i] = box_strdup(va_arg(va, char*));
}
va_end (va);
}
}
+31 -48
View File
@@ -58,89 +58,89 @@ static int SameVersion(versymbol_t* s, int ver, const char* vername)
}
static versymbol_t* FindVersionLocal(versymbols_t* s, size_t size)
static versymbol_t* FindVersionLocal(versymbols_t* s)
{
if(!s || !s->sz)
return NULL;
for (int i=0; i<s->sz; ++i)
if(s->syms[i].version==0 && (!size || (size==s->syms[i].sym.sz)))
if(s->syms[i].version==0)
return &s->syms[i];
return NULL;
}
static versymbol_t* FindNoVersion(versymbols_t* s, size_t size)
static versymbol_t* FindNoVersion(versymbols_t* s)
{
if(!s || !s->sz)
return NULL;
for (int i=0; i<s->sz; ++i)
if(s->syms[i].version==-1 && (!size || (size==s->syms[i].sym.sz)))
if(s->syms[i].version==-1)
return &s->syms[i];
return NULL;
}
static versymbol_t* FindVersionGlobal(versymbols_t* s, size_t size)
static versymbol_t* FindVersionGlobal(versymbols_t* s)
{
if(!s || !s->sz)
return NULL;
for (int i=0; i<s->sz; ++i)
if(s->syms[i].version==1 && (!size || (size==s->syms[i].sym.sz)))
if(s->syms[i].version==1)
return &s->syms[i];
return NULL;
}
static versymbol_t* FindVersion(versymbols_t* s, size_t size, const char* vername)
static versymbol_t* FindVersion(versymbols_t* s, const char* vername)
{
if(!s || !s->sz)
return NULL;
for (int i=0; i<s->sz; ++i)
if(s->syms[i].vername && !strcmp(s->syms[i].vername, vername) && (!size || (size==s->syms[i].sym.sz)))
if(s->syms[i].vername && !strcmp(s->syms[i].vername, vername))
return &s->syms[i];
return NULL;
}
/* static versymbol_t* FindFirstVersion(versymbols_t* s, size_t size)
static versymbol_t* FindFirstVersion(versymbols_t* s)
{
if(!s || !s->sz)
return NULL;
for (int i=0; i<s->sz; ++i)
if(s->syms[i].version>1 && (!size || (size==s->syms[i].sym.sz)))
if(s->syms[i].version>1)
return &s->syms[i];
return NULL;
} */
}
// Match version (so ver=0:0, ver=1:-1/1/X, ver=-1:any, ver=X:1/"name")
static versymbol_t* MatchVersion(versymbols_t* s, int ver, const char* vername, size_t size, int local, const char* defver)
static versymbol_t* MatchVersion(versymbols_t* s, int ver, const char* vername, int local, const char* defver)
{
if(!s || !s->sz)
return NULL;
versymbol_t* ret = NULL;
if(ver==0) {
if(local) ret = FindVersionLocal(s, size);
if(!ret) ret = FindNoVersion(s, size);
if(!ret) ret = FindVersionGlobal(s, size);
if(!ret && defver) ret = FindVersion(s, size, defver);
if(local) ret = FindVersionLocal(s);
if(!ret) ret = FindNoVersion(s);
if(!ret) ret = FindVersionGlobal(s);
if(!ret && defver) ret = FindVersion(s, defver);
return ret;
}
if(ver==-1) {
if(local) ret = FindVersionLocal(s, size);
if(!ret) ret = FindNoVersion(s, size);
if(!ret) ret = FindVersionGlobal(s, size);
if(!ret && defver) ret = FindVersion(s, size, defver);
if(local) ret = FindVersionLocal(s);
if(!ret) ret = FindNoVersion(s);
if(!ret) ret = FindVersionGlobal(s);
if(!ret && defver) ret = FindVersion(s, defver);
//if(!ret) ret = FindFirstVersion(s);
return ret;
}
if(ver==-2) {
if(local) ret = FindVersionLocal(s, size);
if(!ret) ret = FindVersionGlobal(s, size);
if(local) ret = FindVersionLocal(s);
if(!ret) ret = FindVersionGlobal(s);
return ret;
}
if(ver==1) {
if(local) ret = FindVersionLocal(s, size);
if(!ret) ret = FindVersionGlobal(s, size);
if(!ret) ret = FindNoVersion(s, size);
if(!ret && defver) ret = FindVersion(s, size, defver);
if(local) ret = FindVersionLocal(s);
if(!ret) ret = FindVersionGlobal(s);
if(!ret) ret = FindNoVersion(s);
if(!ret && defver) ret = FindVersion(s, defver);
//if(!ret) ret = FindFirstVersion(s);
return ret;
}
ret = FindVersion(s, size, vername);
if(local && !ret) ret = FindVersionLocal(s, size);
if(!ret && defver && vername && !strcmp(defver, vername)) ret = FindVersionGlobal(s, size);
ret = FindVersion(s, vername);
if(local && !ret) ret = FindVersionLocal(s);
if(!ret && defver && vername && !strcmp(defver, vername)) ret = FindVersionGlobal(s);
//if(!ret) return FindVersionGlobal(s);
return ret;
}
@@ -178,7 +178,7 @@ uintptr_t FindSymbol(kh_mapsymbols_t *mapsymbols, const char* name, int ver, con
if(k==kh_end(mapsymbols))
return 0;
versymbols_t * v = &kh_val(mapsymbols, k);
versymbol_t * s = MatchVersion(v, ver, vername, 0, local, defver);
versymbol_t * s = MatchVersion(v, ver, vername, local, defver);
if(s)
return s->sym.offs;
return 0;
@@ -215,24 +215,7 @@ int GetSymbolStartEnd(kh_mapsymbols_t* mapsymbols, const char* name, uintptr_t*
if(k==kh_end(mapsymbols))
return 0;
versymbols_t * v = &kh_val(mapsymbols, k);
versymbol_t* s = MatchVersion(v, ver, vername, 0, local, defver);
if(s) {
*start = s->sym.offs;
*end = *start + s->sym.sz;
return 1;
}
return 0;
}
int GetSizedSymbolStartEnd(kh_mapsymbols_t* mapsymbols, const char* name, uintptr_t* start, uintptr_t* end, size_t size, int ver, const char* vername, int local, const char* defver)
{
if(!mapsymbols)
return 0;
khint_t k = kh_get(mapsymbols, mapsymbols, name);
if(k==kh_end(mapsymbols))
return 0;
versymbols_t * v = &kh_val(mapsymbols, k);
versymbol_t* s = MatchVersion(v, ver, vername, size, local, defver);
versymbol_t* s = MatchVersion(v, ver, vername, local, defver);
if(s) {
*start = s->sym.offs;
*end = *start + s->sym.sz;
-5
View File
@@ -39,7 +39,6 @@ GO("libXext.so.6", libxext)
GO("libXfixes.so.3", libxfixes)
GO("libXcursor.so.1", libxcursor)
GO("libXrender.so.1", libxrender)
GO("libXpresent.so.1", libxpresent)
GO("libXft.so.2", libxft)
GO("libXi.so.6", libxi)
GO("libXss.so.1", libxss)
@@ -113,14 +112,10 @@ GO("libpangoft2-1.0.so", pangoft2)
GO("libpangoft2-1.0.so.0", pangoft2)
GO("libpangocairo-1.0.so.0", pangocairo)
GO("libcairo.so.2", cairo)
GO("libcairo.so", cairo)
GO("libcairo-gobject.so.2", cairogobject)
GO("libpango-1.0.so.0", pango)
GO("libpango-1.0.so", pango)
GO("libnm.so.0", libnm)
GO("libnm-glib.so.4", libnm)
GO("libnm-util.so.2", libnm)
GO("libibus-1.0.so.5", libibus)
GO("libfontconfig.so.1", fontconfig)
GO("libbz2.so.1", bz2)
GO("libexpat.so.1", expat)
+1 -2
View File
@@ -23,7 +23,6 @@
static uintptr_t* auxval_start = NULL;
int init_auxval(int argc, const char **argv, char **env) {
(void)argc; (void)argv;
// auxval vector is after envs...
while(*env)
env++;
@@ -57,4 +56,4 @@ EXPORT unsigned long my_getauxval(x86emu_t* emu, unsigned long type)
p+=2;
}
return 0;
}
}
+12 -20
View File
@@ -35,12 +35,10 @@ void myStackAlign(const char* fmt, uint32_t* st, uint32_t* mystack)
case 2: // l
case 3: // ll
case 4: // L
case 5: // z
switch(*p) {
case '%': state = 0; ++p; break; //%% = back to 0
case 'l': ++state; if (state>3) state=3; ++p; break;
case 'L': state = 4; ++p; break;
case 'z': state = 5; ++p; break;
case 'a':
case 'A':
case 'e':
@@ -68,7 +66,6 @@ void myStackAlign(const char* fmt, uint32_t* st, uint32_t* mystack)
case '8':
case '9':
case '.':
case '#':
case '+':
case '-': ++p; break; // formating, ignored
case 'm': state = 0; ++p; break; // no argument
@@ -86,7 +83,6 @@ void myStackAlign(const char* fmt, uint32_t* st, uint32_t* mystack)
case 11: //double
case 12: //%lg, still double
case 13: //%llg, still double
case 15: //%zg, meh... double?
case 23: // 64bits int
if((((uint32_t)mystack)&0x7)!=0)
mystack++;
@@ -97,7 +93,6 @@ void myStackAlign(const char* fmt, uint32_t* st, uint32_t* mystack)
break;
case 14: //%LG long double
#ifdef HAVE_LD80BITS
(void)d;
if((((uint32_t)mystack)&0x7)!=0)
mystack++;
memcpy(mystack, st, 10);
@@ -117,7 +112,6 @@ void myStackAlign(const char* fmt, uint32_t* st, uint32_t* mystack)
case 21:
case 22:
case 24: // normal int / pointer
case 25: // size_t int
case 30:
*mystack = *st;
++mystack;
@@ -299,11 +293,9 @@ void myStackAlignGVariantNew(const char* fmt, uint32_t* st, uint32_t* mystack)
++st;
state = 0;
} else state = 0; //???
break;
case 8: // ^&
if (*p == 'a') state = 9;
else state = 0; //???
break;
case 9: // ^&a
if (*p == 'y') {
*mystack = *st;
@@ -311,7 +303,6 @@ void myStackAlignGVariantNew(const char* fmt, uint32_t* st, uint32_t* mystack)
++st;
state = 0;
} else state = 0; //???
break;
}
++p;
} while (*p && (inblocks || state));
@@ -337,12 +328,10 @@ void myStackAlignW(const char* fmt, uint32_t* st, uint32_t* mystack)
case 2: // l
case 3: // ll
case 4: // L
case 5: // z
switch(*p) {
case '%': state = 0; ++p; break; //%% = back to 0
case 'l': ++state; if (state>3) state=3; ++p; break;
case 'L': state = 4; ++p; break;
case 'z': state = 5; ++p; break;
case 'a':
case 'A':
case 'e':
@@ -370,7 +359,6 @@ void myStackAlignW(const char* fmt, uint32_t* st, uint32_t* mystack)
case '8':
case '9':
case '.':
case '#':
case '+':
case '-': ++p; break; // formating, ignored
case 'm': state = 0; ++p; break; // no argument
@@ -388,7 +376,6 @@ void myStackAlignW(const char* fmt, uint32_t* st, uint32_t* mystack)
case 11: //double
case 12: //%lg, still double
case 13: //%llg, still double
case 15: //%zg, meh.. double?
case 23: // 64bits int
if((((uint32_t)mystack)&0x7)!=0)
mystack++;
@@ -399,7 +386,6 @@ void myStackAlignW(const char* fmt, uint32_t* st, uint32_t* mystack)
break;
case 14: //%LG long double
#ifdef HAVE_LD80BITS
(void)d;
if((((uint32_t)mystack)&0x7)!=0)
mystack++;
memcpy(mystack, st, 10);
@@ -419,7 +405,6 @@ void myStackAlignW(const char* fmt, uint32_t* st, uint32_t* mystack)
case 21:
case 22:
case 24: // normal int / pointer
case 25: // size_t int
case 30:
*mystack = *st;
++mystack;
@@ -769,9 +754,16 @@ void AlignVorbisBlock(void* dest, void* source)
#undef TRANSFERT
typedef union __attribute__((packed)) x86_epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} x86_epoll_data_t;
struct __attribute__((packed)) x86_epoll_event {
uint32_t events;
uint64_t data;
uint32_t events;
x86_epoll_data_t data;
};
// Arm -> x86
void UnalignEpollEvent(void* dest, void* source, int nbr)
@@ -780,7 +772,7 @@ void UnalignEpollEvent(void* dest, void* source, int nbr)
struct epoll_event *arm_struct = (struct epoll_event*)source;
while(nbr) {
x86_struct->events = arm_struct->events;
x86_struct->data = arm_struct->data.u64;
x86_struct->data.u64 = arm_struct->data.u64;
++x86_struct;
++arm_struct;
--nbr;
@@ -794,7 +786,7 @@ void AlignEpollEvent(void* dest, void* source, int nbr)
struct epoll_event *arm_struct = (struct epoll_event*)dest;
while(nbr) {
arm_struct->events = x86_struct->events;
arm_struct->data.u64 = x86_struct->data;
arm_struct->data.u64 = x86_struct->data.u64;
++x86_struct;
++arm_struct;
--nbr;
@@ -916,4 +908,4 @@ void unalignNGValue(void* value, my_GValue_t* v, int n)
value+=4+2*sizeof(double);
--n;
}
}
}
+1 -9
View File
@@ -146,7 +146,6 @@ void freeFts(box86context_t* context, void* ftsp)
#endif
EXPORT void* my_fts_open(x86emu_t* emu, void* path, int options, void* compare_fn)
{
(void)emu;
return fts_open(path, options, findcompareFct(compare_fn));
}
@@ -154,8 +153,6 @@ EXPORT int my_fts_close(x86emu_t* emu, void* ftsp)
{
#ifndef NOALIGN
freeFts(emu->context, ftsp);
#else
(void)emu;
#endif
return fts_close(ftsp);
}
@@ -163,7 +160,6 @@ EXPORT int my_fts_close(x86emu_t* emu, void* ftsp)
EXPORT void* my_fts_read(x86emu_t* emu, void* ftsp)
{
#ifdef NOALIGN
(void)emu;
return fts_read(ftsp);
#else
return getFtsent(getFtsentMap(emu->context, ftsp), fts_read(ftsp), 0);
@@ -173,7 +169,6 @@ EXPORT void* my_fts_read(x86emu_t* emu, void* ftsp)
EXPORT void* my_fts_children(x86emu_t* emu, void* ftsp, int options)
{
#ifdef NOALIGN
(void)emu;
return fts_children(ftsp, options);
#else
return getFtsent(getFtsentMap(emu->context, ftsp), fts_children(ftsp, options), 1);
@@ -184,8 +179,6 @@ void InitFTSMap(box86context_t* context)
{
#ifndef NOALIGN
context->ftsmap = kh_init(fts);
#else
(void)context;
#endif
}
void FreeFTSMap(box86context_t* context)
@@ -196,7 +189,6 @@ void FreeFTSMap(box86context_t* context)
(void)ftsentMap;
kh_foreach(context->ftsmap, ptr, ftsentMap, freeFts(context, (FTSENT*)ptr));
kh_destroy(fts, context->ftsmap);
#else
(void)context;
#endif
}
-1
View File
@@ -189,7 +189,6 @@ EXPORT void my__obstack_newchunk(struct i386_obstack* obstack, int s)
EXPORT int32_t my_obstack_vprintf(x86emu_t* emu, struct i386_obstack* obstack, void* fmt, uint32_t* b, va_list V)
{
(void)emu; (void)V;
struct obstack native = {0};
from_i386_obstack(obstack, &native);
#ifndef NOALIGN
+67 -82
View File
@@ -32,7 +32,6 @@
#ifdef DYNAREC
#include "dynablock.h"
#include "../dynarec/dynablock_private.h"
#include "dynarec_arm.h"
#endif
@@ -132,19 +131,35 @@ struct i386_fpstate
static void save_fpreg(x86emu_t* emu, struct i386_fpstate* state)
{
emu->sw.f.F87_TOP = emu->top&7;
state->sw = emu->sw.x16;
state->cw = emu->cw.x16;
// save SSE and MMX regs
int top = emu->top&7;
int stack = 8-top;
if(top==0) // check if stack is full or empty, based on tag[0]
stack = (emu->p_regs[0].tag)?8:0;
emu->sw.f.F87_TOP = top;
state->sw = emu->sw.x16;
uint8_t tags = 0;
for (int i=0; i<8; ++i)
tags |= ((emu->p_regs[i].tag)<<(i*2)==0b11)?0:1;
fpu_fxsave(emu, &state->ControlWord);
}
static void load_fpreg(x86emu_t* emu, struct i386_fpstate* state)
{
// copy SSE and MMX regs
fpu_fxrstor(emu, &state->ControlWord);
emu->cw.x16 = state->cw;
emu->sw.x16 = state->sw;
emu->top = emu->sw.f.F87_TOP&7;
emu->top = emu->sw.f.F87_TOP;
uint8_t tags = state->tag;
for(int i=0; i<8; ++i)
emu->p_regs[i].tag = (tags>>(i*2))?0:0b11;
// copy back MMX regs...
int top = emu->top&7;
int stack = 8-top;
if(top==0) // check if stack is full or empty, based on tag[0]
stack = (emu->p_regs[0].tag)?8:0;
for(int i=0; i<8; ++i)
memcpy((i<stack)?&ST(i):&emu->mmx[i], &state->_st[i], sizeof(mmx87_regs_t));
// copy SSE regs
fpu_fxrstor(emu, &state->ControlWord);
}
typedef struct i386_fpstate *i386_fpregset_t;
@@ -265,9 +280,7 @@ static void sigstack_key_alloc() {
pthread_key_create(&sigstack_key, sigstack_destroy);
}
//1<<8 is mutex_dyndump
#define is_dyndump_locked (1<<8)
uint32_t RunFunctionHandler(int* exit, int dynarec, i386_ucontext_t* sigcontext, uintptr_t fnc, int nargs, ...)
uint32_t RunFunctionHandler(int* exit, i386_ucontext_t* sigcontext, uintptr_t fnc, int nargs, ...)
{
if(fnc==0 || fnc==1) {
printf_log(LOG_NONE, "BOX86: Warning, calling Signal function handler %s with %d args \n", fnc?"SIG_DFL":"SIG_IGN", nargs);
@@ -300,10 +313,7 @@ uint32_t RunFunctionHandler(int* exit, int dynarec, i386_ucontext_t* sigcontext,
int oldquitonlongjmp = emu->quitonlongjmp;
emu->quitonlongjmp = 2;
if(dynarec)
DynaCall(emu, fnc);
else
EmuCall(emu, fnc);
EmuCall(emu, fnc); // avoid DynaCall for now
uint32_t ret = R_EAX;
emu->quitonlongjmp = oldquitonlongjmp;
@@ -356,7 +366,7 @@ EXPORT int my_sigaltstack(x86emu_t* emu, const i386_stack_t* ss, i386_stack_t* o
return -1;
}
i386_stack_t *new_ss = (i386_stack_t*)pthread_getspecific(sigstack_key);
if(oss) {
if(!ss) {
if(!new_ss) {
oss->ss_flags = SS_DISABLE;
oss->ss_sp = emu->init_stack;
@@ -366,8 +376,6 @@ EXPORT int my_sigaltstack(x86emu_t* emu, const i386_stack_t* ss, i386_stack_t* o
oss->ss_sp = new_ss->ss_sp;
oss->ss_size = new_ss->ss_size;
}
}
if(!ss) {
return 0;
}
printf_log(LOG_DEBUG, "%04d|sigaltstack called ss=%p[flags=0x%x, sp=%p, ss=0x%x], oss=%p\n", GetTID(), ss, ss->ss_flags, ss->ss_sp, ss->ss_size, oss);
@@ -383,9 +391,19 @@ EXPORT int my_sigaltstack(x86emu_t* emu, const i386_stack_t* ss, i386_stack_t* o
return 0;
}
if(oss) {
if(!new_ss) {
oss->ss_flags = SS_DISABLE;
oss->ss_sp = emu->init_stack;
oss->ss_size = emu->size_stack;
} else {
oss->ss_flags = new_ss->ss_flags;
oss->ss_sp = new_ss->ss_sp;
oss->ss_size = new_ss->ss_size;
}
}
if(!new_ss)
new_ss = (i386_stack_t*)box_calloc(1, sizeof(i386_stack_t));
new_ss->ss_flags = 0;
new_ss->ss_sp = ss->ss_sp;
new_ss->ss_size = ss->ss_size;
@@ -479,8 +497,6 @@ void my_sigactionhandler_oldcode(int32_t sig, int simple, int Locks, siginfo_t*
if(db) {
frame = (uintptr_t*)p->uc_mcontext.arm_r8;
}
#else
(void)ucntx; (void)cur_db;
#endif
// stack tracking
i386_stack_t *new_ss = my_context->onstack[sig]?(i386_stack_t*)pthread_getspecific(sigstack_key):NULL;
@@ -555,8 +571,7 @@ void my_sigactionhandler_oldcode(int32_t sig, int simple, int Locks, siginfo_t*
sigcontext->uc_stack.ss_sp = new_ss->ss_sp;
sigcontext->uc_stack.ss_size = new_ss->ss_size;
sigcontext->uc_stack.ss_flags = new_ss->ss_flags;
} else
sigcontext->uc_stack.ss_flags = SS_DISABLE;
}
// Try to guess some REG_TRAPNO
/*
TRAP_x86_DIVIDE = 0, // Division by zero exception
@@ -599,13 +614,8 @@ void my_sigactionhandler_oldcode(int32_t sig, int simple, int Locks, siginfo_t*
}
if(info->si_code == SEGV_ACCERR && old_code)
*old_code = -1;
} else if(sig==SIGFPE) {
if (info->si_code == FPE_INTOVF) {
sigcontext->uc_mcontext.gregs[REG_TRAPNO] = 4;
} else {
sigcontext->uc_mcontext.gregs[REG_TRAPNO] = 19;
}
}
} else if(sig==SIGFPE)
sigcontext->uc_mcontext.gregs[REG_TRAPNO] = 19;
else if(sig==SIGILL)
sigcontext->uc_mcontext.gregs[REG_TRAPNO] = 6;
// call the signal handler
@@ -623,18 +633,11 @@ void my_sigactionhandler_oldcode(int32_t sig, int simple, int Locks, siginfo_t*
int exits = 0;
int ret;
int dynarec = 0;
#ifdef DYNAREC
if(sig!=SIGSEGV && !(Locks&is_dyndump_locked))
dynarec = 1;
#endif
if(simple)
ret = RunFunctionHandler(&exits, dynarec, sigcontext, my_context->signals[sig], 1, sig);
ret = RunFunctionHandler(&exits, sigcontext, my_context->signals[sig], 1, sig);
else
ret = RunFunctionHandler(&exits, dynarec, sigcontext, my_context->signals[sig], 3, sig, info2, sigcontext);
ret = RunFunctionHandler(&exits, sigcontext, my_context->signals[sig], 3, sig, info2, sigcontext);
// restore old value from emu
if(used_stack) // release stack
new_ss->ss_flags = 0;
#define GO(R) R_##R = old_##R
GO(EAX);
GO(ECX);
@@ -674,10 +677,6 @@ void my_sigactionhandler_oldcode(int32_t sig, int simple, int Locks, siginfo_t*
if(used_stack) // release stack
new_ss->ss_flags = 0;
//relockMutex(Locks); // do not relock mutex, because of the siglongjmp, whatever was running is canceled
#ifdef DYNAREC
if(Locks & is_dyndump_locked)
CancelBlock();
#endif
siglongjmp(ejb->jmpbuf, 1);
}
printf_log(LOG_INFO, "Warning, context has been changed in Sigactionhanlder%s\n", (sigcontext->uc_mcontext.gregs[REG_EIP]!=sigmcontext_copy.gregs[REG_EIP])?" (EIP changed)":"");
@@ -706,18 +705,16 @@ void my_sigactionhandler_oldcode(int32_t sig, int simple, int Locks, siginfo_t*
printf_log(LOG_DEBUG, "Sigactionhanlder main function returned (exit=%d, restorer=%p)\n", exits, (void*)restorer);
if(exits) {
//relockMutex(Locks); // the thread will exit, so no relock there
#ifdef DYNAREC
if(Locks & is_dyndump_locked)
CancelBlock();
#endif
exit(ret);
}
if(restorer)
RunFunctionHandler(&exits, 0, NULL, restorer, 0);
RunFunctionHandler(&exits, NULL, restorer, 0);
if(used_stack) // release stack
new_ss->ss_flags = 0;
relockMutex(Locks);
}
extern void* current_helper;
extern __thread void* current_helper;
void my_box86signalhandler(int32_t sig, siginfo_t* info, void * ucntx)
{
@@ -739,30 +736,19 @@ void my_box86signalhandler(int32_t sig, siginfo_t* info, void * ucntx)
#endif
int Locks = unlockMutex();
uint32_t prot = getProtection((uintptr_t)addr);
#ifdef BAD_SIGNAL
// try to see if the si_code makes sense
// the RK3588 tend to need a special Kernel that seems to have a weird behaviour sometimes
if((sig==SIGSEGV) && (addr) && (info->si_code == 1) && prot&(PROT_READ|PROT_WRITE|PROT_EXEC)) {
printf_log(LOG_DEBUG, "Workaround for suspicious si_code for %p / prot=0x%x\n", addr, prot);
info->si_code = 2;
}
#endif
#ifdef DYNAREC
if((Locks & is_dyndump_locked) && (sig==SIGSEGV) && current_helper) {
if((Locks & (1<<8)) && (sig==SIGSEGV) && current_helper) { //1<<8 is mutex_dyndump
relockMutex(Locks);
CancelBlock();
cancelFillBlock(); // Segfault inside a Fillblock
}
dynablock_t* db = NULL;
int db_searched = 0;
if ((sig==SIGSEGV) && (addr) && (info->si_code == SEGV_ACCERR) && (prot&PROT_CUSTOM)) {
// access error, unprotect the block (and mark them dirty)
unprotectDB((uintptr_t)addr, 1, 1); // unprotect 1 byte... But then, the whole page will be unprotected
// check if SMC inside block
db = FindDynablockFromNativeAddress(pc);
db_searched = 1;
dynarec_log(LOG_INFO/*LOG_DEBUG*/, "SIGSEGV with Access error on %p for %p , db=%p(%p)\n", pc, addr, db, db?((void*)db->x86_addr):NULL);
static uintptr_t repeated_page = 0;
dynarec_log(LOG_DEBUG, "SIGSEGV with Access error on %p for %p , db=%p(%p), prot=0x%x (old page=%p)\n", pc, addr, db, db?((void*)db->x86_addr):NULL, prot, (void*)repeated_page);
static int repeated_count = 0;
if(repeated_page == ((uintptr_t)addr&~0xfff)) {
++repeated_count; // Access eoor multiple time on same page, disable dynarec on this page a few time...
@@ -772,6 +758,8 @@ void my_box86signalhandler(int32_t sig, siginfo_t* info, void * ucntx)
repeated_page = (uintptr_t)addr&~0xfff;
repeated_count = 0;
}
// access error, unprotect the block (and mark them dirty)
unprotectDB((uintptr_t)addr, 1, 1); // unprotect 1 byte... But then, the whole page will be unprotected
if(db && ((addr>=db->x86_addr && addr<(db->x86_addr+db->x86_size)) || db->need_test)) {
// dynablock got auto-dirty! need to get out of it!!!
emu_jmpbuf_t* ejb = GetJmpBuf();
@@ -799,10 +787,6 @@ void my_box86signalhandler(int32_t sig, siginfo_t* info, void * ucntx)
dynarec_log(LOG_INFO, "Dynablock %p(%p) unprotected, getting out (arm pc=%p, x86_pc=%p, special=%d)!\n", db, db->x86_addr, pc, (void*)ejb->emu->ip.dword[0], special);
}
//relockMutex(Locks); // do not relock because of he siglongjmp
#ifdef DYNAREC
if(Locks & is_dyndump_locked)
CancelBlock();
#endif
siglongjmp(ejb->jmpbuf, 2);
}
dynarec_log(LOG_INFO, "Warning, Auto-SMC (%p for db %p/%p) detected, but jmpbuffer not ready!\n", (void*)addr, db, (void*)db->x86_addr);
@@ -830,7 +814,6 @@ void my_box86signalhandler(int32_t sig, siginfo_t* info, void * ucntx)
glitch_addr = addr;
glitch_prot = prot;
relockMutex(Locks);
sched_yield(); // give time to the other process
return; // try again
}
glitch_pc = NULL;
@@ -838,24 +821,21 @@ void my_box86signalhandler(int32_t sig, siginfo_t* info, void * ucntx)
glitch_prot = 0;
}
if(addr && pc && ((prot&(PROT_READ|PROT_WRITE))==(PROT_READ|PROT_WRITE))) {
static void* glitch2_pc = NULL;
static void* glitch2_addr = NULL;
static int glitch2_prot = 0;
if((glitch2_pc!=pc || glitch2_addr!=addr || glitch2_prot!=prot)) {
static void* glitch_pc = NULL;
static void* glitch_addr = NULL;
static int glitch_prot = 0;
if((glitch_pc!=pc || glitch_addr!=addr || glitch_prot!=prot)) {
dynarec_log(LOG_INFO, "Is that a multi process glitch too?\n");
//printf_log(LOG_INFO, "Is that a multi process glitch too?\n");
glitch2_pc = pc;
glitch2_addr = addr;
glitch2_prot = prot;
sched_yield(); // give time to the other process
glitch_pc = pc;
glitch_addr = addr;
glitch_prot = prot;
forceProtection((uintptr_t)addr, 1, prot); // force the protection
relockMutex(Locks);
sched_yield(); // give time to the other process
return; // try again
}
glitch2_pc = NULL;
glitch2_addr = NULL;
glitch2_prot = 0;
glitch_pc = NULL;
glitch_addr = NULL;
glitch_prot = 0;
}
}
#else
@@ -917,7 +897,13 @@ exit(-1);
}
}
if(cycle_log) {
print_cycle_log(log_minimum);
int j = (my_context->current_line+1)&(CYCLE_LOG-1);
for (int i=0; i<CYCLE_LOG; ++i) {
int k = (i+j)&(CYCLE_LOG-1);
if(my_context->log_call[k][0]) {
printf_log(log_minimum, "%s => return %s\n", my_context->log_call[k], my_context->log_ret[k]);
}
}
}
#ifdef DYNAREC
uint32_t hash = 0;
@@ -957,7 +943,7 @@ exit(-1);
else
printf_log(log_minimum, "\n");
#ifndef ANDROID
if(box86_showbt && (log_minimum<=box86_log)) {
if(box86_backtrace && (log_minimum<=box86_log)) {
int nptrs;
void *buffer[200];
char **strings;
@@ -1293,7 +1279,6 @@ EXPORT int my_setcontext(x86emu_t* emu, void* ucp)
EXPORT int my_makecontext(x86emu_t* emu, void* ucp, void* fnc, int32_t argc, int32_t* argv)
{
(void)emu;
// printf_log(LOG_NONE, "Warning: call to unimplemented makecontext\n");
i386_ucontext_t *u = (i386_ucontext_t*)ucp;
// setup stack
+42 -75
View File
@@ -85,50 +85,50 @@ void CleanStackSize(box86context_t* context)
threadstack_t *ts;
if(!context || !context->stacksizes)
return;
mutex_lock(&context->mutex_thread);
pthread_mutex_lock(&context->mutex_thread);
kh_foreach_value(context->stacksizes, ts, box_free(ts));
kh_destroy(threadstack, context->stacksizes);
context->stacksizes = NULL;
mutex_unlock(&context->mutex_thread);
pthread_mutex_unlock(&context->mutex_thread);
}
void FreeStackSize(kh_threadstack_t* map, uintptr_t attr)
{
mutex_lock(&my_context->mutex_thread);
pthread_mutex_lock(&my_context->mutex_thread);
khint_t k = kh_get(threadstack, map, attr);
if(k!=kh_end(map)) {
box_free(kh_value(map, k));
kh_del(threadstack, map, k);
}
mutex_unlock(&my_context->mutex_thread);
pthread_mutex_unlock(&my_context->mutex_thread);
}
void AddStackSize(kh_threadstack_t* map, uintptr_t attr, void* stack, size_t stacksize)
{
khint_t k;
int ret;
mutex_lock(&my_context->mutex_thread);
pthread_mutex_lock(&my_context->mutex_thread);
k = kh_put(threadstack, map, attr, &ret);
threadstack_t* ts = kh_value(map, k) = (threadstack_t*)box_calloc(1, sizeof(threadstack_t));
ts->stack = stack;
ts->stacksize = stacksize;
mutex_unlock(&my_context->mutex_thread);
pthread_mutex_unlock(&my_context->mutex_thread);
}
// return stack from attr (or from current emu if attr is not found..., wich is wrong but approximate enough?)
int GetStackSize(x86emu_t* emu, uintptr_t attr, void** stack, size_t* stacksize)
{
if(emu->context->stacksizes && attr) {
mutex_lock(&my_context->mutex_thread);
pthread_mutex_lock(&my_context->mutex_thread);
khint_t k = kh_get(threadstack, emu->context->stacksizes, attr);
if(k!=kh_end(emu->context->stacksizes)) {
threadstack_t* ts = kh_value(emu->context->stacksizes, k);
*stack = ts->stack;
*stacksize = ts->stacksize;
mutex_unlock(&my_context->mutex_thread);
pthread_mutex_unlock(&my_context->mutex_thread);
return 1;
}
mutex_unlock(&my_context->mutex_thread);
pthread_mutex_unlock(&my_context->mutex_thread);
}
// should a Warning be emited?
*stack = emu->init_stack;
@@ -183,9 +183,16 @@ static void emuthread_destroy(void* p)
}
static pthread_key_t thread_key;
static pthread_once_t thread_key_once = PTHREAD_ONCE_INIT;
static void thread_key_alloc() {
pthread_key_create(&thread_key, emuthread_destroy);
}
void thread_set_emu(x86emu_t* emu)
{
// create the key
pthread_once(&thread_key_once, thread_key_alloc);
emuthread_t *et = (emuthread_t*)pthread_getspecific(thread_key);
if(!et) {
et = (emuthread_t*)box_calloc(1, sizeof(emuthread_t));
@@ -200,6 +207,8 @@ void thread_set_emu(x86emu_t* emu)
x86emu_t* thread_get_emu()
{
// create the key
pthread_once(&thread_key_once, thread_key_alloc);
emuthread_t *et = (emuthread_t*)pthread_getspecific(thread_key);
if(!et) {
int stacksize = 2*1024*1024;
@@ -224,6 +233,8 @@ x86emu_t* thread_get_emu()
static void* pthread_routine(void* p)
{
// create the key
pthread_once(&thread_key_once, thread_key_alloc);
// free current emuthread if it exist
{
void* t = pthread_getspecific(thread_key);
@@ -311,8 +322,7 @@ EXPORT int my_pthread_create(x86emu_t *emu, void* t, void* attr, void* start_rou
#ifdef DYNAREC
if(box86_dynarec) {
// pre-creation of the JIT code for the entry point of the thread
dynablock_t *current = NULL;
DBGetBlock(emu, (uintptr_t)start_routine, 1, &current);
DBGetBlock(emu, (uintptr_t)start_routine, 1);
}
#endif
// create thread
@@ -335,8 +345,7 @@ void* my_prepare_thread(x86emu_t *emu, void* f, void* arg, int ssize, void** pet
#ifdef DYNAREC
if(box86_dynarec) {
// pre-creation of the JIT code for the entry point of the thread
dynablock_t *current = NULL;
DBGetBlock(emu, (uintptr_t)f, 1, &current);
DBGetBlock(emu, (uintptr_t)f, 1);
}
#endif
*pet = et;
@@ -350,9 +359,8 @@ void my_longjmp(x86emu_t* emu, /*struct __jmp_buf_tag __env[1]*/void *p, int32_t
static __thread x86emu_t* cancel_emu[CANCEL_MAX] = {0};
static __thread x86_unwind_buff_t* cancel_buff[CANCEL_MAX] = {0};
static __thread int cancel_deep = 0;
EXPORT void my___pthread_register_cancel(x86emu_t* emu, void* B)
EXPORT void my___pthread_register_cancel(void* E, void* B)
{
(void)B;
// get a stack local copy of the args, as may be live in some register depending the architecture (like ARM)
if(cancel_deep<0) {
printf_log(LOG_NONE/*LOG_INFO*/, "BOX86: Warning, inconsistant value in __pthread_register_cancel (%d)\n", cancel_deep);
@@ -363,14 +371,14 @@ EXPORT void my___pthread_register_cancel(x86emu_t* emu, void* B)
else
{printf_log(LOG_NONE/*LOG_INFO*/, "BOX86: Warning, calling __pthread_register_cancel(...) too many time\n");}
cancel_emu[cancel_deep] = emu;
cancel_emu[cancel_deep] = (x86emu_t*)E;
// on i386, the function as __cleanup_fct_attribute attribute: so 1st parameter is in register
x86_unwind_buff_t* buff = cancel_buff[cancel_deep] = (x86_unwind_buff_t*)R_EAX;
x86_unwind_buff_t* buff = cancel_buff[cancel_deep] = (x86_unwind_buff_t*)((x86emu_t*)E)->regs[_AX].dword[0];
__pthread_unwind_buf_t * pbuff = AddCancelThread(buff);
if(__sigsetjmp((struct __jmp_buf_tag*)(void*)pbuff->__cancel_jmp_buf, 0)) {
//DelCancelThread(cancel_buff); // no del here, it will be delete by unwind_next...
int i = cancel_deep--;
emu = cancel_emu[i];
x86emu_t* emu = cancel_emu[i];
my_longjmp(emu, cancel_buff[i]->__cancel_jmp_buf, 1);
DynaRun(emu); // resume execution
return;
@@ -392,7 +400,6 @@ EXPORT void my___pthread_unregister_cancel(x86emu_t* emu, x86_unwind_buff_t* buf
EXPORT void my___pthread_unwind_next(x86emu_t* emu, void* p)
{
(void)p;
// on i386, the function as __cleanup_fct_attribute attribute: so 1st parameter is in register
x86_unwind_buff_t* buff = (x86_unwind_buff_t*)R_EAX;
__pthread_unwind_buf_t pbuff = *GetCancelThread(buff);
@@ -487,6 +494,7 @@ static void* findcleanup_routineFct(void* fct)
// custom implementation of pthread_once...
static __thread uintptr_t my_once_callback_fct = 0;
int EXPORT my_pthread_once(x86emu_t* emu, int* once, void* cb)
{
#ifdef DYNAREC
@@ -504,14 +512,13 @@ int EXPORT my_pthread_once(x86emu_t* emu, int* once, void* cb)
#endif
if(old)
return 0;
DynaCall(emu, (uintptr_t)cb); // using DynaCall now, speedup wine 7.21 (proabbly other too) init
EmuCall(emu, (uintptr_t)cb); // avoid DynaCall for now, functions are only used once after all
return 0;
}
EXPORT int my___pthread_once(x86emu_t* emu, void* once, void* cb) __attribute__((alias("my_pthread_once")));
EXPORT int my_pthread_key_create(x86emu_t* emu, void* key, void* dtor)
{
(void)emu;
return pthread_key_create(key, findkey_destructorFct(dtor));
}
EXPORT int my___pthread_key_create(x86emu_t* emu, void* key, void* dtor) __attribute__((alias("my_pthread_key_create")));
@@ -528,7 +535,7 @@ kh_mapcond_t *mapcond = NULL;
static pthread_cond_t* add_cond(void* cond)
{
mutex_lock(&my_context->mutex_thread);
pthread_mutex_lock(&my_context->mutex_thread);
khint_t k;
int ret;
pthread_cond_t *c;
@@ -538,14 +545,14 @@ static pthread_cond_t* add_cond(void* cond)
else
c = kh_value(mapcond, k) = (pthread_cond_t*)box_calloc(1, sizeof(pthread_cond_t));
*(void**)cond = cond;
mutex_unlock(&my_context->mutex_thread);
pthread_mutex_unlock(&my_context->mutex_thread);
return c;
}
static pthread_cond_t* get_cond(void* cond)
{
pthread_cond_t* ret;
int r;
mutex_lock(&my_context->mutex_thread);
pthread_mutex_lock(&my_context->mutex_thread);
khint_t k = kh_get(mapcond, mapcond, *(uintptr_t*)cond);
if(k==kh_end(mapcond)) {
khint_t k = kh_get(mapcond, mapcond, (uintptr_t)cond);
@@ -560,32 +567,30 @@ static pthread_cond_t* get_cond(void* cond)
ret = kh_value(mapcond, k);
} else
ret = kh_value(mapcond, k);
mutex_unlock(&my_context->mutex_thread);
pthread_mutex_unlock(&my_context->mutex_thread);
return ret;
}
static void del_cond(void* cond)
{
if(!mapcond)
return;
mutex_lock(&my_context->mutex_thread);
pthread_mutex_lock(&my_context->mutex_thread);
khint_t k = kh_get(mapcond, mapcond, *(uintptr_t*)cond);
if(k!=kh_end(mapcond)) {
box_free(kh_value(mapcond, k));
kh_del(mapcond, mapcond, k);
}
mutex_unlock(&my_context->mutex_thread);
pthread_mutex_unlock(&my_context->mutex_thread);
}
pthread_mutex_t* getAlignedMutex(pthread_mutex_t* m);
EXPORT int my_pthread_cond_broadcast_old(x86emu_t* emu, void* cond)
{
(void)emu;
pthread_cond_t * c = get_cond(cond);
return pthread_cond_broadcast(c);
}
EXPORT int my_pthread_cond_destroy_old(x86emu_t* emu, void* cond)
{
(void)emu;
pthread_cond_t * c = get_cond(cond);
int ret = pthread_cond_destroy(c);
if(c!=cond) del_cond(cond);
@@ -593,50 +598,42 @@ EXPORT int my_pthread_cond_destroy_old(x86emu_t* emu, void* cond)
}
EXPORT int my_pthread_cond_init_old(x86emu_t* emu, void* cond, void* attr)
{
(void)emu;
pthread_cond_t *c = add_cond(cond);
return pthread_cond_init(c, (const pthread_condattr_t*)attr);
}
EXPORT int my_pthread_cond_signal_old(x86emu_t* emu, void* cond)
{
(void)emu;
pthread_cond_t * c = get_cond(cond);
return pthread_cond_signal(c);
}
EXPORT int my_pthread_cond_timedwait_old(x86emu_t* emu, void* cond, void* mutex, void* abstime)
{
(void)emu;
pthread_cond_t * c = get_cond(cond);
return pthread_cond_timedwait(c, getAlignedMutex((pthread_mutex_t*)mutex), (const struct timespec*)abstime);
}
EXPORT int my_pthread_cond_wait_old(x86emu_t* emu, void* cond, void* mutex)
{
(void)emu;
pthread_cond_t * c = get_cond(cond);
return pthread_cond_wait(c, getAlignedMutex((pthread_mutex_t*)mutex));
}
EXPORT int my_pthread_cond_timedwait(x86emu_t* emu, void* cond, void* mutex, void* abstime)
{
(void)emu;
return pthread_cond_timedwait((pthread_cond_t*)cond, getAlignedMutex((pthread_mutex_t*)mutex), (const struct timespec*)abstime);
}
EXPORT int my_pthread_cond_wait(x86emu_t* emu, void* cond, void* mutex)
{
(void)emu;
return pthread_cond_wait((pthread_cond_t*)cond, getAlignedMutex((pthread_mutex_t*)mutex));
}
EXPORT int my_pthread_mutexattr_setkind_np(x86emu_t* emu, void* t, int kind)
{
(void)emu;
// does "kind" needs some type of translation?
return pthread_mutexattr_settype(t, kind);
}
EXPORT int my_pthread_attr_setscope(x86emu_t* emu, void* attr, int scope)
{
(void)emu;
if(scope!=PTHREAD_SCOPE_SYSTEM) printf_log(LOG_INFO, "Warning, scope of call to pthread_attr_setscope(...) changed from %d to PTHREAD_SCOPE_SYSTEM\n", scope);
return pthread_attr_setscope(attr, PTHREAD_SCOPE_SYSTEM);
//The scope is either PTHREAD_SCOPE_SYSTEM or PTHREAD_SCOPE_PROCESS
@@ -646,32 +643,27 @@ EXPORT int my_pthread_attr_setscope(x86emu_t* emu, void* attr, int scope)
#ifndef ANDROID
EXPORT void my__pthread_cleanup_push_defer(x86emu_t* emu, void* buffer, void* routine, void* arg)
{
(void)emu;
real_pthread_cleanup_push_defer(buffer, findcleanup_routineFct(routine), arg);
}
EXPORT void my__pthread_cleanup_push(x86emu_t* emu, void* buffer, void* routine, void* arg)
{
(void)emu;
_pthread_cleanup_push(buffer, findcleanup_routineFct(routine), arg);
}
EXPORT void my__pthread_cleanup_pop_restore(x86emu_t* emu, void* buffer, int exec)
{
(void)emu;
real_pthread_cleanup_pop_restore(buffer, exec);
}
EXPORT void my__pthread_cleanup_pop(x86emu_t* emu, void* buffer, int exec)
{
(void)emu;
_pthread_cleanup_pop(buffer, exec);
}
// getaffinity_np (pthread or attr) hav an "old" version (glibc-2.3.3) that only have 2 args, cpusetsize is omited
EXPORT int my_pthread_getaffinity_np(x86emu_t* emu, pthread_t thread, int cpusetsize, void* cpuset)
{
(void)emu;
if(cpusetsize>0x1000) {
// probably old version of the function, that didn't have cpusetsize....
cpuset = (void*)cpusetsize;
@@ -688,7 +680,6 @@ EXPORT int my_pthread_getaffinity_np(x86emu_t* emu, pthread_t thread, int cpuset
EXPORT int my_pthread_setaffinity_np(x86emu_t* emu, pthread_t thread, int cpusetsize, void* cpuset)
{
(void)emu;
if(cpusetsize>0x1000) {
// probably old version of the function, that didn't have cpusetsize....
cpuset = (void*)cpusetsize;
@@ -705,7 +696,6 @@ EXPORT int my_pthread_setaffinity_np(x86emu_t* emu, pthread_t thread, int cpuset
EXPORT int my_pthread_attr_setaffinity_np(x86emu_t* emu, void* attr, uint32_t cpusetsize, void* cpuset)
{
(void)emu;
if(cpusetsize>0x1000) {
// probably old version of the function, that didn't have cpusetsize....
cpuset = (void*)cpusetsize;
@@ -723,7 +713,6 @@ EXPORT int my_pthread_attr_setaffinity_np(x86emu_t* emu, void* attr, uint32_t cp
EXPORT int my_pthread_kill(x86emu_t* emu, void* thread, int sig)
{
(void)emu;
// should ESCHR result be filtered, as this is expected to be the 2.34 behaviour?
// check for old "is everything ok?"
if((thread==NULL) && (sig==0))
@@ -733,7 +722,6 @@ EXPORT int my_pthread_kill(x86emu_t* emu, void* thread, int sig)
EXPORT int my_pthread_kill_old(x86emu_t* emu, void* thread, int sig)
{
(void)emu;
// check for old "is everything ok?"
if(!thread)
thread = (void*)pthread_self();
@@ -742,7 +730,6 @@ EXPORT int my_pthread_kill_old(x86emu_t* emu, void* thread, int sig)
EXPORT int my_pthread_join(x86emu_t* emu, void* thread, void** ret)
{
(void)emu;
if(!thread)
return ESRCH;
return pthread_join((pthread_t)thread, ret);
@@ -750,7 +737,6 @@ EXPORT int my_pthread_join(x86emu_t* emu, void* thread, void** ret)
//EXPORT void my_pthread_exit(x86emu_t* emu, void* retval)
//{
// (void)emu;
// emu->quit = 1; // to be safe
// pthread_exit(retval);
//}
@@ -802,11 +788,7 @@ typedef struct mutexes_block_s {
} mutexes_block_t;
static mutexes_block_t *mutexes = NULL;
#ifndef DYNAREC
static pthread_mutex_t mutex_mutexes = PTHREAD_MUTEX_INITIALIZER;
#else
static uint32_t mutex_mutexes = 0;
#endif
static mutexes_block_t* NewMutexesBlock()
{
@@ -816,7 +798,7 @@ static mutexes_block_t* NewMutexesBlock()
}
static int NewMutex() {
mutex_lock(&mutex_mutexes);
pthread_mutex_lock(&mutex_mutexes);
if(!mutexes) {
mutexes = NewMutexesBlock();
}
@@ -833,10 +815,10 @@ static int NewMutex() {
for (int i=0; i<MUTEXES_SIZE; ++i)
if(!m->taken[i]) {
m->taken[i] = 1;
mutex_unlock(&mutex_mutexes);
pthread_mutex_unlock(&mutex_mutexes);
return j*MUTEXES_SIZE + i;
}
mutex_unlock(&mutex_mutexes);
pthread_mutex_unlock(&mutex_mutexes);
printf_log(LOG_NONE, "Error: NewMutex unreachable part reached\n");
return (int)-1; // error!!!!
}
@@ -845,13 +827,13 @@ void FreeMutex(int k)
{
if(!mutexes)
return; //???
mutex_lock(&mutex_mutexes);
pthread_mutex_lock(&mutex_mutexes);
mutexes_block_t* m = mutexes;
for(int i=0; i<k/MUTEXES_SIZE; ++i)
m = m->next;
m->taken[k%MUTEXES_SIZE] = 0;
++m->n_free;
mutex_unlock(&mutex_mutexes);
pthread_mutex_unlock(&mutex_mutexes);
}
void FreeAllMutexes(mutexes_block_t* m)
@@ -1012,9 +994,6 @@ void init_pthread_helper()
InitCancelThread();
mapcond = kh_init(mapcond);
pthread_key_create(&jmpbuf_key, emujmpbuf_destroy);
pthread_setspecific(jmpbuf_key, NULL);
pthread_key_create(&thread_key, emuthread_destroy);
pthread_setspecific(thread_key, NULL);
#if !defined(NOALIGN) && defined(ANDROID)
unaligned_mutex = kh_init(mutex);
#endif
@@ -1045,16 +1024,16 @@ void fini_pthread_helper(box86context_t* context)
#endif
emu_jmpbuf_t *ejb = (emu_jmpbuf_t*)pthread_getspecific(jmpbuf_key);
if(ejb) {
pthread_setspecific(jmpbuf_key, NULL);
emujmpbuf_destroy(ejb);
pthread_setspecific(jmpbuf_key, NULL);
}
emuthread_t *et = (emuthread_t*)pthread_getspecific(thread_key);
if(et) {
pthread_setspecific(thread_key, NULL);
emuthread_destroy(et);
pthread_setspecific(thread_key, NULL);
}
}
#ifndef DYNAREC
int checkUnlockMutex(void* m)
{
pthread_mutex_t* mutex = (pthread_mutex_t*)m;
@@ -1064,15 +1043,3 @@ int checkUnlockMutex(void* m)
}
return 0;
}
int checkLockMutex(void* m)
{
pthread_mutex_t* mutex = (pthread_mutex_t*)m;
int ret = pthread_mutex_unlock(mutex);
if(ret==0) {
pthread_mutex_lock(mutex); // how to check the lock without unlock?
return 1;
}
return 0;
}
#endif
+37 -106
View File
@@ -254,26 +254,25 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000,
VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001,
VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002,
VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR = 1000023000,
VK_STRUCTURE_TYPE_VIDEO_PROFILE_KHR = 1000023000,
VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR = 1000023001,
VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR = 1000023002,
VK_STRUCTURE_TYPE_VIDEO_SESSION_MEMORY_REQUIREMENTS_KHR = 1000023003,
VK_STRUCTURE_TYPE_BIND_VIDEO_SESSION_MEMORY_INFO_KHR = 1000023004,
VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_KHR = 1000023002,
VK_STRUCTURE_TYPE_VIDEO_GET_MEMORY_PROPERTIES_KHR = 1000023003,
VK_STRUCTURE_TYPE_VIDEO_BIND_MEMORY_KHR = 1000023004,
VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR = 1000023005,
VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000023006,
VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_UPDATE_INFO_KHR = 1000023007,
VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR = 1000023008,
VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR = 1000023009,
VK_STRUCTURE_TYPE_VIDEO_CODING_CONTROL_INFO_KHR = 1000023010,
VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR = 1000023011,
VK_STRUCTURE_TYPE_QUEUE_FAMILY_VIDEO_PROPERTIES_KHR = 1000023012,
VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR = 1000023013,
VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_KHR = 1000023011,
VK_STRUCTURE_TYPE_VIDEO_QUEUE_FAMILY_PROPERTIES_2_KHR = 1000023012,
VK_STRUCTURE_TYPE_VIDEO_PROFILES_KHR = 1000023013,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR = 1000023014,
VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR = 1000023015,
VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_KHR = 1000023016,
VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_2_KHR = 1000023016,
VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR = 1000024000,
VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR = 1000024001,
VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR = 1000024002,
VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000,
VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001,
VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002,
@@ -290,26 +289,27 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_ADD_INFO_EXT = 1000038002,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_VCL_FRAME_INFO_EXT = 1000038003,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_DPB_SLOT_INFO_EXT = 1000038004,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_NALU_SLICE_INFO_EXT = 1000038005,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_EMIT_PICTURE_PARAMETERS_INFO_EXT = 1000038006,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_INFO_EXT = 1000038007,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_NALU_SLICE_EXT = 1000038005,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_EMIT_PICTURE_PARAMETERS_EXT = 1000038006,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_EXT = 1000038007,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_INFO_EXT = 1000038008,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_EXT = 1000038009,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_REFERENCE_LISTS_INFO_EXT = 1000038010,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_REFERENCE_LISTS_EXT = 1000038010,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_CAPABILITIES_EXT = 1000039000,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000039001,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_ADD_INFO_EXT = 1000039002,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_VCL_FRAME_INFO_EXT = 1000039003,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_DPB_SLOT_INFO_EXT = 1000039004,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_INFO_EXT = 1000039005,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_EMIT_PICTURE_PARAMETERS_INFO_EXT = 1000039006,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PROFILE_INFO_EXT = 1000039007,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_REFERENCE_LISTS_INFO_EXT = 1000039008,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_EXT = 1000039005,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_EMIT_PICTURE_PARAMETERS_EXT = 1000039006,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PROFILE_EXT = 1000039007,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_REFERENCE_LISTS_EXT = 1000039008,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_INFO_EXT = 1000039009,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_LAYER_INFO_EXT = 1000039010,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_EXT = 1000040000,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_EXT = 1000040001,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_EXT = 1000040003,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_MVC_EXT = 1000040002,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_EXT = 1000040003,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000040004,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_ADD_INFO_EXT = 1000040005,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_DPB_SLOT_INFO_EXT = 1000040006,
@@ -474,7 +474,7 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_EXT = 1000187000,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000187001,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_EXT = 1000187002,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_EXT = 1000187003,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_EXT = 1000187003,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_EXT = 1000187004,
VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_EXT = 1000187005,
VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR = 1000174000,
@@ -575,16 +575,12 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT = 1000287001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT = 1000287002,
VK_STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR = 1000290000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_BARRIER_FEATURES_NV = 1000292000,
VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_BARRIER_NV = 1000292001,
VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_BARRIER_CREATE_INFO_NV = 1000292002,
VK_STRUCTURE_TYPE_PRESENT_ID_KHR = 1000294000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR = 1000294001,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_INFO_KHR = 1000299000,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_RATE_CONTROL_INFO_KHR = 1000299001,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_RATE_CONTROL_LAYER_INFO_KHR = 1000299002,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_CAPABILITIES_KHR = 1000299003,
VK_STRUCTURE_TYPE_VIDEO_ENCODE_USAGE_INFO_KHR = 1000299004,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DIAGNOSTICS_CONFIG_FEATURES_NV = 1000300000,
VK_STRUCTURE_TYPE_DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV = 1000300001,
VK_STRUCTURE_TYPE_EXPORT_METAL_OBJECT_CREATE_INFO_EXT = 1000311000,
@@ -614,8 +610,6 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_MOTION_TRIANGLES_DATA_NV = 1000327000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MOTION_BLUR_FEATURES_NV = 1000327001,
VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MOTION_INFO_NV = 1000327002,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT = 1000328000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_EXT = 1000328001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_2_PLANE_444_FORMATS_FEATURES_EXT = 1000330000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_FEATURES_EXT = 1000332000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_PROPERTIES_EXT = 1000332001,
@@ -628,17 +622,15 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_PROPERTIES_EXT = 1000338004,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT = 1000339000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT = 1000340000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT = 1000341000,
VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT = 1000341001,
VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT = 1000341002,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_ARM = 1000342000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RGBA10X6_FORMATS_FEATURES_EXT = 1000344000,
VK_STRUCTURE_TYPE_DIRECTFB_SURFACE_CREATE_INFO_EXT = 1000346000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_VALVE = 1000351000,
VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE = 1000351002,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_INPUT_DYNAMIC_STATE_FEATURES_EXT = 1000352000,
VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT = 1000352001,
VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT = 1000352002,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT = 1000353000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ADDRESS_BINDING_REPORT_FEATURES_EXT = 1000354000,
VK_STRUCTURE_TYPE_DEVICE_ADDRESS_BINDING_CALLBACK_DATA_EXT = 1000354001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT = 1000355000,
VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT = 1000355001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT = 1000356000,
@@ -679,23 +671,12 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_FEATURES_EXT = 1000392000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_PROPERTIES_EXT = 1000392001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT = 1000393000,
VK_STRUCTURE_TYPE_MICROMAP_BUILD_INFO_EXT = 1000396000,
VK_STRUCTURE_TYPE_MICROMAP_VERSION_INFO_EXT = 1000396001,
VK_STRUCTURE_TYPE_COPY_MICROMAP_INFO_EXT = 1000396002,
VK_STRUCTURE_TYPE_COPY_MICROMAP_TO_MEMORY_INFO_EXT = 1000396003,
VK_STRUCTURE_TYPE_COPY_MEMORY_TO_MICROMAP_INFO_EXT = 1000396004,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPACITY_MICROMAP_FEATURES_EXT = 1000396005,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPACITY_MICROMAP_PROPERTIES_EXT = 1000396006,
VK_STRUCTURE_TYPE_MICROMAP_CREATE_INFO_EXT = 1000396007,
VK_STRUCTURE_TYPE_MICROMAP_BUILD_SIZES_INFO_EXT = 1000396008,
VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_TRIANGLES_OPACITY_MICROMAP_EXT = 1000396009,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT = 1000411000,
VK_STRUCTURE_TYPE_SAMPLER_BORDER_COLOR_COMPONENT_MAPPING_CREATE_INFO_EXT = 1000411001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT = 1000412000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE = 1000420000,
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_BINDING_REFERENCE_VALVE = 1000420001,
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_HOST_MAPPING_INFO_VALVE = 1000420002,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLAMP_ZERO_ONE_FEATURES_EXT = 1000421000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NON_SEAMLESS_CUBE_MAP_FEATURES_EXT = 1000422000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_FEATURES_QCOM = 1000425000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_PROPERTIES_QCOM = 1000425001,
@@ -705,8 +686,6 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_FEATURES_QCOM = 1000440000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_PROPERTIES_QCOM = 1000440001,
VK_STRUCTURE_TYPE_IMAGE_VIEW_SAMPLE_WEIGHT_CREATE_INFO_QCOM = 1000440002,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT = 1000455000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_PROPERTIES_EXT = 1000455001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBPASS_MERGE_FEEDBACK_FEATURES_EXT = 1000458000,
VK_STRUCTURE_TYPE_RENDER_PASS_CREATION_CONTROL_EXT = 1000458001,
VK_STRUCTURE_TYPE_RENDER_PASS_CREATION_FEEDBACK_CREATE_INFO_EXT = 1000458002,
@@ -715,24 +694,10 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_PROPERTIES_EXT = 1000462001,
VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_MODULE_IDENTIFIER_CREATE_INFO_EXT = 1000462002,
VK_STRUCTURE_TYPE_SHADER_MODULE_IDENTIFIER_EXT = 1000462003,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT = 1000342000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV = 1000464000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV = 1000464001,
VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_INFO_NV = 1000464002,
VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_PROPERTIES_NV = 1000464003,
VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_INFO_NV = 1000464004,
VK_STRUCTURE_TYPE_OPTICAL_FLOW_EXECUTE_INFO_NV = 1000464005,
VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_PRIVATE_DATA_INFO_NV = 1000464010,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LEGACY_DITHERING_FEATURES_EXT = 1000465000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_PROTECTED_ACCESS_FEATURES_EXT = 1000466000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TILE_PROPERTIES_FEATURES_QCOM = 1000484000,
VK_STRUCTURE_TYPE_TILE_PROPERTIES_QCOM = 1000484001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_AMIGO_PROFILING_FEATURES_SEC = 1000485000,
VK_STRUCTURE_TYPE_AMIGO_PROFILING_SUBMIT_INFO_SEC = 1000485001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT = 1000351000,
VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT = 1000351002,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_FEATURES_ARM = 1000497000,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_PROPERTIES_ARM = 1000497001,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES,
VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
@@ -895,9 +860,6 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_IMAGE_BLIT_2_KHR = VK_STRUCTURE_TYPE_IMAGE_BLIT_2,
VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2_KHR = VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2,
VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2_KHR = VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_ARM = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_VALVE = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT,
VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE = VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT,
VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3_KHR = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3,
VK_STRUCTURE_TYPE_PIPELINE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_INFO_KHR,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR,
@@ -929,8 +891,10 @@ typedef struct my_vkhead_s {
case VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO: \
case VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO: \
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO: \
case VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO: \
case VK_STRUCTURE_TYPE_EVENT_CREATE_INFO: \
case VK_STRUCTURE_TYPE_FENCE_CREATE_INFO: \
case VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO: \
case VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO: \
case VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO: \
case VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO: \
@@ -1034,20 +998,6 @@ typedef struct my_vkhead_s {
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_PROPERTIES_EXT: \
case VK_STRUCTURE_TYPE_SHADER_MODULE_IDENTIFIER_EXT: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES: \
case VK_STRUCTURE_TYPE_BUFFER_COPY_2: \
case VK_STRUCTURE_TYPE_OPTICAL_FLOW_EXECUTE_INFO_NV: \
case VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_INFO_NV: \
case VK_STRUCTURE_TYPE_IMAGE_COPY_2: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_FEATURES_EXT: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NON_SEAMLESS_CUBE_MAP_FEATURES_EXT: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_PROPERTIES_EXT: \
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT: \
case VK_STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR: \
#define CH(C, B, A) \
case C: \
@@ -1056,13 +1006,12 @@ typedef struct my_vkhead_s {
break;
#define CHANGE(A) \
CH(VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, "uPuuQupupp", A) \
CH(VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, "uPiUiiup", A) \
CH(VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, "uPiUiUU",A) \
CH(VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,"uPiiiiuuUiuuuu", A) \
CH(VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, "uPiUupuuu", A) \
CH(VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, "uPiuppppppppppUUuUi", A) \
CH(VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, "uPiUiiSiiiiSiuuuu", A) \
CH(VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, "uPiUiiiiiiiuuuu", A) \
CH(VK_STRUCTURE_TYPE_SUBMIT_INFO, "uPuppupup", A) \
CH(VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, "uPUuuuippp", A) \
CH(VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET, "uPUuuUuuu", A) \
@@ -1070,7 +1019,7 @@ typedef struct my_vkhead_s {
CH(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, "uP" \
"uuuuiYB" \
"SuuuuuuuuuuuUUuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuffuuuffuLUUUiuiuffuuuuiiiiuiiiiiuifuuuuffffffiiUUU"\
"iiiii",A) \
"Siiiii",A) \
CH(VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR, "uPipu", A) \
CH(VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, "uPipu", A) \
CH(VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR, "uPUUUUu", A) \
@@ -1089,12 +1038,12 @@ typedef struct my_vkhead_s {
CH(VK_STRUCTURE_TYPE_COPY_BUFFER_INFO_2, "uPUUuQ", A) \
CH(VK_STRUCTURE_TYPE_BLIT_IMAGE_INFO_2, "uPUiUiuQi", A) \
CH(VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2, "uPUiUiuQ", A) \
CH(VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2, "uPUUiuQ", A) \
CH(VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2, "uPUUiuQ", A) \
CH(VK_STRUCTURE_TYPE_COPY_IMAGE_TO_BUFFER_INFO_2, "uPUiUuQ", A) \
CH(VK_STRUCTURE_TYPE_RESOLVE_IMAGE_INFO_2, "uPUiUiuQ", A) \
CH(VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_EXT, "uPU", A) \
CH(VK_STRUCTURE_TYPE_DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO, "uPU", A) \
CH(VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, "uPiuPiiUppUUi", A) \
CH(VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, "uPiSuPiiUppUUi", A) \
CH(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR, "uPUUUuuuuu", A)\
CH(VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, "uPibp", A) \
CH(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT, "uPfffiiiiii", A)\
@@ -1103,20 +1052,6 @@ typedef struct my_vkhead_s {
CH(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES, "uPBBBuiuiiiiuuiuU", A) \
CH(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES, "uPiYYSuiiiiiiiiiiiiiiiiiuiiiiiiiuuuuuuuuuuuuuuuuuiiiiUu", A)\
CH(VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES, "uPuuuuuuuuuuiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiUiUiU", A)\
CH(VK_STRUCTURE_TYPE_RENDERING_INFO, "uPiiiuuuuuPPP", A) \
CH(VK_STRUCTURE_TYPE_DEVICE_BUFFER_MEMORY_REQUIREMENTS, "uPP", A) \
CH(VK_STRUCTURE_TYPE_DEVICE_IMAGE_MEMORY_REQUIREMENTS, "uPPi", A) \
CH(VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, "uPiiiuuuuuiiiiupi", A) \
CH(VK_STRUCTURE_TYPE_DEPENDENCY_INFO, "uPiuQuQuQ", A) \
CH(VK_STRUCTURE_TYPE_MEMORY_BARRIER_2, "uPUUUU", A) \
CH(VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2, "uPUUUUuuUUU", A) \
CH(VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2, "uPUUUUiiuuUSiuuuu", A) \
CH(VK_STRUCTURE_TYPE_SUBMIT_INFO_2, "upiuQuQuQ", A) \
CH(VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO, "uPUUUu", A) \
CH(VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2, "uPUuuSiuuuiiiuuu", A) \
CH(VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO, "uPpu", A) \
CH(VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO, "uPUiiUiiiffff", A) \
CH(VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_PROPERTIES_NV, "uPi", A) \
//--------------------------------------------------------------
@@ -1166,9 +1101,10 @@ static void* reverse_vkDebugReportCallback_Fct(void* fct)
//--------------------------------------------------------------
//--------- TOOLS --------
//--------------------------------------------------------------
/* static int needAlign(my_vkhead_t* x86)
static int needAlign(my_vkhead_t* x86)
{
const char* s;
const char** src = &s;
int dst = 0;
while(x86) {
switch(x86->sType) {
@@ -1182,7 +1118,7 @@ static void* reverse_vkDebugReportCallback_Fct(void* fct)
x86 = x86->pNext;
}
return 0;
} */
}
//--------------------------------------------------------------
//--------- ALIGN x86 -> ARM --------
@@ -1247,16 +1183,14 @@ static my_vkhead_t* alignFromx86(my_vkhead_t* src, uint32_t cnt);
void* vkalignStruct(void* src, const char* desc, int cnt)
{
if(!src)
return src;
int sz = vkalignSize(desc);
int count=cnt;
int count=(cnt)?cnt:1;
void* dst = (void*)box_malloc(sz*count+sizeof(void*)*count);
int c = 0;
int a = 0;
uint32_t* psrc = (uint32_t*)src;
uint32_t* pdst = (uint32_t*)dst;
// uint32_t* sign = (uint32_t*)(dst+sz*count);
uint32_t* sign = (uint32_t*)(dst+sz*count);
void** save = (void**)(dst+sz*count);
uint32_t q;
while(count) {
@@ -1334,7 +1268,6 @@ static my_vkhead_t* alignFromx86(my_vkhead_t* src, uint32_t cnt)
{
if(!src)
return src;
//printf_log(LOG_INFO, "alignFromx86(%p:%d, %d)\n", src, src->sType, cnt);
my_vkhead_t *dst = src;
const char* s;
switch(src->sType) {
@@ -1342,7 +1275,7 @@ static my_vkhead_t* alignFromx86(my_vkhead_t* src, uint32_t cnt)
// no need to align, but follow next...
dst->pNext = alignFromx86(src->pNext, 1);
break;
CHANGE(dst=vkalignStruct(src, s, cnt)) // will follow next
CHANGE(dst=vkalignStruct(src, s, 1)) // will follow next
default:
// unknow
printf_log(LOG_INFO, "BOX86: Warning, unknown Vulkan structure type %d\n", src->sType);
@@ -1365,8 +1298,6 @@ void* VulkanFromx86(void* src)
static void* unalignTox86(my_vkhead_t* src, int cnt);
void* vkunalignStruct(void* src, const char* desc, int cnt)
{
if(!src)
return src;
int c = 0;
int a = 1;
int sz = vkalignSize(desc);
@@ -1450,7 +1381,7 @@ void* vkunalignNewStruct(void* dst, void* src, const char* desc, int cnt)
{
int c = 0;
int a = 1;
// int sz = vkalignSize(desc);
int sz = vkalignSize(desc);
uint32_t q;
uint32_t* psrc = (uint32_t*)src;
uint32_t* pdst = (uint32_t*)dst;
@@ -1633,10 +1564,10 @@ static void* unalignTox86(my_vkhead_t* src, int cnt)
{
if(!cnt || !src)
return src;
//printf_log(LOG_INFO, "unalignTox86(%p:%d, %d)\n", src, src->sType, cnt);
void* ret = NULL;
const char* s;
switch(src->sType) {
CHANGE(return vkunalignStruct(src, s, cnt))
CHANGE( return vkunalignStruct(src, s, cnt))
default:
// no need to unalign, but follow next...
if(cnt>1) printf_log(LOG_INFO, "Warning, unalignTox86 of %d struct %d not uspported\n", cnt, src->sType);
+140 -177
View File
@@ -41,30 +41,25 @@
#include "library.h"
#include "auxval.h"
#include "wine_tools.h"
#include "rcfile.h"
box86context_t *my_context = NULL;
int box86_log = LOG_NONE;
int box86_dump = 0;
int box86_nobanner = 0;
int box86_dynarec_log = LOG_NONE;
uintptr_t box86_pagesize;
int box86_pagesize;
uintptr_t box86_load_addr = 0;
int box86_showbt = 0;
int box86_backtrace = 0;
#ifdef DYNAREC
int box86_dynarec = 1;
int box86_dynarec_dump = 0;
int box86_dynarec_forced = 0;
int box86_dynarec_largest = 0;
int box86_dynarec_bigblock = 1;
int box86_dynarec_forward = 128;
int box86_dynarec_strongmem = 0;
int box86_dynarec_x87double = 0;
int box86_dynarec_fastnan = 1;
int box86_dynarec_fastround = 1;
int box86_dynarec_safeflags = 1;
int box86_dynarec_hotpage = 16;
int box86_dynarec_bleeding_edge = 1;
uintptr_t box86_nodynarec_start = 0;
uintptr_t box86_nodynarec_end = 0;
#ifdef ARM
@@ -80,8 +75,6 @@ int dlsym_error = 0;
int cycle_log = 0;
int trace_xmm = 0;
int trace_emm = 0;
char* trace_init = NULL;
char* box86_trace = NULL;
#ifdef HAVE_TRACE
uint64_t start_cnt = 0;
#ifdef DYNAREC
@@ -97,10 +90,8 @@ int box86_tokitori2 = 0;
int box86_sc3u = 0;
int box86_mapclean = 0;
int box86_zoom = 0;
int box86_x11threads = 0;
int box86_x11glx = 1;
int box86_sse_flushto0 = 0;
int box86_x87_no80bits = 0;
int x11threads = 0;
int x11glx = 1;
int allow_missing_libs = 0;
int allow_missing_symbols = 0;
int fix_64bit_inodes = 0;
@@ -112,7 +103,7 @@ int box86_nopulse = 0;
int box86_nogtk = 0;
int box86_novulkan = 0;
int box86_showsegv = 0;
char* box86_libGL = NULL;
char* libGL = NULL;
uintptr_t trace_start = 0, trace_end = 0;
char* trace_func = NULL;
uint32_t default_fs = 0;
@@ -122,11 +113,11 @@ int box86_tcmalloc_minimal = 0;
FILE* ftrace = NULL;
int ftrace_has_pid = 0;
void openFTrace(const char* newtrace)
void openFTrace()
{
const char* t = newtrace?newtrace:getenv("BOX86_TRACE_FILE");
char* t = getenv("BOX86_TRACE_FILE");
char tmp[500];
const char* p = t;
char* p = t;
if(p && strstr(t, "%pid")) {
int next = 0;
do {
@@ -167,13 +158,12 @@ void my_child_fork()
if(ftrace_has_pid) {
// open a new ftrace...
fclose(ftrace);
openFTrace(NULL);
openFTrace();
}
}
int getNCpu();
const char* getCpuName();
#ifdef DYNAREC
int getNCpu();
void GatherDynarecExtensions()
{
if(box86_dynarec==0) // no need to check if no dynarec
@@ -232,7 +222,9 @@ void GatherDynarecExtensions()
if(arm_div)
printf_log(LOG_INFO, " IDIVA");
printf_log(LOG_INFO, " PageSize:%zd ", box86_pagesize);
printf_log(LOG_INFO, " PageSize:%d", box86_pagesize);
int ncpu = getNCpu();
printf_log(LOG_INFO, " Cores:%d\n", ncpu);
#endif
}
#endif
@@ -250,7 +242,7 @@ void LoadLogEnv()
}
}
// grab BOX86_TRACE_FILE envvar, and change %pid to actual pid is present in the name
openFTrace(NULL);
openFTrace();
//box86_log = isatty(fileno(ftrace))?LOG_INFO:LOG_NONE; //default LOG value different if stdout is redirected or not
p = getenv("BOX86_LOG");
if(p) {
@@ -279,20 +271,17 @@ void LoadLogEnv()
}
p = getenv("BOX86_ROLLING_LOG");
if(p) {
int cycle = 0;
if(sscanf(p, "%d", &cycle)==1)
cycle_log = cycle;
if(cycle_log==1)
cycle_log = 16;
if(cycle_log<0)
cycle_log = 0;
if(strlen(p)==1) {
if(p[0]>='0' && p[0]<='1')
cycle_log = p[0]-'0';
}
if(cycle_log && box86_log>LOG_INFO) {
cycle_log = 0;
printf_log(LOG_NONE, "Incompatible Rolling log and Debug Log, disabling Rolling log\n");
}
}
if(!box86_nobanner && cycle_log)
printf_log(LOG_INFO, "Rolling log, showing last %d function call on signals\n", cycle_log);
printf_log(LOG_INFO, "Rolling log, showing last %d function call on signals\n", CYCLE_LOG);
p = getenv("BOX86_DUMP");
if(p) {
if(strlen(p)==1) {
@@ -356,18 +345,6 @@ void LoadLogEnv()
else if (box86_dynarec_bigblock>1)
printf_log(LOG_INFO, "Dynarec will try to make bigger blocks\n");
}
p = getenv("BOX86_DYNAREC_FORWARD");
if(p) {
int val = -1;
if(sscanf(p, "%d", &val)==1) {
if(val>=0)
box86_dynarec_forward = val;
}
if(box86_dynarec_forward)
printf_log(LOG_INFO, "Dynarec will continue block for %d bytes on forward jump\n", box86_dynarec_forward);
else
printf_log(LOG_INFO, "Dynarec will not continue block on forward jump\n");
}
p = getenv("BOX86_DYNAREC_STRONGMEM");
if(p) {
if(strlen(p)==1) {
@@ -395,15 +372,6 @@ void LoadLogEnv()
if(!box86_dynarec_fastnan)
printf_log(LOG_INFO, "Dynarec will try to normalize generated NAN\n");
}
p = getenv("BOX86_DYNAREC_FASTROUND");
if(p) {
if(strlen(p)==1) {
if(p[0]>='0' && p[0]<='1')
box86_dynarec_fastround = p[0]-'0';
}
if(!box86_dynarec_fastround)
printf_log(LOG_INFO, "Dynarec will try to generate x86 precise IEEE->int rounding\n");
}
p = getenv("BOX86_DYNAREC_SAFEFLAGS");
if(p) {
if(strlen(p)==1) {
@@ -415,27 +383,6 @@ void LoadLogEnv()
else
printf_log(LOG_INFO, "Dynarec will play %s safe with x86 flags\n", (box86_dynarec_safeflags==1)?"moderatly":"it");
}
p = getenv("BOX86_DYNAREC_HOTPAGE");
if(p) {
int val = -1;
if(sscanf("%d", p, &val)==1) {
if(val>=0)
box86_dynarec_hotpage = val;
}
if(!box86_dynarec_hotpage)
printf_log(LOG_INFO, "Dynarec will have HotPage tagged for %d attempts\n", box86_dynarec_hotpage);
else
printf_log(LOG_INFO, "Dynarec will not tag HotPage\n");
}
p = getenv("BOX86_DYNAREC_BLEEDING_EDGE");
if(p) {
if(strlen(p)==1) {
if(p[0]>='0' && p[0]<='1')
box86_dynarec_bleeding_edge = p[0]-'0';
}
if(!box86_dynarec_bleeding_edge)
printf_log(LOG_INFO, "Dynarec will not detect MonoBleedingEdge\n");
}
p = getenv("BOX86_NODYNAREC");
if(p) {
if (strchr(p,'-')) {
@@ -511,31 +458,31 @@ void LoadLogEnv()
if(p) {
if(strlen(p)==1) {
if(p[0]>='0' && p[0]<='0'+1)
box86_x11threads = p[0]-'0';
x11threads = p[0]-'0';
}
if(box86_x11threads)
if(x11threads)
printf_log(LOG_INFO, "Try to Call XInitThreads if libX11 is loaded\n");
}
p = getenv("BOX86_X11GLX");
if(p) {
if(strlen(p)==1) {
if(p[0]>='0' && p[0]<='0'+1)
box86_x11glx = p[0]-'0';
x11glx = p[0]-'0';
}
if(box86_x11glx)
if(x11glx)
printf_log(LOG_INFO, "Hack to force libX11 GLX extension present\n");
else
printf_log(LOG_INFO, "Disabled Hack to force libX11 GLX extension present\n");
}
p = getenv("BOX86_LIBGL");
if(p)
box86_libGL = box_strdup(p);
if(!box86_libGL) {
libGL = box_strdup(p);
if(!libGL) {
p = getenv("SDL_VIDEO_GL_DRIVER");
if(p)
box86_libGL = box_strdup(p);
libGL = box_strdup(p);
}
if(box86_libGL) {
if(libGL) {
printf_log(LOG_INFO, "BOX86 using \"%s\" as libGL.so.1\n", p);
}
p = getenv("BOX86_ALLOWMISSING_LIBS");
@@ -612,13 +559,13 @@ void LoadLogEnv()
if(box86_showsegv)
printf_log(LOG_INFO, "Show Segfault signal even if a signal handler is present\n");
}
p = getenv("BOX86_SHOWBT");
p = getenv("BOX86_BACKTRACE");
if(p) {
if(strlen(p)==1) {
if(p[0]>='0' && p[0]<='0'+1)
box86_showbt = p[0]-'0';
box86_backtrace = p[0]-'0';
}
if(box86_showbt)
if(box86_backtrace)
printf_log(LOG_INFO, "Show Backtrace for signals\n");
}
box86_pagesize = sysconf(_SC_PAGESIZE);
@@ -627,9 +574,6 @@ void LoadLogEnv()
#ifdef DYNAREC
GatherDynarecExtensions();
#endif
int ncpu = getNCpu();
const char* cpuname = getCpuName();
printf_log(LOG_INFO, "Running on %s with %d Cores\n", cpuname, ncpu);
}
EXPORTDYN
@@ -658,11 +602,9 @@ int CountEnv(char** env)
char** p = env;
int c = 0;
while(*p) {
if(strncmp(*p, "BOX86_PATH=", 11)==0) {
} else if(strncmp(*p, "BOX86_LD_LIBRARY_PATH=", 22)==0) {
} else if(strncmp(*p, "BOX86_", 6)!=0) {
++c;
}
if(strncmp(*p, "BOX86_", 6)!=0)
//if(!(strncmp(*p, "PATH=", 5)==0 || strncmp(*p, "LD_LIBRARY_PATH=", 16)==0))
++c;
++p;
}
return c+2;
@@ -670,11 +612,14 @@ int CountEnv(char** env)
EXPORTDYN
int GatherEnv(char*** dest, char** env, const char* prog)
{
// Add every BOX86_* environment variables
// Add all but BOX86_* environnement
// but add 2 for default BOX86_PATH and BOX86_LD_LIBRARY_PATH
char** p = env;
int idx = 0;
int box86_path = 0;
int box86_ld_path = 0;
char* path = NULL;
char* ld_path = NULL;
while(*p) {
if(strncmp(*p, "BOX86_PATH=", 11)==0) {
(*dest)[idx++] = box_strdup(*p);
@@ -682,19 +627,27 @@ int GatherEnv(char*** dest, char** env, const char* prog)
} else if(strncmp(*p, "BOX86_LD_LIBRARY_PATH=", 22)==0) {
(*dest)[idx++] = box_strdup(*p);
box86_ld_path = 1;
} else if(strncmp(*p, "_=", 2)==0) {
/*int l = strlen(prog);
char tmp[l+3];
strcpy(tmp, "_=");
strcat(tmp, prog);
(*dest)[idx++] = box_strdup(tmp);*/
} else if(strncmp(*p, "BOX86_", 6)!=0) {
(*dest)[idx++] = box_strdup(*p);
/*if(!(strncmp(*p, "PATH=", 5)==0 || strncmp(*p, "LD_LIBRARY_PATH=", 16)==0)) {
}*/
}
++p;
}
// Add default values for BOX86_PATH and BOX86_LD_LIBRARY_PATH
// update the calloc of envv when adding new variables here
if(!box86_path) {
(*dest)[idx++] = box_strdup("BOX86_PATH=.:bin");
}
if(!box86_ld_path) {
(*dest)[idx++] = box_strdup("BOX86_LD_LIBRARY_PATH=.:lib");
}
// Add "_=prog" at the end...
// add "_=prog" at the end...
if(prog) {
int l = strlen(prog);
char tmp[l+3];
@@ -773,7 +726,7 @@ void addNewEnvVar(const char* s)
char* p = box_strdup(s);
char* e = strchr(p, '=');
if(!e) {
printf_log(LOG_INFO, "Invalid specific env. var. '%s'\n", s);
printf_log(LOG_INFO, "Invalid speicifc env. var. '%s'\n", s);
box_free(p);
return;
}
@@ -786,21 +739,22 @@ void addNewEnvVar(const char* s)
EXPORTDYN
void LoadEnvVars(box86context_t *context)
{
char *p;
// Check custom env. var. and add them if needed
p = getenv("BOX86_ENV");
if(p)
addNewEnvVar(p);
int i = 1;
char box86_env[50];
do {
sprintf(box86_env, "BOX86_ENV%d", i);
p = getenv(box86_env);
if(p) {
{
char* p = getenv("BOX86_ENV");
if(p)
addNewEnvVar(p);
++i;
}
} while(p);
int i = 1;
char box86_env[50];
do {
sprintf(box86_env, "BOX86_ENV%d", i);
p = getenv(box86_env);
if(p) {
addNewEnvVar(p);
++i;
}
} while(p);
}
// check BOX86_LD_LIBRARY_PATH and load it
LoadEnvPath(&context->box86_ld_lib, ".:lib:lib32:x86:i686", "BOX86_LD_LIBRARY_PATH");
#ifdef PANDORA
@@ -841,37 +795,46 @@ void LoadEnvVars(box86context_t *context)
AddPath("libssl.so.1.0.0", &context->box86_emulated_libs, 0);
AddPath("libcrypto.so.1", &context->box86_emulated_libs, 0);
AddPath("libcrypto.so.1.0.0", &context->box86_emulated_libs, 0);
if(getenv("BOX86_PREFER_WRAPPED")) {
if (strcmp(getenv("BOX86_PREFER_WRAPPED"), "1")==0) {
box86_prefer_wrapped = 1;
printf_log(LOG_INFO, "BOX86: Prefer Wrapped libs\n");
}
}
if(getenv("BOX86_PREFER_EMULATED")) {
if (strcmp(getenv("BOX86_PREFER_EMULATED"), "1")==0) {
box86_prefer_emulated = 1;
printf_log(LOG_INFO, "BOX86: Prefer Emulated libs\n");
}
}
if(getenv("BOX86_NOSIGSEGV")) {
if (strcmp(getenv("BOX86_NOSIGSEGV"), "1")==0) {
context->no_sigsegv = 1;
printf_log(LOG_INFO, "BOX86: Disabling handling of SigSEGV\n");
}
}
if(getenv("BOX86_NOSIGILL")) {
if (strcmp(getenv("BOX86_NOSIGILL"), "1")==0) {
context->no_sigill = 1;
printf_log(LOG_INFO, "BOX86: Disabling handling of SigILL\n");
}
}
// check BOX86_PATH and load it
LoadEnvPath(&context->box86_path, ".:bin", "BOX86_PATH");
if(getenv("PATH"))
AppendList(&context->box86_path, getenv("PATH"), 1); // in case some of the path are for x86 world
#define READENV(v, name, dest, eqn) \
do { \
p = getenv(name); \
if (p) { \
if (!strcmp(p, v)) { \
dest = 1; \
eqn; \
} \
} \
} while (0)
#define READENV0(name, dest, eqn) READENV("0", name, dest, eqn)
#define READENV1(name, dest, log) READENV("1", name, dest, printf_log(LOG_INFO, log))
READENV1("BOX86_SSE_FLUSHTO0", box86_sse_flushto0, "BOX86: Direct apply of SSE Flush to 0 flag\n");
READENV1("BOX86_X87_NO80BITS", box86_x87_no80bits, "BOX86: all 80bits x87 long double will be handle as double\n");
READENV1("BOX86_PREFER_WRAPPED", box86_prefer_wrapped, "BOX86: Prefer Wrapped libs\n");
READENV1("BOX86_PREFER_EMULATED", box86_prefer_emulated, "BOX86: Prefer Emulated libs\n");
READENV1("BOX86_NOSIGSEGV", context->no_sigsegv, "BOX86: Disabling handling of SigSEGV\n");
READENV1("BOX86_NOSIGILL", context->no_sigill, "BOX86: Disabling handling of SigILL\n");
#ifdef HAVE_TRACE
p = getenv("BOX86_TRACE");
if(p && strcmp(p, "0")) {
context->x86trace = 1;
box86_trace = p;
};
READENV0("BOX86_TRACE_INIT", context->x86trace, trace_init = p);
char* p = getenv("BOX86_TRACE");
if(p) {
if (strcmp(p, "0"))
context->x86trace = 1;
}
p = getenv("BOX86_TRACE_INIT");
if(p) {
if (strcmp(p, "0"))
context->x86trace = 1;
}
if(my_context->x86trace) {
printf_log(LOG_INFO, "Initializing Zydis lib\n");
if(InitX86Trace(my_context)) {
@@ -880,9 +843,6 @@ void LoadEnvVars(box86context_t *context)
}
}
#endif
#undef READENV
#undef READENV0
#undef READENV1
#ifdef BUILD_LIB
context->argc = 1; // need 1
context->argv = (char**)box_malloc(sizeof(char*));
@@ -894,7 +854,7 @@ EXPORTDYN
void setupTraceInit(box86context_t* context)
{
#ifdef HAVE_TRACE
char* p = trace_init;
char* p = getenv("BOX86_TRACE_INIT");
if(p) {
setbuf(stdout, NULL);
uintptr_t trace_start=0, trace_end=0;
@@ -917,13 +877,11 @@ void setupTraceInit(box86context_t* context)
}
}
} else {
p = box86_trace;
p = getenv("BOX86_TRACE");
if(p)
if (strcmp(p, "0"))
SetTraceEmu(0, 1);
}
#else
(void)context;
#endif
}
@@ -931,7 +889,7 @@ EXPORTDYN
void setupTrace(box86context_t* context)
{
#ifdef HAVE_TRACE
char* p = box86_trace;
char* p = getenv("BOX86_TRACE");
if(p) {
setbuf(stdout, NULL);
uintptr_t trace_start=0, trace_end=0;
@@ -960,14 +918,10 @@ void setupTrace(box86context_t* context)
} else {
printf_log(LOG_NONE, "Warning, symbol to Traced (\"%s\") not found, trying to set trace later\n", p);
SetTraceEmu(0, 1); // disabling trace, mostly
if(trace_func)
box_free(trace_func);
trace_func = box_strdup(p);
}
}
}
#else
(void)context;
#endif
}
@@ -986,7 +940,7 @@ void endBox86()
FreeLibrarian(&my_context->maplib, emu); // unload all libs
// waiting for all thread except this one to finish
int this_thread = GetTID();
// int pid = getpid();
int pid = getpid();
int running = 1;
int attempt = 0;
printf_log(LOG_DEBUG, "Waiting for all threads to finish before unloading box86context\n");
@@ -1024,27 +978,9 @@ void endBox86()
}
// all done, free context
FreeBox86Context(&my_context);
if(box86_libGL) {
box_free(box86_libGL);
box86_libGL = NULL;
}
}
static void load_rcfiles()
{
if(FileExist("/etc/box86.box86rc", IS_FILE))
LoadRCFile("/etc/box86.box86rc");
#ifdef PANDORA
if(FileExist("/mnt/utmp/codeblocks/usr/etc/box86.box86rc", IS_FILE))
LoadRCFile("/mnt/utmp/codeblocks/usr/etc/box86.box86rc");
#endif
char* p = getenv("HOME");
if(p) {
char tmp[4096];
strncpy(tmp, p, 4096);
strncat(tmp, "/.box86rc", 4095);
if(FileExist(tmp, IS_FILE))
LoadRCFile(tmp);
if(libGL) {
box_free(libGL);
libGL = NULL;
}
}
@@ -1121,9 +1057,6 @@ int main(int argc, const char **argv, char **env)
// check BOX86_LOG debug level
LoadLogEnv();
if(!getenv("BOX64_NORCFILES")) {
load_rcfiles();
}
char* bashpath = NULL;
{
char* p = getenv("BOX86_BASH");
@@ -1236,8 +1169,8 @@ int main(int argc, const char **argv, char **env)
// prepare all other env. var
my_context->envc = CountEnv(environ?environ:env);
printf_log(LOG_INFO, "Counted %d Env var\n", my_context->envc);
// allocate extra space for the new environment variable _ and the null terminator
my_context->envv = (char**)box_calloc(my_context->envc+2, sizeof(char*));
// allocate extra space for new environment variables such as BOX86_PATH
my_context->envv = (char**)box_calloc(my_context->envc+4, sizeof(char*));
GatherEnv(&my_context->envv, environ?environ:env, my_context->box86path);
if(box86_dump) {
for (int i=0; i<my_context->envc; ++i)
@@ -1291,17 +1224,44 @@ int main(int argc, const char **argv, char **env)
if(box86_wine) {
AddPath("libdl.so.2", &ld_preload, 0);
}
// special case for LittleInferno that use an old libvorbis
if(strstr(prgname, "LittleInferno.bin.x86")==prgname) {
printf_log(LOG_INFO, "LittleInferno detected, forcing emulated libvorbis\n");
AddPath("libvorbis.so.0", &my_context->box86_emulated_libs, 0);
}
// special case for dontstarve that use an old SDL2
if(strstr(prgname, "dontstarve")) {
printf_log(LOG_INFO, "Dontstarve* detected, forcing emulated SDL2\n");
AddPath("libSDL2-2.0.so.0", &my_context->box86_emulated_libs, 0);
}
// special case for A Golden Wake / GeminiRue that use an old SDL2 and vorbis libs
if(strstr(prgname, "A_Golden_Wake.bin.x86")==prgname || strstr(prgname, "GeminiRue.bin.x86")==prgname) {
printf_log(LOG_INFO, "A Golden Wake / Gemini Rue detected, prefer emulated libs\n");
box86_prefer_emulated = 1;
}
// special case for steam that somehow seems to alter libudev opaque pointer (udev_monitor)
if(strstr(prgname, "steam")==prgname) {
printf_log(LOG_INFO, "steam detected\n");
printf_log(LOG_INFO, "steam detected, forcing emulated libudev and gtk\n");
AddPath("libudev.so.0", &my_context->box86_emulated_libs, 0);
box86_steam = 1;
box86_nogtk = 1;
AddPath("libSDL2-2.0.so.0", &my_context->box86_emulated_libs, 0);
unsetenv("BOX86_NOGTK");
#ifdef PANDORA
x11color16 = 1;
#endif
}
// special case for steam-runtime-check-requirements to fake 64bits suport
if(strstr(prgname, "steam-runtime-check-requirements")==prgname) {
printf_log(LOG_INFO, "steam-runtime-check-requirements detected, faking All is good!\n");
exit(0); // exiting, not testing anything
}
// special case for streaming_client to use emulated libSDL2
if(strstr(prgname, "streaming_client")==prgname) {
printf_log(LOG_INFO, "streaming_client detected, using emulated libSDL2!\n");
AddPath("libSDL2-2.0.so.0", &my_context->box86_emulated_libs, 0);
AddPath("libSDL2_ttf-2.0.so.0", &my_context->box86_emulated_libs, 0);
}
// special case for UnrealLinux.bin, it doesn't like "full path resolution"
if(!strcmp(prog, "UnrealLinux.bin") && my_context->argv[0]) {
box_free(my_context->argv[0]);
@@ -1328,6 +1288,11 @@ int main(int argc, const char **argv, char **env)
printf_log(LOG_INFO, "Zoom detected, trying to use system libturbojpeg if possible\n");
box86_zoom = 1;
}
// special case for X3Reunion to use emulated libjpeg62
if(strstr(prgname, "X3R_main")) {
printf_log(LOG_INFO, "X3Reunion detected, forcing emulated libjpeg\n");
AddPath("libjpeg.so.62", &my_context->box86_emulated_libs, 0);
}
// special case for bash (add BOX86_NOBANNER=1 if not there)
if(!strcmp(prgname, "bash")) {
printf_log(LOG_INFO, "bash detected, disabling banner\n");
@@ -1350,8 +1315,6 @@ int main(int argc, const char **argv, char **env)
/*if(!strcmp(prgname, "gdb")) {
exit(-1);
}*/
ApplyParams("*", &ld_preload); // [*] is a special setting for all process
ApplyParams(prgname, &ld_preload);
for(int i=1; i<my_context->argc; ++i) {
my_context->argv[i] = box_strdup(argv[i+nextarg]);
@@ -1496,7 +1459,7 @@ int main(int argc, const char **argv, char **env)
printf_log(LOG_INFO, "BOX86: Using tcmalloc_minimal.so.4, and it's in the LD_PRELOAD command\n");
}
}
#if defined(RPI) || defined(RK3399) || defined(GOA_CLONE) || defined(PYRA)
#if defined(RPI) || defined(RK3399) || defined(GOA_CLONE)
// before launching emulation, let's check if this is a mojosetup from GOG
if (((strstr(prog, "bin/linux/x86/mojosetup") && getenv("MOJOSETUP_BASE")) || strstr(prog, ".mojosetup/mojosetup"))
&& getenv("GTK2_RC_FILES")) {
+12 -39
View File
@@ -98,7 +98,7 @@ GO2(tc_malloc_skip_new_handler_weak, pFL); \
GO2(tc_mallocopt, iFii); \
GO2(tc_malloc_stats, vFv); \
GO2(tc_malloc_skip_new_handler, pFL); \
GO2S(tc_mallinfo, pFp); \
GO2(tc_mallinfo, pFv); \
GO2(tc_posix_memalign, iFpLL); \
GO2(tc_realloc, pFpL); \
@@ -155,7 +155,7 @@ char* box_realpath(const char* path, char* ret)
static size_t pot(size_t l) {
size_t ret = 0;
while (l>(1u<<ret)) ++ret;
while (l>(1<<ret)) ++ret;
return 1<<ret;
}
#ifndef ANDROID
@@ -230,7 +230,6 @@ EXPORT void* my__Znwm(size_t sz) //operator new(size_t)
EXPORT void* my__ZnwmRKSt9nothrow_t(size_t sz, void* p) //operator new(size_t, std::nothrow_t const&)
{
(void)p;
return box_malloc(sz);
}
@@ -241,7 +240,6 @@ EXPORT void* my__Znam(size_t sz) //operator new[](size_t)
EXPORT void* my__ZnamRKSt9nothrow_t(size_t sz, void* p) //operator new[](size_t, std::nothrow_t const&)
{
(void)p;
return box_malloc(sz);
}
@@ -253,13 +251,11 @@ EXPORT void my__ZdaPv(void* p) //operator delete[](void*)
EXPORT void my__ZdaPvm(void* p, size_t sz) //operator delete[](void*, size_t)
{
(void)sz;
box_free(p);
}
EXPORT void my__ZdaPvmSt11align_val_t(void* p, size_t sz, size_t align) //operator delete[](void*, unsigned long, std::align_val_t)
{
(void)sz; (void)align;
box_free(p);
}
@@ -270,7 +266,6 @@ EXPORT void my__ZdlPv(void* p) //operator delete(void*)
EXPORT void my__ZdlPvm(void* p, size_t sz) //operator delete(void*, size_t)
{
(void)sz;
box_free(p);
}
@@ -281,7 +276,6 @@ EXPORT void* my__ZnwmSt11align_val_t(size_t sz, size_t align) //// operator new
EXPORT void* my__ZnwmSt11align_val_tRKSt9nothrow_t(size_t sz, size_t align, void* p) //// operator new(unsigned long, std::align_val_t, std::nothrow_t const&)
{
(void)p;
return box_memalign(align, sz);
}
@@ -292,49 +286,41 @@ EXPORT void* my__ZnamSt11align_val_t(size_t sz, size_t align) //// operator new
EXPORT void* my__ZnamSt11align_val_tRKSt9nothrow_t(size_t sz, size_t align, void* p) //// operator new[](unsigned long, std::align_val_t, std::nothrow_t const&)
{
(void)p;
return box_memalign(align, sz);
}
EXPORT void my__ZdlPvRKSt9nothrow_t(void* p, void* n) //operator delete(void*, std::nothrow_t const&)
{
(void)n;
box_free(p);
}
EXPORT void my__ZdaPvSt11align_val_tRKSt9nothrow_t(void* p, size_t align, void* n) //operator delete[](void*, std::align_val_t, std::nothrow_t const&)
{
(void)align; (void)n;
box_free(p);
}
EXPORT void my__ZdlPvmSt11align_val_t(void* p, size_t sz, size_t align) //operator delete(void*, unsigned long, std::align_val_t)
{
(void)sz; (void)align;
box_free(p);
}
EXPORT void my__ZdaPvRKSt9nothrow_t(void* p, void* n) //operator delete[](void*, std::nothrow_t const&)
{
(void)n;
box_free(p);
}
EXPORT void my__ZdaPvSt11align_val_t(void* p, size_t align) //operator delete[](void*, std::align_val_t)
{
(void)align;
box_free(p);
}
EXPORT void my__ZdlPvSt11align_val_t(void* p, size_t align) //operator delete(void*, std::align_val_t)
{
(void)align;
box_free(p);
}
EXPORT void my__ZdlPvSt11align_val_tRKSt9nothrow_t(void* p, size_t align, void* n) //operator delete(void*, std::align_val_t, std::nothrow_t const&)
{
(void)align; (void)n;
box_free(p);
}
@@ -360,13 +346,11 @@ EXPORT void my_tc_deletearray(void* p)
EXPORT void my_tc_deletearray_nothrow(void* p, void* n)
{
(void)n;
box_free(p);
}
EXPORT void my_tc_delete_nothrow(void* p, void* n)
{
(void)n;
box_free(p);
}
@@ -392,19 +376,17 @@ EXPORT void* my_tc_new(size_t s)
EXPORT void* my_tc_new_nothrow(size_t s, void* n)
{
(void)n;
return box_calloc(1, s);
return box_calloc(1, s);
}
EXPORT void* my_tc_newarray(size_t s)
{
return box_calloc(1, s);
return box_calloc(1, s);
}
EXPORT void* my_tc_newarray_nothrow(size_t s, void* n)
{
(void)n;
return box_calloc(1, s);
return box_calloc(1, s);
}
EXPORT void* my_tc_pvalloc(size_t size)
@@ -429,7 +411,6 @@ EXPORT void* my_tc_malloc_skip_new_handler_weak(size_t s)
EXPORT int my_tc_mallocopt(int param, int value)
{
(void)param; (void)value;
// ignoring...
return 1;
}
@@ -453,11 +434,11 @@ EXPORT void* my_tc_malloc_skip_new_handler(size_t s)
return box_calloc(1, s);
}
EXPORT void* my_tc_mallinfo(void* p)
EXPORT void* my_tc_mallinfo(void)
{
// ignored, returning null stuffs
memset(p, 0, sizeof(size_t)*10);
return p;
static size_t faked[10] = {0};
return faked;
}
EXPORT int my_tc_posix_memalign(void** p, size_t align, size_t size)
@@ -478,7 +459,6 @@ EXPORT void* my_tc_realloc(void* p, size_t s)
/*
EXPORT int my_tc_version(int i)
{
(void)i;
return 2;
}
*/
@@ -512,32 +492,29 @@ static void addRelocJmp(void* offs, void* where, size_t size, const char* name)
void checkHookedSymbols(lib_t *maplib, elfheader_t* h)
{
(void)maplib;
int hooked = 0;
for (uint32_t i=0; i<h->numDynSym && hooked<2; ++i) {
for (size_t i=0; i<h->numDynSym && hooked<2; ++i) {
const char * symname = h->DynStr+h->DynSym[i].st_name;
int bind = ELF64_ST_BIND(h->DynSym[i].st_info);
int type = ELF64_ST_TYPE(h->DynSym[i].st_info);
int vis = h->DynSym[i].st_other&0x3;
if((type==STT_FUNC)
&& (vis==STV_DEFAULT || vis==STV_PROTECTED) && (h->DynSym[i].st_shndx!=0 && h->DynSym[i].st_shndx<=65521)) {
// uintptr_t offs = h->DynSym[i].st_value + h->delta;
uintptr_t offs = h->DynSym[i].st_value + h->delta;
size_t sz = h->DynSym[i].st_size;
if(bind!=STB_LOCAL && bind!=STB_WEAK && sz>=sizeof(simple_jmp_t)) {
#define GO(A, B) if(!strcmp(symname, #A)) ++hooked;
#define GO2(A, B)
#define GO2S(A, B)
SUPER()
#undef GO
#undef GO2
#undef GO2S
}
}
}
if(hooked<2)
return; // only redirect on lib that hooked / redefined the operators
printf_log(LOG_INFO, "Redirecting overriden malloc function for %s\n", ElfName(h));
for (uint32_t i=0; i<h->numDynSym; ++i) {
for (size_t i=0; i<h->numDynSym; ++i) {
const char * symname = h->DynStr+h->DynSym[i].st_name;
int bind = ELF64_ST_BIND(h->DynSym[i].st_info);
int type = ELF64_ST_TYPE(h->DynSym[i].st_info);
@@ -549,18 +526,14 @@ void checkHookedSymbols(lib_t *maplib, elfheader_t* h)
if(bind!=STB_LOCAL && bind!=STB_WEAK) {
#define GO(A, B) if(!strcmp(symname, "__libc_" #A)) {uintptr_t alt = AddCheckBridge(my_context->system, B, A, 0, #A); printf_log(LOG_DEBUG, "Redirecting %s function from %p (%s)\n", symname, (void*)offs, ElfName(h)); addRelocJmp((void*)offs, (void*)alt, sz, #A);}
#define GO2(A, B)
#define GO2S(A, B)
SUPER()
#undef GO
#undef GO2
#undef GO2S
#define GO(A, B) if(!strcmp(symname, #A)) {uintptr_t alt = AddCheckBridge(my_context->system, B, A, 0, #A); printf_log(LOG_DEBUG, "Redirecting %s function from %p (%s)\n", symname, (void*)offs, ElfName(h)); addRelocJmp((void*)offs, (void*)alt, sz, #A);}
#define GO2(A, B) if(!strcmp(symname, #A)) {uintptr_t alt = AddCheckBridge(my_context->system, B, my_##A, 0, #A); printf_log(LOG_DEBUG, "Redirecting %s function from %p (%s)\n", symname, (void*)offs, ElfName(h)); addRelocJmp((void*)offs, (void*)alt, sz, #A);}
#define GO2S(A, B) if(!strcmp(symname, #A)) {uintptr_t alt = AddCheckBridge(my_context->system, B, my_##A, 4, #A); printf_log(LOG_DEBUG, "Redirecting %s function from %p (%s)\n", symname, (void*)offs, ElfName(h)); addRelocJmp((void*)offs, (void*)alt, sz, #A);}
SUPER()
#undef GO
#undef GO2
#undef GO2S
}
}
}
@@ -579,4 +552,4 @@ void init_malloc_hook() {
#endif
}
#undef SUPER
#undef SUPER
+41 -47
View File
@@ -42,9 +42,9 @@ brick_t* NewBrick(void* old)
brick_t* ret = (brick_t*)box_calloc(1, sizeof(brick_t));
if(old)
old = old + NBRICK * sizeof(onebridge_t);
void* ptr = my_mmap(NULL, old, NBRICK * sizeof(onebridge_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
void* ptr = my_mmap(thread_get_emu(), old, NBRICK * sizeof(onebridge_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if(ptr == MAP_FAILED)
ptr = my_mmap(NULL, NULL, NBRICK * sizeof(onebridge_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
ptr = my_mmap(thread_get_emu(), NULL, NBRICK * sizeof(onebridge_t), PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if(ptr == MAP_FAILED) {
printf_log(LOG_NONE, "Warning, cannot allocate 0x%x aligned bytes for bridge, will probably crash later\n", NBRICK*sizeof(onebridge_t));
}
@@ -71,13 +71,14 @@ void FreeBridge(bridge_t** bridge)
*bridge = NULL;
brick_t *b = br->head;
x86emu_t* emu = thread_get_emu();
while(b) {
brick_t *n = b->next;
#ifdef DYNAREC
if(getProtection((uintptr_t)b->b)&(PROT_DYNAREC|PROT_DYNAREC_R))
unprotectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t), 0);
#endif
my_munmap(NULL, b->b, NBRICK*sizeof(onebridge_t));
my_munmap(emu, b->b, NBRICK*sizeof(onebridge_t));
box_free(b);
b = n;
}
@@ -94,21 +95,27 @@ uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char*
if(!bridge) return 0;
brick_t *b = NULL;
int sz = -1;
mutex_lock(&my_context->mutex_bridge);
b = bridge->last;
if(b->sz == NBRICK) {
b->next = NewBrick(b->b);
b = b->next;
bridge->last = b;
}
sz = b->sz;
#ifdef DYNAREC
if(box86_dynarec) {
int prot = 0;
prot=(getProtection((uintptr_t)&b->b[sz])&(PROT_DYNAREC|PROT_DYNAREC_R))?1:0;
if(prot)
unprotectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t), 0); // don't mark blocks, it's only new one
}
int prot = 0;
do {
#endif
pthread_mutex_lock(&my_context->mutex_bridge);
b = bridge->last;
if(b->sz == NBRICK) {
b->next = NewBrick(b->b);
b = b->next;
bridge->last = b;
}
sz = b->sz;
#ifdef DYNAREC
pthread_mutex_unlock(&my_context->mutex_bridge);
if(box86_dynarec) {
prot=(getProtection((uintptr_t)&b->b[sz])&(PROT_DYNAREC|PROT_DYNAREC_R))?1:0;
if(prot)
unprotectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t), 0); // don't mark blocks, it's only new one
}
} while(sz!=b->sz); // this while loop if someone took the slot when the bridge mutex was unlocked doing memory protection managment
pthread_mutex_lock(&my_context->mutex_bridge);
#endif
b->sz++;
b->b[sz].CC = 0xCC;
@@ -121,17 +128,16 @@ uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char*
int ret;
khint_t k = kh_put(bridgemap, bridge->bridgemap, (uintptr_t)fnc, &ret);
kh_value(bridge->bridgemap, k) = (uintptr_t)&b->b[sz].CC;
#ifdef DYNAREC
if(box86_dynarec)
pthread_mutex_unlock(&my_context->mutex_bridge);
#ifdef DYNAREC
// only reprotect the block when stuffs are running
if(!my_context->deferedInit && box86_dynarec)
protectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t));
#endif
mutex_unlock(&my_context->mutex_bridge);
#ifdef HAVE_TRACE
#endif
#ifdef HAVE_TRACE
if(name)
addBridgeName(fnc, name);
#else
(void)name;
#endif
#endif
return (uintptr_t)&b->b[sz].CC;
}
@@ -139,21 +145,12 @@ uintptr_t AddBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char*
uintptr_t CheckBridged(bridge_t* bridge, void* fnc)
{
// check if function alread have a bridge (the function wrapper will not be tested)
if (!fnc) return 0;
khint_t k = kh_get(bridgemap, bridge->bridgemap, (uint32_t)fnc);
if(k==kh_end(bridge->bridgemap))
return 0;
return kh_value(bridge->bridgemap, k);
}
int IsBridge(void* fnc) {
onebridge_t *b = (onebridge_t*)fnc;
if(!b || b->CC != 0xCC || b->S!='S' || b->C!='C' || (b->C3!=0xC3 && b->C3!=0xC2)) {
return 0;
}
return 1;
}
uintptr_t AddCheckBridge(bridge_t* bridge, wrapper_t w, void* fnc, int N, const char* name)
{
if(!fnc && w)
@@ -174,12 +171,10 @@ uintptr_t AddAutomaticBridge(x86emu_t* emu, bridge_t* bridge, wrapper_t w, void*
if(!hasAlternate(fnc)) {
printf_log(LOG_DEBUG, "Adding AutomaticBridge for %p to %p\n", fnc, (void*)ret);
addAlternate(fnc, (void*)ret);
#ifdef DYNAREC
#ifdef DYNAREC
// now, check if dynablock at native address exist
DBAlternateBlock(emu, (uintptr_t)fnc, ret);
#else
(void)emu;
#endif
#endif
}
return ret;
}
@@ -210,19 +205,18 @@ void* GetNativeFnc(uintptr_t fnc)
#undef PK
#undef PK32
// check if bridge exist
if (IsBridge((void*)fnc)) {
return (void*)((onebridge_t*)fnc)->f;
}
return NULL;
onebridge_t *b = (onebridge_t*)fnc;
if(b->CC != 0xCC || b->S!='S' || b->C!='C' || (b->C3!=0xC3 && b->C3!=0xC2))
return NULL; // not a bridge?!
return (void*)b->f;
}
void* GetNativeFncOrFnc(uintptr_t fnc)
{
if (IsBridge((void*)fnc)) {
return (void*)((onebridge_t*)fnc)->f;
} else {
return (void*)fnc;
}
onebridge_t *b = (onebridge_t*)fnc;
if(b->CC != 0xCC || b->S!='S' || b->C!='C' || (b->C3!=0xC3 && b->C3!=0xC2))
return (void*)fnc; // not a bridge?!
return (void*)b->f;
}
#ifdef HAVE_TRACE
-50
View File
@@ -13,58 +13,9 @@
#include "box86stack.h"
#include "dynarec.h"
EXPORTDYN
uint32_t RunSafeFunction(box86context_t *context, uintptr_t fnc, int nargs, ...)
{
(void)context;
x86emu_t *emu = thread_get_emu();
Push(emu, R_EBP); // push rbp
uintptr_t old_ebp = R_EBP = R_ESP; // mov rbp, rsp
Push(emu, R_EDI);
Push(emu, R_ESI);
Push(emu, R_EDX);
Push(emu, R_ECX);
Push(emu, R_EBX);
Push(emu, R_EAX);
R_ESP -= nargs*4; // need to push in reverse order
uint32_t *p = (uint32_t*)R_ESP;
va_list va;
va_start (va, nargs);
for (int i=0; i<nargs; ++i) {
*p = va_arg(va, uint32_t);
p++;
}
va_end (va);
uintptr_t oldip = R_EIP;
DynaCall(emu, fnc);
R_ESP+=(nargs*4);
uint32_t ret = R_EAX;
R_EIP = oldip;
R_EAX = Pop(emu);
R_EBX = Pop(emu);
R_ECX = Pop(emu);
R_EDX = Pop(emu);
R_ESI = Pop(emu);
R_EDI = Pop(emu);
R_ESP = old_ebp; // mov rsp, rbp
R_EBP = Pop(emu); // pop rbp
return ret;
}
EXPORTDYN
uint32_t RunFunction(box86context_t *context, uintptr_t fnc, int nargs, ...)
{
(void)context;
x86emu_t *emu = thread_get_emu();
R_ESP -= nargs*4; // need to push in reverse order
@@ -90,7 +41,6 @@ uint32_t RunFunction(box86context_t *context, uintptr_t fnc, int nargs, ...)
EXPORTDYN
uint64_t RunFunction64(box86context_t *context, uintptr_t fnc, int nargs, ...)
{
(void)context;
x86emu_t *emu = thread_get_emu();
R_ESP -= nargs*4; // need to push in reverse order
+1 -14
View File
@@ -132,20 +132,7 @@ const char* GetTmpDir() {
return "/tmp"; // meh...
}
char* LowerCase(const char* s) {
if(!s)
return NULL;
char* ret = box_calloc(1, strlen(s)+1);
size_t i=0;
while(*s) {
ret[i++] = (*s>='A' && *s<='Z')?(*s-'A'+'a'):(*s);
++s;
}
return ret;
}
#if defined(RPI) || defined(RK3399) || defined(GOA_CLONE) || defined(PYRA)
#if defined(RPI) || defined(RK3399) || defined(GOA_CLONE)
void sanitize_mojosetup_gtk_background()
{
// get GTK2_RC_FILES folder
+1 -1
View File
@@ -1759,7 +1759,7 @@ static void* find_signal7_Fct(void* fct)
printf_log(LOG_NONE, "Warning, no more slot for GTypeInfo signal7 callback\n");
return NULL;
}
//static const wrapper_t wrappers[] = {pFpp, pFppp, pFpppp, pFpppp, pFppppp, pFpppppp};
static const wrapper_t wrappers[] = {pFpp, pFppp, pFpppp, pFpppp, pFppppp, pFpppppp};
typedef void* (*finder_t)(void*);
static const finder_t finders[] = {find_signal2_Fct, find_signal3_Fct, find_signal4_Fct, find_signal5_Fct, find_signal6_Fct, find_signal7_Fct};
#define MAX_SIGNAL_N 7
+27 -35
View File
@@ -25,31 +25,9 @@ int get_cpuMhz()
return MHz;
}
int getNCpu(); // defined in wrappedlibc.c
const char* getCpuName(); // same
void my_cpuid(x86emu_t* emu, uint32_t tmp32u)
{
static char branding[3*4*4+1] = "";
static int done = 0;
if(!done) {
done = 1;
const char* name = getCpuName();
if(strstr(name, "MHz") || strstr(name, "GHz")) {
// name already have the speed in it
snprintf(branding, 3*4*4, "Box86 on %s", name);
} else {
int MHz = get_cpuMhz();
if(MHz>15000) { // swiches to GHz display...
snprintf(branding, 3*4*4, "Box86 on %s @%1.2f GHz", name, MHz/1000.);
} else {
snprintf(branding, 3*4*4, "Box86 on %s @%04d MHz", name, MHz);
}
}
while(strlen(branding)<3*4*4) {
memmove(branding+1, branding, strlen(branding));
branding[0] = ' ';
}
}
int ncpu = getNCpu();
if(ncpu>255) ncpu = 255;
if(!ncpu) ncpu = 1;
@@ -175,23 +153,37 @@ void my_cpuid(x86emu_t* emu, uint32_t tmp32u)
R_ECX = (1<<5) | (1<<8); // LZCNT | PREFETCHW
R_EDX = 0;
break;
case 0x80000002: // Brand part 1 (branding signature)
R_EAX = ((uint32_t*)branding)[0];
R_EBX = ((uint32_t*)branding)[1];
R_ECX = ((uint32_t*)branding)[2];
R_EDX = ((uint32_t*)branding)[3];
case 0x80000002: // Brand part 1 (P4 signature)
R_EAX = 0x20202020;
R_EBX = 0x20202020;
R_ECX = 0x20202020;
R_EDX = 0x6E492020;
break;
case 0x80000003: // Brand part 2
R_EAX = ((uint32_t*)branding)[4];
R_EBX = ((uint32_t*)branding)[5];
R_ECX = ((uint32_t*)branding)[6];
R_EDX = ((uint32_t*)branding)[7];
R_EAX = 0x286C6574;
R_EBX = 0x50202952;
R_ECX = 0x69746E65;
R_EDX = 0x52286D75;
break;
case 0x80000004: // Brand part 3, with frequency
R_EAX = ((uint32_t*)branding)[8];
R_EBX = ((uint32_t*)branding)[9];
R_ECX = ((uint32_t*)branding)[10];
R_EDX = ((uint32_t*)branding)[11];
R_EAX = 0x20342029;
R_EBX = 0x20555043;
{
static int MHz = 0;
if(!MHz)
MHz = get_cpuMhz();
if(MHz>15000) { // swiches to GHz display...
char tmp[12];
sprintf(tmp, "%1.2f", MHz/1000.);
R_ECX = *(uint32_t*)tmp;
R_EDX = 0x007A4847; // GHz
} else {
char tmp[12];
sprintf(tmp, "%04d", MHz);
R_ECX = *(uint32_t*)tmp;
R_EDX = 0x007A484D; // MHz
}
}
break;
case 0x80000005:
R_EAX = 0;
-517
View File
@@ -1,517 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include "debug.h"
#include "rcfile.h"
#include "box86context.h"
#include "pathcoll.h"
#include "fileutils.h"
#ifdef HAVE_TRACE
#include "x86trace.h"
#endif
#include "custommem.h"
#include "khash.h"
// This file handle the box86rc files
// file are basicaly ini file, with section [XXXX] defining the name of the process
// and BOX86_XXXX=YYYY entry like the env. var. variables
// list of all entries
#define SUPER1() \
ENTRYINTPOS(BOX86_ROLLING_LOG, new_cycle_log) \
ENTRYSTRING_(BOX86_LD_LIBRARY_PATH, ld_library_path) \
ENTRYSTRING_(BOX86_PATH, box86_path) \
ENTRYSTRING_(BOX86_TRACE_FILE, trace_file) \
ENTRYADDR(BOX86_LOAD_ADDR, box86_load_addr) \
ENTRYINT(BOX86_LOG, box86_log, 0, 3, 2) \
ENTRYBOOL(BOX86_DUMP, box86_dump) \
ENTRYBOOL(BOX86_DLSYM_ERROR, dlsym_error) \
CENTRYBOOL(BOX86_NOSIGSEGV, no_sigsegv) \
CENTRYBOOL(BOX86_NOSIGILL, no_sigill) \
ENTRYBOOL(BOX86_SHOWSEGV, box86_showsegv) \
ENTRYBOOL(BOX86_SHOWBT, box86_showbt) \
ENTRYBOOL(BOX86_X11THREADS, box86_x11threads) \
ENTRYBOOL(BOX86_X11GLX, box86_x11glx) \
ENTRYDSTRING(BOX86_LIBGL, box86_libGL) \
ENTRYBOOL(BOX86_SSE_FLUSHTO0, box86_sse_flushto0) \
ENTRYBOOL(BOX86_X87_NO80BITS, box86_x87_no80bits) \
ENTRYSTRING_(BOX86_EMULATED_LIBS, emulated_libs) \
ENTRYBOOL(BOX86_ALLOWMISSINGLIBS, allow_missing_libs) \
ENTRYBOOL(BOX86_ALLOWMISSING_SYMBOLS, allow_missing_symbols) \
ENTRYBOOL(BOX86_PREFER_WRAPPED, box86_prefer_wrapped) \
ENTRYBOOL(BOX86_PREFER_EMULATED, box86_prefer_emulated) \
ENTRYBOOL(BOX86_NOPULSE, box86_nopulse) \
ENTRYBOOL(BOX86_NOGTK, box86_nogtk) \
ENTRYBOOL(BOX86_NOVULKAN, box86_novulkan) \
ENTRYBOOL(BOX86_FIX_64BIT_INODES, fix_64bit_inodes) \
ENTRYSTRING_(BOX86_BASH, bash) \
ENTRYINT(BOX86_JITGDB, jit_gdb, 0, 2, 2) \
ENTRYSTRING_(BOX86_BOX64, box64) \
ENTRYSTRING_(BOX86_LD_PRELOAD, ld_preload) \
#ifdef HAVE_TRACE
#define SUPER2() \
ENTRYSTRING_(BOX86_TRACE, trace) \
ENTRYULONG(BOX86_TRACE_START, start_cnt) \
ENTRYSTRING_(BOX86_TRACE_INIT, trace_init) \
ENTRYBOOL(BOX86_TRACE_XMM, trace_xmm) \
ENTRYBOOL(BOX86_TRACE_EMM, trace_emm) \
#else
#define SUPER2() \
IGNORE(BOX86_TRACE) \
IGNORE(BOX86_TRACE_START) \
IGNORE(BOX86_TRACE_INIT) \
IGNORE(BOX86_TRACE_XMM) \
IGNORE(BOX86_TRACE_EMM) \
#endif
#ifdef DYNAREC
#define SUPER3() \
ENTRYBOOL(BOX86_DYNAREC, box86_dynarec) \
ENTRYINT(BOX86_DYNAREC_DUMP, box86_dynarec_dump, 0, 2, 2) \
ENTRYINT(BOX86_DYNAREC_LOG, box86_dynarec_log, 0, 3, 2) \
ENTRYINT(BOX86_DYNAREC_BIGBLOCK, box86_dynarec_bigblock, 0, 3, 2) \
ENTRYSTRING_(BOX86_DYNAREC_FORWARD, box86_dynarec_forward) \
ENTRYINT(BOX86_DYNAREC_STRONGMEM, box86_dynarec_strongmem, 0, 2, 2) \
ENTRYBOOL(BOX86_DYNAREC_X87DOUBLE, box86_dynarec_x87double) \
ENTRYBOOL(BOX86_DYNAREC_FASTNAN, box86_dynarec_fastnan) \
ENTRYBOOL(BOX86_DYNAREC_FASTROUND, box86_dynarec_fastround) \
ENTRYINT(BOX86_DYNAREC_SAFEFLAGS, box86_dynarec_safeflags, 0, 2, 2) \
ENTRYINT(BOX86_DYNAREC_HOTPAGE, box86_dynarec_hotpage, 0, 255, 8) \
ENTRYBOOL(BOX86_DYNAREC_BLEEDING_EDGE, box86_dynarec_bleeding_edge) \
ENTRYSTRING_(BOX86_NODYNAREC, box86_nodynarec) \
#else
#define SUPER3() \
IGNORE(BOX86_DYNAREC) \
IGNORE(BOX86_DYNAREC_DUMP) \
IGNORE(BOX86_DYNAREC_LOG) \
IGNORE(BOX86_DYNAREC_BIGBLOCK) \
IGNORE(BOX64_DYNAREC_FORWARD) \
IGNORE(BOX86_DYNAREC_STRONGMEM) \
IGNORE(BOX86_DYNAREC_X87DOUBLE) \
IGNORE(BOX86_DYNAREC_FASTNAN) \
IGNORE(BOX86_DYNAREC_FASTROUND) \
IGNORE(BOX86_DYNAREC_SAFEFLAGS) \
IGNORE(BOX86_DYNAREC_HOTPAGE) \
IGNORE(BOX86_DYNAREC_BLEEDING_EDGE) \
IGNORE(BOX86_NODYNAREC) \
#endif
#if defined(HAVE_TRACE) && defined(DYNAREC)
#define SUPER4() \
ENTRYBOOL(BOX86_DYNAREC_TRACE, box86_dynarec_trace) \
#else
#define SUPER4() \
IGNORE(BOX86_DYNAREC_TRACE) \
#endif
#ifdef PANDORA
#define SUPER5() \
ENTRYBOOL(BOX86_X11COLOR16, x11color16)
#else
#define SUPER5() \
IGNORE(BOX86_X11COLOR16)
#endif
#define SUPER() \
SUPER1() \
SUPER2() \
SUPER3() \
SUPER4() \
SUPER5()
typedef struct my_params_s {
// is present part
#define ENTRYBOOL(NAME, name) uint8_t is_##name##_present:1;
#define CENTRYBOOL(NAME, name) uint8_t is_##name##_present:1;
#define ENTRYINT(NAME, name, minval, maxval, bits) uint8_t is_##name##_present:1;
#define ENTRYINTPOS(NAME, name) uint8_t is_##name##_present:1;
#define ENTRYSTRING(NAME, name) uint8_t is_##name##_present:1;
#define ENTRYSTRING_(NAME, name) uint8_t is_##name##_present:1;
#define ENTRYDSTRING(NAME, name) uint8_t is_##name##_present:1;
#define ENTRYADDR(NAME, name) uint8_t is_##name##_present:1;
#define ENTRYULONG(NAME, name) uint8_t is_##name##_present:1;
#define IGNORE(NAME)
SUPER()
// done
#undef ENTRYBOOL
#undef CENTRYBOOL
#undef ENTRYINT
#undef ENTRYINTPOS
#undef ENTRYSTRING
#undef ENTRYSTRING_
#undef ENTRYDSTRING
#undef ENTRYADDR
#undef ENTRYULONG
// the actual fields
#define ENTRYBOOL(NAME, name) uint8_t name:1;
#define CENTRYBOOL(NAME, name) uint8_t name:1;
#define ENTRYINT(NAME, name, minval, maxval, bits) uint8_t name:bits;
#define ENTRYINTPOS(NAME, name) uint32_t name;
#define ENTRYSTRING(NAME, name) char* name;
#define ENTRYSTRING_(NAME, name) char* name;
#define ENTRYDSTRING(NAME, name) char* name;
#define ENTRYADDR(NAME, name) uintptr_t name;
#define ENTRYULONG(NAME, name) uint64_t name;
SUPER()
// done
#undef ENTRYBOOL
#undef CENTRYBOOL
#undef ENTRYINT
#undef ENTRYINTPOS
#undef ENTRYSTRING
#undef ENTRYSTRING_
#undef ENTRYDSTRING
#undef ENTRYADDR
#undef ENTRYULONG
} my_params_t;
KHASH_MAP_INIT_STR(params, my_params_t)
static kh_params_t *params = NULL;
#ifdef PANDORA
extern int x11color16;
#endif
extern int fix_64bit_inodes;
static void clearParam(my_params_t* param)
{
#define ENTRYBOOL(NAME, name)
#define CENTRYBOOL(NAME, name)
#define ENTRYINT(NAME, name, minval, maxval, bits)
#define ENTRYINTPOS(NAME, name)
#define ENTRYSTRING(NAME, name) free(param->name);
#define ENTRYSTRING_(NAME, name) free(param->name);
#define ENTRYDSTRING(NAME, name) free(param->name);
#define ENTRYADDR(NAME, name)
#define ENTRYULONG(NAME, name)
SUPER()
#undef ENTRYBOOL
#undef CENTRYBOOL
#undef ENTRYINT
#undef ENTRYINTPOS
#undef ENTRYSTRING
#undef ENTRYSTRING_
#undef ENTRYDSTRING
#undef ENTRYADDR
#undef ENTRYULONG
}
static void addParam(const char* name, my_params_t* param)
{
khint_t k;
k = kh_get(params, params, name);
if(k==kh_end(params)) {
int ret;
k = kh_put(params, params, strdup(name), &ret);
} else {
clearParam(&kh_value(params, k));
}
my_params_t *p = &kh_value(params, k);
memcpy(p, param, sizeof(my_params_t));
}
static void trimString(char* s)
{
if(!s)
return;
// trim right space/tab
size_t len = strlen(s);
while(len && (s[len-1]==' ' || s[len-1]=='\t' || s[len-1]=='\n'))
s[--len] = '\0';
// trim left space/tab
while(s[0]==' ' || s[0]=='\t')
memmove(s, s+1, strlen(s));
}
void LoadRCFile(const char* filename)
{
FILE *f = fopen(filename, "r");
if(!f) {
printf_log(LOG_INFO, "Cannot open RC file %s\n", filename);
return;
}
// init the hash table if needed
if(!params)
params = kh_init(params);
// prepare to parse the file
char* line = NULL;
size_t lsize = 0;
my_params_t current_param = {0};
char* current_name = NULL;
int dummy;
size_t len;
char* p;
// parsing
while ((dummy = getline(&line, &lsize, f)) != -1) {
// remove comments
if((p=strchr(line, '#')))
*p = '\0';
trimString(line);
len = strlen(line);
// check the line content
if(line[0]=='[' && strchr(line, ']')) {
// new entry, will need to add current one
if(current_name)
addParam(current_name, &current_param);
// prepare a new entry
memset(&current_param, 0, sizeof(current_param));
free(current_name);
current_name = LowerCase(line+1);
*strchr(current_name, ']') = '\0';
trimString(current_name);
} else if(strchr(line, '=')) {
// actual parameters
//get the key and val
char* key = line;
char* val = strchr(key, '=')+1;
*strchr(key, '=') = '\0';
trimString(key);
trimString(val);
// extract, check and set arg
#define ENTRYBOOL(NAME, name) ENTRYINT(NAME, name, 0, 1, 1)
#define CENTRYBOOL(NAME, name) ENTRYBOOL(NAME, name)
#define ENTRYINT(NAME, name, minval, maxval, bits) \
else if(!strcmp(key, #NAME)) { \
int v = strtol(val, &p, 0); \
if(p!=val && v>=minval && v<=maxval) { \
current_param.is_##name##_present = 1; \
current_param.name = v; \
} \
}
#define ENTRYINTPOS(NAME, name) \
else if(!strcmp(key, #NAME)) { \
int v = strtol(val, &p, 0); \
if(p!=val) { \
current_param.is_##name##_present = 1; \
current_param.name = v; \
} \
}
#define ENTRYSTRING(NAME, name) \
else if(!strcmp(key, #NAME)) { \
current_param.is_##name##_present = 1; \
if(current_param.name) free(current_param.name); \
current_param.name = strdup(val); \
}
#define ENTRYSTRING_(NAME, name) ENTRYSTRING(NAME, name)
#define ENTRYDSTRING(NAME, name) ENTRYSTRING(NAME, name)
#define ENTRYADDR(NAME, name) \
else if(!strcmp(key, #NAME)) { \
uintptr_t v = strtoul(val, &p, 0); \
if(p!=val) { \
current_param.is_##name##_present = 1; \
current_param.name = v; \
} \
}
#define ENTRYULONG(NAME, name) \
else if(!strcmp(key, #NAME)) { \
uint64_t v = strtoull(val, &p, 0); \
if(p!=val) { \
current_param.is_##name##_present = 1; \
current_param.name = v; \
} \
}
#undef IGNORE
#define IGNORE(NAME) else if(!strcmp(key, #NAME)) ;
if(0) ;
SUPER()
else if(len && current_name) {
printf_log(LOG_INFO, "Warning, unsupported %s=%s for [%s] in %s", key, val, current_name, filename);
}
#undef ENTRYBOOL
#undef CENTRYBOOL
#undef ENTRYINT
#undef ENTRYINTPOS
#undef ENTRYSTRING
#undef ENTRYSTRING_
#undef ENTRYDSTRING
#undef ENTRYADDR
#undef ENTRYULONG
#undef IGNORE
#define IGNORE(NAME)
}
}
// last entry to be pushed too
if(current_name)
addParam(current_name, &current_param);
free(line);
printf_log(LOG_INFO, "Params database has %d entries\n", kh_size(params));
}
void DeleteParams()
{
if(!params)
return;
// free strings
my_params_t* p;
// need to free duplicated strings
kh_foreach_value_ref(params, p, clearParam(p));
const char* key;
kh_foreach_key(params, key, free((void*)key));
// free the hash itself
kh_destroy(params, params);
params = NULL;
}
extern int ftrace_has_pid;
void openFTrace(const char* newtrace);
#ifdef DYNAREC
void GatherDynarecExtensions();
#endif
#ifdef HAVE_TRACE
void setupTraceInit();
void setupTrace();
#endif
void ApplyParams(const char* name, path_collection_t* preload)
{
if(!name || !params)
return;
static const char* old_name = NULL;
int new_cycle_log = cycle_log;
if(old_name && !strcmp(name, old_name))
return;
old_name = name;
khint_t k;
{
char* lname = LowerCase(name);
k = kh_get(params, params, lname);
free(lname);
}
if(k == kh_end(params))
return;
my_params_t* param = &kh_value(params, k);
#ifdef DYNAREC
int olddynarec = box86_dynarec;
#endif
printf_log(LOG_INFO, "Apply RC params for %s\n", name);
#define ENTRYBOOL(NAME, name) ENTRYINT(NAME, name, 0, 1, 1)
#define CENTRYBOOL(NAME, name) if(param->is_##name##_present) {my_context->name = param->name; printf_log(LOG_INFO, "Applying %s=%d\n", #NAME, param->name);}
#define ENTRYINT(NAME, name, minval, maxval, bits) if(param->is_##name##_present) {name = param->name; printf_log(LOG_INFO, "Applying %s=%d\n", #NAME, param->name);}
#define ENTRYINTPOS(NAME, name) if(param->is_##name##_present) {name = param->name; printf_log(LOG_INFO, "Applying %s=%d\n", #NAME, param->name);}
#define ENTRYSTRING(NAME, name) if(param->is_##name##_present) {name = param->name; printf_log(LOG_INFO, "Applying %s=%s\n", #NAME, param->name);}
#define ENTRYSTRING_(NAME, name)
#define ENTRYDSTRING(NAME, name) if(param->is_##name##_present) {if(name) free(name); name = strdup(param->name); printf_log(LOG_INFO, "Applying %s=%s\n", #NAME, param->name);}
#define ENTRYADDR(NAME, name) if(param->is_##name##_present) {name = param->name; printf_log(LOG_INFO, "Applying %s=%zd\n", #NAME, param->name);}
#define ENTRYULONG(NAME, name) if(param->is_##name##_present) {name = param->name; printf_log(LOG_INFO, "Applying %s=%lld\n", #NAME, param->name);}
SUPER()
#undef ENTRYBOOL
#undef CENTRYBOOL
#undef ENTRYINT
#undef ENTRYINTPOS
#undef ENTRYSTRING
#undef ENTRYSTRING_
#undef ENTRYDSTRING
#undef ENTRYADDR
#undef ENTRYULONG
// now handle the manuel entry (the one with ending underscore)
if(new_cycle_log==1)
new_cycle_log = 16;
if(new_cycle_log!=cycle_log) {
freeCycleLog(my_context);
cycle_log = new_cycle_log;
initCycleLog(my_context);
}
if(param->is_ld_library_path_present) AppendList(&my_context->box86_ld_lib, param->ld_library_path, 1);
if(param->is_box86_path_present) AppendList(&my_context->box86_path, param->box86_path, 1);
if(param->is_trace_file_present) {
if(ftrace_has_pid) {
// open a new ftrace...
fclose(ftrace);
}
openFTrace(param->trace_file);
}
if(param->is_emulated_libs_present) {
AppendList(&my_context->box86_emulated_libs, param->emulated_libs, 0);
printf_log(LOG_INFO, "Applying %s=%s\n", "BOX86_EMULATED_LIBS", param->emulated_libs);
}
if(param->is_bash_present && (FileIsX86ELF(param->bash) || FileIsX64ELF(param->bash))) {
if(my_context->bashpath)
free(my_context->bashpath);
my_context->bashpath = strdup(param->bash);
printf_log(LOG_INFO, "Applying %s=%s\n", "BOX86_BASH", param->bash);
}
if(param->is_box64_present && FileExist(param->box64, IS_FILE)) {
if(my_context->box64path) {
free(my_context->box64path);
}
my_context->box64path = strdup(param->box64);
printf_log(LOG_INFO, "Applying %s=%s\n", "BOX86_BOX64", param->box64);
}
if(param->is_ld_preload_present) {
if(preload) {
printf_log(LOG_INFO, "Applying %s=%s\n", "BOX86_LD_PRELOAD", param->ld_preload);
PrependList(preload, param->ld_preload, 1);
} else {
printf_log(LOG_INFO, "Cannot Apply %s=%s\n", "BOX86_LD_PRELOAD", param->ld_preload);
}
}
#ifdef HAVE_TRACE
int old_x86trace = my_context->x86trace;
if(param->is_trace_present) {
char*p = param->trace;
if (strcmp(p, "0")) {
my_context->x86trace = 1;
box86_trace = p;
}
printf_log(LOG_INFO, "Applying %s=%s", "BOX86_TRACE", param->trace);
}
if(param->is_trace_init_present) {
char* p = param->trace_init;
if (strcmp(p, "0")) {
my_context->x86trace = 1;
trace_init = p;
}
printf_log(LOG_INFO, "Applying %s=%s", "BOX86_TRACE_INIT", param->trace_init);
}
if(my_context->x86trace && !old_x86trace) {
printf_log(LOG_INFO, "Initializing Zydis lib\n");
if(InitX86Trace(my_context)) {
printf_log(LOG_INFO, "Zydis init failed, no x86 trace activated\n");
my_context->x86trace = 0;
}
}
if(param->is_trace_init_present)
setupTraceInit();
if(param->is_trace_present)
setupTrace();
#endif
#ifdef DYNAREC
if(param->is_box86_nodynarec_present) {
uintptr_t no_start = 0, no_end = 0;
char* p;
no_start = strtoul(param->box86_nodynarec, &p, 0);
if(p!=param->box86_nodynarec) {
char* p2;
no_end = strtoul(p, &p2, 0);
if(p2!=p && no_end>no_start) {
box86_nodynarec_start = no_start;
box86_nodynarec_end = no_end;
printf_log(LOG_INFO, "Appling BOX86_NODYNAREC=%p-%p\n", (void*)box86_nodynarec_start, (void*)box86_nodynarec_end);
}
}
}
if(param->is_box86_dynarec_forward_present) {
int forward = 0;
if(sscanf(param->box86_dynarec_forward, "%d", &forward)==1) {
box86_dynarec_forward = forward;
printf_log(LOG_INFO, "Appling BOX86_DYNAREC_FORWARD=%d\n", box86_dynarec_forward);
}
}
if(!olddynarec && box86_dynarec)
GatherDynarecExtensions();
#endif
if(box86_log==3) {
box86_log = 2;
box86_dump = 1;
}
}
+5 -123
View File
@@ -68,7 +68,6 @@
#() dFG
#() lFv
#() lFi
#() lFu
#() lFl
#() lFp
#() lFG
@@ -279,7 +278,6 @@
#() vFEpV
#() vFiii
#() vFiiu
#() vFiif
#() vFiip
#() vFiII
#() vFiui
@@ -288,7 +286,6 @@
#() vFiUU
#() vFiff
#() vFidd
#() vFill
#() vFilp
#() vFipi
#() vFipu
@@ -317,9 +314,6 @@
#() vFfpp
#() vFddd
#() vFdpp
#() vFlip
#() vFllp
#() vFlpp
#() vFLpL
#() vFpii
#() vFpiI
@@ -331,17 +325,14 @@
#() vFpui
#() vFpuI
#() vFpuu
#() vFpuU
#() vFpup
#() vFpUi
#() vFpUu
#() vFpUU
#() vFpUp
#() vFpUP
#() vFpff
#() vFpdd
#() vFpll
#() vFplp
#() vFpLi
#() vFpLL
#() vFpLp
@@ -596,27 +587,21 @@
#() vFEpPp
#() vFiiii
#() vFiiip
#() vFiill
#() vFiipp
#() vFiipV
#() vFiIII
#() vFiuiu
#() vFiuip
#() vFiuuu
#() vFiuup
#() vFiulp
#() vFiupu
#() vFiupV
#() vFiUUU
#() vFifff
#() vFiddd
#() vFilil
#() vFilip
#() vFilpu
#() vFilpp
#() vFipii
#() vFipup
#() vFipll
#() vFippi
#() vFippu
#() vFippp
@@ -683,19 +668,16 @@
#() vFpuuV
#() vFpudd
#() vFpupp
#() vFpupP
#() vFpUui
#() vFpUuu
#() vFpUup
#() vFpUUi
#() vFpUUu
#() vFpUUp
#() vFpUpp
#() vFpfff
#() vFpdii
#() vFpddi
#() vFpddd
#() vFplpp
#() vFpLLL
#() vFppii
#() vFppiu
@@ -825,7 +807,6 @@
#() iFpLpL
#() iFppii
#() iFppiu
#() iFppiU
#() iFppiL
#() iFppip
#() iFppIL
@@ -878,7 +859,6 @@
#() uFpppi
#() uFpppu
#() uFpppp
#() uFpppV
#() UFpipp
#() UFppii
#() UFppip
@@ -923,14 +903,12 @@
#() pFiipi
#() pFiipp
#() pFiIIi
#() pFillu
#() pFipii
#() pFipip
#() pFipup
#() pFippi
#() pFippu
#() pFuiii
#() pFuuii
#() pFuuuu
#() pFulli
#() pFullu
@@ -984,15 +962,10 @@
#() vFEppiV
#() vFEppup
#() vFEpppp
#() vFEpPpp
#() vFiiiii
#() vFiiiiu
#() vFiiuii
#() vFiiuup
#() vFiillu
#() vFiilll
#() vFiipii
#() vFiipll
#() vFiIIII
#() vFiuiip
#() vFiuipi
@@ -1003,8 +976,6 @@
#() vFiffff
#() vFidddd
#() vFilill
#() vFilipi
#() vFilipl
#() vFipipu
#() vFipipp
#() vFipupi
@@ -1014,7 +985,6 @@
#() vFuiiiu
#() vFuiiip
#() vFuiifi
#() vFuiill
#() vFuiIII
#() vFuiuii
#() vFuiuiu
@@ -1067,8 +1037,6 @@
#() vFpiipp
#() vFpiIiI
#() vFpiIII
#() vFpiUUp
#() vFpilpp
#() vFpipii
#() vFpipiu
#() vFpuiip
@@ -1129,7 +1097,6 @@
#() iFEpipi
#() iFEpipp
#() iFEpipV
#() iFEpupU
#() iFEpupp
#() iFEpupV
#() iFEpUup
@@ -1172,7 +1139,6 @@
#() iFpiIip
#() iFpiuwp
#() iFpiupu
#() iFpiUUU
#() iFpipii
#() iFpipiL
#() iFpipip
@@ -1196,7 +1162,6 @@
#() iFpupup
#() iFpuppu
#() iFpuppp
#() iFpUiUi
#() iFplluu
#() iFpLlpp
#() iFpLLpp
@@ -1237,7 +1202,6 @@
#() uFEpppp
#() uFiuuuu
#() uFipipp
#() uFipLpp
#() uFuiiiu
#() uFpCCCC
#() uFpWuip
@@ -1335,20 +1299,13 @@
#() vFEppppp
#() vFiiiiii
#() vFiiiuil
#() vFiiilpi
#() vFiiuiil
#() vFiiuilp
#() vFiiuulp
#() vFiililp
#() vFiiplli
#() vFiiplll
#() vFiuippp
#() vFiffiff
#() vFiddidd
#() vFililll
#() vFilipli
#() vFiliplu
#() vFipiplp
#() vFipllli
#() vFuiiiii
#() vFuiiiil
@@ -1362,7 +1319,6 @@
#() vFuiuiuu
#() vFuiuuip
#() vFuiuuuu
#() vFuiuulp
#() vFuiupii
#() vFuiupiu
#() vFuiUUUU
@@ -1430,7 +1386,6 @@
#() vFppippi
#() vFppippp
#() vFppuuuu
#() vFppuUUU
#() vFppupii
#() vFppuppp
#() vFppdidd
@@ -1465,7 +1420,6 @@
#() iFEpuppp
#() iFEpUPpp
#() iFEpLppp
#() iFEpppip
#() iFEppppp
#() iFiiiiii
#() iFiiiiip
@@ -1610,12 +1564,8 @@
#() vFEpppppp
#() vFiiiiiip
#() vFiiiiuup
#() vFiiuilil
#() vFiiffffp
#() vFiipllli
#() vFiuulipi
#() vFilipliu
#() vFilulipi
#() vFuiiiiii
#() vFuiiiuip
#() vFuiiiuup
@@ -1655,7 +1605,6 @@
#() vFulipulp
#() vFulpiill
#() vFlipuiip
#() vFlliiiip
#() vFpiiiipp
#() vFpiiliip
#() vFpiipCpp
@@ -1819,7 +1768,6 @@
#() vFEippippp
#() vFEuuuuppp
#() vFEppipppp
#() vFEpppippp
#() vFEpppuipV
#() vFEpppppuu
#() vFEppppppp
@@ -1830,7 +1778,6 @@
#() vFuiiiiuup
#() vFuiuiiiii
#() vFuiuiiiip
#() vFuiuiuuuu
#() vFuiulplpp
#() vFuipuliuf
#() vFuuiiiiii
@@ -1844,7 +1791,6 @@
#() vFuuuipipp
#() vFuuuuuuuu
#() vFuuuuufff
#() vFuuufffff
#() vFulllplip
#() vFffffffff
#() vFlipuiuip
@@ -1869,7 +1815,6 @@
#() vFpppppppp
#() iFEipupupi
#() iFEpippppp
#() iFEpuiippp
#() iFEpuuiipp
#() iFEpuuuipp
#() iFEpuuLppp
@@ -1905,7 +1850,6 @@
#() uFEpppuppp
#() uFEppppppp
#() uFuipppppp
#() uFulpppppp
#() uFpupuuuCp
#() uFppuuuupp
#() uFppuuuppi
@@ -1941,14 +1885,10 @@
#() vFEpiiiiipp
#() vFEpippippp
#() vFEpippippV
#() vFEpuuuippp
#() vFEppiipppp
#() vFEpppiippp
#() vFEppppippp
#() vFiiiiiiiii
#() vFiiiiiiill
#() vFiiiiillli
#() vFiiilllilp
#() vFuiiiiiiii
#() vFuiiiiiuip
#() vFuiiiiiuup
@@ -2034,10 +1974,7 @@
#() vFEiippppppp
#() vFEpippppppp
#() vFEpppiipppp
#() vFiiiiiiiiii
#() vFiiiiiiiiiu
#() vFiiiiiiiiui
#() vFiiillliiip
#() vFippppppppp
#() vFuiiiiiiiii
#() vFuiiiiiiill
@@ -2072,7 +2009,7 @@
#() iFEppppppipp
#() iFiiiiiiiiip
#() iFpiipiiipip
#() iFpippddiidd
#() iFpuipuppppp
#() iFpuupiuiipp
#() iFpddpippppp
#() iFppipiippii
@@ -2093,8 +2030,6 @@
#() pFppuiipuuii
#() pFpppppppppp
#() vFEpiiiupupup
#() vFiiiiillliip
#() vFiiiiilllilp
#() vFiippppppppp
#() vFuiiiiiiiiip
#() vFuiiiiiiiuip
@@ -2120,7 +2055,6 @@
#() vFppipppuiiii
#() vFppipppppppp
#() vFppppppppppp
#() iFEpuipuppppp
#() iFEpuuiiuippu
#() iFEpuuuuuiipp
#() iFEpppipppppp
@@ -2200,7 +2134,6 @@
#() pFEppCuuWWwwCCup
#() pFEppuuuWWWWWWWW
#() pFpuupuupwwwwWWC
#() vFuiiiiiuiiiiilll
#() vFuuiiiiuuiiiiiii
#() vFfffffffffffffff
#() vFppipppppppppppp
@@ -2213,9 +2146,7 @@
#() vFpppppppppppppppp
#() iFpppppppppppppppp
#() pFppipipipipipipip
#() vFuuuiiiiiuiiiiilll
#() vFppiiiiddddiiiiiuu
#() vFpppuppiipppuUUUpi
#() iFppipipppppppppppp
#() iFpppippppppppppppp
#() pFppippipipipipipip
@@ -2272,7 +2203,9 @@
#() UFsvvs -> UFss
#() iFEpvpp -> iFEppp
#() iFEpvpV -> iFEppV
#() iFEpvvpV -> iFEppV
#() pFpsvvvvs -> pFpss
#() iFEpuvvppp -> iFEpuppp
#defined(NOALIGN) iFpvpV -> iFppV
#!defined(NOALIGN) iFEivpV -> iFEipV
wrappedalure:
@@ -2299,7 +2232,6 @@ wrappedcairo:
- cairo_scaled_font_set_user_data
- cairo_set_user_data
- cairo_surface_set_user_data
wrappedcairogobject:
wrappedcap:
wrappedcrashhandler:
wrappedcrypto:
@@ -2427,8 +2359,6 @@ wrappedgconf2:
- uFpppppp:
- gconf_client_notify_add
wrappedgcrypt:
- uFpppV:
- gcry_sexp_build
wrappedgdk3:
- vFpp:
- gdk_init
@@ -2684,8 +2614,6 @@ wrappedgobject2:
- g_param_spec_get_default_value
- g_type_class_peek_parent
- g_value_reset
- vFpp:
- g_closure_set_marshal
- iFpp:
- g_param_type_register_static
- pFpi:
@@ -2695,8 +2623,6 @@ wrappedgobject2:
- vFiip:
- g_type_add_interface_static
- g_value_register_transform_func
- vFppp:
- g_closure_add_finalize_notifier
- vFppV:
- g_object_get
- g_object_set
@@ -3091,7 +3017,7 @@ wrappedlibc:
- iFipppp:
- getopt_long
- getopt_long_only
- iFpiipV:
- iFpvvpV:
- iFpiLpp:
- iFpippp:
- iFpuppp:
@@ -3107,7 +3033,7 @@ wrappedlibc:
- pFpLiiiI:
- pFpppppp:
- iFpippppp:
- iFpuiippp:
- iFpuvvppp:
- iFpLiLppp:
wrappedlibcairogobject:
wrappedlibcrypt:
@@ -3143,7 +3069,6 @@ wrappedlibgl:
- glDebugMessageCallback
- glDebugMessageCallbackAMD
- glDebugMessageCallbackARB
- glDebugMessageCallbackKHR
- vFipp:
- glProgramCallbackMESA
wrappedlibglu:
@@ -3152,23 +3077,6 @@ wrappedlibglu:
- gluQuadricCallback
- gluTessCallback
wrappedlibharfbuzz:
wrappedlibibus:
- vFpippp:
- ibus_bus_current_input_context_async
- ibus_bus_get_global_engine_async
- ibus_bus_list_active_engines_async
- ibus_bus_list_engines_async
- ibus_input_context_get_engine_async
- vFppippp:
- ibus_bus_create_input_context_async
- ibus_bus_set_global_engine_async
- ibus_config_get_values_async
- vFpppippp:
- ibus_config_get_value_async
- vFpuuuippp:
- ibus_input_context_process_key_event_async
- vFppppippp:
- ibus_config_set_value_async
wrappedlibice:
wrappedlibjpeg:
- iFv:
@@ -3178,9 +3086,6 @@ wrappedlibjpeg:
- jpeg_start_decompress
- pFp:
- jpeg_std_error
- vFpp:
- jpeg_stdio_dest
- jpeg_stdio_src
- iFpi:
- jpeg_read_header
- vFpiL:
@@ -3204,9 +3109,6 @@ wrappedlibjpeg62:
- jpeg_std_error
- vFpi:
- jpeg_start_compress
- vFpp:
- jpeg_stdio_dest
- jpeg_stdio_src
- iFpi:
- jpeg_read_header
- jpeg_resync_to_restart
@@ -3277,7 +3179,6 @@ wrappedlibm:
- cbrtl
- erfcl
- erfl
- floorl
- ldexpl
- lgammal
- logl
@@ -3608,7 +3509,6 @@ wrappedlibxcb:
- xcb_unmap_window
- xFpp:
- xcb_free_cursor
- xcb_no_operation
- xFpCC:
- xcb_get_keyboard_mapping
- xFpup:
@@ -3637,8 +3537,6 @@ wrappedlibxcb:
- xcb_change_window_attributes
- xcb_change_window_attributes_checked
- xcb_query_text_extents
- iFpppip:
- xcb_take_socket
- xFpCuup:
- xcb_send_event
- xFpCppp:
@@ -3660,7 +3558,6 @@ wrappedlibxcb:
- xcb_grab_keyboard
- xFpCuuWW:
- xcb_create_pixmap
- xcb_create_pixmap_checked
- xFpCuuup:
- xcb_poly_line
- xcb_poly_line_checked
@@ -3884,7 +3781,6 @@ wrappedlibxft:
wrappedlibxi:
wrappedlibxmu:
wrappedlibxpm:
wrappedlibxpresent:
wrappedlibxrandr:
wrappedlibxrender:
wrappedlibxss:
@@ -4436,7 +4332,6 @@ wrappedtbbmallocproxy:
- _ZnamRKSt9nothrow_t
- _ZnwmRKSt9nothrow_t
wrappedtcmallocminimal:
- pFp:
- iFpL:
- munmap
- pFpLiiii:
@@ -4526,12 +4421,9 @@ wrappedvulkan:
- vkDestroyFramebuffer
- vkDestroyImage
- vkDestroyImageView
- vkDestroyOpticalFlowSessionNV
- vkDestroyPipeline
- vkDestroyPipelineCache
- vkDestroyPipelineLayout
- vkDestroyPrivateDataSlot
- vkDestroyPrivateDataSlotEXT
- vkDestroyQueryPool
- vkDestroyRenderPass
- vkDestroySampler
@@ -4560,12 +4452,6 @@ wrappedvulkan:
- vkGetPhysicalDeviceSurfaceCapabilities2KHR
- iFPpp:
- vkCreateInstance
- vFpPpp:
- vkGetDeviceImageSparseMemoryRequirements
- vkGetDeviceImageSparseMemoryRequirementsKHR
- iFpupU:
- vkQueueSubmit2
- vkQueueSubmit2KHR
- iFpUup:
- vkGetDisplayPlaneCapabilitiesKHR
- iFpUpP:
@@ -4591,11 +4477,8 @@ wrappedvulkan:
- vkCreateHeadlessSurfaceEXT
- vkCreateImage
- vkCreateImageView
- vkCreateOpticalFlowSessionNV
- vkCreatePipelineCache
- vkCreatePipelineLayout
- vkCreatePrivateDataSlot
- vkCreatePrivateDataSlotEXT
- vkCreateQueryPool
- vkCreateRenderPass
- vkCreateRenderPass2
@@ -4609,7 +4492,6 @@ wrappedvulkan:
- vkCreateValidationCacheEXT
- vkCreateXcbSurfaceKHR
- vkCreateXlibSurfaceKHR
- vkGetPhysicalDeviceOpticalFlowImageFormatsNV
- vkRegisterDeviceEventEXT
- vFpupup:
- vkUpdateDescriptorSets
@@ -1,8 +0,0 @@
/*******************************************************************
* File automatically generated by rebuild_wrappers.py (v2.0.0.10) *
*******************************************************************/
#ifndef __wrappedcairogobjectDEFS_H_
#define __wrappedcairogobjectDEFS_H_
#endif // __wrappedcairogobjectDEFS_H_
@@ -1,17 +0,0 @@
/*******************************************************************
* File automatically generated by rebuild_wrappers.py (v2.0.0.10) *
*******************************************************************/
#ifndef __wrappedcairogobjectTYPES_H_
#define __wrappedcairogobjectTYPES_H_
#ifndef LIBNAME
#error You should only #include this file inside a wrapped*.c file
#endif
#ifndef ADDED_FUNCTIONS
#define ADDED_FUNCTIONS()
#endif
#define SUPER() ADDED_FUNCTIONS()
#endif // __wrappedcairogobjectTYPES_H_
@@ -1,8 +0,0 @@
/*******************************************************************
* File automatically generated by rebuild_wrappers.py (v2.0.0.10) *
*******************************************************************/
#ifndef __wrappedcairogobjectUNDEFS_H_
#define __wrappedcairogobjectUNDEFS_H_
#endif // __wrappedcairogobjectUNDEFS_H_
+1 -3
View File
@@ -11,9 +11,7 @@
#define ADDED_FUNCTIONS()
#endif
typedef uint32_t (*uFpppV_t)(void*, void*, void*, ...);
#define SUPER() ADDED_FUNCTIONS() \
GO(gcry_sexp_build, uFpppV_t)
#define SUPER() ADDED_FUNCTIONS()
#endif // __wrappedgcryptTYPES_H_
Loaded 100 of 240 files, more files were not shown because too many files have changed in this diff. Show more