Skip to contentSkip to conversation

SPL: Port SPL framework to powerpc

PATCH Superseded Stefan Roese 3 participants 17 messages Sep 26, 2012 – Oct 5, 2012 PowerPC

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover SPL: Port SPL framework to powerpc

This patchset ports the SPL framework to powerpc. Its based on the SPL generalization lately done by Tom Rini. The patches can be applied on top of his 7th version located here:

http://github.com/trini/u-boot WIP/spl-improvements

Additionally, a new MPC5200 board port is included, the a3m071 board port. This board port uses this SPL framework mainly to speed up booting into the OS (Linux of course). Detection of Linux vs. U-Boot booting is done here by checking the environment variable "boot_os". If "boot_os" is set to "yes", then the OS (Linux) is booted. Otherwise the "real" U-Boot is booted. For this env checking in the SPL, a small restructuring of the env code has been done.

Comments welcome!

Thanks,
Stefan

Changes in v2:
- Rebased on Tom's SPL framework patches v4
- Add option to skip copying of the mkimage header
- Rebased on Tom's SPL framework patches v4
- Rebased on Tom's SPL framework patches v4
- a3m071 build: Concat SPL binary and u-boot.img directly (no padding)

Changes in v3:
- Rebased on current master plus SPL framework v7
- Don't use special MPC5xxx memcpy in SPL
- Move linker symbols to header spl.h (checkpatch)

Stefan Roese (8):
powerpc: Extract EPAPR_MAGIC constants into processor.h
SPL: Port SPL framework to powerpc
env: Extract getenv_f() into separate source file
mpc5200: Add SPL support
mpc5200: Add a3m071 board support
fdt: cmd_fdt: Call fdt_chosen() from "fdt boardsetup"
Makefile: Add possibility to set entry-point for u-boot.img
Makefile: Add target for combined spl/u-boot.bin & u-boot.img

 MAINTAINERS                             |   2 +
 Makefile                                |  14 +-
 arch/powerpc/cpu/mpc5xxx/Makefile       |   4 +
 arch/powerpc/cpu/mpc5xxx/spl_boot.c     |  79 +++++++
 arch/powerpc/cpu/mpc5xxx/start.S        |  22 ++
 arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds |  57 +++++
 arch/powerpc/include/asm/processor.h    |   6 +
 arch/powerpc/include/asm/spl.h          |  31 +++
 arch/powerpc/lib/Makefile               |  11 +
 arch/powerpc/lib/bootm.c                |   6 -
 arch/powerpc/lib/spl.c                  |  42 ++++
 board/a3m071/Makefile                   |  36 +++
 board/a3m071/README                     |  79 +++++++
 board/a3m071/a3m071.c                   | 335 +++++++++++++++++++++++++++
 board/a3m071/mt46v16m16-75.h            |  32 +++
 boards.cfg                              |   1 +
 common/Makefile                         |   4 +
 common/cmd_fdt.c                        |   4 +-
 common/cmd_nvedit.c                     |  58 -----
 common/env_getenv_f.c                   |  82 +++++++
 common/spl/spl.c                        |  10 +
 include/configs/a3m071.h                | 385 ++++++++++++++++++++++++++++++++
 22 files changed, 1234 insertions(+), 66 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc5xxx/spl_boot.c
 create mode 100644 arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds
 create mode 100644 arch/powerpc/include/asm/spl.h
 create mode 100644 arch/powerpc/lib/spl.c
 create mode 100644 board/a3m071/Makefile
 create mode 100644 board/a3m071/README
 create mode 100644 board/a3m071/a3m071.c
 create mode 100644 board/a3m071/mt46v16m16-75.h
 create mode 100644 common/env_getenv_f.c
 create mode 100644 include/configs/a3m071.h
Signature · 1 line
1.7.12.1
#1 lore raw

PATCH v3 1/8 powerpc: Extract EPAPR_MAGIC constants into processor.h

By extracting these defines into a header, they can be re-used by other C sources as well. This will be done by the SPL framework OS boot support.

---

 arch/powerpc/include/asm/processor.h | 6 ++++++
 arch/powerpc/lib/bootm.c             | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/processor.h +6 -0
index dc009d6..daa670b 100644
@@ -1329,4 +1329,10 @@ void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
 #endif
 #endif /* CONFIG_MACH_SPECIFIC */
 
+#if defined(CONFIG_MPC85xx) || defined(CONFIG_440)
+ #define EPAPR_MAGIC	(0x45504150)
+#else
+ #define EPAPR_MAGIC	(0x65504150)
+#endif
+
 #endif /* __ASM_PPC_PROCESSOR_H */
arch/powerpc/lib/bootm.c +0 -6
index 53dc4df..e3fee0b 100644
@@ -87,12 +87,6 @@ static void boot_jump_linux(bootm_headers_t *images)
 		 *   r8: 0
 		 *   r9: 0
 		 */
