xilpdi
Vitis Drivers API Documentation
XilPDI APIs

Functions

int XilPdi_ValidateChecksum (const void *Buffer, u32 Length)
 This function is used to validate the word checksum for the Image Header table and Partition Headers. More...
 
int XilPdi_ValidateImgHdrTbl (const XilPdi_ImgHdrTbl *ImgHdrTbl)
 This function checks the fields of the Image Header Table and validates them. More...
 
int XilPdi_ValidatePrtnHdr (const XilPdi_PrtnHdr *PrtnHdr)
 This function validates the Partition Header. More...
 
void XilPdi_ReadBootHdr (const XilPdi_BootHdr **BootHdrPtr)
 This function reads the boot header. More...
 
int XilPdi_ReadImgHdrTbl (XilPdi_MetaHdr *MetaHdrPtr)
 This function Reads the Image Header Table. More...
 
int XilPdi_ReadIhtAndOptionalData (XilPdi_MetaHdr *MetaHdrPtr, u8 PdiType)
 This function reads IHT and optional data in Image Header Table. More...
 
int XilPdi_ReadOptionalData (XilPdi_MetaHdr *MetaHdrPtr, u8 PdiType)
 This function reads optional data in Image Header Table. More...
 
int XilPdi_StoreDigestTable (XilPdi_MetaHdr *MetaHdrPtr)
 This function stores digest table for given data Id. More...
 
u64 XilPdi_SearchOptionalData (u64 StartAddress, u64 EndAddress, u32 DataId)
 This function search offset of optional data address. More...
 
XilPdi_PrtnHashInfoXilPdi_IsPrtnHashPresent (u32 PrtnNum, u32 HashTableSize)
 This function checks if partition hash is present. More...
 
int XilPdi_ReadImgHdrs (const XilPdi_MetaHdr *MetaHdrPtr)
 This function reads the Image Headers. More...
 
int XilPdi_ReadPrtnHdrs (const XilPdi_MetaHdr *MetaHdrPtr)
 This function reads the Partition Headers. More...
 
int XilPdi_VerifyPrtnHdrs (const XilPdi_MetaHdr *MetaHdrPtr)
 This function verifies Partition Headers. More...
 
int XilPdi_VerifyImgHdrs (const XilPdi_MetaHdr *MetaHdrPtr)
 This function verifies Image headers. More...
 

Function Documentation

XilPdi_PrtnHashInfo* XilPdi_IsPrtnHashPresent ( u32  PrtnNum,
u32  HashTableSize 
)

This function checks if partition hash is present.

Parameters
PrtnNumPrtnNum to check partition hash is present or not
HashTableSizeSize of hash table
Returns
  • HashEntry Offset of partition hash to skip authentication.
  • NULL To authenticate the signature as regular flow.

References XIH_PMC_RAM_IHT_OP_DATA_STORE_ADDR.

void XilPdi_ReadBootHdr ( const XilPdi_BootHdr **  BootHdrPtr)

This function reads the boot header.

Parameters
BootHdrPtris pointer to the address of Boot Header
  • Copy boot header to local variable from PRAM address

References XIH_BH_PRAM_ADDR.

int XilPdi_ReadIhtAndOptionalData ( XilPdi_MetaHdr MetaHdrPtr,
u8  PdiType 
)

This function reads IHT and optional data in Image Header Table.

Parameters
MetaHdrPtris pointer to MetaHeader table.
Returns
  • XST_SUCCESS on successful read.
  • XST_FAILURE on unsuccessful copy.

Clear 2KB PMC RAM which is allocated to store IHT OPTIONAL DATA

  • Read the IHT from Metaheader

References XilPdi_MetaHdr::ImgHdrTbl, XIH_IHT_LEN, XIH_PMC_RAM_IHT_OP_DATA_STORE_ADDR, and XilPdi_ReadOptionalData().

int XilPdi_ReadImgHdrs ( const XilPdi_MetaHdr MetaHdrPtr)

This function reads the Image Headers.

Parameters
MetaHdrPtris pointer to Meta Header
Returns
  • XST_SUCCESS on successful read.
  • XST_FAILURE on unsuccessful read.
  • Read the Image headers of 64 bytes and update the Image Header structure for all images

References XilPdi_MetaHdr::DeviceCopy, XilPdi_MetaHdr::FlashOfstAddr, XilPdi_MetaHdr::ImgHdr, XilPdi_ImgHdrTbl::ImgHdrAddr, XilPdi_MetaHdr::ImgHdrTbl, and XilPdi_ImgHdrTbl::NoOfImgs.

