• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Overview<a name="EN-US_TOPIC_0000001153842840"></a>
2
3-   [Porting Scenario](#section93781277367)
4-   [Directory Specifications](#section18127744153119)
5-   [Chip Architecture Adaptation](#section137431650339)
6
7## Porting Scenario<a name="section93781277367"></a>
8
9The chip architecture adaptation process is optional. If the particular chip architecture is supported in the  **liteos\_m/kernel/arch**  directory, you can directly implement the board adaptation. Otherwise, chip architecture porting is required.
10
11## Directory Specifications<a name="section18127744153119"></a>
12
13The kernel used by module chips is LiteOS Cortex-M, which consists of four modules, namely kernel abstraction layer \(KAL\), components, kernel, and utils.
14
15-   **KAL**: provides APIs exposed externally and depends on the components and kernel modules.
16-   **Components**: is pluggable and relies on the kernel module.
17
18-   **Kernel**: stores hardware-related code in the  **arch**  directory and other code. The implementation of kernel function sets \(such as task and sem\), for example, task context switching and atomic operations, depends on the hardware-related code in the  **arch**  directory.
19-   **Utils**: functions as a basic code block where other modules rely.
20
21**Figure  1**  Architecture of the LiteOS Cortex-M kernel<a name="fig10838105524917"></a>
22
23
24![](figure/architecture-of-the-liteos-cortex-m-kernel.png)
25
26The directory structure of the kernel is described as follows:
27
28```
29.
30├── components              --- Components available for porting and header files exposed externally
31├── kal                     --- APIs exposed externally, including CMSIS APIs and part of POSIX APIs
32├── kernel                  --- Code for defining the minimum kernel function set
33│   ├── arch                --- Code of the kernel instruction architecture layer
34│   │   ├── arm             --- Code of the ARM32 architecture
35│   │   │   ├── cortex-m3   --- Code of the Cortex-M3 architecture
36│   │   │   │   ├── iar     --- Implementation of the IAR toolchain
37│   │   │   │   ├── keil    --- Implementation of the Keil toolchain
38│   │   │   │   └── xxx     --- Implementation of the particular toolchain
39│   │   │   └── cortex-m4    --- Code of the Cortex-M4 architecture
40│   │   │        ├── iar    --- Implementation of the IAR toolchain
41│   │   │        ├── keil   --- Implementation of the Keil toolchain
42│   │   │        └── xxx    --- Implementation of the particular toolchain
43│   │   ├── include         --- Header files that declare the APIs required, kernel-independent
44│   │   └── risc-v          --- RISK_V architecture
45│   │        └── gcc        --- Implementation of the IAR toolchain
46│   ├── include             --- Code for defining the minimum kernel function set
47│   └── src                 --- Code for implementing the minimum kernel function set
48└──utils                    --- Basic code
49```
50
51## Chip Architecture Adaptation<a name="section137431650339"></a>
52
53As shown in the  [Directory Specifications](#section18127744153119), the  **arch/include**  directory defines the functions that need to be implemented on the common chip architecture. The code related to the chip architecture contains assembly code, which varies based on building toolchains. Therefore, the code for adapting to different toolchains \(for example, IAR, Keil, GCC, etc.\) must be implemented in a specific chip architecture.
54
55The  **arch/include**  directory defines common files and functions. All functions in this directory need to be implemented to adapt to a newly added architecture. For details, refer to the following header files.
56
57```
58los_arch.h                        --- Defines the functions required for initializing the chip architecture.
59los_atomic.h                      --- Defines the atomic operation functions required by the chip architecture.
60los_context.h                     --- Defines the context functions required by the chip architecture.
61los_interrupt.h                   --- Defines the interrupt and exception functions required by the chip architecture.
62los_timer.h                       --- Defines the timer functions required by the chip architecture.
63```
64
65