Skip to contentSkip to conversation

x86: Support Intel FSP initialization path in start.S

PATCH New Bin Meng 2 participants 3 messages Dec 4, 2014 – Dec 5, 2014 x86

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 14/25 x86: Support Intel FSP initialization path in start.S

Per Intel FSP architecture specification, FSP provides 3 routines for bootloader to call. The first one is the TempRamInit (aka Cache-As-Ram initialization) and the second one is the FspInit which does the memory bring up (like MRC for other x86 targets) and chipset initialization. Those two routines have to be called before U-Boot jumping to board_init_f in start.S.

The FspInit() will return several memory blocks called Hand Off Blocks (HOBs) whose format is described in Platform Initialization (PI) specification (part of the UEFI specication) to the bootloader. Save this HOB address to the U-Boot global data for later use.

---
 arch/x86/cpu/start.S               | 37 +++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/global_data.h |  3 +++
 arch/x86/lib/asm-offsets.c         |  3 +++
 3 files changed, 43 insertions(+)
arch/x86/cpu/start.S +37 -0
index f9662fb..b4a69d2 100644
@@ -75,6 +75,35 @@ early_board_init_ret:
 	jmp	car_init
 .globl car_init_ret
 car_init_ret:
+#ifdef CONFIG_HAVE_FSP
+	/*
+	 * The FSP TempRamInit initializes the ecx and edx registers to
+	 * point to a temporary but writable memory range (Cache-As-RAM).
+	 * ecx: the start of this temporary memory range,
+	 * edx: the end of this range.
+	 */
+
+	/* stack grows down from top of CAR */
+	movl	%edx, %esp
+
+	movl	$CONFIG_FSP_TEMP_RAM_ADDR, %eax
+	xorl	%edx, %edx
+	xorl	%ecx, %ecx
+	call	FspInitWrapper
+
+.global fsp_init_done
+fsp_init_done:
+	/*
+	 * We come here from FspInit with eax pointing to the HOB list.
+	 * Save eax to esi temporarily.
+	 */
+	movl	%eax, %esi
+	/*
+	 * Re-initialize the ebp (BIST) to zero, as we already reach here
+	 * which means we passed BIST testing before.
+	 */
+	xorl	%ebp, %ebp
+#else
 	/*
 	 * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
 	 * or fully initialised SDRAM - we really don't care which)
@@ -95,6 +124,7 @@ car_init_ret:
 #ifdef CONFIG_DCACHE_RAM_MRC_VAR_SIZE
 	subl	$CONFIG_DCACHE_RAM_MRC_VAR_SIZE, %esp
 #endif
+#endif
 
 	/* Reserve space on stack for global data */
 	subl	$GENERATED_GBL_DATA_SIZE, %esp
@@ -109,6 +139,13 @@ car_init_ret:
 	movl	%esp, %edi
 	rep	stosb
 
+#ifdef CONFIG_HAVE_FSP
+	/* Store HOB list */
+	movl	%esp, %edx
+	addl	$GD_HOB_LIST, %edx
+	movl	%esi, (%edx)
+#endif
+
 	/* Setup first parameter to setup_gdt, pointer to global_data */
 	movl	%esp, %eax
 
arch/x86/include/asm/global_data.h +3 -0
index 48bbd1a..03d491a 100644
@@ -47,6 +47,9 @@ struct arch_global_data {
 	enum pei_boot_mode_t pei_boot_mode;
 	const struct pch_gpio_map *gpio_map;	/* board GPIO map */
 	struct memory_info meminfo;	/* Memory information */
+#ifdef CONFIG_HAVE_FSP
+	void	*hob_list;		/* FSP HOB list */
+#endif
 };
 
 #endif
arch/x86/lib/asm-offsets.c +3 -0
index 50a488f..70ccf1b 100644
@@ -18,5 +18,8 @@
 int main(void)
 {
 	DEFINE(GD_BIST, offsetof(gd_t, arch.bist));
+#ifdef CONFIG_HAVE_FSP
+	DEFINE(GD_HOB_LIST, offsetof(gd_t, arch.hob_list));
+#endif
 	return 0;
 }
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH 14/25 x86: Support Intel FSP initialization path in start.S

