EDT PDV SDK Documentation 6.1.0
edt_bitload.h File Reference

(git ddc052b, 2023-10-30)

This graph shows which files directly or indirectly include this file:

Data Structures

struct  EdtBitfileHeader
 
struct  EdtBitfile
 
struct  _bitfile_list
 
struct  EdtBoardFpgas
 

Macros

#define BFH_EXTRASIZE   128
 
#define BITLOAD_FLAGS_OVR   0x2
 
#define BITLOAD_FLAGS_CH1   0x8
 
#define BITLOAD_FLAGS_MEZZANINE   0x4
 
#define _DEPRECATED_BITLOAD_FLAGS_OCM   0x4
 
#define _DEPRECATED_BITLOAD_FLAGS_SRXL   0x10
 

Typedefs

typedef struct EdtBitfile EdtBitfile
 
typedef struct _bitfile_list EdtBitfileList
 

Functions

void bf_init (EdtBitfileList *bf)
 Initialize a bitfile list to zero. More...
 
void bf_destroy (EdtBitfileList *bf)
 Frees the memory for a list of bitfiles. More...
 
void bf_add_entry (EdtBitfileList *bf, EdtBitfileHeader *bfh)
 Adds a bitfile header to a list of bitfiles. More...
 
void bf_check_and_add (EdtBitfileList *bf, const char *fname)
 Checks if a bitfile exists and adds it to the bitfile list if it does. More...
 
int bf_allocate_max_buffer (EdtBitfileList *bf, EdtBitfile *data)
 Allocates data to the largest bitfile size found in the bf list. More...
 
EDT_LIB_LOCAL const char * edt_bitload_basedir (EdtDev edt_p, const char *in, char *out)
 Gets the base directory based on the device type (PDV vs. PCD). More...
 
int edt_get_bitfile_list (const char *basedir, const char *devdir, const char *fname, EdtBoardFpgas *fpga_list, int id, int channel, EdtBitfileList *bf, char *fpga_hint)
 Gets all possible bitfiles with name fname and stores them in list bf. If fpga_hint is present, it will be first in the list. More...
 
int edt_load_mezzfile (EdtDev edt_p, const char *basedir, const char *bitname, int bitload_flags, int skip_load, int channel)
 Loads a mezzanine bitfile. More...
 
int edt_get_bitfile_header (EdtBitfile *bp, EdtBitfileHeader *bfh)
 Extract the FPGA header (Xilinx, OR faked one for Altera, etc.) More...
 
int edt_program_mezzanine (EdtDev edt_p, const u_char *buf, u_int size, int channel)
 Program the mezzanine bitfile. Wraps edt_program_mezzanine_direct(). More...
 
EDT_LIB_LOCAL int edt_program_flash_direct (EdtDev edt_p, const u_char *buf, int size, int do_sleep)
 Program the interface FPGA. Typically only called by edt_bitload. More...
 
EDT_LIB_LOCAL int edt_program_mezzanine_direct (EdtDev edt_p, const u_char *buf, int size, int channel)
 Program the mezzanine bitfile. More...
 
int edt_bitload (EdtDev edt_p, const char *basedir, const char *fname, int flags, int skip)
 
int edt_bitfile_load_file (EdtBitfile *bfd, const char *name)
 Opens a bitfile and populates the bfd structure. More...
 
void edt_bitfile_init (EdtBitfile *bitfile)
 Initialize an EdtBitfile data structure. More...
 
void edt_bitfile_destroy (EdtBitfile *bfd)
 Closes the associated file handle, zeros fields, and frees allocated memory for the given EdtBitfile structure. More...
 
void ensure_bitfile_name (const char *name, char *bitname)
 
int edt_get_x_array_header (u_char *ba, char *header, int *size)
 Get the FPGA header from an array, typically as read out from an FPGA. More...
 

Detailed Description

Header file for declarations & defines related to loading the Xilinx bitfile.

Macro Definition Documentation

◆ BFH_EXTRASIZE

