From: Richard Henderson <richard.henderson@linaro.org>
To: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 2/6] target/tricore: Add read and write semihosting calls
Date: Sun, 15 Oct 2023 16:48:02 -0700 [thread overview]
Message-ID: <c7db8b9b-328d-47ab-b14e-53a1c1bed133@linaro.org> (raw)
In-Reply-To: <20231015205913.264782-3-kbastian@mail.uni-paderborn.de>
On 10/15/23 13:59, Bastian Koppelmann wrote:
> Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> ---
> target/tricore/tricore-semi.c | 52 +++++++++++++++++++++++++++++++++++
> 1 file changed, 52 insertions(+)
>
> diff --git a/target/tricore/tricore-semi.c b/target/tricore/tricore-semi.c
> index 27e1bdc59d..ccbeae4bc0 100644
> --- a/target/tricore/tricore-semi.c
> +++ b/target/tricore/tricore-semi.c
> @@ -164,6 +164,52 @@ static void tricore_vio_set_result(CPUTriCoreState *env, int retval,
> env->gpr_d[12] = tricore_vio_errno_h2g(host_errno);
> }
>
> +static void tricore_vio_readwrite(CPUTriCoreState *env, bool is_write)
> +{
> + CPUState *cs = env_cpu(env);
> + hwaddr paddr, sz;
> + uint32_t page_left, io_sz, vaddr;
> + size_t count;
> + ssize_t ret = 0;
> +
> + int fd = env->gpr_d[4];
> + vaddr = env->gpr_a[4];
> + count = env->gpr_d[5];
> +
> + while (count > 0) {
> + paddr = cpu_get_phys_page_debug(cs, vaddr);
> + page_left = TARGET_PAGE_SIZE - (vaddr & (TARGET_PAGE_SIZE - 1));
> + io_sz = page_left < count ? page_left : count;
> + sz = io_sz;
> + void *buf = cpu_physical_memory_map(paddr, &sz, true);
> +
> + if (buf) {
> + vaddr += io_sz;
> + count -= io_sz;
> + ret = is_write ?
> + write(fd, buf, io_sz) :
> + read(fd, buf, io_sz);
You should be able to use "semihosting/syscalls.h".
Compare m68k-semi.c.
r~
next prev parent reply other threads:[~2023-10-15 23:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-15 20:59 [PATCH 0/6] TriCore Semihosting Bastian Koppelmann
2023-10-15 20:59 ` [PATCH 1/6] target/tricore: Add semihosting stub Bastian Koppelmann
2023-10-15 20:59 ` [PATCH 2/6] target/tricore: Add read and write semihosting calls Bastian Koppelmann
2023-10-15 23:48 ` Richard Henderson [this message]
2023-10-15 20:59 ` [PATCH 3/6] target/tricore: Add lseek semihosting call Bastian Koppelmann
2023-10-15 20:59 ` [PATCH 4/6] target/tricore: Add close " Bastian Koppelmann
2023-10-15 20:59 ` [PATCH 5/6] target/tricore: Add open and creat semihosting calls Bastian Koppelmann
2023-10-15 20:59 ` [PATCH 6/6] target/tricore: Enable semihosting Bastian Koppelmann
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=c7db8b9b-328d-47ab-b14e-53a1c1bed133@linaro.org \
--to=richard.henderson@linaro.org \
--cc=kbastian@mail.uni-paderborn.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).