Hi Albert,

On 2015年11月13日 22:43, Albert ARIBAUD wrote:
+/*
+ * Initialize reserved space (which has been safely allocated on the C
+ * stack from the C runtime environment handling code).
+ *
+ * Do not use 'gd->' until arch_setup_gd() has been called!
+ */
+
+void board_init_f_init_reserve(ulong base)
  {
        struct global_data *gd_ptr;
  #ifndef _USE_MEMCPY
        int *ptr;
  #endif

-       /* Leave space for the stack we are running with now */
-       top -= 0x40;
+       /*
+        * clear GD entirely
+        */

-       top -= sizeof(struct global_data);
-       top = ALIGN(top, 16);
-       gd_ptr = (struct global_data *)top;
+       gd_ptr = (struct global_data *)base;
+       /* go down one GD plus 16-byte alignment */
+       base += roundup(sizeof(struct global_data), 16);

Maybe it can keep the original order, top--gd--malloc--base.

#if defined(CONFIG_SYS_MALLOC_F)
        base += CONFIG_SYS_MALLOC_F_LEN;
#endif
        gd_ptr = (struct global_data *)base;

+       /* zero the area */
  #ifdef _USE_MEMCPY
        memset(gd_ptr, '\0', sizeof(*gd));
  #else
        for (ptr = (int *)gd_ptr; ptr < (int *)(gd_ptr + 1); )
                *ptr++ = 0;
  #endif
+       /* set GD unless architecture did it already */
+#if !defined(CONFIG_X86) && !defined(CONFIG_SYS_THUMB_BUILD)
        arch_setup_gd(gd_ptr);
+#endif
+
+       /*
+        * record malloc arena start
+        */

  #if defined(CONFIG_SYS_MALLOC_F)
-       top -= CONFIG_SYS_MALLOC_F_LEN;
-       gd->malloc_base = top;
+       /* go down one malloc arena */
+       gd->malloc_base = base;

#if defined(CONFIG_SYS_MALLOC_F)
        base -= CONFIG_SYS_MALLOC_F_LEN;
        gd->malloc_base = base;
#endif

+       base += CONFIG_SYS_MALLOC_F_LEN;

Useless statement.

Best regards,
Thomas
_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to