GNU/Linux - Kconfig Language - 1

Introduction

配置数据库是以树形结构组织的配置选项集合:

The configuration database is a collection of configuration options organized in a tree structure:

+- Code maturity level options

|  +- Prompt for development and/or incomplete code/drivers

+- General setup

|  +- Networking support

|  +- System V IPC

|  +- BSD Process Accounting

|  +- Sysctl support

+- Loadable module support

|  +- Enable loadable module support

|     +- Set version information on all module symbols

|     +- Kernel module loader

+- ...

每个条目都有自己的依赖关系。这些依赖关系用于确定条目的可见性。任何子条目只有在其父条目也可见时才可见。

Every entry has its own dependencies. These dependencies are used to determine the visibility of an entry. Any child entry is only visible if its parent entry is also visible.

Menu entries | 菜单条目

大多数条目都定义了一个配置选项;所有其他条目都有助于组织这些选项。单个配置选项的定义如下

Most entries define a config option; all other entries help to organize them. A single configuration option is defined like this:

config MODVERSIONS

      bool "Set version information on all module symbols"

      depends on MODULES

      help

        Usually, modules have to be recompiled whenever you switch to a new

        kernel.  ...

每一行都以一个关键词开头,后面可以跟多个参数。"config "开始一个新的配置项。下面几行定义了该配置选项的属性。属性可以是配置选项的类型、输入提示、依赖关系、帮助文本和默认值。一个配置选项可以用相同的名称定义多次,但每次定义只能有一个输入提示,且类型不得冲突。

Every line starts with a key word and can be followed by multiple arguments. “config” starts a new config entry. The following lines define attributes for this config option. Attributes can be the type of the config option, input prompt, dependencies, help text and default values. A config option can be defined multiple times with the same name, but every definition can have only a single input prompt and the type must not conflict.

Menu attributes | 菜单属性

菜单条目可以有多种属性。并非所有属性都适用于所有地方(参见语法)。

A menu entry can have a number of attributes. Not all of them are applicable everywhere (see syntax).

  • type definition: "bool"/ "tristate"/ "string"/ "hex"/ "int"

每个配置选项都必须有一个类型。只有两种基本类型:三态和字符串;其他类型以这两种类型为基础。类型定义可选择接受输入提示,因此这两个示例是等价的:

Every config option must have a type. There are only two basic types: tristate and string; the other types are based on these two. The type definition optionally accepts an input prompt, so these two examples are equivalent:

bool "Networking support"

and:

bool

prompt "Networking support"

  • input prompt: "prompt" <prompt> ["if" <expr>]

每个菜单项最多只能有一个提示,用于向用户显示。可以用 "if "添加仅适用于该提示的依赖项。

Every menu entry can have at most one prompt, which is used to display to the user. Optionally dependencies only for this prompt can be added with “if”.

  • default value: "default" <expr> ["if" <expr>]

一个配置选项可以有任意多个默认值。如果可以看到多个默认值,则只有第一个定义的默认值有效。默认值并不局限于定义默认值的菜单项。这意味着默认值可以在其他地方定义,也可以被先前的定义覆盖。只有在用户没有设置其他值的情况下(通过上述输入提示),默认值才会分配给配置符号。如果输入提示可见,默认值就会显示给用户,用户可以自行更改。可以选择使用 "if "添加仅适用于该默认值的依赖关系。

A config option can have any number of default values. If multiple default values are visible, only the first defined one is active. Default values are not limited to the menu entry where they are defined. This means the default can be defined somewhere else or be overridden by an earlier definition. The default value is only assigned to the config symbol if no other value was set by the user (via the input prompt above). If an input prompt is visible the default value is presented to the user and can be overridden by him. Optionally, dependencies only for this default value can be added with “if”.

默认值特意设置为 "n",以避免编译过程臃肿。除少数例外情况外,新的配置选项不应改变默认值。make oldconfig "的目的是尽可能少地从一个版本添加到另一个版本的配置中。

The default value deliberately defaults to ‘n’ in order to avoid bloating the build. With few exceptions, new config options should not change this. The intent is for “make oldconfig” to add as little as possible to the config from release to release.

注意:

值得使用 "default y/m "的内容包括

