Velocity Userspace
|
Manufacturing-related API functions. More...
Classes | |
struct | cfg_stmfd |
struct | get_cfgs_reply |
Functions | |
static int | switchtec_mfg_cmd (struct switchtec_dev *dev, uint32_t cmd, const void *payload, size_t payload_len, void *resp, size_t resp_len) |
Execute a manufacturing command on the Switchtec device. More... | |
static void | get_i2c_operands (enum switchtec_gen gen, uint32_t *addr_shift, uint32_t *map_shift, uint32_t *map_mask) |
Get I2C operands based on the Switchtec generation. More... | |
static int | get_configs (struct switchtec_dev *dev, struct get_cfgs_reply *cfgs, int *otp_valid) |
Retrieve configuration settings from the device. More... | |
int | switchtec_security_spi_avail_rate_get (struct switchtec_dev *dev, struct switchtec_security_spi_avail_rate *rates) |
Get the available SPI rates for the Switchtec device. More... | |
static void | parse_otp_settings (struct switchtec_security_cfg_otp_region *otp, uint32_t flags) |
Parse OTP settings from flags. More... | |
int | switchtec_security_config_get (struct switchtec_dev *dev, struct switchtec_security_cfg_state *state) |
Get secure boot configurations. More... | |
int | switchtec_mailbox_to_file (struct switchtec_dev *dev, int fd) |
Retrieve mailbox entries. More... | |
static int | convert_spi_clk_rate (float clk_float, int hi_rate) |
Converts SPI clock rate from float to an integer index. More... | |
int | switchtec_security_config_set (struct switchtec_dev *dev, struct switchtec_security_cfg_set *setting) |
Set secure settings. More... | |
int | switchtec_otp_sjtag_mode_set (struct switchtec_dev *dev, uint8_t sjtag_mode) |
Set the SJTAG mode for the Switchtec device. More... | |
int | switchtec_sjtag_hr_send (struct switchtec_dev *dev, uint8_t *sjtag_hr) |
Send SJTAG host response to the device. More... | |
int | switchtec_otp_sjtag_uuid_set (struct switchtec_dev *dev, uint8_t *sjtag_uuid) |
Set the SJTAG UUID for a Switchtec device. More... | |
int | switchtec_otp_sjtag_key_set (struct switchtec_dev *dev, uint8_t *sjtag_key) |
Set the SJTAG key in the OTP memory of the Switchtec device. More... | |
int | switchtec_otp_config_prog (struct switchtec_dev *dev, uint16_t config_len, uint8_t *config_data, bool is_firmware_halt) |
Programs the OTP configuration on the Switchtec device. More... | |
int | switchtec_otp_config_read (struct switchtec_dev *dev, uint16_t config_start_address, int32_t config_length, int out_fd) |
Reads OTP configuration data from the device. More... | |
int | switchtec_otp_sjtag_key_verify (struct switchtec_dev *dev, uint8_t *sjtag_key, uint8_t *is_verified) |
Verify the SJTAG key in the OTP memory. More... | |
int | switchtec_otp_sjtag_key_lock (struct switchtec_dev *dev) |
Locks the SJTAG key on the specified Switchtec device. More... | |
int | switchtec_chip_serial_num_prog (struct switchtec_dev *dev, uint32_t chip_serial_num) |
Program the chip serial number for a Switchtec device. More... | |
int | switchtec_otp_sku_info_set (struct switchtec_dev *dev, struct otp_sku_info_set *sku_info_set_str) |
Set the SKU information in the OTP memory of the Switchtec device. More... | |
int | switchtec_sjtag_get_uuid_idcode (struct switchtec_dev *dev, uint8_t *sjtag_uuid_ptr, uint8_t *sjtag_idcode) |
Retrieve the UUID and ID code from the switchtec device. More... | |
int | switchtec_sjtag_get_nonce (struct switchtec_dev *dev, struct sjtag_nonce *sjtag_nonce_ptr) |
Retrieve the SJTAG nonce from the device. More... | |
int | switchtec_sjtag_status_get (struct switchtec_dev *dev, struct sjtag_status_get *sjtag_sts_get) |
Get the SJTAG status from the switchtec device. More... | |
void | sjtag_encode_cmd_header (uint8_t *cmd_header, uint8_t cmd) |
This function generates the command header to send to the server. More... | |
int | sjtag_debug_token_gen (uint8_t *idcode_ptr, uint8_t *uuid_ptr, uint8_t *suv_ptr, uint8_t *sjtag_debug_token, bool verbose) |
This Generates the Debug Token. More... | |
int | switchtec_read_sjtag_debug_token_file (FILE *debug_token_file, struct sjtag_debug_token *debug_token) |
This function fetches the Debug Token from a bin file. More... | |
int | switchtec_otp_regs_write_protect (struct switchtec_dev *dev, bool sku_info, bool otp_config) |
Write Protect given choice of OTP Regions. More... | |
int | switchtec_otp_sku_info_get (struct switchtec_dev *dev, struct otp_sku_info_get *sku_info_get_str) |
Get SKU Information and Write Protected Status. More... | |
int | switchtec_otp_self_test_policy_set (struct switchtec_dev *dev, uint8_t *self_test_policy) |
Program Self Test Policy into OTP. More... | |
int | switchtec_otp_die_trace_prog (struct switchtec_dev *dev, uint8_t *die_trace) |
Progrom Die Trace into OTP. More... | |
int | switchtec_otp_bit_byte_prog_mode_set (struct switchtec_dev *dev, bool bit_byte_mode) |
Set Bit or Byte Mode for OTP. More... | |
int | switchtec_otp_smart_prog_mode_set (struct switchtec_dev *dev, bool smart_prog_mode) |
Set Smart Programming mode for OTP. More... | |
int | switchtec_otp_mode_status_get (struct switchtec_dev *dev, struct otp_mode_status *otp_mode_status_str) |
Get Status of Programming Modes in OTP. More... | |
int | switchtec_custid_prog (struct switchtec_dev *dev, uint16_t cust_id) |
Program given customer id into OTP. More... | |
int | switchtec_active_image_index_get (struct switchtec_dev *dev, struct switchtec_active_index *index) |
Get active image index. More... | |
int | switchtec_active_image_index_set (struct switchtec_dev *dev, struct switchtec_active_index *index) |
Set active image index. More... | |
int | switchtec_fw_exec (struct switchtec_dev *dev, enum switchtec_bl2_recovery_mode recovery_mode) |
Execute the transferred firmware. More... | |
int | switchtec_boot_resume (struct switchtec_dev *dev) |
Resume device boot. Note that after calling this function, the current 'dev' pointer is no longer valid. Before making further calls to switchtec library functions, be sure to close this pointer and get a new one by calling switchtec_open(). Also be sure to check the return value of switchtec_open() for error, as the device might not be immediately accessible after normal boot process. More... | |
int | switchtec_secure_state_set (struct switchtec_dev *dev, enum switchtec_secure_state state) |
Set device secure state. More... | |
static int | dbg_unlock_send_pubkey (struct switchtec_dev *dev, struct switchtec_pubkey *public_key) |
Send the public key to unlock the device. More... | |
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. More... | |
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. More... | |
int | switchtec_read_sec_cfg_file (struct switchtec_dev *dev, FILE *setting_file, struct switchtec_security_cfg_set *set) |
Read security settings from config file. More... | |
static int | kmsk_set_send_pubkey (struct switchtec_dev *dev, struct switchtec_pubkey *public_key) |
Set and send the public key to the device. More... | |
static int | kmsk_set_send_signature (struct switchtec_dev *dev, struct switchtec_signature *signature) |
Set the KMSK send signature. More... | |
static int | kmsk_set_send_kmsk (struct switchtec_dev *dev, struct switchtec_kmsk *kmsk) |
Set the KMSK (Key Management Security Key) for the device. More... | |
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 partition, which contains keys to verify all other partitions. More... | |
int | switchtec_read_kmsk_file (FILE *kmsk_file, struct switchtec_kmsk *kmsk) |
Read KMSK data from KMSK file. More... | |
int | switchtec_read_signature_file (FILE *sig_file, struct switchtec_signature *signature) |
Read signature data from signature file. More... | |
int | switchtec_read_uuid_file (FILE *uuid_file, struct switchtec_uuid *uuid) |
Read UUID data from UUID file. More... | |
int | switchtec_read_sjtag_key_file (FILE *sjtag_file, struct otp_sjtag_key *sjtag_key) |
Read SJTAG key data from SJTAG file. More... | |
int | switchtec_read_otp_config_data_file (FILE *config_file, struct otp_config_data *config_data, unsigned short config_len) |
Read OTP Config data from bin file. More... | |
int | switchtec_read_self_test_policy_file (FILE *self_test_file, struct otp_self_test_policy *otp_self_test_policy) |
Read Self Test Policy from bin file. More... | |
int | switchtec_read_die_trace_file (FILE *die_trace_file, struct otp_die_trace *otp_die_trace_ptr) |
Read Die Trace from die trace bin file. More... | |
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. It is a key used to verify Key Manifest partition, which contains keys used to verify all other partitions. More... | |
int | switchtec_sn_ver_get (struct switchtec_dev *dev, struct switchtec_sn_ver_info *info) |
Get serial number and security version. More... | |
Manufacturing-related API functions.
These are functions used during manufacturing process. These includes functions that configure device security settings and recover device from boot failures.
Some of these functions modify device One-Time-Programming (OTP) memory, so they should be used with great caution, and you should really know what you are doing when calling these functions. FAILURE TO DO SO COULD MAKE YOUR DEVICE UNBOOTABLE!!
|
static |
Converts SPI clock rate from float to an integer index.
This function takes a floating-point SPI clock rate and converts it to an integer index based on predefined clock rate arrays. The function supports both high rate and normal rate conversions.
clk_float | [in] The SPI clock rate as a float. |
hi_rate | [in] A flag indicating whether to use the high rate clock array. |
|
static |
|
static |
Retrieve configuration settings from the device.
[in] | dev | Pointer to the switchtec device structure. |
[out] | cfgs | Pointer to the structure where configuration settings will be stored. |
[out] | otp_valid | Pointer to an integer that will be set to true if OTP is valid, false otherwise. |
|
static |
Get I2C operands based on the Switchtec generation.
[in] | gen | The Switchtec generation. |
[out] | addr_shift | Pointer to store the address shift value. |
[out] | map_shift | Pointer to store the map shift value. |
[out] | map_mask | Pointer to store the map mask value. |
|
static |
|
static |
|
static |
|
static |
int sjtag_debug_token_gen | ( | uint8_t * | idcode_ptr, |
uint8_t * | uuid_ptr, | ||
uint8_t * | suv_ptr, | ||
uint8_t * | sjtag_debug_token, | ||
bool | verbose | ||
) |
This Generates the Debug Token.
idcode_ptr | [in] Pointer to IDCODE |
uuid_ptr | [in] Pointer to UUID |
suv_ptr | [in] Pointer to SUV |
sjtag_debug_token | [out] Debug Token |
verbose | [in] verbose enable/disable |
void sjtag_encode_cmd_header | ( | uint8_t * | cmd_header, |
uint8_t | cmd | ||
) |
int switchtec_active_image_index_get | ( | struct switchtec_dev * | dev, |
struct switchtec_active_index * | index | ||
) |
int switchtec_active_image_index_set | ( | struct switchtec_dev * | dev, |
struct switchtec_active_index * | index | ||
) |
int switchtec_boot_resume | ( | struct switchtec_dev * | dev | ) |
Resume device boot. Note that after calling this function, the current 'dev' pointer is no longer valid. Before making further calls to switchtec library functions, be sure to close this pointer and get a new one by calling switchtec_open(). Also be sure to check the return value of switchtec_open() for error, as the device might not be immediately accessible after normal boot process.
[in] | dev | Switchtec device handle |
int switchtec_chip_serial_num_prog | ( | struct switchtec_dev * | dev, |
uint32_t | chip_serial_num | ||
) |
int switchtec_custid_prog | ( | struct switchtec_dev * | dev, |
uint16_t | cust_id | ||
) |
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 | ||
) |
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.
[in] | dev | Switchtec device handle |
[in] | serial | Device serial number |
[in] | ver_sec_unlock | New secure unlock version |
[in] | public_key | public key data |
[in] | signature | Signature of data sent |
int switchtec_fw_exec | ( | struct switchtec_dev * | dev, |
enum switchtec_bl2_recovery_mode | recovery_mode | ||
) |
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 partition, which contains keys to verify all other partitions.
[in] | dev | Switchtec device handle |
[in] | public_key | Public key |
[in] | signature | Signature |
[in] | kmsk | KMSK entry data |
int switchtec_mailbox_to_file | ( | struct switchtec_dev * | dev, |
int | fd | ||
) |
|
static |
Execute a manufacturing command on the Switchtec device.
[in] | dev | Pointer to the Switchtec device structure. |
[in] | cmd | Command to be executed. |
[in] | payload | Pointer to the payload data. |
[in] | payload_len | Length of the payload data. |
[out] | resp | Pointer to the response buffer. |
[in] | resp_len | Length of the response buffer. |
int switchtec_otp_bit_byte_prog_mode_set | ( | struct switchtec_dev * | dev, |
bool | bit_byte_mode | ||
) |
int switchtec_otp_config_prog | ( | struct switchtec_dev * | dev, |
uint16_t | config_len, | ||
uint8_t * | config_data, | ||
bool | is_firmware_halt | ||
) |
Programs the OTP configuration on the Switchtec device.
dev | [in] Pointer to the Switchtec device structure. |
config_len | [in] Length of the configuration data. |
config_data | [in] Pointer to the configuration data. |
is_firmware_halt | [in] Boolean flag indicating if the firmware should halt. |
int switchtec_otp_config_read | ( | struct switchtec_dev * | dev, |
uint16_t | config_start_address, | ||
int32_t | config_length, | ||
int | out_fd | ||
) |
Reads OTP configuration data from the device.
[in] | dev | Pointer to the switchtec device structure. |
[in] | config_start_address | The starting address of the configuration data to read. |
[in] | config_length | The length of the configuration data to read. |
[in] | out_fd | The file descriptor to write the configuration data to. |
int switchtec_otp_die_trace_prog | ( | struct switchtec_dev * | dev, |
uint8_t * | die_trace | ||
) |
int switchtec_otp_mode_status_get | ( | struct switchtec_dev * | dev, |
struct otp_mode_status * | otp_mode_status_str | ||
) |
Get Status of Programming Modes in OTP.
[in] | dev | Switchtec device handle |
[out] | otp_mode_status_str | pointer to structure otp_mode_status |
int switchtec_otp_regs_write_protect | ( | struct switchtec_dev * | dev, |
bool | sku_info, | ||
bool | otp_config | ||
) |
int switchtec_otp_self_test_policy_set | ( | struct switchtec_dev * | dev, |
uint8_t * | self_test_policy | ||
) |
int switchtec_otp_sjtag_key_lock | ( | struct switchtec_dev * | dev | ) |
int switchtec_otp_sjtag_key_set | ( | struct switchtec_dev * | dev, |
uint8_t * | sjtag_key | ||
) |
int switchtec_otp_sjtag_key_verify | ( | struct switchtec_dev * | dev, |
uint8_t * | sjtag_key, | ||
uint8_t * | is_verified | ||
) |
Verify the SJTAG key in the OTP memory.
[in] | dev | Pointer to the switchtec device structure. |
[in] | sjtag_key | Pointer to the SJTAG key to be verified. |
[out] | is_verified | Pointer to a variable that will be set to 1 if the key is verified, 0 otherwise. |
int switchtec_otp_sjtag_mode_set | ( | struct switchtec_dev * | dev, |
uint8_t | sjtag_mode | ||
) |
int switchtec_otp_sjtag_uuid_set | ( | struct switchtec_dev * | dev, |
uint8_t * | sjtag_uuid | ||
) |
Set the SJTAG UUID for a Switchtec device.
[in] | dev | Pointer to the Switchtec device structure. |
[in] | sjtag_uuid | Pointer to the SJTAG UUID to be set. |
int switchtec_otp_sku_info_get | ( | struct switchtec_dev * | dev, |
struct otp_sku_info_get * | sku_info_get_str | ||
) |
int switchtec_otp_sku_info_set | ( | struct switchtec_dev * | dev, |
struct otp_sku_info_set * | sku_info_set_str | ||
) |
Set the SKU information in the OTP memory of the Switchtec device.
[in] | dev | Pointer to the Switchtec device structure. |
[in] | sku_info_set_str | Pointer to the structure containing SKU information to be set. |
int switchtec_otp_smart_prog_mode_set | ( | struct switchtec_dev * | dev, |
bool | smart_prog_mode | ||
) |
int switchtec_read_die_trace_file | ( | FILE * | die_trace_file, |
struct otp_die_trace * | otp_die_trace_ptr | ||
) |
Read Die Trace from die trace bin file.
[in] | die_trace_file | Die Trace file |
[out] | otp_die_trace_ptr | Pointer to otp_die_trace structure |
int switchtec_read_kmsk_file | ( | FILE * | kmsk_file, |
struct switchtec_kmsk * | kmsk | ||
) |
int switchtec_read_otp_config_data_file | ( | FILE * | config_file, |
struct otp_config_data * | config_data, | ||
unsigned short | config_len | ||
) |
int switchtec_read_sec_cfg_file | ( | struct switchtec_dev * | dev, |
FILE * | setting_file, | ||
struct switchtec_security_cfg_set * | set | ||
) |
int switchtec_read_self_test_policy_file | ( | FILE * | self_test_file, |
struct otp_self_test_policy * | otp_self_test_policy | ||
) |
Read Self Test Policy from bin file.
[in] | self_test_file | Self test policy file |
[out] | otp_self_test_policy | Self Test Policy Structure |
int switchtec_read_signature_file | ( | FILE * | sig_file, |
struct switchtec_signature * | signature | ||
) |
int switchtec_read_sjtag_debug_token_file | ( | FILE * | debug_token_file, |
struct sjtag_debug_token * | debug_token | ||
) |
int switchtec_read_sjtag_key_file | ( | FILE * | sjtag_file, |
struct otp_sjtag_key * | sjtag_key | ||
) |
int switchtec_read_uuid_file | ( | FILE * | uuid_file, |
struct switchtec_uuid * | uuid | ||
) |
int switchtec_secure_state_set | ( | struct switchtec_dev * | dev, |
enum switchtec_secure_state | state | ||
) |
int switchtec_security_config_get | ( | struct switchtec_dev * | dev, |
struct switchtec_security_cfg_state * | state | ||
) |
int switchtec_security_config_set | ( | struct switchtec_dev * | dev, |
struct switchtec_security_cfg_set * | setting | ||
) |
int switchtec_security_spi_avail_rate_get | ( | struct switchtec_dev * | dev, |
struct switchtec_security_spi_avail_rate * | rates | ||
) |
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. It is a key used to verify Key Manifest partition, which contains keys used to verify all other partitions.
[in] | state | Secure config |
[out] | kmsk | KMSK entry to check for |
int switchtec_sjtag_get_nonce | ( | struct switchtec_dev * | dev, |
struct sjtag_nonce * | sjtag_nonce_ptr | ||
) |
int switchtec_sjtag_get_uuid_idcode | ( | struct switchtec_dev * | dev, |
uint8_t * | sjtag_uuid_ptr, | ||
uint8_t * | sjtag_idcode | ||
) |
Retrieve the UUID and ID code from the switchtec device.
[in] | dev | Pointer to the switchtec device structure. |
[out] | sjtag_uuid_ptr | Pointer to the structure where the UUID will be stored. |
[out] | sjtag_idcode | Pointer to the structure where the ID code will be stored. |
int switchtec_sjtag_hr_send | ( | struct switchtec_dev * | dev, |
uint8_t * | sjtag_hr | ||
) |
int switchtec_sjtag_status_get | ( | struct switchtec_dev * | dev, |
struct sjtag_status_get * | sjtag_sts_get | ||
) |
int switchtec_sn_ver_get | ( | struct switchtec_dev * | dev, |
struct switchtec_sn_ver_info * | info | ||
) |