Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple OTP implementation from API to prepare for supporting multiple OTP backends #26

Merged
merged 6 commits into from
Aug 24, 2023
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
39 changes: 21 additions & 18 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,27 @@ F: pc-bios/vof*

RISC-V Machines
---------------

Earlgrey OpenTitan platform
M: Emmanuel Blot <eblot@rivosinc.com>
M: Loïc Lefort <loic@rivosinc.com>
S: Supported
F: hw/opentitan/*
F: include/hw/opentitan/*
F: scripts/opentitan/*
F: hw/riscv/ot_earlgrey.c
F: include/hw/riscv/ot_earlgrey.h

Ibex platforms and utilities
M: Emmanuel Blot <eblot@rivosinc.com>
M: Loïc Lefort <loic@rivosinc.com>
S: Supported
F: hw/riscv/ibex_common.c
F: include/hw/riscv/ibex_common.h
F: include/hw/riscv/ibex_irq.h
F: hw/ibexdemo/*
F: include/hw/ibexdemo/*

OpenTitan
M: Alistair Francis <Alistair.Francis@wdc.com>
L: qemu-riscv@nongnu.org
Expand Down Expand Up @@ -3801,24 +3822,6 @@ S: Maintained
F: ebpf/*
F: tools/ebpf/*

Ibex
M: Emmanuel Blot <eblot@rivosinc.com>
M: Loïc Lefort <loic@rivosinc.com>
S: Supported
F: hw/riscv/ibex_common.c
F: include/hw/riscv/ibex_common.h
F: include/hw/riscv/ibex_irq.h
F: hw/ibexdemo/*
F: include/hw/ibexdemo/*

OpenTitan
M: Emmanuel Blot <eblot@rivosinc.com>
M: Loïc Lefort <loic@rivosinc.com>
S: Supported
F: hw/opentitan/*
F: include/hw/opentitan/*
F: scripts/opentitan/*

Build and test automation
-------------------------
Build and test automation, general continuous integration
Expand Down
4 changes: 4 additions & 0 deletions hw/opentitan/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ config OT_OTBN
config OT_OTP
bool

config OT_OTP_EARLGREY
select OT_OTP
bool

config OT_PINMUX
bool

Expand Down
1 change: 1 addition & 0 deletions hw/opentitan/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ softmmu_ss.add(when: 'CONFIG_OT_KMAC', if_true: [files('ot_kmac.c'), libtomcrypt
softmmu_ss.add(when: 'CONFIG_OT_LIFECYCLE', if_true: files('ot_lifecycle.c'))
softmmu_ss.add(when: 'CONFIG_OT_OTBN', if_true: files('ot_otbn.c'))
softmmu_ss.add(when: 'CONFIG_OT_OTP', if_true: files('ot_otp.c'))
softmmu_ss.add(when: 'CONFIG_OT_OTP_EARLGREY', if_true: files('ot_otp_earlgrey.c'))
softmmu_ss.add(when: 'CONFIG_OT_PINMUX', if_true: files('ot_pinmux.c'))
softmmu_ss.add(when: 'CONFIG_OT_PRNG', if_true: files('ot_prng.c'))
softmmu_ss.add(when: 'CONFIG_OT_PWRMGR', if_true: files('ot_pwrmgr.c'))
Expand Down
5 changes: 3 additions & 2 deletions hw/opentitan/ot_csrng.c
Original file line number Diff line number Diff line change
Expand Up @@ -1645,8 +1645,9 @@ static void ot_csrng_regs_write(void *opaque, hwaddr addr, uint64_t val64,
if (change) {
xtrace_ot_csrng_info("handling CTRL change", val32);
ot_csrng_handle_enable(s);
const OtOTPHWCfg *hw_cfg;
hw_cfg = ot_otp_ctrl_get_hw_cfg(s->otp_ctrl);
OtOTPStateClass *oc =
OBJECT_GET_CLASS(OtOTPStateClass, s->otp_ctrl, TYPE_OT_OTP);
const OtOTPHWCfg *hw_cfg = oc->get_hw_cfg(s->otp_ctrl);
if (hw_cfg->en_csrng_sw_app_read == OT_MULTIBITBOOL8_TRUE) {
uint32_t sw_app_en = FIELD_EX32(val32, CTRL, SW_APP_ENABLE);
s->sw_app_granted = sw_app_en == OT_MULTIBITBOOL4_TRUE;
Expand Down
5 changes: 3 additions & 2 deletions hw/opentitan/ot_entropy_src.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,8 +1575,9 @@ static void ot_entropy_src_reset(DeviceState *dev)
ibex_irq_set(&s->alerts[ix], 0);
}

const OtOTPHWCfg *hw_cfg;
hw_cfg = ot_otp_ctrl_get_hw_cfg(s->otp_ctrl);
OtOTPStateClass *oc =
OBJECT_GET_CLASS(OtOTPStateClass, s->otp_ctrl, TYPE_OT_OTP);
const OtOTPHWCfg *hw_cfg = oc->get_hw_cfg(s->otp_ctrl);

s->obs_fifo_en = false;
s->otp_fw_read = hw_cfg->en_entropy_src_fw_read == OT_MULTIBITBOOL8_TRUE;
Expand Down
8 changes: 6 additions & 2 deletions hw/opentitan/ot_lifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ static uint32_t ot_lifecycle_get_lc_state(OtLifeCycleState *s)
uint32_t lc_state;

if (s->otp_ctrl) {
ot_otp_ctrl_get_lc_info(s->otp_ctrl, &lc_state, NULL);
OtOTPStateClass *oc =
OBJECT_GET_CLASS(OtOTPStateClass, s->otp_ctrl, TYPE_OT_OTP);
oc->get_lc_info(s->otp_ctrl, &lc_state, NULL);
} else {
qemu_log_mask(LOG_GUEST_ERROR, "OTP controller not connected\n");
lc_state = LC_STATE_INVALID;
Expand All @@ -263,7 +265,9 @@ static uint32_t ot_lifecycle_get_lc_transition_count(OtLifeCycleState *s)
uint32_t lc_tcount;

if (s->otp_ctrl) {
ot_otp_ctrl_get_lc_info(s->otp_ctrl, NULL, &lc_tcount);
OtOTPStateClass *oc =
OBJECT_GET_CLASS(OtOTPStateClass, s->otp_ctrl, TYPE_OT_OTP);
oc->get_lc_info(s->otp_ctrl, NULL, &lc_tcount);
} else {
qemu_log_mask(LOG_GUEST_ERROR, "OTP controller not connected\n");
lc_tcount = LC_TRANSITION_COUNT_MAX + 1u;
Expand Down
Loading