KasperskyOS Community Edition 1.0

Entity startup

In this Help section

Einit entity

init.yaml file

Page top
[Topic entities_start]

Einit entity

One of the most important entities in KasperskyOS is the entity named Einit, which is the first entity started by the operating system kernel when the image is loaded. In most solutions built on KasperskyOS, the Einit entity starts all other entities included in the solution, which means that it serves as the initializing entity.

The toolkit provided in KasperskyOS Community Edition includes the einit tool, which lets you generate the code of the Einit entity in C based on the init.yaml file (also known as the init description). The Einit entity created using the einit script performs the following initializing functions:

  • creates all entities included in the solution;
  • creates required connections (IPC channels) between entities;
  • copies information about the entity's connections into the environment of each entity;
  • starts entities.

The standard way of using the einit tool is to integrate an einit call into one of the steps of the build script. As a result, the einit tool uses the init.yaml file to generate the einit.c file containing the Einit entity code. In one of the following steps of the build script, compile the einit.c file into the executable file of the Einit entity and include it into the solution image.

You are not required to create static description files for the Einit entity. These files are included in the KasperskyOS Community Edition toolkit and are automatically connected during a solution build. However, the Einit entity must be described in the security.psl file.

Page top
[Topic einit_entity]

init.yaml file

The init.yaml file (init description) is used by the einit tool to generate source code of the Einit initializing entity. This file contains data in YAML format. This data identifies the following:

  • Entities that are started when KasperskyOS is loaded.
  • IPC channels that are used by entities to interact with each other.

This data consists of a dictionary with the entities key containing a list of dictionaries of entities. Entity dictionary keys are presented in the table below.

Entity dictionary keys in an init description

Key

Required

Description

name

Yes

Name of the entity

task

No

Entity ID, which coincides with the entity name by default. Each entity must have a unique ID.

You can start multiple entities with the same name but different IDs.

path

No

Name of the executable file in ROMFS (in the solution image) from which the entity will be started. By default, the entity will be started from a file in ROMFS with a name that matches the short name of the entity. For example, the Client and net.Client entities will be started from the Client file by default.

You can start multiple entities with the same name from different executable files. However, the IDs of these entities must be different.

connections

No

Dictionary key containing a list of dictionaries of the IPC channels of the entity. This list defines the statically created IPC channels whose client handles will be owned by the entity. The list is empty by default. (In addition to statically created IPC channels, entities may use dynamically created IPC channels.)

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

Entity IPC channel dictionary keys in an init description

Key

Required

Description

id

Yes

IPC channel ID, which can be defined as a specific value or as a link such as

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

Each IPC channel must have a unique ID.

(The IPC channel ID is used by entities to receive an IPC handle.)

target

Yes

ID of the entity that will own the server handle of the IPC channel.

Example init descriptions

In the provided examples, the file containing the init description is named init.yaml, but it can have any name.

init.yaml

# init description of the solution containing the client entity and server entity

entities:

# The Client entity will send requests to the Server entity.

- name: Client

connections:

# ID of the server entity to which the Client entity will

# send requests

- target: Server

# ID of the IPC channel for exchanging IPC messages

# between entities

id: server_connection

# The Server entity will perform the server role

# (will respond to requests from the Client entity).

- name: Server

init.yaml

# init description in which the IPC channel ID is defined by a link

entities:

- name: Client

connections:

- target: Server

# IPC channel ID is in the SERVER_CONN constant

# in the src/example.h file

id: {var: SERVER_CONN, include: src/example.h}

- name: Server

init.yaml

# init description that defines the names of executable files that

# will be used to start the entities named Client, ClientServer and

# MainServer

entities:

- name: Client

path: cl

connections:

- target: ClientServer

id: server_connection_cs

- name: ClientServer

path: csr

connections:

- target: MainServer

id: server_connection_ms

- name: MainServer

path: msr

init.yaml

# init description in which the MainServer and BkServer entities

# will be started from one executable file

entities:

- name: Client

connections:

- id: server_connection_ms

target: MainServer

- id: server_connection_bs

target: BkServer

- name: MainServer

path: srv

- name: BkServer

path: srv

init.yaml

# init description that will start two

# Server entities with different IDs from the same executable

# file

entities:

- name: Client

connections:

- id: server_connection_us

# Server entity ID

target: UserServer

- id: server_connection_ps

# Server entity ID

target: PrivilegedServer

- task: UserServer

name: Server

- task: PrivilegedServer

name: Server

Page top
[Topic init_yaml_file]