Skip to contentSkip to conversation

Add ability for arch code to make changes before we boot

PATCH New Kumar Gala 3 participants 11 messages Aug 14, 2009 – Aug 27, 2009

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

Added a arch_preboot() function that cpu specific code can implement to allow for various modifications to the state of the machine right before we boot. This can be useful to setup register state to a specific configuration.

---
 common/cmd_bootm.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_bootm.c +10 -0
index 86c8122..766889a 100644
@@ -166,6 +166,13 @@ void __arch_lmb_reserve(struct lmb *lmb)
 }
 void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__arch_lmb_reserve")));
 
+/* Allow for arch specific config before we boot */
+void __arch_preboot(void)
+{
+	/* please define platform specific arch_preboot() */
+}
+void arch_preboot(void) __attribute__((weak, alias("__arch_preboot")));
+
 #if defined(__ARM__)
   #define IH_INITRD_ARCH IH_ARCH_ARM
 #elif defined(__avr32__)
@@ -543,6 +550,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 			break;
 		case BOOTM_STATE_OS_GO:
 			disable_interrupts();
+			arch_preboot();
 			boot_fn(BOOTM_STATE_OS_GO, argc, argv, &images);
 			break;
 	}
@@ -673,6 +681,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 
+	arch_preboot();
+
 	boot_fn(0, argc, argv, &images);
 
 	show_boot_progress (-9);
Signature · 1 line
1.6.0.6
author
#1 lore raw

PATCH 1/1 85xx: Add support for setting IVORs to fixed offset defaults

In future Book-E implementations IVORs will most likely go away and be replaced with fixed offsets. The IVPR will continue to exist to allow for relocation of the interrupt vectors.

This code adds support to setup the IVORs as their fixed offset values per the ISA 2.06 spec when we transition from u-boot to another OS either via 'bootm' or a cpu release.

---
 cpu/mpc85xx/cpu_init.c      |    7 ++++
 cpu/mpc85xx/fixed_ivor.S    |   79 +++++++++++++++++++++++++++++++++++++++++++
 cpu/mpc85xx/release.S       |    3 ++
 cpu/mpc85xx/start.S         |    6 +++
 include/asm-ppc/processor.h |   12 ++++++
 5 files changed, 107 insertions(+), 0 deletions(-)
 create mode 100644 cpu/mpc85xx/fixed_ivor.S
cpu/mpc85xx/cpu_init.c +7 -0
index 41de694..76db914 100644
@@ -374,3 +374,10 @@ int cpu_init_r(void)
 #endif
 	return 0;
 }
+
+extern void setup_ivors(void);
+
+void arch_preboot(void)
+{
+	setup_ivors();
+}
cpu/mpc85xx/fixed_ivor.S new file +79 -0

79 lines not on this page · raw message

cpu/mpc85xx/release.S +3 -0
index 2d4f219..b839ba0 100644
@@ -167,6 +167,9 @@ __secondary_start_page:
 	andi.	r11,r4,1
 	bne	2b
 	isync
+	
+	/* setup IVORs to match fixed offsets */
+#include "fixed_ivor.S"
 
 	/* get the upper bits of the addr */
 	lwz	r11,ENTRY_ADDR_UPPER(r10)
cpu/mpc85xx/start.S +6 -0
index 4f7236f..e21a4eb 100644
@@ -1122,3 +1122,9 @@ flush_dcache:
 	isync
 
 	blr
+
+.globl setup_ivors
+setup_ivors:
+
+#include "fixed_ivor.S"
+	blr
include/asm-ppc/processor.h +12 -0
index 5547245..a2b74bf 100644
@@ -468,6 +468,16 @@
 #define SPRN_IVOR13	0x19d	/* Interrupt Vector Offset Register 13 */
 #define SPRN_IVOR14	0x19e	/* Interrupt Vector Offset Register 14 */
 #define SPRN_IVOR15	0x19f	/* Interrupt Vector Offset Register 15 */
