Directory and file organization - nradulovic/esolid-kernel GitHub Wiki

Intro

The directory structure of eSolid RT Kernel is fairly easy to understand. Once the organization of directories and files is understood it is fairly easy to integrate eSolid RT Kernel into application.

What is a port?

Porting is a process of adapting software to an architecture that is different from the one for which it was originally designed. The term is also used when software is changed to make it usable in different environments. Software is portable when the cost of porting it to a new platform is less than the cost of writing it from beginning.

Code Sections

The kernel is divided into three sections. One section is port independent code, the second one is port dependent code and the third sections is code templates.

Port independent code

Port independent code is the code which does not change from port to port, e.g. when the CPU is changed this code is not changed at all and it is still correctly executed. Code can be developed and tested on another machine, which greatly reduces design efforts. It provides API and some common data structures. Port independent code lives under /inc and /src directories:

  • inc/kernel.h
  • inc/kernel_cfg.h
  • src/kernel.c

Port dependent code

Second section is the port dependent code. This code provides low-level functions which are needed to interact with interrupt controllers, manipulate CPU settings and do the context switching. They are highly CPU/compiler bounded and are often written in assembly language.

Each port has it's name which is also the name of directory which holds all the port files. Usually each port has some kind of variant. In that case each variant is a subdirectory of the containing port. Common code for all variants will be in common subdirectory. Each eSolid RT Kernel port will have at least the following files:

  • port/[port_name]/common/compiler.h
  • port/[port_name]/[variant_name]/cpu_cfg.h
  • port/[port_name]/[variant_name]/cpu.h
  • port/[port_name]/[variant_name]/cpu.c

Port dependent code is separately described in documentation for relevant port.

Template and example code

Templates are some predefined configuration settings for various scenarios where eSolid RT Kernel can be used. Templates also contain some example code for how to write new ports.

In the example below is given Generic template which holds files with default configuration settings and some example code for new ports. New port files are in template/generic/port directory. When porting to a new architecture/compiler use provided template files for starters. This will greatly reduce the time needed to become familiar with the kernel port requirements. Generic template files are the following:

  • template/generic/port/compiler.h
  • template/generic/port/cpu_cfg.h
  • template/generic/port/cpu.h
  • template/generic/port/cpu.c
  • template/generic/kernel_cfg.h