-#if defined(CONFIG_MPC85xx) || defined(CONFIG_440)
- #define EPAPR_MAGIC	(0x45504150)
-#else
- #define EPAPR_MAGIC	(0x65504150)
-#endif
-
 		debug ("   Booting using OF flat tree...\n");
 		WATCHDOG_RESET ();
 		(*kernel) ((bd_t *)of_flat_tree, 0, 0, EPAPR_MAGIC,
Signature · 1 line
1.7.12.1
#2 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

In reply to Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

---
Changes in v2:
- Rebased on Tom's SPL framework patches v4
- Add option to skip copying of the mkimage header

 arch/powerpc/lib/Makefile |  1 +
 arch/powerpc/lib/spl.c    | 42 ++++++++++++++++++++++++++++++++++++++++++
 common/spl/spl.c          | 10 ++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/powerpc/lib/spl.c
arch/powerpc/lib/Makefile +1 -0
index 965f9ea..9bcbdde 100644
@@ -50,6 +50,7 @@ COBJS-y	+= cache.o
 COBJS-y	+= extable.o
 COBJS-y	+= interrupts.o
 COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
+COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 COBJS-y	+= time.o
 
 # Workaround for local bus unaligned access problems
arch/powerpc/lib/spl.c new file +42 -0

42 lines not on this page · raw message

common/spl/spl.c +10 -0
index c640f87..e568c49 100644
@@ -74,6 +74,16 @@ __weak int spl_start_uboot(void)
 }
 #endif
 
+/*
+ * Weak default function for board specific cleanup/preparation before
+ * Linux boot. Some boards/platforms might now need it, so just provide
+ * an empty stub here.
+ */
+__weak void spl_board_prepare_for_linux(void)
+{
+	/* Nothing to do! */
+}
+
 void spl_parse_image_header(const struct image_header *header)
 {
 	u32 header_size = sizeof(struct image_header);
Signature · 1 line
1.7.12.1
#3 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

Quoted 21 lines · Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

---
Changes in v2:
- Rebased on Tom's SPL framework patches v4
- Add option to skip copying of the mkimage header

 arch/powerpc/lib/Makefile |  1 +
 arch/powerpc/lib/spl.c    | 42  
++++++++++++++++++++++++++++++++++++++++++
 common/spl/spl.c          | 10 ++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/powerpc/lib/spl.c
arch/powerpc/lib/Makefile +0 -0
index 965f9ea..9bcbdde 100644

arch/powerpc/lib/Makefile COBJS-y += cache.o · line 54

Quoted 5 lines
arch/powerpc/lib/Makefile +1 -0
@@ -50,6 +50,7 @@ COBJS-y	+= cache.o
 COBJS-y	+= extable.o
 COBJS-y	+= interrupts.o
 COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
+COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 COBJS-y	+= time.o

Won't this build spl.o into the main U-Boot as well?

Quoted 12 lines
arch/powerpc/lib/Makefile +2 -0
+/*
+ * This function jumps to an image with argument. Normally an FDT or  

ATAGS
+ * image.
+ * arg: Pointer to paramter image in RAM
+ */

arch/powerpc/lib/Makefile +5 -0
+#ifdef CONFIG_SPL_OS_BOOT
+void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);
+	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5,  

ulong r6,

arch/powerpc/lib/Makefile

Quoted 7 lines
arch/powerpc/lib/Makefile +7 -0
+					  ulong r7, ulong r8, ulong r9)
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
+	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
+}

At what point does the image get cache-flushed?

-Scott

#4 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 13 lines · Scott Wood
Quoted 12 lines · Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

Rebased on Tom's SPL framework patches v4 - Add option to skip copying of the mkimage header

arch/powerpc/lib/Makefile | 1 + arch/powerpc/lib/spl.c | 42
++++++++++++++++++++++++++++++++++++++++++ common/spl/spl.c | 10 ++++++++++ 3 files changed, 53 insertions(+) create mode 100644 arch/powerpc/lib/spl.c

Quoted 8 lines
Quoted 6 lines
(quoted diff) +0 -0

b/arch/powerpc/lib/Makefile index 965f9ea..9bcbdde 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@
-50,6 +50,7 @@ COBJS-y += cache.o COBJS-y += extable.o
COBJS-y += interrupts.o COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
+COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o COBJS-y += time.o

Won't this build spl.o into the main U-Boot as well?

True and probably uncaught as PowerPC uses -ffunction-sections /
- --gc-sections on main U-Boot.

- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQZjOOAAoJENk4IS6UOR1We/UQAKmSBzEcGwjNzG9LqZhrRATj 8eMp/mep10saPAoaf8iUjqn+gWtAuvTdP9a0Nd4wkHUFtlvh7PPx6SQ1PNTf1V+z VkOaXxplN52p0Ba/PKKEU4RFd9kdtxLrH+HM8mzz6ktzvwFT8lnCGY//C0OW8vk5 FLTeZafyde1OY5igGA2t/+Lu4CM3Dl1o7wMqcy7nNTucAMGgBjvZueOF7SWFAT7F 4mjxjIq9Co1NOIE9kCR4nmoJpRgvLZ2nBZpv2NDkXjKEr/6G2CSgDxBUG+Q2nGFG HaBQv4yDfBEPCjUKWm+pq8BMYg/M+WuJZ02NNbGG09PeB8C+a26oYiy9KEPA+i5F tTaBqgTNGIayqsYtOhQXEQntMudP1FTwCxQ2QMXuu3K5kY+foi5V/HdZ3Iy3Wl9W WigE2+FBRfMPlvZT+s7qQ54UVOJgylRvld7e0jt/kcwTMF8WG3CauzqzgMbADz9C Fr7J+cqij0JMCvE2E3/1Q8N4WIcnwBlM7R7TXVzd8cb3u/WHoLGVwhgLWGz3dg/E /Ko+k4S/E0f3NWRX9pd1ygEveYNi4qVf8vWIaNMetjJputhHsToPtY8iid0TgOxt oXGlOtOxHHkr5YFV3GIO6gmDWBzwTYrOCS9clrWZUq1fTgKxbsIythoOg0YIhA+U Olz0yRI+lzUOkTOV1ZGc
=VYvH
-----END PGP SIGNATURE-----

#5 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

In reply to Scott Wood
Quoted 17 lines · Scott Wood
Quoted 16 lines · Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

---
Changes in v2:
- Rebased on Tom's SPL framework patches v4
- Add option to skip copying of the mkimage header

 arch/powerpc/lib/Makefile |  1 +
 arch/powerpc/lib/spl.c    | 42  
++++++++++++++++++++++++++++++++++++++++++
 common/spl/spl.c          | 10 ++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/powerpc/lib/spl.c
Quoted 12 lines

arch/powerpc/lib/Makefile COBJS-y += cache.o · line 54

Quoted 10 lines
arch/powerpc/lib/Makefile +1 -0
index 965f9ea..9bcbdde 100644
@@ -50,6 +50,7 @@ COBJS-y	+= cache.o
 COBJS-y	+= extable.o
 COBJS-y	+= interrupts.o
 COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
+COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 COBJS-y	+= time.o

Won't this build spl.o into the main U-Boot as well?

Yes. I'll fix it in the next patchset version.

Quoted 13 lines
Quoted 13 lines
arch/powerpc/lib/Makefile +2 -0
+/*
+ * This function jumps to an image with argument. Normally an FDT or  

ATAGS
+ * image.
+ * arg: Pointer to paramter image in RAM
+ */

arch/powerpc/lib/Makefile +5 -0
+#ifdef CONFIG_SPL_OS_BOOT
+void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);
+	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5,  

ulong r6,

arch/powerpc/lib/Makefile +1 -0
+					  ulong r7, ulong r8, ulong r9)
Quoted 8 lines

arch/powerpc/lib/Makefile

Quoted 6 lines
arch/powerpc/lib/Makefile +6 -0
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
+	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
+}

At what point does the image get cache-flushed?

Not at all right now. MPC5200 has dcache disabled, at least in the SPL. Other PowerPC architectures might add a cache flush here if needed at some time. Okay?

Thanks,
Stefan

#6 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

Quoted 57 lines · Stefan Roese
Quoted 2 lines · Scott Wood
Quoted 1 line · Stefan Roese

This patch enables the SPL framework to be used on powerpc

platforms

Quoted 15 lines
Quoted 15 lines

and not only ARM.

---
Changes in v2:
- Rebased on Tom's SPL framework patches v4
- Add option to skip copying of the mkimage header

 arch/powerpc/lib/Makefile |  1 +
 arch/powerpc/lib/spl.c    | 42
++++++++++++++++++++++++++++++++++++++++++
 common/spl/spl.c          | 10 ++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 arch/powerpc/lib/spl.c
Quoted 12 lines

arch/powerpc/lib/Makefile COBJS-y += cache.o · line 54

Quoted 10 lines
arch/powerpc/lib/Makefile +1 -0
index 965f9ea..9bcbdde 100644
@@ -50,6 +50,7 @@ COBJS-y	+= cache.o
 COBJS-y	+= extable.o
 COBJS-y	+= interrupts.o
 COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
+COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 COBJS-y	+= time.o

Won't this build spl.o into the main U-Boot as well?

Yes. I'll fix it in the next patchset version.

Quoted 2 lines

arch/powerpc/lib/Makefile COBJS-y += cache.o · line 56

Quoted 2 lines
arch/powerpc/lib/Makefile +2 -0
+/*
+ * This function jumps to an image with argument. Normally an FDT  

or

Quoted 11 lines
Quoted 11 lines

ATAGS
+ * image.
+ * arg: Pointer to paramter image in RAM
+ */

arch/powerpc/lib/Makefile +5 -0
+#ifdef CONFIG_SPL_OS_BOOT
+void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);
+	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5,

ulong r6,

arch/powerpc/lib/Makefile +1 -0
+					  ulong r7, ulong r8, ulong r9)
Quoted 8 lines

arch/powerpc/lib/Makefile

Quoted 6 lines
arch/powerpc/lib/Makefile +6 -0
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
+	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
+}

At what point does the image get cache-flushed?

Quoted 4 lines

Not at all right now. MPC5200 has dcache disabled, at least in the SPL.
Other PowerPC architectures might add a cache flush here if needed at some time. Okay?

Or they might forget to do so and have weird bugs.

Why not just call flush_cache() on the image now? Non-SPL does this in common code, not even PPC-specific.

-Scott

#7 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

Quoted 20 lines · Scott Wood
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
arch/powerpc/lib/spl.c new file +4 -0
+void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);
+	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5,

ulong r6,

arch/powerpc/lib/spl.c new file +1 -0
+					  ulong r7, ulong r8, ulong r9)
Quoted 8 lines

arch/powerpc/lib/spl.c line 41

Quoted 6 lines
arch/powerpc/lib/spl.c new file +6 -0
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
+	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
+}

At what point does the image get cache-flushed?

Quoted 4 lines

Not at all right now. MPC5200 has dcache disabled, at least in the SPL.
Other PowerPC architectures might add a cache flush here if needed at some time. Okay?

Quoted 4 lines

Or they might forget to do so and have weird bugs.

Why not just call flush_cache() on the image now? Non-SPL does this in common code, not even PPC-specific.

Okay, probably better to add this code now. But shouldn't we add this code to the common SPL framework code then? Right before calling jump_to_image_linux()?

Tom? Should I prepare a patch adding this cache flushing to common/spl/spl.c?

Thanks,
Stefan

#8 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

Quoted 27 lines · Stefan Roese
Quoted 4 lines · Scott Wood
Quoted 4 lines
Quoted 4 lines

arch/powerpc/lib/spl.c

Quoted 4 lines
arch/powerpc/lib/spl.c new file +4 -0
+void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);
+	typedef void (*image_entry_arg_t)(void *, ulong r4,  

ulong r5,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines

ulong r6,

(quoted diff) +1 -0
+					  ulong r7, ulong r8,  

ulong r9)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

arch/powerpc/lib/spl.c

Quoted 5 lines
arch/powerpc/lib/spl.c new file +5 -0
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
+	image_entry(arg, 0, 0, EPAPR_MAGIC,  

CONFIG_SYS_BOOTMAPSZ, 0, 0);

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+}

At what point does the image get cache-flushed?

Not at all right now. MPC5200 has dcache disabled, at least in the SPL.
Other PowerPC architectures might add a cache flush here if needed

at

Quoted 4 lines
Quoted 1 line

some time. Okay?

Or they might forget to do so and have weird bugs.

Quoted 7 lines
Quoted 1 line

Why not just call flush_cache() on the image now? Non-SPL does

this in

Quoted 1 line

common code, not even PPC-specific.

Okay, probably better to add this code now. But shouldn't we add this code to the common SPL framework code then? Right before calling jump_to_image_linux()?

Sure, I didn't mean it should go here (it needs to be somewhere that knows the image start/end, not just the entry point). This is just the patch that prompted me to ask the question.

-Scott

#9 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

Quoted 32 lines · Scott Wood
Quoted 31 lines · Stefan Roese
Quoted 4 lines · Scott Wood
Quoted 4 lines
Quoted 4 lines

arch/powerpc/lib/spl.c

Quoted 4 lines
arch/powerpc/lib/spl.c new file +4 -0
+void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);
+	typedef void (*image_entry_arg_t)(void *, ulong r4,  

ulong r5,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines

ulong r6,

(quoted diff) +1 -0
+					  ulong r7, ulong r8,  

ulong r9)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

arch/powerpc/lib/spl.c

Quoted 5 lines
arch/powerpc/lib/spl.c new file +5 -0
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
+	image_entry(arg, 0, 0, EPAPR_MAGIC,  

CONFIG_SYS_BOOTMAPSZ, 0, 0);

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+}

At what point does the image get cache-flushed?

Not at all right now. MPC5200 has dcache disabled, at least in the SPL.
Other PowerPC architectures might add a cache flush here if needed

at

Quoted 5 lines
Quoted 1 line

some time. Okay?

Or they might forget to do so and have weird bugs.

Why not just call flush_cache() on the image now? Non-SPL does

this in

Quoted 1 line

common code, not even PPC-specific.

Quoted 7 lines
Quoted 3 lines

Okay, probably better to add this code now. But shouldn't we add this code to the common SPL framework code then? Right before calling jump_to_image_linux()?

Sure, I didn't mean it should go here (it needs to be somewhere that knows the image start/end, not just the entry point). This is just the patch that prompted me to ask the question.

I see.

Tom, whats your input on this? Do you see any problems about putting a flush_cache() into the common SPL framework code? Are any of the ARM platforms currently using this framework already running with d-cache enabled?

Should I post a patch?

Thanks,
Stefan

