Switchtec Userspace
PROJECT_NUMBER = PROJECT_NUMBER=PROJECT_NUMBER = 2.2
|
Retrieve firmware information and update or retrieve images. More...
Classes | |
struct | switchtec_fw_footer_gen3 |
struct | switchtec_fw_metadata_gen4 |
struct | switchtec_fw_image_header_gen3 |
struct | cmd_fwdl |
struct | switchtec_flash_info_gen4 |
struct | switchtec_boot_ro |
Functions | |
int | switchtec_fw_toggle_active_partition (struct switchtec_dev *dev, int toggle_bl2, int toggle_key, int toggle_fw, int toggle_cfg) |
Toggle the active firmware partition for the main or configuration images. More... | |
int | switchtec_fw_setup_redundancy (struct switchtec_dev *dev, enum switchtec_fw_redundancy redund, enum switchtec_fw_type type) |
Set or clear the redundancy flag of a partition type. More... | |
int | switchtec_fw_write_fd (struct switchtec_dev *dev, int img_fd, int dont_activate, int force, void(*progress_callback)(int cur, int tot)) |
Write a firmware file to the switchtec device. More... | |
int | switchtec_fw_write_file (struct switchtec_dev *dev, FILE *fimg, int dont_activate, int force, void(*progress_callback)(int cur, int tot)) |
Write a firmware file to the switchtec device. More... | |
void | switchtec_fw_perror (const char *s, int ret) |
Print an error string to stdout. More... | |
int | switchtec_fw_file_info (int fd, struct switchtec_fw_image_info *info) |
Retrieve information about a firmware image file. More... | |
int | switchtec_fw_file_secure_version_newer (struct switchtec_dev *dev, int img_fd) |
Check if the secure version of an image file is newer than that of the image on device. More... | |
const char * | switchtec_fw_image_type (const struct switchtec_fw_image_info *info) |
Return a string describing the type of a firmware image. More... | |
static int | switchtec_fw_part_info (struct switchtec_dev *dev, int nr_info, struct switchtec_fw_image_info *info) |
Return firmware information structures for a number of firmware partitions. More... | |
struct switchtec_fw_part_summary * | switchtec_fw_part_summary (struct switchtec_dev *dev) |
Return firmware summary information structure for the flash partitfons in the device. More... | |
void | switchtec_fw_part_summary_free (struct switchtec_fw_part_summary *summary) |
Free a firmware part summary data structure. More... | |
int | switchtec_fw_read (struct switchtec_dev *dev, unsigned long addr, size_t len, void *buf) |
Read a Switchtec device's flash data. More... | |
int | switchtec_fw_read_fd (struct switchtec_dev *dev, int fd, unsigned long addr, size_t len, void(*progress_callback)(int cur, int tot)) |
Read a Switchtec device's flash data into a file. More... | |
int | switchtec_fw_body_read_fd (struct switchtec_dev *dev, int fd, struct switchtec_fw_image_info *info, void(*progress_callback)(int cur, int tot)) |
Read a Switchtec device's flash image body into a file. More... | |
int | switchtec_fw_img_write_hdr (int fd, struct switchtec_fw_image_info *info) |
Write the header for a Switchtec firmware image file. More... | |
int | switchtec_fw_is_boot_ro (struct switchtec_dev *dev) |
Check if the boot partition is marked as read-only. More... | |
int | switchtec_fw_set_boot_ro (struct switchtec_dev *dev, enum switchtec_fw_ro ro) |
Set or clear a boot partition's read-only flag. More... | |
int | switchtec_flash_part (struct switchtec_dev *dev, struct switchtec_fw_image_info *info, enum switchtec_fw_image_part_id_gen3 part) |
Retrieve information about a flash partition. More... | |
Retrieve firmware information and update or retrieve images.
switchtec_fw_write_fd() may be used to update a Switchtec firmware image. switchtec_fw_read_fd() can retrieve a firmware image into a local file. switchtec_fw_img_info() and switchtec_fw_cfg_info() may be used to query information about the currently programmed images.
int switchtec_flash_part | ( | struct switchtec_dev * | dev, |
struct switchtec_fw_image_info * | info, | ||
enum switchtec_fw_image_part_id_gen3 | part | ||
) |
Retrieve information about a flash partition.
[in] | dev | Switchtec device handle |
[out] | info | Structure to place the result in |
[in] | part | Which partition to retrieve |
Definition at line 251 of file platform.c.
int switchtec_fw_body_read_fd | ( | struct switchtec_dev * | dev, |
int | fd, | ||
struct switchtec_fw_image_info * | info, | ||
void(*)(int cur, int tot) | progress_callback | ||
) |
Read a Switchtec device's flash image body into a file.
[in] | dev | Switchtec device handle |
[in] | fd | File descriptor for image file to write |
[in] | info | Partition information structure |
[in] | progress_callback | This function is called periodically to indicate the progress of the read. May be NULL. |
int switchtec_fw_file_info | ( | int | fd, |
struct switchtec_fw_image_info * | info | ||
) |
int switchtec_fw_file_secure_version_newer | ( | struct switchtec_dev * | dev, |
int | img_fd | ||
) |
Check if the secure version of an image file is newer than that of the image on device.
[in] | dev | Switchtec device handle |
[in] | img_fd | Image file descriptor |
const char* switchtec_fw_image_type | ( | const struct switchtec_fw_image_info * | info | ) |
int switchtec_fw_img_write_hdr | ( | int | fd, |
struct switchtec_fw_image_info * | info | ||
) |
Write the header for a Switchtec firmware image file.
[in] | fd | File descriptor for image file to write |
[in] | info | Partition information structure |
The offset of image body in the image file is greater than or equal to the image header length. This function also repositions the read/write file offset of fd to the offset of image body in the image file if needed. This will facilitate the switchtec_fw_read_fd() function which is usually called following this function to complete a firmware image read.
int switchtec_fw_is_boot_ro | ( | struct switchtec_dev * | dev | ) |
|
static |
Return firmware information structures for a number of firmware partitions.
[in] | dev | Switchtec device handle |
[in] | nr_info | Number of partitions to retrieve the info for |
[out] | info | Pointer to a list of info structs of at least nr_info entries |
struct switchtec_fw_part_summary* switchtec_fw_part_summary | ( | struct switchtec_dev * | dev | ) |
Return firmware summary information structure for the flash partitfons in the device.
[in] | dev | Switchtec device handle nr_info entries |
void switchtec_fw_part_summary_free | ( | struct switchtec_fw_part_summary * | summary | ) |
void switchtec_fw_perror | ( | const char * | s, |
int | ret | ||
) |
int switchtec_fw_read | ( | struct switchtec_dev * | dev, |
unsigned long | addr, | ||
size_t | len, | ||
void * | buf | ||
) |
int switchtec_fw_read_fd | ( | struct switchtec_dev * | dev, |
int | fd, | ||
unsigned long | addr, | ||
size_t | len, | ||
void(*)(int cur, int tot) | progress_callback | ||
) |
Read a Switchtec device's flash data into a file.
[in] | dev | Switchtec device handle |
[in] | fd | File descriptor of the file to save the firmware data to |
[in] | addr | Address to read from |
[in] | len | Number of bytes to read |
[in] | progress_callback | This function is called periodically to indicate the progress of the read. May be NULL. |
int switchtec_fw_set_boot_ro | ( | struct switchtec_dev * | dev, |
enum switchtec_fw_ro | ro | ||
) |
int switchtec_fw_setup_redundancy | ( | struct switchtec_dev * | dev, |
enum switchtec_fw_redundancy | redund, | ||
enum switchtec_fw_type | type | ||
) |
Set or clear the redundancy flag of a partition type.
[in] | dev | Switchtec device handle |
[in] | redund | Whether to set or clear the redundancy flag |
[in] | type | Switchtec fw partition type |
This function does not support Gen3 switch.
int switchtec_fw_toggle_active_partition | ( | struct switchtec_dev * | dev, |
int | toggle_bl2, | ||
int | toggle_key, | ||
int | toggle_fw, | ||
int | toggle_cfg | ||
) |
Toggle the active firmware partition for the main or configuration images.
[in] | dev | Switchtec device handle |
[in] | toggle_bl2 | Set to 1 to toggle the BL2 FW image |
[in] | toggle_key | Set to 1 to toggle the key manifest FW image |
[in] | toggle_fw | Set to 1 to toggle the main FW image |
[in] | toggle_cfg | Set to 1 to toggle the config FW image |
int switchtec_fw_write_fd | ( | struct switchtec_dev * | dev, |
int | img_fd, | ||
int | dont_activate, | ||
int | force, | ||
void(*)(int cur, int tot) | progress_callback | ||
) |
Write a firmware file to the switchtec device.
[in] | dev | Switchtec device handle |
[in] | img_fd | File descriptor for the image file to write |
[in] | force | If 1, ignore if another download command is already in progress. |
[in] | dont_activate | If 1, the new image will not be activated |
[in] | progress_callback | If not NULL, this function will be called to indicate the progress. |
int switchtec_fw_write_file | ( | struct switchtec_dev * | dev, |
FILE * | fimg, | ||
int | dont_activate, | ||
int | force, | ||
void(*)(int cur, int tot) | progress_callback | ||
) |
Write a firmware file to the switchtec device.
[in] | dev | Switchtec device handle |
[in] | fimg | FILE pointer for the image file to write |
[in] | dont_activate | If 1, the new image will not be activated |
[in] | force | If 1, ignore if another download command is already in progress. |
[in] | progress_callback | If not NULL, this function will be called to indicate the progress. |