qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 0/2] ARM: fix commandline handling forsemihosted


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 0/2] ARM: fix commandline handling forsemihosted executables
Date: Fri, 7 Jan 2011 15:56:12 +0000

On 7 January 2011 15:46, Schildbach, Wolfgang <address@hidden> wrote:
> I usually compile a hello world (echoing its arguments) with rvds2.2 or
> above:

> If you don't have an ARM compiler available, I could send you the
> compiled binary to test. Peter, is there another way to generate
> binaries using semihosting?

You can also do this with a gcc compiled for arm-none-eabi (eg as found
in the codesourcery "ARM EABI" toolchain:
http://www.codesourcery.com/sgpp/lite/arm/portal/release1592 ):

/opt/arm-2010.09/bin/arm-none-eabi-gcc -g -Wall -o hello hello.c -T
generic-hosted.ld

Or you can just test "by hand":
#include <stdio.h>

struct datablock {
   char *string;
   int buflen;
};

char buf[20];

int main(int argc, char **argv) {
   int r, i;
   struct datablock datablock;
   printf("semihosting-cmd test: argc %d\n", argc);
   for (i = 0; i < argc; i++) {
      printf("argv[%d]: %s\n", i, argv[i]);
   }
   datablock.string = buf;
   datablock.buflen = sizeof(buf);
   {
      register int r0 asm ("r0") = 0x15;
      register void * r1 asm ("r1") = &datablock;
      register int result asm ("r0");
      __asm__ __volatile__ (
      "svc 0x123456"
      : "=r" (result)
      : "r" (r0), "r" (r1)
      : "cc", "memory");
      r = result;
   }
   printf("semihosting returned status %d\n", r);
   if (r == 0) {
       printf("and string '%s'\n", datablock.string);
   }
   return 0;
}

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]