]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
env: Relocate env drivers if manual reloc is required
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Sat, 10 Feb 2018 09:35:20 +0000 (15:05 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 14 Feb 2018 07:41:14 +0000 (08:41 +0100)
Relocate env drivers if manual relocation is enabled. This
patch fixes the issue of u-boot hang incase if env is
present in any of the flash devices.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
env/common.c
env/env.c
include/environment.h

index 8167ea299264427248a57f9f2f930df752d18c89..db31204df47a792b0bf6aa5ea33070f1e3537a20 100644 (file)
@@ -208,6 +208,7 @@ void env_relocate(void)
 {
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
        env_reloc();
+       fix_envdriver();
        env_htab.change_ok += gd->reloc_off;
 #endif
        if (gd->env_valid == ENV_INVALID) {
index 76a5608628fc3c1b9c1be12bcffb5b6843a5f3dd..8314d23052366e2c1f0f3e3b6a7f1f546427a440 100644 (file)
--- a/env/env.c
+++ b/env/env.c
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_NEEDS_MANUAL_RELOC)
+void fix_envdriver(void)
+{
+       struct env_driver *drv;
+       const int n_ents = ll_entry_count(struct env_driver, env_driver);
+       struct env_driver *entry;
+
+       drv = ll_entry_start(struct env_driver, env_driver);
+       for (entry = drv; entry != drv + n_ents; entry++) {
+               if (entry->name)
+                       entry->name += gd->reloc_off;
+               if (entry->get_char)
+                       entry->get_char += gd->reloc_off;
+               if (entry->load)
+                       entry->load += gd->reloc_off;
+               if (entry->save)
+                       entry->save += gd->reloc_off;
+               if (entry->init)
+                       entry->init += gd->reloc_off;
+       }
+}
+#endif
+
 static struct env_driver *env_driver_lookup(enum env_location loc)
 {
        struct env_driver *drv;
index d29f82cb5d6faf148f126df5aa2207928a1628ef..04b8ae7f3f4c4799212ce0423c2d9ec9d44cd39b 100644 (file)
@@ -323,6 +323,11 @@ int env_load(void);
  */
 int env_save(void);
 
+/**
+ * fix_envdriver() - Updates envdriver as per relocation
+ */
+void fix_envdriver(void);
+
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENVIRONMENT_H_ */