Services Framework

The Services Framework provides a convenient way for independent modules to provide static, compile-time hooks that can be used by other modules. For example, a module might provide a hook that gets called whenever a certain event occurs.

Modules that make use of a given hook can specify a call to a function the module provides, to be executed whenever the hook is called.

This framework enables independent modules to make use of each other’s functionality without the need for dynamic, run-time registration of callbacks, event listeners, or similar mechanisms.

Service Descriptions

Service descriptions are contained in a YAML-file named SVCID.svc, where SVCID is a short, unique service identifier for the module.

The service description contains the source files of the module, the hooks the module provides, and code snippets for any hooks that the module uses.


  - ui/uisvc.c

  - void button (int)

hook.exti_irq: button_exti

The service in this example provides a hook called button with the signature void (*) (int), while making use of the exti_irq hook which must be provided by another module. The function button_exti(...) will be executed whenever the exti_irq hook is called.

Build Process

To make use of a service module, add the corresponding service identifier to the SVCS list in the project Makefile.

The build environment will search the services directory and the project directory for service description files.

The information gathered from the service descriptions is then used by the service tool to generate the svcdefs.h header file. This header file is populated with macros containing the code that is executed when the hook is called.

Furthermore, all source files specified in the service descriptions will be added to the build.

Some modules may provide APIs to be used by other modules or applications. For this purpose, the services directory is added to the include-path during the build process. This allows API header files to be easily included.


See the test-service project for an example on how an application might make use of services.