xref: /DragonOS/docs/kernel/configuration/config.md (revision 59a6bcf6aee15a11a16431bdf875905c5ecf9157)
1# 内核编译配置说明
2
3## 原理
4
5  在内核目录下,用kernel.config来设置内核编译配置信息,以类似解析toml文件的方式去解析该文件,然后接着去解析各模块下的d.config以获取feature的启用情况
6
7## 示例
8
9**kernel.config**
10
11```toml
12[[module.include]]
13name = "init"
14path = "src/init/"
15enable = "y"
16description = ""
17
18[[module.include]]
19name = "mm"
20path = "src/mm/"
21enable = "y"
22description = ""
23```
24
25
26- **[[module.include]]:** 将模块加入到include列表中
27- **name:** 模块名
28- **path:** 模块路径,存放着d.config
29- **enable:**
30  - **y:** 启用,解析模块下的d.config
31  - **n:** 不启用,不解析
32- **description:** 模块的描述信息
33
34
35**src/mm/d.config**
36
37```toml
38[module]
39name = "mm"
40description = ""
41
42[[module.include]]
43name = "allocator"
44path = "src/mm/allocator/"
45enable = "y"
46description = ""
47
48[[module.features]]
49name = "mm_debug"
50enable = "y"
51description = ""
52```
53
54
55- **\[module\]:** 当前模块
56  - **name:** 当前模块名称
57  - **description:** 模块的描述信息
58- **[[module.include]]:** 当前模块下所包含的模块,与kernel.config下的相同
59- **[[module.features]]:** 当前模块下的feature
60  - **name:** feature名
61  - **enable:** 是否开启
62    - **y:** 开启
63    - **n:** 不开启
64  - **description:** feature的描述信息
65
66
67*以下是其它模块下的d.config:*
68
69**src/mm/allocator/d.config**
70
71```toml
72[module]
73name = "allocator"
74description = ""
75
76[[module.features]]
77name = "allocator_debug"
78enable = "y"
79description = ""
80```
81
82**src/init/d.config**
83
84```toml
85[module]
86name = "init"
87description = ""
88
89[[module.features]]
90name = "init_debug"
91enable = "y"
92description = ""
93```
94
95
96上面所有已开启模块的d.config中的feature,会最终生成到内核目录下的D.config文件,即D.config是最终内核编译的配置,如下:
97
98
99**D.config**
100
101```
102init_debug = y
103allocator_debug = y
104mm_debug = y
105```