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 5ACB2C55178 for ; Wed, 21 Oct 2020 14:18:24 +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 B9D3B22249 for ; Wed, 21 Oct 2020 14:18:22 +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="kXOsgINU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9D3B22249 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]:45066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVEwX-0002pn-Ok for qemu-devel@archiver.kernel.org; Wed, 21 Oct 2020 10:18:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVEvp-00021S-58 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 10:17:37 -0400 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]:41424) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVEvm-0002ct-Fu for qemu-devel@nongnu.org; Wed, 21 Oct 2020 10:17:36 -0400 Received: by mail-oi1-x22f.google.com with SMTP id q136so2217373oic.8 for ; Wed, 21 Oct 2020 07:17:33 -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=iROrmkBqDzQeScHYQs2DCy4kVq7FcyoJUXW5d7IJkD0=; b=kXOsgINUroriAoCVbHomO554dCoa2oKAD/D8MGSlYtDycKpGRDhZaNbsXBslM3bnZU 6RmtV4eW8ZZV5ypp1ivetRRiSobaWo5vCTwq3Q9SX09jhyxS074F/aEF5TPn+eJP3zpF 8bLrzJEOIzioPE7h/wnWrJR3sAowGJNlFZQza2kKLEBY9ja3u2oYGWRQgyQAVHDpIe6d xGsBrFII7uXdT8dkls6KFRSBE08YqGXPHKtuRc0b/gFGy8bze+ZKU/PrpPOGuzgtfWLM 7VfaFekCkCSnXSDZt4TH0Mqt3i4ct2+ViTdzSAR9oE/1OJRbITDayIOiTz0jwQouIXYS wbkA== 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=iROrmkBqDzQeScHYQs2DCy4kVq7FcyoJUXW5d7IJkD0=; b=tDwRYpzb+NVCQr+V7Am9UFiKkY4CumEmohx/3eatcqgt2eKvLZ+WYYz/eVLXvmozPg J8JFspnT1EFAIAmrn1YwcsDGQSOo3vAUFl7Ysc3ybSK/RHiUGcw6E8gx7RVm8zmwQ0fU vVYh6eIQRpYqKHcqEp0hk8/20aNotrxsBwZW6mqqrAoSo4rWtddxCUvAFXUJqeNqa38w WlPGXZwyR6BsHrICMAYsL69seuMwF/mQe9KnYNNZWfMkOIdF7kkCDTa32HqqMtqDOWPd 5MRklIX3VvcqHLsd2CADJVfSG2mOJh1uXqkpUfIJXhKEQ5xdPAWnQzTTJrFg7Nbe3mXx OkSA== X-Gm-Message-State: AOAM532OG8Ljg6Lr1oZeCDwRRtGu6QhhWO7VfAYxcNJHs7Vx2NmU+zw3 6n4QgI2+cmTNaCkpcgK8di7dp+yiNyLbHA95keY= X-Google-Smtp-Source: ABdhPJwReNK4HfWhRHF+Qkn2A0xXEyHUABjS5fsaxL80yXbr0suAkE6+yX7PeNe11xhEc/A7C/nbDm7L7cZkyZOTtmU= X-Received: by 2002:aca:5515:: with SMTP id j21mr2385256oib.150.1603289853069; Wed, 21 Oct 2020 07:17:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bruno Prado Date: Wed, 21 Oct 2020 11:16:56 -0300 Message-ID: Subject: Re: ARM semihosting issue To: Peter Maydell Content-Type: multipart/alternative; boundary="0000000000002a0e9e05b22f0211" Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=bruno.otavio@gmail.com; helo=mail-oi1-x22f.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: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, 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" --0000000000002a0e9e05b22f0211 Content-Type: text/plain; charset="UTF-8" Hello, is it really a bug? ---- Bruno Prado On Fri, Oct 2, 2020 at 8:09 AM Bruno Prado 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? > > 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 >> > --0000000000002a0e9e05b22f0211 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello, is it really a bug?

-= ---
Bruno Prado


On Fri, Oct 2, 2020 at 8:09 AM Brun= o Prado <bruno@dcomp.ufs.br>= ; wrote:
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-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
<= br>
Could you please provide any working example using ARM semiho= sting on stdin?

Thanks,
----=
Bruno Prado


<= div dir=3D"ltr" class=3D"gmail_attr">On Fri, Oct 2, 2020 at 7:25 AM Peter M= aydell <pe= ter.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() {
>=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
--0000000000002a0e9e05b22f0211--