|
From: | Bruno Prado |
Subject: | Re: ARM semihosting issue |
Date: | Wed, 21 Oct 2020 14:51:40 -0300 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |