2.12. System Calls

A system call is the means by which application programs call an operating system. System calls are mostly used for input-output. The C language input-output functions declared in <stdio.h> use these calls.

With XGC compilers, we have no operating system as such, just the run-time system module art0. However, we support the system call mechanism using trap 80 (the SPARC standard) and when running on the simulator we map system calls to host system calls so that application programs can access host computer files during program development.

When running on the target, any system call will bring your program to an abnormal termination because the required system call handler is absent in the default configuration. The default system call handler is located in libc and supports an appropriate subset of calls. For example, read and write are directed to UARTA and may be used in a console dialog. You may wish to customise the default handler so that calls that would otherwise be non-operational could do something useful. For example, the call to get the time could be implemented to read the time form some external clock.

This can be done quite easily and an example system call handler is included with the source files in /opt/gcc-erc32-1.7/erc-coff/src/libc/sys/schandler.c. The handler is attached to the system call trap in the same fashion as other interrupts are attached to their handlers. In the example, a C function is provided to do the attaching.