Initializes uboot env with sysvar.

Change-Id: I9f8c9667f82e821186a62d0582c78b5a0588a5fb
diff --git a/common/cmd_sysvar.c b/common/cmd_sysvar.c
index 3eb1f2f..da083cf 100644
--- a/common/cmd_sysvar.c
+++ b/common/cmd_sysvar.c
@@ -600,21 +600,21 @@
 /*
  * sysvar_buf_init - Initializes a sysvar_buf struct.
  */
-static bool sysvar_buf_init(struct sysvar_buf *buf, bool is_ro) {
+static int sysvar_buf_init(struct sysvar_buf *buf, bool is_ro) {
   if (buf == NULL) {
-    return false;
+    return SYSVAR_PARAM_ERR;
   }
   memset(buf, 0, sizeof(*buf));
   buf->list = (struct sysvar_list *)malloc(sizeof(struct sysvar_list));
   if (buf->list == NULL) {
     printf("list allocation ");
-    return false;
+    return SYSVAR_MEMORY_ERR;
   }
   buf->data = (uchar *) map_physmem(is_ro ? SYSVAR_RO_MEM : SYSVAR_RW_MEM);
   if (buf->data == NULL) {
     printf("data allocation ");
     free(buf->list);
-    return false;
+    return SYSVAR_MEMORY_ERR;
   }
 
   buf->data_len = SYSVAR_BLOCK_SIZE;
@@ -627,15 +627,26 @@
   buf->list->len = SYSVAR_NAME + 2;
   buf->list->next = NULL;
   buf->loaded = false;
-  return true;
+  return SYSVAR_SUCCESS;
+}
+
+static void sysvar_env_init(struct sysvar_buf *buf) {
+  struct sysvar_list *curr = buf->list->next;
+  while (curr != NULL) {
+    setenv(curr->name, curr->value);
+    curr = curr->next;
+  }
 }
 
 int sysvar_init(void) {
-  printf("sysvar_init. . .");
-  if (!sysvar_buf_init(&rw_buf, false) || !sysvar_buf_init(&ro_buf, true)) {
-    printf("failure!\n");
+  printf("sysvar_init. . .\n");
+  if (sysvar_buf_init(&rw_buf, false) || sysvar_buf_init(&ro_buf, true) ||
+      sf_loadvar()) {
+    printf("init failure!\n");
     return SYSVAR_MEMORY_ERR;
   }
-  printf("success!\n");
+  sysvar_env_init(&rw_buf);
+  sysvar_env_init(&ro_buf);
+  printf("init success!\n");
   return SYSVAR_SUCCESS;
 }