Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
add loongarch64 architecture support
Author: xiaojuanZhai <zhaixiaojuan@loongson.cn> Author: meidanLi <limeidan@loongson.cn> Author: guoqiChen <chenguoqi@loongson.cn> Author: xiaolinZhao <zhaoxiaolin@loongson.cn> Author: Fanpeng <fanpeng@loongson.cn> Author: jiantaoShan <shanjiantao@loongson.cn> Author: xuhuiQiang <qiangxuhui@loongson.cn> Author: jingyunHua <huajingyun@loongson.cn> This port has involved the work of many people. I have tried to ensure that everyone with substantial contributions have been credited above; if any omissions are found they will be noted later in an update to the authors/contributors list in the COPYRIGHT file. Signed-off-by: zhaixiaojuan <zhaixiaojuan@loongson.cn>
- Loading branch information
Showing
39 changed files
with
1,353 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #define LLSC_M "m" | ||
|
|
||
| #define a_ll a_ll | ||
| static inline int a_ll(volatile int *p) | ||
| { | ||
| int v; | ||
| __asm__ __volatile__ ( | ||
| "ll.w %0, %1" | ||
| : "=r"(v) : LLSC_M(*p)); | ||
| return v; | ||
| } | ||
|
|
||
| #define a_sc a_sc | ||
| static inline int a_sc(volatile int *p, int v) | ||
| { | ||
| int r; | ||
| __asm__ __volatile__ ( | ||
| "sc.w %0, %1" | ||
| : "=r"(r), "="LLSC_M(*p) : "0"(v) : "memory"); | ||
| return r; | ||
| } | ||
|
|
||
| #define a_ll_p a_ll_p | ||
| static inline void *a_ll_p(volatile void *p) | ||
| { | ||
| void *v; | ||
| __asm__ __volatile__ ( | ||
| "ll.d %0, %1" | ||
| : "=r"(v) : LLSC_M(*(void *volatile *)p)); | ||
| return v; | ||
| } | ||
|
|
||
| #define a_sc_p a_sc_p | ||
| static inline int a_sc_p(volatile void *p, void *v) | ||
| { | ||
| long r; | ||
| __asm__ __volatile__ ( | ||
| "sc.d %0, %1" | ||
| : "=r"(r), "="LLSC_M(*(void *volatile *)p) : "0"(v) : "memory"); | ||
| return r; | ||
| } | ||
|
|
||
| #define a_barrier a_barrier | ||
| static inline void a_barrier() | ||
| { | ||
| __asm__ __volatile__ ("dbar 0" : : : "memory"); | ||
| } | ||
|
|
||
| #define a_pre_llsc a_barrier | ||
| #define a_post_llsc a_barrier | ||
|
|
||
| #undef LLSC_M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #define _Addr long | ||
| #define _Int64 long | ||
| #define _Reg long | ||
|
|
||
| #define __BYTE_ORDER 1234 | ||
| #define __LONG_MAX 0x7fffffffffffffffL | ||
|
|
||
| TYPEDEF __builtin_va_list va_list; | ||
| TYPEDEF __builtin_va_list __isoc_va_list; | ||
|
|
||
| #ifndef __cplusplus | ||
| TYPEDEF int wchar_t; | ||
| #endif | ||
|
|
||
| TYPEDEF float float_t; | ||
| TYPEDEF double double_t; | ||
|
|
||
| TYPEDEF struct { long long __ll; long double __ld; } max_align_t; | ||
|
|
||
| TYPEDEF unsigned nlink_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #define O_CREAT 0100 | ||
| #define O_EXCL 0200 | ||
| #define O_NOCTTY 0400 | ||
| #define O_TRUNC 01000 | ||
| #define O_APPEND 02000 | ||
| #define O_NONBLOCK 04000 | ||
| #define O_DSYNC 010000 | ||
| #define O_SYNC 04010000 | ||
| #define O_RSYNC 04010000 | ||
| #define O_DIRECTORY 0200000 | ||
| #define O_NOFOLLOW 0400000 | ||
| #define O_CLOEXEC 02000000 | ||
|
|
||
| #define O_ASYNC 020000 | ||
| #define O_DIRECT 040000 | ||
| #define O_LARGEFILE 0100000 | ||
| #define O_NOATIME 01000000 | ||
| #define O_PATH 010000000 | ||
| #define O_TMPFILE 020000000 | ||
| #define O_NDELAY O_NONBLOCK | ||
|
|
||
| #define F_DUPFD 0 | ||
| #define F_GETFD 1 | ||
| #define F_SETFD 2 | ||
| #define F_GETFL 3 | ||
| #define F_SETFL 4 | ||
|
|
||
| #define F_SETOWN 8 | ||
| #define F_GETOWN 9 | ||
| #define F_SETSIG 10 | ||
| #define F_GETSIG 11 | ||
|
|
||
| #define F_GETLK 5 | ||
| #define F_SETLK 6 | ||
| #define F_SETLKW 7 | ||
|
|
||
| #define F_SETOWN_EX 15 | ||
| #define F_GETOWN_EX 16 | ||
|
|
||
| #define F_GETOWNER_UIDS 17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #ifdef __loongarch_soft_float | ||
| #define FE_ALL_EXCEPT 0 | ||
| #define FE_TONEAREST 0 | ||
| #else | ||
| #define FE_INEXACT 0x010000 | ||
| #define FE_UNDERFLOW 0x020000 | ||
| #define FE_OVERFLOW 0x040000 | ||
| #define FE_DIVBYZERO 0x080000 | ||
| #define FE_INVALID 0x100000 | ||
|
|
||
| #define FE_ALL_EXCEPT 0x1F0000 | ||
|
|
||
| #define FE_TONEAREST 0x000 | ||
| #define FE_TOWARDZERO 0x100 | ||
| #define FE_UPWARD 0x200 | ||
| #define FE_DOWNWARD 0x300 | ||
| #endif | ||
|
|
||
| typedef unsigned fexcept_t; | ||
|
|
||
| typedef struct { | ||
| unsigned __cw; | ||
| } fenv_t; | ||
|
|
||
| #define FE_DFL_ENV ((const fenv_t *) -1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #define FLT_EVAL_METHOD 0 | ||
|
|
||
| #define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L | ||
| #define LDBL_MIN 3.36210314311209350626267781732175260e-4932L | ||
| #define LDBL_MAX 1.18973149535723176508575932662800702e+4932L | ||
| #define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L | ||
|
|
||
| #define LDBL_MANT_DIG 113 | ||
| #define LDBL_MIN_EXP (-16381) | ||
| #define LDBL_MAX_EXP 16384 | ||
|
|
||
| #define LDBL_DIG 33 | ||
| #define LDBL_MIN_10_EXP (-4931) | ||
| #define LDBL_MAX_10_EXP 4932 | ||
|
|
||
| #define DECIMAL_DIG 36 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* HWCAP - Hardware Capabilities | ||
| * Hardware information is not clear at present, leave it blank. | ||
| */ | ||
| #define HWCAP_LOONGARCH_CPUCFG (1 << 0) | ||
| #define HWCAP_LOONGARCH_FPU (1 << 1) | ||
| #define HWCAP_LOONGARCH_LSX (1 << 2) /* support 128bit vectors*/ | ||
| #define HWCAP_LOONGARCH_LASX (1 << 3) /* support 256bit vectors*/ | ||
| #define HWCAP_LOONGARCH_LBT (1 << 4) /* support LBT*/ | ||
| #define HWCAP_LOONGARCH_LVZ (1 << 5) /* support virtualization expansion*/ | ||
| #define HWCAP_LOONGARCH_CRC32 (1 << 7) /* support CRC32 check*/ | ||
| #define HWCAP_LOONGARCH_AES (1 << 6) | ||
| #define HWCAP_LOONGARCH_SHA1 (1 << 8) | ||
| #define HWCAP_LOONGARCH_SHA2 (1 << 9) | ||
| #define HWCAP_LOONGARCH_SHA3 (1 << 10) | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #define _POSIX_V6_LP64_OFF64 1 | ||
| #define _POSIX_V7_LP64_OFF64 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #define PTRACE_GET_THREAD_AREA 25 | ||
| #define PTRACE_SET_THREAD_AREA 26 | ||
| #define PTRACE_GET_WATCH_REGS 0xd0 | ||
| #define PTRACE_SET_WATCH_REGS 0xd1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #undef __WORDSIZE | ||
| #define __WORDSIZE 64 | ||
| #define LOONGARCH64_EF_R0 0 | ||
| #define LOONGARCH64_EF_R1 1 | ||
| #define LOONGARCH64_EF_R2 2 | ||
| #define LOONGARCH64_EF_R3 3 | ||
| #define LOONGARCH64_EF_R4 4 | ||
| #define LOONGARCH64_EF_R5 5 | ||
| #define LOONGARCH64_EF_R6 6 | ||
| #define LOONGARCH64_EF_R7 7 | ||
| #define LOONGARCH64_EF_R8 8 | ||
| #define LOONGARCH64_EF_R9 9 | ||
| #define LOONGARCH64_EF_R10 10 | ||
| #define LOONGARCH64_EF_R11 11 | ||
| #define LOONGARCH64_EF_R12 12 | ||
| #define LOONGARCH64_EF_R13 13 | ||
| #define LOONGARCH64_EF_R14 14 | ||
| #define LOONGARCH64_EF_R15 15 | ||
| #define LOONGARCH64_EF_R16 16 | ||
| #define LOONGARCH64_EF_R17 17 | ||
| #define LOONGARCH64_EF_R18 18 | ||
| #define LOONGARCH64_EF_R19 19 | ||
| #define LOONGARCH64_EF_R20 20 | ||
| #define LOONGARCH64_EF_R21 21 | ||
| #define LOONGARCH64_EF_R22 22 | ||
| #define LOONGARCH64_EF_R23 23 | ||
| #define LOONGARCH64_EF_R24 24 | ||
| #define LOONGARCH64_EF_R25 25 | ||
| #define LOONGARCH64_EF_R26 26 | ||
| #define LOONGARCH64_EF_R27 27 | ||
| #define LOONGARCH64_EF_R28 28 | ||
| #define LOONGARCH64_EF_R29 29 | ||
| #define LOONGARCH64_EF_R30 30 | ||
| #define LOONGARCH64_EF_R31 31 | ||
|
|
||
| #define LOONGARCH64_EF_SIZE 304 /* size in bytes */ | ||
|
|
||
| #define EF_R0 LOONGARCH64_EF_R0 | ||
| #define EF_R1 LOONGARCH64_EF_R1 | ||
| #define EF_R2 LOONGARCH64_EF_R2 | ||
| #define EF_R3 LOONGARCH64_EF_R3 | ||
| #define EF_R4 LOONGARCH64_EF_R4 | ||
| #define EF_R5 LOONGARCH64_EF_R5 | ||
| #define EF_R6 LOONGARCH64_EF_R6 | ||
| #define EF_R7 LOONGARCH64_EF_R7 | ||
| #define EF_R8 LOONGARCH64_EF_R8 | ||
| #define EF_R9 LOONGARCH64_EF_R9 | ||
| #define EF_R10 LOONGARCH64_EF_R10 | ||
| #define EF_R11 LOONGARCH64_EF_R11 | ||
| #define EF_R12 LOONGARCH64_EF_R12 | ||
| #define EF_R13 LOONGARCH64_EF_R13 | ||
| #define EF_R14 LOONGARCH64_EF_R14 | ||
| #define EF_R15 LOONGARCH64_EF_R15 | ||
| #define EF_R16 LOONGARCH64_EF_R16 | ||
| #define EF_R17 LOONGARCH64_EF_R17 | ||
| #define EF_R18 LOONGARCH64_EF_R18 | ||
| #define EF_R19 LOONGARCH64_EF_R19 | ||
| #define EF_R20 LOONGARCH64_EF_R20 | ||
| #define EF_R21 LOONGARCH64_EF_R21 | ||
| #define EF_R22 LOONGARCH64_EF_R22 | ||
| #define EF_R23 LOONGARCH64_EF_R23 | ||
| #define EF_R24 LOONGARCH64_EF_R24 | ||
| #define EF_R25 LOONGARCH64_EF_R25 | ||
| #define EF_R26 LOONGARCH64_EF_R26 | ||
| #define EF_R27 LOONGARCH64_EF_R27 | ||
| #define EF_R28 LOONGARCH64_EF_R28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #define RLIMIT_NOFILE 7 /* num of file limit, able to open file */ | ||
| #define RLIMIT_AS 9 /* address space limit */ | ||
| #define RLIMIT_RSS 5 /* max resident set size */ | ||
| #define RLIMIT_NPROC 6 /* max number of processes */ | ||
| #define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| typedef unsigned long long __jmp_buf[22]; |
Oops, something went wrong.