|
Message
From: Aitor Garay-Romero<terminaaitor@g...>
Date: Mon May 23 12:28:48 CEST 2005
Subject: [openrisc] using stdio.h functions with or1ksim
Hi there!,Gy?rgy 'nog' Jeney wrote: >> I'm linking the application with newlib. The fopen/fread/fclose >>symbols get resolved by the linker, but a lot of other external symbols >>>from newlib remain unresolved. The unresolved symbols look like >>_lseek_r, _read_r, _sbrk_r, _fstat_r, ... I assume that those functions >>must be provided by some OS, for example uclinux. >> >> > >The underlying implementation (what comunicates with the hardware) is provided >by uclinux or linux, which newlib calls via syscalls. Though you don't need to >link in the os kernel for the symbols to resolve. This is probably the annoying >linker issue discussed many times before. See: > >attachment-0001.htm). I don't see that platform specific directory in the OpenRISC port, neither the 'configure.host' file specifies a suitable directory. Newlib provides a 'fake' implementation in 'libgloss/libnosys' of those symbols, but seems that it's not linked automatically.
Anyway, even if those functions are implemented ( using 'l.sys' instructions), this does not solve my problem (see below).
>>I also have looked to the or1ksim source to see if it emulates the >>syscalls but found nothing (there seems to be an obsolete #define >>ONLY_VIRTUAL_MACHINE). >> >> > >Syscalls (the l.sys instruction) are emulated just fine. > > > Sorry, i was referring to the emulation different system calls defined in the 'unistd.h' header file ( __NR_exit, __NR_fork, __NR_read, __NR_write, ...), not to the emulation of the 'l.sys' instruction.
>> So, in summary: is there an easy way to use >>fopen/fread/fclose/printf/... under or1ksim? One way i see is to >>somehow communicate with the outside world via the emulated serial port >>of or1ksim, but that's not trivial... >> >> > >There are the `report' and `printf' `nop' `instructions' provided by the sim, >which may or maynot be what you're after. The testbenches use them quite abit >(check out the files under or1ksim/testbench on how to use them). Or you could >just run the entire (uc)linux kernel and run your code from there... > > > What i want to do is to use fopen/fread/fwrite/... functions from the simulator, and those functions must work on files stored on my computer.
When i link my application with newlib it does provide those functions, but it ends up calling _open/_read/_write/... methods that make use of 'l.sys' instructions to request "the OS running inside the simulator" (uc/linux) to implement the functions. Even if i use uc/linux, i don't see how the code running in the simulator (uc/linux + my application) can open/read/write to a file in my computer.
There must be some code in the simulator that "catches" l.sys instructions, looks at the requested service and implements it on the host computer. It does not make sense to emulate many system calls like fork/waitpid/lock/... since those must the implemented by the target OS, but some other like open/close/read/write/lseek/... could be emulated nicely.
For example, the commercial ARM simulator from ARM Ltd. implements
something they call "semihosting SWI" ( 'SWI' is the the 'l.sys'
instruction for ARM). You link you application with the C library, and
the simulator will catch some SWI instructions and implement them on the
host. This way you can work with local files, for example.
So, is it possible to do something like this in or1ksim?
Thanks for your support!
/AITOR
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: openrisc/attachments/20050523/76ab94beattachment-0001.htm
|
 |