-#ifdef ENV_IS_EMBEDDED
- /*
- * The environment buffer is embedded with the text segment,
- * just relocate the environment pointer
- */
-#ifndef CONFIG_RELOC_FIXUP_WORKS
- env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off);
-#endif
- 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 (CONFIG_ENV_SIZE);
- DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
-#endif
+ if (check) {
+ uint32_t crc;
+
+ memcpy(&crc, &ep->crc, sizeof(crc));
+
+ if (crc32(0, ep->data, ENV_SIZE) != crc) {
+ set_default_env("!bad CRC");
+ return 0;
+ }
+ }
+
+ if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0)) {
+ gd->flags |= GD_FLG_ENV_READY;
+ return 1;
+ }
+
+ error("Cannot import environment: errno = %d\n", errno);