Skip to content

Commit 1ede166

Browse files
[ot] hw/opentitan: ot_common: Add register span macros
Adds macros for generic computing of the size of register spans for OpenTitan multi registers, which can be used to e.g. make static assertions to ensure that the size of macros matches the size of buffers being used. Co-authored-by: Emmanuel Blot <[email protected]> Signed-off-by: Alex Jones <[email protected]>
1 parent 37b92f4 commit 1ede166

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/hw/opentitan/ot_common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
#define OT_TL_UL_D_WIDTH_BITS 32u
4444
#define OT_TL_UL_D_WIDTH_BYTES ((OT_TL_UL_D_WIDTH_BITS) / 8u)
4545

46+
/* ------------------------------------------------------------------------ */
47+
/* Register Span Definitions */
48+
/* ------------------------------------------------------------------------ */
49+
50+
#define OT_REG_NAME_IDX(_n_, _i_) (R_##_n_##_##_i_)
51+
#define OT_REG_COUNT(_n_, _l_) \
52+
(OT_REG_NAME_IDX(_n_, _l_) - OT_REG_NAME_IDX(_n_, 0) + 1u)
53+
#define OT_REG_SPAN(_n_, _l_) (OT_REG_COUNT(_n_, _l_) * sizeof(uint32_t))
54+
4655
/* ------------------------------------------------------------------------ */
4756
/* Multi-bit boolean values */
4857
/* ------------------------------------------------------------------------ */

0 commit comments

Comments
 (0)