Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions hw/opentitan/ot_lc_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ REG32(MANUF_STATE_7, 0x88u)
#define LC_TOKEN_WIDTH 16u /* 128 bits */
#define LC_TOKEN_DWORDS (LC_TOKEN_WIDTH / sizeof(uint64_t))

#define LC_DEV_ID_WIDTH OT_REG_SPAN(DEVICE_ID, 7)
#define LC_MANUF_STATE_WIDTH OT_REG_SPAN(MANUF_STATE, 7)

#define REG_NAME_ENTRY(_reg_) [R_##_reg_] = stringify(_reg_)
static const char *REG_NAMES[REGS_COUNT] = {
REG_NAME_ENTRY(ALERT_TEST),
Expand Down Expand Up @@ -435,7 +438,11 @@ typedef struct {
} OtLcCtrlTransitionDesc;

static_assert(sizeof(OtOTPTokenValue) == LC_TOKEN_WIDTH,
"Unexpected LC TOLEN WIDTH");
"Unexpected LC Token width");
static_assert(OT_OTP_HWCFG_DEVICE_ID_BYTES == LC_DEV_ID_WIDTH,
"Unexpected LC Device ID width");
static_assert(OT_OTP_HWCFG_MANUF_STATE_BYTES == LC_MANUF_STATE_WIDTH,
"Unexpected LC Manufacturing State width");

#define KECCAK_STATE_BITS 1600u
#define KECCAK_STATE_BYTES (KECCAK_STATE_BITS / 8u)
Expand Down Expand Up @@ -1211,10 +1218,14 @@ static void ot_lc_ctrl_load_otp_hw_cfg(OtLcCtrlState *s)
OtOTPClass *oc = OBJECT_GET_CLASS(OtOTPClass, s->otp_ctrl, TYPE_OT_OTP);
const OtOTPHWCfg *hw_cfg = oc->get_hw_cfg(s->otp_ctrl);

memcpy(&s->regs[R_DEVICE_ID_0], &hw_cfg->device_id[0],
sizeof(*hw_cfg->device_id));
static_assert(sizeof(hw_cfg->device_id) == LC_DEV_ID_WIDTH,
"HW_CFG Device ID size does not match size in registers");
memcpy(&s->regs[R_DEVICE_ID_0], &hw_cfg->device_id[0], LC_DEV_ID_WIDTH);

static_assert(sizeof(hw_cfg->manuf_state) == LC_MANUF_STATE_WIDTH,
"HW_CFG Manuf State size does not match size in registers");
memcpy(&s->regs[R_MANUF_STATE_0], &hw_cfg->manuf_state[0],
sizeof(*hw_cfg->manuf_state));
LC_MANUF_STATE_WIDTH);

if (!s->socdbg) {
return;
Expand Down
9 changes: 9 additions & 0 deletions include/hw/opentitan/ot_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
#define OT_TL_UL_D_WIDTH_BITS 32u
#define OT_TL_UL_D_WIDTH_BYTES ((OT_TL_UL_D_WIDTH_BITS) / 8u)

/* ------------------------------------------------------------------------ */
/* Register Span Definitions */
/* ------------------------------------------------------------------------ */

#define OT_REG_NAME_IDX(_n_, _i_) (R_##_n_##_##_i_)
#define OT_REG_COUNT(_n_, _l_) \
(OT_REG_NAME_IDX(_n_, _l_) - OT_REG_NAME_IDX(_n_, 0) + 1u)
#define OT_REG_SPAN(_n_, _l_) (OT_REG_COUNT(_n_, _l_) * sizeof(uint32_t))

/* ------------------------------------------------------------------------ */
/* Multi-bit boolean values */
/* ------------------------------------------------------------------------ */
Expand Down
Loading