Switchtec Userspace PROJECT_NUMBER = 3.1
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_KMSK_LEN 64
33#define SWITCHTEC_KMSK_NUM 4
34
35#define SWITCHTEC_SECURITY_SPI_RATE_MAX_NUM 16
36
38 uint32_t chip_serial;
39 uint32_t ver_km;
40 uint32_t ver_bl2;
41 uint32_t ver_main;
42 uint32_t ver_sec_unlock;
43};
44enum switchtec_debug_mode {
45 SWITCHTEC_DEBUG_MODE_ENABLED,
46 SWITCHTEC_DEBUG_MODE_DISABLED_BUT_ENABLE_ALLOWED,
47 SWITCHTEC_DEBUG_MODE_DISABLED,
48 SWITCHTEC_DEBUG_MODE_DISABLED_EXT
49};
50
51enum switchtec_secure_state {
52 SWITCHTEC_UNINITIALIZED_UNSECURED,
53 SWITCHTEC_INITIALIZED_UNSECURED,
54 SWITCHTEC_INITIALIZED_SECURED,
55 SWITCHTEC_SECURE_STATE_UNKNOWN = 0xff,
56};
57
61enum switchtec_otp_program_status {
62 SWITCHTEC_OTP_PROGRAMMABLE = 0,
63 SWITCHTEC_OTP_UNPROGRAMMABLE = 1,
64};
65
67 bool basic_valid;
68 bool mixed_ver_valid;
69 bool main_fw_ver_valid;
70 bool sec_unlock_ver_valid;
71 bool kmsk_valid[4];
72 enum switchtec_otp_program_status basic;
73 enum switchtec_otp_program_status mixed_ver;
74 enum switchtec_otp_program_status main_fw_ver;
75 enum switchtec_otp_program_status sec_unlock_ver;
76 enum switchtec_otp_program_status kmsk[4];
77};
78
80 uint8_t basic_setting_valid;
81 uint8_t public_key_exp_valid;
82 uint8_t public_key_num_valid;
83 uint8_t public_key_ver_valid;
84 uint8_t public_key_valid;
85
86 enum switchtec_debug_mode debug_mode;
87 enum switchtec_secure_state secure_state;
88
89 uint8_t jtag_lock_after_reset;
90 uint8_t jtag_lock_after_bl1;
91 uint8_t jtag_bl1_unlock_allowed;
92 uint8_t jtag_post_bl1_unlock_allowed;
93
94 float spi_clk_rate;
95 uint32_t i2c_recovery_tmo;
96 uint32_t i2c_port;
97 uint32_t i2c_addr;
98 uint32_t i2c_cmd_map;
99 uint32_t public_key_exponent;
100 uint32_t public_key_num;
101 uint32_t public_key_ver;
102
103 uint8_t public_key[SWITCHTEC_KMSK_NUM][SWITCHTEC_KMSK_LEN];
104
105 bool otp_valid;
107};
108
110 uint8_t jtag_lock_after_reset;
111 uint8_t jtag_lock_after_bl1;
112 uint8_t jtag_bl1_unlock_allowed;
113 uint8_t jtag_post_bl1_unlock_allowed;
114
115 float spi_clk_rate;
116 uint32_t i2c_recovery_tmo;
117 uint32_t i2c_port;
118 uint32_t i2c_addr;
119 uint32_t i2c_cmd_map;
120 uint32_t public_key_exponent;
121};
122
123enum switchtec_active_index_id {
124 SWITCHTEC_ACTIVE_INDEX_0 = 0,
125 SWITCHTEC_ACTIVE_INDEX_1 = 1,
126 SWITCHTEC_ACTIVE_INDEX_NOT_SET = 0xfe
127};
128
130 enum switchtec_active_index_id bl2;
131 enum switchtec_active_index_id firmware;
132 enum switchtec_active_index_id config;
133 enum switchtec_active_index_id keyman;
134};
135
136enum switchtec_bl2_recovery_mode {
137 SWITCHTEC_BL2_RECOVERY_I2C = 1,
138 SWITCHTEC_BL2_RECOVERY_XMODEM = 2,
139 SWITCHTEC_BL2_RECOVERY_I2C_AND_XMODEM = 3
140};
141
143 uint8_t kmsk[SWITCHTEC_KMSK_LEN];
144};
145
147 uint8_t pubkey[SWITCHTEC_PUB_KEY_LEN];
148 uint32_t pubkey_exp;
149};
150
152 uint8_t signature[SWITCHTEC_SIG_LEN];
153};
154
156 int num_rates;
157 float rates[SWITCHTEC_SECURITY_SPI_RATE_MAX_NUM];
158};
159
160int switchtec_sn_ver_get(struct switchtec_dev *dev,
161 struct switchtec_sn_ver_info *info);
162int switchtec_security_config_get(struct switchtec_dev *dev,
163 struct switchtec_security_cfg_state *state);
164int switchtec_security_spi_avail_rate_get(struct switchtec_dev *dev,
166int switchtec_security_config_set(struct switchtec_dev *dev,
167 struct switchtec_security_cfg_set *setting);
168int switchtec_mailbox_to_file(struct switchtec_dev *dev, int fd);
169int switchtec_active_image_index_get(struct switchtec_dev *dev,
170 struct switchtec_active_index *index);
171int switchtec_active_image_index_set(struct switchtec_dev *dev,
172 struct switchtec_active_index *index);
173int switchtec_fw_exec(struct switchtec_dev *dev,
174 enum switchtec_bl2_recovery_mode recovery_mode);
175int switchtec_boot_resume(struct switchtec_dev *dev);
176int switchtec_kmsk_set(struct switchtec_dev *dev,
177 struct switchtec_pubkey *public_key,
178 struct switchtec_signature *signature,
179 struct switchtec_kmsk *kmsk);
180int switchtec_secure_state_set(struct switchtec_dev *dev,
181 enum switchtec_secure_state state);
182int switchtec_dbg_unlock(struct switchtec_dev *dev, uint32_t serial,
183 uint32_t ver_sec_unlock,
184 struct switchtec_pubkey *public_key,
185 struct switchtec_signature *signature);
186int switchtec_dbg_unlock_version_update(struct switchtec_dev *dev,
187 uint32_t serial,
188 uint32_t ver_sec_unlock,
189 struct switchtec_pubkey *public_key,
190 struct switchtec_signature *signature);
191int switchtec_read_sec_cfg_file(struct switchtec_dev *dev,
192 FILE *setting_file,
193 struct switchtec_security_cfg_set *set);
194int switchtec_read_pubk_file(FILE *pubk_file, struct switchtec_pubkey *pubk);
195int switchtec_read_kmsk_file(FILE *kmsk_file, struct switchtec_kmsk *kmsk);
196int switchtec_read_signature_file(FILE *sig_file,
197 struct switchtec_signature *sigature);
198int
199switchtec_security_state_has_kmsk(struct switchtec_security_cfg_state *state,
200 struct switchtec_kmsk *kmsk);
201
202#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:1003