+#define SPRN_IVOR38	0x1b0	/* Interrupt Vector Offset Register 38 */
+#define SPRN_IVOR39	0x1b1	/* Interrupt Vector Offset Register 39 */
+#define SPRN_IVOR40	0x1b2	/* Interrupt Vector Offset Register 40 */
+#define SPRN_IVOR41	0x1b3	/* Interrupt Vector Offset Register 41 */
+#define SPRN_GIVOR2	0x1b8	/* Guest Interrupt Vector Offset Register 2 */
+#define SPRN_GIVOR3	0x1b9	/* Guest Interrupt Vector Offset Register 3 */
+#define SPRN_GIVOR4	0x1ba	/* Guest Interrupt Vector Offset Register 4 */
+#define SPRN_GIVOR8	0x1bb	/* Guest Interrupt Vector Offset Register 8 */
+#define SPRN_GIVOR13	0x1bc	/* Guest Interrupt Vector Offset Register 13 */
+#define SPRN_GIVOR14	0x1bd	/* Guest Interrupt Vector Offset Register 14 */
 
 /* e500 definitions */
 #define SPRN_L1CFG0	0x203	/* L1 Cache Configuration Register 0 */
@@ -513,6 +523,8 @@
 #define SPRN_IVOR33	0x211	/* Interrupt Vector Offset Register 33 */
 #define SPRN_IVOR34	0x212	/* Interrupt Vector Offset Register 34 */
 #define SPRN_IVOR35	0x213	/* Interrupt Vector Offset Register 35 */
+#define SPRN_IVOR36	0x214	/* Interrupt Vector Offset Register 36 */
+#define SPRN_IVOR37	0x215	/* Interrupt Vector Offset Register 37 */
 #define SPRN_SPEFSCR	0x200	/* SPE & Embedded FP Status & Control */
 
 #define SPRN_MCSRR0	0x23a	/* Machine Check Save and Restore Register 0 */
Signature · 1 line
1.6.0.6
author
#2 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

In reply to Kumar Gala
Quoted 11 lines · Kumar Gala

Added a arch_preboot() function that cpu specific code can implement to
allow for various modifications to the state of the machine right before
we boot. This can be useful to setup register state to a specific configuration.

---
common/cmd_bootm.c | 10 ++++++++++

1 files changed, 10 insertions(+), 0 deletions(-)

If you can review and ack this if its ok that would be great. I'd like to send this via the 85xx next tree as the patch for fixed IVORs depends on it.

- k

Quoted 47 lines
common/cmd_bootm.c +7 -0
index 86c8122..766889a 100644
@@ -166,6 +166,13 @@ void __arch_lmb_reserve(struct lmb *lmb)
 }
 void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak,  
 alias("__arch_lmb_reserve")));
 
+/* Allow for arch specific config before we boot */
+void __arch_preboot(void)
+{
+	/* please define platform specific arch_preboot() */
+}
+void arch_preboot(void) __attribute__((weak,  
 alias("__arch_preboot")));
+
 #if defined(__ARM__)

#define IH_INITRD_ARCH IH_ARCH_ARM
#elif defined(__avr32__)

common/cmd_bootm.c +1 -0
@@ -543,6 +550,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int  
 flag, int argc, char *argv[])
 			break;
 		case BOOTM_STATE_OS_GO:
 			disable_interrupts();
+			arch_preboot();
 			boot_fn(BOOTM_STATE_OS_GO, argc, argv, &images);
 			break;
	}
common/cmd_bootm.c +2 -0
@@ -673,6 +681,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int  
 argc, char *argv[])
 		return 1;
 	}
 
+	arch_preboot();
+
 	boot_fn(0, argc, argv, &images);
 
	show_boot_progress (-9);
Signature · 6 lines
1.6.0.6

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
#3 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

In reply to Kumar Gala
Quoted 15 lines · Kumar Gala

Added a arch_preboot() function that cpu specific code can implement to allow for various modifications to the state of the machine right before we boot. This can be useful to setup register state to a specific configuration.

---
 common/cmd_bootm.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_bootm.c +0 -0
index 86c8122..766889a 100644

common/cmd_bootm.c void __arch_lmb_reserve(struct lmb *lmb) · line 175

Quoted 10 lines
common/cmd_bootm.c +7 -0
@@ -166,6 +166,13 @@ void __arch_lmb_reserve(struct lmb *lmb)
 }
 void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__arch_lmb_reserve")));
 
+/* Allow for arch specific config before we boot */
+void __arch_preboot(void)
+{
+	/* please define platform specific arch_preboot() */
+}
+void arch_preboot(void) __attribute__((weak, alias("__arch_preboot")));
+