int XilPdi_ReadImgHdrTbl ( XilPdi_MetaHdr MetaHdrPtr)

This function Reads the Image Header Table.

Parameters
MetaHdrPtris pointer to MetaHeader table
Returns
  • XST_SUCCESS on successful read.
  • XST_FAILURE on unsuccessful copy of image header table.
  • Read the Img header table of 64 bytes and update the Image Header Table structure
  • Discard or ignore SMAP header when detected in partial PDIs

References XilPdi_MetaHdr::DeviceCopy, XilPdi_MetaHdr::FlashOfstAddr, XilPdi_MetaHdr::ImgHdrTbl, XilPdi_MetaHdr::MetaHdrOfst, SMAP_BUS_WIDTH_LENGTH, and XIH_IHT_LEN.

int XilPdi_ReadOptionalData ( XilPdi_MetaHdr MetaHdrPtr,
u8  PdiType 
)

This function reads optional data in Image Header Table.

Parameters
MetaHdrPtris pointer to MetaHeader table.
PdiTypeis PDI type
Returns
  • XST_SUCCESS on successful read.
  • XST_FAILURE on unsuccessful copy.
  • Read the IHT Optional data from Metaheader

References XilPdi_MetaHdr::DeviceCopy, XilPdi_MetaHdr::FlashOfstAddr, XilPdi_MetaHdr::ImgHdrTbl, XilPdi_MetaHdr::MetaHdrOfst, XilPdi_ImgHdrTbl::OptionalDataLen, SMAP_BUS_WIDTH_LENGTH, XIH_IHT_LEN, and XILPDI_OPTIONAL_DATA_MAX_SIZE_16K_BYTES.

Referenced by XilPdi_ReadIhtAndOptionalData().

int XilPdi_ReadPrtnHdrs ( const XilPdi_MetaHdr MetaHdrPtr)

This function reads the Partition Headers.

Parameters
MetaHdrPtris pointer to Meta Header
Returns
  • XST_SUCCESS on successful read.
  • XST_FAILURE on unsuccessful read.
  • Read the Partition headers of 64 bytes and update the Image Header structure for all images

References XilPdi_MetaHdr::DeviceCopy, XilPdi_MetaHdr::FlashOfstAddr, XilPdi_MetaHdr::ImgHdrTbl, XilPdi_ImgHdrTbl::NoOfPrtns, XilPdi_MetaHdr::PrtnHdr, and XilPdi_ImgHdrTbl::PrtnHdrAddr.

u64 XilPdi_SearchOptionalData ( u64  StartAddress,
u64  EndAddress,
u32  DataId 
)

This function search offset of optional data address.

Parameters
StartAddressis start address of IHT optional data
EndAddressis end address of IHT optional data
DataIdis to identify type of data in data structure
Returns
  • Offset on getting successful optional data offset address for given data Id.

Referenced by XilPdi_StoreDigestTable().

int XilPdi_StoreDigestTable ( XilPdi_MetaHdr MetaHdrPtr)

This function stores digest table for given data Id.

Parameters
MetaHdrPtris pointer to MetaHeader table.
Returns
  • XST_SUCCESS on successful read.
  • XST_FAILURE on unsuccessful copy.
IHT Optional data format:
-------------------------------------------------------------------------
|    0x00    |            Size (31:16)            |    Data Id (15:0)   |
-------------------------------------------------------------------------
|    0x04    |            Data (Size in words)                          |
-------------------------------------------------------------------------
|    Last    |            Checksum (Sum of previous words in DS)        |
-------------------------------------------------------------------------
DigestTableSize is size of Data except first(0x00) and last word(Last)

Verify checksum of data structure info

Copy only data part

References XilPdi_MetaHdr::DigestTableSize, XilPdi_MetaHdr::ImgHdrTbl, XilPdi_MetaHdr::IsAuthOptimized, XilPdi_ImgHdrTbl::OptionalDataLen, XIH_PMC_RAM_IHT_OP_DATA_STORE_ADDR, XILPDI_OPTIONAL_DATA_WORD_LEN, XILPDI_PARTITION_HASH_DATA_ID, XilPdi_SearchOptionalData(), and XilPdi_ValidateChecksum().

int XilPdi_ValidateChecksum ( const void *  Buffer,
u32  Length 
)

This function is used to validate the word checksum for the Image Header table and Partition Headers.

            Checksum is based on the below formula
            Checksum = ~(X1 + X2 + X3 + .... + Xn)
