Skip to content

Commit

Permalink
adding tap interface to new registers
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitsirks committed Nov 17, 2024
1 parent dcc5525 commit 1614171
Show file tree
Hide file tree
Showing 13 changed files with 407 additions and 96 deletions.
20 changes: 17 additions & 3 deletions src/integration/rtl/caliptra_top.sv
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ module caliptra_top
//caliptra uncore jtag ports & pertinent logic
logic cptra_core_dmi_enable;
logic cptra_uncore_dmi_enable;
logic cptra_mbox_dmi_enable;
logic cptra_uncore_dmi_reg_en;
logic cptra_uncore_dmi_unlocked_reg_en;
logic cptra_uncore_dmi_locked_reg_en;
logic cptra_uncore_dmi_reg_wr_en;
logic [31:0] cptra_uncore_dmi_reg_rdata;
logic [6:0] cptra_uncore_dmi_reg_addr;
Expand Down Expand Up @@ -413,9 +416,19 @@ always_comb begin
intr[NUM_INTR-1:`VEER_INTR_VEC_MAX_ASSIGNED] = '0;
end

always_comb cptra_core_dmi_enable = ~(cptra_security_state_Latched.debug_locked);
//Open Core TAP only for debug unlocked
always_comb cptra_core_dmi_enable = ~(cptra_security_state_Latched.debug_locked);
//Open Uncore TAP for debug unlocked, or DEVICE_MANUFACTURING, or debug intent set
always_comb cptra_uncore_dmi_enable = ~(cptra_security_state_Latched.debug_locked) |
((cptra_security_state_Latched.debug_locked) & (cptra_security_state_Latched.device_lifecycle == DEVICE_MANUFACTURING));
(cptra_security_state_Latched.device_lifecycle == DEVICE_MANUFACTURING) |
ss_debug_intent;

//Uncore registers only open for debug unlock or manufacturing
always_comb cptra_uncore_dmi_unlocked_reg_en = cptra_uncore_dmi_reg_en &
(~(cptra_security_state_Latched.debug_locked) |
(cptra_security_state_Latched.device_lifecycle == DEVICE_MANUFACTURING));
//Uncore registers open for all cases
always_comb cptra_uncore_dmi_locked_reg_en = cptra_uncore_dmi_reg_en;

el2_veer_wrapper rvtop (
`ifdef CALIPTRA_FORCE_CPU_RESET
Expand Down Expand Up @@ -1283,7 +1296,8 @@ soc_ifc_top1
//multiple cryptos operating at once, assert fatal error
.crypto_error(crypto_error),
//caliptra uncore jtag ports
.cptra_uncore_dmi_reg_en ( cptra_uncore_dmi_reg_en ),
.cptra_uncore_dmi_unlocked_reg_en( cptra_uncore_dmi_unlocked_reg_en ),
.cptra_uncore_dmi_locked_reg_en( cptra_uncore_dmi_locked_reg_en ),
.cptra_uncore_dmi_reg_wr_en( cptra_uncore_dmi_reg_wr_en ),
.cptra_uncore_dmi_reg_rdata( cptra_uncore_dmi_reg_rdata ),
.cptra_uncore_dmi_reg_addr ( cptra_uncore_dmi_reg_addr ),
Expand Down
2 changes: 1 addition & 1 deletion src/integration/test_suites/caliptra_demo/caliptra_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void mbox_fw() {
uint32_t data;

//set ready for FW
lsu_write_32(CLP_SOC_IFC_REG_CPTRA_FLOW_STATUS, SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_FW_MASK);
lsu_write_32(CLP_SOC_IFC_REG_CPTRA_FLOW_STATUS, SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_MB_PROCESSING_MASK);

// Roughly equivalent to .rept 99 "nop" since the loop requires 3 (5?) ops each iteration
// nop
Expand Down
8 changes: 4 additions & 4 deletions src/integration/test_suites/caliptra_top/caliptra_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void main() {
doe_init(iv_data_uds, iv_data_fe, 0x6); // TODO replace 0x6 with entry indicators

VPRINTF(LOW, "Setting Flow Status\n");
soc_ifc_set_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_FW_MASK);
soc_ifc_set_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_MB_PROCESSING_MASK);

VPRINTF(LOW, "Unlocking SHA512-ACC\n");
// Clear SHA accelerator lock (FIPS requirement)
Expand Down Expand Up @@ -150,7 +150,7 @@ void main() {
}

// Clear 'ready for fw'
soc_ifc_clr_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_FW_MASK);
soc_ifc_clr_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_MB_PROCESSING_MASK);

