Switchtec Userspace PROJECT_NUMBER = 4.0
Loading...
Searching...
No Matches
mfg.h
1/*
2 * Microsemi Switchtec(tm) PCIe Management Library
3 * Copyright (c) 2019, Microsemi Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25#ifndef LIBSWITCHTEC_MFG_H
26#define LIBSWITCHTEC_MFG_H
27
28#define SWITCHTEC_MB_LOG_LEN 32
29
30#define SWITCHTEC_PUB_KEY_LEN 512
31#define SWITCHTEC_SIG_LEN 512
32#define SWITCHTEC_UDS_LEN 32
33#define SWITCHTEC_KMSK_LEN 64
34#define SWITCHTEC_KMSK_NUM_MAX 10
35
36#define SWITCHTEC_SECURITY_SPI_RATE_MAX_NUM 16
37
39 uint32_t chip_serial;
40 uint32_t ver_km;
41 uint32_t ver_bl2;
42 uint32_t ver_main;
43 uint32_t ver_sec_unlock;
44 bool riot_ver_valid;
45 uint32_t ver_riot;
46};
47enum switchtec_debug_mode {
48 SWITCHTEC_DEBUG_MODE_ENABLED,
49 SWITCHTEC_DEBUG_MODE_DISABLED_BUT_ENABLE_ALLOWED,
50 SWITCHTEC_DEBUG_MODE_DISABLED,
51 SWITCHTEC_DEBUG_MODE_DISABLED_EXT
52};
53
54enum switchtec_secure_state {
55 SWITCHTEC_UNINITIALIZED_UNSECURED,
56 SWITCHTEC_INITIALIZED_UNSECURED,
57 SWITCHTEC_INITIALIZED_SECURED,
58 SWITCHTEC_SECURE_STATE_UNKNOWN = 0xff,
59};
60
61enum switchtec_attestation_mode {
62 SWITCHTEC_ATTESTATION_MODE_NOT_SUPPORTED,
63 SWITCHTEC_ATTESTATION_MODE_NONE,
64 SWITCHTEC_ATTESTATION_MODE_DICE
65};
66
70enum switchtec_otp_program_status {
71 SWITCHTEC_OTP_PROGRAMMABLE = 0,
72 SWITCHTEC_OTP_UNPROGRAMMABLE = 1,
73};
74
75enum switchtec_otp_program_mask {
76 SWITCHTEC_OTP_UNMASKED = 0,
77 SWITCHTEC_OTP_MASKED = 1,
78};
79
81 bool basic_valid;
82 bool mixed_ver_valid;
83 bool main_fw_ver_valid;
84 bool sec_unlock_ver_valid;
85 bool kmsk_valid[4];
86 enum switchtec_otp_program_status basic;
87 enum switchtec_otp_program_status mixed_ver;
88 enum switchtec_otp_program_status main_fw_ver;
89 enum switchtec_otp_program_status sec_unlock_ver;
90 enum switchtec_otp_program_status kmsk[4];
91};
92
94 bool basic_valid;
95 bool debug_mode_valid;
96 bool key_ver_valid;
97 bool rc_ver_valid;
98 bool bl2_ver_valid;
99 bool main_fw_ver_valid;
100 bool sec_unlock_ver_valid;
101 bool kmsk_valid[10];
102 bool cdi_efuse_inc_mask_valid;
103 bool uds_valid;
104 bool uds_mask_valid;
105 bool mchp_uds_valid;
106 bool mchp_uds_mask_valid;
107 bool did_cert0_valid;
108 bool did_cert1_valid;
109 enum switchtec_otp_program_status basic;
110 enum switchtec_otp_program_status debug_mode;
111 enum switchtec_otp_program_status key_ver;
112 enum switchtec_otp_program_status rc_ver;
113 enum switchtec_otp_program_status bl2_ver;
114 enum switchtec_otp_program_status main_fw_ver;
115 enum switchtec_otp_program_status sec_unlock_ver;
116 enum switchtec_otp_program_status kmsk[10];
117 enum switchtec_otp_program_status cdi_efuse_inc_mask;
118 enum switchtec_otp_program_status uds;
119 enum switchtec_otp_program_mask uds_mask;
120 enum switchtec_otp_program_status mchp_uds;
121 enum switchtec_otp_program_mask mchp_uds_mask;
122 enum switchtec_otp_program_status did_cert0;
123 enum switchtec_otp_program_status did_cert1;
124};
125
127 enum switchtec_attestation_mode attestation_mode;
128 bool cdi_efuse_inc_mask_valid;
129 unsigned int cdi_efuse_inc_mask;
130 bool uds_selfgen;
131 bool uds_visible;
132 unsigned char uds_data[32];
133};
134
136 bool debug_mode_valid;
137 uint8_t basic_setting_valid;
138 uint8_t public_key_exp_valid;
139 uint8_t public_key_num_valid;
140 uint8_t public_key_ver_valid;
141 uint8_t public_key_valid;
142
143 enum switchtec_debug_mode debug_mode;
144 enum switchtec_secure_state secure_state;
145
146 uint8_t jtag_lock_after_reset;
147 uint8_t jtag_lock_after_bl1;
148 uint8_t jtag_bl1_unlock_allowed;
149 uint8_t jtag_post_bl1_unlock_allowed;
150
151 float spi_clk_rate;
152 uint32_t i2c_recovery_tmo;
153 uint32_t i2c_port;
154 uint32_t i2c_addr;
155 uint32_t i2c_cmd_map;
156 uint32_t public_key_exponent;
157 uint32_t public_key_num;
158 uint32_t public_key_ver;
159
160 uint8_t public_key[SWITCHTEC_KMSK_NUM_MAX][SWITCHTEC_KMSK_LEN];
161
162 bool otp_valid;
163 bool use_otp_ext;
166
167 struct switchtec_attestation_state attn_state;
168};
169
171 enum switchtec_attestation_mode attestation_mode;
172 unsigned int cdi_efuse_inc_mask;
173 bool uds_selfgen;
174 bool uds_valid;
175 unsigned char uds_data[32];
176};
177
179 uint8_t jtag_lock_after_reset;
180 uint8_t jtag_lock_after_bl1;
181 uint8_t jtag_bl1_unlock_allowed;
182 uint8_t jtag_post_bl1_unlock_allowed;
183
184 float spi_clk_rate;
185 uint32_t i2c_recovery_tmo;
186 uint32_t i2c_port;
187 uint32_t i2c_addr;
188 uint32_t i2c_cmd_map;
189 uint32_t public_key_exponent;
190
191 struct switchtec_attestation_set attn_set;
192};
193
194enum switchtec_active_index_id {
195 SWITCHTEC_ACTIVE_INDEX_0 = 0,
196 SWITCHTEC_ACTIVE_INDEX_1 = 1,
197 SWITCHTEC_ACTIVE_INDEX_NOT_SET = 0xfe
198};
199
201 enum switchtec_active_index_id bl2;
202 enum switchtec_active_index_id firmware;
203 enum switchtec_active_index_id config;
204 enum switchtec_active_index_id keyman;
205 enum switchtec_active_index_id riot;
206};
207
208enum switchtec_bl2_recovery_mode {
209 SWITCHTEC_BL2_RECOVERY_I2C = 1,
210 SWITCHTEC_BL2_RECOVERY_XMODEM = 2,
211 SWITCHTEC_BL2_RECOVERY_I2C_AND_XMODEM = 3
212};
213
215 uint8_t kmsk[SWITCHTEC_KMSK_LEN];
216};
217
219 uint8_t pubkey[SWITCHTEC_PUB_KEY_LEN];
220 uint32_t pubkey_exp;
221};
222
224 uint8_t signature[SWITCHTEC_SIG_LEN];
225};
226
228 unsigned char uds[SWITCHTEC_UDS_LEN];
229};
230
232 int num_rates;
233 float rates[SWITCHTEC_SECURITY_SPI_RATE_MAX_NUM];
234};
235
236int switchtec_sn_ver_get(struct switchtec_dev *dev,
237 struct switchtec_sn_ver_info *info);
238int switchtec_security_config_get(struct switchtec_dev *dev,
239 struct switchtec_security_cfg_state *state);
240int switchtec_security_spi_avail_rate_get(struct switchtec_dev *dev,
242int switchtec_security_config_set(struct switchtec_dev *dev,
243 struct switchtec_security_cfg_set *setting);
244int switchtec_mailbox_to_file(struct switchtec_dev *dev, int fd);
245int switchtec_active_image_index_get(struct switchtec_dev *dev,
246 struct switchtec_active_index *index);
247int switchtec_active_image_index_set(struct switchtec_dev *dev,
248 struct switchtec_active_index *index);
249int switchtec_fw_exec(struct switchtec_dev *dev,
250 enum switchtec_bl2_recovery_mode recovery_mode);
251int switchtec_boot_resume(struct switchtec_dev *dev);
252int switchtec_kmsk_set(struct switchtec_dev *dev,
253 struct switchtec_pubkey *public_key,
254 struct switchtec_signature *signature,
255 struct switchtec_kmsk *kmsk);
256int switchtec_secure_state_set(struct switchtec_dev *dev,
257 enum switchtec_secure_state state);
258int switchtec_dbg_unlock(struct switchtec_dev *dev, uint32_t serial,
259 uint32_t ver_sec_unlock,
260 struct switchtec_pubkey *public_key,
261 struct switchtec_signature *signature);
262int switchtec_dbg_unlock_version_update(struct switchtec_dev *dev,
263 uint32_t serial,
264 uint32_t ver_sec_unlock,
265 struct switchtec_pubkey *public_key,
266 struct switchtec_signature *signature);
267int switchtec_read_sec_cfg_file(struct switchtec_dev *dev,
268 FILE *setting_file,
269 struct switchtec_security_cfg_set *set);
270int switchtec_read_pubk_file(FILE *pubk_file, struct switchtec_pubkey *pubk);
271int switchtec_read_kmsk_file(FILE *kmsk_file, struct switchtec_kmsk *kmsk);
272int switchtec_read_signature_file(FILE *sig_file,
273 struct switchtec_signature *sigature);
274int switchtec_read_uds_file(FILE *uds_file, struct switchtec_uds *uds);
275int
276switchtec_security_state_has_kmsk(struct switchtec_security_cfg_state *state,
277 struct switchtec_kmsk *kmsk);
278
279#endif // LIBSWITCHTEC_MFG_H
int switchtec_sn_ver_get(struct switchtec_dev *dev, struct switchtec_sn_ver_info *info)
Get serial number and security version.
Definition: mfg.c:1683