1, 一个新的 Kconfig 选项,如果过去总是内置的,则应使用 "default y"。

2, 隐藏/显示其他 Kconfig 选项(但自身不生成任何代码)的新把关 Kconfig 选项应为 "default y",这样人们就能看到其他选项。

3, 子驱动程序行为或驱动程序的类似选项应为 "default n"。这样可以提供合理的默认值。

4, 大家都期望使用的硬件或基础架构,如 CONFIG_NET 或 CONFIG_BLOCK。这些都是罕见的例外情况。

Note:

Things that merit “default y/m” include:

1. A new Kconfig option for something that used to always be built should be “default y”.

2. A new gatekeeping Kconfig option that hides/shows other Kconfig options (but does not generate any code of its own), should be “default y” so people will see those other options.

3. Sub-driver behavior or similar options for a driver that is “default n”. This allows you to provide sane defaults.

4. Hardware or infrastructure that everybody expects, such as CONFIG_NET or CONFIG_BLOCK. These are rare exceptions.

  • type definition + default value:

"def_bool" / "def_tristate" <expr> ["if" <expr>]

这是一个类型定义加上一个值的速记符号。可以选择用 "if "来添加该默认值的依赖关系。

This is a shorthand notation for a type definition plus a value. Optionally dependencies for this default value can be added with “if”.

  • dependencies: “depends on” <expr>

这就为该菜单条目定义了一个依赖项。如果定义了多个依赖项,则用"&&"将它们连接起来。依赖关系适用于该菜单项中的所有其他选项(这些选项也接受 "if "表达式),因此这两个示例是等价的:

This defines a dependency for this menu entry. If multiple dependencies are defined, they are connected with ‘&&’. Dependencies are applied to all other options within this menu entry (which also accept an “if” expression), so these two examples are equivalent:

bool "foo" if BAR

default y if BAR

and:

depends on BAR

bool "foo"

default y

  • reverse dependencies: “select” <symbol> [“if” <expr>]  

    反向依赖

正常从属关系会降低一个符号的上限(见下文),而反向从属关系则可用于强制降低另一个符号的上限。当前菜单符号的值被用作 <symbol> 可以设置的最小值。如果 <symbol> 被多次选择,则限制将设置为最大选择。反向依赖关系只能用于布尔或三态符号。

While normal dependencies reduce the upper limit of a symbol (see below), reverse dependencies can be used to force a lower limit of another symbol. The value of the current menu symbol is used as the minimal value <symbol> can be set to. If <symbol> is selected multiple times, the limit is set to the largest selection. Reverse dependencies can only be used with boolean or tristate symbols.

注意:

select会在不访问依赖关系的情况下将一个符号强制设为一个值。通过滥用 select,即使 FOO 依赖于未设置的 BAR,也能选择符号 FOO。一般来说,select 只用于不可见的符号(没有提示)和没有依赖关系的符号。这将限制其实用性,但另一方面也避免了到处都是的非法配置。

如果在 "select"<symbol>后面加上 "if"<expr>,<symbol> 将根据当前菜单符号值和 <expr> 的逻辑 AND 值进行选择。这意味着,由于 "if"<expr> 的存在,下限可以降级。这种行为可能看起来很奇怪,但我们依赖它。(该行为的未来尚未确定)。

Note:

select should be used with care. select will force a symbol to a value without visiting the dependencies. By abusing select you are able to select a symbol FOO even if FOO depends on BAR that is not set. In general use select only for non-visible symbols (no prompts anywhere) and for symbols with no dependencies. That will limit the usefulness but on the other hand avoid the illegal configurations all over.

If “select” <symbol> is followed by “if” <expr>, <symbol> will be selected by the logical AND of the value of the current menu symbol and <expr>. This means, the lower limit can be downgraded due to the presence of “if” <expr>. This behavior may seem weird, but we rely on it. (The future of this behavior is undecided.)

  • weak reverse dependencies: “imply” <symbol> [“if” <expr>]

这与 "select" 类似,因为它对另一个符号强制执行下限,但 "implied"符号的值仍可通过直接依赖关系或可见提示设置为 n。