why not a section so you will be able to have multiple callback so it can be arch or soc or board too in any combination

Best Regards,
J.

author
#4 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

Quoted 22 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 21 lines · Kumar Gala

Added a arch_preboot() function that cpu specific code can implement to
allow for various modifications to the state of the machine right before
we boot. This can be useful to setup register state to a specific configuration.

---
common/cmd_bootm.c | 10 ++++++++++

1 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_bootm.c +0 -0
index 86c8122..766889a 100644
@@ -166,6 +166,13 @@ void __arch_lmb_reserve(struct lmb *lmb)
 }
 void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak,  
 alias("__arch_lmb_reserve")));
 
Quoted 11 lines

common/cmd_bootm.c void __arch_lmb_reserve(struct lmb *lmb) · line 175

Quoted 8 lines
common/cmd_bootm.c +7 -0
+/* Allow for arch specific config before we boot */
+void __arch_preboot(void)
+{
+	/* please define platform specific arch_preboot() */
+}
+void arch_preboot(void) __attribute__((weak,  
 alias("__arch_preboot")));
+

why not a section so you will be able to have multiple callback so it can be
arch or soc or board too in any combination

Because the use I have for it is a simple single case at this point.

If and when we need more complexity we can add it.

- k

#5 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

Quoted 37 lines · Kumar Gala
Quoted 22 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 21 lines · Kumar Gala

Added a arch_preboot() function that cpu specific code can implement to
allow for various modifications to the state of the machine right before
we boot. This can be useful to setup register state to a specific configuration.

---
common/cmd_bootm.c | 10 ++++++++++

1 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_bootm.c +0 -0
index 86c8122..766889a 100644
@@ -166,6 +166,13 @@ void __arch_lmb_reserve(struct lmb *lmb)
 }
 void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak,
 alias("__arch_lmb_reserve")));
 
Quoted 11 lines

common/cmd_bootm.c void __arch_lmb_reserve(struct lmb *lmb) · line 175

Quoted 8 lines
common/cmd_bootm.c +7 -0
+/* Allow for arch specific config before we boot */
+void __arch_preboot(void)
+{
+	/* please define platform specific arch_preboot() */
+}
+void arch_preboot(void) __attribute__((weak,
 alias("__arch_preboot")));
+

why not a section so you will be able to have multiple callback so it can be
arch or soc or board too in any combination

Quoted 3 lines

Because the use I have for it is a simple single case at this point.

If and when we need more complexity we can add it.

we have already it
as example the usb drivers that need to be stop before start an os I forget some but I'm sure to have seen oher

Best Regards,
J.

author
#6 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

Quoted 38 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 37 lines · Kumar Gala
Quoted 33 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 19 lines · Kumar Gala

Added a arch_preboot() function that cpu specific code can implement to
allow for various modifications to the state of the machine right before
we boot. This can be useful to setup register state to a specific configuration.

---
common/cmd_bootm.c | 10 ++++++++++

1 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_bootm.c +0 -0
index 86c8122..766889a 100644
@@ -166,6 +166,13 @@ void __arch_lmb_reserve(struct lmb *lmb)
 }
 void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak,

common/cmd_bootm.c void __arch_lmb_reserve(struct lmb *lmb) · line 177

Quoted 10 lines
common/cmd_bootm.c +7 -0
 alias("__arch_lmb_reserve")));
 
+/* Allow for arch specific config before we boot */
+void __arch_preboot(void)
+{
+	/* please define platform specific arch_preboot() */
+}
+void arch_preboot(void) __attribute__((weak,
 alias("__arch_preboot")));
+

why not a section so you will be able to have multiple callback so it can be
arch or soc or board too in any combination

Quoted 6 lines
Quoted 3 lines

Because the use I have for it is a simple single case at this point.

If and when we need more complexity we can add it.

we have already it
as example the usb drivers that need to be stop before start an os I forget some but I'm sure to have seen oher

We already handle USB in the bootm code. I don't see any reason to go add a bunch of code for the one case we handle.

- k

author
#7 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

In reply to Kumar Gala
Quoted 11 lines · Kumar Gala

Added a arch_preboot() function that cpu specific code can implement to
allow for various modifications to the state of the machine right before
we boot. This can be useful to setup register state to a specific configuration.

