Previous: What to do now, Up: Libraries [Contents]
This describes newlib
, a freely available libc replacement. Most
applications use calls in the standard C library. When initially linking
in libc.a, several I/O functions are undefined. If you don’t plan on
doing any I/O, then you’re OK, otherwise they need to be created. These
routines are read, write, open, close. sbrk, and kill. Open & close
don’t need to be fully supported unless you have a filesystems, so
typically they are stubbed out. Kill is also a stub, since you can’t do
process control on an embedded system.
Sbrk() is only needed by applications that do dynamic memory
allocation. It’s uses the symbol _end
that is setup in the linker
script. It also requires a compile time option to set the upper size
limit on the heap space. This leaves us with read and write, which are
required for serial I/O. Usually these two routines are written in C,
and call a lower level function for the actual I/O operation. These two
lowest level I/O primitives are inbyte() and outbyte(), and are also
used by GDB back ends if you’ve written an exception handler. Some
systems also implement a havebyte() for input as well.
Other commonly included functions are routines for manipulating LED’s on the target (if they exist) or low level debug help. Typically a putnum() for printing words and bytes as a hex number is helpful, as well as a low-level print() to output simple strings.
As libg++ uses the I/O routines in libc.a, if read and write work, then libg++ will also work with no additional changes.
• I/O Support: | Functions that make serial I/O work. | |
• Memory Support: | Memory support. | |
• Misc Support: | Other needed functions. | |
• Debugging: | Useful Debugging Functions |
Previous: What to do now, Up: Libraries [Contents]