Kernel Overview

Overview

The OpenHarmony LiteOS-M kernel is a lightweight operating system (OS) kernel designed for the IoT field. It features small size, low power consumption, and high performance. The LiteOS-M kernel has simple code structure, including the minimum function set, kernel abstraction layer, optional components, and project directory.

The OpenHarmony LiteOS-M kernel architecture consists of the hardware layer and the hardware-irrelevant layers, as shown in Figure Kernel architecture.

The hardware layer is classified based on the compilation toolchain and chip architecture, and provides a unified Hardware Abstraction Layer (HAL) interface to improve hardware adaptation and facilitate the expansion of various types of &IoT hardware and compilation toolchains. The basic kernel provides basic kernel capabilities. The extended modules provide capabilities of components, such as network and file systems, as well as exception handling and debug tools. The Kernel Abstraction Layer (KAL) provides unified standard APIs.

Figure 1 Kernel architecture

CPU Architecture Support

The CPU architecture includes two layers: general architecture definition layer and specific architecture definition layer. The former provides interfaces supported and implemented by all architectures. The latter is specific to an architecture. For a new architecture to be added, the general architecture definition layer must be implemented first and the architecture-specific functions can be implemented at the specific architecture definition layer.

Table 1 CPU architecture rules

Rule

General Architecture Definition Layer

Specific Architecture Definition Layer

Header file location

kernel/arch/include

kernel/arch/<arch>/<arch>/<toolchain>/

Header file name

los_<function>.h

los_arch_<function>.h

Function name

Halxxxx

Halxxxx

LiteOS-M supports mainstream architectures, such as ARM Cortex-M3, ARM Cortex-M4, ARM Cortex-M7, ARM Cortex-M33, and RISC-V. If you need to expand the CPU architecture, see Chip Architecture Adaptation.

Working Principles

Configure the system clock and number of ticks per second in the target_config.h file of the development board. Configure the task, memory, inter-process communication (IPC), and exception handling modules based on service requirements. When the system boots, the modules are initialized based on the configuration. The kernel startup process includes peripheral initialization, system clock configuration, kernel initialization, and OS boot. For details, see Figure 2.

Figure 2 Kernel startup process