[U-Boot] [Patch v2] vxworks: Add CONFIG_VXWORKS_PREBOOT

Niklaus Giger niklaus.giger at netstal.com
Wed Sep 23 16:03:06 CEST 2009


The option CONFIG_VXWORKS_PREBOOT allows a board specific
vxworks_preboot to be run just before jumping into the
vxWorks images. This can be used to alter a register
which is used differently by U-boot and vxWorks.

The patch defines a weak function which may be overridden by a board
specific version. vxworks_preboot should return 0 to indicated
that everything worked fine. The error code is checked and the
vxWorks image will not be loaded in case of errors.

Signed-off-by: Niklaus Giger <niklaus.giger at netstal.com>
---
 board/netstal/mcu25/mcu25.c |    8 ++++++++
 common/cmd_elf.c            |   11 +++++++++++
 include/vxworks.h           |    2 ++
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/board/netstal/mcu25/mcu25.c b/board/netstal/mcu25/mcu25.c
index 9054282..d64194d 100644
--- a/board/netstal/mcu25/mcu25.c
+++ b/board/netstal/mcu25/mcu25.c
@@ -53,6 +53,7 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 #define CPC0_CR0_VALUE	0x0007F03C
 #define CPC0_CR1_VALUE	0x00004051
+#define CPCO_CR1_USE_EXTERNAL  0x00804051
 
 int board_early_init_f (void)
 {
@@ -161,6 +162,13 @@ int misc_init_r(void)
 	return 0;
 }
 
+int vxworks_preboot(void) {
+	if (sys_install_requested()) {
+		mtdcr(CPC0_CR1, CPCO_CR1_USE_EXTERNAL);
+	}
+	return 0;
+}
+
 phys_size_t initdram(int board_type)
 {
 	unsigned int dram_size = 64*1024*1024;
diff --git a/common/cmd_elf.c b/common/cmd_elf.c
index 63f6fe7..c8eb88a 100644
--- a/common/cmd_elf.c
+++ b/common/cmd_elf.c
@@ -53,6 +53,11 @@ unsigned long do_bootelf_exec (ulong (*entry)(int, char *[]), int argc, char *ar
 	return ret;
 }
 
+__attribute__((weak)) int vxworks_preboot(void)
+{
+	return 0;
+}
+
 /* ======================================================================
  * Interpreter command to boot an arbitrary ELF image from memory.
  * ====================================================================== */
@@ -100,6 +105,7 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	char *bootline;			/* Text of the bootline        */
 	char *tmp;			/* Temporary char pointer      */
 	char build_buf[128];		/* Buffer for building the bootline */
+	int  rc;			/* Checking vxworks_preboot */
 
 	/* ---------------------------------------------------
 	 *
@@ -211,6 +217,11 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	printf ("## Using bootline (@ 0x%lx): %s\n", bootaddr,
 			(char *) bootaddr);
+	rc = vxworks_preboot();
+	if (rc != 0) {
+		printf ("## vxworks_preboot failed with %d\n", rc);
+		return 1;
+	}
 	printf ("## Starting vxWorks at 0x%08lx ...\n", addr);
 
 	((void (*)(void)) addr) ();
diff --git a/include/vxworks.h b/include/vxworks.h
index 1633904..2edbf8e 100644
--- a/include/vxworks.h
+++ b/include/vxworks.h
@@ -50,4 +50,6 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 #define CONFIG_SYS_VXWORKS_SERVERNAME	"srv"
 #endif
 
+int vxworks_preboot(void);
+
 #endif
-- 
1.6.3.3



More information about the U-Boot mailing list