diff mbox

[U-Boot,10/17] x86: Allow cache before copy to RAM

Message ID 1325477374-6417-11-git-send-email-graeme.russ@gmail.com
State Accepted
Commit 98f1fa9fd4f468c67b5f4d16077898992d6bae0b
Headers show

Commit Message

Graeme Russ Jan. 2, 2012, 4:09 a.m. UTC
Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
---
 arch/x86/lib/board.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

Comments

Simon Glass Jan. 4, 2012, 5:40 a.m. UTC | #1
Hi Graeme,

On Sun, Jan 1, 2012 at 8:09 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
>
> Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
> ---
>  arch/x86/lib/board.c |   15 ++++++++++-----
>  1 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
> index ffddfbe..52e27e1 100644
> --- a/arch/x86/lib/board.c
> +++ b/arch/x86/lib/board.c
> @@ -131,16 +131,11 @@ init_fnc_t *init_sequence_f[] = {
>        console_init_f,
>        dram_init_f,
>        calculate_relocation_address,
> -       copy_uboot_to_ram,
> -       clear_bss,
> -       do_elf_reloc_fixups,
>
>        NULL,
>  };
>
>  init_fnc_t *init_sequence_r[] = {
> -       copy_gd_to_ram,
> -       init_cache,
>        cpu_init_r,             /* basic cpu dependent setup */
>        board_early_init_r,     /* basic board dependent setup */
>        dram_init,              /* configure available RAM banks */
> @@ -269,6 +264,16 @@ void board_init_f(ulong boot_flags)
>
>  void board_init_f_r(void)
>  {
> +       if (copy_gd_to_ram() != 0)
> +               hang();
> +
> +       if (init_cache() != 0)
> +               hang();
> +
> +       copy_uboot_to_ram();
> +       clear_bss();
> +       do_elf_reloc_fixups();

Can you not just put these in the init list above? Why do they need to
move back into this functoin?

Regards,
Simon

> +
>        /*
>         * Transfer execution from Flash to RAM by calculating the address
>         * of the in-RAM copy of board_init_r() and calling it
> --
> 1.7.5.2.317.g391b14
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Graeme Russ Jan. 4, 2012, 11:29 a.m. UTC | #2
Hi Simon,

On 04/01/12 16:40, Simon Glass wrote:
> Hi Graeme,
> 
> On Sun, Jan 1, 2012 at 8:09 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
>>
>> Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
>> ---
>>  arch/x86/lib/board.c |   15 ++++++++++-----
>>  1 files changed, 10 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
>> index ffddfbe..52e27e1 100644
>> --- a/arch/x86/lib/board.c
>> +++ b/arch/x86/lib/board.c
>> @@ -131,16 +131,11 @@ init_fnc_t *init_sequence_f[] = {
>>        console_init_f,
>>        dram_init_f,
>>        calculate_relocation_address,
>> -       copy_uboot_to_ram,
>> -       clear_bss,
>> -       do_elf_reloc_fixups,
>>
>>        NULL,
>>  };
>>
>>  init_fnc_t *init_sequence_r[] = {
>> -       copy_gd_to_ram,
>> -       init_cache,
>>        cpu_init_r,             /* basic cpu dependent setup */
>>        board_early_init_r,     /* basic board dependent setup */
>>        dram_init,              /* configure available RAM banks */
>> @@ -269,6 +264,16 @@ void board_init_f(ulong boot_flags)
>>
>>  void board_init_f_r(void)
>>  {
>> +       if (copy_gd_to_ram() != 0)
>> +               hang();
>> +
>> +       if (init_cache() != 0)
>> +               hang();
>> +
>> +       copy_uboot_to_ram();
>> +       clear_bss();
>> +       do_elf_reloc_fixups();
> 
> Can you not just put these in the init list above? Why do they need to
> move back into this functoin?

board_init_f_r() is the intermediate step when we are running from Flash,
but with the stack and global data in RAM. If these functions are put in
init_sequence_f() we cannot enable the CPU cache (as the stack and global
data would get trashed). We can't put them in init_sequence_r because these
are the functions that actually copy U-Boot to RAM (and hence must be done
before init_sequence_r)

Regards,

Graeme
diff mbox

Patch

diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c
index ffddfbe..52e27e1 100644
--- a/arch/x86/lib/board.c
+++ b/arch/x86/lib/board.c
@@ -131,16 +131,11 @@  init_fnc_t *init_sequence_f[] = {
 	console_init_f,
 	dram_init_f,
 	calculate_relocation_address,
-	copy_uboot_to_ram,
-	clear_bss,
-	do_elf_reloc_fixups,
 
 	NULL,
 };
 
 init_fnc_t *init_sequence_r[] = {
-	copy_gd_to_ram,
-	init_cache,
 	cpu_init_r,		/* basic cpu dependent setup */
 	board_early_init_r,	/* basic board dependent setup */
 	dram_init,		/* configure available RAM banks */
@@ -269,6 +264,16 @@  void board_init_f(ulong boot_flags)
 
 void board_init_f_r(void)
 {
+	if (copy_gd_to_ram() != 0)
+		hang();
+
+	if (init_cache() != 0)
+		hang();
+
+	copy_uboot_to_ram();
+	clear_bss();
+	do_elf_reloc_fixups();
+
 	/*
 	 * Transfer execution from Flash to RAM by calculating the address
 	 * of the in-RAM copy of board_init_r() and calling it