arm: Add support for semihosting for armv8 fastmodel targets.
Subsystems (2)
PATCH v4 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 v4:
- refreshed patch and retested
- fix boards.cfg conflict
- fix GICV3 conflict
- minor documentation cleanup - semihosting.c, README.semihosting
- change maintainer of semihosting target
- tested with vexpress_aemv8a_semi target (BASE_FVP) against e75e73dd5f280b91f5bfc0a76a0fd09b6eba1c66 (May 16, 2014)
Changes in v3:
- minor format fixup in board file
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 | 233 ++++++++++++++++++++++++++++++++++ board/armltd/vexpress64/vexpress64.c | 101 ++++++++++++++- boards.cfg | 1 + doc/README.semihosting | 35 +++++ include/configs/vexpress_aemv8a.h | 63 ++++++++- 7 files changed, 443 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 +233 -0
233 lines not on this page · raw message
board/armltd/vexpress64/vexpress64.c +96 -5
119 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 Steve Rae <[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 target vexpress_aemv8a_semi enables +CONFIG_SEMIHOSTING and CONFIG_BASE_FVP 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 +56 -7
120 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v4 1/1 arm: Add support for semihosting for armv8 fastmodel targets.
Hi Darwin,
Quoted 32 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.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-freeFoundation_v8simulator. Fortunately, theFoundation_v8simulator also supports theBASE_FVPmodel 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 onCONFIG_BASE_FVPfor 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_SEMIHOSTINGandCONFIG_BASE_FVPboth set. Also reuse the existing board config filevexpress_aemv8a.hbut differentiate the two models by the presence or absence ofCONFIG_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.
Quoted 6 lines
Signed-off-by Darwin Rambo <[email protected]>Cc trini at ti.comCc fenghua at phytium.com.cnCc bhupesh.sharma at freescale.com---
I am basically ok with this patch, except for the very long commit message. I would prefer it to be shorter and more synthetic and just state in a few paragraphs what is fixed or improved, and that the rest of it be moved after the commit message boundary above, or if it should be kept for future reference, added or put in a README.* file under doc/.
Amicalement,
Signature · 1 line
Albert.