Velocity Userspace
Classes | Functions
mfg.c File Reference

Switchtec core library functions for mfg operations. More...

#include "switchtec_priv.h"
#include "switchtec/switchtec.h"
#include "switchtec/mfg.h"
#include "switchtec/errors.h"
#include "switchtec/endian.h"
#include "switchtec/mrpc.h"
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
#include <arpa/inet.h>
#include <iconv.h>
#include "lib/crc.h"
#include "config.h"
Include dependency graph for mfg.c:

Go to the source code of this file.

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...
 

Detailed Description

Switchtec core library functions for mfg operations.

Definition in file mfg.c.