From ea8111cff5ead60d5773fe29c72a513c66004f00 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 25 Dec 2019 19:44:33 +0800 Subject: [PATCH] For #1537, support aarch64 for armv8. 3.0.84 --- README.md | 1 + trunk/3rdparty/st-srs/md.S | 102 ++++++++++++++++++++++++++++++++++-- trunk/3rdparty/st-srs/md.h | 6 +++ trunk/src/core/srs_core.hpp | 2 +- 4 files changed, 106 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c3a90d7b74..5f492fceaf 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2019-12-25, For [#1537][bug #1537], support aarch64 for armv8. 3.0.84 * v3.0, 2019-12-25, For [#1538][bug #1538], fresh chunk allow fmt=0 or fmt=1. 3.0.83 * v3.0, 2019-12-25, Remove FFMPEG and NGINX, please use [srs-docker](https://github.com/ossrs/srs-docker) instead. 3.0.82 * v3.0, 2019-12-25, For [#1537][bug #1537], remove cross-build, not used patches, directly build st. diff --git a/trunk/3rdparty/st-srs/md.S b/trunk/3rdparty/st-srs/md.S index 7aa5f5b1f6..cfabb438e2 100644 --- a/trunk/3rdparty/st-srs/md.S +++ b/trunk/3rdparty/st-srs/md.S @@ -463,6 +463,100 @@ +#elif defined(__aarch64__) + + /****************************************************************/ + + #define JB_X19 0 + #define JB_X20 1 + #define JB_X21 2 + #define JB_X22 3 + #define JB_X23 4 + #define JB_X24 5 + #define JB_X25 6 + #define JB_X26 7 + #define JB_X27 8 + #define JB_X28 9 + #define JB_X29 10 + #define JB_LR 11 + #define JB_SP 13 + + #define JB_D8 14 + #define JB_D9 15 + #define JB_D10 16 + #define JB_D11 17 + #define JB_D12 18 + #define JB_D13 19 + #define JB_D14 20 + #define JB_D15 21 + + .file "md.S" + .text + + /* _st_md_cxt_save(__jmp_buf env) */ + .globl _st_md_cxt_save + .type _st_md_cxt_save, %function + .align 4 + _st_md_cxt_save: + stp x19, x20, [x0, #JB_X19<<3] + stp x21, x22, [x0, #JB_X21<<3] + stp x23, x24, [x0, #JB_X23<<3] + stp x25, x26, [x0, #JB_X25<<3] + stp x27, x28, [x0, #JB_X27<<3] + stp x29, x30, [x0, #JB_X29<<3] + + stp d8, d9, [x0, #JB_D8<<3] + stp d10, d11, [x0, #JB_D10<<3] + stp d12, d13, [x0, #JB_D12<<3] + stp d14, d15, [x0, #JB_D14<<3] + mov x2, sp + str x2, [x0, #JB_SP<<3] + + mov x0, #0 + ret + .size _st_md_cxt_save, .-_st_md_cxt_save + + /****************************************************************/ + + /* _st_md_cxt_restore(__jmp_buf env, int val) */ + .globl _st_md_cxt_restore + .type _st_md_cxt_restore, %function + .align 4 + _st_md_cxt_restore: + ldp x19, x20, [x0, #JB_X19<<3] + ldp x21, x22, [x0, #JB_X21<<3] + ldp x23, x24, [x0, #JB_X23<<3] + ldp x25, x26, [x0, #JB_X25<<3] + ldp x27, x28, [x0, #JB_X27<<3] + + ldp x29, x30, [x0, #JB_X29<<3] + + ldp d8, d9, [x0, #JB_D8<<3] + ldp d10, d11, [x0, #JB_D10<<3] + ldp d12, d13, [x0, #JB_D12<<3] + ldp d14, d15, [x0, #JB_D14<<3] + + ldr x5, [x0, #JB_SP<<3] + mov sp, x5 + + cmp x1, #0 + mov x0, #1 + csel x0, x1, x0, ne + /* Use br instead of ret because ret is guaranteed to mispredict */ + br x30 + .size _st_md_cxt_restore, .-_st_md_cxt_restore + + /****************************************************************/ + + + + + + + + + + #elif defined(__arm__) /****************************************************************/ @@ -486,7 +580,7 @@ .size _st_md_cxt_save, .-_st_md_cxt_save /****************************************************************/ - + .globl _st_md_cxt_restore .type _st_md_cxt_restore, %function .align 2 @@ -495,13 +589,13 @@ movs r0, r1 // r1 -> return value // The bellow is a group, that is: // if (r0 == 0) r0 =1; - ITT eq + ITT eq moveq r0, #1 // long_jmp should never return 0 - + ldmia ip!, {v1-v6, sl, fp} // restore registers. ldr sp, [ip], #4 // restore sp, like: sp=*ip; ip+=4; ldr lr, [ip], #4 - bx lr + bx lr .size _st_md_cxt_restore, .-_st_md_cxt_restore /****************************************************************/ diff --git a/trunk/3rdparty/st-srs/md.h b/trunk/3rdparty/st-srs/md.h index 115e6fdce4..dc4ef54c90 100644 --- a/trunk/3rdparty/st-srs/md.h +++ b/trunk/3rdparty/st-srs/md.h @@ -418,6 +418,12 @@ #endif #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_RSP] + #elif defined(__aarch64__) + /* https://github.com/ossrs/state-threads/issues/9 */ + #define MD_STACK_GROWS_DOWN + #define MD_USE_BUILTIN_SETJMP + #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[13] + #elif defined(__arm__) #define MD_STACK_GROWS_DOWN /* https://github.com/ossrs/state-threads/issues/1#issuecomment-244648573 */ diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index e9114f6ef7..d27ecb6893 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 83 +#define VERSION_REVISION 84 // The macros generated by configure script. #include