This is similar to “select” as it enforces a lower limit on another symbol except that the “implied” symbol’s value may still be set to n from a direct dependency or with a visible prompt.

举例如下:

Given the following example:

config FOO

    tristate "foo"

    imply BAZ

config BAZ

    tristate "baz"

    depends on BAR

The following values are possible:

例如,如果多个驱动程序都希望表明自己有能力连接到辅助子系统,而允许用户在配置该子系统时无需同时取消设置这些驱动程序,那么这种方法就非常有用。

This is useful e.g. with multiple drivers that want to indicate their ability to hook into a secondary subsystem while allowing the user to configure that subsystem out without also having to unset these drivers.

注意:如果 FOO=y 和 BAZ=m 的组合会导致链接错误,可以使用 IS_REACHABLE() 来保护函数调用:

Note: If the combination of FOO=y and BAZ=m causes a link error, you can guard the function call with IS_REACHABLE():

foo_init()

{

        if (IS_REACHABLE(CONFIG_BAZ))

                baz_register(&foo);

        ...

}

注:如果 BAZ 提供的功能是 FOO 非常需要的,则 FOO 不仅要暗示 BAZ,还要暗示其依赖关系 BAR:

Note: If the feature provided by BAZ is highly desirable for FOO, FOO should imply not only BAZ, but also its dependency BAR:

config FOO

    tristate "foo"

    imply BAR

    imply BAZ

注意:如果 "imply"<symbol> 后跟 "if"<expr>,<symbol> 的默认值将是当前菜单符号值和 <expr> 的逻辑 AND 值。(这种行为的未来还未确定)。

Note: If “imply” <symbol> is followed by “if” <expr>, the default of <symbol> will be the logical AND of the value of the current menu symbol and <expr>. (The future of this behavior is undecided.)

  • limiting menu display: “visible if” <expr>

该属性仅适用于菜单块,如果条件为假,则菜单块不会显示给用户(但其中包含的符号仍可被其他符号选择)。它类似于单个菜单项的条件 "prompt" 属性。"visible" 的默认值为 true。

This attribute is only applicable to menu blocks, if the condition is false, the menu block is not displayed to the user (the symbols contained there can still be selected by other symbols, though). It is similar to a conditional “prompt” attribute for individual menu entries. Default value of “visible” is true.

  • numerical ranges: “range” <symbol> <symbol> [“if” <expr>]

这样可以限制 int 和十六进制符号的可能输入值范围。用户只能输入大于或等于第一个符号、小于或等于第二个符号的值。

This allows to limit the range of possible input values for int and hex symbols. The user can only input a value which is larger than or equal to the first symbol and smaller than or equal to the second symbol.

  • help text: “help”

这定义了一个帮助文本。帮助文本的结尾由缩进级别决定,这意味着它在缩进比帮助文本的第一行小的行结束。

This defines a help text. The end of the help text is determined by the indentation level, this means it ends at the first line which has a smaller indentation than the first line of the help text.

  • module attribute

("modules") 此项声明将该符号用作 MODULES 符号,从而使所有配置符号都处于第三模块状态。最多只能有一个符号设置了 "modules "选项。

“modules” This declares the symbol to be used as the MODULES symbol, which enables the third modular state for all config symbols. At most one symbol may have the “modules” option set.

Menu dependencies

依赖关系定义了菜单项的可见性,也可以缩小三态符号的输入范围。表达式中使用的三态逻辑比普通布尔逻辑多使用一种状态来表达模块状态。依赖关系表达式的语法如下:

Dependencies define the visibility of a menu entry and can also reduce the input range of tristate symbols. The tristate logic used in the expressions uses one more state than normal boolean logic to express the module state. Dependency expressions have the following syntax:

         <expr> ::= <symbol>                  (1)

         <symbol> '=' <symbol>                (2)

         <symbol> '!=' <symbol>               (3)

         <symbol1> '<' <symbol2>              (4)

         <symbol1> '>' <symbol2>              (4)

         <symbol1> '<=' <symbol2>             (4)

         <symbol1> '>=' <symbol2>             (4)

         '(' <expr> ')'                       (5)

         '!' <expr>                           (6)

         <expr> '&&' <expr>                   (7)

         <expr> '||' <expr>                   (8)

