I will discuss the POK code and model written to contain the final RTEMS-POK-Partition-binary and changes and additions to the build system to generate the necessary library.
POK libpart
Up to now POK does not generate a library containing all object files of one partition, referring to everything in libpok.a and the user defined code (hello.c). This is done by adding a new makefile target called libpart.
It will build a library libpart.a containing all object files generated by the user code and all generated files from libpok.a and resides in each partitions directory.
However, up to now you have to add it by hand to part1/Makefile after invoking make in the projects root directory (rtems-guest), the ocarina run overwrites changes to any file in generated-code. Details in HelloWorld – describing the link process.
POK example code
I used the partitioned-threads example as a starting point for my rtems-guest code. Additionally the header files describing the RTEMS virtualization layer are copied, namely virtLayerBSP.h and virtLayerCPU.h. The model.aadl (model) is reduced to generate only one partition. The hello.c file includes the virtLayer*.h files and implements the defined functions.
Assuming that POK is configured and the $POK_PATH is set make will check model and user code and generate the partition and kernel accordingly.
To ensure that POK and RTEMS are using the same calling convention every function in the virtualization layer has the attribute fastcall.