#10 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 39 lines · Stefan Roese
Quoted 30 lines · Scott Wood
Quoted 29 lines · Stefan Roese
Quoted 3 lines · Scott Wood
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+void __noreturn jump_to_image_linux(void *arg) +{ + debug("Entering kernel arg pointer: 0x%p\n", arg); + typedef void (*image_entry_arg_t)(void *, ulong r4,

ulong r5,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ulong r6, + ulong r7, ulong r8,

ulong r9)

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +1 -0
+		__attribute__ ((noreturn)); +	image_entry_arg_t

image_entry = +
(image_entry_arg_t)spl_image.entry_point; + +
image_entry(arg, 0, 0, EPAPR_MAGIC,

CONFIG_SYS_BOOTMAPSZ, 0, 0);

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+}

At what point does the image get cache-flushed?

Not at all right now. MPC5200 has dcache disabled, at least in the SPL. Other PowerPC architectures might add a cache flush here if needed

at

Quoted 6 lines
Quoted 1 line

some time. Okay?

Or they might forget to do so and have weird bugs.

Why not just call flush_cache() on the image now? Non-SPL does

this in

Quoted 1 line

common code, not even PPC-specific.

Quoted 7 lines
Quoted 3 lines

Okay, probably better to add this code now. But shouldn't we add this code to the common SPL framework code then? Right before calling jump_to_image_linux()?

Sure, I didn't mean it should go here (it needs to be somewhere that knows the image start/end, not just the entry point). This is just the patch that prompted me to ask the question.

Quoted 6 lines

I see.

Tom, whats your input on this? Do you see any problems about putting a flush_cache() into the common SPL framework code? Are any of the ARM platforms currently using this framework already running with d-cache enabled?

On ARM, jump_to_image_linux() calls cleanup_before_linux() to take care of flushing, etc. So the PowerPC jump_to_image_linux should take care of what it needs to take care of.

- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQbvs/AAoJENk4IS6UOR1WXB4P/0g4rlsgzs1QBqRnM7oo/gDx k3yNcN4jz7eHkY+X0hdgd8IqH8znqvptbr6D0w7/a35ZNqe0YZGqjQVI6DOh6QPx oVSDYuywbP9arA83sYy44Ucf/acn/vYuvFqHoM7PTukUGcX3pdG5V4qiGnHe0H/B 4cp0iyY9wvt/eSrB6P7ZB2rse+fnQswBVEQ20Lkinr2ZkXcQMxiUHixfmxtQSV+b SSHnd1XjSeIrLGHw4HlyoDYjZ8DQc4Zw/Sc/9fGnuwOiir4K743VXhU5hao4fQWp F8OQgLaVkxxkALkwfdYS1G+vUgfzCxvWTxG3x/9oXUPh8VcXkqwhK3CXcnvLGAs8 3gu33UFzgMAFfd5bthwgKx50K9dTVSUWRsOu3lDUDi3jYZNoRpxcatQ5dWV1IW2V UGgBQ4e7UE0h3SvQocnHbJAm+qcLyT6USH2xTyWRqi129OwKbuYM4nDH/nrYW11I K7VY+tCqP9hoReuzVzFzsfBdaAzS9A+Z3uejYzfKaolnFvp8Bz4HVLdDQ9XBnddv 3flO7M4cO35xroBQ2QltibUkI5tgp3lmsVBuMUj5CQ7uojdjHoUNjfRKAKkKJYVp 07vlraRqNiqO1w7WoJCb3rLyH5P/9gZYoMkRsmtjA/Upg4FV+ntQgzDINANGE7e9 Lqd5K3EBnDLeLXt1bdWY
=5wlk
-----END PGP SIGNATURE-----

#11 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

Quoted 47 lines · Tom Rini

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 8 lines · Stefan Roese
Quoted 7 lines · Scott Wood
Quoted 6 lines · Stefan Roese
Quoted 3 lines · Scott Wood
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+void __noreturn jump_to_image_linux(void *arg) +{ + debug("Entering kernel arg pointer: 0x%p\n", arg); + typedef void (*image_entry_arg_t)(void *, ulong r4,

ulong r5,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ulong r6, + ulong r7,

ulong r8,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

ulong r9)

Quoted 1 line
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +1 -0
+		__attribute__ ((noreturn)); +	 

image_entry_arg_t

Quoted 31 lines
Quoted 21 lines
Quoted 21 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

image_entry = +
(image_entry_arg_t)spl_image.entry_point; + +
image_entry(arg, 0, 0, EPAPR_MAGIC,

CONFIG_SYS_BOOTMAPSZ, 0, 0);

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+}

At what point does the image get cache-flushed?

Not at all right now. MPC5200 has dcache disabled, at least in the SPL. Other PowerPC architectures might add a cache flush here if needed

at

Quoted 6 lines
Quoted 1 line

some time. Okay?

Or they might forget to do so and have weird bugs.

Why not just call flush_cache() on the image now? Non-SPL does

this in

Quoted 1 line

common code, not even PPC-specific.

Quoted 7 lines
Quoted 3 lines