表达式按优先级递减顺序排列。

1. 将符号转换为表达式。布尔和三态符号只需转换为相应的表达式值。所有其他符号类型的结果都是 "n"。

2. 如果两个符号的值相等,则返回 "y",否则返回 "n"。

3. 如果两个符号的值相等,则返回 "n",否则返回 "y"。

4. 如果 <symbol1> 的值分别比 <symbol2> 的值小、大、小或相等、大或相等,则返回'y',否则返回'n'。

5. 返回表达式的值。用于覆盖优先级。

6. 返回 (2-/expr/) 的结果。

7. 返回 min(/expr/, /expr/) 的结果。

8. 返回 max(/expr/, /expr/) 的结果。

Expressions are listed in decreasing order of precedence.

1. Convert the symbol into an expression. Boolean and tristate symbols are simply converted into the respective expression values. All other symbol types result in ‘n’.

2. If the values of both symbols are equal, it returns ‘y’, otherwise ‘n’.

3. If the values of both symbols are equal, it returns ‘n’, otherwise ‘y’.

4. If value of <symbol1> is respectively lower, greater, lower-or-equal, or greater-or-equal than value of <symbol2>, it returns ‘y’, otherwise ‘n’.

5. Returns the value of the expression. Used to override precedence.

6. Returns the result of (2-/expr/).

7. Returns the result of min(/expr/, /expr/).

8. Returns the result of max(/expr/, /expr/).

表达式的值可以是 "n"、"m "或 "y"(计算时分别为 0、1、2)。当表达式的值为 "m "或 "y "时,菜单条目才会显示。

An expression can have a value of ‘n’, ‘m’ or ‘y’ (or 0, 1, 2 respectively for calculations). A menu entry becomes visible when its expression evaluates to ‘m’ or ‘y’.

符号有两类:常量符号和非常量符号。非常数符号是最常见的符号,通过 "config "语句定义。非常数符号完全由字母数字字符或下划线组成。常量符号只是表达式的一部分。常量符号总是由单引号或双引号包围。在引号内,允许使用任何其他字符,引号可以用"'"转义。

There are two types of symbols: constant and non-constant symbols. Non-constant symbols are the most common ones and are defined with the ‘config’ statement. Non-constant symbols consist entirely of alphanumeric characters or underscores. Constant symbols are only part of expressions. Constant symbols are always surrounded by single or double quotes. Within the quote, any other character is allowed and the quotes can be escaped using "'".

Menu structure

菜单条目在树中的位置有两种确定方式。首先,可以明确指定:

The position of a menu entry in the tree is determined in two ways. First it can be specified explicitly:

menu "Network device support"

      depends on NET

config NETDEVICES

      ...

endmenu

"menu"... "endmenu"块中的所有条目都将成为 "Network device support"的子菜单。所有子菜单条目都将继承菜单条目的依赖关系,例如,这意味着 "NET "依赖关系将被添加到配置选项 NETDEVICES 的依赖关系列表中。

All entries within the “menu” ... “endmenu” block become a submenu of “Network device support”. All subentries inherit the dependencies from the menu entry, e.g. this means the dependency “NET” is added to the dependency list of the config option NETDEVICES.

生成菜单结构的另一种方法是分析依赖关系。如果一个菜单条目在某种程度上依赖于前一个条目,那么它就可以成为前一个条目的子菜单。首先,前一个(父)符号必须是依赖列表的一部分,然后这两个条件之一必须为真:

The other way to generate the menu structure is done by analyzing the dependencies. If a menu entry somehow depends on the previous entry, it can be made a submenu of it. First, the previous (parent) symbol must be part of the dependency list and then one of these two conditions must be true:

  • 如果父条目设置为 "n",子条目必须变为不可见

  • 子条目必须在父条目可见时才可见:

  • the child entry must become invisible, if the parent is set to ‘n’

  • the child entry must only be visible, if the parent is visible:

config MODULES

    bool "Enable loadable module support"

config MODVERSIONS

    bool "Set version information on all module symbols"

    depends on MODULES

comment "module support disabled"

    depends on !MODULES

