18 static int read_section(FILE *input_file,
int length_size,
char section,
19 uint32_t *buffer_length, uint8_t **
buffer)
21 uint8_t length_buffer[4];
26 if ((length_size != 2) && (length_size != 4)) {
27 LOG_ERROR(
"BUG: length_size neither 2 nor 4");
31 read_count = fread(§ion_char, 1, 1, input_file);
35 if (section_char != section)
38 read_count = fread(length_buffer, 1, length_size, input_file);
39 if (read_count != length_size)
64 if (!filename || !bit_file)
67 input_file = fopen(filename,
"rb");
69 LOG_ERROR(
"couldn't open %s: %s", filename, strerror(errno));
80 if (read_count != 13) {
81 LOG_ERROR(
"couldn't read unknown_header from file '%s'", filename);
128 free(bit_file->
date);
129 free(bit_file->
time);
130 free(bit_file->
data);
#define ERROR_COMMAND_SYNTAX_ERROR
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
#define ERROR_PLD_FILE_LOAD_FAILED
uint8_t unknown_header[13]
static uint32_t be_to_h_u32(const uint8_t *buf)
static uint16_t be_to_h_u16(const uint8_t *buf)
void xilinx_free_bit_file(struct xilinx_bit_file *bit_file)
int xilinx_read_bit_file(struct xilinx_bit_file *bit_file, const char *filename)
static int read_section(FILE *input_file, int length_size, char section, uint32_t *buffer_length, uint8_t **buffer)