Download STLite/OS20 Real-Time Kernel Reference Manual

Transcript
B Using RCUs with STLite/OS20
B Using RCUs with STLite/OS20
This appendix provides some guidelines on using STLite/OS20 with Relocatable
Code Units (RCUs). The appendix makes several recommendations in order to avoid
some potential problems.
This appendix does not discuss the loading and initialization of RCUs in general. For
this please see the ‘ST20 Embedded Toolset User Manual - 72-TDS-505’. This
manual also gives details of st20cc (the Embedded Toolset’s compile/link driver) and
the pragma ST_translate referred to in the sections which follow. The import and
export commands are described in the ‘ST20 Embedded Toolset Command
Language Reference Manual - 72-TDS-533’.
B.1
Recommendations
There are a number of recommendations which should be followed when using RCUs
with STLite/OS20.
B.1.1 STLite/OS20 kernel
Ensure that only one copy of the kernel is linked in. Many of the standard C run time
libraries can be linked into both the main application code, and the RCU, with no
problems. For simple functions, for example strlen, this may even be desirable, to
reduce the function call overhead at the expense of code size.
However, for STLite/OS20 it is vital that there is only one copy of the kernel running on
the processor. The easiest way to do this is to ensure that the application code (which
is run when the processor is booted and loads any RCUs) also starts STLite/OS20.
Any RCUs should only ever import STLite/OS20 functions from the application.
Note: that the st20cc -runtime os20 option can still be used with the st20cc
-rcu or -dl options. The linker scripts are written so that when used with an RCU,
run time libraries are never linked in.
B.1.2 Passing function pointers
Problems can occur when passing function pointers between RCUs and the application. This is because while the pointer is valid in all cases, it needs to be called with
the correct static link. In particular this is a problem with some STLite/OS20 functions
which take a function pointer as an argument. To overcome this a number of additional
functions have been provided, which take a static link as well as function pointer:
task_init_sl
task_create_sl
task_onexit_set_sl
interrupt_install_sl
These are all described in the appropriate chapters of the manual (Chapter 5 and
Chapter 9).
253