Skip to content

Commit 1d3f17f

Browse files
committed
[ot] hw/opentitan: ot_otp: make multibool bit type more visible
Signed-off-by: Emmanuel Blot <[email protected]>
1 parent 67148ce commit 1d3f17f

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

hw/opentitan/ot_csrng.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ static void ot_csrng_regs_write(void *opaque, hwaddr addr, uint64_t val64,
18261826
OBJECT_GET_CLASS(OtOTPClass, s->otp_ctrl, TYPE_OT_OTP);
18271827
const OtOTPHWCfg *hw_cfg = oc->get_hw_cfg(s->otp_ctrl);
18281828
g_assert(hw_cfg);
1829-
if (hw_cfg->en_csrng_sw_app_read == OT_MULTIBITBOOL8_TRUE) {
1829+
if (hw_cfg->en_csrng_sw_app_read_mb8 == OT_MULTIBITBOOL8_TRUE) {
18301830
uint32_t sw_app_en = FIELD_EX32(val32, CTRL, SW_APP_ENABLE);
18311831
s->sw_app_granted = sw_app_en == OT_MULTIBITBOOL4_TRUE;
18321832
uint32_t read_int = FIELD_EX32(val32, CTRL, READ_INT_STATE);

hw/opentitan/ot_otp_dj.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3540,11 +3540,11 @@ static void ot_otp_dj_pwr_load_hw_cfg(OtOTPDjState *s)
35403540
memcpy(hw_cfg->soc_dbg_state, &otp->data[R_HW_CFG1_SOC_DBG_STATE],
35413541
sizeof(hw_cfg->soc_dbg_state));
35423542
/* do not prevent execution from SRAM if no OTP configuration is loaded */
3543-
hw_cfg->en_sram_ifetch =
3543+
hw_cfg->en_sram_ifetch_mb8 =
35443544
s->blk ? (uint8_t)otp->data[R_HW_CFG1_EN_SRAM_IFETCH] :
35453545
OT_MULTIBITBOOL8_TRUE;
35463546
/* do not prevent CSRNG app reads if no OTP configuration is loaded */
3547-
hw_cfg->en_csrng_sw_app_read =
3547+
hw_cfg->en_csrng_sw_app_read_mb8 =
35483548
s->blk ? (uint8_t)otp->data[R_HW_CFG1_EN_CSRNG_SW_APP_READ] :
35493549
OT_MULTIBITBOOL8_TRUE;
35503550
}

hw/opentitan/ot_otp_eg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,11 +3423,11 @@ static void ot_otp_eg_pwr_load_hw_cfg(OtOTPEgState *s)
34233423
memcpy(hw_cfg->manuf_state, &otp->data[R_HW_CFG0_MANUF_STATE],
34243424
sizeof(hw_cfg->manuf_state));
34253425
/* do not prevent execution from SRAM if no OTP configuration is loaded */
3426-
hw_cfg->en_sram_ifetch =
3426+
hw_cfg->en_sram_ifetch_mb8 =
34273427
s->blk ? (uint8_t)otp->data[R_HW_CFG1_EN_SRAM_IFETCH] :
34283428
OT_MULTIBITBOOL8_TRUE;
34293429
/* do not prevent CSRNG app reads if no OTP configuration is loaded */
3430-
hw_cfg->en_csrng_sw_app_read =
3430+
hw_cfg->en_csrng_sw_app_read_mb8 =
34313431
s->blk ? (uint8_t)otp->data[R_HW_CFG1_EN_CSRNG_SW_APP_READ] :
34323432
OT_MULTIBITBOOL8_TRUE;
34333433
}

hw/opentitan/ot_sram_ctrl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static void ot_sram_ctrl_update_exec(OtSramCtrlState *s)
356356
*/
357357
if (s->otp_ctrl) {
358358
OtOTPClass *oc = OBJECT_GET_CLASS(OtOTPClass, s->otp_ctrl, TYPE_OT_OTP);
359-
s->otp_ifetch = oc->get_hw_cfg(s->otp_ctrl)->en_sram_ifetch ==
359+
s->otp_ifetch = oc->get_hw_cfg(s->otp_ctrl)->en_sram_ifetch_mb8 ==
360360
OT_MULTIBITBOOL8_TRUE;
361361
}
362362

include/hw/opentitan/ot_otp.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#define HW_OPENTITAN_OT_OTP_H
3131

3232
#include "qom/object.h"
33+
#include "hw/opentitan/ot_common.h"
3334
#include "hw/sysbus.h"
3435

3536
#define TYPE_OT_OTP "ot-otp"
@@ -57,16 +58,20 @@ typedef enum {
5758
#define OT_OTP_HWCFG_SOC_DBG_STATE_BYTES 4u
5859

5960
/*
60-
* Hardware configuration (for HW_CFG partitions)
61+
* Hardware configuration (for HW_CFG partitions).
62+
*
63+
* Digests are not added to this structure since real HW does not use them
64+
*
65+
* Note that some fields may be meaningless / not initialized depending on the
66+
* actual OpenTitan top.
6167
*/
6268
typedef struct {
6369
uint8_t device_id[OT_OTP_HWCFG_DEVICE_ID_BYTES];
6470
uint8_t manuf_state[OT_OTP_HWCFG_MANUF_STATE_BYTES];
65-
/* soc_dbg_state may be meaningless, dep. on the platform */
6671
uint8_t soc_dbg_state[OT_OTP_HWCFG_SOC_DBG_STATE_BYTES];
67-
/* the following value is stored as OT_MULTIBITBOOL8 */
68-
uint8_t en_sram_ifetch;
69-
uint8_t en_csrng_sw_app_read;
72+
ot_mb8_t en_sram_ifetch_mb8;
73+
ot_mb8_t en_csrng_sw_app_read_mb8;
74+
ot_mb_lc4_t valid_lc4; /* seems generated but no used on real HW */
7075
} OtOTPHWCfg;
7176

7277
typedef enum {

0 commit comments

Comments
 (0)