Hi Bin,

Quoted 24 lines · Bin Meng

Per Intel FSP architecture specification, FSP provides 3 routines for bootloader to call. The first one is the TempRamInit (aka Cache-As-Ram initialization) and the second one is the FspInit which does the memory bring up (like MRC for other x86 targets) and chipset initialization. Those two routines have to be called before U-Boot jumping to board_init_f in start.S.

The FspInit() will return several memory blocks called Hand Off Blocks (HOBs) whose format is described in Platform Initialization (PI) specification (part of the UEFI specication) to the bootloader. Save this HOB address to the U-Boot global data for later use.

---
 arch/x86/cpu/start.S               | 37 +++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/global_data.h |  3 +++
 arch/x86/lib/asm-offsets.c         |  3 +++
 3 files changed, 43 insertions(+)
arch/x86/cpu/start.S +0 -0
index f9662fb..b4a69d2 100644

arch/x86/cpu/start.S early_board_init_ret: · line 78

Quoted 4 lines
arch/x86/cpu/start.S +1 -0
@@ -75,6 +75,35 @@ early_board_init_ret:
        jmp     car_init
 .globl car_init_ret
 car_init_ret:
+#ifdef CONFIG_HAVE_FSP

Can we put this code into car_init?

Quoted 4 lines
arch/x86/cpu/start.S +4 -0
+       /*
+        * The FSP TempRamInit initializes the ecx and edx registers to
+        * point to a temporary but writable memory range (Cache-As-RAM).
+        * ecx: the start of this temporary memory range,

arch/x86/cpu/start.S early_board_init_ret: · line 92

Quoted 10 lines
arch/x86/cpu/start.S +10 -0
+        * edx: the end of this range.
+        */
+
+       /* stack grows down from top of CAR */
+       movl    %edx, %esp
+
+       movl    $CONFIG_FSP_TEMP_RAM_ADDR, %eax
+       xorl    %edx, %edx
+       xorl    %ecx, %ecx
+       call    FspInitWrapper

What does this return? Can you add a a comment?

arch/x86/cpu/start.S early_board_init_ret: · line 103

Quoted 11 lines
arch/x86/cpu/start.S +11 -0
+
+.global fsp_init_done
+fsp_init_done:
+       /*
+        * We come here from FspInit with eax pointing to the HOB list.
+        * Save eax to esi temporarily.
+        */
+       movl    %eax, %esi
+       /*
+        * Re-initialize the ebp (BIST) to zero, as we already reach here
+        * which means we passed BIST testing before.

How do you know we already reached here?

Quoted 56 lines
arch/x86/cpu/start.S +11 -0
+        */
+       xorl    %ebp, %ebp
+#else
        /*
         * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
         * or fully initialised SDRAM - we really don't care which)
@@ -95,6 +124,7 @@ car_init_ret:
 #ifdef CONFIG_DCACHE_RAM_MRC_VAR_SIZE
        subl    $CONFIG_DCACHE_RAM_MRC_VAR_SIZE, %esp
 #endif
+#endif
 
        /* Reserve space on stack for global data */
        subl    $GENERATED_GBL_DATA_SIZE, %esp
@@ -109,6 +139,13 @@ car_init_ret:
        movl    %esp, %edi
        rep     stosb
 
+#ifdef CONFIG_HAVE_FSP
+       /* Store HOB list */
+       movl    %esp, %edx
+       addl    $GD_HOB_LIST, %edx
+       movl    %esi, (%edx)
+#endif
+
        /* Setup first parameter to setup_gdt, pointer to global_data */
        movl    %esp, %eax
 
arch/x86/include/asm/global_data.h +3 -0
index 48bbd1a..03d491a 100644
@@ -47,6 +47,9 @@ struct arch_global_data {
        enum pei_boot_mode_t pei_boot_mode;
        const struct pch_gpio_map *gpio_map;    /* board GPIO map */
        struct memory_info meminfo;     /* Memory information */
+#ifdef CONFIG_HAVE_FSP
+       void    *hob_list;              /* FSP HOB list */
+#endif
 };
 
 #endif
