From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>,
qemu-devel@nongnu.org
Cc: brian.cain@oss.qualcomm.com, pierrick.bouvier@oss.qualcomm.com,
marco.liebel@oss.qualcomm.com, ale@rev.ng, anjo@rev.ng
Subject: Re: [PATCH v3 11/13] target/hexagon: Add an errno mapping
Date: Mon, 17 Aug 2026 06:41:28 +0200 [thread overview]
Message-ID: <27fdd807-549b-41ba-9a6b-64ddf4b8b0ce@oss.qualcomm.com> (raw)
In-Reply-To: <bf030fc808d220374abfbd5714154f733ce9826f.1784568922.git.matheus.bernardino@oss.qualcomm.com>
On 20/7/26 19:41, Matheus Tavares Bernardino wrote:
> From: Brian Cain <brian.cain@oss.qualcomm.com>
>
> The Hexagon semihosting ABI defines its own errno values
> which may differ from the host's. Translate host errno to
> the Hexagon-specific values before returning results to the
> guest so that baremetal programs see the expected error codes.
>
> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
> Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
> ---
> target/hexagon/hexswi.c | 75 ++++++++++++++++++++++++++++++++++-------
> 1 file changed, 63 insertions(+), 12 deletions(-)
>
> diff --git a/target/hexagon/hexswi.c b/target/hexagon/hexswi.c
> index 564a11e557a..d93789e39c7 100644
> --- a/target/hexagon/hexswi.c
> +++ b/target/hexagon/hexswi.c
> @@ -154,12 +154,63 @@ static void do_preload(CPUHexagonState *env, target_ulong swi_info, bool load)
> hexagon_peek_memory_range(env, addr, count, retaddr);
> }
>
> +/* Hexagon semihosting errno values */
> +#define HEX_EINVAL 22
> +#define HEX_ERRNOS \
> + HEX_ERRNO(EPERM, 1) \
> + HEX_ERRNO(ENOENT, 2) \
> + HEX_ERRNO(EINTR, 4) \
> + HEX_ERRNO(EIO, 5) \
> + HEX_ERRNO(ENXIO, 6) \
> + HEX_ERRNO(EBADF, 9) \
> + HEX_ERRNO(EAGAIN, 11) \
> + HEX_ERRNO(ENOMEM, 12) \
> + HEX_ERRNO(EACCES, 13) \
> + HEX_ERRNO(EFAULT, 14) \
> + HEX_ERRNO(EBUSY, 16) \
> + HEX_ERRNO(EEXIST, 17) \
> + HEX_ERRNO(EXDEV, 18) \
> + HEX_ERRNO(ENODEV, 19) \
> + HEX_ERRNO(ENOTDIR, 20) \
> + HEX_ERRNO(EISDIR, 21) \
> + HEX_ERRNO(EINVAL, HEX_EINVAL) \
> + HEX_ERRNO(ENFILE, 23) \
> + HEX_ERRNO(EMFILE, 24) \
> + HEX_ERRNO(ENOTTY, 25) \
> + HEX_ERRNO(ETXTBSY, 26) \
> + HEX_ERRNO(EFBIG, 27) \
> + HEX_ERRNO(ENOSPC, 28) \
> + HEX_ERRNO(ESPIPE, 29) \
> + HEX_ERRNO(EROFS, 30) \
> + HEX_ERRNO(EMLINK, 31) \
> + HEX_ERRNO(EPIPE, 32) \
> + HEX_ERRNO(ERANGE, 34) \
> + HEX_ERRNO(ENAMETOOLONG, 36) \
> + HEX_ERRNO(ENOSYS, 38) \
> + HEX_ERRNO(ELOOP, 40) \
> + HEX_ERRNO(EOVERFLOW, 75)
> +
> +/* Map host errno to hexagon semihosting errno */
> +static void semi_cb(CPUState *cs, uint64_t ret, int err)
> +{
> +#define HEX_ERRNO(NAME, CODE) case NAME: err = CODE; break;
> + switch (err) {
> + case 0:
> + break;
> + HEX_ERRNOS
IMHO defining the target-specific semihosting values as TARGET_foo
like done in target/xtensa/xtensa-semi.c is more readable long-term.
> + default:
> + err = HEX_EINVAL;
> + break;
> + }
> + common_semi_cb(cs, ret, err);
> +}
next prev parent reply other threads:[~2026-08-17 4:42 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 17:40 [PATCH v3 00/13] hexagon: add semihosting support Matheus Tavares Bernardino
2026-07-20 17:40 ` [PATCH v3 01/13] target/hexagon: fix improper assign of cause code to exception index Matheus Tavares Bernardino
2026-07-20 17:40 ` [PATCH v3 02/13] target/hexagon: fix PC advancement for non-COF TB terminators Matheus Tavares Bernardino
2026-07-20 17:40 ` [PATCH v3 03/13] target/hexagon: add aux functions for guest mem load/store Matheus Tavares Bernardino
2026-07-20 17:41 ` [PATCH v3 04/13] hexagon: cpu_helper: add reg reading/writing helpers Matheus Tavares Bernardino
2026-08-10 3:48 ` Brian Cain
2026-07-20 17:41 ` [PATCH v3 05/13] semihosting: add APIs for chardev-aware guest fd routing Matheus Tavares Bernardino
2026-07-20 17:41 ` [PATCH v3 06/13] semihosting: add callback to set error Matheus Tavares Bernardino
2026-07-20 17:41 ` [PATCH v3 07/13] target/hexagon: add semihosting support Matheus Tavares Bernardino
2026-08-17 4:11 ` Brian Cain
2026-08-17 4:23 ` Philippe Mathieu-Daudé
2026-08-17 18:50 ` Matheus Tavares Bernardino
2026-07-20 17:41 ` [PATCH v3 08/13] semihosting: add ftruncate helper (to be used for hexagon) Matheus Tavares Bernardino
2026-07-20 17:41 ` [PATCH v3 09/13] target/hexagon: add main arch-specific semihosting operations Matheus Tavares Bernardino
2026-08-17 4:10 ` Brian Cain
2026-08-17 4:29 ` Philippe Mathieu-Daudé
2026-08-18 14:06 ` Matheus Tavares Bernardino
2026-07-20 17:41 ` [PATCH v3 10/13] target/hexagon: add COREDUMP semihosting operation Matheus Tavares Bernardino
2026-08-17 4:34 ` Philippe Mathieu-Daudé
2026-08-17 19:55 ` Matheus Tavares Bernardino
2026-07-20 17:41 ` [PATCH v3 11/13] target/hexagon: Add an errno mapping Matheus Tavares Bernardino
2026-08-17 4:41 ` Philippe Mathieu-Daudé [this message]
2026-08-17 20:09 ` Matheus Tavares Bernardino
2026-07-20 17:41 ` [PATCH v3 12/13] python/machine: support routing semihosting output to the test console Matheus Tavares Bernardino
2026-07-20 17:41 ` [PATCH v3 13/13] tests/functional: Add hexagon semihosting systests Matheus Tavares Bernardino
2026-08-17 4:47 ` Philippe Mathieu-Daudé
2026-08-19 20:25 ` Matheus Tavares Bernardino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=27fdd807-549b-41ba-9a6b-64ddf4b8b0ce@oss.qualcomm.com \
--to=philmd@oss.qualcomm.com \
--cc=ale@rev.ng \
--cc=anjo@rev.ng \
--cc=brian.cain@oss.qualcomm.com \
--cc=marco.liebel@oss.qualcomm.com \
--cc=matheus.bernardino@oss.qualcomm.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.