qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Bruno Prado <bruno@dcomp.ufs.br>
Cc: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: ARM semihosting issue
Date: Wed, 21 Oct 2020 16:45:09 +0100	[thread overview]
Message-ID: <875z73wpkq.fsf@linaro.org> (raw)
In-Reply-To: <CAD5UmjqDGmOksXSk31q3asXLogSggc7rqOXuo2K2yLLs81ccQQ@mail.gmail.com>


Bruno Prado <bruno@dcomp.ufs.br> writes:

> Hello, is it really a bug?
>
> ----
> Bruno Prado
>
>
> On Fri, Oct 2, 2020 at 8:09 AM Bruno Prado <bruno@dcomp.ufs.br> wrote:
>
>> I am including some syscall functions:
>>
>> int _fstat(int file, struct stat* st) {
>>        register int value asm("r0");
>>        uint32_t p[] = { file };
>>        R0(0x0C);
>>        R1(p);
>>        BKPT();
>>        return value;
>> }
>>
>> int _read(int file, char* ptr, int len) {
>>        register int value asm("r0");
>>        uint32_t p[] = { file, (uint32_t)(ptr), len };
>>        R0(0x06);
>>        R1(p);
>>        BKPT();
>>        return value;
>> }
>>
>> int _write(int file, char* ptr, int len) {
>>        register int value asm("r0");
>>        uint32_t p[] = { file, (uint32_t)(ptr), len };
>>        R0(0x05);
>>        R1(p);
>>        BKPT();
>>        return value;
>> }
>>
>> Also the interruption output from execution:
>>
>> $ qemu-system-arm -M netduino2 -nographic -semihosting -kernel vp2.bin -d
>> int
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x1
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x1
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x1
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x1
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0xc
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x5
>> What is your name?
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x5
>> Reading from file...
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0xc
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x6
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0xc
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x6
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x5
>> My name is Turing
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x5
>> I am alive!!!
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0xa
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0xa
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x2
>> Taking exception 16 [Semihosting call]
>> ...handling as semihosting call 0x20
>>
>> Could you please provide any working example using ARM semihosting on
>> stdin?

We have a test which you can run by hand:

   ./tests/tcg/arm-linux-user/semiconsole

>>
>> Thanks,
>> ----
>> Bruno Prado
>>
>>
>> On Fri, Oct 2, 2020 at 7:25 AM Peter Maydell <peter.maydell@linaro.org>
>> wrote:
>>
>>> On Thu, 1 Oct 2020 at 22:21, Bruno Prado <bruno@dcomp.ufs.br> wrote:
>>> > Thanks for the reply... I am attaching some code and output:
>>> >
>>> > #include <stdio.h>
>>> > int main() {
>>> >        char name[50] = "Nobody";
>>> >        FILE* file = fopen("name", "r");
>>> >        printf("What is your name?\n");
>>> >        fprintf(stdout, "Reading from file...\n");
>>> >        fscanf(file, "%s", name);
>>> >        fscanf(stdin, "%s", name);
>>> >        printf("My name is %s\n", name);
>>> >        fprintf(stderr, "I am alive!!!\n");
>>> >        fclose(file);
>>> >        return 0;
>>> > }
>>>
>>> This is not making direct semihosting calls. The behaviour
>>> of these function calls will depend on whatever the C
>>> standard library implementation you're linking with is doing.
>>>
>>> You're not checking for errors from any of your function
>>> calls, incidentally.
>>>
>>> thanks
>>> -- PMM
>>>
>>


-- 
Alex Bennée


  reply	other threads:[~2020-10-21 15:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01 18:19 ARM semihosting issue Bruno Prado
2020-10-01 20:38 ` Peter Maydell
2020-10-01 21:20   ` Bruno Prado
2020-10-02 10:25     ` Peter Maydell
2020-10-02 11:09       ` Bruno Prado
2020-10-21 14:16         ` Bruno Prado
2020-10-21 15:45           ` Alex Bennée [this message]
2020-10-21 17:51             ` Bruno Prado

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=875z73wpkq.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=bruno@dcomp.ufs.br \
    --cc=peter.maydell@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).