From dfb1cd487616cdcee38488eb1f6f30b76942bc69 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 20 Mar 2021 16:49:02 +0100 Subject: Renamed arm64_lock_helper to arm64_lock --- src/custommem.c | 2 +- src/dynarec/arm64_lock.S | 87 +++++++++++++++++++++++++++++++++++++++++ src/dynarec/arm64_lock.h | 31 +++++++++++++++ src/dynarec/arm64_lock_helper.S | 87 ----------------------------------------- src/dynarec/arm64_lock_helper.h | 31 --------------- src/dynarec/dynablock.c | 2 +- src/emu/x64run.c | 2 +- src/emu/x64run0f.c | 2 +- src/emu/x64run66.c | 2 +- src/emu/x64runf0.c | 2 +- 10 files changed, 124 insertions(+), 124 deletions(-) create mode 100755 src/dynarec/arm64_lock.S create mode 100755 src/dynarec/arm64_lock.h delete mode 100755 src/dynarec/arm64_lock_helper.S delete mode 100755 src/dynarec/arm64_lock_helper.h (limited to 'src') diff --git a/src/custommem.c b/src/custommem.c index d3dc4b62..6b245112 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -23,7 +23,7 @@ #include "khash.h" #ifdef DYNAREC #include "dynablock.h" -#include "dynarec/arm64_lock_helper.h" +#include "dynarec/arm64_lock.h" //#define USE_MMAP diff --git a/src/dynarec/arm64_lock.S b/src/dynarec/arm64_lock.S new file mode 100755 index 00000000..ebe7f8ec --- /dev/null +++ b/src/dynarec/arm64_lock.S @@ -0,0 +1,87 @@ +//arm lock helper +//there is 2 part: read and write +// write return 0 on success, 1 on fail (value has been changed) + +.text +.align 4 + +.global arm64_lock_read_b +.global arm64_lock_write_b +.global arm64_lock_read_h +.global arm64_lock_write_h +.global arm64_lock_read_d +.global arm64_lock_write_d +.global arm64_lock_read_dd +.global arm64_lock_write_dd +.global arm64_lock_xchg +.global arm64_lock_storeifnull + + +arm64_lock_read_b: + // address is x0, return is x0 + ldaxrb w0, [x0] + ret + +arm64_lock_write_b: + // address is x0, value is x1, return is x0 + mov x2, x0 + stlxrb w0, w1, [x2] + ret + +arm64_lock_read_h: + // address is x0, return is x0 + ldaxrh w0, [x0] + ret + +arm64_lock_write_h: + // address is x0, value is x1, return is x0 + mov x2, x0 + stlxrh w0, w1, [x2] + ret + +arm64_lock_read_d: + // address is x0, return is x0 + #ldaxr w0, [x0] + ldr w0,[x0] + ret + +arm64_lock_write_d: + // address is x0, value is w1, return is x0 + mov x2, x0 + #stlxr w0, w1, [x2] + str w1, [x2] + mov w0, 0 + ret + +arm64_lock_read_dd: + // address is x0, return is x0 + ldaxr x0, [x0] + ret + +arm64_lock_write_dd: + // address is x0, value is x1, return is x0 + mov x2, x0 + stlxr w0, x1, [x2] + ret + +arm64_lock_xchg: + // address is x0, value is x1, return old value in x0 + ldaxr x2, [x0] + stlxr w3, x1, [x0] + cmp w3, #1 + beq arm64_lock_xchg + mov x0, x2 + ret + +arm64_lock_storeifnull: + // address is x0, value is x1, x1 store to x0 only if [x0] is 0. return new [x0] value (so x1 or old value) + ldaxr x2, [x0] + cmp x2, #0 + bne arm64_lock_storeifnull_exit + mov x2, x1 + stlxr w3, x2, [x0] + cmp w3, #1 + beq arm64_lock_storeifnull +arm64_lock_storeifnull_exit: + mov x0, x2 + ret diff --git a/src/dynarec/arm64_lock.h b/src/dynarec/arm64_lock.h new file mode 100755 index 00000000..12a57e7a --- /dev/null +++ b/src/dynarec/arm64_lock.h @@ -0,0 +1,31 @@ +#ifndef __ARM64_LOCK__H__ +#define __ARM64_LOCK__H__ +#include + +// LDAXRB of ADDR +extern uint8_t arm64_lock_read_b(void* addr); +// STLXRB of ADDR, return 0 if ok, 1 if not +extern int arm64_lock_write_b(void* addr, uint8_t val); + +// LDAXRH of ADDR +extern uint16_t arm64_lock_read_h(void* addr); +// STLXRH of ADDR, return 0 if ok, 1 if not +extern int arm64_lock_write_h(void* addr, uint16_t val); + +// LDAXR of ADDR +extern uint32_t arm64_lock_read_d(void* addr); +// STLXR of ADDR, return 0 if ok, 1 if not +extern int arm64_lock_write_d(void* addr, uint32_t val); + +// LDAXRD of ADDR +extern uint64_t arm64_lock_read_dd(void* addr); +// STLXR of ADDR, return 0 if ok, 1 if not +extern int arm64_lock_write_dd(void* addr, uint64_t val); + +// Atomicaly exchange value at [p] with val, return old p +extern uintptr_t arm64_lock_xchg(void* p, uintptr_t val); + +// Atomicaly store value to [p] only if [p] is NULL. Return new [p] value (so val or old) +extern void* arm64_lock_storeifnull(void*p, void* val); + +#endif //__ARM64_LOCK__H__ \ No newline at end of file diff --git a/src/dynarec/arm64_lock_helper.S b/src/dynarec/arm64_lock_helper.S deleted file mode 100755 index ebe7f8ec..00000000 --- a/src/dynarec/arm64_lock_helper.S +++ /dev/null @@ -1,87 +0,0 @@ -//arm lock helper -//there is 2 part: read and write -// write return 0 on success, 1 on fail (value has been changed) - -.text -.align 4 - -.global arm64_lock_read_b -.global arm64_lock_write_b -.global arm64_lock_read_h -.global arm64_lock_write_h -.global arm64_lock_read_d -.global arm64_lock_write_d -.global arm64_lock_read_dd -.global arm64_lock_write_dd -.global arm64_lock_xchg -.global arm64_lock_storeifnull - - -arm64_lock_read_b: - // address is x0, return is x0 - ldaxrb w0, [x0] - ret - -arm64_lock_write_b: - // address is x0, value is x1, return is x0 - mov x2, x0 - stlxrb w0, w1, [x2] - ret - -arm64_lock_read_h: - // address is x0, return is x0 - ldaxrh w0, [x0] - ret - -arm64_lock_write_h: - // address is x0, value is x1, return is x0 - mov x2, x0 - stlxrh w0, w1, [x2] - ret - -arm64_lock_read_d: - // address is x0, return is x0 - #ldaxr w0, [x0] - ldr w0,[x0] - ret - -arm64_lock_write_d: - // address is x0, value is w1, return is x0 - mov x2, x0 - #stlxr w0, w1, [x2] - str w1, [x2] - mov w0, 0 - ret - -arm64_lock_read_dd: - // address is x0, return is x0 - ldaxr x0, [x0] - ret - -arm64_lock_write_dd: - // address is x0, value is x1, return is x0 - mov x2, x0 - stlxr w0, x1, [x2] - ret - -arm64_lock_xchg: - // address is x0, value is x1, return old value in x0 - ldaxr x2, [x0] - stlxr w3, x1, [x0] - cmp w3, #1 - beq arm64_lock_xchg - mov x0, x2 - ret - -arm64_lock_storeifnull: - // address is x0, value is x1, x1 store to x0 only if [x0] is 0. return new [x0] value (so x1 or old value) - ldaxr x2, [x0] - cmp x2, #0 - bne arm64_lock_storeifnull_exit - mov x2, x1 - stlxr w3, x2, [x0] - cmp w3, #1 - beq arm64_lock_storeifnull -arm64_lock_storeifnull_exit: - mov x0, x2 - ret diff --git a/src/dynarec/arm64_lock_helper.h b/src/dynarec/arm64_lock_helper.h deleted file mode 100755 index a6879bea..00000000 --- a/src/dynarec/arm64_lock_helper.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __ARM64_LOCK_HELPER__H__ -#define __ARM64_LOCK_HELPER__H__ -#include - -// LDAXRB of ADDR -extern uint8_t arm64_lock_read_b(void* addr); -// STLXRB of ADDR, return 0 if ok, 1 if not -extern int arm64_lock_write_b(void* addr, uint8_t val); - -// LDAXRH of ADDR -extern uint16_t arm64_lock_read_h(void* addr); -// STLXRH of ADDR, return 0 if ok, 1 if not -extern int arm64_lock_write_h(void* addr, uint16_t val); - -// LDAXR of ADDR -extern uint32_t arm64_lock_read_d(void* addr); -// STLXR of ADDR, return 0 if ok, 1 if not -extern int arm64_lock_write_d(void* addr, uint32_t val); - -// LDAXRD of ADDR -extern uint64_t arm64_lock_read_dd(void* addr); -// STLXR of ADDR, return 0 if ok, 1 if not -extern int arm64_lock_write_dd(void* addr, uint64_t val); - -// Atomicaly exchange value at [p] with val, return old p -extern uintptr_t arm64_lock_xchg(void* p, uintptr_t val); - -// Atomicaly store value to [p] only if [p] is NULL. Return new [p] value (so val or old) -extern void* arm64_lock_storeifnull(void*p, void* val); - -#endif //__ARM64_LOCK_HELPER__H__ \ No newline at end of file diff --git a/src/dynarec/dynablock.c b/src/dynarec/dynablock.c index 06694e06..e92b7f0b 100755 --- a/src/dynarec/dynablock.c +++ b/src/dynarec/dynablock.c @@ -20,7 +20,7 @@ #include "elfloader.h" #ifdef ARM64 #include "dynarec_arm64.h" -#include "arm64_lock_helper.h" +#include "arm64_lock.h" #else #error Unsupported architecture! #endif diff --git a/src/emu/x64run.c b/src/emu/x64run.c index 19fa56e5..629bfe71 100755 --- a/src/emu/x64run.c +++ b/src/emu/x64run.c @@ -21,7 +21,7 @@ #include "bridge.h" #include "signals.h" #ifdef DYNAREC -#include "../dynarec/arm64_lock_helper.h" +#include "../dynarec/arm64_lock.h" #endif #include "modrm.h" diff --git a/src/emu/x64run0f.c b/src/emu/x64run0f.c index ec0048f4..45df3e22 100644 --- a/src/emu/x64run0f.c +++ b/src/emu/x64run0f.c @@ -22,7 +22,7 @@ #include "bridge.h" #include "signals.h" #ifdef DYNAREC -#include "../dynarec/arm64_lock_helper.h" +#include "../dynarec/arm64_lock.h" #endif #include "modrm.h" diff --git a/src/emu/x64run66.c b/src/emu/x64run66.c index 377ece8c..73eb5417 100644 --- a/src/emu/x64run66.c +++ b/src/emu/x64run66.c @@ -20,7 +20,7 @@ #include "box64context.h" #include "bridge.h" #ifdef DYNAREC -#include "../dynarec/arm64_lock_helper.h" +#include "../dynarec/arm64_lock.h" #endif #include "modrm.h" diff --git a/src/emu/x64runf0.c b/src/emu/x64runf0.c index faf1a109..b09fd3aa 100644 --- a/src/emu/x64runf0.c +++ b/src/emu/x64runf0.c @@ -21,7 +21,7 @@ #include "my_cpuid.h" #include "bridge.h" #ifdef DYNAREC -#include "../dynarec/arm64_lock_helper.h" +#include "../dynarec/arm64_lock.h" #endif #include "modrm.h" -- cgit 1.4.1