25 #ifndef LIBSWITCHTEC_MFG_H 26 #define LIBSWITCHTEC_MFG_H 28 #define SWITCHTEC_MB_LOG_LEN 64 30 #define SWITCHTEC_PUB_KEY_LEN 512 31 #define SWITCHTEC_SIG_LEN 512 32 #define SWITCHTEC_KMSK_LEN 64 33 #define SWITCHTEC_KMSK_NUM 4 40 uint32_t ver_sec_unlock;
42 enum switchtec_debug_mode {
43 SWITCHTEC_DEBUG_MODE_ENABLED,
44 SWITCHTEC_DEBUG_MODE_DISABLED_BUT_ENABLE_ALLOWED,
45 SWITCHTEC_DEBUG_MODE_DISABLED
48 enum switchtec_secure_state {
49 SWITCHTEC_UNINITIALIZED_UNSECURED,
50 SWITCHTEC_INITIALIZED_UNSECURED,
51 SWITCHTEC_INITIALIZED_SECURED,
52 SWITCHTEC_SECURE_STATE_UNKNOWN = 0xff,
55 enum switchtec_spi_clk_rate {
56 SWITCHTEC_SPI_RATE_100M = 1,
57 SWITCHTEC_SPI_RATE_67M,
58 SWITCHTEC_SPI_RATE_50M,
59 SWITCHTEC_SPI_RATE_40M,
60 SWITCHTEC_SPI_RATE_33_33M,
61 SWITCHTEC_SPI_RATE_28_57M,
62 SWITCHTEC_SPI_RATE_25M,
63 SWITCHTEC_SPI_RATE_22_22M,
64 SWITCHTEC_SPI_RATE_20M,
65 SWITCHTEC_SPI_RATE_18_18M
69 uint8_t basic_setting_valid;
70 uint8_t public_key_exp_valid;
71 uint8_t public_key_num_valid;
72 uint8_t public_key_ver_valid;
73 uint8_t public_key_valid;
75 enum switchtec_debug_mode debug_mode;
76 enum switchtec_secure_state secure_state;
78 uint8_t jtag_lock_after_reset;
79 uint8_t jtag_lock_after_bl1;
80 uint8_t jtag_bl1_unlock_allowed;
81 uint8_t jtag_post_bl1_unlock_allowed;
83 enum switchtec_spi_clk_rate spi_clk_rate;
84 uint32_t i2c_recovery_tmo;
88 uint32_t public_key_exponent;
89 uint32_t public_key_num;
90 uint32_t public_key_ver;
92 uint8_t public_key[SWITCHTEC_KMSK_NUM][SWITCHTEC_KMSK_LEN];
96 uint8_t jtag_lock_after_reset;
97 uint8_t jtag_lock_after_bl1;
98 uint8_t jtag_bl1_unlock_allowed;
99 uint8_t jtag_post_bl1_unlock_allowed;
101 uint32_t spi_clk_rate;
102 uint32_t i2c_recovery_tmo;
105 uint32_t i2c_cmd_map;
106 uint32_t public_key_exponent;
109 enum switchtec_active_index_id {
110 SWITCHTEC_ACTIVE_INDEX_0 = 0,
111 SWITCHTEC_ACTIVE_INDEX_1 = 1,
112 SWITCHTEC_ACTIVE_INDEX_NOT_SET = 0xfe
116 enum switchtec_active_index_id bl2;
117 enum switchtec_active_index_id firmware;
118 enum switchtec_active_index_id config;
119 enum switchtec_active_index_id keyman;
122 enum switchtec_bl2_recovery_mode {
123 SWITCHTEC_BL2_RECOVERY_I2C = 1,
124 SWITCHTEC_BL2_RECOVERY_XMODEM = 2,
125 SWITCHTEC_BL2_RECOVERY_I2C_AND_XMODEM = 3
129 uint8_t kmsk[SWITCHTEC_KMSK_LEN];
133 uint8_t pubkey[SWITCHTEC_PUB_KEY_LEN];
138 uint8_t signature[SWITCHTEC_SIG_LEN];
153 enum switchtec_bl2_recovery_mode recovery_mode);
160 enum switchtec_secure_state state);
162 uint32_t ver_sec_unlock,
167 uint32_t ver_sec_unlock,
172 int switchtec_read_pubk_file(FILE *pubk_file,
struct switchtec_pubkey *pubk);
180 #endif // LIBSWITCHTEC_MFG_H int switchtec_active_image_index_get(struct switchtec_dev *dev, struct switchtec_active_index *index)
Get active image index.
int switchtec_fw_exec(struct switchtec_dev *dev, enum switchtec_bl2_recovery_mode recovery_mode)
Execute the transferred firmware.
int switchtec_kmsk_set(struct switchtec_dev *dev, struct switchtec_pubkey *public_key, struct switchtec_signature *signature, struct switchtec_kmsk *kmsk)
Set KMSK entry KMSK stands for Key Manifest Secure Key. It is a key used to verify Key Manifest parti...
int switchtec_mailbox_to_file(struct switchtec_dev *dev, int fd)
Retrieve mailbox entries.
int switchtec_read_sec_cfg_file(FILE *setting_file, struct switchtec_security_cfg_set *set)
Read security settings from config file.
int switchtec_secure_state_set(struct switchtec_dev *dev, enum switchtec_secure_state state)
Set device secure state.
int switchtec_read_signature_file(FILE *sig_file, struct switchtec_signature *sigature)
Read signature data from signature file.
int switchtec_sn_ver_get(struct switchtec_dev *dev, struct switchtec_sn_ver_info *info)
Get serial number and security version.
int switchtec_security_config_set(struct switchtec_dev *dev, struct switchtec_security_cfg_set *setting)
Set secure settings.
int switchtec_dbg_unlock_version_update(struct switchtec_dev *dev, uint32_t serial, uint32_t ver_sec_unlock, struct switchtec_pubkey *public_key, struct switchtec_signature *signature)
Update firmware debug secure unlock version number.
int switchtec_read_kmsk_file(FILE *kmsk_file, struct switchtec_kmsk *kmsk)
Read KMSK data from KMSK file.
int switchtec_security_config_get(struct switchtec_dev *dev, struct switchtec_security_cfg_state *state)
Get secure boot configurations.
int switchtec_dbg_unlock(struct switchtec_dev *dev, uint32_t serial, uint32_t ver_sec_unlock, struct switchtec_pubkey *public_key, struct switchtec_signature *signature)
Unlock firmware debug features.
int switchtec_boot_resume(struct switchtec_dev *dev)
Resume device boot. Note that after calling this function, the current 'dev' pointer is no longer val...
int switchtec_security_state_has_kmsk(struct switchtec_security_cfg_state *state, struct switchtec_kmsk *kmsk)
Check if secure config already has a KMSK entry KMSK stands for Key Manifest Secure Key...
int switchtec_active_image_index_set(struct switchtec_dev *dev, struct switchtec_active_index *index)
Set active image index.