5 #ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_OTBN_H_
6 #define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_DRIVERS_OTBN_H_
12 #include "sw/device/silicon_creator/lib/error.h"
23 kScOtbnWideWordNumBits = 256,
25 kScOtbnWideWordNumWords = kScOtbnWideWordNumBits / (
sizeof(uint32_t) * 8),
40 kScOtbnSecMmioExecute = 1,
48 typedef enum sc_otbn_cmd {
49 kScOtbnCmdExecute = 0xd8,
50 kScOtbnCmdSecWipeDmem = 0xc3,
51 kScOtbnCmdSecWipeImem = 0x1e,
59 typedef enum sc_otbn_status {
60 kScOtbnStatusIdle = 0x00,
61 kScOtbnStatusBusyExecute = 0x01,
62 kScOtbnStatusBusySecWipeDmem = 0x02,
63 kScOtbnStatusBusySecWipeImem = 0x03,
64 kScOtbnStatusBusySecWipeInt = 0x04,
65 kScOtbnStatusLocked = 0xFF,
74 typedef uint32_t sc_otbn_addr_t;
128 #define OTBN_SYMBOL_PTR(app_name, sym) _otbn_local_app_##app_name##_##sym
139 #define OTBN_SYMBOL_ADDR(app_name, sym) _otbn_remote_app_##app_name##_##sym
148 #define OTBN_DECLARE_SYMBOL_PTR(app_name, symbol_name) \
149 extern const uint32_t OTBN_SYMBOL_PTR(app_name, symbol_name)[]
165 #define OTBN_DECLARE_SYMBOL_ADDR(app_name, symbol_name) \
166 extern const uint32_t OTBN_SYMBOL_ADDR(app_name, symbol_name)[]
180 #define OTBN_DECLARE_APP_SYMBOLS(app_name) \
181 OTBN_DECLARE_SYMBOL_PTR(app_name, _imem_start); \
182 OTBN_DECLARE_SYMBOL_PTR(app_name, _imem_end); \
183 OTBN_DECLARE_SYMBOL_PTR(app_name, _dmem_data_start); \
184 OTBN_DECLARE_SYMBOL_PTR(app_name, _dmem_data_end); \
185 OTBN_DECLARE_SYMBOL_ADDR(app_name, _dmem_data_start);
197 #define OTBN_APP_T_INIT(app_name) \
199 .imem_start = OTBN_SYMBOL_PTR(app_name, _imem_start), \
200 .imem_end = OTBN_SYMBOL_PTR(app_name, _imem_end), \
201 .dmem_data_start = OTBN_SYMBOL_PTR(app_name, _dmem_data_start), \
202 .dmem_data_end = OTBN_SYMBOL_PTR(app_name, _dmem_data_end), \
203 .dmem_data_start_addr = OTBN_ADDR_T_INIT(app_name, _dmem_data_start), \
209 #define OTBN_ADDR_T_INIT(app_name, symbol_name) \
210 ((uint32_t)OTBN_SYMBOL_ADDR(app_name, symbol_name))
233 rom_error_t sc_otbn_dmem_write(
size_t num_words,
const uint32_t *src,
234 sc_otbn_addr_t dest);
246 rom_error_t sc_otbn_dmem_read(
size_t num_words,
const sc_otbn_addr_t src,
257 rom_error_t sc_otbn_execute(
void);
267 rom_error_t sc_otbn_busy_wait_for_done(
void);
284 uint32_t sc_otbn_instruction_count_get(
void);
294 rom_error_t sc_otbn_imem_sec_wipe(
void);
304 rom_error_t sc_otbn_dmem_sec_wipe(
void);