From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17FB6C4363D for ; Fri, 2 Oct 2020 11:11:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29C62206B8 for ; Fri, 2 Oct 2020 11:11:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=dcomp-ufs-br.20150623.gappssmtp.com header.i=@dcomp-ufs-br.20150623.gappssmtp.com header.b="iDtkH89U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29C62206B8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dcomp.ufs.br Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOIy5-0005xa-2K for qemu-devel@archiver.kernel.org; Fri, 02 Oct 2020 07:11:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOIws-0005DK-4d for qemu-devel@nongnu.org; Fri, 02 Oct 2020 07:10:02 -0400 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]:34254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kOIwm-0004Ll-GJ for qemu-devel@nongnu.org; Fri, 02 Oct 2020 07:09:58 -0400 Received: by mail-oi1-x229.google.com with SMTP id n2so879234oij.1 for ; Fri, 02 Oct 2020 04:09:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dcomp-ufs-br.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RvjhiqJHJgBeVGeyTjrvQLPx9SjIv+Uiqsdw4TJ4qDI=; b=iDtkH89UJB61Jtyaqi8Wjk5QWLHxzkkbet/aeF7ljVaxFzcgLi7dcO7z0D12/p6FlR P7RVBOF4WQCbUYP7L858dsZ82U+2gXAcg/2l4MY4tIE8TlXbwzkkz1jKZXcyWSOhcs8W Z8mXWZA77a9ezmyO15yeluSRZdMh3BML+OdSvo5XHCJgvdjZ5TFH2m+1JLladMvqi3MZ pvlzZ7pQQLZJW6LwrRwr1N/E6SLBxmZ66mC6qZ2RRVXO9A6Bq5w3L2ozzJbV6o7pFIYI PEJTjHCxfIzOP/3vtvL2SMkNLa3Jp2KZAp4TlBKWQvc7Ic+ULCvbOC/ZGvO2LEKhykQY SwSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RvjhiqJHJgBeVGeyTjrvQLPx9SjIv+Uiqsdw4TJ4qDI=; b=iRdfDXyNKyZ+fA7XIXh5AzLlwS3JsLM56jwmlsuLw2mrbRG8HWxUYEV209JIeO1REK nJJMgXp3KCjSBvQbUsGWU1xCMkiz/n4J5VZKQDey6Ig4pzCI8KnqPSkfnAuJUlVzmzyU FSkeGdOPBNF0djQchztdhHv1zHnNjCo5kKYrdlRJS9CqoYg7nK7/1EE2GnhNpuAkBRQk WQZaX6RU1srYH7VguJWvOvo0rDDhtwf0EdJtI+LUdo/seimmrGt1ttUT3oQq7O8AJ6Z0 4+qMnnC0zPS+CBeNxFY9YT2j9R3WcvJzB8/kqTfKiVijt4oKwLmhfZdWb6GbUTaXu6iK t30g== X-Gm-Message-State: AOAM531a8iOmcE8PKnZx3IDDttbaQloKg7KBs0SGsyqAkN8JoHpb3nOY DGAUfaIe0kTfM7/GQ2+XU3gaklPKJ7wLRpafp5A= X-Google-Smtp-Source: ABdhPJzXiNmiOX+IlwVbFsT5Y1VmTWYdE51CIV5Svr0C25HfZawX986PSc76PzKN9PhMatpnZ6g4JzO2lmE12SRGinU= X-Received: by 2002:aca:c442:: with SMTP id u63mr873155oif.150.1601636995123; Fri, 02 Oct 2020 04:09:55 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bruno Prado Date: Fri, 2 Oct 2020 08:09:19 -0300 Message-ID: Subject: Re: ARM semihosting issue To: Peter Maydell Content-Type: multipart/alternative; boundary="000000000000274e8005b0ae2c74" Received-SPF: pass client-ip=2607:f8b0:4864:20::229; envelope-from=bruno.otavio@gmail.com; helo=mail-oi1-x229.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU Developers Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --000000000000274e8005b0ae2c74 Content-Type: text/plain; charset="UTF-8" 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 wrote: > On Thu, 1 Oct 2020 at 22:21, Bruno Prado wrote: > > Thanks for the reply... I am attaching some code and output: > > > > #include > > 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 > --000000000000274e8005b0ae2c74 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I am including some syscall functions:

= int = _fstat(int file, struct stat* st) {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0register int value as= m("r0");
=C2=A0 =C2=A0 =C2=A0 =C2=A0uint32_t p[] =3D { file };
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0R0(0x0C);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0R1(p);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0BKPT();
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return value;
}

int _read(int file, char* ptr, int le= n) {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0register int value as= m("r0");
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0uint32_t p[] =3D { file, (ui= nt32_t)(ptr), len };
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0R0(0x06);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0R1(p);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0BKPT();
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return value;
}

int _write(int file, char* ptr, int l= en) {
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0register int value as= m("r0");
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0uint32_t p[] =3D { file, (ui= nt32_t)(ptr), len };
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0R0(0x05);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0R1(p);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0BKPT();
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return value;
}

Also the interruption output from execution:
=

$ qemu-syste= m-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 plea= se provide any working example using ARM semihosting on stdin?

Thanks,
----
Bruno Prado


On Fri, Oct 2, 2020 at 7:25 AM Pe= ter Maydell <peter.maydell@l= inaro.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() {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 char name[50] =3D "Nobody";
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 FILE* file =3D fopen("name", &quo= t;r");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("What is your name?\n"); >=C2=A0 =C2=A0 =C2=A0 =C2=A0 fprintf(stdout, "Reading from file...\= n");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 fscanf(file, "%s", name);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 fscanf(stdin, "%s", name);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("My name is %s\n", name);<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 fprintf(stderr, "I am alive!!!\n"= );
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 fclose(file);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 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
--000000000000274e8005b0ae2c74--