#define BFH_EXTRASIZE   128

Number of bytes to read in for bitfile preamble.

◆ BITLOAD_FLAGS_OVR

#define BITLOAD_FLAGS_OVR   0x2

Override GS/SS bitfile size constraint

◆ BITLOAD_FLAGS_CH1

#define BITLOAD_FLAGS_CH1   0x8

Program OCM channel 1 if BITLOAD_FLAGS_OCM is set

◆ BITLOAD_FLAGS_MEZZANINE

#define BITLOAD_FLAGS_MEZZANINE   0x4

Changes programming algorithm to program mezzanine boards.

◆ _DEPRECATED_BITLOAD_FLAGS_OCM

#define _DEPRECATED_BITLOAD_FLAGS_OCM   0x4
Deprecated:
Use BITLOAD_FLAGS_MEZZANINE.

◆ _DEPRECATED_BITLOAD_FLAGS_SRXL

#define _DEPRECATED_BITLOAD_FLAGS_SRXL   0x10
Deprecated:
Use BITLOAD_FLAGS_MEZZANINE.

Typedef Documentation

◆ EdtBitfile

typedef struct EdtBitfile EdtBitfile

Structure used to access UI bitfile.

◆ EdtBitfileList

typedef struct _bitfile_list EdtBitfileList

Structure describing a list of bitfiles and their associated headers.

Function Documentation

◆ bf_init()

void bf_init ( EdtBitfileList bf)

Initialize a bitfile list to zero.

Parameters
bfPointer to the bitfile list to initialize.
Here is the caller graph for this function:

◆ bf_destroy()

void bf_destroy ( EdtBitfileList bf)

Frees the memory for a list of bitfiles.

Parameters
bfPointer to the bitfile list to destroy.
Here is the call graph for this function:

◆ bf_add_entry()

void bf_add_entry ( EdtBitfileList bf,
EdtBitfileHeader bfh 
)

Adds a bitfile header to a list of bitfiles.

Parameters
bfPointer to the bitfile list to add to.
bfhPointer to the bitfile header to add.

◆ bf_check_and_add()

void bf_check_and_add ( EdtBitfileList bf,
const char *  fname 
)

Checks if a bitfile exists and adds it to the bitfile list if it does.

Parameters
bfPointer to the bitfile list to add to.
fnameName of the bitfile to check for.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bf_allocate_max_buffer()

int bf_allocate_max_buffer ( EdtBitfileList bf,
EdtBitfile data 
)

Allocates data to the largest bitfile size found in the bf list.

Deallocate with edt_bitfile_destroy()

Parameters
bfPointer to the bitfile list to read.
[out]dataBitfile struct with EdtBitfile.full_buffer set to an allocated array of size EdtBitfile.buffer_allocated bytes.
Returns
0 on success, -1 on failure.

◆ edt_bitload_basedir()

EDT_LIB_LOCAL const char * edt_bitload_basedir ( EdtDev  edt_p,
const char *  in,
char *  out 
)

Gets the base directory based on the device type (PDV vs. PCD).

Parameters
edt_pThe open EDT device handle.
inThe name of the directory. Optional, if set, it will be returned.
outThe resulting directory. Optional, if set, will overwritten with the home directory value and returned.
Returns
The resulting directory.

◆ edt_get_bitfile_list()

int edt_get_bitfile_list ( const char *  basedir,
const char *  devdir,
const char *  fname,
EdtBoardFpgas fpga_list,
int  id,
int  channel,
EdtBitfileList bf,
char *  fpga_hint 
)

Gets all possible bitfiles with name fname and stores them in list bf. If fpga_hint is present, it will be first in the list.

Parameters
basedirThe base directory to look for the bitfile in.
devdirThe device directory to look for the bitfile in.
fnameThe name of the bitfile.
fpga_listThe list of available FPGAs.
idEither a board id or a mezzanine id, which is used to look up FPGA type(s) in the fpga_list.
channelIndex into the mezz_chips array.
bfThe list of bitfiles to add to.
fpga_hintThe name of the fpga to check for.
Returns
0 on success, -1 on failure.