MODVERSIONS 直接依赖于 MODULES,这意味着只有 MODULES 与 "n "不同时它才可见。另一方面,注释只有在 MODULES 设置为 "n"时才可见。

MODVERSIONS directly depends on MODULES, this means it’s only visible if MODULES is different from ‘n’. The comment on the other hand is only visible when MODULES is set to ‘n’.

参考:

Kconfig Language — The Linux Kernel documentation

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/770083.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

hibernate与jpa学习

jpa是一个规范&#xff0c;hibernate是jpa的实现&#xff0c;是一种框架。 hibernate&#xff1a; ORM框架/持久层框架&#xff08;Object Relational Mapping&#xff09; 它是是一个轻量级开放源代码的对象关系映射框架&#xff0c;hibernate可以自动生成SQL语句&#xff0…

js 使用 lodash-es 检测某个值是否是函数

import { isFunction } from lodash-eslet isA isFunction(() > {}) console.log(isA) //true https://www.lodashjs.com/docs/lodash.isFunction#_isfunctionvalue https://lodash.com/docs/4.17.15#isFunction 人工智能学习网站 https://chat.xutongbao.top

简单的电路指示锂离子电池的健康状况

锂离子电池对不良处理很敏感。当我们将电池充电至低于制造商定义的裕量时&#xff0c;可能会发生火灾、爆炸和其他危险情况。 锂离子电池在正常使用的过程中&#xff0c;其内部进行电能与化学能相互转化的化学正反应。但在某些条件下&#xff0c;如对其过充电、过放电或过电流…

复杂流分类

拓扑图 配置 配置ACL 配置流分类、流行为、流策略 在接口应用 sysname AR1 # acl number 2000 rule 5 permit source 10.1.1.1 0 acl number 2001 rule 5 permit source 10.1.1.2 0 acl number 2002 rule 5 permit source 10.1.1.3 0 # traffic classifier EF operat…

CGLib动态代理技术

基于CGLib的动态代理机制&#xff0c;ProxyFactoryy无需再像JDK动态代理那样实现一个interface&#xff0c;实际情况下可能这个interface并不存在&#xff0c;只需要实现另外一个接口MethodInterceptor即可 package com.hmdp.service.尚硅谷的代理模式3; //CGlib代理import …

FlinkSQL 开发经验分享

作者&#xff1a;汤包 最近做了几个实时数据开发需求&#xff0c;也不可避免地在使用 Flink 的过程中遇到了一些问题&#xff0c;比如数据倾斜导致的反压、interval join、开窗导致的水位线失效等问题&#xff0c;通过思考并解决这些问题&#xff0c;加深了我对 Flink 原理与机…

Android 开发中 C++ 和Java 日志调试

在 C 中添加堆栈日志 先在 Android.bp 中 添加 ‘libutilscallstack’ shared_libs:["liblog"," libutilscallstack"]在想要打印堆栈的代码中添加 #include <utils/CallStack.h> using android::CallStack;// 在函数中添加 int VisualizerLib_Crea…

制作一个动态库

1. 准备工作 # 目录结构 add.c div.c mult.c sub.c -> 算法的源文件, 函数声明在头文件 head.h # main.c中是对接口的测试程序, 制作库的时候不需要将 main.c 算进去 . ├── add.c ├── div.c ├── include │ └── head.h ├── main.c ├── mult.c └── s…

Day04-jenkins-docker

Day04-jenkins-docker 9. 案例06: 基于docker的案例实现静态代码9.1 整体流程9.2 步骤与环境1) 步骤2) 环境 9.3 详细步骤1&#xff09;代码准备2&#xff09;书写dockerfile3&#xff09;准备私有仓库4&#xff09;创建jenkins任务5&#xff09;web节点上启动对应的docker容器…

WPF真入门教程34--爆肝了【仓库管理系统】

1、项目介绍 本项目是一个基于C#WPF实现的仓库管理系统&#xff0c;系统规模较小&#xff0c;适合入门级的项目练练手&#xff0c;但项目还是具有较高的学习价值&#xff0c;它采用mvvmlight框架&#xff0c;EF框架&#xff0c;WPF前端等技术构成。对于学习来说&#xff0c;可…

Ubuntu设置nacos开机以单机模式自启动

首先&#xff0c;需要安装jdk Ubuntu 安装JDK 创建Systemd服务单元文件 sudo vim /etc/systemd/system/nacos.service按i进入编辑模式&#xff0c;写入下面信息 [Unit] Descriptionnacos server Afternetwork.target[Service] Typeforking Environment"JAVA_HOME/opt/j…

树莓派0 2W重启后突然没有声音

树莓派0 2W重启后突然没有声音。 最近在使用该板卡。重启后突然出现了显示器不能显示界面的情况&#xff0c;接着用putty的ssh方式连接该板卡&#xff0c;能连上。使用vnc方式连接该板卡&#xff0c;也能连上。后来通过修改/boot/config.txt文件&#xff0c;能在显示器上显示界…

AI大模型深度学习:理论与应用全方位解析

背景 在当前技术环境下&#xff0c;AI大模型学习不仅要求研究者具备深厚的数学基础和编程能力&#xff0c;还需要对特定领域的业务场景有深入的了解。通过不断优化模型结构和算法&#xff0c;AI大模型学习能够不断提升模型的准确性和效率&#xff0c;为人类生活和工作带来更多…

用一百场线下讲座科普充电桩 能效电气做到了

在新能源汽车产业蓬勃发展的今天,充电桩作为产业链的重要环节,其建设与发展成为推动行业进步的关键。在这一背景下,能效电气凭借其卓越的技术实力和前瞻性的市场布局,成为了新能源充电桩行业的佼佼者。 为了进一步推动新能源产业的发展,普及充电桩知识,能效电气精心策划并举办…

LangChain的基本构成、组件与典型场景

【图书推荐】《ChatGLM3大模型本地化部署、应用开发与微调》-CSDN博客 在人工智能的持续演进中&#xff0c;语言模型&#xff0c;尤其是大型语言模型&#xff08;LLM&#xff09;&#xff0c;例如备受瞩目的ChatGPT&#xff0c;已经稳固地占据了科技前沿的核心地位。这些模型不…

ChatGPT 论文助手:如何用 AI 技术加速学术写作过程

ChatGPT在论文写作中的应用 ChatGPT作为一个先进的语言模型&#xff0c;在学术论文创作领域提供显著帮助。它不仅提升学生与研究者的写作效率&#xff0c;还优化论文质量并引入创新观点。以下是ChatGPT在论文写作中的几种具体应用&#xff1a; 提升写作效率 生成写作构思&…

Mac密室逃脱游戏推荐:Escape Simulator for mac安装包

Escape Simulator 是一款逃生模拟游戏&#xff0c;玩家在游戏中需要寻找线索、解决谜题&#xff0c;以逃离各种房间或环境。这种类型的游戏通常设计有多个关卡或场景&#xff0c;每个场景都有不同的设计和难度。 在 Escape Simulator 中&#xff0c;玩家的目标通常是找到出口或…

Springboot+Vue3开发学习笔记《1》

SpringbootVue3开发学习笔记《1》 博主正在学习SpringbootVue3开发&#xff0c;希望记录自己学习过程同时与广大网友共同学习讨论。 一、前置条件 博主所用版本&#xff1a; IDEA需要破解&#xff0c;破解工具链接容易挂&#xff0c;关注私聊我单发。 Spring Boot是Spring提…

Zabbix 配置WEB监控

Zabbix WEB监控介绍 在Zabbix中配置Web监控&#xff0c;可以监控网站的可用性和响应时间。Zabbix提供了内置的Web监控功能&#xff0c;通过配置Web场景&#xff08;Web Scenario&#xff09;&#xff0c;可以监控HTTP/HTTPS协议下的Web服务。 通过Zabbix的WEB监控可以监控网站…

深入解析RocketMQ的存储设计艺术(二)

1. 零拷贝与MMAP 1.1 什么是零拷贝? 零拷贝(英语: Zero-copy) 技术是指计算机执行操作时,CPU不需要先将数据从某处内存复制到另一个特定区域。这种技术通常用于通过网络传输文件时节省CPU周期和内存带宽。 ➢零拷贝技术可以减少数据拷贝和共享总线操作的次数,消除传输数据…