summaryrefslogtreecommitdiff
path: root/src/parse.c
diff options
context:
space:
mode:
authorVince Hsu <vinceh@nvidia.com>2014-07-16 10:37:16 +0800
committerAllen Martin <amartin@nvidia.com>2014-07-15 21:42:46 -0700
commit456b8aa442f0e54db9c38cedf548a4f14cee1f59 (patch)
treecf26e7ce79d14e8ff85197b6188bc0813db1e1b8 /src/parse.c
parent3717d5efb02b96104c0533df463d148faeb7afa1 (diff)
downloadcbootimage-456b8aa442f0e54db9c38cedf548a4f14cee1f59.tar.gz
Add Tegra132 support for the cbootimage utility
This patch adds support for Tegra132. This are only slight differences between Tegra124 and Tegra132. The command line usage is exactly the same as other platforms like Tegra124. The structure nvboot_mts_info is added into the bct for Tegra132. So the bootrom and first stage bootloader know where to load the preboot and mts images. Two parse items "Mts=" and "MtsPreboot=" are added to embedded MTS images in BCT image like what we do for bootloader. The syntax is also the same. For example: MtsPreboot = <preboot_image>,<load_address>,<entry_address>,Complete; Mts = <mts_image>,<load_address>,<entry_address>,Complete; The load and entry addresses depned on your board design. Four files are added in src/t132: nvbctlib_t132.c - is cloned from nvbctlib_t124.c and adds mts information getter and setter. nvboot_bct_t132.h - adds mts structure into bct nvboot_sdram_param_t132.h - clone of nvboot_sdram_param_t124.h parse_t132.c - clone of parse_t124.c Signed-off-by: Vince Hsu <vinceh@nvidia.com> Acked-by: Allen Martin <amartin@nvidia.com>
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/src/parse.c b/src/parse.c
index 7ccd594..f866ad5 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -63,6 +63,8 @@ parse_array(build_image_context *context, parse_token token, char *rest);
static int
parse_bootloader(build_image_context *context, parse_token token, char *rest);
static int
+parse_mts_image(build_image_context *context, parse_token token, char *rest);
+static int
parse_value_u32(build_image_context *context, parse_token token, char *rest);
static int
parse_value_chipuid(build_image_context *context,
@@ -87,6 +89,8 @@ static parse_item parse_simple_items[] =
{ "BootLoader=", token_bootloader, parse_bootloader },
{ "Redundancy=", token_redundancy, parse_value_u32 },
{ "Bctcopy=", token_bct_copy, parse_value_u32 },
+ { "MtsPreboot=", token_mts_preboot, parse_mts_image},
+ { "Mts=", token_mts, parse_mts_image},
{ "Version=", token_version, parse_value_u32 },
{ "PreBctPadBlocks=", token_pre_bct_pad_blocks, parse_value_u32 },
{ NULL, 0, NULL } /* Must be last */
@@ -105,6 +109,8 @@ static parse_item s_top_level_items[] = {
{ "BootLoader=", token_bootloader, parse_bootloader },
{ "Redundancy=", token_redundancy, parse_value_u32 },
{ "Bctcopy=", token_bct_copy, parse_value_u32 },
+ { "MtsPreboot=", token_mts_preboot, parse_mts_image},
+ { "Mts=", token_mts, parse_mts_image},
{ "Version=", token_version, parse_value_u32 },
{ "OdmData=", token_odm_data, parse_value_u32 },
{ "ChipUid=", token_unique_chip_id, parse_value_chipuid },
@@ -418,6 +424,61 @@ static int parse_bootloader(build_image_context *context,
}
/*
+ * Parse the given string and find the MTS file name, load address and
+ * entry point information then call set_mts_image function.
+ *
+ * @param context The main context pointer
+ * @param token The parse token value
+ * @param rest String to parse
+ * @return 0 and 1 for success and failure
+ */
+static int parse_mts_image(build_image_context *context,
+ parse_token token,
+ char *rest)
+{
+ char filename[MAX_BUFFER];
+ char e_state[MAX_STR_LEN];
+ u_int32_t load_addr;
+ u_int32_t entry_point;
+
+ assert(context != NULL);
+ assert(rest != NULL);
+
+ if (context->generate_bct != 0)
+ return 0;
+ /* Parse the file name. */
+ rest = parse_filename(rest, filename, MAX_BUFFER);
+ if (rest == NULL)
+ return 1;
+
+ PARSE_COMMA(1);
+
+ /* Parse the load address. */
+ rest = parse_u32(rest, &load_addr);
+ if (rest == NULL)
+ return 1;
+
+ PARSE_COMMA(1);
+
+ /* Parse the entry point. */
+ rest = parse_u32(rest, &entry_point);
+ if (rest == NULL)
+ return 1;
+
+ PARSE_COMMA(1);
+
+ /* Parse the end state. */
+ rest = parse_end_state(rest, e_state, MAX_STR_LEN);
+ if (rest == NULL)
+ return 1;
+ if (strncmp(e_state, "Complete", strlen("Complete")))
+ return 1;
+
+ /* Parsing has finished - set the bootloader */
+ return set_mts_image(context, filename, load_addr, entry_point);
+}
+
+/*
* Parse the given string and find the array items in config file.
*
* @param context The main context pointer