[PATCH 1/8] semihosting: Change semihosting file operation functions into global symbols
Heinrich Schuchardt
xypron.debian at gmx.de
Mon May 18 18:34:33 CEST 2020
On 5/11/20 5:05 AM, Akashi Takahiro wrote:
> On Thu, Apr 30, 2020 at 11:06:23PM +0530, Sughosh Ganu wrote:
>> Change the semihosting file operation functions into external symbols
>> so that they can be called from outside the file. These functions
>> would be required to be called for implementing firmware update
>> functionality for the qemu arm64 platform.
>>
>> Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
>> ---
>> arch/arm/lib/semihosting.c | 7 ++++---
>> include/semihosting.h | 13 +++++++++++++
>> 2 files changed, 17 insertions(+), 3 deletions(-)
>> create mode 100644 include/semihosting.h
>>
>> diff --git a/arch/arm/lib/semihosting.c b/arch/arm/lib/semihosting.c
>> index 2658026cf4..3aeda1303a 100644
>> --- a/arch/arm/lib/semihosting.c
>> +++ b/arch/arm/lib/semihosting.c
Semihosting in QEMU is not ARM specific but exists also for the M68K,
Xtensa, MIPS, and NIOS2 architecture. arch/arm/lib/ is the wrong place
for this file. This file should be moved to lib/.
The smhload command should be moved to cmd/smhload.c
>> @@ -13,6 +13,7 @@
>> */
>> #include <common.h>
>> #include <command.h>
>> +#include <semihosting.h>
>
> Do we need this file here?
This patch is about turning the functions defined in semihosting.h into
global functions. In patch 3/8 the functions are called from other parts
of the U-Boot code. We need the include here to ensure that the
definitions match.
>
> -Takahiro Akashi
>
>> #define SYSOPEN 0x01
>> #define SYSCLOSE 0x02
>> @@ -43,7 +44,7 @@ static noinline long smh_trap(unsigned int sysnum, void *addr)
>> * Open a file on the host. Mode is "r" or "rb" currently. Returns a file
>> * descriptor or -1 on error.
>> */
>> -static long smh_open(const char *fname, char *modestr)
>> +long smh_open(const char *fname, char *modestr)
>> {
>> long fd;
>> unsigned long mode;
>> @@ -82,7 +83,7 @@ static long smh_open(const char *fname, char *modestr)
>> /*
>> * Read 'len' bytes of file into 'memp'. Returns 0 on success, else failure
>> */
>> -static long smh_read(long fd, void *memp, size_t len)
>> +long smh_read(long fd, void *memp, size_t len)
>> {
>> long ret;
>> struct smh_read_s {
>> @@ -116,7 +117,7 @@ static long smh_read(long fd, void *memp, size_t len)
>> /*
>> * Close the file using the file descriptor
>> */
>> -static long smh_close(long fd)
>> +long smh_close(long fd)
>> {
>> long ret;
>>
>> diff --git a/include/semihosting.h b/include/semihosting.h
>> new file mode 100644
>> index 0000000000..f1bf419275
>> --- /dev/null
>> +++ b/include/semihosting.h
>> @@ -0,0 +1,13 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * Copyright (c) 2020, Linaro Limited
>> + */
>> +
>> +#if !defined _SEMIHOSTING_H_
>> +#define _SEMIHOSTING_H_
>> +
If these functions become global symbols, we should provide a function
description according to
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
and merge this file into doc/api/index.rst to produce HTML documentation
with 'make htmldoc'.
Cf. https://u-boot.readthedocs.io/en/latest/api/index.html
Best regards
Heinrich
>> +long smh_open(const char *fname, char *modestr);
>> +long smh_read(long fd, void *memp, size_t len);
>> +long smh_close(long fd);
>> +
>> +#endif /* _SEMIHOSTING_H_ */
>> --
>> 2.17.1
>>
More information about the U-Boot
mailing list