Assumes bf has been initialized

Here is the call graph for this function:

◆ edt_load_mezzfile()

int edt_load_mezzfile ( EdtDev  edt_p,
const char *  basedir,
const char *  bitname,
int  bitload_flags,
int  skip_load,
int  channel 
)

Loads a mezzanine bitfile.

Parameters
edt_pThe open EDT device handle.
basedirThe base directory to look for the bitfile in.
bitnameThe name of the bitfile.
bitload_flagsFlags to use when loading the bitfile.
skip_loadCurrently not used.
channelIndex into the mezz_chips array.
Returns
0 on success, -1 on failure.

◆ edt_get_bitfile_header()

int edt_get_bitfile_header ( EdtBitfile bp,
EdtBitfileHeader bfh 
)

Extract the FPGA header (Xilinx, OR faked one for Altera, etc.)

Parameters
bpStruct that will be populated with the FPGA file information.
bfhStruct that will be populated with the FPGA file header information.
Returns
-1 on error, otherwise the address of the beginning of the FPGA data (after the header).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ edt_program_mezzanine()

int edt_program_mezzanine ( EdtDev  edt_p,
const u_char *  buf,
u_int  size,
int  channel 
)

Program the mezzanine bitfile. Wraps edt_program_mezzanine_direct().

Parameters
edt_pThe open EDT device handle.
bufPointer to the bitfile data.
sizeSize of the bitfile data.
channelWhich channel the data is directed to.
Returns
0 on success, -1 on failure.

◆ edt_program_flash_direct()

EDT_LIB_LOCAL int edt_program_flash_direct ( EdtDev  edt_p,
const u_char *  buf,
int  size,
int  do_sleep 
)

Program the interface FPGA. Typically only called by edt_bitload.

Parameters
edt_pThe open EDT device handle.
bufBuffer containing the data to be loaded.
sizeNumber of bytes to load from buffer.
do_sleepEnable (1) or disable (0) delays to slow flashing down in case of host speed issues.
Returns
0 on success, nonzero on failure

◆ edt_program_mezzanine_direct()

EDT_LIB_LOCAL int edt_program_mezzanine_direct ( EdtDev  edt_p,
const u_char *  buf,
int  size,
int  channel 
)

Program the mezzanine bitfile.

Parameters
edt_pPointer to the device structure.
bufPointer to the bitfile data.
sizeSize of the bitfile data.
channelWhich channel the data is directed to.
Returns
0 on success, -1 on failure.

◆ edt_bitfile_load_file()

int edt_bitfile_load_file ( EdtBitfile bfd,
const char *  name 
)

Opens a bitfile and populates the bfd structure.

Parameters
bfdThe structure to be populated.
nameThe path of the file to open.
Returns
0 on success, -1 on failure.

◆ edt_bitfile_init()

void edt_bitfile_init ( EdtBitfile bitfile)

Initialize an EdtBitfile data structure.

Parameters
bitfileThe structure to be initialized.
Here is the caller graph for this function:

◆ edt_bitfile_destroy()

void edt_bitfile_destroy ( EdtBitfile bfd)

Closes the associated file handle, zeros fields, and frees allocated memory for the given EdtBitfile structure.

Parameters
bfdThe bitfile to be destroyed.

◆ ensure_bitfile_name()

void ensure_bitfile_name ( const char *  name,
char *  bitname 
)

Normalizes a bitfile name to ensure it is valid.

Parameters
nameName of bitfile before normalization.
bitnameThe normalized bitfile name.

◆ edt_get_x_array_header()

int edt_get_x_array_header ( u_char *  ba,
char *  header,
int *  size 
)

Get the FPGA header from an array, typically as read out from an FPGA.

Parameters
baArray containing data bytes presumably read from the FPGA.
headerString that will be populated with the header info in a printable format.
sizeSize of the formatted header string.
Returns
0 on success, -1 on failure.
Here is the call graph for this function: