make i/o work ?

J. Johnston
Tue Feb 5 15:50:00 GMT 2002

"Mr.Smoke" wrote:
> Hi,
> how can i get the i/o stuff working in newlib 1.9 ?
> I read many docs (B.Gatlif for ex.) but not realy sure what i need to do.

That's bit of an open question.  What particular platform are you targetting
(v850?) and
what particular board or do you just want to use the simulator?  

> That´s what i suppose:
> I need a inbyte() and outbyte() function. Must they be build with the
> complete newlib sources, or can i include them in my programms which will be
> linked against newlib ?

Newlib is built to sit on a relatively small syscall layer.  Typically, this
layer is kept separate in libgloss to allow multiple implementations (e.g. an
evaluation board vs a simulator).  Newlib itself does not know about inbyte()
or outbyte();  it calls the read/write syscalls.  See
for details on what the syscall interface routines need to be named.  
You also need a crt0 and a crt1 (if you want C++ ctor/dtor support).

If you are building to run on a simulator, the task is quite straightforward.  
Assuming you are targetting the v850, looking at the v850 simulator, a syscall
is a trap 0

/* Registers passed to trap 0 */

#define FUNC   State.regs[6]    /* function number, return value */
#define PARM1  State.regs[7]    /* optional parm 1 */
#define PARM2  State.regs[8]    /* optional parm 2 */
#define PARM3  State.regs[9]    /* optional parm 3 */

Thus, you need to add a set of syscall routines that newlib will call that use
trap 0.  See the libgloss/mn10300 code which also uses trap 0.

If you want to run off a board, there is the RedBoot monitor you can use for
certain v850 boards.  See for details.  You
will have to write a libgloss library that calls the RedBoot syscall interface.  
Offhand I don't know, but it might just be trap 0 as well.  Alternatively,
you could just use eCos instead of newlib which contains a configurable C
library and
RedBoot that already support v850.  See for more

-- Jeff J.

More information about the Newlib mailing list