Skip to content

Commit

Permalink
[TB] Update soc_ifc C lib to support import by caliptra-ss (#637)
Browse files Browse the repository at this point in the history
* Remove inline fn in header so it can be included to caliptra-ss

* Restamp repo after rebase
  • Loading branch information
calebofearth authored and Nitsirks committed Nov 15, 2024
1 parent a8aca5f commit dbf52da
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflow_metadata/pr_hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
82be4e878bee59a14221f09dcddc6eb0a64c67ff0418a3e933e58973d94a5c7a2f5bc75fccf00fa98301a4ed55208e6e
df42838de9b502d7686784b11be0148d4a5932afe2b90a3fa20298b52582ba414864b171cff5c7f53658351e67fbde06
2 changes: 1 addition & 1 deletion .github/workflow_metadata/pr_timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1731604164
1731692225
19 changes: 19 additions & 0 deletions src/integration/test_suites/libs/soc_ifc/soc_ifc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@
//

#include "caliptra_defines.h"
#include "caliptra_reg.h"
#include "soc_ifc.h"
#include "printf.h"

uint32_t soc_ifc_mbox_read_dataout_single() {
return lsu_read_32(CLP_MBOX_CSR_MBOX_DATAOUT);
}
uint32_t soc_ifc_mbox_dir_read_single(uint32_t rdptr) {
return lsu_read_32(CLP_MBOX_SRAM_BASE_ADDR + rdptr);
}
uint32_t soc_ifc_mbox_dir_write_single(uint32_t wrptr, uint32_t wrdata) {
lsu_write_32(CLP_MBOX_SRAM_BASE_ADDR + wrptr, wrdata);
}

void soc_ifc_clear_execute_reg() {
VPRINTF(MEDIUM,"SOC_IFC: Clear execute reg");
uint32_t reg;
Expand Down Expand Up @@ -283,6 +294,10 @@ void soc_ifc_set_fw_update_reset(uint8_t wait_cycles) {
lsu_write_32(CLP_SOC_IFC_REG_INTERNAL_FW_UPDATE_RESET,reg);
}

void soc_ifc_set_iccm_lock() {
lsu_write_32((CLP_SOC_IFC_REG_INTERNAL_ICCM_LOCK), SOC_IFC_REG_INTERNAL_ICCM_LOCK_LOCK_MASK);
}

//SHA Accelerator
void soc_ifc_sha_accel_acquire_lock() {
while((lsu_read_32(CLP_SHA512_ACC_CSR_LOCK) & SHA512_ACC_CSR_LOCK_LOCK_MASK) == 1);
Expand All @@ -295,6 +310,10 @@ void soc_ifc_sha_accel_wr_mode(enum sha_accel_mode_e mode) {
lsu_write_32(CLP_SHA512_ACC_CSR_MODE,reg);
}

void soc_ifc_sha_accel_execute() {
lsu_write_32((CLP_SHA512_ACC_CSR_EXECUTE), SHA512_ACC_CSR_EXECUTE_EXECUTE_MASK);
}

void soc_ifc_sha_accel_poll_status() {
while((lsu_read_32(CLP_SHA512_ACC_CSR_STATUS) & SHA512_ACC_CSR_STATUS_VALID_MASK) == 0) {
//poke at the mailbox direct read path to create stall scenario
Expand Down
22 changes: 5 additions & 17 deletions src/integration/test_suites/libs/soc_ifc/soc_ifc.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#ifndef SOC_IFC_H
#define SOC_IFC_H

#include "caliptra_defines.h"
#include "caliptra_reg.h"
#include "stdint.h"
#include "riscv_hw_if.h"

Expand Down Expand Up @@ -121,24 +119,16 @@ enum sha_accel_mode_e {

/* --------------- Function Prototypes --------------- */
// Simple reg accesses
inline uint32_t soc_ifc_mbox_read_dataout_single() {
return lsu_read_32(CLP_MBOX_CSR_MBOX_DATAOUT);
}
inline uint32_t soc_ifc_mbox_dir_read_single(uint32_t rdptr) {
return lsu_read_32(0x30000000 + rdptr);
}
inline uint32_t soc_ifc_mbox_dir_write_single(uint32_t wrptr, uint32_t wrdata) {
lsu_write_32(0x30000000 + wrptr, wrdata);
}
uint32_t soc_ifc_mbox_read_dataout_single();
uint32_t soc_ifc_mbox_dir_read_single(uint32_t rdptr);
uint32_t soc_ifc_mbox_dir_write_single(uint32_t wrptr, uint32_t wrdata);
void soc_ifc_clear_execute_reg();
uint8_t soc_ifc_chk_execute_uc();
void soc_ifc_set_mbox_status_field(enum mbox_status_e field);
void soc_ifc_set_flow_status_field(uint32_t field);
void soc_ifc_clr_flow_status_field(uint32_t field);
void soc_ifc_set_fw_update_reset(uint8_t wait_cycles);
inline void soc_ifc_set_iccm_lock() {
lsu_write_32((CLP_SOC_IFC_REG_INTERNAL_ICCM_LOCK), SOC_IFC_REG_INTERNAL_ICCM_LOCK_LOCK_MASK);
}
void soc_ifc_set_iccm_lock();
// Mailbox command flows
uint8_t soc_ifc_mbox_acquire_lock(uint32_t attempt_count);
mbox_op_s soc_ifc_read_mbox_cmd();
Expand All @@ -149,9 +139,7 @@ uint8_t soc_ifc_sanitize_mbox_n_bytes(uint32_t byte_count, uint32_t attempt_coun
// SHA Accelerator Functions
void soc_ifc_sha_accel_acquire_lock();
void soc_ifc_sha_accel_wr_mode(enum sha_accel_mode_e mode);
inline void soc_ifc_sha_accel_execute() {
lsu_write_32((CLP_SHA512_ACC_CSR_EXECUTE), SHA512_ACC_CSR_EXECUTE_EXECUTE_MASK);
}
void soc_ifc_sha_accel_execute();
void soc_ifc_sha_accel_poll_status();
void soc_ifc_sha_accel_clr_lock();
void soc_ifc_w1clr_sha_lock_field();
Expand Down

0 comments on commit dbf52da

Please sign in to comment.