[U-Boot] [PATCH] bootm: vxworks: Support Linux compatible standard DTB for ARM and PPC

Bin Meng bmeng.cn at gmail.com
Fri Nov 15 08:21:17 UTC 2019


From: Lihua Zhao <lihua.zhao at windriver.com>

Enhance do_bootm_vxworks() to support Linux compatible standard DTB
for ARM and PPC, when the least significant bit of flags in VxWorks
bootargs is set. Otherwise it falls back to the existing bootm flow
which is now legacy.

Signed-off-by: Lihua Zhao <lihua.zhao at windriver.com>
Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
---

 common/bootm_os.c  | 39 +++++++++++++++++++++++++++++++++++++--
 doc/README.vxworks | 13 +++++++++++++
 include/vxworks.h  |  3 +++
 3 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/common/bootm_os.c b/common/bootm_os.c
index 6fb7d65..6c2d4e2 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -318,8 +318,8 @@ static void do_bootvx_fdt(bootm_headers_t *images)
 	puts("## vxWorks terminated\n");
 }
 
-int do_bootm_vxworks(int flag, int argc, char * const argv[],
-		     bootm_headers_t *images)
+static int do_bootm_vxworks_legacy(int flag, int argc, char * const argv[],
+				   bootm_headers_t *images)
 {
 	if (flag != BOOTM_STATE_OS_GO)
 		return 0;
@@ -335,6 +335,41 @@ int do_bootm_vxworks(int flag, int argc, char * const argv[],
 
 	return 1;
 }
+
+int do_bootm_vxworks(int flag, int argc, char * const argv[],
+		     bootm_headers_t *images)
+{
+	char *bootargs;
+	int pos;
+	unsigned long vxflags;
+	bool std_dtb = false;
+
+	/* get bootargs env */
+	bootargs = env_get("bootargs");
+
+	if (bootargs != NULL) {
+		for (pos = 0; pos < strlen(bootargs); pos++) {
+			/* find f=0xnumber flag */
+			if ((bootargs[pos] == '=') && (pos >= 1) &&
+			    (bootargs[pos - 1] == 'f')) {
+				vxflags = simple_strtoul(&bootargs[pos + 1],
+							 NULL, 16);
+				if (vxflags & VXWORKS_SYSFLG_STD_DTB)
+					std_dtb = true;
+			}
+		}
+	}
+
+	if (std_dtb) {
+		if (flag & BOOTM_STATE_OS_PREP)
+			printf("   Using standard DTB\n");
+		return do_bootm_linux(flag, argc, argv, images);
+	} else {
+		if (flag & BOOTM_STATE_OS_PREP)
+			printf("   !!! WARNING !!! Using legacy DTB\n");
+		return do_bootm_vxworks_legacy(flag, argc, argv, images);
+	}
+}
 #endif
 
 #if defined(CONFIG_CMD_ELF)
diff --git a/doc/README.vxworks b/doc/README.vxworks
index 3e08711..12a0d74 100644
--- a/doc/README.vxworks
+++ b/doc/README.vxworks
@@ -2,6 +2,7 @@
 #
 # Copyright (C) 2013, Miao Yan <miao.yan at windriver.com>
 # Copyright (C) 2015-2018, Bin Meng <bmeng.cn at gmail.com>
+# Copyright (C) 2019, Lihua Zhao <lihua.zhao at windriver.com>
 
 VxWorks Support
 ===============
@@ -24,6 +25,15 @@ From VxWorks 7, VxWorks starts adopting device tree as its hardware description
 mechanism (for PowerPC and ARM), thus requiring boot interface changes.
 This section will describe the new interface.
 
+Since VxWorks 7 SR0640 release, VxWorks starts using Linux compatible standard
+DTB for some boards. With that, the exact same bootm flow as used by Linux is
+used, which includes board-specific DTB fix up. To keep backward compatibility,
+only when the least significant bit of flags in bootargs is set, the standard
+DTB will be used. Otherwise it falls back to the legacy bootm flow.
+
+For legacy bootm flow, make sure the least significant bit of flags in bootargs
+is cleared. The calling convention is described below:
+
 For PowerPC, the calling convention of the new VxWorks entry point conforms to
 the ePAPR standard, which is shown below (see ePAPR for more details):
 
@@ -33,6 +43,9 @@ For ARM, the calling convention is shown below:
 
     void (*kernel_entry)(void *fdt_addr)
 
+When using the Linux compatible standard DTB, the calling convention of VxWorks
+entry point is exactly the same as the Linux kernel.
+
 When booting a VxWorks 7 kernel (uImage format), the parameters passed to bootm
 is like below:
 
diff --git a/include/vxworks.h b/include/vxworks.h
index 1a29509..d90d862 100644
--- a/include/vxworks.h
+++ b/include/vxworks.h
@@ -9,6 +9,9 @@
 
 #include <efi_api.h>
 
+/* Use Linux compatible standard DTB */
+#define VXWORKS_SYSFLG_STD_DTB	0x1
+
 /*
  * Physical address of memory base for VxWorks x86
  * This is LOCAL_MEM_LOCAL_ADRS in the VxWorks kernel configuration.
-- 
2.7.4



More information about the U-Boot mailing list