From: Bartlomiej Sieka <tur@semihalf.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 4/6] [new uImage] Add fit_parse_conf() and fit_parse_subimage() routines
Date: Wed, 20 Feb 2008 18:20:15 +0100 [thread overview]
Message-ID: <20080220172015.25624.8809.stgit@pollux.denx.de> (raw)
In-Reply-To: <20080220171950.25624.71201.stgit@pollux.denx.de>
From: Marian Balakowicz <m8@semihalf.com>
New routines for parsing new uImage format bootm arguments:
[<addr>]#<conf> - configuration spec
[<addr>]:<subimg> - subimage spec
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
---
common/image.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/image.h | 10 +++++++
2 files changed, 88 insertions(+), 0 deletions(-)
diff --git a/common/image.c b/common/image.c
index 8d5ca4e..c9a09ce 100644
--- a/common/image.c
+++ b/common/image.c
@@ -772,4 +772,82 @@ ulong get_boot_kbd (ulong alloc_current, bd_t **kbd)
}
#endif /* CONFIG_PPC || CONFIG_M68K */
+#if defined(CONFIG_FIT)
+/*****************************************************************************/
+/* New uImage format routines */
+/*****************************************************************************/
+static int fit_parse_spec (const char *spec, char sepc, ulong addr_curr,
+ ulong *addr, const char **name)
+{
+ const char *sep;
+
+ *addr = addr_curr;
+ *name = NULL;
+
+ sep = strchr (spec, sepc);
+ if (sep) {
+ if (sep - spec > 0)
+ *addr = simple_strtoul (spec, NULL, 16);
+
+ *name = sep + 1;
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * fit_parse_conf - parse FIT configuration spec
+ * @spec: input string, containing configuration spec
+ * @add_curr: current image address (to be used as a possible default)
+ * @addr: pointer to a ulong variable, will hold FIT image address of a given
+ * configuration
+ * @conf_name double pointer to a char, will hold pointer to a configuration
+ * unit name
+ *
+ * fit_parse_conf() expects configuration spec in the for of [<addr>]#<conf>,
+ * where <addr> is a FIT image address that contains configuration
+ * with a <conf> unit name.
+ *
+ * Address part is optional, and if omitted default add_curr will
+ * be used instead.
+ *
+ * returns:
+ * 1 if spec is a valid configuration string,
+ * addr and conf_name are set accordingly
+ * 0 otherwise
+ */
+inline int fit_parse_conf (const char *spec, ulong addr_curr,
+ ulong *addr, const char **conf_name)
+{
+ return fit_parse_spec (spec, '#', addr_curr, addr, conf_name);
+}
+
+/**
+ * fit_parse_subimage - parse FIT subimage spec
+ * @spec: input string, containing subimage spec
+ * @add_curr: current image address (to be used as a possible default)
+ * @addr: pointer to a ulong variable, will hold FIT image address of a given
+ * subimage
+ * @image_name: double pointer to a char, will hold pointer to a subimage name
+ *
+ * fit_parse_subimage() expects subimage spec in the for of
+ * [<addr>]:<subimage>, where <addr> is a FIT image address that contains
+ * subimage with a <subimg> unit name.
+ *
+ * Address part is optional, and if omitted default add_curr will
+ * be used instead.
+ *
+ * returns:
+ * 1 if spec is a valid subimage string,
+ * addr and image_name are set accordingly
+ * 0 otherwise
+ */
+inline int fit_parse_subimage (const char *spec, ulong addr_curr,
+ ulong *addr, const char **image_name)
+{
+ return fit_parse_spec (spec, ':', addr_curr, addr, image_name);
+}
+#endif /* CONFIG_FIT */
+
#endif /* USE_HOSTCC */
diff --git a/include/image.h b/include/image.h
index b4de49d..4923612 100644
--- a/include/image.h
+++ b/include/image.h
@@ -367,6 +367,16 @@ ulong get_boot_cmdline (ulong alloc_current, ulong *cmd_start, ulong *cmd_end);
ulong get_boot_kbd (ulong alloc_current, bd_t **kbd);
#endif /* CONFIG_PPC || CONFIG_M68K */
+#if defined(CONFIG_FIT)
+/*
+ * New uImage format
+ */
+inline int fit_parse_conf (const char *spec, ulong addr_curr,
+ ulong *addr, const char **conf_name);
+inline int fit_parse_subimage (const char *spec, ulong addr_curr,
+ ulong *addr, const char **image_name);
+#endif /* CONFIG_FIT */
+
#endif /* USE_HOSTCC */
#endif /* __IMAGE_H__ */
next prev parent reply other threads:[~2008-02-20 17:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-20 17:19 [U-Boot-Users] [PATCH 0/6] [new uImage] patchset4 - assorted patches Bartlomiej Sieka
2008-02-20 17:19 ` [U-Boot-Users] [PATCH 1/6] [new uImage] Pull in libfdt if CONFIG_FIT is enabled Bartlomiej Sieka
2008-02-20 17:20 ` [U-Boot-Users] [PATCH 2/6] [libfdt] Fix compilation errors is fdt_support.c Bartlomiej Sieka
2008-02-20 17:33 ` Jerry Van Baren
2008-02-20 19:10 ` Kumar Gala
2008-02-20 20:36 ` Bartlomiej Sieka
2008-02-20 17:20 ` [U-Boot-Users] [PATCH 3/6] [new uImage] Add gen_get_image() routine Bartlomiej Sieka
2008-02-20 19:19 ` Kumar Gala
2008-02-20 20:38 ` Bartlomiej Sieka
2008-02-20 20:44 ` Kumar Gala
2008-02-21 15:57 ` Bartlomiej Sieka
2008-02-20 17:20 ` Bartlomiej Sieka [this message]
2008-02-20 19:27 ` [U-Boot-Users] [PATCH 4/6] [new uImage] Add fit_parse_conf() and fit_parse_subimage() routines Kumar Gala
2008-02-20 20:39 ` Bartlomiej Sieka
2008-02-20 17:20 ` [U-Boot-Users] [PATCH 5/6] [new uImage] Rename and move print_image_hdr() routine Bartlomiej Sieka
2008-02-20 17:20 ` [U-Boot-Users] [PATCH 6/6] [new uImage] Fix erroneous use of image_get_magic() in fdc/usb cmds Bartlomiej Sieka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080220172015.25624.8809.stgit@pollux.denx.de \
--to=tur@semihalf.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox