SicsInitializer


New Initialization Scheme for SICS

The idea behind this scheme is, to have to edit only one list when adding a new feature. The aim is not to make the source code shorter. In fact, the initialization code is just moved from a central place to the modules. The main goal is to have a better structure of the code, which should be easier to maintain, and less error-prone.

Let us look at the difference when adding a command or driver. Before using this scheme, there were many different places in psi/psi.c where modifications had to be added:

when adding a new command:

when adding a new driver:

With the new scheme, for a module one has one init function, with prototype "void (void)" placed in the source file of the module. In this function, you call AddCmd, AddIniCmd or AddCommand(SCinter.h) to insert a standalone command, startup command or an object command. To create a new driver, use either the MakeDriver function, if you want to use the MakeObject command to create the driver, or the functions MakeInitializer/GetInitializer, if you want to do use an other factory command (see initializer.h). The init function has to be added to the system by inserting one line to the SiteInit (psi.c) or InitGeneral (ofac.c) function.

Suggestion by Markus Zolliker

At present, only the new stuff I inserted uses this scheme. I propose to move to the new scheme during next shutdown.

ofac.c:

psi.c:

These modifications will not change the behaviour of SICS.