Skip to contentSkip to conversation

arm: Add support for semihosting for armv8 fastmodel targets.

PATCH New Darwin Rambo 3 participants 7 messages Mar 12, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: Add support for semihosting for armv8 fastmodel targets.

The reason for this change is to be able to use the ARM Trusted Firmware (ATF) to load the various ATF images, plus u-boot, which can then load the kernel/ramdisk/dtb with calls to an external host from a standard fastmodel armv8 board file using semihosting, and then launch the kernel without a bootwrapper. This gives us a more realistic boot sequence.

Rather than create a new armv8 board similar to armltd/vexpress64, add semihosting calls to the existing one, enabled with CONFIG_SEMIHOSTING. Also add a new board config file vexpress_aemv8a_semi.h. This change is tested and works on the ARM foundation model.

Support for armv7 in fastmodel is less useful due to the wide range of available silicon but this change contains an untested armv7 placeholder if desired.

The level of semihosting support is minimal, restricted to just what it takes to load images to memory. If more semihosting functionality is required, such as file seek, outputting strings, reading characters, etc, then it can be easily added later.

---

 arch/arm/include/asm/semihosting.h     |   21 +++
 arch/arm/lib/Makefile                  |    1 +
 arch/arm/lib/semihosting.c             |  235 ++++++++++++++++++++++++++++++++
 board/armltd/vexpress64/vexpress64.c   |   83 ++++++++++-
 boards.cfg                             |    1 +
 include/configs/vexpress_aemv8a_semi.h |  112 +++++++++++++++
 6 files changed, 448 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/include/asm/semihosting.h
 create mode 100644 arch/arm/lib/semihosting.c
 create mode 100644 include/configs/vexpress_aemv8a_semi.h
arch/arm/include/asm/semihosting.h new file +21 -0
new file mode 100644
index 0000000..74111dc
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2014 Broadcom Corporation
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __SEMIHOSTING_H__
+#define __SEMIHOSTING_H__
+
+/*
+ * ARM semihosting functions for loading images to memory. See the source
+ * code for more information.
+ */
+int smh_load(const char *fname, void *memp, int avail, int verbose);
+int smh_read(int fd, void *memp, int len);
+int smh_open(const char *fname, char *modestr);
+int smh_close(int fd);
+int smh_len_fd(int fd);
+int smh_len(const char *fname);
+
+#endif /* __SEMIHOSTING_H__ */
arch/arm/lib/Makefile +1 -0
index 9fc81cd..0ba929d 100644
@@ -32,6 +32,7 @@ obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 else
 obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
 endif
+obj-$(CONFIG_SEMIHOSTING) += semihosting.o
 
 obj-y	+= sections.o
 ifdef CONFIG_ARM64
arch/arm/lib/semihosting.c new file +235 -0

235 lines not on this page · raw message

board/armltd/vexpress64/vexpress64.c +78 -5

101 lines not on this page · raw message

boards.cfg +1 -0
index a32f46b..db3239f 100644
@@ -44,6 +44,7 @@
 ###########################################################################################################
 
 Active  aarch64     armv8          -           armltd          vexpress64          vexpress_aemv8a                      vexpress_aemv8a:ARM64                                                                                                             David Feng <[email protected]>
+Active  aarch64     armv8          -           armltd          vexpress64          vexpress_aemv8a_semi                 vexpress_aemv8a_semi:ARM64                                                                                                        Darwin Rambo <[email protected]>
 Active  arc         arc700         -           synopsys        <none>              arcangel4                            -                                                                                                                                 Alexey Brodkin <[email protected]>
 Active  arc         arc700         -           synopsys        -                   axs101                               -                                                                                                                                 Alexey Brodkin <[email protected]>
 Active  arc         arc700         -           synopsys        <none>              arcangel4-be                         -                                                                                                                                 Alexey Brodkin <[email protected]>
include/configs/vexpress_aemv8a_semi.h new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 arm: Add support for semihosting for armv8 fastmodel targets.

Quoted 15 lines · Darwin Rambo

The reason for this change is to be able to use the ARM Trusted Firmware (ATF) to load the various ATF images, plus u-boot, which can then load the kernel/ramdisk/dtb with calls to an external host from a standard fastmodel armv8 board file using semihosting, and then launch the kernel without a bootwrapper. This gives us a more realistic boot sequence.

Rather than create a new armv8 board similar to armltd/vexpress64, add semihosting calls to the existing one, enabled with CONFIG_SEMIHOSTING. Also add a new board config file vexpress_aemv8a_semi.h. This change is tested and works on the ARM foundation model.

Support for armv7 in fastmodel is less useful due to the wide range of available silicon but this change contains an untested armv7 placeholder if desired.

Quoted 6 lines

The level of semihosting support is minimal, restricted to just what it takes to load images to memory. If more semihosting functionality is required, such as file seek, outputting strings, reading characters, etc, then it can be easily added later.

At the high-level, I'm fine with this. But as an implementation detail we need to either leverage vexpress_common.h or create a vexpress_arm64_common.h or something. There's a lot in common between these two configs, and some further clean-up we need to do to the first one anyhow.

Next:

Quoted 14 lines
board/armltd/vexpress64/vexpress64.c +14 -0
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+#ifdef CONFIG_SEMIHOSTING
+
+	/*
+	 * We require that the board include file defines these env variables:
+	 * - kernel_addr
+	 * - initrd_addr
+	 * - fdt_addr
+	 *
+	 * For the "fdt chosen" startup macro, this code will then define:
+	 * - initrd_end (based on initrd_base plus actual initrd_size)
+	 *

board/armltd/vexpress64/vexpress64.c void reset_cpu(ulong addr) · line 68

Quoted 10 lines
board/armltd/vexpress64/vexpress64.c +10 -0
+	 * We will then load the kernel, initrd, and fdt into the specified
+	 * locations in memory in a similar way that the ATF fastmodel code
+	 * uses semihosting calls to load other boot stages and u-boot itself.
+	 */
+
+	/* Env variable strings */
+	char *kernel_addr_str = getenv("kernel_addr");
+	char *initrd_addr_str = getenv("initrd_addr");
+	char *fdt_addr_str = getenv("fdt_addr");
+	char initrd_end_str[64];

First, we need to document this stuff in a README file as well. Second, I'd like to see kernel_addr_r / ramdisk_addr_r / fdt_addr_r used to match-up with what Dennis Gilmore has been working on to get a common env working.

[snip]

board/armltd/vexpress64/vexpress64.c void reset_cpu(ulong addr) · line 112

Quoted 8 lines
board/armltd/vexpress64/vexpress64.c +8 -0
+	/* Assumes kernel is lower in memory than fdt */
+	smh_load(CONFIG_KNLNAME, kernel_addr, fdt_addr - kernel_addr, 1);
+
+	/* Load fdt to memory */
+	smh_load(CONFIG_FDTNAME, fdt_addr, 0x20000, 1);
+
+	/* Load initrd to memory */
+	smh_load(CONFIG_RDNAME, initrd_addr, initrd_size, 1);

Is there a reason we can't also get these from the environment? Or a limitation of (how we support) the simulator that we don't have persistent r/w environment right now?

Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140312/88fe0506/attachment.pgp>
#2 lore raw

PATCH 1/1 arm: Add support for semihosting for armv8 fastmodel targets.

Quoted 22 lines · Tom Rini
Quoted 20 lines · Darwin Rambo

The reason for this change is to be able to use the ARM Trusted Firmware (ATF) to load the various ATF images, plus u-boot, which can then load the kernel/ramdisk/dtb with calls to an external host from a standard fastmodel armv8 board file using semihosting, and then launch the kernel without a bootwrapper. This gives us a more realistic boot sequence.

Rather than create a new armv8 board similar to armltd/vexpress64, add semihosting calls to the existing one, enabled with CONFIG_SEMIHOSTING. Also add a new board config file vexpress_aemv8a_semi.h. This change is tested and works on the ARM foundation model.

Support for armv7 in fastmodel is less useful due to the wide range of available silicon but this change contains an untested armv7 placeholder if desired.

The level of semihosting support is minimal, restricted to just what it takes to load images to memory. If more semihosting functionality is required, such as file seek, outputting strings, reading characters, etc, then it can be easily added later.

Quoted 7 lines
Quoted 1 line

At the high-level, I'm fine with this. But as an implementation detail we need to either leverage vexpress_common.h or create a vexpress_arm64_common.h or something. There's a lot in common between these two configs, and some further clean-up we need to do to the first one anyhow.

Let me try to digest this to see what is truly common and get back to you. Thanks.

Quoted 23 lines

Next:

