mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 00:51:29 +00:00
Add format functions to express BCT and bootloader data value
Add a new field to the value_data table, which is the function to use to format the data value. Signed-off-by: Penny Chiu <pchiu@nvidia.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
This commit is contained in:
committed by
Stephen Warren
parent
fac5875bae
commit
3d0bff52c4
@@ -27,36 +27,53 @@
|
||||
int enable_debug;
|
||||
cbootimage_soc_config * g_soc_config;
|
||||
|
||||
static void format_u32_hex8(char const * message, void * data);
|
||||
static void format_u32(char const * message, void * data);
|
||||
|
||||
typedef void (*format_function)(char const * message, void * data);
|
||||
|
||||
typedef struct {
|
||||
parse_token id;
|
||||
char const * message;
|
||||
format_function format;
|
||||
} value_data;
|
||||
|
||||
static value_data const values[] = {
|
||||
{ token_boot_data_version, "Version = 0x%08x;\n" },
|
||||
{ token_block_size_log2, "BlockSize = 0x%08x;\n" },
|
||||
{ token_page_size_log2, "PageSize = 0x%08x;\n" },
|
||||
{ token_partition_size, "PartitionSize = 0x%08x;\n" },
|
||||
{ token_odm_data, "OdmData = 0x%08x;\n\n" },
|
||||
{ token_bootloader_used, "# Bootloader used = %d;\n" },
|
||||
{ token_bootloaders_max, "# Bootloaders max = %d;\n" },
|
||||
{ token_bct_size, "# BCT size = %d;\n" },
|
||||
{ token_hash_size, "# Hash size = %d;\n" },
|
||||
{ token_crypto_offset, "# Crypto offset = %d;\n" },
|
||||
{ token_crypto_length, "# Crypto length = %d;\n" },
|
||||
{ token_max_bct_search_blks, "# Max BCT search blocks = %d;\n" },
|
||||
{ token_boot_data_version, "Version = ", format_u32_hex8 },
|
||||
{ token_block_size_log2, "BlockSize = ", format_u32_hex8 },
|
||||
{ token_page_size_log2, "PageSize = ", format_u32_hex8 },
|
||||
{ token_partition_size, "PartitionSize = ", format_u32_hex8 },
|
||||
{ token_odm_data, "OdmData = ", format_u32_hex8 },
|
||||
{ token_bootloader_used, "# Bootloader used = ", format_u32 },
|
||||
{ token_bootloaders_max, "# Bootloaders max = ", format_u32 },
|
||||
{ token_bct_size, "# BCT size = ", format_u32 },
|
||||
{ token_hash_size, "# Hash size = ", format_u32 },
|
||||
{ token_crypto_offset, "# Crypto offset = ", format_u32 },
|
||||
{ token_crypto_length, "# Crypto length = ", format_u32 },
|
||||
{ token_max_bct_search_blks, "# Max BCT search blocks = ", format_u32 },
|
||||
};
|
||||
|
||||
static value_data const bl_values[] = {
|
||||
{ token_bl_version, "Version = 0x%08x;\n" },
|
||||
{ token_bl_start_blk, "Start block = %d;\n" },
|
||||
{ token_bl_start_page, "Start page = %d;\n" },
|
||||
{ token_bl_length, "Length = %d;\n" },
|
||||
{ token_bl_load_addr, "Load address = 0x%08x;\n" },
|
||||
{ token_bl_entry_point, "Entry point = 0x%08x;\n" },
|
||||
{ token_bl_attribute, "Attributes = 0x%08x;\n" },
|
||||
{ token_bl_version, "Version = ", format_u32_hex8 },
|
||||
{ token_bl_start_blk, "Start block = ", format_u32 },
|
||||
{ token_bl_start_page, "Start page = ", format_u32 },
|
||||
{ token_bl_length, "Length = ", format_u32 },
|
||||
{ token_bl_load_addr, "Load address = ", format_u32_hex8 },
|
||||
{ token_bl_entry_point, "Entry point = ", format_u32_hex8 },
|
||||
{ token_bl_attribute, "Attributes = ", format_u32_hex8 },
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
static void format_u32_hex8(char const * message, void * data)
|
||||
{
|
||||
printf("%s0x%08x;\n", message, *((u_int32_t *) data));
|
||||
}
|
||||
|
||||
static void format_u32(char const * message, void * data)
|
||||
{
|
||||
printf("%s%d;\n", message, *((u_int32_t *) data));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
static void usage(void)
|
||||
{
|
||||
@@ -164,7 +181,7 @@ int main(int argc, char *argv[])
|
||||
values[i].id == token_page_size_log2)
|
||||
data = 1 << data;
|
||||
|
||||
printf(values[i].message, data);
|
||||
values[i].format(values[i].message, &data);
|
||||
}
|
||||
|
||||
/* Display bootloader values */
|
||||
@@ -192,7 +209,7 @@ int main(int argc, char *argv[])
|
||||
if (e != 0)
|
||||
data = -1;
|
||||
|
||||
printf(bl_values[j].message, data);
|
||||
bl_values[j].format(bl_values[j].message, &data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user