Skip to content

Commit 9a81a0e

Browse files
virtualabsamaanq
authored andcommitted
Squashed commit of unicorn-engine#1918
1 parent cbdd83b commit 9a81a0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+13663
-17
lines changed

CMakeLists.txt

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ option(UNICORN_FUZZ "Enable fuzzing" OFF)
8686
option(UNICORN_LOGGING "Enable logging" OFF)
8787
option(UNICORN_BUILD_TESTS "Build unicorn tests" ${PROJECT_IS_TOP_LEVEL})
8888
option(UNICORN_INSTALL "Enable unicorn installation" ${PROJECT_IS_TOP_LEVEL})
89-
set(UNICORN_ARCH "x86;arm;aarch64;riscv;mips;sparc;m68k;ppc;s390x;tricore;avr" CACHE STRING "Enabled unicorn architectures")
89+
set(UNICORN_ARCH "x86;arm;aarch64;riscv;mips;sparc;m68k;ppc;rh850;s390x;tricore;avr" CACHE STRING "Enabled unicorn architectures")
9090
option(UNICORN_TRACER "Trace unicorn execution" OFF)
9191
option(UNICORN_INTERPRETER "Use interpreter mode" OFF)
9292

@@ -309,6 +309,9 @@ else()
309309
if(UNICORN_HAS_PPC)
310310
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_PPC ")
311311
endif()
312+
if(UNICORN_HAS_RH850)
313+
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_RH850 ")
314+
endif()
312315
if(UNICORN_HAS_RISCV)
313316
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_RISCV ")
314317
endif()
@@ -363,6 +366,9 @@ else()
363366
if(UNICORN_HAS_PPC)
364367
set(TARGET_LIST "${TARGET_LIST}ppc-softmmu, ppc64-softmmu, ")
365368
endif()
369+
if(UNICORN_HAS_RH850)
370+
set(TARGET_LIST "${TARGET_LIST}rh850-softmmu, ")
371+
endif()
366372
if(UNICORN_HAS_RISCV)
367373
set(TARGET_LIST "${TARGET_LIST}riscv32-softmmu, riscv64-softmmu, ")
368374
endif()
@@ -457,6 +463,12 @@ else()
457463
OUTPUT_FILE ${CMAKE_BINARY_DIR}/ppc64-softmmu/config-target.h
458464
)
459465
endif()
466+
if(UNICORN_HAS_RH850)
467+
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
468+
INPUT_FILE ${CMAKE_BINARY_DIR}/rh850-softmmu/config-target.mak
469+
OUTPUT_FILE ${CMAKE_BINARY_DIR}/rh850-softmmu/config-target.h
470+
)
471+
endif()
460472
if(UNICORN_HAS_RISCV)
461473
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/create_config
462474
INPUT_FILE ${CMAKE_BINARY_DIR}/riscv32-softmmu/config-target.mak
@@ -1219,6 +1231,37 @@ endif()
12191231
endif()
12201232

12211233

1234+
if (UNICORN_HAS_RH850)
1235+
add_library(rh850-softmmu STATIC
1236+
${UNICORN_ARCH_COMMON}
1237+
1238+
qemu/target/rh850/cpu.c
1239+
qemu/target/rh850/fpu_helper.c
1240+
qemu/target/rh850/helper.c
1241+
qemu/target/rh850/op_helper.c
1242+
qemu/target/rh850/translate.c
1243+
qemu/target/rh850/fpu_translate.c
1244+
qemu/target/rh850/unicorn.c
1245+
)
1246+
1247+
1248+
if(MSVC)
1249+
target_compile_options(rh850-softmmu PRIVATE
1250+
-DNEED_CPU_H
1251+
/FIrh850.h
1252+
/I${CMAKE_CURRENT_SOURCE_DIR}/msvc/rh850-softmmu
1253+
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/rh850
1254+
)
1255+
else()
1256+
target_compile_options(rh850-softmmu PRIVATE
1257+
-DNEED_CPU_H
1258+
-include rh850.h
1259+
-I${CMAKE_BINARY_DIR}/rh850-softmmu
1260+
-I${CMAKE_CURRENT_SOURCE_DIR}/qemu/target/rh850
1261+
)
1262+
endif()
1263+
endif()
1264+
12221265
set(UNICORN_SRCS
12231266
uc.c
12241267

@@ -1371,6 +1414,13 @@ if(UNICORN_HAS_PPC)
13711414
target_link_libraries(ppc64-softmmu PRIVATE unicorn-common)
13721415
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_ppc)
13731416
endif()
1417+
if(UNICORN_HAS_RH850)
1418+
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_RH850)
1419+
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} rh850-softmmu rh850-softmmu)
1420+
set(UNICORN_SAMPLE_FILE ${UNICORN_SAMPLE_FILE} sample_rh850)
1421+
target_link_libraries(rh850-softmmu PRIVATE unicorn-common)
1422+
set(UNICORN_TEST_FILE ${UNICORN_TEST_FILE} test_rh850)
1423+
endif()
13741424
if(UNICORN_HAS_RISCV)
13751425
set(UNICORN_COMPILE_OPTIONS ${UNICORN_COMPILE_OPTIONS} -DUNICORN_HAS_RISCV)
13761426
set(UNICORN_LINK_LIBRARIES ${UNICORN_LINK_LIBRARIES} riscv32-softmmu riscv64-softmmu)

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pkg-config = { version = "0.3" }
4242
[features]
4343
default = ["arch_all"]
4444
dynamic_linkage = []
45-
arch_all = ["arch_x86", "arch_arm", "arch_aarch64", "arch_riscv", "arch_mips", "arch_sparc", "arch_m68k", "arch_ppc", "arch_s390x", "arch_tricore", "arch_avr"]
45+
arch_all = ["arch_x86", "arch_arm", "arch_aarch64", "arch_riscv", "arch_mips", "arch_sparc", "arch_m68k", "arch_ppc", "arch_rh850", "arch_s390x", "arch_tricore", "arch_avr"]
4646
arch_x86 = []
4747
arch_arm = []
4848
# NOTE: unicorn-c only separates on top-level arch name,
@@ -56,3 +56,4 @@ arch_ppc = []
5656
arch_s390x = []
5757
arch_tricore = []
5858
arch_avr = []
59+
arch_rh850 = []