Okay, probably better to add this code now. But shouldn't we add this code to the common SPL framework code then? Right before calling jump_to_image_linux()?

Sure, I didn't mean it should go here (it needs to be somewhere that knows the image start/end, not just the entry point). This is just the patch that prompted me to ask the question.

I see.

Quoted 8 lines
Quoted 4 lines

Tom, whats your input on this? Do you see any problems about putting a flush_cache() into the common SPL framework code? Are any of the ARM platforms currently using this framework already running with d-cache enabled?

On ARM, jump_to_image_linux() calls cleanup_before_linux() to take care of flushing, etc. So the PowerPC jump_to_image_linux should take care of what it needs to take care of.

It seems that most implementations of cleanup_before_linux() -- which is quite misnamed as we need to do this stuff no matter what we're loading -- disable and flush the entire cache. Are there any implementations that just flush the range that the image was loaded into? Is that information available at that point?

What if we're loading main U-Boot and not Linux? Does cleanup_before_linux() still get called?

Normal U-Boot does this from generic code, why not SPL? It should become a no-op on platforms that don't need it.

-Scott

#12 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

In reply to Tom Rini

On 10/05/2012 05:22 PM, Tom Rini wrote:

<snip>

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines

Okay, probably better to add this code now. But shouldn't we add this code to the common SPL framework code then? Right before calling jump_to_image_linux()?

Sure, I didn't mean it should go here (it needs to be somewhere that knows the image start/end, not just the entry point). This is just the patch that prompted me to ask the question.

I see.

Quoted 8 lines
Quoted 4 lines

Tom, whats your input on this? Do you see any problems about putting a flush_cache() into the common SPL framework code? Are any of the ARM platforms currently using this framework already running with d-cache enabled?

On ARM, jump_to_image_linux() calls cleanup_before_linux() to take care of flushing, etc. So the PowerPC jump_to_image_linux should take care of what it needs to take care of.

Hmmm. Why not move this cleanup_xxx stuff into the common code as well? Is it really that platform specific? Cache flushing is a common problem.

So basically a "+1" for Scotts comments. But I would suggest to address this in a follow up patch, to consolidate all this cleanup/cache_flush stuff. Okay?

Thanks,
Stefan

#13 lore raw

PATCH v3 2/8 SPL: Port SPL framework to powerpc

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 24 lines · Stefan Roese

On 10/05/2012 05:22 PM, Tom Rini wrote:

<snip>

Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

Okay, probably better to add this code now. But shouldn't we add this code to the common SPL framework code then? Right before calling jump_to_image_linux()?

Sure, I didn't mean it should go here (it needs to be somewhere that knows the image start/end, not just the entry point). This is just the patch that prompted me to ask the question.

I see.

Quoted 8 lines
Quoted 4 lines

Tom, whats your input on this? Do you see any problems about putting a flush_cache() into the common SPL framework code? Are any of the ARM platforms currently using this framework already running with d-cache enabled?

On ARM, jump_to_image_linux() calls cleanup_before_linux() to take care of flushing, etc. So the PowerPC jump_to_image_linux should take care of what it needs to take care of.

Quoted 7 lines

Hmmm. Why not move this cleanup_xxx stuff into the common code as well? Is it really that platform specific? Cache flushing is a common problem.

So basically a "+1" for Scotts comments. But I would suggest to address this in a follow up patch, to consolidate all this cleanup/cache_flush stuff. Okay?

OK, so my quick check of things shows that in SPL, arm isn't ever enabling the dcache (at least CONFIG_SPL_FRAMEWORK), we just make sure that yes, really, we're good to go for Linux kernel booting. That's why we haven't had this as a general issue yet. So in sum, yes, please come up with patches to get things in a more consistent state.
It should probably be re-naming cleanup_before_linux as well and
calling that as in some cases we need to do a little more than i/d_disable, flush (see the v7 one). Thanks!

- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQbxnlAAoJENk4IS6UOR1WzcMP+wY7gH6kE9ryBF+Aem78dz/O 5nCBzQJg6GSpab6S4qUFGutmh0GVqMhTgA5cQrlzNt7JvZNboe15bf/u91g6RNCv q2saJzYj8wQJ7DrUQtAoNA/jdI5zLTQ8jE0Zbg8kD/MszP5NipMH7SHZTfoedVfx dAqoDpmXFbsp70E8/rtnlhP+8z5kxrw9xzZwRvtjb1oAT8w707frge4Yfa/lz2Xo vd55/CzdUYwJRKgJmdSzYjGmV+nBER6IDl76LiVg4C/xVbcc8qjO8Ebja2j8Cftr cuJ7ith/RLpMNqPQ/yNwA25MK3yBL1AA+XGADjMhMv4VjzbapRkDveUOFYzORlko jdjEOfR4g0onerjHGTkysIqIchvxPOatDm0a0+kw+JronCh9aJMJOZ0xjaBdEQ9Q xQDA+U+o45+YKFTuAAOisehJ5hmgnmqV2yH4my7CR/NcJvaV1vbq0DN1O9gIRvWU x1wUKWH/MtOs/SdIDXF+nIwI7LBK96YyTERIaOwpa01YuTkc8m6frGJZYZO1yaQU sACj3e8mQmXkkXXy6eKiY/aJLnMep1ZNOf/JobzSN+R92g01yED88T38/aqZWt80 0+N2vFmLZvg4CLWWdUbVNxU7mv14b2kCc2bI5m7zuTXdXccTausaZ9r3WZgBnY3R RPYJc0MosHUmXEozty2y
=3AZY
-----END PGP SIGNATURE-----