// Jump to ICCM (this is the FMC image, a.k.a. Section 0)
VPRINTF(LOW, "FMC FW loaded into ICCM - jumping there \n");
Expand All @@ -177,7 +177,7 @@ void main() {
// skip doe_init

// Ready for FW (need to reload the FMC)
soc_ifc_set_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_FW_MASK);
soc_ifc_set_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_MB_PROCESSING_MASK);

// Clear SHA accelerator lock (FIPS requirement)
soc_ifc_w1clr_sha_lock_field(SHA512_ACC_CSR_LOCK_LOCK_MASK);
Expand Down Expand Up @@ -217,7 +217,7 @@ void main() {
}

// Clear 'ready for fw'
soc_ifc_clr_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_FW_MASK);
soc_ifc_clr_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_MB_PROCESSING_MASK);

// Jump to ICCM (this is the FMC image, a.k.a. Section 0)
iccm_fmc();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void main() {
: "i" (0x304), "r" (mie_machinetimer_en) /* input : immediate */ \
: /* clobbers: none */);

*soc_ifc_flow_status = SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_FW_MASK;
*soc_ifc_flow_status = SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_MB_PROCESSING_MASK;

//Halt the core
__asm__ volatile ("csrwi %0, %1" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ _start:
//TODO: how to write a dword in asm
//Trigger APB tx
li x3, CLP_SOC_IFC_REG_CPTRA_FLOW_STATUS
li x4, SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_FW_MASK
li x4, SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_MB_PROCESSING_MASK
//sb x5, 0(x3)

loop1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void main () {
VPRINTF(LOW, "----------------------------------\n");

//set ready for FW so tb will push FW
soc_ifc_set_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_FW_MASK);
soc_ifc_set_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_MB_PROCESSING_MASK);

// Sleep
for (uint16_t slp = 0; slp < 33; slp++);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void main () {
SEND_STDOUT_CTRL(0xf2);

//set ready for FW so tb will push FW
soc_ifc_set_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_FW_MASK);
soc_ifc_set_flow_status_field(SOC_IFC_REG_CPTRA_FLOW_STATUS_READY_FOR_MB_PROCESSING_MASK);

set_mit0_and_halt_core(mitb0, mie_timer0_ext_int_en);

Expand Down
22 changes: 21 additions & 1 deletion src/soc_ifc/rtl/soc_ifc_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,30 @@ package soc_ifc_pkg;
parameter DMI_REG_BOOT_STATUS = 7'h53;
parameter DMI_REG_CPTRA_HW_ERRROR_ENC = 7'h54;
parameter DMI_REG_CPTRA_FW_ERROR_ENC = 7'h55;
parameter DMI_REG_MBOX_DIN = 7'h56;
parameter DMI_REG_SS_UDS_SEED_BASE_ADDR_L = 7'h56;
parameter DMI_REG_SS_UDS_SEED_BASE_ADDR_H = 7'h57;
//RW registers
parameter DMI_REG_CPTRA_DBG_MANUF_SERVICE_REG = 7'h60;
parameter DMI_REG_BOOTFSM_GO = 7'h61;
parameter DMI_REG_MBOX_DIN = 7'h62;
parameter DMI_REG_SS_DEBUG_INTENT = 7'h63;
parameter DMI_REG_SS_SOC_IFC_BASE_ADDR_L = 7'h64;
parameter DMI_REG_SS_SOC_IFC_BASE_ADDR_H = 7'h65;
parameter DMI_REG_SS_MCI_BASE_ADDR_L = 7'h66;
parameter DMI_REG_SS_MCI_BASE_ADDR_H = 7'h67;
parameter DMI_REG_SS_RECOVERY_IFC_BASE_ADDR_L = 7'h68;
parameter DMI_REG_SS_RECOVERY_IFC_BASE_ADDR_H = 7'h69;
parameter DMI_REG_SS_OTP_FC_BASE_ADDR_L = 7'h6A;
parameter DMI_REG_SS_OTP_FC_BASE_ADDR_H = 7'h6B;
parameter DMI_REG_SS_STRAP_RSVD_0 = 7'h6C;
parameter DMI_REG_SS_STRAP_RSVD_1 = 7'h6D;
parameter DMI_REG_SS_STRAP_RSVD_2 = 7'h6E;
parameter DMI_REG_SS_STRAP_RSVD_3 = 7'h6F;
parameter DMI_REG_SS_DBG_MANUF_SERVICE_REG_REQ = 7'h70;
parameter DMI_REG_SS_DBG_MANUF_SERVICE_REG_RSP = 7'h71;
parameter DMI_REG_SS_DBG_UNLOCK_LEVEL0 = 7'h72;
parameter DMI_REG_SS_DBG_UNLOCK_LEVEL1 = 7'h73;


// This parameter describes the hard-coded implementation in the BOOT FSM
// that results in noncore reset assertion being delayed from the soft reset
Expand Down
Loading

0 comments on commit 1614171

Please sign in to comment.