From patchwork Mon Jan 3 19:46:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Graeme Russ X-Patchwork-Id: 77331 X-Patchwork-Delegate: graeme.russ@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 0459EB70FC for ; Tue, 4 Jan 2011 06:51:54 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4B21C283A4; Mon, 3 Jan 2011 20:50:00 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FsE22NxNaUXD; Mon, 3 Jan 2011 20:50:00 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D12232821B; Mon, 3 Jan 2011 20:49:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2E7C92824B for ; Mon, 3 Jan 2011 20:49:12 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fE2HqmKPzoY9 for ; Mon, 3 Jan 2011 20:49:10 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by theia.denx.de (Postfix) with ESMTP id BDF2E282BF for ; Mon, 3 Jan 2011 20:48:44 +0100 (CET) Received: by mail-fx0-f44.google.com with SMTP id 9so12889169fxm.3 for ; Mon, 03 Jan 2011 11:48:44 -0800 (PST) Received: by 10.103.214.9 with SMTP id r9mr1542762muq.135.1294084123846; Mon, 03 Jan 2011 11:48:43 -0800 (PST) Received: from helios.localdomain6 (d122-104-38-246.sbr6.nsw.optusnet.com.au [122.104.38.246]) by mx.google.com with ESMTPS id a6sm3124092fak.1.2011.01.03.11.48.40 (version=SSLv3 cipher=RC4-MD5); Mon, 03 Jan 2011 11:48:42 -0800 (PST) From: Graeme Russ To: u-boot@lists.denx.de Date: Tue, 4 Jan 2011 06:46:44 +1100 Message-Id: <1294084016-2674-25-git-send-email-graeme.russ@gmail.com> X-Mailer: git-send-email 1.7.1.422.g049e9 In-Reply-To: <1294084016-2674-1-git-send-email-graeme.russ@gmail.com> References: <1294084016-2674-1-git-send-email-graeme.russ@gmail.com> Subject: [U-Boot] [RFC][PATCH 24/36] x86 - Move initial gd to fixed location X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de --- arch/i386/cpu/start.S | 12 +++++----- arch/i386/include/asm/global_data.h | 7 +++++- arch/i386/lib/board.c | 36 +++++++++++++++++++++++----------- include/configs/eNET.h | 1 + 4 files changed, 37 insertions(+), 19 deletions(-) --- 1.7.1.422.g049e9 diff --git a/arch/i386/cpu/start.S b/arch/i386/cpu/start.S index 97bac8f..0ce9713 100644 --- a/arch/i386/cpu/start.S +++ b/arch/i386/cpu/start.S @@ -127,13 +127,13 @@ mem_ok: /* Set the upper memory limit parameter */ subl $CONFIG_SYS_STACK_SIZE, %eax - /* Reserve space for global data */ - subl $(GD_SIZE * 4), %eax + /* Pointer to temporary global data */ + movl $CONFIG_SYS_INIT_GD_ADDR, %edx - /* %eax points to the global data structure */ - movl %esp, (GD_RAM_SIZE * 4)(%eax) - movl %ebx, (GD_FLAGS * 4)(%eax) - movl %ecx, (GD_LOAD_OFF * 4)(%eax) + /* %edx points to the global data structure */ + movl %esp, (GD_RAM_SIZE * 4)(%edx) + movl %ebx, (GD_FLAGS * 4)(%edx) + movl %ecx, (GD_LOAD_OFF * 4)(%edx) call board_init_f /* Enter, U-boot! */ diff --git a/arch/i386/include/asm/global_data.h b/arch/i386/include/asm/global_data.h index e9000c3..cd067f5 100644 --- a/arch/i386/include/asm/global_data.h +++ b/arch/i386/include/asm/global_data.h @@ -87,7 +87,12 @@ extern gd_t *gd; #define GD_FLG_COLD_BOOT 0x00100 /* Cold Boot */ #define GD_FLG_WARM_BOOT 0x00200 /* Warm Boot */ - +#if 0 #define DECLARE_GLOBAL_DATA_PTR +#else +#define XTRN_DECLARE_GLOBAL_DATA_PTR extern +#define DECLARE_GLOBAL_DATA_PTR XTRN_DECLARE_GLOBAL_DATA_PTR \ +gd_t *gd +#endif #endif /* __ASM_GBL_DATA_H */ diff --git a/arch/i386/lib/board.c b/arch/i386/lib/board.c index 2cadce8..460a5e9 100644 --- a/arch/i386/lib/board.c +++ b/arch/i386/lib/board.c @@ -45,7 +45,15 @@ #include #endif -DECLARE_GLOBAL_DATA_PTR; +/* + * Pointer to initial global data area + * + * Here we initialize it. + */ +#undef XTRN_DECLARE_GLOBAL_DATA_PTR +#define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */ +DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CONFIG_SYS_INIT_GD_ADDR); + /* Exports from the Linker Script */ extern ulong __text_start; @@ -168,7 +176,7 @@ gd_t *gd; /* * Load U-Boot into RAM, initialize BSS, perform relocation adjustments */ -void board_init_f (ulong gdp) +void board_init_f (ulong mem_top) { void *text_start = &__text_start; void *data_end = &__data_end; @@ -187,11 +195,11 @@ void board_init_f (ulong gdp) Elf32_Rel *re_end; /* Calculate destination RAM Address and relocation offset */ - dest_addr = (void *)gdp - (bss_end - text_start); + dest_addr = (void *)mem_top - (bss_end - text_start); rel_offset = text_start - dest_addr; /* Perform low-level initialization only when cold booted */ - if (((gd_t *)gdp)->flags & GD_FLG_COLD_BOOT) { + if (gd->flags & GD_FLG_COLD_BOOT) { /* First stage CPU initialization */ if (cpu_init_f() != 0) hang(); @@ -203,8 +211,8 @@ void board_init_f (ulong gdp) /* Copy U-Boot into RAM */ dst_addr = (ulong *)dest_addr; - src_addr = (ulong *)(text_start + ((gd_t *)gdp)->load_off); - end_addr = (ulong *)(data_end + ((gd_t *)gdp)->load_off); + src_addr = (ulong *)(text_start + gd->load_off); + end_addr = (ulong *)(data_end + gd->load_off); while (src_addr < end_addr) *dst_addr++ = *src_addr++; @@ -217,8 +225,8 @@ void board_init_f (ulong gdp) *dst_addr++ = 0x00000000; /* Perform relocation adjustments */ - re_src = (Elf32_Rel *)(rel_dyn_start + ((gd_t *)gdp)->load_off); - re_end = (Elf32_Rel *)(rel_dyn_end + ((gd_t *)gdp)->load_off); + re_src = (Elf32_Rel *)(rel_dyn_start + gd->load_off); + re_end = (Elf32_Rel *)(rel_dyn_end + gd->load_off); do { if (re_src->r_offset >= CONFIG_SYS_TEXT_BASE) @@ -226,11 +234,11 @@ void board_init_f (ulong gdp) *(Elf32_Addr *)(re_src->r_offset - rel_offset) -= rel_offset; } while (re_src++ < re_end); - ((gd_t *)gdp)->reloc_off = rel_offset; - ((gd_t *)gdp)->flags |= GD_FLG_RELOC; + gd->reloc_off = rel_offset; + gd->flags |= GD_FLG_RELOC; /* Enter the relocated U-Boot! */ - (board_init_r - rel_offset)((gd_t *)gdp, (ulong)dest_addr); + (board_init_r - rel_offset)(gd, (ulong)dest_addr); /* NOTREACHED - board_init_f() does not return */ while(1); @@ -242,11 +250,15 @@ void board_init_r(gd_t *id, ulong dest_addr) int i; ulong size; static bd_t bd_data; + static gd_t gd_data; init_fnc_t **init_fnc_ptr; show_boot_progress(0x21); - gd = id; + /* Global data pointer is now writable */ + gd = &gd_data; + memcpy(gd, id, sizeof(gd_t)); + /* compiler optimization barrier needed for GCC >= 3.4 */ __asm__ __volatile__("": : :"memory"); diff --git a/include/configs/eNET.h b/include/configs/eNET.h index 9ad10de..59f8e6d 100644 --- a/include/configs/eNET.h +++ b/include/configs/eNET.h @@ -179,6 +179,7 @@ #define CONFIG_SYS_FLASH_BASE 0x38000000 /* Boot Flash */ #define CONFIG_SYS_FLASH_BASE_1 0x10000000 /* StrataFlash 1 */ #define CONFIG_SYS_FLASH_BASE_2 0x11000000 /* StrataFlash 2 */ +#define CONFIG_SYS_INIT_GD_ADDR 0x19040000 /* Address of temporary Global Data */ /* timeout values are in ticks */ #define CONFIG_SYS_FLASH_ERASE_TOUT (2*CONFIG_SYS_HZ) /* Timeout for Flash Erase */