---
common/cmd_bootm.c | 10 ++++++++++

1 files changed, 10 insertions(+), 0 deletions(-)

Wolfgang,

Can you look at either commenting on this or picking it up for 'next'. Its one patch the current '85xx next' tree depends on.

- k

#8 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

In reply to Kumar Gala

Dear Kumar Gala,

Quoted 15 lines · In message <[email protected]> you…

Added a arch_preboot() function that cpu specific code can implement to allow for various modifications to the state of the machine right before we boot. This can be useful to setup register state to a specific configuration.

---
 common/cmd_bootm.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_bootm.c +0 -0
index 86c8122..766889a 100644

common/cmd_bootm.c void __arch_lmb_reserve(struct lmb *lmb) · line 170

Quoted 5 lines
common/cmd_bootm.c +2 -0
@@ -166,6 +166,13 @@ void __arch_lmb_reserve(struct lmb *lmb)
 }
 void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__arch_lmb_reserve")));
 
+/* Allow for arch specific config before we boot */
+void __arch_preboot(void)

As this is only used when booting an OS (and not for example when starting a standalone program) we should probably write:

	/* Allow for arch specific code before booting the OS */
	void __arch_preboot_os()
	...

common/cmd_bootm.c int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 551

Quoted 11 lines
common/cmd_bootm.c +5 -0
+{
+	/* please define platform specific arch_preboot() */
+}
+void arch_preboot(void) __attribute__((weak, alias("__arch_preboot")));
+
 #if defined(__ARM__)
   #define IH_INITRD_ARCH IH_ARCH_ARM
 #elif defined(__avr32__)
@@ -543,6 +550,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 			break;
 		case BOOTM_STATE_OS_GO:

Hm... maybe this could / should be handled in BOOTM_STATE_OS_PREP state?

common/cmd_bootm.c int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 553

Quoted 2 lines
common/cmd_bootm.c +1 -0
 			disable_interrupts();
+			arch_preboot();

And maybe we should mode disable_interrupts() into the default implementation of arch_preboot_os() ?

common/cmd_bootm.c int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 686

Quoted 10 lines
common/cmd_bootm.c +2 -0
 			boot_fn(BOOTM_STATE_OS_GO, argc, argv, &images);
 			break;
 	}
@@ -673,6 +681,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 
+	arch_preboot();
+
 	boot_fn(0, argc, argv, &images);

But this would change behaviour here. Eventually to the better?

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Niklaus Wirth has lamented that, whereas Europeans pronounce his name
correctly  (Ni-klows  Virt),  Americans  invariably  mangle  it  into
(Nick-les  Worth).  Which  is to say that Europeans call him by name,
but Americans call him by value.
author
#9 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

Quoted 31 lines · Wolfgang Denk

Dear Kumar Gala,

In message <[email protected]

Quoted 18 lines

you wrote:
Added a arch_preboot() function that cpu specific code can implement to
allow for various modifications to the state of the machine right before
we boot. This can be useful to setup register state to a specific configuration.

---
common/cmd_bootm.c | 10 ++++++++++

1 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_bootm.c +0 -0
index 86c8122..766889a 100644

common/cmd_bootm.c void __arch_lmb_reserve(struct lmb *lmb) · line 171

Quoted 6 lines
common/cmd_bootm.c +2 -0
@@ -166,6 +166,13 @@ void __arch_lmb_reserve(struct lmb *lmb)
 }
 void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak,  
 alias("__arch_lmb_reserve")));
 
+/* Allow for arch specific config before we boot */
+void __arch_preboot(void)

As this is only used when booting an OS (and not for example when starting a standalone program) we should probably write:

Quoted 3 lines
	/* Allow for arch specific code before booting the OS */
	void __arch_preboot_os()
	...

no problem, will change the name.

Quoted 8 lines
Quoted 8 lines
common/cmd_bootm.c +5 -0
+{
+	/* please define platform specific arch_preboot() */
+}
+void arch_preboot(void) __attribute__((weak,  
 alias("__arch_preboot")));
+
 #if defined(__ARM__)
  #define IH_INITRD_ARCH IH_ARCH_ARM
Quoted 8 lines

