You can use the system call functionality in the picoJavaTM environment to extend the capabilities of the simulation environment in various ways. A sample implementation of the system call functionality is present in the picoJava-II distribution. See the README in the directory $PICOJAVAHOME/$PROJECT/syscall_example.
At startup, IAS or RTL looks for a dynamically linked library in the file
that the environment variable PICOJAVA_SYSCALL_LIB
points to.
The following process follows:
PICOJAVA_SYSCALL_LIB
is not set, IAS or RTL drops the system call functionality.
PICOJAVA_SYSCALL_LIB
, it then looks for
the functions picojava_syscall_init ()
and picojava_syscall ()
in the library.
int picojava_syscall_init ()
.
If int picojava_syscall_init ()
returns a nonzero value,
IAS or RTL assumes that initialization has succeeded and enables the system
call functionality; otherwise, it assumes that initialization failed and
disables the functionality.
The initialization function cannot assume any state, except that IAS or
RTL has created memory (by calling cmInit
) and initialized it--that
is, IAS or RTL does not write over anything that is now written.
To invoke system calls, the program that runs on IAS or RTL must write
to the special address 0xffe8 with the ncstore_byte
instruction. Doing so triggers a call to the
function void picojava_syscall ()
. The IAS or RTL environment does not
handle passing of parameters between the code that runs on the picoJava
core and the system call library; instead, IAS or RTL assumes that parameters
and such are set up in memory according to a predefined protocol.
Compile with this command:
cc -G -o libsyscall.so.1 libsyscall.c
If you are using gcc, use this command:
gcc -fpic -shared -o libsyscall.so.1 libsyscall.c
Set up the environment variable, as follows
setenv PJSIM_SYSCALL_LIB libsyscall.so.1
IAS or RTL looks for PJSIM_SYSCALL_LIB
; if it is set, it the loads
the functions from the specified library.