]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
x86: board_r: Set the global data pointer after relocation
authorSimon Glass <sjg@chromium.org>
Mon, 16 Jan 2017 14:03:51 +0000 (07:03 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Mon, 6 Feb 2017 03:38:46 +0000 (11:38 +0800)
Since 'gd' is just a normal variable on 64-bit x86, it is relocated by the
time we get to board_init_r(). The old 'gd' variable is passed in as
parameter to board_init_r(), presumably for this situation.

Assign it on 64-bit x86 so that gd points to the correct data.

Options to improve this:
- Make gd a fixed register and remove the board_init_r() parameter
- Make all archs use this board_init_r() parameter

The second has a TODO in the code. The first has a TODO in a future commit
('x86: Support global_data on x86_64')

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
common/board_r.c

index f739c8afdfc221d54f3213cff219d5e500757603..8077280de414f6ba6504d5c992c4e2c575cfe440 100644 (file)
@@ -947,6 +947,16 @@ static init_fnc_t init_sequence_r[] = {
 
 void board_init_r(gd_t *new_gd, ulong dest_addr)
 {
+       /*
+        * Set up the new global data pointer. So far only x86 does this
+        * here.
+        * TODO(sjg@chromium.org): Consider doing this for all archs, or
+        * dropping the new_gd parameter.
+        */
+#if CONFIG_IS_ENABLED(X86_64)
+       arch_setup_gd(new_gd);
+#endif
+
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
        int i;
 #endif