Parameters
Bufferpointer for the data words
Lengthof the buffer for which checksum should be calculated. Last word is taken as expected checksum.
Returns
  • XST_SUCCESS for successful checksum validation.
  • XST_FAILURE if checksum validation fails.
  • Verify the buffer is not empty and has at least 2 values
  • Calculate the checksum with the below formula Checksum = ~(X1 + X2 + X3 + .... + Xn)
  • Verify the calculated checksum with the checksum in buffer

References XILPDI_CHECKSUM_MIN_BUF_LEN, and XILPDI_INVERT_CHECKSUM.

Referenced by XilPdi_StoreDigestTable(), XilPdi_ValidateImgHdrTbl(), XilPdi_VerifyImgHdrs(), and XilPdi_VerifyPrtnHdrs().

int XilPdi_ValidateImgHdrTbl ( const XilPdi_ImgHdrTbl ImgHdrTbl)

This function checks the fields of the Image Header Table and validates them.

Image Header Table contains the fields that are common across all the partitions and images.

Parameters
ImgHdrTblpointer to the Image Header Table
Returns
  • XST_SUCCESS on successful Image Header Table validation.
  • XILPDI_ERR_IHT_CHECKSUM if checksum validation fails.
  • XILPDI_ERR_NO_OF_IMGS if number of images is less than 0 or more than 32.
  • XILPDI_ERR_NO_OF_PRTNS if number of partitions is less than 0 or more than 32.
  • Calculate the checksum of Image Header Table and compare it with the value in Image Header Table
  • Verify the number of images are greater than zero and less than or equal to 32
  • Verify the number of partitions are greater than zero and less than or equal to 32

References XilPdi_ImgHdrTbl::NoOfImgs, XilPdi_ImgHdrTbl::NoOfPrtns, XIH_IHT_LEN, XILPDI_ERR_IHT_CHECKSUM, and XilPdi_ValidateChecksum().

int XilPdi_ValidatePrtnHdr ( const XilPdi_PrtnHdr PrtnHdr)

This function validates the Partition Header.

Parameters
PrtnHdris pointer to Partition Header
Returns
  • XST_SUCCESS on successful Partition Header validation.
  • XILPDI_ERR_ZERO_LENGTH if partition length is 0.
  • XILPDI_ERR_TOTAL_LENGTH if total length is not matching encoded and unencoded word length.
  • XILPDI_ERR_PRTN_TYPE if partition type is other than elf, cdo, raw, raw_elf, cfi_gsc and cfi_gsc_unmask.
  • Verify the partition length is not zero. Otherwise, return XILPDI_ERR_ZERO_LENGTH error.
  • Verify the total partition length is not less than the encrypted data word and unencrypted data word length. Otherwise, return XILPDI_ERR_TOTAL_LENGTH error.
  • Verify that the partition type is one of elf, cdo, raw raw_elf, cfi_gsc or cfi_gsc_unmask. Otherwise, return XILPDI_ERR_PRTN_TYPE error.

References XilPdi_PrtnHdr::EncDataWordLen, XilPdi_PrtnHdr::TotalDataWordLen, XilPdi_PrtnHdr::UnEncDataWordLen, and XIH_PH_ATTRB_PRTN_TYPE_RSVD.

int XilPdi_VerifyImgHdrs ( const XilPdi_MetaHdr MetaHdrPtr)

This function verifies Image headers.

Parameters
MetaHdrPtris pointer to MetaHeader table.
Returns
  • XST_SUCCESS on successful image validation.
  • XILPDI_ERR_IH_CHECKSUM on checksum fail.
  • Verify checksum of all image Headers

References XilPdi_MetaHdr::ImgHdr, XilPdi_MetaHdr::ImgHdrTbl, XilPdi_ImgHdrTbl::NoOfImgs, and XilPdi_ValidateChecksum().

int XilPdi_VerifyPrtnHdrs ( const XilPdi_MetaHdr MetaHdrPtr)

This function verifies Partition Headers.

Parameters
MetaHdrPtris pointer to MetaHeader table
Returns
  • XST_SUCCESS on success.
  • XILPDI_ERR_PH_CHECKSUM on checksum fail.
  • Verify checksum of all Partition Headers

References XilPdi_MetaHdr::ImgHdrTbl, XilPdi_ImgHdrTbl::NoOfPrtns, XilPdi_MetaHdr::PrtnHdr, and XilPdi_ValidateChecksum().