All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd
@ 2015-04-06 21:02 Sjoerd Simons
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 1/8] sandbox: only do sandboxfs for hostfs interface Sjoerd Simons
                   ` (7 more replies)
  0 siblings, 8 replies; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-06 21:02 UTC (permalink / raw)
  To: u-boot


Testing whether images will correctly boot with the standard distro
bootcmds can be rather time-consuming as it tends to require flashing
the images and booting on a device. Ditto for testing changes to
config_distro_bootcmd.

Adding support for sandbox to run distro bootcmds makes things a lot
more convenient.

Sjoerd Simons (8):
  sandbox: only do sandboxfs for hostfs interface
  sandbox: Split bootm code out into lib/bootm
  sandbox: Add support for bootz
  sandbox: Renamed sb command to host
  sandbox: Implement host dev [device]
  config_distro_bootcmd.h: Add shared block definition for the host
    interface
  pxe: Ensure all memory access is to mapped memory
  sandbox: add config_distro_defaults and config_distro_bootcmd

 arch/sandbox/cpu/cpu.c               | 12 -----
 arch/sandbox/lib/Makefile            |  1 +
 arch/sandbox/lib/bootm.c             | 40 ++++++++++++++++
 common/Makefile                      |  2 +-
 common/{cmd_sandbox.c => cmd_host.c} | 93 +++++++++++++++++++++++++++++-------
 common/cmd_pxe.c                     | 86 +++++++++++++++++++++------------
 fs/sandbox/sandboxfs.c               |  6 ++-
 include/config_distro_bootcmd.h      | 13 +++++
 include/configs/sandbox.h            | 29 +++++++++--
 9 files changed, 218 insertions(+), 64 deletions(-)
 create mode 100644 arch/sandbox/lib/bootm.c
 rename common/{cmd_sandbox.c => cmd_host.c} (50%)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 1/8] sandbox: only do sandboxfs for hostfs interface
  2015-04-06 21:02 [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd Sjoerd Simons
@ 2015-04-06 21:02 ` Sjoerd Simons
  2015-04-07 20:40   ` Simon Glass
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 2/8] sandbox: Split bootm code out into lib/bootm Sjoerd Simons
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-06 21:02 UTC (permalink / raw)
  To: u-boot

Only do sandbox filesystem access when using the hostfs device
interface, rather then falling back to it in all cases. This prevents
confusion situations due to the fallback being taken rather then an
unsupported error being raised.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed-by: Simon Glass <sjg@chromium.org>

---

Changes in v2:
- Minor comment coding style improvement

 fs/sandbox/sandboxfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c
index a920bc0..5acfc03 100644
--- a/fs/sandbox/sandboxfs.c
+++ b/fs/sandbox/sandboxfs.c
@@ -10,7 +10,11 @@
 
 int sandbox_fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info)
 {
-	return 0;
+	/*
+	 * Only accept a NULL block_dev_desc_t for the sandbox, which is when
+	 * hostfs interface is used
+	 */
+	return rbdd != NULL;
 }
 
 int sandbox_fs_read_at(const char *filename, loff_t pos, void *buffer,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 2/8] sandbox: Split bootm code out into lib/bootm
  2015-04-06 21:02 [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd Sjoerd Simons
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 1/8] sandbox: only do sandboxfs for hostfs interface Sjoerd Simons
@ 2015-04-06 21:02 ` Sjoerd Simons
  2015-04-07 20:40   ` Simon Glass
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz Sjoerd Simons
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-06 21:02 UTC (permalink / raw)
  To: u-boot

Follow the convention of other architectures and move the platform
specific linux bootm code into sandbox/lib/bootm.c.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---

Changes in v2: None

 arch/sandbox/cpu/cpu.c    | 12 ------------
 arch/sandbox/lib/Makefile |  1 +
 arch/sandbox/lib/bootm.c  | 21 +++++++++++++++++++++
 3 files changed, 22 insertions(+), 12 deletions(-)
 create mode 100644 arch/sandbox/lib/bootm.c

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 1aa397c..a0c8106 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -40,18 +40,6 @@ unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
 	return os_get_nsec() / 1000;
 }
 
-int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
-{
-	if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
-		bootstage_mark(BOOTSTAGE_ID_RUN_OS);
-		printf("## Transferring control to Linux (at address %08lx)...\n",
-		       images->ep);
-		reset_cpu(0);
-	}
-
-	return 0;
-}
-
 int cleanup_before_linux(void)
 {
 	return 0;
diff --git a/arch/sandbox/lib/Makefile b/arch/sandbox/lib/Makefile
index 4c1a38d..3c86cc2 100644
--- a/arch/sandbox/lib/Makefile
+++ b/arch/sandbox/lib/Makefile
@@ -9,3 +9,4 @@
 
 
 obj-y	+= interrupts.o
+obj-$(CONFIG_CMD_BOOTM) += bootm.o
diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
new file mode 100644
index 0000000..8ddf4ef
--- /dev/null
+++ b/arch/sandbox/lib/bootm.c
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+{
+	if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
+		bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+		printf("## Transferring control to Linux (at address %08lx)...\n",
+		       images->ep);
+		reset_cpu(0);
+	}
+
+	return 0;
+}
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz
  2015-04-06 21:02 [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd Sjoerd Simons
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 1/8] sandbox: only do sandboxfs for hostfs interface Sjoerd Simons
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 2/8] sandbox: Split bootm code out into lib/bootm Sjoerd Simons
@ 2015-04-06 21:02 ` Sjoerd Simons
  2015-04-06 21:40   ` Stephen Warren
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 4/8] sandbox: Renamed sb command to host Sjoerd Simons
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-06 21:02 UTC (permalink / raw)
  To: u-boot

Add dummy bootz_setup implementation allowing the u-boot sandbox to
run bootz. This recognizes both ARM and x86 zImages to validate a
valid zImage was loaded.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

---

Changes in v2:
- Move into sandbox/lib/bootm.c
- convert to u-boot coding style
- Remove unneeded cast

 arch/sandbox/lib/bootm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
index 8ddf4ef..25c5aa4 100644
--- a/arch/sandbox/lib/bootm.c
+++ b/arch/sandbox/lib/bootm.c
@@ -8,6 +8,25 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+int bootz_setup(ulong image, ulong *start, ulong *end)
+{
+	uint8_t *zimage = map_sysmem(image, 0);
+	uint8_t arm_magic[] = { 0x18, 0x28, 0x6f, 0x01 };
+
+	if (memcmp(zimage + 0x202, "HdrS", 4) == 0) {
+		printf("setting up x86 zImage\n");
+	} else if (memcmp(zimage + 0x24, arm_magic, 4) == 0) {
+		printf("setting up ARM zImage\n");
+	} else {
+		printf("Unrecognized zImage\n");
+		return 1;
+	}
+
+	*start = 0xdead;
+	*end = 0xbeef;
+	return 0;
+}
+
 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 {
 	if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 4/8] sandbox: Renamed sb command to host
  2015-04-06 21:02 [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd Sjoerd Simons
                   ` (2 preceding siblings ...)
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz Sjoerd Simons
@ 2015-04-06 21:02 ` Sjoerd Simons
  2015-04-07 20:40   ` Simon Glass
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 5/8] sandbox: Implement host dev [device] Sjoerd Simons
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-06 21:02 UTC (permalink / raw)
  To: u-boot

