Overview: Einit and init.yaml

Einit initializing program

When a solution is started, the KasperskyOS kernel finds the executable file named Einit (initializing program) in the solution image and runs this executable file. The initializing program performs the following operations:

A process of the initializing program belongs to the Einit class.

The KasperskyOS SDK includes the einit tool, which generates the C-language source code of the initializing program. This tool is used by the CMake build system, which also compiles the einit.c file into the Einit executable file and includes this executable in the solution image.

You are not required to create formal specification files for the initializing program. These files are automatically generated and applied when building the solution. However, the Einit process class must be specified in the solution security policy description.

The einit tool generates the source code of the initializing program based on the formal specifications of solution components and the init description, which consists of a text file that is usually named init.yaml.

Init description (init.yaml)

An init description contains data in YAML format. This data identifies the following:

This data consists of a dictionary with the entities key containing a list of dictionaries of processes (see Example init descriptions). Process dictionary keys are presented in the table below.

You can create an init description manually or automatically. In the second case, you need to prepare the init.yaml.in template from which the build system will create an init description.

Process dictionary keys in an init description

Key

Required

Value

name

Yes

Process class name (from the EDL description).

task

No

Process name. If this name is not specified, the process class name will be used. Each process must have a unique name.

You can start multiple processes of the same class if they have different names.

path

No

Name of the executable file in ROMFS (in the solution image). If this name is not specified, the process class name (without prefixes and dots) will be used. For example, processes of the Client and net.Client classes for which an executable file name is not specified will be started from the Client file.

You can start multiple processes from the same executable file.

connections

No

Process IPC channel dictionaries list. This list defines the statically created IPC channels whose client IPC handles will be owned by the process. The list is empty by default. (In addition to statically created IPC channels, processes can also use dynamically created IPC channels.)

args

No

List of program startup parameters (main() function parameters). The maximum size of one item on the list is 1024 bytes.

env

No

Dictionary of program environment variables. The keys in this dictionary are the names of environment variables. The maximum size of an environment variable value is 65524 bytes.

before

No

Determines the order in which processes are started. You must specify a list of names of processes that should be started after starting this process.

after

No

Determines the order in which processes are started. You must specify a list of names of processes that must be started before starting this process.

wait_for

No

Sign used to determine that the process has started successfully.

Syntax options:

wait_for: <event_name>

or

wait_for:

event: <event_name>

timeout: <timeout_value><timeout_suffix>

or

wait_for: { event: <event_name>, timeout: <timeout_value><timeout_suffix> }

Parameter <event_name> can take the following values:

  • start – wait for the main() function to start.
  • ready – wait for the em_notify_ready() signal from the running process. The function is declared in the header file sysroot-*-kos/include/em_transport/em_transport.h.
  • exit_success – wait for the successful completion of the process.

The <timeout_value> parameter is an integer representing the time to wait for a sign of successful startup of the process. Default value: 3 minutes.

The <timeout_suffix> parameter is specified without a space after the <timeout_value> parameter and can take the following values:

  • ms, msec – milliseconds
  • s, sec – seconds
  • m, min – minutes

Usage examples:

wait_for: ready

wait_for: { event: ready, timeout: 100ms }

wait_for:

event: ready

timeout: 100ms

For more details, refer to Example init descriptions.

Process IPC channel dictionary keys are presented in the table below.

IPC channel dictionary keys in an init description

Key

Required

Value

id

Yes

IPC channel name, which can be set as a fixed value or as a link such as

{var: <constant name>, include: <path to header file>}.

target

Yes

Name of the process that will own the server handle of the IPC channel.

The init description may also contain the mount_romfs key, which specifies the name of the mount point of the additional romfs.1 file system before starting the processes. This allows you to start processes from binary files located in the romfs.1 file system. The romfs.1 file system will be unmounted after the Einit process ends. Usage example:

mount_romfs:

"romfs.1": "romfs/1"

Page top