summaryrefslogtreecommitdiff
path: root/include/hwconfig.h
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2011-01-09 11:37:00 -0600
committerKumar Gala <galak@kernel.crashing.org>2011-01-19 22:58:23 -0600
commitdd50af2515ad39fa2f6c09ab621f69fef4f5fceb (patch)
tree53efcd705316bc268507d110e26d9712f9fae17f /include/hwconfig.h
parentf193e3da9817dc4892bc25967954d98838f84386 (diff)
powerpc/8xxx: Add hwconfig APIs to address early parsing used by DDR init
There are several users of the hwconfig APIs (8xxx DDR) before we have the environment properly setup. This causes issues because of the numerous ways the environment might be accessed because of the non-volatile memory it might be stored in. Additionally the access might be so early that memory isn't even properly setup for us. Towards resolving these issues we provide versions of all the hwconfig APIs that can be passed in a buffer to parse and leave it to the caller to determine how to allocate and populate the buffer. We use the _f naming convention for these new APIs even though they are perfectly useable after relocation and the environment being ready. We also now warn if the non-f APIs are called before the environment is ready to allow users to address the issues. Finally, we convert the 8xxx DDR code to utilize the new APIs to hopefully address the issue once and for all. We have the 8xxx DDR code create a buffer on the stack and populate it via getenv_f(). Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'include/hwconfig.h')
-rw-r--r--include/hwconfig.h68
1 files changed, 51 insertions, 17 deletions
diff --git a/include/hwconfig.h b/include/hwconfig.h
index d517f782fd9..a037ed88501 100644
--- a/include/hwconfig.h
+++ b/include/hwconfig.h
@@ -2,6 +2,7 @@
* An inteface for configuring a hardware via u-boot environment.
*
* Copyright (c) 2009 MontaVista Software, Inc.
+ * Copyright 2011 Freescale Semiconductor, Inc.
*
* Author: Anton Vorontsov <avorontsov@ru.mvista.com>
*
@@ -19,51 +20,84 @@
#ifdef CONFIG_HWCONFIG
-extern int hwconfig(const char *opt);
-extern const char *hwconfig_arg(const char *opt, size_t *arglen);
-extern int hwconfig_arg_cmp(const char *opt, const char *arg);
-extern int hwconfig_sub(const char *opt, const char *subopt);
-extern const char *hwconfig_subarg(const char *opt, const char *subopt,
- size_t *subarglen);
-extern int hwconfig_subarg_cmp(const char *opt, const char *subopt,
- const char *subarg);
-
+extern int hwconfig_f(const char *opt, char *buf);
+extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf);
+extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf);
+extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf);
+extern const char *hwconfig_subarg_f(const char *opt, const char *subopt,
+ size_t *subarglen, char *buf);
+extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
+ const char *subarg, char *buf);
#else
-static inline int hwconfig(const char *opt)
+static inline int hwconfig_f(const char *opt, char *buf)
{
return -ENOSYS;
}
-static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
+static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen,
+ char *buf)
{
*arglen = 0;
return "";
}
-static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
+static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg,
+ char *buf)
{
return -ENOSYS;
}
-static inline int hwconfig_sub(const char *opt, const char *subopt)
+static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf)
{
return -ENOSYS;
}
-static inline const char *hwconfig_subarg(const char *opt, const char *subopt,
- size_t *subarglen)
+static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt,
+ size_t *subarglen, char *buf)
{
*subarglen = 0;
return "";
}
-static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt,
- const char *subarg)
+static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
+ const char *subarg, char *buf)
{
return -ENOSYS;
}
#endif /* CONFIG_HWCONFIG */
+static inline int hwconfig(const char *opt)
+{
+ return hwconfig_f(opt, NULL);
+}
+
+static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
+{
+ return hwconfig_arg_f(opt, arglen, NULL);
+}
+
+static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
+{
+ return hwconfig_arg_cmp_f(opt, arg, NULL);
+}
+
+static inline int hwconfig_sub(const char *opt, const char *subopt)
+{
+ return hwconfig_sub_f(opt, subopt, NULL);
+}
+
+static inline const char *hwconfig_subarg(const char *opt, const char *subopt,
+ size_t *subarglen)
+{
+ return hwconfig_subarg_f(opt, subopt, subarglen, NULL);
+}
+
+static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt,
+ const char *subarg)
+{
+ return hwconfig_subarg_cmp_f(opt, subopt, subarg, NULL);
+}
+
#endif /* _HWCONFIG_H */