bindings/const_generator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
INCL_DIR = os.path.join('..', 'include', 'unicorn')
88

9-
include = [ 'arm.h', 'arm64.h', 'avr.h', 'mips.h', 'x86.h', 'sparc.h', 'm68k.h', 'ppc.h', 'riscv.h', 's390x.h', 'tricore.h', 'unicorn.h' ]
9+
include = [ 'arm.h', 'arm64.h', 'avr.h', 'mips.h', 'x86.h', 'sparc.h', 'm68k.h', 'ppc.h', 'rh850.h', 'riscv.h', 's390x.h', 'tricore.h', 'unicorn.h' ]
1010

1111
template = {
1212
'python': {
@@ -23,6 +23,7 @@
2323
'sparc.h': 'sparc',
2424
'm68k.h': 'm68k',
2525
'ppc.h': 'ppc',
26+
'rh850.h': 'rh850',
2627
'riscv.h': 'riscv',
2728
's390x.h' : 's390x',
2829
'tricore.h' : 'tricore',
@@ -45,6 +46,7 @@
4546
'm68k.h': 'm68k',
4647
'ppc.h': 'ppc',
4748
'riscv.h': 'riscv',
49+
'rh850.h': 'rh850',
4850
's390x.h' : 's390x',
4951
'tricore.h' : 'tricore',
5052
'unicorn.h': 'unicorn',
@@ -65,6 +67,7 @@
6567
'sparc.h': 'sparc',
6668
'm68k.h': 'm68k',
6769
'ppc.h': 'ppc',
70+
'rh850.h': 'rh850',
6871
'riscv.h': 'riscv',
6972
's390x.h' : 's390x',
7073
'tricore.h' : 'tricore',
@@ -86,6 +89,7 @@
8689
'sparc.h': 'Sparc',
8790
'm68k.h': 'M68k',
8891
'ppc.h': 'Ppc',
92+
'rh850.h': 'Rh850',
8993
'riscv.h': 'Riscv',
9094
's390x.h' : 'S390x',
9195
'tricore.h' : 'TriCore',
@@ -107,6 +111,7 @@
107111
'sparc.h': 'Sparc',
108112
'm68k.h': 'M68k',
109113
'ppc.h': 'Ppc',
114+
'rh850.h': 'Rh850',
110115
'riscv.h': 'Riscv',
111116
's390x.h' : 'S390x',
112117
'tricore.h' : 'TriCore',
@@ -128,6 +133,7 @@
128133
'sparc.h': 'Sparc',
129134
'm68k.h': 'M68k',
130135
'ppc.h': 'Ppc',
136+
'rh850.h': 'Rh850',
131137
'riscv.h': 'Riscv',
132138
's390x.h' : 'S390x',
133139
'tricore.h' : 'TriCore',
@@ -150,6 +156,7 @@
150156
'm68k.h': 'm68k',
151157
'ppc.h': 'ppc',
152158
'riscv.h': 'riscv',
159+
'rh850.h': 'rh850',
153160
's390x.h' : 's390x',
154161
'tricore.h' : 'tricore',
155162
'unicorn.h': 'unicorn',

bindings/dotnet/UnicornEngine/Const/Common.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ module Common =
2727
let UC_ARCH_S390X = 9
2828
let UC_ARCH_TRICORE = 10
2929
let UC_ARCH_AVR = 11
30-
let UC_ARCH_MAX = 12
30+
let UC_ARCH_RH850 = 12
31+
let UC_ARCH_MAX = 13
3132

3233
let UC_MODE_LITTLE_ENDIAN = 0
3334
let UC_MODE_BIG_ENDIAN = 1073741824
@@ -54,6 +55,7 @@ module Common =
5455
let UC_MODE_SPARC32 = 4
5556
let UC_MODE_SPARC64 = 8
5657
let UC_MODE_V9 = 16
58+
let UC_MODE_RH850 = 4
5759
let UC_MODE_RISCV32 = 4
5860
let UC_MODE_RISCV64 = 8
5961

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT
2+
3+
namespace UnicornManaged.Const
4+
5+
open System
6+
7+
[<AutoOpen>]
8+
module Rh850 =
9+
let UC_RH850_SYSREG_SELID0 = 32
10+
let UC_RH850_SYSREG_SELID1 = 64
11+
let UC_RH850_SYSREG_SELID2 = 96
12+
let UC_RH850_SYSREG_SELID3 = 128
13+
let UC_RH850_SYSREG_SELID4 = 160
14+
let UC_RH850_SYSREG_SELID5 = 192
15+
let UC_RH850_SYSREG_SELID6 = 224
16+
let UC_RH850_SYSREG_SELID7 = 256
17+
18+
// RH850 global purpose registers
19+
20+
let UC_RH850_REG_R0 = 0
21+
let UC_RH850_REG_R1 = 1
22+
let UC_RH850_REG_R2 = 2
23+
let UC_RH850_REG_R3 = 3
24+
let UC_RH850_REG_R4 = 4
25+
let UC_RH850_REG_R5 = 5
26+
let UC_RH850_REG_R6 = 6
27+
let UC_RH850_REG_R7 = 7
28+
let UC_RH850_REG_R8 = 8
29+
let UC_RH850_REG_R9 = 9
30+
let UC_RH850_REG_R10 = 10
31+
let UC_RH850_REG_R11 = 11
32+
let UC_RH850_REG_R12 = 12
33+
let UC_RH850_REG_R13 = 13
34+
let UC_RH850_REG_R14 = 14
35+
let UC_RH850_REG_R15 = 15
36+
let UC_RH850_REG_R16 = 16
37+
let UC_RH850_REG_R17 = 17
38+
let UC_RH850_REG_R18 = 18
39+
let UC_RH850_REG_R19 = 19
40+
let UC_RH850_REG_R20 = 20
41+
let UC_RH850_REG_R21 = 21
42+
let UC_RH850_REG_R22 = 22
43+
let UC_RH850_REG_R23 = 23
44+
let UC_RH850_REG_R24 = 24
45+
let UC_RH850_REG_R25 = 25
46+
let UC_RH850_REG_R26 = 26
47+
let UC_RH850_REG_R27 = 27
48+
let UC_RH850_REG_R28 = 28
49+
let UC_RH850_REG_R29 = 29
50+
let UC_RH850_REG_R30 = 30
51+
let UC_RH850_REG_R31 = 31
52+
53+
// RH850 system registers, selection ID 0
54+
let UC_RH850_REG_EIPC = 32
55+
let UC_RH850_REG_EIPSW = 33
56+
let UC_RH850_REG_FEPC = 34
57+
let UC_RH850_REG_FEPSW = 35
58+
let UC_RH850_REG_ECR = 36
59+
let UC_RH850_REG_PSW = 37
60+
let UC_RH850_REG_FPSR = 38
61+
let UC_RH850_REG_FPEPC = 39
62+
let UC_RH850_REG_FPST = 40
63+
let UC_RH850_REG_FPCC = 41
64+
let UC_RH850_REG_FPCFG = 42
65+
let UC_RH850_REG_FPEC = 43
66+
let UC_RH850_REG_EIIC = 45
67+
let UC_RH850_REG_FEIC = 46
68+
let UC_RH850_REG_CTPC = 48
69+
let UC_RH850_REG_CTPSW = 49
70+
let UC_RH850_REG_CTBP = 52
71+
let UC_RH850_REG_EIWR = 60
72+
let UC_RH850_REG_FEWR = 61
73+
let UC_RH850_REG_BSEL = 63
74+
75+
// RH850 system regusters, selection ID 1
76+
let UC_RH850_REG_MCFG0 = 64
77+
let UC_RH850_REG_RBASE = 65
78+
let UC_RH850_REG_EBASE = 66
79+
let UC_RH850_REG_INTBP = 67
80+
let UC_RH850_REG_MCTL = 68
81+
let UC_RH850_REG_PID = 69
82+
let UC_RH850_REG_SCCFG = 75
83+
let UC_RH850_REG_SCBP = 76
84+
85+
// RH850 system registers, selection ID 2
86+
let UC_RH850_REG_HTCFG0 = 96
87+
let UC_RH850_REG_MEA = 102
88+
let UC_RH850_REG_ASID = 103
89+
let UC_RH850_REG_MEI = 104
90+
let UC_RH850_REG_PC = 288
91+
let UC_RH850_REG_ENDING = 289
92+
93+
// RH8509 Registers aliases.
94+
95+
let UC_RH850_REG_ZERO = 0
96+
let UC_RH850_REG_SP = 3
97+
let UC_RH850_REG_EP = 30
98+
let UC_RH850_REG_LP = 31
99+

bindings/go/unicorn/rh850_const.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package unicorn
2+
// For Unicorn Engine. AUTO-GENERATED FILE, DO NOT EDIT [rh850_const.go]
3+
const (
4+
RH850_SYSREG_SELID0 = 32
5+
RH850_SYSREG_SELID1 = 64
6+
RH850_SYSREG_SELID2 = 96
7+
RH850_SYSREG_SELID3 = 128
8+
RH850_SYSREG_SELID4 = 160
9+
RH850_SYSREG_SELID5 = 192
10+
RH850_SYSREG_SELID6 = 224
11+
RH850_SYSREG_SELID7 = 256
12+
13+
// RH850 global purpose registers
14+
15+
RH850_REG_R0 = 0
16+
RH850_REG_R1 = 1
17+
RH850_REG_R2 = 2
18+
RH850_REG_R3 = 3
19+
RH850_REG_R4 = 4
20+
RH850_REG_R5 = 5
21+
RH850_REG_R6 = 6
22+
RH850_REG_R7 = 7
23+
RH850_REG_R8 = 8
24+
RH850_REG_R9 = 9
25+
RH850_REG_R10 = 10
26+
RH850_REG_R11 = 11
27+
RH850_REG_R12 = 12
28+
RH850_REG_R13 = 13
29+
RH850_REG_R14 = 14
30+
RH850_REG_R15 = 15
31+
RH850_REG_R16 = 16
32+
RH850_REG_R17 = 17
33+
RH850_REG_R18 = 18
34+
RH850_REG_R19 = 19
35+
RH850_REG_R20 = 20
36+
RH850_REG_R21 = 21
37+
RH850_REG_R22 = 22
38+
RH850_REG_R23 = 23
39+
RH850_REG_R24 = 24
40+
RH850_REG_R25 = 25
41+
RH850_REG_R26 = 26
42+
RH850_REG_R27 = 27
43+
RH850_REG_R28 = 28
44+
RH850_REG_R29 = 29
45+
RH850_REG_R30 = 30
46+
RH850_REG_R31 = 31
47+
48+
// RH850 system registers, selection ID 0
49+
RH850_REG_EIPC = 32
50+
RH850_REG_EIPSW = 33
51+
RH850_REG_FEPC = 34
52+
RH850_REG_FEPSW = 35
53+
RH850_REG_ECR = 36
54+
RH850_REG_PSW = 37
55+
RH850_REG_FPSR = 38
56+
RH850_REG_FPEPC = 39
57+
RH850_REG_FPST = 40
58+
RH850_REG_FPCC = 41
59+
RH850_REG_FPCFG = 42
60+
RH850_REG_FPEC = 43
61+
RH850_REG_EIIC = 45
62+
RH850_REG_FEIC = 46
63+
RH850_REG_CTPC = 48
64+
RH850_REG_CTPSW = 49
65+
RH850_REG_CTBP = 52
66+
RH850_REG_EIWR = 60
67+
RH850_REG_FEWR = 61
68+
RH850_REG_BSEL = 63
69+
70+
// RH850 system regusters, selection ID 1
71+
RH850_REG_MCFG0 = 64
72+
RH850_REG_RBASE = 65
73+
RH850_REG_EBASE = 66
74+
RH850_REG_INTBP = 67
75+
RH850_REG_MCTL = 68
76+
RH850_REG_PID = 69
77+
RH850_REG_SCCFG = 75
78+
RH850_REG_SCBP = 76
79+
80+
// RH850 system registers, selection ID 2
81+
RH850_REG_HTCFG0 = 96
82+
RH850_REG_MEA = 102
83+
RH850_REG_ASID = 103
84+
RH850_REG_MEI = 104
85+
RH850_REG_PC = 288
86+
RH850_REG_ENDING = 289
87+
88+
// RH8509 Registers aliases.
89+
90+
RH850_REG_ZERO = 0
91+
RH850_REG_SP = 3
92+
RH850_REG_EP = 30
93+
RH850_REG_LP = 31
94+
)

0 commit comments

Comments
 (0)