As suggested by Simon Glass, rename the sb command to host but keep the
old sb command as an alias

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---

Changes in v2: None

 common/Makefile                      |  2 +-
 common/{cmd_sandbox.c => cmd_host.c} | 49 +++++++++++++++++++++++-------------
 2 files changed, 33 insertions(+), 18 deletions(-)
 rename common/{cmd_sandbox.c => cmd_host.c} (62%)

diff --git a/common/Makefile b/common/Makefile
index 7216a13..ccb5b99 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -151,7 +151,7 @@ obj-$(CONFIG_CMD_PXE) += cmd_pxe.o
 obj-$(CONFIG_CMD_READ) += cmd_read.o
 obj-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o
 obj-$(CONFIG_CMD_REISER) += cmd_reiser.o
-obj-$(CONFIG_SANDBOX) += cmd_sandbox.o
+obj-$(CONFIG_SANDBOX) += cmd_host.o
 obj-$(CONFIG_CMD_SATA) += cmd_sata.o
 obj-$(CONFIG_CMD_SF) += cmd_sf.o
 obj-$(CONFIG_CMD_SCSI) += cmd_scsi.o
diff --git a/common/cmd_sandbox.c b/common/cmd_host.c
similarity index 62%
rename from common/cmd_sandbox.c
rename to common/cmd_host.c
index 4286969..d8a0bea 100644
--- a/common/cmd_sandbox.c
+++ b/common/cmd_host.c
@@ -10,25 +10,25 @@
 #include <sandboxblockdev.h>
 #include <asm/errno.h>
 