Quoted 21 lines
board/armltd/vexpress64/vexpress64.c +21 -0
+#ifdef CONFIG_BOARD_LATE_INIT
+int board_late_init(void)
+{
+#ifdef CONFIG_SEMIHOSTING
+
+	/*
+	 * We require that the board include file defines these env variables:
+	 * - kernel_addr
+	 * - initrd_addr
+	 * - fdt_addr
+	 *
+	 * For the "fdt chosen" startup macro, this code will then define:
+	 * - initrd_end (based on initrd_base plus actual initrd_size)
+	 *
+	 * We will then load the kernel, initrd, and fdt into the specified
+	 * locations in memory in a similar way that the ATF fastmodel code
+	 * uses semihosting calls to load other boot stages and u-boot itself.
+	 */
+
+	/* Env variable strings */
+	char *kernel_addr_str = getenv("kernel_addr");
Quoted 8 lines

board/armltd/vexpress64/vexpress64.c void reset_cpu(ulong addr) · line 68

Quoted 3 lines
board/armltd/vexpress64/vexpress64.c +3 -0
+	char *initrd_addr_str = getenv("initrd_addr");
+	char *fdt_addr_str = getenv("fdt_addr");
+	char initrd_end_str[64];

First, we need to document this stuff in a README file as well. Second, I'd like to see kernel_addr_r / ramdisk_addr_r / fdt_addr_r used to match-up with what Dennis Gilmore has been working on to get a common env working.

Okay, thanks.

Quoted 14 lines

[snip]

board/armltd/vexpress64/vexpress64.c void reset_cpu(ulong addr) · line 112

Quoted 8 lines
board/armltd/vexpress64/vexpress64.c +8 -0
+	/* Assumes kernel is lower in memory than fdt */
+	smh_load(CONFIG_KNLNAME, kernel_addr, fdt_addr - kernel_addr, 1);
+
+	/* Load fdt to memory */
+	smh_load(CONFIG_FDTNAME, fdt_addr, 0x20000, 1);
+
+	/* Load initrd to memory */
+	smh_load(CONFIG_RDNAME, initrd_addr, initrd_size, 1);

Is there a reason we can't also get these from the environment? Or a limitation of (how we support) the simulator that we don't have persistent r/w environment right now?

These names can also come from the environment, there's r/w capability there, just no physical eMMC. Thanks.

Quoted 3 lines

Thanks!

#3 lore raw

PATCH 1/1 arm: Add support for semihosting for armv8 fastmodel targets.

Quoted 4 lines · Darwin Rambo
Quoted 1 line · Tom Rini

On Wed, Mar 12, 2014 at 09:04:01AM -0700, Darwin Rambo wrote:

[snip]

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
board/armltd/vexpress64/vexpress64.c +4 -0
+	/* Assumes kernel is lower in memory than fdt */
+	smh_load(CONFIG_KNLNAME, kernel_addr, fdt_addr - kernel_addr, 1);
+
+	/* Load fdt to memory */
Quoted 8 lines

board/armltd/vexpress64/vexpress64.c void reset_cpu(ulong addr) · line 112

Quoted 4 lines
board/armltd/vexpress64/vexpress64.c +4 -0
+	smh_load(CONFIG_FDTNAME, fdt_addr, 0x20000, 1);
+
+	/* Load initrd to memory */
+	smh_load(CONFIG_RDNAME, initrd_addr, initrd_size, 1);

Is there a reason we can't also get these from the environment? Or a limitation of (how we support) the simulator that we don't have persistent r/w environment right now?

Quoted 2 lines

These names can also come from the environment, there's r/w capability there, just no physical eMMC. Thanks.

I need to play more with the foundation model then, I didn't think we could talk with the "mmc" or anything on it. As you've got it coded now, you can't change what's loaded here :) But if we can have a file-backed storage used as the "disk" and keep env there, making this load files named in the environment and then fw_getenv/setenv can change the values from Linux too, if we don't boot into a full U-Boot at some point.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140312/7c97ef67/attachment.pgp>
#4 lore raw

PATCH 1/1 arm: Add support for semihosting for armv8 fastmodel targets.

Quoted 21 lines · Tom Rini
Quoted 4 lines · Darwin Rambo
Quoted 1 line · Tom Rini

On Wed, Mar 12, 2014 at 09:04:01AM -0700, Darwin Rambo wrote:

[snip]

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
board/armltd/vexpress64/vexpress64.c +4 -0
+	/* Assumes kernel is lower in memory than fdt */
+	smh_load(CONFIG_KNLNAME, kernel_addr, fdt_addr - kernel_addr, 1);
+
+	/* Load fdt to memory */
Quoted 8 lines

board/armltd/vexpress64/vexpress64.c void reset_cpu(ulong addr) · line 112

Quoted 4 lines
board/armltd/vexpress64/vexpress64.c +4 -0
+	smh_load(CONFIG_FDTNAME, fdt_addr, 0x20000, 1);
+
+	/* Load initrd to memory */
+	smh_load(CONFIG_RDNAME, initrd_addr, initrd_size, 1);

Is there a reason we can't also get these from the environment? Or a limitation of (how we support) the simulator that we don't have persistent r/w environment right now?

Quoted 2 lines

These names can also come from the environment, there's r/w capability there, just no physical eMMC. Thanks.

Quoted 7 lines

