Skip to content

Commit e94dc41

Browse files
committed
LoongArch: Add Loongson Binary Translation syscall support
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent a72dd44 commit e94dc41

10 files changed

Lines changed: 1288 additions & 1 deletion

File tree

arch/loongarch/include/asm/errno.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* This file is subject to the terms and conditions of the GNU General Public
4+
* License. See the file "COPYING" in the main directory of this archive
5+
* for more details.
6+
*
7+
* Copyright (C) 1995, 1999, 2001, 2002 by Ralf Baechle
8+
* Copyright (C) 2020 Loongson Technology Co., Ltd.
9+
*/
10+
#ifndef _ASM_ERRNO_H
11+
#define _ASM_ERRNO_H
12+
13+
#include <uapi/asm/errno.h>
14+
15+
16+
/* The biggest error number defined here or in <linux/errno.h>. */
17+
#define EMAXERRNO 1133
18+
19+
#endif /* _ASM_ERRNO_H */
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2020 Loongson Technology Corporation Limited
4+
* Authors: Hanlu Li <lihanlu@loongson.cn>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License version 2 as
8+
* published by the Free Software Foundation.
9+
*/
10+
#ifndef _TRANS_MIPS_SYSCALLS_H
11+
#define _TRANS_MIPS_SYSCALLS_H
12+
13+
#define M_ENOMSG 35
14+
#define M_EIDRM 36
15+
#define M_ECHRNG 37
16+
#define M_EL2NSYNC 38
17+
#define M_EL3HLT 39
18+
#define M_EL3RST 40
19+
#define M_ELNRNG 41
20+
#define M_EUNATCH 42
21+
#define M_ENOCSI 43
22+
#define M_EL2HLT 44
23+
#define M_EDEADLK 45
24+
#define M_ENOLCK 46
25+
#define M_EBADE 50
26+
#define M_EBADR 51
27+
#define M_EXFULL 52
28+
#define M_ENOANO 53
29+
#define M_EBADRQC 54
30+
#define M_EBADSLT 55
31+
#define M_EBFONT 59
32+
#define M_ENOSTR 60
33+
#define M_ENODATA 61
34+
#define M_ETIME 62
35+
#define M_ENOSR 63
36+
#define M_ENONET 64
37+
#define M_ENOPKG 65
38+
#define M_EREMOTE 66
39+
#define M_ENOLINK 67
40+
#define M_EADV 68
41+
#define M_ESRMNT 69
42+
#define M_ECOMM 70
43+
#define M_EPROTO 71
44+
#define M_EDOTDOT 73
45+
#define M_EMULTIHOP 74
46+
#define M_EBADMSG 77
47+
#define M_ENAMETOOLONG 78
48+
#define M_EOVERFLOW 79
49+
#define M_ENOTUNIQ 80
50+
#define M_EBADFD 81
51+
#define M_EREMCHG 82
52+
#define M_ELIBACC 83
53+
#define M_ELIBBAD 84
54+
#define M_ELIBSCN 85
55+
#define M_ELIBMAX 86
56+
#define M_ELIBEXEC 87
57+
#define M_EILSEQ 88
58+
#define M_ENOSYS 89
59+
#define M_ELOOP 90
60+
#define M_ERESTART 91
61+
#define M_ESTRPIPE 92
62+
#define M_ENOTEMPTY 93
63+
#define M_EUSERS 94
64+
#define M_ENOTSOCK 95
65+
#define M_EDESTADDRREQ 96
66+
#define M_EMSGSIZE 97
67+
#define M_EPROTOTYPE 98
68+
#define M_ENOPROTOOPT 99
69+
#define M_EPROTONOSUPPORT 120
70+
#define M_ESOCKTNOSUPPORT 121
71+
#define M_EOPNOTSUPP 122
72+
#define M_EPFNOSUPPORT 123
73+
#define M_EAFNOSUPPORT 124
74+
#define M_EADDRINUSE 125
75+
#define M_EADDRNOTAVAIL 126
76+
#define M_ENETDOWN 127
77+
#define M_ENETUNREACH 128
78+
#define M_ENETRESET 129
79+
#define M_ECONNABORTED 130
80+
#define M_ECONNRESET 131
81+
#define M_ENOBUFS 132
82+
#define M_EISCONN 133
83+
#define M_ENOTCONN 134
84+
#define M_EUCLEAN 135
85+
#define M_ENOTNAM 137
86+
#define M_ENAVAIL 138
87+
#define M_EISNAM 139
88+
#define M_EREMOTEIO 140
89+
#define M_ESHUTDOWN 143
90+
#define M_ETOOMANYREFS 144
91+
#define M_ETIMEDOUT 145
92+
#define M_ECONNREFUSED 146
93+
#define M_EHOSTDOWN 147
94+
#define M_EHOSTUNREACH 148
95+
#define M_EALREADY 149
96+
#define M_EINPROGRESS 150
97+
#define M_ESTALE 151
98+
#define M_ECANCELED 158
99+
#define M_ENOMEDIUM 159
100+
#define M_EMEDIUMTYPE 160
101+
#define M_ENOKEY 161
102+
#define M_EKEYEXPIRED 162
103+
#define M_EKEYREVOKED 163
104+
#define M_EKEYREJECTED 164
105+
#define M_EOWNERDEAD 165
106+
#define M_ENOTRECOVERABLE 166
107+
#define M_ERFKILL 167
108+
#define M_EHWPOISON 168
109+
#define M_EDQUOT 1133
110+
#endif /* _TRANS_MIPS_SYSCALLS_H */
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2020 Loongson Technology Corporation Limited
4+
* Authors: Hanlu Li <lihanlu@loongson.cn>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License version 2 as
8+
* published by the Free Software Foundation.
9+
*/
10+
#ifndef _TRANS_SYSCALLS_H_
11+
#define _TRANS_SYSCALLS_H_
12+
#include <asm/trans_mips_syscalls.h>
13+
#endif

arch/loongarch/include/asm/unistd.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,19 @@
1212
#define __ARCH_WANT_SYS_CLONE
1313

1414
#define NR_syscalls (__NR_syscalls)
15+
16+
/* for binary translation */
17+
#if defined(CONFIG_CPU_HAS_LBT)
18+
#define __ARCH_WANT_SYS_ALARM
19+
#define __ARCH_WANT_SYS_GETPGRP
20+
21+
#define __NR_MIPS64_Linux 5000
22+
#define __NR_MIPS64_Linux_syscalls 329
23+
#define __NR_i386_Linux_syscalls 386
24+
25+
#define TRANS_MIPS_N64 0x010000
26+
#define TRANS_I386 0x100000
27+
#define TRANS_X64 0x110000
28+
#define TRANS_ARCH_MASK 0xffff0000
29+
#define SYS_NUM_MASK 0xffff
30+
#endif

arch/loongarch/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ obj-$(CONFIG_EFI) += efi.o
1717

1818
obj-$(CONFIG_CPU_HAS_FPU) += fpu.o kfpu.o
1919

20-
obj-$(CONFIG_CPU_HAS_LBT) += lbt.o
20+
obj-$(CONFIG_CPU_HAS_LBT) += lbt.o scall-trans-mips64.o trans_mips_syscalls.o scall-trans-i386.o trans_i386_syscalls.o
2121

2222
obj-$(CONFIG_ARCH_STRICT_ALIGN) += unaligned.o
2323

0 commit comments

Comments
 (0)