-#ifdef ENV_IS_EMBEDDED
- /*
- * The environment buffer is embedded with the text segment,
- * just relocate the environment pointer
- */
- env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off);
- DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
-#else
- /*
- * We must allocate a buffer for the environment
- */
- env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
- DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
-#endif
+/*
+ * Check if CRC is valid and (if yes) import the environment.
+ * Note that "buf" may or may not be aligned.
+ */
+int env_import(const char *buf, int check)
+{
+ env_t *ep = (env_t *)buf;