From: Paolo Bonzini <pbonzini@redhat.com>
To: Keith Packard <keithp@keithp.com>, qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH] Semihost SYS_READC implementation
Date: Wed, 23 Oct 2019 17:51:52 +0200 [thread overview]
Message-ID: <5e8913f8-558d-6a2e-c7d0-787ec533e4a9@redhat.com> (raw)
In-Reply-To: <87sgnk3b0k.fsf@keithp.com>
On 22/10/19 20:12, Keith Packard wrote:
> $ qemu-system-arm -chardev stdio,mux=on,id=stdio0 -serial chardev:stdio0 -semihosting-config enable=on,chardev=stdio0 -mon chardev=stdio0,mode=readline
>
> It might be nice if this could be shortened, but it certainly provides
> the necessary options to make it all work.
Yeah, it's not easy to cram all of the possibilities in the command
line, so in general you need two options, one for the backend ("stdio")
and one for the front-end ("semihosting"). In some cases there are
shortcuts that refer the front-end name in the option name ("-serial"),
but semihosting isn't one of those.
There is no particular reason for this, except for the fact that the
older option "-semihosting" was added without an argument many many
years ago.
> I'll post an updated version of the patch in a while, after waiting to
> see if there are any additional comments.
Indeed I have a couple comments, mostly on coding style and duplication:
>
> +typedef struct SemihostingFifo {
> + unsigned int insert, remove;
> +
> + uint8_t fifo[FIFO_SIZE];
> +} SemihostingFifo;
> +
Please take a look at include/qemu/fifo8.h instead of rolling your own
ring buffer. Note that it is not thread-safe so you'll have to keep
that part.
>
> +target_ulong qemu_semihosting_console_inc(CPUArchState *env)
> +{
> + (void) env;
No need for this, and also...
> + SemihostingConsole *c = &console;
> + qemu_mutex_unlock_iothread();
> + pthread_mutex_lock(&c->mutex);
> + while (fifo_empty(&c->fifo)) {
> + pthread_cond_wait(&c->cond, &c->mutex);
> + }
> + uint8_t ch;
... we tend not to mix declarations and statements.
> + fifo_remove(&c->fifo, ch);
> + pthread_mutex_unlock(&c->mutex);
> + qemu_mutex_lock_iothread();
> + return (target_ulong) ch;
> +}
> +
Kudos for the unlock/lock_iothread; I am not really familiar with the
semihosting code and I would have naively assumed that it runs without
that lock taken. It is indeed better to have your own mutex, because we
do want to pull the unlock/lock up into do_arm_semihosting or even its
callers.
Thanks,
Paolo
next prev parent reply other threads:[~2019-10-23 16:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 3:13 [PATCH] Semihost SYS_READC implementation Keith Packard
2019-10-22 8:34 ` Paolo Bonzini
2019-10-22 18:12 ` Keith Packard
2019-10-23 15:51 ` Paolo Bonzini [this message]
2019-10-23 19:15 ` Keith Packard
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=5e8913f8-558d-6a2e-c7d0-787ec533e4a9@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=keithp@keithp.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--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).