[U-Boot] [PATCH v2 13/58] x86: Set up the global data pointer in C instead of asm

Graeme Russ graeme.russ at gmail.com
Fri Dec 14 23:36:44 CET 2012


Hi Simon,

On 14/12/12 17:48, Simon Glass wrote:
> We currently assume that the global data pointer is at the start of
> struct global_data. We want to remove this restriction, and it is
> easiest to do this in C.
> 
> Remove the asm code and add equivalent code in C.
> 
> This idea was proposed by Graeme Russ here:
>    http://patchwork.ozlabs.org/patch/199741/
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> Changes in v2:
> - Add new patch to move gd pointer by C to asm on x86
> 
>  arch/x86/cpu/cpu.c   |    4 +++-
>  arch/x86/cpu/start.S |    6 ------
>  2 files changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
> index 315e87a..6a23974 100644
> --- a/arch/x86/cpu/cpu.c
> +++ b/arch/x86/cpu/cpu.c
> @@ -100,7 +100,9 @@ void setup_gdt(gd_t *id, u64 *gdt_addr)
>  	gdt_addr[X86_GDT_ENTRY_32BIT_DS] = GDT_ENTRY(0xc093, 0, 0xfffff);
>  
>  	/* FS: data, read/write, 4 GB, base (Global Data Pointer) */
> -	gdt_addr[X86_GDT_ENTRY_32BIT_FS] = GDT_ENTRY(0xc093, (ulong)id, 0xfffff);
> +	id->arch.gd_addr = id;
> +	gdt_addr[X86_GDT_ENTRY_32BIT_FS] = GDT_ENTRY(0xc093,
> +		     (ulong)&id->arch.gd_addr, 0xfffff);

This patch needs to come before #12 as:

-	gdt_addr[X86_GDT_ENTRY_32BIT_FS] = GDT_ENTRY(0xc093, (ulong)id, 0xfffff);
+	id->gd_addr = id;
+	gdt_addr[X86_GDT_ENTRY_32BIT_FS] = GDT_ENTRY(0xc093,
+		     (ulong)&id->gd_addr, 0xfffff);

Then you can move gd_addr into arch-specific global data


Regards,

Graeme



More information about the U-Boot mailing list