summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPenny Chiu <pchiu@nvidia.com>2012-12-21 21:17:37 +0800
committerStephen Warren <swarren@nvidia.com>2013-01-11 08:36:49 -0800
commit5f4e2a3a2e2d4424053d8c4479323284d3b8dbf6 (patch)
treeaf75a98665657e3f30c86b61cc692c075485e6da
parentce21ef893f0a0b321c2e0a99ff8a1641d6c40625 (diff)
downloadnvidia-cbootimage-5f4e2a3a2e2d4424053d8c4479323284d3b8dbf6.tar.gz
Rewrite the interface for T20/T30 bct data access
Create a structure called cbootimage_soc_config that defines a chip, and data tables and functions for that chip. The main function just sets appropriate instance based on boot_data_version, then uses the same interface to access different chip bct data. Change-Id: I58fbc07012dce8947467c0bea62e2a50126d54fe Signed-off-by: Penny Chiu <pchiu@nvidia.com> Reviewed-on: http://git-master/r/173670 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Rhyland Klein <rklein@nvidia.com> Reviewed-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r--bct_dump.c57
-rw-r--r--cbootimage.c60
-rw-r--r--cbootimage.h3
-rw-r--r--crypto.c8
-rw-r--r--data_layout.c68
-rw-r--r--parse.c35
-rw-r--r--parse.h42
-rw-r--r--set.c6
-rw-r--r--t20/nvbctlib_t20.c51
-rw-r--r--t20/nvboot_bct_t20.h6
-rw-r--r--t20/nvboot_sdram_param_t20.h6
-rw-r--r--t30/nvbctlib_t30.c51
-rw-r--r--t30/nvboot_bct_t30.h6
-rw-r--r--t30/nvboot_sdram_param_t30.h6
14 files changed, 223 insertions, 182 deletions
diff --git a/bct_dump.c b/bct_dump.c
index 12f2fa9..dbef913 100644
--- a/bct_dump.c
+++ b/bct_dump.c
@@ -24,9 +24,8 @@
#include "t20/nvboot_bct_t20.h"
#include <string.h>
-int enable_debug = 0;
-
-bct_parse_interface *g_bct_parse_interf;
+int enable_debug;
+cbootimage_soc_config * g_soc_config;
typedef struct {
parse_token id;
@@ -139,7 +138,6 @@ int main(int argc, char *argv[])
u_int32_t parameters_used;
u_int32_t sdram_used;
nvboot_dev_type type;
- nvboot_config_table *bct = NULL;
u_int32_t data;
int i;
int j;
@@ -148,22 +146,15 @@ int main(int argc, char *argv[])
usage();
memset(&context, 0, sizeof(build_image_context));
-
- g_bct_parse_interf = malloc(sizeof(bct_parse_interface));
- if (g_bct_parse_interf == NULL) {
- printf("Insufficient memory to proceed.\n");
- return -EINVAL;
- }
-
context.bct_filename = argv[1];
e = read_bct_file(&context);
if (e != 0)
return e;
- bct = (nvboot_config_table *)(context.bct);
+
/* Display root values */
for (i = 0; i < sizeof(values) / sizeof(values[0]); ++i) {
- e = g_bct_parse_interf->get_value(values[i].id,
+ e = g_soc_config->get_value(values[i].id,
&data,
context.bct);
@@ -177,7 +168,7 @@ int main(int argc, char *argv[])
}
/* Display bootloader values */
- e = g_bct_parse_interf->get_value(token_bootloader_used,
+ e = g_soc_config->get_value(token_bootloader_used,
&bootloaders_used,
context.bct);
@@ -192,7 +183,7 @@ int main(int argc, char *argv[])
for (i = 0; i < bootloaders_used; ++i) {
for (j = 0; j < bl_count; ++j) {
- e = g_bct_parse_interf->getbl_param(i,
+ e = g_soc_config->getbl_param(i,
bl_values[j].id,
&data,
context.bct);
@@ -207,7 +198,7 @@ int main(int argc, char *argv[])
}
/* Display flash device parameters */
- e = g_bct_parse_interf->get_value(token_num_param_sets,
+ e = g_soc_config->get_value(token_num_param_sets,
&parameters_used,
context.bct);
@@ -216,36 +207,28 @@ int main(int argc, char *argv[])
char const * prefix = NULL;
field_item const * item;
- e = g_bct_parse_interf->get_dev_param(&context,
+ e = g_soc_config->get_dev_param(&context,
i,
token_dev_type,
&type);
printf("\n"
"DevType[%d] = ", i);
- display_enum_value(&context, s_devtype_table_t20, type);
+ display_enum_value(&context, g_soc_config->devtype_table, type);
printf(";\n");
switch (type) {
case nvboot_dev_type_spi:
- device_field_table = s_spiflash_table_t20;
+ device_field_table = g_soc_config->spiflash_table;
prefix = "SpiFlashParams";
break;
case nvboot_dev_type_sdmmc:
- if (bct->boot_data_version ==
- NVBOOT_BOOTDATA_VERSION(3, 1))
- device_field_table = s_sdmmc_table_t30;
- else
- device_field_table = s_sdmmc_table_t20;
+ device_field_table = g_soc_config->sdmmc_table;
prefix = "SdmmcParams";
break;
case nvboot_dev_type_nand:
- if (bct->boot_data_version ==
- NVBOOT_BOOTDATA_VERSION(3, 1))
- device_field_table = s_nand_table_t30;
- else
- device_field_table = s_nand_table_t20;
+ device_field_table = g_soc_config->nand_table;
prefix = "NandParams";
break;
@@ -261,7 +244,7 @@ int main(int argc, char *argv[])
int width = max_width(device_field_table);
for (item = device_field_table; item->name != NULL; ++item) {
- g_bct_parse_interf->get_dev_param(&context,
+ g_soc_config->get_dev_param(&context,
i,
item->token,
&data);
@@ -278,25 +261,19 @@ int main(int argc, char *argv[])
}
/* Display SDRAM parameters */
- e = g_bct_parse_interf->get_value(token_num_sdram_sets,
+ e = g_soc_config->get_value(token_num_sdram_sets,
&sdram_used,
context.bct);
for (i = 0; (e == 0) && (i < sdram_used); ++i) {
- field_item const *s_sdram_field_table;
field_item const *item;
printf("\n");
- if (bct->boot_data_version == NVBOOT_BOOTDATA_VERSION(3, 1))
- s_sdram_field_table = s_sdram_field_table_t30;
- else
- s_sdram_field_table = s_sdram_field_table_t20;
-
- int width = max_width(s_sdram_field_table);
+ int width = max_width(g_soc_config->sdram_field_table);
- for (item = s_sdram_field_table; item->name != NULL; ++item) {
- e = g_bct_parse_interf ->get_sdram_param(&context,
+ for (item = g_soc_config->sdram_field_table; item->name != NULL; ++item) {
+ e = g_soc_config->get_sdram_param(&context,
i,
item->token,
&data);
diff --git a/cbootimage.c b/cbootimage.c
index 55b88d2..0118a73 100644
--- a/cbootimage.c
+++ b/cbootimage.c
@@ -32,11 +32,10 @@
/*
* Global data
*/
-int enable_debug = 0;
+int enable_debug;
+static int help_only; // Only print help & exit
+cbootimage_soc_config * g_soc_config;
-static int help_only = 0; // Only print help & exit
-
-bct_parse_interface *g_bct_parse_interf;
/*
* Function prototypes
*/
@@ -64,14 +63,14 @@ usage(void)
{
printf("Usage: cbootimage [options] configfile imagename\n");
printf(" options:\n");
- printf(" -h, --help, -? Display this message.\n");
- printf(" -d, --debug Output debugging information.\n");
- printf(" -gbct Generate the new bct file.\n");
- printf(" -o<ODM_DATA> Specify the odm_data(in hex).\n");
- printf(" [-t20|-t25|-t30] Select one of the possible\n");
- printf(" target devices, -t20 if unspecified\n");
- printf(" configfile File with configuration information\n");
- printf(" imagename Output image name\n");
+ printf(" -h, --help, -? Display this message.\n");
+ printf(" -d, --debug Output debugging information.\n");
+ printf(" -gbct Generate the new bct file.\n");
+ printf(" -o<ODM_DATA> Specify the odm_data(in hex).\n");
+ printf(" [-t20|-t30] Select one of the possible target devices,\n");
+ printf(" -t20 if unspecified.\n");
+ printf(" configfile File with configuration information\n");
+ printf(" imagename Output image name\n");
}
static int
@@ -81,15 +80,6 @@ process_command_line(int argc, char *argv[], build_image_context *context)
context->generate_bct = 0;
- g_bct_parse_interf = malloc(sizeof(bct_parse_interface));
- if (g_bct_parse_interf == NULL) {
- printf("Insufficient memory to proceed.\n");
- return -EINVAL;
- }
- /* Make the default interface to t20. */
- t20_get_cbootimage_interf(g_bct_parse_interf);
- context->boot_data_version = NVBOOT_BOOTDATA_VERSION(2, 1);
-
while ((c = getopt_long(argc, argv, "hdg:t:o:", cbootcmd, NULL)) != -1) {
switch (c) {
case 'h':
@@ -109,16 +99,11 @@ process_command_line(int argc, char *argv[], build_image_context *context)
}
break;
case 't':
- if (!(strcasecmp("20", optarg)
- && strcasecmp("25", optarg))) {
- /* Assign the interface based on the chip. */
- t20_get_cbootimage_interf(g_bct_parse_interf);
- context->boot_data_version =
- NVBOOT_BOOTDATA_VERSION(2, 1);
- } else if (!(strcasecmp("30", optarg))) {
- t30_get_cbootimage_interf(g_bct_parse_interf);
- context->boot_data_version =
- NVBOOT_BOOTDATA_VERSION(3, 1);
+ /* Assign the soc_config based on the chip. */
+ if (!strcasecmp("20", optarg)) {
+ t20_get_soc_config(context, &g_soc_config);
+ } else if (!strcasecmp("30", optarg)) {
+ t30_get_soc_config(context, &g_soc_config);
} else {
printf("Unsupported chipname!\n");
usage();
@@ -136,6 +121,11 @@ process_command_line(int argc, char *argv[], build_image_context *context)
usage();
return -EINVAL;
}
+
+ /* If SoC is not specified, make the default soc_config to t20. */
+ if (!context->boot_data_version)
+ t20_get_soc_config(context, &g_soc_config);
+
/* Open the configuration file. */
context->config_file = fopen(argv[optind], "r");
if (context->config_file == NULL) {
@@ -161,12 +151,12 @@ main(int argc, char *argv[])
if (process_command_line(argc, argv, &context) != 0)
return -EINVAL;
- assert(g_bct_parse_interf != NULL);
+ assert(g_soc_config != NULL);
if (help_only)
return 1;
- g_bct_parse_interf->get_value(token_bct_size,
+ g_soc_config->get_value(token_bct_size,
&context.bct_size,
context.bct);
@@ -235,9 +225,5 @@ main(int argc, char *argv[])
/* Clean up memory. */
cleanup_context(&context);
- if (g_bct_parse_interf) {
- free(g_bct_parse_interf);
- g_bct_parse_interf = NULL;
- }
return e;
}
diff --git a/cbootimage.h b/cbootimage.h
index 1f45c88..8d79a8f 100644
--- a/cbootimage.h
+++ b/cbootimage.h
@@ -38,6 +38,9 @@
#define NVBOOT_BAD_BLOCK_TABLE_SIZE 4096
#define NV_MAX(a, b) (((a) > (b)) ? (a) : (b))
+#define BOOTDATA_VERSION_T20 NVBOOT_BOOTDATA_VERSION(0x2, 0x1)
+#define BOOTDATA_VERSION_T30 NVBOOT_BOOTDATA_VERSION(0x3, 0x1)
+
/*
* Enumerations
*/
diff --git a/crypto.c b/crypto.c
index 7e49c00..88de357 100644
--- a/crypto.c
+++ b/crypto.c
@@ -267,15 +267,15 @@ sign_bct(build_image_context *context,
assert(bct != NULL);
- if (g_bct_parse_interf->get_value(token_hash_size,
+ if (g_soc_config->get_value(token_hash_size,
&hash_size,
bct) != 0)
return -ENODATA;
- if (g_bct_parse_interf->get_value(token_crypto_offset,
+ if (g_soc_config->get_value(token_crypto_offset,
&Offset,
bct) != 0)
return -ENODATA;
- if (g_bct_parse_interf->get_value(token_crypto_length,
+ if (g_soc_config->get_value(token_crypto_length,
&length,
bct) != 0)
return -ENODATA;
@@ -286,7 +286,7 @@ sign_bct(build_image_context *context,
e = sign_data_block(bct + Offset, length, hash_buffer);
if (e != 0)
goto fail;
- e = g_bct_parse_interf->set_data(token_crypto_hash,
+ e = g_soc_config->set_data(token_crypto_hash,
hash_buffer,
hash_size,
bct);
diff --git a/data_layout.c b/data_layout.c
index 2a2230e..13d8f7f 100644
--- a/data_layout.c
+++ b/data_layout.c
@@ -28,7 +28,6 @@
#include "set.h"
#include "context.h"
#include "parse.h"
-#include "t20/nvboot_bct_t20.h"
#include <sys/param.h>
typedef struct blk_data_rec
@@ -309,14 +308,14 @@ fail:
#define SET_BL_FIELD(instance, field, value) \
do { \
- g_bct_parse_interf->setbl_param(instance, \
+ g_soc_config->setbl_param(instance, \
token_bl_##field, \
&(value), \
context->bct); \
} while (0);
#define GET_BL_FIELD(instance, field, ptr) \
-g_bct_parse_interf->getbl_param(instance, \
+g_soc_config->getbl_param(instance, \
token_bl_##field, \
ptr, \
context->bct);
@@ -387,9 +386,9 @@ write_bootloaders(build_image_context *context)
pages_per_blk = 1 << (context->block_size_log2
- context->page_size_log2);
- g_bct_parse_interf->get_value(token_hash_size,
+ g_soc_config->get_value(token_hash_size,
&hash_size, context->bct);
- g_bct_parse_interf->get_value(token_bootloaders_max,
+ g_soc_config->get_value(token_bootloaders_max,
&bootloaders_max, context->bct);
hash_buffer = malloc(hash_size);
@@ -408,7 +407,7 @@ write_bootloaders(build_image_context *context)
* a BL in the device.
*/
GET_BL_FIELD(0, version, &bl_0_version);
- g_bct_parse_interf->get_value(token_bootloader_used,
+ g_soc_config->get_value(token_bootloader_used,
&bl_used, context->bct);
for (bl_instance = 0; bl_instance < bl_used; bl_instance++) {
u_int32_t bl_version;
@@ -438,11 +437,11 @@ write_bootloaders(build_image_context *context)
COPY_BL_FIELD(inst_from, inst_to, entry_point);
COPY_BL_FIELD(inst_from, inst_to, attribute);
- g_bct_parse_interf->getbl_param(inst_from,
+ g_soc_config->getbl_param(inst_from,
token_bl_crypto_hash,
(u_int32_t*)hash_buffer,
context->bct);
- g_bct_parse_interf->setbl_param(inst_to,
+ g_soc_config->setbl_param(inst_to,
token_bl_crypto_hash,
(u_int32_t*)hash_buffer,
context->bct);
@@ -520,7 +519,7 @@ write_bootloaders(build_image_context *context)
sign_data_block(buffer,
bl_actual_size,
hash_buffer);
- g_bct_parse_interf->setbl_param(bl_instance,
+ g_soc_config->setbl_param(bl_instance,
token_bl_crypto_hash,
(u_int32_t*)hash_buffer,
context->bct);
@@ -555,7 +554,7 @@ write_bootloaders(build_image_context *context)
free(buffer);
}
- g_bct_parse_interf->set_value(token_bootloader_used,
+ g_soc_config->set_value(token_bootloader_used,
context->redundancy + bl_move_count,
context->bct);
@@ -585,7 +584,7 @@ write_bootloaders(build_image_context *context)
load_addr,
entry_point);
- g_bct_parse_interf->getbl_param(i,
+ g_soc_config->getbl_param(i,
token_bl_crypto_hash,
(u_int32_t*)hash_buffer,
context->bct);
@@ -599,6 +598,7 @@ write_bootloaders(build_image_context *context)
free(bl_storage);
free(hash_buffer);
return 0;
+
fail:
/* Cleanup. */
free(buffer);
@@ -611,16 +611,16 @@ fail:
void
update_context(struct build_image_context_rec *context)
{
- g_bct_parse_interf->get_value(token_partition_size,
+ g_soc_config->get_value(token_partition_size,
&context->partition_size,
context->bct);
- g_bct_parse_interf->get_value(token_page_size_log2,
+ g_soc_config->get_value(token_page_size_log2,
&context->page_size_log2,
context->bct);
- g_bct_parse_interf->get_value(token_block_size_log2,
+ g_soc_config->get_value(token_block_size_log2,
&context->block_size_log2,
context->bct);
- g_bct_parse_interf->get_value(token_odm_data,
+ g_soc_config->get_value(token_odm_data,
&context->odm_data,
context->bct);
@@ -665,7 +665,6 @@ read_bct_file(struct build_image_context_rec *context)
u_int8_t *bct_storage; /* Holds the Bl after reading */
u_int32_t bct_actual_size; /* In bytes */
file_type bct_filetype = file_type_bct;
- nvboot_config_table *bct = NULL;
int err = 0;
if (read_from_image(context->bct_filename,
@@ -685,18 +684,13 @@ read_bct_file(struct build_image_context_rec *context)
memcpy(context->bct, bct_storage, context->bct_size);
free(bct_storage);
- bct = (nvboot_config_table *)(context->bct);
- if (bct->boot_data_version == NVBOOT_BOOTDATA_VERSION(3, 1)) {
- t30_get_cbootimage_interf(g_bct_parse_interf);
- context->boot_data_version =
- NVBOOT_BOOTDATA_VERSION(3, 1);
- }
- else {
- t20_get_cbootimage_interf(g_bct_parse_interf);
- context->boot_data_version =
- NVBOOT_BOOTDATA_VERSION(2, 1);
- }
- return err;
+ /* get proper soc_config pointer by polling each supported chip */
+ if (if_bct_is_t20_get_soc_config(context, &g_soc_config))
+ return 0;
+ if (if_bct_is_t30_get_soc_config(context, &g_soc_config))
+ return 0;
+
+ return ENODATA;
}
/*
* Update the next_bct_blk and make it point to the next
@@ -711,7 +705,7 @@ find_new_bct_blk(build_image_context *context)
assert(context);
- g_bct_parse_interf->get_value(token_max_bct_search_blks,
+ g_soc_config->get_value(token_max_bct_search_blks,
&max_bct_search_blks, context->bct);
if (context->next_bct_blk > max_bct_search_blks) {
@@ -744,29 +738,29 @@ begin_update(build_image_context *context)
u_int32_t block_size_log2;
u_int32_t page_size_log2;
- g_bct_parse_interf->get_value(token_block_size_log2,
+ g_soc_config->get_value(token_block_size_log2,
&block_size_log2, context->bct);
- g_bct_parse_interf->get_value(token_page_size_log2,
+ g_soc_config->get_value(token_page_size_log2,
&page_size_log2, context->bct);
printf("begin_update(): bct data: b=%d p=%d\n",
block_size_log2, page_size_log2);
}
- g_bct_parse_interf->set_value(token_boot_data_version,
+ g_soc_config->set_value(token_boot_data_version,
context->boot_data_version, context->bct);
- g_bct_parse_interf->get_value(token_hash_size,
+ g_soc_config->get_value(token_hash_size,
&hash_size, context->bct);
- g_bct_parse_interf->get_value(token_reserved_size,
+ g_soc_config->get_value(token_reserved_size,
&reserved_size, context->bct);
- g_bct_parse_interf->get_value(token_reserved_offset,
+ g_soc_config->get_value(token_reserved_offset,
&reserved_offset, context->bct);
/* Set the odm data */
- g_bct_parse_interf->set_value(token_odm_data,
+ g_soc_config->set_value(token_odm_data,
context->odm_data, context->bct);
/* Initialize the bad block table field. */
- g_bct_parse_interf->init_bad_block_table(context);
+ g_soc_config->init_bad_block_table(context);
/* Fill the reserved data w/the padding pattern. */
write_padding(context->bct + reserved_offset, reserved_size);
diff --git a/parse.c b/parse.c
index 5c074d5..60c5274 100644
--- a/parse.c
+++ b/parse.c
@@ -405,7 +405,7 @@ parse_array(build_image_context *context, parse_token token, char *rest)
case token_dev_type:
rest = parse_enum(context,
rest,
- s_devtype_table_t20,
+ g_soc_config->devtype_table,
&value);
break;
@@ -444,13 +444,13 @@ set_array(build_image_context *context,
switch (token) {
case token_attribute:
- err = g_bct_parse_interf->setbl_param(index,
+ err = g_soc_config->setbl_param(index,
token_bl_attribute,
&value,
context->bct);
break;
case token_dev_type:
- err = g_bct_parse_interf->set_dev_param(context,
+ err = g_soc_config->set_dev_param(context,
index,
token_dev_type,
value);
@@ -509,7 +509,9 @@ parse_bct_file(build_image_context *context, parse_token token, char *rest)
/* Parsing has finished - set the bctfile */
context->bct_filename = filename;
/* Read the bct file to buffer */
- read_bct_file(context);
+ if (read_bct_file(context))
+ return 1;
+
update_context(context);
return 0;
}
@@ -544,16 +546,11 @@ parse_dev_param(build_image_context *context, parse_token token, char *rest)
u_int32_t value;
field_item *field;
u_int32_t index;
- parse_subfield_item *device_type_table;
parse_subfield_item *device_item = NULL;
assert(context != NULL);
assert(rest != NULL);
- if (context->boot_data_version == NVBOOT_BOOTDATA_VERSION(3, 1))
- device_type_table = s_device_type_table_t30;
- else
- device_type_table = s_device_type_table_t20;
/* Parse the index. */
rest = parse_u32(rest, &index);
if (rest == NULL)
@@ -570,16 +567,16 @@ parse_dev_param(build_image_context *context, parse_token token, char *rest)
rest++;
/* Parse the device name. */
- for (i = 0; device_type_table[i].prefix != NULL; i++) {
- if (!strncmp(device_type_table[i].prefix,
- rest, strlen(device_type_table[i].prefix))) {
+ for (i = 0; g_soc_config->device_type_table[i].prefix != NULL; i++) {
+ if (!strncmp(g_soc_config->device_type_table[i].prefix,
+ rest, strlen(g_soc_config->device_type_table[i].prefix))) {
- device_item = &(device_type_table[i]);
- rest = rest + strlen(device_type_table[i].prefix);
+ device_item = &(g_soc_config->device_type_table[i]);
+ rest = rest + strlen(g_soc_config->device_type_table[i].prefix);
/* Parse the field name. */
rest = parse_field_name(rest,
- device_type_table[i].field_table,
+ g_soc_config->device_type_table[i].field_table,
&field);
if (rest == NULL)
return 1;
@@ -635,10 +632,8 @@ parse_sdram_param(build_image_context *context, parse_token token, char *rest)
rest++;
/* Parse the field name. */
- if (context->boot_data_version == NVBOOT_BOOTDATA_VERSION(3, 1))
- rest = parse_field_name(rest, s_sdram_field_table_t30, &field);
- else
- rest = parse_field_name(rest, s_sdram_field_table_t20, &field);
+ rest = parse_field_name(rest, g_soc_config->sdram_field_table, &field);
+
if (rest == NULL)
return 1;
@@ -653,7 +648,7 @@ parse_sdram_param(build_image_context *context, parse_token token, char *rest)
return 1;
/* Store the result. */
- return g_bct_parse_interf->set_sdram_param(context,
+ return g_soc_config->set_sdram_param(context,
index,
field->token,
value);
diff --git a/parse.h b/parse.h
index c683b53..ff92950 100644
--- a/parse.h
+++ b/parse.h
@@ -416,10 +416,10 @@ typedef struct
} parse_item;
/*
- * Set of function pointers to be used to access the different hardware
+ * Set of function pointers and table pointers to be used to access the different hardware
* interface for setting/getting bct information.
*/
-typedef struct bct_parse_interface_rec {
+typedef struct cbootimage_soc_config_rec {
/*
* Set device parameters in bct according to the value listed
*
@@ -541,11 +541,30 @@ typedef struct bct_parse_interface_rec {
u_int8_t *bct);
void (*init_bad_block_table)(build_image_context *context);
-} bct_parse_interface;
+
+ enum_item *devtype_table;
+ enum_item *sdmmc_data_width_table;
+ enum_item *spi_clock_source_table;
+ enum_item *nvboot_memory_type_table;
+ field_item *sdram_field_table;
+ field_item *nand_table;
+ field_item *sdmmc_table;
+ field_item *spiflash_table;
+ parse_subfield_item *device_type_table;
+} cbootimage_soc_config;
void process_config_file(build_image_context *context, u_int8_t simple_parse);
-void t20_get_cbootimage_interf(bct_parse_interface *cbootimage_bct_interf);
-void t30_get_cbootimage_interf(bct_parse_interface *cbootimage_bct_interf);
+
+void t30_get_soc_config(build_image_context *context,
+ cbootimage_soc_config **soc_config);
+void t20_get_soc_config(build_image_context *context,
+ cbootimage_soc_config **soc_config);
+
+int if_bct_is_t30_get_soc_config(build_image_context *context,
+ cbootimage_soc_config **soc_config);
+int if_bct_is_t20_get_soc_config(build_image_context *context,
+ cbootimage_soc_config **soc_config);
+
int
t30_get_dev_param(build_image_context *context,
u_int32_t index,
@@ -593,14 +612,21 @@ u_int32_t iceil_log2(u_int32_t a, u_int32_t b);
/* Returns the smallest power of 2 >= a */
u_int32_t ceil_log2(u_int32_t a);
-extern bct_parse_interface *g_bct_parse_interf;
+extern cbootimage_soc_config *g_soc_config;
+
/*
* Provide access to enum and field tables. These tables are useful when
* pretty printing a BCT file using bct_dump.
*/
extern enum_item s_devtype_table_t20[];
+extern enum_item s_devtype_table_t30[];
+
extern enum_item s_sdmmc_data_width_table_t20[];
+extern enum_item s_sdmmc_data_width_table_t30[];
+
extern enum_item s_spi_clock_source_table_t20[];
+extern enum_item s_spi_clock_source_table_t30[];
+
extern enum_item s_nvboot_memory_type_table_t20[];
extern enum_item s_nvboot_memory_type_table_t30[];
extern field_item s_sdram_field_table_t20[];
@@ -610,7 +636,9 @@ extern field_item s_nand_table_t30[];
extern field_item s_sdmmc_table_t20[];
extern field_item s_sdmmc_table_t30[];
extern field_item s_spiflash_table_t20[];
-extern parse_subfield_item s_device_type_table_t30[];
+extern field_item s_spiflash_table_t30[];
+
extern parse_subfield_item s_device_type_table_t20[];
+extern parse_subfield_item s_device_type_table_t30[];
#endif /* #ifndef INCLUDED_PARSE_H */
diff --git a/set.c b/set.c
index d52b720..08c9fb6 100644
--- a/set.c
+++ b/set.c
@@ -151,7 +151,7 @@ int context_set_value(build_image_context *context,
}
context->pages_per_blk= 1 << (context->block_size_log2-
context->page_size_log2);
- g_bct_parse_interf->set_value(token_block_size_log2,
+ g_soc_config->set_value(token_block_size_log2,
context->block_size_log2, context->bct);
break;
@@ -162,7 +162,7 @@ int context_set_value(build_image_context *context,
}
context->partition_size= value;
- g_bct_parse_interf->set_value(token_partition_size,
+ g_soc_config->set_value(token_partition_size,
value, context->bct);
break;
@@ -172,7 +172,7 @@ int context_set_value(build_image_context *context,
context->pages_per_blk= 1 << (context->block_size_log2-
context->page_size_log2);
- g_bct_parse_interf->set_value(token_page_size_log2,
+ g_soc_config->set_value(token_page_size_log2,
context->page_size_log2, context->bct);
break;
case token_redundancy:
diff --git a/t20/nvbctlib_t20.c b/t20/nvbctlib_t20.c
index 376bc5f..c145d6d 100644
--- a/t20/nvbctlib_t20.c
+++ b/t20/nvbctlib_t20.c
@@ -640,16 +640,45 @@ void t20_init_bad_block_table(build_image_context *context)
table->virtual_blk_size_log2);
}
-void t20_get_cbootimage_interf(bct_parse_interface *cbootimage_bct_interf)
+cbootimage_soc_config tegra20_config = {
+ .init_bad_block_table = t20_init_bad_block_table,
+ .set_dev_param = t20_set_dev_param,
+ .get_dev_param = t20_get_dev_param,
+ .set_sdram_param = t20_set_sdram_param,
+ .get_sdram_param = t20_get_sdram_param,
+ .setbl_param = t20_setbl_param,
+ .getbl_param = t20_getbl_param,
+ .set_value = t20_bct_set_value,
+ .get_value = t20_bct_get_value,
+ .set_data = t20_bct_set_data,
+
+ .devtype_table = s_devtype_table_t20,
+ .sdmmc_data_width_table = s_sdmmc_data_width_table_t20,
+ .spi_clock_source_table = s_spi_clock_source_table_t20,
+ .nvboot_memory_type_table = s_nvboot_memory_type_table_t20,
+ .sdram_field_table = s_sdram_field_table_t20,
+ .nand_table = s_nand_table_t20,
+ .sdmmc_table = s_sdmmc_table_t20,
+ .spiflash_table = s_spiflash_table_t20,
+ .device_type_table = s_device_type_table_t20,
+};
+
+void t20_get_soc_config(build_image_context *context,
+ cbootimage_soc_config **soc_config)
{
- cbootimage_bct_interf->init_bad_block_table = t20_init_bad_block_table;
- cbootimage_bct_interf->set_dev_param = t20_set_dev_param;
- cbootimage_bct_interf->get_dev_param = t20_get_dev_param;
- cbootimage_bct_interf->set_sdram_param = t20_set_sdram_param;
- cbootimage_bct_interf->get_sdram_param = t20_get_sdram_param;
- cbootimage_bct_interf->setbl_param = t20_setbl_param;
- cbootimage_bct_interf->getbl_param = t20_getbl_param;
- cbootimage_bct_interf->set_value = t20_bct_set_value;
- cbootimage_bct_interf->get_value = t20_bct_get_value;
- cbootimage_bct_interf->set_data = t20_bct_set_data;
+ context->boot_data_version = BOOTDATA_VERSION_T20;
+ *soc_config = &tegra20_config;
+}
+
+int if_bct_is_t20_get_soc_config(build_image_context *context,
+ cbootimage_soc_config **soc_config)
+{
+ nvboot_config_table * bct = (nvboot_config_table *) context->bct;
+
+ if (bct->boot_data_version == BOOTDATA_VERSION_T20)
+ {
+ t20_get_soc_config(context, soc_config);
+ return 1;
+ }
+ return 0;
}
diff --git a/t20/nvboot_bct_t20.h b/t20/nvboot_bct_t20.h
index 730d42a..8585cdb 100644
--- a/t20/nvboot_bct_t20.h
+++ b/t20/nvboot_bct_t20.h
@@ -17,8 +17,8 @@
* project.
*/
-#ifndef INCLUDED_NVBOOT_BCT_H
-#define INCLUDED_NVBOOT_BCT_H
+#ifndef INCLUDED_NVBOOT_BCT_T20_H
+#define INCLUDED_NVBOOT_BCT_T20_H
#include <sys/types.h>
#include "nvboot_sdram_param_t20.h"
@@ -313,4 +313,4 @@ typedef struct nvboot_config_table_rec {
u_int8_t enable_fail_back;
u_int8_t reserved[NVBOOT_BCT_RESERVED_SIZE];
} nvboot_config_table;
-#endif /* #ifndef INCLUDED_NVBOOT_BCT_H */
+#endif /* #ifndef INCLUDED_NVBOOT_BCT_T20_H */
diff --git a/t20/nvboot_sdram_param_t20.h b/t20/nvboot_sdram_param_t20.h
index 2ee944f..2c385d5 100644
--- a/t20/nvboot_sdram_param_t20.h
+++ b/t20/nvboot_sdram_param_t20.h
@@ -23,8 +23,8 @@
* Note that PLLM is used by EMC.
*/
-#ifndef INCLUDED_NVBOOT_SDRAM_PARAM_H
-#define INCLUDED_NVBOOT_SDRAM_PARAM_H
+#ifndef INCLUDED_NVBOOT_SDRAM_PARAM_T20_H
+#define INCLUDED_NVBOOT_SDRAM_PARAM_T20_H
#define NVBOOT_BCT_SDRAM_ARB_CONFIG_WORDS 27
@@ -359,5 +359,5 @@ typedef struct nvboot_sdram_params_rec {
u_int32_t arbitration_config[NVBOOT_BCT_SDRAM_ARB_CONFIG_WORDS];
} nvboot_sdram_params;
-#endif /* #ifndef INCLUDED_NVBOOT_SDRAM_PARAM_H */
+#endif /* #ifndef INCLUDED_NVBOOT_SDRAM_PARAM_T20_H */
diff --git a/t30/nvbctlib_t30.c b/t30/nvbctlib_t30.c
index 94e5f67..59b0246 100644
--- a/t30/nvbctlib_t30.c
+++ b/t30/nvbctlib_t30.c
@@ -847,16 +847,45 @@ void t30_init_bad_block_table(build_image_context *context)
table->virtual_blk_size_log2);
}
-void t30_get_cbootimage_interf(bct_parse_interface *cbootimage_bct_interf)
+cbootimage_soc_config tegra30_config = {
+ .init_bad_block_table = t30_init_bad_block_table,
+ .set_dev_param = t30_set_dev_param,
+ .get_dev_param = t30_get_dev_param,
+ .set_sdram_param = t30_set_sdram_param,
+ .get_sdram_param = t30_get_sdram_param,
+ .setbl_param = t30_setbl_param,
+ .getbl_param = t30_getbl_param,
+ .set_value = t30_bct_set_value,
+ .get_value = t30_bct_get_value,
+ .set_data = t30_bct_set_data,
+
+ .devtype_table = s_devtype_table_t30,
+ .sdmmc_data_width_table = s_sdmmc_data_width_table_t30,
+ .spi_clock_source_table = s_spi_clock_source_table_t30,
+ .nvboot_memory_type_table = s_nvboot_memory_type_table_t30,
+ .sdram_field_table = s_sdram_field_table_t30,
+ .nand_table = s_nand_table_t30,
+ .sdmmc_table = s_sdmmc_table_t30,
+ .spiflash_table = s_spiflash_table_t30,
+ .device_type_table = s_device_type_table_t30,
+};
+
+void t30_get_soc_config(build_image_context *context,
+ cbootimage_soc_config **soc_config)
{
- cbootimage_bct_interf->init_bad_block_table = t30_init_bad_block_table;
- cbootimage_bct_interf->set_dev_param = t30_set_dev_param;
- cbootimage_bct_interf->get_dev_param = t30_get_dev_param;
- cbootimage_bct_interf->set_sdram_param = t30_set_sdram_param;
- cbootimage_bct_interf->get_sdram_param = t30_get_sdram_param;
- cbootimage_bct_interf->setbl_param = t30_setbl_param;
- cbootimage_bct_interf->getbl_param = t30_getbl_param;
- cbootimage_bct_interf->set_value = t30_bct_set_value;
- cbootimage_bct_interf->get_value = t30_bct_get_value;
- cbootimage_bct_interf->set_data = t30_bct_set_data;
+ context->boot_data_version = BOOTDATA_VERSION_T30;
+ *soc_config = &tegra30_config;
+}
+
+int if_bct_is_t30_get_soc_config(build_image_context *context,
+ cbootimage_soc_config **soc_config)
+{
+ nvboot_config_table * bct = (nvboot_config_table *) context->bct;
+
+ if (bct->boot_data_version == BOOTDATA_VERSION_T30)
+ {
+ t30_get_soc_config(context, soc_config);
+ return 1;
+ }
+ return 0;
}
diff --git a/t30/nvboot_bct_t30.h b/t30/nvboot_bct_t30.h
index 8cf3511..39c998e 100644
--- a/t30/nvboot_bct_t30.h
+++ b/t30/nvboot_bct_t30.h
@@ -17,8 +17,8 @@
* project.
*/
-#ifndef INCLUDED_NVBOOT_BCT_H
-#define INCLUDED_NVBOOT_BCT_H
+#ifndef INCLUDED_NVBOOT_BCT_T30_H
+#define INCLUDED_NVBOOT_BCT_T30_H
#include <sys/types.h>
#include "nvboot_sdram_param_t30.h"
@@ -376,4 +376,4 @@ typedef struct nvboot_config_table_rec {
u_int8_t enable_fail_back;
u_int8_t reserved[NVBOOT_BCT_RESERVED_SIZE];
} nvboot_config_table;
-#endif /* #ifndef INCLUDED_NVBOOT_BCT_H */
+#endif /* #ifndef INCLUDED_NVBOOT_BCT_T30_H */
diff --git a/t30/nvboot_sdram_param_t30.h b/t30/nvboot_sdram_param_t30.h
index 68231eb..18d77d7 100644
--- a/t30/nvboot_sdram_param_t30.h
+++ b/t30/nvboot_sdram_param_t30.h
@@ -23,8 +23,8 @@
* Note that PLLM is used by EMC.
*/
-#ifndef INCLUDED_NVBOOT_SDRAM_PARAM_H
-#define INCLUDED_NVBOOT_SDRAM_PARAM_H
+#ifndef INCLUDED_NVBOOT_SDRAM_PARAM_T30_H
+#define INCLUDED_NVBOOT_SDRAM_PARAM_T30_H
#define NVBOOT_BCT_SDRAM_ARB_CONFIG_WORDS 27
@@ -564,5 +564,5 @@ typedef struct nvboot_sdram_params_rec {
/* End of generated code by warmboot_code_gen */
} nvboot_sdram_params;
-#endif /* #ifndef INCLUDED_NVBOOT_SDRAM_PARAM_H */
+#endif /* #ifndef INCLUDED_NVBOOT_SDRAM_PARAM_T30_H */