-static int do_sandbox_load(cmd_tbl_t *cmdtp, int flag, int argc,
+static int do_host_load(cmd_tbl_t *cmdtp, int flag, int argc,
 			   char * const argv[])
 {
 	return do_load(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
 }
 
-static int do_sandbox_ls(cmd_tbl_t *cmdtp, int flag, int argc,
+static int do_host_ls(cmd_tbl_t *cmdtp, int flag, int argc,
 			   char * const argv[])
 {
 	return do_ls(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
 }
 
-static int do_sandbox_save(cmd_tbl_t *cmdtp, int flag, int argc,
+static int do_host_save(cmd_tbl_t *cmdtp, int flag, int argc,
 			   char * const argv[])
 {
 	return do_save(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
 }
 
-static int do_sandbox_bind(cmd_tbl_t *cmdtp, int flag, int argc,
+static int do_host_bind(cmd_tbl_t *cmdtp, int flag, int argc,
 			   char * const argv[])
 {
 	if (argc < 2 || argc > 3)
@@ -44,7 +44,7 @@ static int do_sandbox_bind(cmd_tbl_t *cmdtp, int flag, int argc,
 	return host_dev_bind(dev, file);
 }
 
-static int do_sandbox_info(cmd_tbl_t *cmdtp, int flag, int argc,
+static int do_host_info(cmd_tbl_t *cmdtp, int flag, int argc,
 			   char * const argv[])
 {
 	if (argc < 1 || argc > 2)
@@ -85,25 +85,25 @@ static int do_sandbox_info(cmd_tbl_t *cmdtp, int flag, int argc,
 	return 0;
 }
 
-static cmd_tbl_t cmd_sandbox_sub[] = {
-	U_BOOT_CMD_MKENT(load, 7, 0, do_sandbox_load, "", ""),
-	U_BOOT_CMD_MKENT(ls, 3, 0, do_sandbox_ls, "", ""),
-	U_BOOT_CMD_MKENT(save, 6, 0, do_sandbox_save, "", ""),
-	U_BOOT_CMD_MKENT(bind, 3, 0, do_sandbox_bind, "", ""),
-	U_BOOT_CMD_MKENT(info, 3, 0, do_sandbox_info, "", ""),
+static cmd_tbl_t cmd_host_sub[] = {
+	U_BOOT_CMD_MKENT(load, 7, 0, do_host_load, "", ""),
+	U_BOOT_CMD_MKENT(ls, 3, 0, do_host_ls, "", ""),
+	U_BOOT_CMD_MKENT(save, 6, 0, do_host_save, "", ""),
+	U_BOOT_CMD_MKENT(bind, 3, 0, do_host_bind, "", ""),
+	U_BOOT_CMD_MKENT(info, 3, 0, do_host_info, "", ""),
 };
 
-static int do_sandbox(cmd_tbl_t *cmdtp, int flag, int argc,
+static int do_host(cmd_tbl_t *cmdtp, int flag, int argc,
 		      char * const argv[])
 {
 	cmd_tbl_t *c;
 
-	/* Skip past 'sandbox' */
+	/* Skip past 'host' */
 	argc--;
 	argv++;
 
-	c = find_cmd_tbl(argv[0], cmd_sandbox_sub,
-			 ARRAY_SIZE(cmd_sandbox_sub));
+	c = find_cmd_tbl(argv[0], cmd_host_sub,
+			 ARRAY_SIZE(cmd_host_sub));
 
 	if (c)
 		return c->cmd(cmdtp, flag, argc, argv);
@@ -112,8 +112,8 @@ static int do_sandbox(cmd_tbl_t *cmdtp, int flag, int argc,
 }
 
 U_BOOT_CMD(
-	sb,	8,	1,	do_sandbox,
-	"Miscellaneous sandbox commands",
+	sb,	8,	1,	do_host,
+	"Deprecated use host command instead - Miscellaneous sandbox commands",
 	"load hostfs - <addr> <filename> [<bytes> <offset>]  - "
 		"load a file from host\n"
 	"sb ls hostfs - <filename>                    - list files on host\n"
@@ -124,3 +124,18 @@ U_BOOT_CMD(
 	"sb commands use the \"hostfs\" device. The \"host\" device is used\n"
 	"with standard IO commands such as fatls or ext2load"
 );
+
+U_BOOT_CMD(
+	host, 8, 1, do_host,
+	"Miscellaneous host commands",
+	"load hostfs - <addr> <filename> [<bytes> <offset>]  - "
+		"load a file from host\n"
+	"host ls hostfs - <filename>                    - list files on host\n"
+	"host save hostfs - <addr> <filename> <bytes> [<offset>] - "
+		"save a file to host\n"
+	"host bind <dev> [<filename>] - bind \"host\" device to file\n"
+	"host info [<dev>]            - show device binding & info\n"
+	"host commands use the \"hostfs\" device. The \"host\" device is used\n"
+	"with standard IO commands such as fatls or ext2load"
+);
+
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 5/8] sandbox: Implement host dev [device]
  2015-04-06 21:02 [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd Sjoerd Simons
                   ` (3 preceding siblings ...)
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 4/8] sandbox: Renamed sb command to host Sjoerd Simons
@ 2015-04-06 21:02 ` Sjoerd Simons
  2015-04-07 20:40   ` Simon Glass
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 6/8] config_distro_bootcmd.h: Add shared block definition for the host interface Sjoerd Simons
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-06 21:02 UTC (permalink / raw)
  To: u-boot

A common pattern to check if a certain device exists (e.g. in
config_distro_bootcmd) is to use: <interface> dev [device]

Implement host dev [device] so this pattern can be used for sandbox host
devices.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---

Changes in v2: None

 common/cmd_host.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/common/cmd_host.c b/common/cmd_host.c
index d8a0bea..b47ed1c 100644
--- a/common/cmd_host.c
+++ b/common/cmd_host.c
@@ -10,6 +10,8 @@
 #include <sandboxblockdev.h>
 #include <asm/errno.h>
 
+static int host_curr_device = -1;
+
 static int do_host_load(cmd_tbl_t *cmdtp, int flag, int argc,
 			   char * const argv[])
 {
@@ -85,12 +87,53 @@ static int do_host_info(cmd_tbl_t *cmdtp, int flag, int argc,
 	return 0;
 }
 
+static int do_host_dev(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char * const argv[])
+{
+	int dev;
+	char *ep;
+	block_dev_desc_t *blk_dev;
+	int ret;
+
+	if (argc < 1 || argc > 3)
+		return CMD_RET_USAGE;
+
+	if (argc == 1) {
+		if (host_curr_device < 0) {
+			printf("No current host device\n");
+			return 1;
+		}
+		printf("Current host device %d\n", host_curr_device);
+		return 0;
+	}
+
+	dev = simple_strtoul(argv[1], &ep, 16);
+	if (*ep) {
+		printf("** Bad device specification %s **\n", argv[2]);
+		return CMD_RET_USAGE;
+	}
+
+	ret = host_get_dev_err(dev, &blk_dev);
+	if (ret) {
+		if (ret == -ENOENT)
+			puts("Not bound to a backing file\n");
+		else if (ret == -ENODEV)
+			puts("Invalid host device number\n");
+
+		return 1;
+	}
+
+	host_curr_device = dev;
+	return 0;
+}
+
 static cmd_tbl_t cmd_host_sub[] = {
 	U_BOOT_CMD_MKENT(load, 7, 0, do_host_load, "", ""),
 	U_BOOT_CMD_MKENT(ls, 3, 0, do_host_ls, "", ""),
 	U_BOOT_CMD_MKENT(save, 6, 0, do_host_save, "", ""),
 	U_BOOT_CMD_MKENT(bind, 3, 0, do_host_bind, "", ""),
 	U_BOOT_CMD_MKENT(info, 3, 0, do_host_info, "", ""),
+	U_BOOT_CMD_MKENT(dev, 0, 1, do_host_dev, "", ""),
 };
 
 static int do_host(cmd_tbl_t *cmdtp, int flag, int argc,
@@ -135,6 +178,7 @@ U_BOOT_CMD(
 		"save a file to host\n"
 	"host bind <dev> [<filename>] - bind \"host\" device to file\n"
 	"host info [<dev>]            - show device binding & info\n"
+	"host dev [<dev>] - Set or retrieve the current host device\n"
 	"host commands use the \"hostfs\" device. The \"host\" device is used\n"
 	"with standard IO commands such as fatls or ext2load"
 );
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 6/8] config_distro_bootcmd.h: Add shared block definition for the host interface
  2015-04-06 21:02 [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd Sjoerd Simons
                   ` (4 preceding siblings ...)
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 5/8] sandbox: Implement host dev [device] Sjoerd Simons
@ 2015-04-06 21:02 ` Sjoerd Simons
  2015-04-07 20:40   ` Simon Glass
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 7/8] pxe: Ensure all memory access is to mapped memory Sjoerd Simons
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 8/8] sandbox: add config_distro_defaults and config_distro_bootcmd Sjoerd Simons
  7 siblings, 1 reply; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-06 21:02 UTC (permalink / raw)
  To: u-boot

Define the common shared block environment for the host interface in
preperation for the sandbox build to use config_distro_bootcmd.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---

Changes in v2: None

 include/config_distro_bootcmd.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index d71e58d..3a360ca4 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -48,6 +48,18 @@
 #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
 	#devtypel #instance " "
 
+#ifdef CONFIG_SANDBOX
+#define BOOTENV_SHARED_HOST	BOOTENV_SHARED_BLKDEV(host)
+#define BOOTENV_DEV_HOST	BOOTENV_DEV_BLKDEV
+#define BOOTENV_DEV_NAME_HOST	BOOTENV_DEV_NAME_BLKDEV
+#else
+#define BOOTENV_SHARED_HOST
+#define BOOTENV_DEV_HOST \
+	BOOT_TARGET_DEVICES_references_HOST_without_CONFIG_SANDBOX
+#define BOOTENV_DEV_NAME_HOST \
+	BOOT_TARGET_DEVICES_references_HOST_without_CONFIG_SANDBOX
+#endif
+
 #ifdef CONFIG_CMD_MMC
 #define BOOTENV_SHARED_MMC	BOOTENV_SHARED_BLKDEV(mmc)
 #define BOOTENV_DEV_MMC		BOOTENV_DEV_BLKDEV
@@ -167,6 +179,7 @@
 #define BOOTENV_DEV(devtypeu, devtypel, instance) \
 	BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance)
 #define BOOTENV \
+	BOOTENV_SHARED_HOST \
 	BOOTENV_SHARED_MMC \
 	BOOTENV_SHARED_USB \
 	BOOTENV_SHARED_SATA \
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 7/8] pxe: Ensure all memory access is to mapped memory
  2015-04-06 21:02 [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd Sjoerd Simons
                   ` (5 preceding siblings ...)
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 6/8] config_distro_bootcmd.h: Add shared block definition for the host interface Sjoerd Simons
@ 2015-04-06 21:02 ` Sjoerd Simons
  2015-04-07 20:41   ` Simon Glass
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 8/8] sandbox: add config_distro_defaults and config_distro_bootcmd Sjoerd Simons
  7 siblings, 1 reply; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-06 21:02 UTC (permalink / raw)
  To: u-boot

Properly map memory through map_sysmem so that pxe can be used from the
sandbox.

Tested in sandbox as well as on jetson-tk1, odroid-xu3, snow as peach-pi
boards

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

---

Changes in v2:
- Prevent uncessary casts
- Always unmap mapped sysmem
- Consistently use base variable to refer to unmapped memory
- Various coding style fixes

 common/cmd_pxe.c | 86 ++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 56 insertions(+), 30 deletions(-)

diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 7e32c95..292f2c1 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <linux/list.h>
 #include <fs.h>
+#include <asm/io.h>
 
 #include "menu.h"
 #include "cli.h"
@@ -188,11 +189,12 @@ static int do_get_any(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr)
  *
  * Returns 1 for success, or < 0 on error.
  */
-static int get_relfile(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr)
+static int get_relfile(cmd_tbl_t *cmdtp, const char *file_path,
+	unsigned long file_addr)
 {
 	size_t path_len;
 	char relfile[MAX_TFTP_PATH_LEN+1];
-	char addr_buf[10];
+	char addr_buf[18];
 	int err;
 
 	err = get_bootfile_path(file_path, relfile, sizeof(relfile));
@@ -215,7 +217,7 @@ static int get_relfile(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr)
 
 	printf("Retrieving file: %s\n", relfile);
 
-	sprintf(addr_buf, "%p", file_addr);
+	sprintf(addr_buf, "%lx", file_addr);
 
 	return do_getfile(cmdtp, relfile, addr_buf);
 }
@@ -227,11 +229,13 @@ static int get_relfile(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr)
  *
  * Returns 1 on success, or < 0 for error.
  */
-static int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr)
+static int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path,
+	unsigned long file_addr)
 {
 	unsigned long config_file_size;
 	char *tftp_filesize;
 	int err;
+	char *buf;
 
 	err = get_relfile(cmdtp, file_path, file_addr);
 
@@ -250,7 +254,9 @@ static int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr
 	if (strict_strtoul(tftp_filesize, 16, &config_file_size) < 0)
 		return -EINVAL;
 
-	*(char *)(file_addr + config_file_size) = '\0';
+	buf = map_sysmem(file_addr + config_file_size, 1);
+	*buf = '\0';
+	unmap_sysmem(buf);
 
 	return 1;
 }
@@ -266,7 +272,8 @@ static int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr
  *
  * Returns 1 on success or < 0 on error.
  */
-static int get_pxelinux_path(cmd_tbl_t *cmdtp, const char *file, void *pxefile_addr_r)
+static int get_pxelinux_path(cmd_tbl_t *cmdtp, const char *file,
+	unsigned long pxefile_addr_r)
 {
 	size_t base_len = strlen(PXELINUX_DIR);
 	char path[MAX_TFTP_PATH_LEN+1];
@@ -287,7 +294,7 @@ static int get_pxelinux_path(cmd_tbl_t *cmdtp, const char *file, void *pxefile_a
  *
  * Returns 1 on success or < 0 on error.
  */
-static int pxe_uuid_path(cmd_tbl_t *cmdtp, void *pxefile_addr_r)
+static int pxe_uuid_path(cmd_tbl_t *cmdtp, unsigned long pxefile_addr_r)
 {
 	char *uuid_str;
 
@@ -305,7 +312,7 @@ static int pxe_uuid_path(cmd_tbl_t *cmdtp, void *pxefile_addr_r)
  *
  * Returns 1 on success or < 0 on error.
  */
-static int pxe_mac_path(cmd_tbl_t *cmdtp, void *pxefile_addr_r)
+static int pxe_mac_path(cmd_tbl_t *cmdtp, unsigned long pxefile_addr_r)
 {
 	char mac_str[21];
 	int err;
@@ -325,7 +332,7 @@ static int pxe_mac_path(cmd_tbl_t *cmdtp, void *pxefile_addr_r)
  *
  * Returns 1 on success or < 0 on error.
  */
-static int pxe_ipaddr_paths(cmd_tbl_t *cmdtp, void *pxefile_addr_r)
+static int pxe_ipaddr_paths(cmd_tbl_t *cmdtp, unsigned long pxefile_addr_r)
 {
 	char ip_addr[9];
 	int mask_pos, err;
@@ -384,9 +391,9 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	 * Keep trying paths until we successfully get a file we're looking
 	 * for.
 	 */
-	if (pxe_uuid_path(cmdtp, (void *)pxefile_addr_r) > 0 ||
-	    pxe_mac_path(cmdtp, (void *)pxefile_addr_r) > 0 ||
-	    pxe_ipaddr_paths(cmdtp, (void *)pxefile_addr_r) > 0) {
+	if (pxe_uuid_path(cmdtp, pxefile_addr_r) > 0 ||
+	    pxe_mac_path(cmdtp, pxefile_addr_r) > 0 ||
+	    pxe_ipaddr_paths(cmdtp, pxefile_addr_r) > 0) {
 		printf("Config file found\n");
 
 		return 0;
@@ -394,7 +401,7 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	while (pxe_default_paths[i]) {
 		if (get_pxelinux_path(cmdtp, pxe_default_paths[i],
-				      (void *)pxefile_addr_r) > 0) {
+				      pxefile_addr_r) > 0) {
 			printf("Config file found\n");
 			return 0;
 		}
@@ -427,7 +434,7 @@ static int get_relfile_envaddr(cmd_tbl_t *cmdtp, const char *file_path, const ch
 	if (strict_strtoul(envaddr, 16, &file_addr) < 0)
 		return -EINVAL;
 
-	return get_relfile(cmdtp, file_path, (void *)file_addr);
+	return get_relfile(cmdtp, file_path, file_addr);
 }
 
 /*
@@ -790,6 +797,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 	else
 		do_bootz(cmdtp, 0, bootm_argc, bootm_argv);
 #endif
+	unmap_sysmem(buf);
 	return 1;
 }
 
@@ -1054,7 +1062,8 @@ static int parse_integer(char **c, int *dst)
 	return 1;
 }
 
-static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, struct pxe_menu *cfg, int nest_level);
+static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, unsigned long base,
+	struct pxe_menu *cfg, int nest_level);
 
 /*
  * Parse an include statement, and retrieve and parse the file it mentions.
@@ -1064,12 +1073,14 @@ static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, struct pxe_menu *cfg, in
  * include, nest_level has already been incremented and doesn't need to be
  * incremented here.
  */
-static int handle_include(cmd_tbl_t *cmdtp, char **c, char *base,
+static int handle_include(cmd_tbl_t *cmdtp, char **c, unsigned long base,
 				struct pxe_menu *cfg, int nest_level)
 {
 	char *include_path;
 	char *s = *c;
 	int err;
+	char *buf;
+	int ret;
 
 	err = parse_sliteral(c, &include_path);
 
@@ -1086,20 +1097,25 @@ static int handle_include(cmd_tbl_t *cmdtp, char **c, char *base,
 		return err;
 	}
 
-	return parse_pxefile_top(cmdtp, base, cfg, nest_level);
+	buf = map_sysmem(base, 0);
+	ret = parse_pxefile_top(cmdtp, buf, base, cfg, nest_level);
+	unmap_sysmem(buf);
+
+	return ret;
 }
 
 /*
  * Parse lines that begin with 'menu'.
  *
- * b and nest are provided to handle the 'menu include' case.
+ * base and nest are provided to handle the 'menu include' case.
  *
- * b should be the address where the file currently being parsed is stored.
+ * base should point to a location where it's safe to store the included file.
  *
  * nest_level should be 1 when parsing the top level pxe file, 2 when parsing
  * a file it includes, 3 when parsing a file included by that file, and so on.
  */
-static int parse_menu(cmd_tbl_t *cmdtp, char **c, struct pxe_menu *cfg, char *b, int nest_level)
+static int parse_menu(cmd_tbl_t *cmdtp, char **c, struct pxe_menu *cfg,
+				unsigned long base, int nest_level)
 {
 	struct token t;
 	char *s = *c;
@@ -1114,7 +1130,7 @@ static int parse_menu(cmd_tbl_t *cmdtp, char **c, struct pxe_menu *cfg, char *b,
 		break;
 
 	case T_INCLUDE:
-		err = handle_include(cmdtp, c, b + strlen(b) + 1, cfg,
+		err = handle_include(cmdtp, c, base, cfg,
 						nest_level + 1);
 		break;
 
@@ -1281,7 +1297,8 @@ static int parse_label(char **c, struct pxe_menu *cfg)
  *
  * Returns 1 on success, < 0 on error.
  */
-static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, struct pxe_menu *cfg, int nest_level)
+static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, unsigned long base,
+				struct pxe_menu *cfg, int nest_level)
 {
 	struct token t;
 	char *s, *b, *label_name;
@@ -1303,7 +1320,9 @@ static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, struct pxe_menu *cfg, in
 		switch (t.type) {
 		case T_MENU:
 			cfg->prompt = 1;
-			err = parse_menu(cmdtp, &p, cfg, b, nest_level);
+			err = parse_menu(cmdtp, &p, cfg,
+				base + ALIGN(strlen(b) + 1, 4),
+				nest_level);
 			break;
 
 		case T_TIMEOUT:
@@ -1328,8 +1347,9 @@ static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, struct pxe_menu *cfg, in
 			break;
 
 		case T_INCLUDE:
-			err = handle_include(cmdtp, &p, b + ALIGN(strlen(b), 4), cfg,
-							nest_level + 1);
+			err = handle_include(cmdtp, &p,
+				base + ALIGN(strlen(b), 4), cfg,
+				nest_level + 1);
 			break;
 
 		case T_PROMPT:
@@ -1385,9 +1405,11 @@ static void destroy_pxe_menu(struct pxe_menu *cfg)
  * files it includes). The resulting pxe_menu struct can be free()'d by using
  * the destroy_pxe_menu() function.
  */
-static struct pxe_menu *parse_pxefile(cmd_tbl_t *cmdtp, char *menucfg)
+static struct pxe_menu *parse_pxefile(cmd_tbl_t *cmdtp, unsigned long menucfg)
 {
 	struct pxe_menu *cfg;
+	char *buf;
+	int r;
 
 	cfg = malloc(sizeof(struct pxe_menu));
 
@@ -1398,7 +1420,11 @@ static struct pxe_menu *parse_pxefile(cmd_tbl_t *cmdtp, char *menucfg)
 
 	INIT_LIST_HEAD(&cfg->labels);
 
-	if (parse_pxefile_top(cmdtp, menucfg, cfg, 1) < 0) {
+	buf = map_sysmem(menucfg, 0);
+	r = parse_pxefile_top(cmdtp, buf, menucfg, cfg, 1);
+	unmap_sysmem(buf);
+
+	if (r < 0) {
 		destroy_pxe_menu(cfg);
 		return NULL;
 	}
@@ -1556,7 +1582,7 @@ do_pxe_boot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 1;
 	}
 
-	cfg = parse_pxefile(cmdtp, (char *)(pxefile_addr_r));
+	cfg = parse_pxefile(cmdtp, pxefile_addr_r);
 
 	if (cfg == NULL) {
 		printf("Error parsing config file\n");
@@ -1663,12 +1689,12 @@ static int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 1;
 	}
 
-	if (get_pxe_file(cmdtp, filename, (void *)pxefile_addr_r) < 0) {
+	if (get_pxe_file(cmdtp, filename, pxefile_addr_r) < 0) {
 		printf("Error reading config file\n");
 		return 1;
 	}
 
-	cfg = parse_pxefile(cmdtp, (char *)(pxefile_addr_r));
+	cfg = parse_pxefile(cmdtp, pxefile_addr_r);
 
 	if (cfg == NULL) {
 		printf("Error parsing config file\n");
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 8/8] sandbox: add config_distro_defaults and config_distro_bootcmd
  2015-04-06 21:02 [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd Sjoerd Simons
                   ` (6 preceding siblings ...)
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 7/8] pxe: Ensure all memory access is to mapped memory Sjoerd Simons
@ 2015-04-06 21:02 ` Sjoerd Simons
  2015-04-07 20:41   ` Simon Glass
  7 siblings, 1 reply; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-06 21:02 UTC (permalink / raw)
  To: u-boot

Make the sandbox setup more generic/examplary by including
config_distro_defaults.h and config_distro_bootcmd.h.

Among other things this makes it easy to test whether images will boot
though with the standard distro bootcmds by running e.g:
  u-boot -c 'host bind 0 myimage.img ; boot'

By default there are 2 target host devices to emulate device with
multiple storage devices (e.g. internal ("host 0") and external
("host 1") and verify that the prioritization and fallbacks do work
correctly.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed by: Simon Glass <sjg@chromium.org>

---

Changes in v2: None

 include/configs/sandbox.h | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index febbfb6..02c83cd 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -75,7 +75,6 @@
 #define CONFIG_CMDLINE_EDITING
 #define CONFIG_COMMAND_HISTORY
 #define CONFIG_AUTO_COMPLETE
-#define CONFIG_BOOTDELAY	3
 
 #define CONFIG_ENV_SIZE		8192
 #define CONFIG_ENV_IS_NOWHERE
@@ -125,10 +124,21 @@
 
 /* include default commands */
 #include <config_cmd_default.h>
+#include <config_distro_defaults.h>
+
+#define BOOT_TARGET_DEVICES(func) \
+	func(HOST, host, 1) \
+	func(HOST, host, 0)
+
+#include <config_distro_bootcmd.h>
 
 /* We don't have networking support yet */
 #undef CONFIG_CMD_NET
 #undef CONFIG_CMD_NFS
+#undef CONFIG_CMD_PING
+
+/* Can't boot elf images */
+#undef CONFIG_CMD_ELF
 
 #define CONFIG_CMD_HASH
 #define CONFIG_HASH_VERIFY
@@ -165,16 +175,29 @@
 
 #define CONFIG_KEYBOARD
 
-#define CONFIG_EXTRA_ENV_SETTINGS	"stdin=serial,cros-ec-keyb\0" \
+#define EXTRA_ENV_SETTINGS		"stdin=serial,cros-ec-keyb\0" \
 					"stdout=serial,lcd\0" \
 					"stderr=serial,lcd\0"
 #else
 
-#define CONFIG_EXTRA_ENV_SETTINGS	"stdin=serial\0" \
+#define EXTRA_ENV_SETTINGS		"stdin=serial\0" \
 					"stdout=serial,lcd\0" \
 					"stderr=serial,lcd\0"
 #endif
 
+#define MEM_LAYOUT_ENV_SETTINGS \
+	"bootm_size=0x10000000\0" \
+	"kernel_addr_r=0x1000000\0" \
+	"fdt_addr_r=0xc00000\0" \
+	"ramdisk_addr_r=0x2000000\0" \
+	"scriptaddr=0x1000\0" \
+	"pxefile_addr_r=0x2000\0"
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	BOOTENV \
+	MEM_LAYOUT_ENV_SETTINGS \
+	EXTRA_ENV_SETTINGS
+
 #define CONFIG_GZIP_COMPRESSED
 #define CONFIG_BZIP2
 #define CONFIG_LZO
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz Sjoerd Simons
@ 2015-04-06 21:40   ` Stephen Warren
  2015-04-07  7:56     ` Sjoerd Simons
  0 siblings, 1 reply; 21+ messages in thread
From: Stephen Warren @ 2015-04-06 21:40 UTC (permalink / raw)
  To: u-boot

On 04/06/2015 03:02 PM, Sjoerd Simons wrote:
> Add dummy bootz_setup implementation allowing the u-boot sandbox to
> run bootz. This recognizes both ARM and x86 zImages to validate a
> valid zImage was loaded.

> diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c

> +int bootz_setup(ulong image, ulong *start, ulong *end)

> +	*start = 0xdead;
> +	*end = 0xbeef;
> +	return 0;

Isn't that going to cause the rest of bootz to access or jump to some 
bogus address and crash?

Aside from that, this series looks plausible, so,
Acked-by: Stephen Warren <swarren@nvidia.com>

(I read through patch 6 most thoroughly, briefly skimmed patch 7, and 
read the others fairly quickly, so take that as an ack primarily on 
patch 6 although I didn't see anything obviously wrong elsewhere).

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz
  2015-04-06 21:40   ` Stephen Warren
@ 2015-04-07  7:56     ` Sjoerd Simons
  2015-04-07 20:40       ` Simon Glass
  0 siblings, 1 reply; 21+ messages in thread
From: Sjoerd Simons @ 2015-04-07  7:56 UTC (permalink / raw)
  To: u-boot

On Mon, 2015-04-06 at 15:40 -0600, Stephen Warren wrote:
> On 04/06/2015 03:02 PM, Sjoerd Simons wrote:
> > Add dummy bootz_setup implementation allowing the u-boot sandbox to
> > run bootz. This recognizes both ARM and x86 zImages to validate a
> > valid zImage was loaded.
> 
> > diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
> 
> > +int bootz_setup(ulong image, ulong *start, ulong *end)
> 
> > +	*start = 0xdead;
> > +	*end = 0xbeef;
> > +	return 0;
> 
> Isn't that going to cause the rest of bootz to access or jump to some 
> bogus address and crash?

A very good question. I hadn't actually double-checked what these values
are used for as things just worked and i got distracted by fixing other
bits & pieces. 

Looking through the code, these values are only used to add an LMB
region directly after the kernel entry load address. As the sandbox
architecture doesn't define either arch_lmb_reserve nor
board_lmb_reserve these bogus values don't cause any issues (as they
don't seem to make the generic lmb code blow-up thatis), but it's
definitely not pretty.

I'll fix up that patch a bit to make those values more meaningful later
this.

> Aside from that, this series looks plausible, so,
> Acked-by: Stephen Warren <swarren@nvidia.com>
> 
> (I read through patch 6 most thoroughly, briefly skimmed patch 7, and 
> read the others fairly quickly, so take that as an ack primarily on 
> patch 6 although I didn't see anything obviously wrong elsewhere).

Thanks for the review!

-- 
Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Collabora Ltd.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 1/8] sandbox: only do sandboxfs for hostfs interface
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 1/8] sandbox: only do sandboxfs for hostfs interface Sjoerd Simons
@ 2015-04-07 20:40   ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-04-07 20:40 UTC (permalink / raw)
  To: u-boot

On 6 April 2015 at 15:02, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
> Only do sandbox filesystem access when using the hostfs device
> interface, rather then falling back to it in all cases. This prevents
> confusion situations due to the fallback being taken rather then an
> unsupported error being raised.
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> ---
>
> Changes in v2:
> - Minor comment coding style improvement

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 2/8] sandbox: Split bootm code out into lib/bootm
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 2/8] sandbox: Split bootm code out into lib/bootm Sjoerd Simons
@ 2015-04-07 20:40   ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-04-07 20:40 UTC (permalink / raw)
  To: u-boot

On 6 April 2015 at 15:02, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
> Follow the convention of other architectures and move the platform
> specific linux bootm code into sandbox/lib/bootm.c.
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> ---
>
> Changes in v2: None
>
>  arch/sandbox/cpu/cpu.c    | 12 ------------
>  arch/sandbox/lib/Makefile |  1 +
>  arch/sandbox/lib/bootm.c  | 21 +++++++++++++++++++++
>  3 files changed, 22 insertions(+), 12 deletions(-)
>  create mode 100644 arch/sandbox/lib/bootm.c

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz
  2015-04-07  7:56     ` Sjoerd Simons
@ 2015-04-07 20:40       ` Simon Glass
  2015-04-07 21:00         ` Stephen Warren
  0 siblings, 1 reply; 21+ messages in thread
From: Simon Glass @ 2015-04-07 20:40 UTC (permalink / raw)
  To: u-boot

Hi Sjoerd,

On 7 April 2015 at 01:56, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
> On Mon, 2015-04-06 at 15:40 -0600, Stephen Warren wrote:
>> On 04/06/2015 03:02 PM, Sjoerd Simons wrote:
>> > Add dummy bootz_setup implementation allowing the u-boot sandbox to
>> > run bootz. This recognizes both ARM and x86 zImages to validate a
>> > valid zImage was loaded.
>>
>> > diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
>>
>> > +int bootz_setup(ulong image, ulong *start, ulong *end)
>>
>> > +   *start = 0xdead;
>> > +   *end = 0xbeef;
>> > +   return 0;
>>
>> Isn't that going to cause the rest of bootz to access or jump to some
>> bogus address and crash?
>
> A very good question. I hadn't actually double-checked what these values
> are used for as things just worked and i got distracted by fixing other
> bits & pieces.
>
> Looking through the code, these values are only used to add an LMB
> region directly after the kernel entry load address. As the sandbox
> architecture doesn't define either arch_lmb_reserve nor
> board_lmb_reserve these bogus values don't cause any issues (as they
> don't seem to make the generic lmb code blow-up thatis), but it's
> definitely not pretty.

In the future we may want to emulate this with sandbox. Do you think
instead of this we should read out the correct values from the image
file? It seems odd to use fake values.

In fact I wonder if this should use a common function with ARM, or
perhaps part of it should be common?

>
> I'll fix up that patch a bit to make those values more meaningful later
> this.
>
>> Aside from that, this series looks plausible, so,
>> Acked-by: Stephen Warren <swarren@nvidia.com>
>>
>> (I read through patch 6 most thoroughly, briefly skimmed patch 7, and
>> read the others fairly quickly, so take that as an ack primarily on
>> patch 6 although I didn't see anything obviously wrong elsewhere).
>
> Thanks for the review!
>
> --
> Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> Collabora Ltd.

Regards,
Simon

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 4/8] sandbox: Renamed sb command to host
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 4/8] sandbox: Renamed sb command to host Sjoerd Simons
@ 2015-04-07 20:40   ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-04-07 20:40 UTC (permalink / raw)
  To: u-boot

Hi Sjoerd,

On 6 April 2015 at 15:02, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
> As suggested by Simon Glass, rename the sb command to host but keep the
> old sb command as an alias
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> ---
>
> Changes in v2: None
>
>  common/Makefile                      |  2 +-
>  common/{cmd_sandbox.c => cmd_host.c} | 49 +++++++++++++++++++++++-------------
>  2 files changed, 33 insertions(+), 18 deletions(-)
>  rename common/{cmd_sandbox.c => cmd_host.c} (62%)
>
> diff --git a/common/Makefile b/common/Makefile
> index 7216a13..ccb5b99 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -151,7 +151,7 @@ obj-$(CONFIG_CMD_PXE) += cmd_pxe.o
>  obj-$(CONFIG_CMD_READ) += cmd_read.o
>  obj-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o
>  obj-$(CONFIG_CMD_REISER) += cmd_reiser.o
> -obj-$(CONFIG_SANDBOX) += cmd_sandbox.o
> +obj-$(CONFIG_SANDBOX) += cmd_host.o
>  obj-$(CONFIG_CMD_SATA) += cmd_sata.o
>  obj-$(CONFIG_CMD_SF) += cmd_sf.o
>  obj-$(CONFIG_CMD_SCSI) += cmd_scsi.o
> diff --git a/common/cmd_sandbox.c b/common/cmd_host.c
> similarity index 62%
> rename from common/cmd_sandbox.c
> rename to common/cmd_host.c
> index 4286969..d8a0bea 100644
> --- a/common/cmd_sandbox.c
> +++ b/common/cmd_host.c
> @@ -10,25 +10,25 @@
>  #include <sandboxblockdev.h>
>  #include <asm/errno.h>
>
> -static int do_sandbox_load(cmd_tbl_t *cmdtp, int flag, int argc,
> +static int do_host_load(cmd_tbl_t *cmdtp, int flag, int argc,
>                            char * const argv[])
>  {
>         return do_load(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
>  }
>
> -static int do_sandbox_ls(cmd_tbl_t *cmdtp, int flag, int argc,
> +static int do_host_ls(cmd_tbl_t *cmdtp, int flag, int argc,
>                            char * const argv[])
>  {
>         return do_ls(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
>  }
>
> -static int do_sandbox_save(cmd_tbl_t *cmdtp, int flag, int argc,
> +static int do_host_save(cmd_tbl_t *cmdtp, int flag, int argc,
>                            char * const argv[])
>  {
>         return do_save(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
>  }
>
> -static int do_sandbox_bind(cmd_tbl_t *cmdtp, int flag, int argc,
> +static int do_host_bind(cmd_tbl_t *cmdtp, int flag, int argc,
>                            char * const argv[])
>  {
>         if (argc < 2 || argc > 3)
> @@ -44,7 +44,7 @@ static int do_sandbox_bind(cmd_tbl_t *cmdtp, int flag, int argc,
>         return host_dev_bind(dev, file);
>  }
>
> -static int do_sandbox_info(cmd_tbl_t *cmdtp, int flag, int argc,
> +static int do_host_info(cmd_tbl_t *cmdtp, int flag, int argc,
>                            char * const argv[])
>  {
>         if (argc < 1 || argc > 2)
> @@ -85,25 +85,25 @@ static int do_sandbox_info(cmd_tbl_t *cmdtp, int flag, int argc,
>         return 0;
>  }
>
> -static cmd_tbl_t cmd_sandbox_sub[] = {
> -       U_BOOT_CMD_MKENT(load, 7, 0, do_sandbox_load, "", ""),
> -       U_BOOT_CMD_MKENT(ls, 3, 0, do_sandbox_ls, "", ""),
> -       U_BOOT_CMD_MKENT(save, 6, 0, do_sandbox_save, "", ""),
> -       U_BOOT_CMD_MKENT(bind, 3, 0, do_sandbox_bind, "", ""),
> -       U_BOOT_CMD_MKENT(info, 3, 0, do_sandbox_info, "", ""),
> +static cmd_tbl_t cmd_host_sub[] = {
> +       U_BOOT_CMD_MKENT(load, 7, 0, do_host_load, "", ""),
> +       U_BOOT_CMD_MKENT(ls, 3, 0, do_host_ls, "", ""),
> +       U_BOOT_CMD_MKENT(save, 6, 0, do_host_save, "", ""),
> +       U_BOOT_CMD_MKENT(bind, 3, 0, do_host_bind, "", ""),
> +       U_BOOT_CMD_MKENT(info, 3, 0, do_host_info, "", ""),
>  };
>
> -static int do_sandbox(cmd_tbl_t *cmdtp, int flag, int argc,
> +static int do_host(cmd_tbl_t *cmdtp, int flag, int argc,
>                       char * const argv[])
>  {
>         cmd_tbl_t *c;
>
> -       /* Skip past 'sandbox' */
> +       /* Skip past 'host' */
>         argc--;
>         argv++;
>
> -       c = find_cmd_tbl(argv[0], cmd_sandbox_sub,
> -                        ARRAY_SIZE(cmd_sandbox_sub));
> +       c = find_cmd_tbl(argv[0], cmd_host_sub,
> +                        ARRAY_SIZE(cmd_host_sub));
>
>         if (c)
>                 return c->cmd(cmdtp, flag, argc, argv);
> @@ -112,8 +112,8 @@ static int do_sandbox(cmd_tbl_t *cmdtp, int flag, int argc,
>  }
>
>  U_BOOT_CMD(
> -       sb,     8,      1,      do_sandbox,
> -       "Miscellaneous sandbox commands",
> +       sb,     8,      1,      do_host,
> +       "Deprecated use host command instead - Miscellaneous sandbox commands",

"Deprecated: use 'host' command instead."

I think you can drop this help below, no need to repeat it:

>         "load hostfs - <addr> <filename> [<bytes> <offset>]  - "
>                 "load a file from host\n"
>         "sb ls hostfs - <filename>                    - list files on host\n"
> @@ -124,3 +124,18 @@ U_BOOT_CMD(
>         "sb commands use the \"hostfs\" device. The \"host\" device is used\n"
>         "with standard IO commands such as fatls or ext2load"
>  );
> +

This looks good:

> +U_BOOT_CMD(
> +       host, 8, 1, do_host,
> +       "Miscellaneous host commands",
> +       "load hostfs - <addr> <filename> [<bytes> <offset>]  - "
> +               "load a file from host\n"
> +       "host ls hostfs - <filename>                    - list files on host\n"
> +       "host save hostfs - <addr> <filename> <bytes> [<offset>] - "
> +               "save a file to host\n"
> +       "host bind <dev> [<filename>] - bind \"host\" device to file\n"
> +       "host info [<dev>]            - show device binding & info\n"
> +       "host commands use the \"hostfs\" device. The \"host\" device is used\n"
> +       "with standard IO commands such as fatls or ext2load"
> +);
> +


Regards,
Simon

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 5/8] sandbox: Implement host dev [device]
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 5/8] sandbox: Implement host dev [device] Sjoerd Simons
@ 2015-04-07 20:40   ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-04-07 20:40 UTC (permalink / raw)
  To: u-boot

On 6 April 2015 at 15:02, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
> A common pattern to check if a certain device exists (e.g. in
> config_distro_bootcmd) is to use: <interface> dev [device]
>
> Implement host dev [device] so this pattern can be used for sandbox host
> devices.
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> ---
>
> Changes in v2: None
>
>  common/cmd_host.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 6/8] config_distro_bootcmd.h: Add shared block definition for the host interface
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 6/8] config_distro_bootcmd.h: Add shared block definition for the host interface Sjoerd Simons
@ 2015-04-07 20:40   ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-04-07 20:40 UTC (permalink / raw)
  To: u-boot

On 6 April 2015 at 15:02, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
> Define the common shared block environment for the host interface in
> preperation for the sandbox build to use config_distro_bootcmd.
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> ---
>
> Changes in v2: None
>
>  include/config_distro_bootcmd.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 7/8] pxe: Ensure all memory access is to mapped memory
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 7/8] pxe: Ensure all memory access is to mapped memory Sjoerd Simons
@ 2015-04-07 20:41   ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-04-07 20:41 UTC (permalink / raw)
  To: u-boot

Hi Sjoerd,

On 6 April 2015 at 15:02, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
> Properly map memory through map_sysmem so that pxe can be used from the
> sandbox.
>
> Tested in sandbox as well as on jetson-tk1, odroid-xu3, snow as peach-pi
> boards
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
>
> ---
>
> Changes in v2:
> - Prevent uncessary casts
> - Always unmap mapped sysmem
> - Consistently use base variable to refer to unmapped memory
> - Various coding style fixes
>
>  common/cmd_pxe.c | 86 ++++++++++++++++++++++++++++++++++++--------------------
>  1 file changed, 56 insertions(+), 30 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 8/8] sandbox: add config_distro_defaults and config_distro_bootcmd
  2015-04-06 21:02 ` [U-Boot] [PATCH v2 8/8] sandbox: add config_distro_defaults and config_distro_bootcmd Sjoerd Simons
@ 2015-04-07 20:41   ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-04-07 20:41 UTC (permalink / raw)
  To: u-boot

On 6 April 2015 at 15:02, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
> Make the sandbox setup more generic/examplary by including
> config_distro_defaults.h and config_distro_bootcmd.h.
>
> Among other things this makes it easy to test whether images will boot
> though with the standard distro bootcmds by running e.g:
>   u-boot -c 'host bind 0 myimage.img ; boot'
>
> By default there are 2 target host devices to emulate device with
> multiple storage devices (e.g. internal ("host 0") and external
> ("host 1") and verify that the prioritization and fallbacks do work
> correctly.
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> Reviewed by: Simon Glass <sjg@chromium.org>
>
> ---
>
> Changes in v2: None

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz
  2015-04-07 20:40       ` Simon Glass
@ 2015-04-07 21:00         ` Stephen Warren
  2015-04-07 22:31           ` Simon Glass
  0 siblings, 1 reply; 21+ messages in thread
From: Stephen Warren @ 2015-04-07 21:00 UTC (permalink / raw)
  To: u-boot

On 04/07/2015 02:40 PM, Simon Glass wrote:
> Hi Sjoerd,
>
> On 7 April 2015 at 01:56, Sjoerd Simons <sjoerd.simons@collabora.co.uk> wrote:
>> On Mon, 2015-04-06 at 15:40 -0600, Stephen Warren wrote:
>>> On 04/06/2015 03:02 PM, Sjoerd Simons wrote:
>>>> Add dummy bootz_setup implementation allowing the u-boot sandbox to
>>>> run bootz. This recognizes both ARM and x86 zImages to validate a
>>>> valid zImage was loaded.
>>>
>>>> diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
>>>
>>>> +int bootz_setup(ulong image, ulong *start, ulong *end)
>>>
>>>> +   *start = 0xdead;
>>>> +   *end = 0xbeef;
>>>> +   return 0;
>>>
>>> Isn't that going to cause the rest of bootz to access or jump to some
>>> bogus address and crash?
>>
>> A very good question. I hadn't actually double-checked what these values
>> are used for as things just worked and i got distracted by fixing other
>> bits & pieces.
>>
>> Looking through the code, these values are only used to add an LMB
>> region directly after the kernel entry load address. As the sandbox
>> architecture doesn't define either arch_lmb_reserve nor
>> board_lmb_reserve these bogus values don't cause any issues (as they
>> don't seem to make the generic lmb code blow-up thatis), but it's
>> definitely not pretty.
>
> In the future we may want to emulate this with sandbox. Do you think
> instead of this we should read out the correct values from the image
> file? It seems odd to use fake values.
>
> In fact I wonder if this should use a common function with ARM, or
> perhaps part of it should be common?

I wonder if sandbox could somehow exec the loaded image (presumably it'd 
only support native executables then, not ARM/x86 zImages), or keep a 
handle to the file the data was loaded from and fdexec() if such an API 
exists?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz
  2015-04-07 21:00         ` Stephen Warren
@ 2015-04-07 22:31           ` Simon Glass
  0 siblings, 0 replies; 21+ messages in thread
From: Simon Glass @ 2015-04-07 22:31 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

On 7 April 2015 at 15:00, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 04/07/2015 02:40 PM, Simon Glass wrote:
>>
>> Hi Sjoerd,
>>
>> On 7 April 2015 at 01:56, Sjoerd Simons <sjoerd.simons@collabora.co.uk>
>> wrote:
>>>
>>> On Mon, 2015-04-06 at 15:40 -0600, Stephen Warren wrote:
>>>>
>>>> On 04/06/2015 03:02 PM, Sjoerd Simons wrote:
>>>>>
>>>>> Add dummy bootz_setup implementation allowing the u-boot sandbox to
>>>>> run bootz. This recognizes both ARM and x86 zImages to validate a
>>>>> valid zImage was loaded.
>>>>
>>>>
>>>>> diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
>>>>
>>>>
>>>>> +int bootz_setup(ulong image, ulong *start, ulong *end)
>>>>
>>>>
>>>>> +   *start = 0xdead;
>>>>> +   *end = 0xbeef;
>>>>> +   return 0;
>>>>
>>>>
>>>> Isn't that going to cause the rest of bootz to access or jump to some
>>>> bogus address and crash?
>>>
>>>
>>> A very good question. I hadn't actually double-checked what these values
>>> are used for as things just worked and i got distracted by fixing other
>>> bits & pieces.
>>>
>>> Looking through the code, these values are only used to add an LMB
>>> region directly after the kernel entry load address. As the sandbox
>>> architecture doesn't define either arch_lmb_reserve nor
>>> board_lmb_reserve these bogus values don't cause any issues (as they
>>> don't seem to make the generic lmb code blow-up thatis), but it's
>>> definitely not pretty.
>>
>>
>> In the future we may want to emulate this with sandbox. Do you think
>> instead of this we should read out the correct values from the image
>> file? It seems odd to use fake values.
>>
>> In fact I wonder if this should use a common function with ARM, or
>> perhaps part of it should be common?
>
>
> I wonder if sandbox could somehow exec the loaded image (presumably it'd
> only support native executables then, not ARM/x86 zImages), or keep a handle
> to the file the data was loaded from and fdexec() if such an API exists?

Currently bootm on sandbox does everything except execute the image.
I'm sure we could do that to with a bit of fiddling.

The function os_jump_to_image() probably does what you want.

Regards,
Simon

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2015-04-07 22:31 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 21:02 [U-Boot] [PATCH v2 0/8] Allow sandbox to use config_distro_bootcmd Sjoerd Simons
2015-04-06 21:02 ` [U-Boot] [PATCH v2 1/8] sandbox: only do sandboxfs for hostfs interface Sjoerd Simons
2015-04-07 20:40   ` Simon Glass
2015-04-06 21:02 ` [U-Boot] [PATCH v2 2/8] sandbox: Split bootm code out into lib/bootm Sjoerd Simons
2015-04-07 20:40   ` Simon Glass
2015-04-06 21:02 ` [U-Boot] [PATCH v2 3/8] sandbox: Add support for bootz Sjoerd Simons
2015-04-06 21:40   ` Stephen Warren
2015-04-07  7:56     ` Sjoerd Simons
2015-04-07 20:40       ` Simon Glass
2015-04-07 21:00         ` Stephen Warren
2015-04-07 22:31           ` Simon Glass
2015-04-06 21:02 ` [U-Boot] [PATCH v2 4/8] sandbox: Renamed sb command to host Sjoerd Simons
2015-04-07 20:40   ` Simon Glass
2015-04-06 21:02 ` [U-Boot] [PATCH v2 5/8] sandbox: Implement host dev [device] Sjoerd Simons
2015-04-07 20:40   ` Simon Glass
2015-04-06 21:02 ` [U-Boot] [PATCH v2 6/8] config_distro_bootcmd.h: Add shared block definition for the host interface Sjoerd Simons
2015-04-07 20:40   ` Simon Glass
2015-04-06 21:02 ` [U-Boot] [PATCH v2 7/8] pxe: Ensure all memory access is to mapped memory Sjoerd Simons
2015-04-07 20:41   ` Simon Glass
2015-04-06 21:02 ` [U-Boot] [PATCH v2 8/8] sandbox: add config_distro_defaults and config_distro_bootcmd Sjoerd Simons
2015-04-07 20:41   ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.