From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>,
qemu-devel@nongnu.org, Kohei Tokunaga <ktokunaga.mail@gmail.com>
Cc: brian.cain@oss.qualcomm.com, pierrick.bouvier@oss.qualcomm.com,
marco.liebel@oss.qualcomm.com, ale@rev.ng, anjo@rev.ng,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH v3 09/13] target/hexagon: add main arch-specific semihosting operations
Date: Mon, 17 Aug 2026 06:29:56 +0200 [thread overview]
Message-ID: <709f1994-e992-45e8-b33f-1a00b943bc50@oss.qualcomm.com> (raw)
In-Reply-To: <96776c988e48b04a59a146fb62a934389a73a4a2.1784568922.git.matheus.bernardino@oss.qualcomm.com>
Cc'ing Kohei for WASM
On 20/7/26 19:41, Matheus Tavares Bernardino wrote:
> The Hexagon semihosting ABI extends the arm-compatible set with
> operations like OPEN, WRITECREG, WRITE0, ISTTY, STAT, FSTAT, FTELL,
> SEEK, FTRUNC, ACCESS, and GETCWD. Implement these trap0 handlers so
> that baremetal programs using the standard Hexagon simulator ABI can
> perform file I/O when running on qemu-system-hexagon.
>
> 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>
> ---
> include/semihosting/common-semi.h | 1 +
> semihosting/arm-compat-semi.c | 2 +-
> target/hexagon/hexswi.c | 298 +++++++++++++++++++++++++++++-
> 3 files changed, 299 insertions(+), 2 deletions(-)
> + case HEX_SYS_STAT:
> + case HEX_SYS_FSTAT:
> + {
> + struct stat st_buf;
> + uint8_t *st_bufptr = (uint8_t *)&sys_stat;
> + int rc, err = 0;
> + char filename[BUFSIZ];
> + target_ulong physical_filename_addr;
> + target_ulong statBufferAddr;
> + hexagon_read_memory(env, swi_info, 4, &physical_filename_addr, retaddr);
> +
> + if (what_swi == HEX_SYS_STAT) {
> + int i = 0;
> + do {
> + hexagon_read_memory(env, physical_filename_addr + i, 1,
> + &filename[i], retaddr);
> + i++;
> + } while ((i < BUFSIZ) && filename[i - 1]);
> + rc = stat(filename, &st_buf);
> + err = errno;
> + } else {
> + int fd = physical_filename_addr;
> + GuestFD *gf = get_guestfd(fd);
> + if (!gf || gf->type != GuestFDHost) {
> + qemu_log_mask(LOG_UNIMP,
> + "fstat semihosting only implemented"
> + " for native mode\n");
> + g_assert_not_reached();
> + }
> + rc = fstat(gf->hostfd, &st_buf);
> + err = errno;
> + }
> + if (rc == 0) {
> + sys_stat.dev = st_buf.st_dev;
> + sys_stat.ino = st_buf.st_ino;
> + sys_stat.mode = st_buf.st_mode;
> + sys_stat.nlink = (uint32_t) st_buf.st_nlink;
> + sys_stat.rdev = st_buf.st_rdev;
> + sys_stat.size = (uint32_t) st_buf.st_size;
> +#if defined(__linux__)
> + sys_stat.atime = (uint32_t) st_buf.st_atim.tv_sec;
> + sys_stat.mtime = (uint32_t) st_buf.st_mtim.tv_sec;
> + sys_stat.ctime = (uint32_t) st_buf.st_ctim.tv_sec;
> +#elif defined(_WIN32)
> + sys_stat.atime = st_buf.st_atime;
> + sys_stat.mtime = st_buf.st_mtime;
> + sys_stat.ctime = st_buf.st_ctime;
> +#endif
This #if/elif seems bogus in that various hosts are not covered,
in particular *BSD and WASM. We could use #else #error to catch
them, or better implement OS-specific [f]stat() helpers (see
include/system/os-*.h).
> + }
> + hexagon_read_memory(env, swi_info + 4, 4, &statBufferAddr, retaddr);
> +
> + for (int i = 0; i < sizeof(sys_stat); i++) {
> + hexagon_write_memory(env, statBufferAddr + i, 1, st_bufptr[i],
> + retaddr);
> + }
> + common_semi_cb(cs, rc, rc == 0 ? 0 : err);
> + }
> + break;
next prev parent reply other threads:[~2026-08-17 4:30 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é [this message]
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é
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=709f1994-e992-45e8-b33f-1a00b943bc50@oss.qualcomm.com \
--to=philmd@oss.qualcomm.com \
--cc=ale@rev.ng \
--cc=alex.bennee@linaro.org \
--cc=anjo@rev.ng \
--cc=brian.cain@oss.qualcomm.com \
--cc=ktokunaga.mail@gmail.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.