Skip to content

Commit 6a30484

Browse files
berolinuxlz-bro
authored andcommitted
target/riscv: Regenerate debug_defines.{c,h} from current riscv-debug-spec
This pulls in some improvements from the riscv-debug-spec repo, and cleans up the licensing (riscv-debug-spec changed the license to dual CC-BY-4.0 and BSD-2-Clause specifically to make sure the generated debug_defines files don't conflict with OpenOCD licensing) Signed-off-by: Bernhard Rosenkränzer <bero@baylibre.com>
1 parent 8d5f2fe commit 6a30484

File tree

2 files changed

+527
-399
lines changed

2 files changed

+527
-399
lines changed

src/target/riscv/debug_defines.c

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/*
2-
* This file is auto-generated by running 'make debug_defines' in
3-
* https://github.com/riscv/riscv-debug-spec/ (40b9a05)
4-
*/
1+
/* SPDX-License-Identifier: BSD-2-Clause OR CC-BY-4.0 */
2+
/* This file was auto-generated by running 'make debug_defines' in https://github.com/riscv/riscv-debug-spec/ (22a7576) */
53

64
#include "debug_defines.h"
75
#include <stddef.h>
@@ -222,6 +220,17 @@ static const char *csr_dcsr_debugver_values[16] = {
222220
[4] = "1_0",
223221
[15] = "custom"
224222
};
223+
static const char *csr_dcsr_extcause_values[8] = {
224+
[0] = "critical_error"
225+
};
226+
static const char *csr_dcsr_cetrig_values[2] = {
227+
[0] = "disabled",
228+
[1] = "enabled"
229+
};
230+
static const char *csr_dcsr_pelp_values[2] = {
231+
[0] = "NO_LP_EXPECTED",
232+
[1] = "LP_EXPECTED"
233+
};
225234
static const char *csr_dcsr_ebreakvs_values[2] = {
226235
[0] = "exception",
227236
[1] = "debug_mode"
@@ -260,7 +269,8 @@ static const char *csr_dcsr_cause_values[8] = {
260269
[3] = "haltreq",
261270
[4] = "step",
262271
[5] = "resethaltreq",
263-
[6] = "group"
272+
[6] = "group",
273+
[7] = "other"
264274
};
265275
static const char *csr_dcsr_mprven_values[2] = {
266276
[0] = "disabled",
@@ -350,6 +360,20 @@ static riscv_debug_reg_field_list_t csr_dcsr_get_debugver(riscv_debug_reg_ctx_t
350360
return result;
351361
}
352362

363+
static riscv_debug_reg_field_list_t csr_dcsr_get_extcause(riscv_debug_reg_ctx_t context)
364+
{
365+
riscv_debug_reg_field_list_t result = {
366+
.field = {
367+
.name = "extcause",
368+
.lsb = 0x18,
369+
.msb = 0x1a,
370+
.values = csr_dcsr_extcause_values
371+
},
372+
.get_next = csr_dcsr_get_debugver
373+
};
374+
return result;
375+
}
376+
353377
static riscv_debug_reg_field_list_t csr_dcsr_get_step(riscv_debug_reg_ctx_t context)
354378
{
355379
riscv_debug_reg_field_list_t result = {
@@ -359,7 +383,35 @@ static riscv_debug_reg_field_list_t csr_dcsr_get_step(riscv_debug_reg_ctx_t cont
359383
.msb = 2,
360384
.values = NULL
361385
},
362-
.get_next = csr_dcsr_get_debugver
386+
.get_next = csr_dcsr_get_extcause
387+
};
388+
return result;
389+
}
390+
391+
static riscv_debug_reg_field_list_t csr_dcsr_get_cetrig(riscv_debug_reg_ctx_t context)
392+
{
393+
riscv_debug_reg_field_list_t result = {
394+
.field = {
395+
.name = "cetrig",
396+
.lsb = 0x13,
397+
.msb = 0x13,
398+
.values = csr_dcsr_cetrig_values
399+
},
400+
.get_next = csr_dcsr_get_step
401+
};
402+
return result;
403+
}
404+
405+
static riscv_debug_reg_field_list_t csr_dcsr_get_pelp(riscv_debug_reg_ctx_t context)
406+
{
407+
riscv_debug_reg_field_list_t result = {
408+
.field = {
409+
.name = "pelp",
410+
.lsb = 0x12,
411+
.msb = 0x12,
412+
.values = csr_dcsr_pelp_values
413+
},
414+
.get_next = csr_dcsr_get_cetrig
363415
};
364416
return result;
365417
}
@@ -373,7 +425,7 @@ static riscv_debug_reg_field_list_t csr_dcsr_get_ebreakvs(riscv_debug_reg_ctx_t
373425
.msb = 0x11,
374426
.values = csr_dcsr_ebreakvs_values
375427
},
376-
.get_next = csr_dcsr_get_step
428+
.get_next = csr_dcsr_get_pelp
377429
};
378430
return result;
379431
}
@@ -692,12 +744,11 @@ static riscv_debug_reg_field_list_t csr_tcontrol_get_mte(riscv_debug_reg_ctx_t c
692744

693745
static riscv_debug_reg_field_list_t csr_scontext_get_data(riscv_debug_reg_ctx_t context)
694746
{
695-
assert(context.XLEN.is_set);
696747
riscv_debug_reg_field_list_t result = {
697748
.field = {
698749
.name = "data",
699750
.lsb = 0,
700-
.msb = (context.XLEN.value + -1),
751+
.msb = 0x1f,
701752
.values = NULL
702753
},
703754
.get_next = NULL
@@ -707,12 +758,11 @@ static riscv_debug_reg_field_list_t csr_scontext_get_data(riscv_debug_reg_ctx_t
707758

708759
static riscv_debug_reg_field_list_t csr_mcontext_get_hcontext(riscv_debug_reg_ctx_t context)
709760
{
710-
assert(context.XLEN.is_set);
711761
riscv_debug_reg_field_list_t result = {
712762
.field = {
713763
.name = "hcontext",
714764
.lsb = 0,
715-
.msb = (context.XLEN.value + -1),
765+
.msb = 0xd,
716766
.values = NULL
717767
},
718768
.get_next = NULL
@@ -1974,7 +2024,7 @@ static riscv_debug_reg_field_list_t csr_textra64_get_sbytemask(riscv_debug_reg_c
19742024
.field = {
19752025
.name = "sbytemask",
19762026
.lsb = 0x24,
1977-
.msb = 0x28,
2027+
.msb = 0x27,
19782028
.values = NULL
19792029
},
19802030
.get_next = csr_textra64_get_mhselect
@@ -1988,7 +2038,7 @@ static riscv_debug_reg_field_list_t csr_textra64_get_svalue(riscv_debug_reg_ctx_
19882038
.field = {
19892039
.name = "svalue",
19902040
.lsb = 2,
1991-
.msb = 0x23,
2041+
.msb = 0x21,
19922042
.values = NULL
19932043
},
19942044
.get_next = csr_textra64_get_sbytemask

0 commit comments

Comments
 (0)