Posix SDK: Difference between revisions
No edit summary |
|||
(92 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
= | = Introduction = | ||
The SDK | The Posix SDK is a platform-specific package that contains the STRIDE Runtime source and [[Platform_Abstraction_Layer|PAL]] implementation, along with integration tools to build a stride library and a strideDaemon and a TestApp applications. It is intended for this article to be used as a reference. | ||
=Target Makefile= | |||
The ''' | The SDK makefile provides targets for building the [[Runtime Reference|STRIDE Runtime]] library and two executable applications - a strideDaemon (for a [[#Multiprocess_Application_Integration|multiprocess]] application environment), and an TestApp (see [[Building_an_Off-Target_Test_App|this]] for more information). | ||
The default make target builds the STRIDE Runtime library. When a multiprocess runtime library is specified (see RTSINGLEPROC below), and a strideDaemon executable build as well. To build the test application, specify the '''testapp''' make target. | |||
The '''testapp''' target compiles SCL source markup present in the Runtime source and therefore requires that the [[Build Tools]] be installed on your system and in your executable search path. | |||
===Configuration=== | ===Configuration=== | ||
The behavior of the makefile can be affected by setting certain make variable parameters. For example, the following make invocation will change the value of the TOOLCHAIN and DEBUG variables when making: | The behavior of the makefile can be affected by setting certain make variable parameters. For example, the following make invocation will change the value of the TOOLCHAIN and DEBUG variables when making: | ||
<source lang="bash"> | |||
cd ~/stride/SDK/Posix/src | |||
make TOOLCHAIN=arm DEBUG=1 | |||
</source> | |||
The following variable are intended to be specified or overridden as needed: | The following variable are intended to be specified or overridden as needed: | ||
Line 17: | Line 23: | ||
====TOOLCHAIN==== | ====TOOLCHAIN==== | ||
The default compiler toolchain when TOOLCHAIN is set to ''' | The default compiler toolchain when TOOLCHAIN is set to '''x86''' is gcc/g++/ar, which are assumed to be in your path. For any other TOOLCHAIN value, the toolchain tools are $(TOOLCHAIN)-linux-gcc/g++/ar where $(TOOLCHAIN) is replaced by the specified TOOLCHAIN setting. If your toolchain does not fit this pattern, you will need to modify the makefile or explicitly override values for CC, CPP, and AR. | ||
====LIBRARYTYPE==== | ====LIBRARYTYPE==== | ||
Line 29: | Line 35: | ||
====RTSINGLEPROC==== | ====RTSINGLEPROC==== | ||
The default configuration compiles the runtime library with multiprocess support. If you | The default configuration, set to '''1''', compiles the runtime library with no multiprocess support. If you want [[#Multiprocess_Application_Integration|multiprocess]] functionality, you can enable this by explicitly setting this value to '''0'''. | ||
====STANDALONE_TESTAPP==== | |||
The default configuration, set to '''1''', builds the TestApp as a [[#Standalone_Application_Integration|standalone]] application. When set to '''0''' the TestApp is built as a [[#Multiprocess_Application_Integration|multiprocess]] application. <br> | |||
The STANDALONE_TESTAPP variable is affected by the value of RTSINGLEPROC. If RTSINGLEPROC is '''1''' and STANDALONE_TESTAPP is '''0''', this is an invalid combination and STANDALONE_TESTAPP will automatically be set to '''1'''. | |||
====S2SCOPTS==== | ====S2SCOPTS==== | ||
The STRIDE build process that produces the database and [[Intercept Module]] for the | The STRIDE build process that produces the database and [[Intercept Module]] for the test application relies on target settings. These settings are passed as options to the stride compiler and are most conveniently stored in an options file. We provide a default options file with target settings that are appropriate for x86 Linux targets with GNU compilers -- this file is ''SDK/Posix/settings/stride.s2scompile'' in the SDK distribution. | ||
We recommend that you make a copy of this file and adjust the settings as appropriate for your target. You can then set this variable - '''S2SCOPTS''' to the path to your settings file. This will cause the make process to use the specified target settings options instead of the default one provided in the SDK. This same settings file should ultimately be used for the STRIDE build integration with your application source code. | We recommend that you make a copy of this file and adjust the settings as appropriate for your target. You can then set this variable - '''S2SCOPTS''' to the path to your settings file. This will cause the make process to use the specified target settings options instead of the default one provided in the SDK. This same settings file should ultimately be used for the STRIDE build integration with your application source code. | ||
== | ===S2 Build Flags=== | ||
The target Makefile sets the following Build Tool flags: | |||
<pre> | |||
S2_BIND_FLAGS = --starting_suid=7000 | |||
S2_IM_FLAGS = --disable_access_class | |||
</pre> | |||
The | The [[S2sbind#Options|s2sbind]] and [[S2sinstrument#Options|s2sinstrument]] flags are combined so that the test application only registers for test message IDs that are created in a higher range so that it doesn't conflict with other application processes. | ||
===Makefile Targets=== | |||
The makefile included with the SDK supports the following targets: | |||
;all | |||
: builds the runtime library and daemon | |||
;library | |||
: builds the runtime library | |||
;daemon | |||
: builds ''library'' and--if RTSINGLEPRC is not zero--the STRIDE daemon | |||
;im | |||
: builds the STRIDE database and generates IM files | |||
;testapp | |||
:builds ''library'', ''im'' and instrumented test application | |||
;clean | |||
:removes all generated files | |||
=Target API (stride.h)= | |||
The Posix SDK provides a simplified application interface for initializing the STRIDE subsystem and starting STRIDE messaging and IM threads. The API includes the following routines: | |||
===srBOOL strideInit(const strideIO_t * io)=== | ===srBOOL strideInit(const strideIO_t * io)=== | ||
This function initializes the STRIDE subsystem. The IO configuration is passed in as an argument. If this argument is NULL, then the process will attempt to attach to an already running runtime application (daemon) using shared memory for IPC. | This function initializes the STRIDE subsystem. The IO configuration is passed in as an argument. If this argument is NULL, then the process will attempt to attach to an already running runtime application (daemon) using shared memory for IPC. This function should only be called once per application and should be match with a call to <tt>strideUninit()</tt>. | ||
===srBOOL strideUninit(void)=== | ===srBOOL strideUninit(void)=== | ||
Line 49: | Line 84: | ||
Terminates any threads that have been started with this API and uninitializes the STRIDE subsystem. | Terminates any threads that have been started with this API and uninitializes the STRIDE subsystem. | ||
===srBOOL strideCreateThread(strideThreadFunc_t entry, const srCHAR * name)=== | ===srBOOL strideCreateThread(strideThreadFunc_t entry, const srCHAR * name, void* param)=== | ||
Creates a thread to be managed by the STRIDE subsystem. Threads created using this routine will be sent a palSTOP_EVENT notification (available from palWait) and should respond promptly to this event. The name parameter is used primarily for logging purposes. | Creates a thread to be managed by the STRIDE subsystem. Threads created using this routine will be sent a palSTOP_EVENT notification (available from palWait) and should respond promptly to this event. The name parameter is used primarily for logging purposes. | ||
Line 55: | Line 90: | ||
===strideCreateIMThread(name)=== | ===strideCreateIMThread(name)=== | ||
This is a macro that wraps the invocation of | This is a macro that wraps the invocation of <tt>strideCreateThread()</tt> for intercept module entry point functions. Only the IM name must be provided. | ||
===void strideStopThread(srDWORD id)=== | |||
Signals a thread to stop (sends palSTOP_EVENT) and joins it. | |||
===void strideExWaitForExit(void)=== | ===void strideExWaitForExit(void)=== | ||
This function can be called by the main application thread to block until a termination signal is received. Internally it uses the pause function to wait for signals to be delivered and then checks if termination has occurred. | This function can be called by the main application thread to block until a termination signal ([http://en.wikipedia.org/wiki/SIGTERM SIGTERM]) is received. Internally it uses the pause function to wait for signals to be delivered and then checks if termination has occurred. | ||
''This function is optional - if you block some other way (e.g. create the application's message loop) do not call this function.'' | |||
===void | ===void strideExBlockExitSignals(srBOOL enable)=== | ||
This | This function can be called by the main application thread to block termination signals ([http://en.wikipedia.org/wiki/SIGTERM SIGTERM]). | ||
''This function is optional - if you manage your termination signals behaviour do not call this function.'' | |||
=Target Integration= | |||
Here are a few examples of how to integrate the stride API into your application. | Here are a few examples of how to integrate the stride API into your application. | ||
''' | '''NOTE:''' The following code assumes that the intercept module was generated with a name of ''myintercept''. Change all references to that name in your code to the chosen intercept module name. | ||
===Standalone Application Integration=== | ===Standalone Application Integration=== | ||
The following code demonstrates how to integrate your application with the STRIDE Runtime. Your application might require other logic at startup - you can integrate the following calls according to your needs. Note that this code initializes the STRIDE subsystem and assumes a single standalone process that creates the STRIDE system threads as well as application threads. | The following code demonstrates how to integrate your application with the STRIDE Runtime. Your application might require other logic at startup - you can integrate the following calls according to your needs. Note that this code initializes the STRIDE subsystem and assumes a single standalone process that creates the STRIDE system threads as well as application threads. | ||
<source lang="c"> | <source lang="c"> | ||
Line 80: | Line 122: | ||
#include <unistd.h> | #include <unistd.h> | ||
#include <stride.h> | #include <stride.h> | ||
#include | #include "myinterceptIMEntry.h" | ||
int main(int argc, char **argv) | int main(int argc, char **argv) | ||
{ | { | ||
/* initialize the STRIDE subsytem using default I/O */ | |||
#ifdef __cplusplus | |||
strideIO_t io = {strideIO_t::strideDEFAULT}; | |||
#else | |||
strideIO_t io = {strideDEFAULT}; | strideIO_t io = {strideDEFAULT}; | ||
#endif | |||
if (strideInit(&io) != srTRUE) | if (strideInit(&io) != srTRUE) | ||
return -1; | return -1; | ||
/* start all IM threads */ | |||
if (strideCreateIMThread(myintercept) != srTRUE) | if (strideCreateIMThread(myintercept) != srTRUE) | ||
return -1; | return -1; | ||
strideExWaitForExit(); | /* application code here */ | ||
strideExWaitForExit(); /* or block some other way (e.g. application's message loop) */ | |||
/* stop all IM threads and uninitialize STRIDE subsystem */ | |||
strideUninit(); | strideUninit(); | ||
return 0; | return 0; | ||
} | } | ||
</source> | </source> | ||
This sample code assumes you have generated your Intercept Module with a prefix name of '''myintercept'''. | |||
<u>''NOTE:''</u> If you need to provide additional message processing threads, you can call <tt>strideCreateThread()</tt> for each additional thread that you wish to add (this must be called prior to your application code). | |||
===Multiprocess Application Integration=== | ===Multiprocess Application Integration=== | ||
This code demonstrates how to integrate your application with the STRIDE Runtime in multiprocess mode. The only difference with the | This code demonstrates how to integrate your application with the STRIDE Runtime in multiprocess mode. In this mode, the pre-packaged strideDaemon runs simultaneously with the application and provides the STRIDE IO and runtime thread initialization. The host communicates with the application process through the strideDaemon (or another STRIDE IO process). In this sample, the only difference with the preceding sample is the call to strideInit which, in this case, specifies no IO parameters which indicates to the API that the communication and runtime threads should not be started. | ||
<source lang="c"> | <source lang="c"> | ||
Line 106: | Line 160: | ||
#include <unistd.h> | #include <unistd.h> | ||
#include <stride.h> | #include <stride.h> | ||
#include | #include "myinterceptIMEntry.h" | ||
int main(int argc, char **argv) | int main(int argc, char **argv) | ||
{ | { | ||
if (strideInit(NULL) != srTRUE) | if (strideInit(NULL) != srTRUE) | ||
return -1; | return -1; | ||
Line 118: | Line 171: | ||
strideExWaitForExit(); | strideExWaitForExit(); | ||
strideUninit(); | strideUninit(); | ||
return 0; | return 0; | ||
Line 123: | Line 177: | ||
</source> | </source> | ||
==Linux PAL | ===Kernel Module Integration=== | ||
The following code demonstrates how to integrate your kernel space module with the STRIDE Runtime. Your module might require other logic at startup - you can integrate the following calls according to your needs. | |||
'''NOTE:''' You need to also have an active user space STRIDE enabled application (see [[#Standalone_Application_Integration | above]]) that runs the core STRIDE Runtime and IO services. That application also must be built with <tt>-DPAL_KERNEL_UDP_PORT=nnnn</tt>, where the "nnnn" matches the value defined below. | |||
====Linux==== | |||
<source lang="c"> | |||
#include <linux/module.h> | |||
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED | |||
#define PAL_KERNEL_UDP_PORT 8888 /* value should match whatever is defined in the "user" STRIDE Runtime */ | |||
#include <stride.c> /* that's right, directly include the source file */ | |||
#endif /* STRIDE_ENABLED */ | |||
int init_module(void) | |||
{ | |||
... | |||
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED | |||
strideInit(NULL); | |||
#endif /* STRIDE_ENABLED */ | |||
... | |||
return 0; | |||
} | |||
void cleanup_module(void) | |||
{ | |||
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED | |||
strideUninit(); | |||
#endif /* STRIDE_ENABLED */ | |||
... | |||
} | |||
</source> | |||
You don't need to compile any other source nor to link to any other library. Just make sure you pass the following extra flags to your compiler: | |||
<pre> | |||
EXTRA_CFLAGS += -DSTRIDE_ENABLED=1 -I"$(STRIDE_DIR)/SDK/Posix/src" -I"$(STRIDE_DIR)/SDK/Runtime" | |||
</pre> | |||
====FreeBSD==== | |||
<source lang="c"> | |||
#include <sys/module.h> | |||
#include <sys/kernel.h> | |||
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED | |||
#define PAL_KERNEL_UDP_PORT 8888 /* value should match whatever is defined in the "user" STRIDE Runtime */ | |||
#include <stride.c> /* that's right, directly include the source file */ | |||
#endif /* STRIDE_ENABLED */ | |||
/* The function called at load/unload. */ | |||
static int event_handler(struct module *module, int event, void *arg) { | |||
int e = 0; /* Error, 0 for normal return status */ | |||
switch (event) { | |||
case MOD_LOAD: | |||
... | |||
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED | |||
strideInit(NULL); | |||
#endif /* STRIDE_ENABLED */ | |||
... | |||
break; | |||
case MOD_UNLOAD: | |||
... | |||
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED | |||
strideUninit(); | |||
#endif /* STRIDE_ENABLED */ | |||
... | |||
break; | |||
default: | |||
e = EOPNOTSUPP; /* Error, Operation Not Supported */ | |||
break; | |||
} | |||
return(e); | |||
} | |||
</source> | |||
You don't need to compile any other source nor to link to any other library. Just make sure you pass the following extra flags to your compiler: | |||
<pre> | |||
CFLAGS += -DSTRIDE_ENABLED=1 -I"$(STRIDE_DIR)/SDK/Posix/src" -I"$(STRIDE_DIR)/SDK/Runtime" | |||
</pre> | |||
=Posix PAL= | |||
===PAL Configuration (palcfg.h)=== | ===PAL Configuration (palcfg.h)=== | ||
The following parameters can be configured in ''palcfg.h'' to effect the behavior of the compiled pal source files. | The following parameters can be configured in ''palcfg.h'' to effect the behavior of the compiled pal source files. | ||
; PAL_DEFAULT_DEVICE_NAME : default IO device to use. | ; PAL_DEFAULT_DEVICE_NAME : default IO device to use. | ||
; PAL_MAX_THREADS : max STRIDE integrated threads that can be managed by the STRIDE API. | ; PAL_MAX_THREADS : max STRIDE integrated threads that can be managed by the STRIDE API. | ||
; PAL_MAX_TIMERS : max STRIDE timers that can be active in the system. | ; PAL_MAX_TIMERS : max STRIDE timers that can be active in the system. | ||
Latest revision as of 18:52, 10 December 2020
Introduction
The Posix SDK is a platform-specific package that contains the STRIDE Runtime source and PAL implementation, along with integration tools to build a stride library and a strideDaemon and a TestApp applications. It is intended for this article to be used as a reference.
Target Makefile
The SDK makefile provides targets for building the STRIDE Runtime library and two executable applications - a strideDaemon (for a multiprocess application environment), and an TestApp (see this for more information).
The default make target builds the STRIDE Runtime library. When a multiprocess runtime library is specified (see RTSINGLEPROC below), and a strideDaemon executable build as well. To build the test application, specify the testapp make target.
The testapp target compiles SCL source markup present in the Runtime source and therefore requires that the Build Tools be installed on your system and in your executable search path.
Configuration
The behavior of the makefile can be affected by setting certain make variable parameters. For example, the following make invocation will change the value of the TOOLCHAIN and DEBUG variables when making:
cd ~/stride/SDK/Posix/src
make TOOLCHAIN=arm DEBUG=1
The following variable are intended to be specified or overridden as needed:
TOOLCHAIN
The default compiler toolchain when TOOLCHAIN is set to x86 is gcc/g++/ar, which are assumed to be in your path. For any other TOOLCHAIN value, the toolchain tools are $(TOOLCHAIN)-linux-gcc/g++/ar where $(TOOLCHAIN) is replaced by the specified TOOLCHAIN setting. If your toolchain does not fit this pattern, you will need to modify the makefile or explicitly override values for CC, CPP, and AR.
LIBRARYTYPE
The default behavior of the makefile is to build the STRIDE Runtime as a static library. If you prefer a shared library, set this value to '.so'.
DEBUG
The default configuration compiles with optimization and NDEBUG defined. If you prefer debuggable binaries, set this value to 1.
RTSINGLEPROC
The default configuration, set to 1, compiles the runtime library with no multiprocess support. If you want multiprocess functionality, you can enable this by explicitly setting this value to 0.
STANDALONE_TESTAPP
The default configuration, set to 1, builds the TestApp as a standalone application. When set to 0 the TestApp is built as a multiprocess application.
The STANDALONE_TESTAPP variable is affected by the value of RTSINGLEPROC. If RTSINGLEPROC is 1 and STANDALONE_TESTAPP is 0, this is an invalid combination and STANDALONE_TESTAPP will automatically be set to 1.
S2SCOPTS
The STRIDE build process that produces the database and Intercept Module for the test application relies on target settings. These settings are passed as options to the stride compiler and are most conveniently stored in an options file. We provide a default options file with target settings that are appropriate for x86 Linux targets with GNU compilers -- this file is SDK/Posix/settings/stride.s2scompile in the SDK distribution.
We recommend that you make a copy of this file and adjust the settings as appropriate for your target. You can then set this variable - S2SCOPTS to the path to your settings file. This will cause the make process to use the specified target settings options instead of the default one provided in the SDK. This same settings file should ultimately be used for the STRIDE build integration with your application source code.
S2 Build Flags
The target Makefile sets the following Build Tool flags:
S2_BIND_FLAGS = --starting_suid=7000 S2_IM_FLAGS = --disable_access_class
The s2sbind and s2sinstrument flags are combined so that the test application only registers for test message IDs that are created in a higher range so that it doesn't conflict with other application processes.
Makefile Targets
The makefile included with the SDK supports the following targets:
- all
- builds the runtime library and daemon
- library
- builds the runtime library
- daemon
- builds library and--if RTSINGLEPRC is not zero--the STRIDE daemon
- im
- builds the STRIDE database and generates IM files
- testapp
- builds library, im and instrumented test application
- clean
- removes all generated files
Target API (stride.h)
The Posix SDK provides a simplified application interface for initializing the STRIDE subsystem and starting STRIDE messaging and IM threads. The API includes the following routines:
srBOOL strideInit(const strideIO_t * io)
This function initializes the STRIDE subsystem. The IO configuration is passed in as an argument. If this argument is NULL, then the process will attempt to attach to an already running runtime application (daemon) using shared memory for IPC. This function should only be called once per application and should be match with a call to strideUninit().
srBOOL strideUninit(void)
Terminates any threads that have been started with this API and uninitializes the STRIDE subsystem.
srBOOL strideCreateThread(strideThreadFunc_t entry, const srCHAR * name, void* param)
Creates a thread to be managed by the STRIDE subsystem. Threads created using this routine will be sent a palSTOP_EVENT notification (available from palWait) and should respond promptly to this event. The name parameter is used primarily for logging purposes.
strideCreateIMThread(name)
This is a macro that wraps the invocation of strideCreateThread() for intercept module entry point functions. Only the IM name must be provided.
void strideStopThread(srDWORD id)
Signals a thread to stop (sends palSTOP_EVENT) and joins it.
void strideExWaitForExit(void)
This function can be called by the main application thread to block until a termination signal (SIGTERM) is received. Internally it uses the pause function to wait for signals to be delivered and then checks if termination has occurred.
This function is optional - if you block some other way (e.g. create the application's message loop) do not call this function.
void strideExBlockExitSignals(srBOOL enable)
This function can be called by the main application thread to block termination signals (SIGTERM).
This function is optional - if you manage your termination signals behaviour do not call this function.
Target Integration
Here are a few examples of how to integrate the stride API into your application.
NOTE: The following code assumes that the intercept module was generated with a name of myintercept. Change all references to that name in your code to the chosen intercept module name.
Standalone Application Integration
The following code demonstrates how to integrate your application with the STRIDE Runtime. Your application might require other logic at startup - you can integrate the following calls according to your needs. Note that this code initializes the STRIDE subsystem and assumes a single standalone process that creates the STRIDE system threads as well as application threads.
#include <stdlib.h>
#include <unistd.h>
#include <stride.h>
#include "myinterceptIMEntry.h"
int main(int argc, char **argv)
{
/* initialize the STRIDE subsytem using default I/O */
#ifdef __cplusplus
strideIO_t io = {strideIO_t::strideDEFAULT};
#else
strideIO_t io = {strideDEFAULT};
#endif
if (strideInit(&io) != srTRUE)
return -1;
/* start all IM threads */
if (strideCreateIMThread(myintercept) != srTRUE)
return -1;
/* application code here */
strideExWaitForExit(); /* or block some other way (e.g. application's message loop) */
/* stop all IM threads and uninitialize STRIDE subsystem */
strideUninit();
return 0;
}
This sample code assumes you have generated your Intercept Module with a prefix name of myintercept.
NOTE: If you need to provide additional message processing threads, you can call strideCreateThread() for each additional thread that you wish to add (this must be called prior to your application code).
Multiprocess Application Integration
This code demonstrates how to integrate your application with the STRIDE Runtime in multiprocess mode. In this mode, the pre-packaged strideDaemon runs simultaneously with the application and provides the STRIDE IO and runtime thread initialization. The host communicates with the application process through the strideDaemon (or another STRIDE IO process). In this sample, the only difference with the preceding sample is the call to strideInit which, in this case, specifies no IO parameters which indicates to the API that the communication and runtime threads should not be started.
#include <stdlib.h>
#include <unistd.h>
#include <stride.h>
#include "myinterceptIMEntry.h"
int main(int argc, char **argv)
{
if (strideInit(NULL) != srTRUE)
return -1;
if (strideCreateIMThread(myintercept) != srTRUE)
return -1;
strideExWaitForExit();
strideUninit();
return 0;
}
Kernel Module Integration
The following code demonstrates how to integrate your kernel space module with the STRIDE Runtime. Your module might require other logic at startup - you can integrate the following calls according to your needs.
NOTE: You need to also have an active user space STRIDE enabled application (see above) that runs the core STRIDE Runtime and IO services. That application also must be built with -DPAL_KERNEL_UDP_PORT=nnnn, where the "nnnn" matches the value defined below.
Linux
#include <linux/module.h>
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED
#define PAL_KERNEL_UDP_PORT 8888 /* value should match whatever is defined in the "user" STRIDE Runtime */
#include <stride.c> /* that's right, directly include the source file */
#endif /* STRIDE_ENABLED */
int init_module(void)
{
...
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED
strideInit(NULL);
#endif /* STRIDE_ENABLED */
...
return 0;
}
void cleanup_module(void)
{
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED
strideUninit();
#endif /* STRIDE_ENABLED */
...
}
You don't need to compile any other source nor to link to any other library. Just make sure you pass the following extra flags to your compiler:
EXTRA_CFLAGS += -DSTRIDE_ENABLED=1 -I"$(STRIDE_DIR)/SDK/Posix/src" -I"$(STRIDE_DIR)/SDK/Runtime"
FreeBSD
#include <sys/module.h>
#include <sys/kernel.h>
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED
#define PAL_KERNEL_UDP_PORT 8888 /* value should match whatever is defined in the "user" STRIDE Runtime */
#include <stride.c> /* that's right, directly include the source file */
#endif /* STRIDE_ENABLED */
/* The function called at load/unload. */
static int event_handler(struct module *module, int event, void *arg) {
int e = 0; /* Error, 0 for normal return status */
switch (event) {
case MOD_LOAD:
...
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED
strideInit(NULL);
#endif /* STRIDE_ENABLED */
...
break;
case MOD_UNLOAD:
...
#if defined(STRIDE_ENABLED) && STRIDE_ENABLED
strideUninit();
#endif /* STRIDE_ENABLED */
...
break;
default:
e = EOPNOTSUPP; /* Error, Operation Not Supported */
break;
}
return(e);
}
You don't need to compile any other source nor to link to any other library. Just make sure you pass the following extra flags to your compiler:
CFLAGS += -DSTRIDE_ENABLED=1 -I"$(STRIDE_DIR)/SDK/Posix/src" -I"$(STRIDE_DIR)/SDK/Runtime"
Posix PAL
PAL Configuration (palcfg.h)
The following parameters can be configured in palcfg.h to effect the behavior of the compiled pal source files.
- PAL_DEFAULT_DEVICE_NAME
- default IO device to use.
- PAL_MAX_THREADS
- max STRIDE integrated threads that can be managed by the STRIDE API.
- PAL_MAX_TIMERS
- max STRIDE timers that can be active in the system.