arch/x86/lib/asm-offsets.c +3 -1
index 50a488f..70ccf1b 100644
@@ -18,5 +18,8 @@
 int main(void)
 {
        DEFINE(GD_BIST, offsetof(gd_t, arch.bist));
+#ifdef CONFIG_HAVE_FSP
+       DEFINE(GD_HOB_LIST, offsetof(gd_t, arch.hob_list));
+#endif
        return 0;
 }
--
Quoted 2 lines

1.8.2.1

Regards,
Simon

author
#2 lore raw

PATCH 14/25 x86: Support Intel FSP initialization path in start.S

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Bin,

Quoted 19 lines · Bin Meng

Per Intel FSP architecture specification, FSP provides 3 routines for bootloader to call. The first one is the TempRamInit (aka Cache-As-Ram initialization) and the second one is the FspInit which does the memory bring up (like MRC for other x86 targets) and chipset initialization. Those two routines have to be called before U-Boot jumping to board_init_f in start.S.

The FspInit() will return several memory blocks called Hand Off Blocks (HOBs) whose format is described in Platform Initialization (PI) specification (part of the UEFI specication) to the bootloader. Save this HOB address to the U-Boot global data for later use.

---
 arch/x86/cpu/start.S               | 37 +++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/global_data.h |  3 +++
 arch/x86/lib/asm-offsets.c         |  3 +++
 3 files changed, 43 insertions(+)
Quoted 11 lines

arch/x86/cpu/start.S early_board_init_ret: · line 78

Quoted 9 lines
arch/x86/cpu/start.S +1 -0
index f9662fb..b4a69d2 100644
@@ -75,6 +75,35 @@ early_board_init_ret:
        jmp     car_init
 .globl car_init_ret
 car_init_ret:
+#ifdef CONFIG_HAVE_FSP

Can we put this code into car_init?

Yes, there codes can be put into car_init. I actually considered putting them to car_init before. In the FSP case, the car_init will not return to car_init_ret. Instead it will jump directly to reserving space on stack for global data. This may look weird why car_init does not return to car_init_ret. But it is not a big problem. I will move it to car_init in v2, and put a comment in start.S to explain.

Quoted 8 lines
Quoted 8 lines
arch/x86/cpu/start.S +8 -0
+       /*
+        * The FSP TempRamInit initializes the ecx and edx registers to
+        * point to a temporary but writable memory range (Cache-As-RAM).
+        * ecx: the start of this temporary memory range,
+        * edx: the end of this range.
+        */
+
+       /* stack grows down from top of CAR */
Quoted 8 lines

arch/x86/cpu/start.S early_board_init_ret: · line 92

Quoted 6 lines
arch/x86/cpu/start.S +6 -0
+       movl    %edx, %esp
+
+       movl    $CONFIG_FSP_TEMP_RAM_ADDR, %eax
+       xorl    %edx, %edx
+       xorl    %ecx, %ecx
+       call    FspInitWrapper

What does this return? Can you add a a comment?

Sure.

Quoted 5 lines
Quoted 5 lines
arch/x86/cpu/start.S +5 -0
+
+.global fsp_init_done
+fsp_init_done:
+       /*
+        * We come here from FspInit with eax pointing to the HOB list.
Quoted 8 lines

arch/x86/cpu/start.S early_board_init_ret: · line 103

Quoted 6 lines
arch/x86/cpu/start.S +6 -0
+        * Save eax to esi temporarily.
+        */
+       movl    %eax, %esi
+       /*
+        * Re-initialize the ebp (BIST) to zero, as we already reach here
+        * which means we passed BIST testing before.

How do you know we already reached here?

In the car_init, the BIST testing will be done before any call to FSP to enable the CAR. If that fails, it will never get here.

[snip]

Regards,
Bin