common/cmd_bootm.c int do_bootm_subcommand (cmd_tbl_t *cmdtp, int · line 552

Quoted 5 lines

#elif defined(__avr32__)

common/cmd_bootm.c +0 -0
@@ -543,6 +550,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int  
 flag, int argc, char *argv[])
 			break;
 		case BOOTM_STATE_OS_GO:

Hm... maybe this could / should be handled in BOOTM_STATE_OS_PREP state?

I'd prefer to keep arch_preboot_os() as close to boot_fn() as possible

Quoted 5 lines

common/cmd_bootm.c int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 553

Quoted 2 lines
common/cmd_bootm.c +1 -0
 			disable_interrupts();
+			arch_preboot();

And maybe we should mode disable_interrupts() into the default implementation of arch_preboot_os() ?

Got no issue with moving disable_interrupts into the default implementation of arch_preboot_os()

Quoted 10 lines
Quoted 10 lines
common/cmd_bootm.c +0 -0
 			boot_fn(BOOTM_STATE_OS_GO, argc, argv, &images);
 			break;
	}
common/cmd_bootm.c +0 -0
@@ -673,6 +681,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int  
 argc, char *argv[])
 		return 1;
 	}
 
Quoted 5 lines

common/cmd_bootm.c int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 686

Quoted 3 lines
common/cmd_bootm.c +2 -0
+	arch_preboot();
+
 	boot_fn(0, argc, argv, &images);

But this would change behaviour here. Eventually to the better?

Not sure if I see how this would be better (or worse for that matter).

- k

author
#10 lore raw

PATCH 1/1 Add ability for arch code to make changes before we boot

Quoted 59 lines · Kumar Gala
Quoted 31 lines · Wolfgang Denk

Dear Kumar Gala,

In message <[email protected]

Quoted 18 lines

you wrote:
Added a arch_preboot() function that cpu specific code can implement to
allow for various modifications to the state of the machine right before
we boot. This can be useful to setup register state to a specific configuration.

---
common/cmd_bootm.c | 10 ++++++++++

1 files changed, 10 insertions(+), 0 deletions(-)
common/cmd_bootm.c +0 -0
index 86c8122..766889a 100644

common/cmd_bootm.c void __arch_lmb_reserve(struct lmb *lmb) · line 171

Quoted 6 lines
common/cmd_bootm.c +2 -0
@@ -166,6 +166,13 @@ void __arch_lmb_reserve(struct lmb *lmb)
 }
 void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak,
 alias("__arch_lmb_reserve")));
 
+/* Allow for arch specific config before we boot */
+void __arch_preboot(void)

As this is only used when booting an OS (and not for example when starting a standalone program) we should probably write:

Quoted 3 lines
	/* Allow for arch specific code before booting the OS */
	void __arch_preboot_os()
	...

no problem, will change the name.

Quoted 8 lines
Quoted 8 lines
common/cmd_bootm.c +5 -0
+{
+	/* please define platform specific arch_preboot() */
+}
+void arch_preboot(void) __attribute__((weak,
 alias("__arch_preboot")));
+
 #if defined(__ARM__)

#define IH_INITRD_ARCH IH_ARCH_ARM

Quoted 8 lines

common/cmd_bootm.c int do_bootm_subcommand (cmd_tbl_t *cmdtp, int · line 552

Quoted 5 lines

#elif defined(__avr32__)

common/cmd_bootm.c +0 -0
@@ -543,6 +550,7 @@ int do_bootm_subcommand (cmd_tbl_t *cmdtp, int
 flag, int argc, char *argv[])
 			break;
 		case BOOTM_STATE_OS_GO:

Hm... maybe this could / should be handled in BOOTM_STATE_OS_PREP state?

I'd prefer to keep arch_preboot_os() as close to boot_fn() as possible

Quoted 8 lines
Quoted 5 lines

common/cmd_bootm.c int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) · line 553

Quoted 2 lines
common/cmd_bootm.c +1 -0
 			disable_interrupts();
+			arch_preboot();

And maybe we should mode disable_interrupts() into the default implementation of arch_preboot_os() ?

Got no issue with moving disable_interrupts into the default implementation of arch_preboot_os()

Now that I look at how do_bootm() calls and uses disable_interrupts() this is a bit more tricky. I'd prefer to leave disable_interrupts() alone.

- k