1 # Copyright (C) 2015, 2020 Synopsys, Inc.
2 # Anton Kolesov <anton.kolesov@synopsys.com>
3 # Didin Evgeniy <didin@synopsys.com>
5 # SPDX-License-Identifier: GPL-2.0-or-later
7 source [find cpu/arc/common.tcl]
9 # Currently 'examine_target' can only read JTAG registers and set properties -
10 # but it shouldn't write any of registers - writes will be cached, but cache
11 # will be invalidated before flushing after examine_target, and changes will be
12 # lost. Perhaps that would be fixed later - perhaps writes shouldn't be cached
13 # after all. But if write to register is really needed from TCL - then it
14 # should be done via "arc jtag" for now.
15 proc arc_v2_examine_target { {target ""} } {
16 # Set current target, because OpenOCD event handlers don't do this for us.
17 if { $target != "" } {
21 # Those registers always exist. DEBUG and DEBUGI are formally optional,
22 # however they come with JTAG interface, and so far there is no way
23 # OpenOCD can communicate with target without JTAG interface.
24 arc set-reg-exists identity pc status32 bta debug lp_start lp_end \
25 eret erbta erstatus ecr efa
29 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 \
30 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 r23 r24 r25 \
31 gp fp sp ilink r30 blink lp_count pcl
34 set dccm_version [arc get-reg-field dccm_build version]
35 if { $dccm_version == 3 || $dccm_version == 4 } {
36 arc set-reg-exists aux_dccm
40 if { [arc get-reg-field iccm_build version] == 4 } {
41 arc set-reg-exists aux_iccm
45 if { [arc get-reg-field mpu_build version] >= 2 &&
46 [arc get-reg-field mpu_build version] <= 4 } {
47 arc set-reg-exists mpu_en mpu_ecr
48 set mpu_regions [arc get-reg-field mpu_build regions]
49 for {set i 0} {$i < $mpu_regions} {incr i} {
50 arc set-reg-exists mpu_rdp$i mpu_rdb$i
54 if { [arc get-reg-field mpu_build version] == 4 } {
55 arc set-reg-exists mpu_index mpu_rstart mpu_rend mpu_rper
60 proc arc_v2_init_regs { } {
62 set core_feature "org.gnu.gdb.arc.core.v2"
63 set aux_min_feature "org.gnu.gdb.arc.aux-minimal"
64 set aux_other_feature "org.gnu.gdb.arc.aux-other"
67 # Types are sorted alphabetically according to their name.
68 arc add-reg-type-struct -name ap_build_t -bitfield version 0 7 \
70 arc add-reg-type-struct -name ap_control_t -bitfield at 0 3 -bitfield tt 4 5 \
71 -bitfield m 6 6 -bitfield p 7 7 -bitfield aa 8 8 -bitfield q 9 9
72 # Cycles field added in version 4.
73 arc add-reg-type-struct -name dccm_build_t -bitfield version 0 7 \
74 -bitfield size0 8 11 -bitfield size1 12 15 -bitfield cycles 17 19
76 arc add-reg-type-struct -name debug_t \
77 -bitfield fh 1 1 -bitfield ah 2 2 -bitfield asr 3 10 \
78 -bitfield is 11 11 -bitfield ep 19 19 -bitfield ed 20 20 \
79 -bitfield eh 21 21 -bitfield ra 22 22 -bitfield zz 23 23 \
80 -bitfield sm 24 26 -bitfield ub 28 28 -bitfield bh 29 29 \
81 -bitfield sh 30 30 -bitfield ld 31 31
83 arc add-reg-type-struct -name ecr_t \
84 -bitfield parameter 0 7 \
85 -bitfield cause 8 15 \
86 -bitfield vector 16 23 \
89 arc add-reg-type-struct -name iccm_build_t -bitfield version 0 7 \
90 -bitfield iccm0_size0 8 11 -bitfield iccm1_size0 12 15 \
91 -bitfield iccm0_size1 16 19 -bitfield iccm1_size1 20 23
92 arc add-reg-type-struct -name identity_t \
93 -bitfield arcver 0 7 -bitfield arcnum 8 15 -bitfield chipid 16 31
94 arc add-reg-type-struct -name isa_config_t -bitfield version 0 7 \
95 -bitfield pc_size 8 11 -bitfield lpc_size 12 15 -bitfield addr_size 16 19 \
96 -bitfield b 20 20 -bitfield a 21 21 -bitfield n 22 22 -bitfield l 23 23 \
97 -bitfield c 24 27 -bitfield d 28 31
98 arc add-reg-type-struct -name mpu_build_t -bitfield version 0 7 \
99 -bitfield regions 8 15 \
102 arc add-reg-type-struct -name mpu_ecr_t \
105 -bitfield EC_CODE 16 31
106 arc add-reg-type-struct -name mpu_en_t \
107 -bitfield UE 3 3 -bitfield UW 4 4 -bitfield UR 5 5 \
108 -bitfield KE 6 6 -bitfield KW 7 7 -bitfield KR 8 8 \
109 -bitfield S 15 15 -bitfield SID 16 23 \
111 arc add-reg-type-struct -name mpu_index_t \
112 -bitfield I 0 3 -bitfield M 30 30 -bitfield D 31 31
113 arc add-reg-type-struct -name mpu_rper_t \
115 -bitfield UE 3 3 -bitfield UW 4 4 -bitfield UR 5 5 \
116 -bitfield KE 6 6 -bitfield KW 7 7 -bitfield KR 8 8 \
117 -bitfield S 15 15 -bitfield SID 16 23
118 arc add-reg-type-flags -name status32_t \
119 -flag H 0 -flag E0 1 -flag E1 2 -flag E2 3 \
120 -flag E3 4 -flag AE 5 -flag DE 6 -flag U 7 \
121 -flag V 8 -flag C 9 -flag N 10 -flag Z 11 \
122 -flag L 12 -flag DZ 13 -flag SC 14 -flag ES 15 \
123 -flag RB0 16 -flag RB1 17 -flag RB2 18 \
124 -flag AD 19 -flag US 20 -flag IE 31
193 foreach {reg count type} $core_regs {
194 arc add-reg -name $reg -num $count -core -type $type -g \
195 -feature $core_feature
201 0x2 lp_start code_ptr
203 0xA status32 status32_t
205 foreach {num name type} $aux_min {
206 arc add-reg -name $name -num $num -type $type -feature $aux_min_feature -g
211 0x004 identity identity_t
219 0x402 erstatus status32_t
223 0x409 mpu_en mpu_en_t
227 0x420 mpu_ecr mpu_ecr_t
260 0x448 mpu_index mpu_index_t
261 0x449 mpu_rstart uint32
262 0x44A mpu_rend uint32
263 0x44B mpu_rper mpu_rper_t
264 0x44C mpu_probe uint32
266 foreach {num name type} $aux_other {
267 arc add-reg -name $name -num $num -type $type -feature $aux_other_feature
278 foreach {num reg} $bcr {
279 arc add-reg -name $reg -num $num -type ${reg}_t -bcr -feature $aux_other_feature
282 [target current] configure \
283 -event examine-end "arc_v2_examine_target [target current]"
286 proc arc_v2_reset { {target ""} } {
287 arc_common_reset $target