arm: Add support for semihosting for armv8 fastmodel targets.
Subsystems (2)
PATCH v2 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.
There are two main ARM virtual Fixed Virtual Platform (FVP) models, Versatile Express (VE) FVP and BASE FVP (See
http://www.arm.com/products/tools/models/fast-models/foundation-model.php)
The initial vexpress64 u-boot board created here runs on the VE virtual platform using the license-free Foundation_v8 simulator. Fortunately, the Foundation_v8 simulator also supports the BASE_FVP model which companies can purchase licenses for and contain much more functionality. So we can, in u-boot, run either model by either using the VE FVP (default), or turning on CONFIG_BASE_FVP for the more full featured model.
Rather than create a new armv8 board similar to armltd/vexpress64, add semihosting calls to the existing one, enabled with CONFIG_SEMIHOSTING and CONFIG_BASE_FVP both set. Also reuse the existing board config file vexpress_aemv8a.h but differentiate the two models by the presence or absence of CONFIG_BASE_FVP. This change is tested and works on both the Foundation and Base fastmodel simulators.
Support for armv7 in fastmodel is less useful due to the wide range of available silicon and the lack of a free armv7 fastmodel, so this change contains an untested armv7 placeholder for the service trap opcode.
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.
---
Changes in v2:
- use kernel_addr_r, fdt_addr_r, initrd_addr_r convention.
- Use env variables for kernel/fdt/initrd file names.
- Add CONFIG_BASE_FVP to differentiate VE and BASE FVP models.
- CONFIG_SEMIHOSTING only refers to bringing in semihosting code now.
- Remove unnecessary CONFIG_SYS_BAUDRATE_TABLE, CONFIG_SYS_PROMPT_HUSH_PS2
- Remove vexpress_aemv8a_semi.h and replace with CONFIG_BASE_FVP
- Update boards.cfg with option SEMIHOSTING and BASE_FVP
- Add doc/README.semihosting
Changes in v1:
- Initial code
- Remove empty timer_init() function.
arch/arm/include/asm/semihosting.h | 21 +++ arch/arm/lib/Makefile | 1 + arch/arm/lib/semihosting.c | 235 ++++++++++++++++++++++++++++++++++ board/armltd/vexpress64/vexpress64.c | 102 ++++++++++++++- boards.cfg | 1 + doc/README.semihosting | 35 +++++ include/configs/vexpress_aemv8a.h | 59 ++++++++- 7 files changed, 442 insertions(+), 12 deletions(-) create mode 100644 arch/arm/include/asm/semihosting.h create mode 100644 arch/arm/lib/semihosting.c create mode 100644 doc/README.semihosting
arch/arm/include/asm/semihosting.h new file +21 -0
@@ -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
@@ -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 +97 -5
120 lines not on this page · raw message
boards.cfg +1 -0
@@ -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:ARM64,SEMIHOSTING,BASE_FVP Darwin Rambo <[email protected]> Active arc arc700 - synopsys - axs101 - Alexey Brodkin <[email protected]> Active arc arc700 - synopsys <none> arcangel4 - Alexey Brodkin <[email protected]> Active arc arc700 - synopsys <none> arcangel4-be - Alexey Brodkin <[email protected]>
doc/README.semihosting new file +35 -0
@@ -0,0 +1,35 @@ +/* + * Copyright 2014 Broadcom Corporation. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +Semihosting is ARM's way of having a real or virtual target communicate +with a host or host debugger for basic operations such as file I/O, +console I/O, etc. Please see +http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471c/Bgbjjgij.html for more information. + +For developing on armv8 virtual fastmodel platforms, semihosting is a +valuable tool since it allows access to image/configuration files before +eMMC or other NV media are available. + +For reference, the current example is enabled by setting CONFIG_SEMIHOSTING +for the "vexpress_aemv8a" board. + +We require that the board include file define these env variables: +- kernel_name e.g. "uImage" +- kernel_addr_r e.g. "0x80000000" +- initrd_name e.g. "ramdisk.img" +- initrd_addr_r e.g. "0x88000000" +- fdt_name e.g. "devtree.dtb" +- fdt_addr_r e.g. "0x83000000" + +Optionally, "fdt_high" and "initrd_high" can be specified as per +their rules for allowing or preventing copying of these images. + +For the "fdt chosen" startup macro, this code will then define: +- initrd_end (based on retrieving initrd_addr_r 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.
include/configs/vexpress_aemv8a.h +52 -7
112 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 1/1 arm: Add support for semihosting for armv8 fastmodel targets.
Quoted 5 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/dtbwith 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.
[snip]
board/armltd/vexpress64/vexpress64.c void reset_cpu(ulong addr) · line 95
Quoted 4 lines
board/armltd/vexpress64/vexpress64.c +4
-0+if (!(kernel_name && initrd_name && fdt_name)) { +printf + ("%s: Define {kernel/initrd/fdt}_name\n" , __func__); +return -1 ;
Funky wrapping there, please correct.
Otherwise I think this is OK. Albert?
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/20140321/38ec9961/attachment.pgp>