All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bruno Prado <bruno@dcomp.ufs.br>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: ARM semihosting issue
Date: Fri, 2 Oct 2020 08:09:19 -0300	[thread overview]
Message-ID: <CAD5UmjrFgv1pCKGW813dzmYcEEWLdvu9FmGi0ymvXbvfw-aonQ@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA9JecdSwd=gXSu7mhDHVysLP5JP4dtRBgBVr7=bt=j6Tw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3149 bytes --]

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?

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
>

[-- Attachment #2: Type: text/html, Size: 5306 bytes --]

  reply	other threads:[~2020-10-02 11:11 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 [this message]
2020-10-21 14:16         ` Bruno Prado
2020-10-21 15:45           ` Alex Bennée
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=CAD5UmjrFgv1pCKGW813dzmYcEEWLdvu9FmGi0ymvXbvfw-aonQ@mail.gmail.com \
    --to=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 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.