summaryrefslogtreecommitdiff
path: root/common/hwconfig.c
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2010-11-16 09:55:11 +0900
committerMinkyu Kang <mk7.kang@samsung.com>2010-11-16 09:55:11 +0900
commit1032d97496f6d534bf0030a5779ff1cb38cc9ebf (patch)
tree3713c814a7453024eceb097c67532072950e2f2e /common/hwconfig.c
parent37a3bda0c9c8a2ffbf7e2a9e121177a3385a0626 (diff)
parent227b72515546fca535dbd3274f6d875d97f494fe (diff)
downloadu-boot-imx-1032d97496f6d534bf0030a5779ff1cb38cc9ebf.zip
u-boot-imx-1032d97496f6d534bf0030a5779ff1cb38cc9ebf.tar.gz
u-boot-imx-1032d97496f6d534bf0030a5779ff1cb38cc9ebf.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-arm
Diffstat (limited to 'common/hwconfig.c')
-rw-r--r--common/hwconfig.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/common/hwconfig.c b/common/hwconfig.c
index 1f9f4a0..3c9759f 100644
--- a/common/hwconfig.c
+++ b/common/hwconfig.c
@@ -26,6 +26,8 @@
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif /* HWCONFIG_TEST */
+DECLARE_GLOBAL_DATA_PTR;
+
static const char *hwconfig_parse(const char *opts, size_t maxlen,
const char *opt, char *stopchs, char eqch,
size_t *arglen)
@@ -69,9 +71,26 @@ next:
const char *cpu_hwconfig __attribute__((weak));
const char *board_hwconfig __attribute__((weak));
+#define HWCONFIG_PRE_RELOC_BUF_SIZE 128
+
static const char *__hwconfig(const char *opt, size_t *arglen)
{
- const char *env_hwconfig = getenv("hwconfig");
+ const char *env_hwconfig = NULL;
+ char buf[HWCONFIG_PRE_RELOC_BUF_SIZE];
+
+ if (gd->flags & GD_FLG_ENV_READY) {
+ env_hwconfig = getenv("hwconfig");
+ } else {
+ /*
+ * Use our own on stack based buffer before relocation to allow
+ * accessing longer hwconfig strings that might be in the
+ * environment before we've relocated. This is pretty fragile
+ * on both the use of stack and if the buffer is big enough.
+ * However we will get a warning from getenv_f for the later.
+ */
+ if ((getenv_f("hwconfig", buf, sizeof(buf))) > 0)
+ env_hwconfig = buf;
+ }
if (env_hwconfig)
return hwconfig_parse(env_hwconfig, strlen(env_hwconfig),