#14 lore raw

PATCH v3 3/8 env: Extract getenv_f() into separate source file

In reply to Stefan Roese

By extracting getenv_f and envmatch() from cmd_nvedit.c into a separate file, getenv_f() can be included easily into the SPL binary. With this, SPL boards can now use getenv_f() to read environment variables (e.g. to detect if the OS or U-Boot shall be executed).

In the approach this is done for env stored in NOR flash, as this will be used by an upcoming MPC5200 board port.

---
Changes in v3:
- Rebased on current master plus SPL framework v7

 common/Makefile       |  4 +++
 common/cmd_nvedit.c   | 58 ------------------------------------
 common/env_getenv_f.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 58 deletions(-)
 create mode 100644 common/env_getenv_f.c
common/Makefile +4 -0
index 22e8a6f..c30099d 100644
@@ -50,6 +50,7 @@ XCOBJS-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o
 COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_embedded.o
 XCOBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o
 COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_embedded.o
+COBJS-y += env_getenv_f.o
 COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 COBJS-$(CONFIG_ENV_IS_IN_MMC) += env_mmc.o
 COBJS-$(CONFIG_ENV_IS_IN_FAT) += env_fat.o
@@ -194,6 +195,9 @@ COBJS-$(CONFIG_CMD_DFU) += cmd_dfu.o
 endif
 
 ifdef CONFIG_SPL_BUILD
+COBJS-y += env_common.o
+COBJS-y += env_getenv_f.o
+COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
 endif
 COBJS-y += console.o
common/cmd_nvedit.c +0 -58

70 lines not on this page · raw message

common/env_getenv_f.c new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
1.7.12.1
#15 lore raw

PATCH v3 3/8 env: Extract getenv_f() into separate source file

Quoted 8 lines · Stefan Roese

By extracting getenv_f and envmatch() from cmd_nvedit.c into a separate file, getenv_f() can be included easily into the SPL binary. With this, SPL boards can now use getenv_f() to read environment variables (e.g. to detect if the OS or U-Boot shall be executed).

In the approach this is done for env stored in NOR flash, as this will be used by an upcoming MPC5200 board port.

This patch is not needed as it seems. I'll post a new version in a short while that only enables the needed files for SPL_BUILD.

Thanks,
Stefan

#16 lore raw

PATCH v3 4/8 mpc5200: Add SPL support

In reply to Stefan Roese

This patch adds SPL booting support (NOR flash) for the MPC5200 platforms.

---
Changes in v2:
- Rebased on Tom's SPL framework patches v4

Changes in v3:
- Don't use special MPC5xxx memcpy in SPL
- Move linker symbols to header spl.h (checkpatch)

 arch/powerpc/cpu/mpc5xxx/Makefile       |  4 ++
 arch/powerpc/cpu/mpc5xxx/spl_boot.c     | 79 +++++++++++++++++++++++++++++++++
 arch/powerpc/cpu/mpc5xxx/start.S        | 22 +++++++++
 arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds | 57 ++++++++++++++++++++++++
 arch/powerpc/include/asm/spl.h          | 31 +++++++++++++
 arch/powerpc/lib/Makefile               | 10 +++++
 6 files changed, 203 insertions(+)
 create mode 100644 arch/powerpc/cpu/mpc5xxx/spl_boot.c
 create mode 100644 arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds
 create mode 100644 arch/powerpc/include/asm/spl.h
arch/powerpc/cpu/mpc5xxx/Makefile +4 -0
index 1a088b7..8de2c13 100644
@@ -41,6 +41,10 @@ COBJS-y += speed.o
 COBJS-$(CONFIG_CMD_USB) += usb_ohci.o
 COBJS-$(CONFIG_CMD_USB) += usb.o
 
+ifdef CONFIG_SPL_BUILD
+COBJS-y += spl_boot.o
+endif
+
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS-y))
 START	:= $(addprefix $(obj),$(SSTART) $(CSTART))
arch/powerpc/cpu/mpc5xxx/spl_boot.c new file +79 -0

79 lines not on this page · raw message

arch/powerpc/cpu/mpc5xxx/start.S +22 -0
index 51cc4e2..ad5bc0a 100644
@@ -50,6 +50,7 @@
 #define MSR_KERNEL (MSR_FP|MSR_ME|MSR_RI)
 #endif
 
