From patchwork Fri Dec 14 06:48:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [U-Boot, v2, 13/58] x86: Set up the global data pointer in C instead of asm Date: Thu, 13 Dec 2012 20:48:42 -0000 From: Simon Glass X-Patchwork-Id: 206305 Message-Id: <1355467767-29575-14-git-send-email-sjg@chromium.org> To: U-Boot Mailing List Cc: Tom Rini 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 --- 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); /* 16-bit CS: code, read/execute, 64 kB, base 0 */ gdt_addr[X86_GDT_ENTRY_16BIT_CS] = GDT_ENTRY(0x109b, 0, 0x0ffff); diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S index e960e21..f389584 100644 --- a/arch/x86/cpu/start.S +++ b/arch/x86/cpu/start.S @@ -113,9 +113,6 @@ car_init_ret: /* Set second parameter to setup_gdt */ movl %esp, %edx - /* gd->gd_addr = gd (Required to allow gd->xyz to work) */ - movl %eax, (%eax) - /* Setup global descriptor table so gd->xyz works */ call setup_gdt @@ -171,9 +168,6 @@ board_init_f_r_trampoline: /* Set second parameter to setup_gdt */ movl %esp, %edx - /* gd->gd_addr = gd (Required to allow gd->xyz to work) */ - movl %eax, (%eax) - /* Setup global descriptor table so gd->xyz works */ call setup_gdt