diff mbox

[U-Boot,v3,34/62] x86: Support global_data on x86_64

Message ID 20170116140427.29283-35-sjg@chromium.org
State Accepted
Commit a160092a610f4345cea5b606a8daf27d1feba185
Delegated to: Bin Meng
Headers show

Commit Message

Simon Glass Jan. 16, 2017, 2:03 p.m. UTC
At present this is just an ordinary variable. We may consider making it a
fixed register in the future.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Add a TODO to look at using a fixed register for gd on x86_64
- Expand the TODO about the necessary printch() call
- Add a required debug_uart.h #include in this patch

Changes in v2: None

 arch/x86/cpu/x86_64/cpu.c          | 27 +++++++++++++++++++++++++++
 arch/x86/include/asm/global_data.h |  7 ++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

Comments

Bin Meng Jan. 17, 2017, 3:26 a.m. UTC | #1
On Mon, Jan 16, 2017 at 10:03 PM, Simon Glass <sjg@chromium.org> wrote:
> At present this is just an ordinary variable. We may consider making it a
> fixed register in the future.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add a TODO to look at using a fixed register for gd on x86_64
> - Expand the TODO about the necessary printch() call
> - Add a required debug_uart.h #include in this patch
>
> Changes in v2: None
>
>  arch/x86/cpu/x86_64/cpu.c          | 27 +++++++++++++++++++++++++++
>  arch/x86/include/asm/global_data.h |  7 ++++++-
>  2 files changed, 33 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng Jan. 17, 2017, 3:51 a.m. UTC | #2
On Tue, Jan 17, 2017 at 11:26 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Mon, Jan 16, 2017 at 10:03 PM, Simon Glass <sjg@chromium.org> wrote:
>> At present this is just an ordinary variable. We may consider making it a
>> fixed register in the future.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> Changes in v3:
>> - Add a TODO to look at using a fixed register for gd on x86_64
>> - Expand the TODO about the necessary printch() call
>> - Add a required debug_uart.h #include in this patch
>>
>> Changes in v2: None
>>
>>  arch/x86/cpu/x86_64/cpu.c          | 27 +++++++++++++++++++++++++++
>>  arch/x86/include/asm/global_data.h |  7 ++++++-
>>  2 files changed, 33 insertions(+), 1 deletion(-)
>>
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

applied to u-boot-x86, thanks!
diff mbox

Patch

diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
index b12eab1cb69..36272296e63 100644
--- a/arch/x86/cpu/x86_64/cpu.c
+++ b/arch/x86/cpu/x86_64/cpu.c
@@ -6,6 +6,33 @@ 
  */
 
 #include <common.h>
+#include <debug_uart.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Global declaration of gd */
+struct global_data *global_data_ptr;
+
+void arch_setup_gd(gd_t *new_gd)
+{
+	global_data_ptr = new_gd;
+
+	/*
+	 * TODO(sjg@chromium.org): For some reason U-Boot does not boot
+	 * without this line. It fails to start up U-Boot proper and instead
+	 * restarts SPL. Need to figure out why:
+	 *
+	 * U-Boot SPL 2017.01
+	 *
+	 * U-Boot SPL 2017.01
+	 * CPU:   Intel(R) Core(TM) i5-3427U CPU @ 1.80GHz
+	 * Trying to boot from SPIJumping to 64-bit U-Boot: Note many
+	 * features are missing
+	 *
+	 * U-Boot SPL 2017.01
+	 */
+	printch(' ');
+}
 
 int cpu_has_64bit(void)
 {
diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h
index 7434f779b66..34e19efd145 100644
--- a/arch/x86/include/asm/global_data.h
+++ b/arch/x86/include/asm/global_data.h
@@ -104,8 +104,9 @@  struct arch_global_data {
 #include <asm-generic/global_data.h>
 
 #ifndef __ASSEMBLY__
-# ifdef CONFIG_EFI_APP
+# if defined(CONFIG_EFI_APP) || CONFIG_IS_ENABLED(X86_64)
 
+/* TODO(sjg@chromium.org): Consider using a fixed register for gd on x86_64 */
 #define gd global_data_ptr
 
 #define DECLARE_GLOBAL_DATA_PTR   extern struct global_data *global_data_ptr
@@ -114,7 +115,11 @@  static inline __attribute__((no_instrument_function)) gd_t *get_fs_gd_ptr(void)
 {
 	gd_t *gd_ptr;
 
+#if CONFIG_IS_ENABLED(X86_64)
+	asm volatile("fs mov 0, %0\n" : "=r" (gd_ptr));
+#else
 	asm volatile("fs movl 0, %0\n" : "=r" (gd_ptr));
+#endif
 
 	return gd_ptr;
 }