+#ifndef CONFIG_SPL_BUILD
 /*
  * Set up GOT: Global Offset Table
  *
@@ -68,6 +69,7 @@
 	GOT_ENTRY(__bss_end__)
 	GOT_ENTRY(__bss_start)
 	END_GOT
+#endif
 
 /*
  * Version string
@@ -84,6 +86,18 @@ version_string:
 	. = EXC_OFF_SYS_RESET
 	.globl	_start
 _start:
+
+#if defined(CONFIG_SPL) && !defined(CONFIG_SPL_BUILD)
+	/*
+	 * This is the entry of the real U-Boot from a board port
+	 * that supports SPL booting on the MPC5200. We only need
+	 * to call board_init_f() here. Everything else has already
+	 * been done in the SPL u-boot version.
+	 */
+	GET_GOT			/* initialize GOT access		*/
+	bl	board_init_f	/* run 1st part of board init code (in Flash)*/
+	/* NOTREACHED - board_init_f() does not return */
+#else
 	mfmsr	r5			/* save msr contents		*/
 
 	/* Move CSBoot and adjust instruction pointer                   */
@@ -152,7 +166,9 @@ lowboot_reentry:
 	/* Be careful to keep code relocatable !			*/
 	/*--------------------------------------------------------------*/
 
+#ifndef CONFIG_SPL_BUILD
 	GET_GOT			/* initialize GOT access		*/
+#endif
 
 	/* r3: IMMR */
 	bl	cpu_init_f	/* run low-level CPU init code (in Flash)*/
@@ -160,7 +176,9 @@ lowboot_reentry:
 	bl	board_init_f	/* run 1st part of board init code (in Flash)*/
 
 	/* NOTREACHED - board_init_f() does not return */
+#endif
 
+#ifndef CONFIG_SPL_BUILD
 /*
  * Vector Table
  */
@@ -333,6 +351,7 @@ int_return:
 	lwz	r1,GPR1(r1)
 	SYNC
 	rfi
+#endif /* CONFIG_SPL_BUILD */
 
 /*
  * This code initialises the MPC5xxx processor core
@@ -522,6 +541,7 @@ get_pvr:
 	mfspr	r3, PVR
 	blr
 
+#ifndef CONFIG_SPL_BUILD
 /*------------------------------------------------------------------------------*/
 
 /*
@@ -759,3 +779,5 @@ trap_init:
 
 	mtlr	r4			/* restore link register    */
 	blr
+
+#endif /* CONFIG_SPL_BUILD */
arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds new file +57 -0

57 lines not on this page · raw message

arch/powerpc/include/asm/spl.h new file +31 -0
new file mode 100644
index 0000000..f43bc23
@@ -0,0 +1,31 @@
+/*
+ * (C) Copyright 2012
+ * Texas Instruments, <www.ti.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#ifndef	_ASM_SPL_H_
+#define	_ASM_SPL_H_
+
+#define BOOT_DEVICE_NOR		1
+
+/* Linker symbols */
+extern char __bss_start[], __bss_end__[];
+
+#endif
arch/powerpc/lib/Makefile +10 -0
index 9bcbdde..cdb7a31 100644
@@ -44,7 +44,9 @@ SOBJS-y	+= ticks.o
 SOBJS-y	+= reloc.o
 
 COBJS-$(CONFIG_BAT_RW) += bat_rw.o
+ifndef CONFIG_SPL_BUILD
 COBJS-y	+= board.o
+endif
 COBJS-y	+= bootm.o
 COBJS-y	+= cache.o
 COBJS-y	+= extable.o
@@ -53,6 +55,11 @@ COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
 COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 COBJS-y	+= time.o
 
+# Don't include the MPC5xxx special memcpy into the
+# SPL U-Boot image. memcpy is used in the SPL NOR
+# flash driver. And we need the real, fast memcpy
+# here. We have no problems with unaligned access.
+ifndef CONFIG_SPL_BUILD
 # Workaround for local bus unaligned access problems
 # on MPC512x and MPC5200
 ifdef CONFIG_MPC512X
@@ -63,6 +70,7 @@ ifdef CONFIG_MPC5200
 $(obj)ppcstring.o: AFLAGS += -Dmemcpy=__memcpy
 COBJS-y += memcpy_mpc5200.o
 endif
+endif
 
 COBJS	+= $(sort $(COBJS-y))
 
@@ -75,12 +83,14 @@ TARGETS += $(LIB)
 all: $(TARGETS)
 
 $(LIB):	$(obj).depend $(OBJS)
+ifndef CONFIG_SPL_BUILD
 	@if ! $(CROSS_COMPILE)readelf -S $(OBJS) | grep -q '\.fixup.*PROGBITS';\
 	then \
 		echo "ERROR: Your compiler doesn't generate .fixup sections!";\
 		echo "       Upgrade to a recent toolchain."; \
 		exit 1; \
 	fi;
+endif
 	$(call cmd_link_o_target, $(OBJS))
 
 $(LIBGCC): $(obj).depend $(LGOBJS)
Signature · 1 line
1.7.12.1