I need to play more with the foundation model then, I didn't think we could talk with the "mmc" or anything on it. As you've got it coded now, you can't change what's loaded here :) But if we can have a file-backed storage used as the "disk" and keep env there, making this load files named in the environment and then fw_getenv/setenv can change the values from Linux too, if we don't boot into a full U-Boot at some point.

Sorry Tom, what I really meant to say was that with fastmodel, you can define environment variables at build and run time, but they can't be saved or viewed as persistent for the next bootup. Semihosting is kind of a way to get around this lack of persistence since you can load different image files on different runs. You could even potentially load an environment file to fake out the eMMC if warranted. By r/w capability, I meant just for that one instance of execution of u-boot. But you can potentially access real eMMC on palladium or FPGA for example, and eMMC would then be persistent in that environment from run to run. Thanks.

Quoted 1 line
#5 lore raw

PATCH 1/1 arm: Add support for semihosting for armv8 fastmodel targets.

In reply to Darwin Rambo

Hi Darwin,

Quoted 15 lines · Darwin Rambo

The reason for this change is to be able to use the ARM Trusted Firmware (ATF) to load the various ATF images, plus u-boot, which can then load the kernel/ramdisk/dtb with calls to an external host from a standard fastmodel armv8 board file using semihosting, and then launch the kernel without a bootwrapper. This gives us a more realistic boot sequence.

Rather than create a new armv8 board similar to armltd/vexpress64, add semihosting calls to the existing one, enabled with CONFIG_SEMIHOSTING. Also add a new board config file vexpress_aemv8a_semi.h. This change is tested and works on the ARM foundation model.

Support for armv7 in fastmodel is less useful due to the wide range of available silicon but this change contains an untested armv7 placeholder if desired.

Quoted 7 lines

The level of semihosting support is minimal, restricted to just what it takes to load images to memory. If more semihosting functionality is required, such as file seek, outputting strings, reading characters, etc, then it can be easily added later.

---

If you're only adding semihosting to vexpress_aemv8a, not creating a new board, then why add a new header file? Can you not just reuse orextend the existing header file, and make the new entry in boards.cfg define option CONFIG_SEMIHOSTING instead?

Quoted 6 lines
board/armltd/vexpress64/vexpress64.c +0 -0
index 2ec3bc9..9b64f71 100644

board/armltd/vexpress64/vexpress64.c int dram_init(void) · line 38

Quoted 8 lines
board/armltd/vexpress64/vexpress64.c +0 -5
@@ -31,11 +35,6 @@ int dram_init(void)
 	return 0;
 }
 
-int timer_init(void)
-{
-	return 0;
-}
-

This removal does not seem to be described in the commit summary.

Amicalement,

Signature · 1 line
Albert.
#6 lore raw

PATCH 1/1 arm: Add support for semihosting for armv8 fastmodel targets.

Quoted 25 lines · Albert ARIBAUD

Hi Darwin,

Quoted 20 lines · Darwin Rambo

The reason for this change is to be able to use the ARM Trusted Firmware (ATF) to load the various ATF images, plus u-boot, which can then load the kernel/ramdisk/dtb with calls to an external host from a standard fastmodel armv8 board file using semihosting, and then launch the kernel without a bootwrapper. This gives us a more realistic boot sequence.

Rather than create a new armv8 board similar to armltd/vexpress64, add semihosting calls to the existing one, enabled with CONFIG_SEMIHOSTING. Also add a new board config file vexpress_aemv8a_semi.h. This change is tested and works on the ARM foundation model.

Support for armv7 in fastmodel is less useful due to the wide range of available silicon but this change contains an untested armv7 placeholder if desired.

The level of semihosting support is minimal, restricted to just what it takes to load images to memory. If more semihosting functionality is required, such as file seek, outputting strings, reading characters, etc, then it can be easily added later.

Quoted 7 lines
Quoted 2 lines

---

If you're only adding semihosting to vexpress_aemv8a, not creating a new board, then why add a new header file? Can you not just reuse orextend the existing header file, and make the new entry in boards.cfg define option CONFIG_SEMIHOSTING instead?

Good idea, thanks. This meshes well with Tom's recent suggestions.

Quoted 10 lines
Quoted 10 lines
board/armltd/vexpress64/vexpress64.c +0 -0
index 2ec3bc9..9b64f71 100644
@@ -31,11 +35,6 @@ int dram_init(void)
 	return 0;
 }
 
Quoted 7 lines

board/armltd/vexpress64/vexpress64.c int dram_init(void) · line 38

Quoted 5 lines
board/armltd/vexpress64/vexpress64.c +0 -5
-int timer_init(void)
-{
-	return 0;
-}
-

This removal does not seem to be described in the commit summary.

Will fix. Thanks.

Quoted 3 lines

Amicalement,