From: "Keith Packard" <keithp@keithp.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH] Semihost SYS_READC implementation (v4)
Date: Fri, 25 Oct 2019 09:36:52 -0700 [thread overview]
Message-ID: <87pnik4w9n.fsf@keithp.com> (raw)
In-Reply-To: <8736fhm9tw.fsf@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 3051 bytes --]
Alex Bennée <alex.bennee@linaro.org> writes:
> I can see the use for this but I'd like to know what you are testing
> with. We only have very basic smoketests in check-tcg but I've tested
> with the latest arm-semihosting tests and they are all fine so no
> regressions there.
I'm adding semihosting support to picolibc
(https://keithp.com/picolibc/) and need a way to automate tests for it's
SYS_READC support, so eventually I'll have automated tests there, but
that depends on qemu support...
> Please keep version history bellow --- so they get dropped when the
> patch is applied.
Sure, I'll edit the mail before sending. In my repo, I'm leaving the
version history in git so I can keep track of it.
>> v4:
>> Add qemu_semihosting_console_init to stubs/semihost.c for
>> hosts that don't support semihosting
>
> This doesn't appear to be in the diff which is why I'm seeing a compile
> failure for non-CONFIG_SEMIHOST machines. However...
Argh! Just git operation failure -- I'm building another patch on top of
this (for RISC-V semihosting support) and the stubs/semihost.c change
got caught in there. My overall check for changes missed this mistake.
>> +
>> +#include <poll.h>
>
> Headers should go at the top.
Thanks; I've fixed this file and hw/semihosting/console.c
>> case TARGET_SYS_READC:
>> - qemu_log_mask(LOG_UNIMP, "%s: SYS_READC not implemented", __func__);
>> - return 0;
>> + return qemu_semihosting_console_inc(env);
>
> I'm not sure this would be correct if there was no character available.
> The docs imply it blocks although don't say so explicitly AFAICT.
Here's what the docs say:
https://static.docs.arm.com/100863/0200/semihosting.pdf
Return
On exit, the RETURN REGISTER contains the byte read from the console.
If this call didn't block, they'd have to define a value which indicated
that no byte was available? Openocd also implements SYS_READC using
'getchar()', which definitely blocks. So, at least qemu would be the
same.
I realize it's really weird to block the whole emulation for this call,
but given the target environment (deeply embedded devices), it's quite
convenient as the whole qemu process blocks, instead of spinning.
>> + /* connect semihosting console input if requested */
>> + qemu_semihosting_console_init();
>> +
>
> I'd rather rename qemu_semihosting_connect_chardevs to
> qemu_semihosting_init and keep all our bits of semihosting setup in
> there rather than having multiple calls out of vl.c
I also thought this would be a nice cleanup. However, the last caller to
qemu_chr_fe_set_handlers gets the focus for input, and connect_chardevs
is called before the serial ports and monitor are initialized, so
semihosting gets pushed aside and stdio input ends up hooked to the monitor
instead.
Adding this function and placing the call after the other stdio users
get hooked up means that semihosting starts with the input focus.
--
-keith
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2019-10-25 16:40 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-23 19:26 [PATCH] Semihost SYS_READC implementation (v3) Keith Packard
2019-10-24 17:33 ` no-reply
2019-10-24 18:54 ` Paolo Bonzini
2019-10-24 22:46 ` [PATCH] Semihost SYS_READC implementation (v4) Keith Packard
2019-10-25 9:51 ` Alex Bennée
2019-10-25 16:36 ` Keith Packard [this message]
2019-10-25 16:49 ` Peter Maydell
2019-10-25 19:15 ` Keith Packard
2019-10-25 20:53 ` Peter Maydell
2019-10-25 23:18 ` Keith Packard
2019-11-04 20:42 ` [PATCH] Semihost SYS_READC implementation (v6) Keith Packard
2019-12-17 8:38 ` Alex Bennée
2019-12-17 9:08 ` Paolo Bonzini
2019-12-17 9:51 ` Alex Bennée
2019-12-17 10:04 ` Paolo Bonzini
2019-12-17 12:14 ` [RFC PATCH] semihosting: suspend recieving CPU when blocked (HACK, WIP) Alex Bennée
2019-12-17 12:22 ` Paolo Bonzini
2019-12-17 13:42 ` Alex Bennée
2019-12-17 13:48 ` Paolo Bonzini
2019-12-17 14:18 ` Alex Bennée
2019-12-17 14:39 ` Paolo Bonzini
2019-12-17 14:39 ` Paolo Bonzini
2019-12-18 17:36 ` Alex Bennée
2019-12-18 21:23 ` Paolo Bonzini
2019-11-05 5:10 ` [PATCH] Semihost SYS_READC implementation (v4) Keith Packard
2019-11-11 14:51 ` Peter Maydell
2019-11-14 15:46 ` Alistair Francis
2019-11-14 17:43 ` Keith Packard
2019-11-14 17:39 ` Keith Packard
2019-11-14 17:47 ` Peter Maydell
2019-11-14 19:20 ` Peter Maydell
2019-11-14 16:14 ` Peter Maydell
2019-11-14 18:05 ` Keith Packard
2019-11-14 18:18 ` Peter Maydell
2019-11-14 19:18 ` Richard Henderson
2019-11-14 19:29 ` Peter Maydell
2019-11-14 20:52 ` Richard Henderson
2019-11-14 21:04 ` Peter Maydell
2019-11-14 22:26 ` Keith Packard
2019-11-15 10:54 ` Peter Maydell
2019-11-15 23:40 ` Keith Packard
2019-10-25 17:02 ` Alex Bennée
2019-10-25 18:17 ` no-reply
2019-10-25 18:20 ` no-reply
2019-10-24 17:43 ` [PATCH] Semihost SYS_READC implementation (v3) no-reply
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=87pnik4w9n.fsf@keithp.com \
--to=keithp@keithp.com \
--cc=alex.bennee@linaro.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).