Kconfig syntax (one of the kernel values)

Source: Internet
Author: User
Tags alphanumeric characters
The following is an article about the kconfig syntax I found online. I will compare it with an example.

Linux Versions later than 2.6 change the configuration file from the original config. In to kconfig, for the kconfig syntax in/documentation/kbuild/kconfig-language.txt
Detailed descriptions are provided here. The Chinese version of kconfig-language.txt is provided. Introduction
----

The configuration options in the configuration database are organized in the form of a tree:

+-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
+ -...

Each option has its own dependency. These dependencies determine whether the options are visible. The parent option is visible, and the Child option is visible.

Menu Options
--------

Most options define a configuration option, and other options help to organize them. (Original article: Most entries define
A config option, all other entries help to organize them.) A configuration option definition can be as follows:
Format:

Config modversions
Bool "set version information on all module symbols"
Depends modules
Help
Usually, modules have to be recompiled whenever you switch to a new
Kernel ....

Each line starts with a keyword and can be connected to multiple parameters. "Config" defines a new configuration option. The following lines define the configuration
Option. Attribute can be the type of the configuration option, input prompt (input prompt), dependency, help information, and default value. I
Configuration options can be defined multiple times with the same name, but each definition can only have one input prompt and the type cannot conflict.

Menu Properties
--------

One menu option can have multiple attributes. These attributes are not required to be used anywhere (see syntax ).

-Type Definition: "bool"/"tristate"/"string"/"hex"/"int"
The type must be specified for each configuration option. There are two basic types: Tristate and string. Other types are based on these two basic types.
Type. You can use the input prompt to define the type, so the two examples below are equivalent:

Bool "Networking support"
And
Bool
Prompt "Networking support"

-Input prompt: "prompt" <prompt> ["if" <expr>]
Each menu option can have only one input prompt displayed to the user. You can use "if" to indicate the dependency of the prompt. Of course this is
Optional.

-Default value: "default" <expr> ["if" <expr>]
One configuration option can have any number of default values. If multiple default values exist, only the first defined value is available. Default Value and
It is not limited to defining their menu options for applications. This means that the default value can be defined anywhere or earlier.
If you have not set the value (as prompted by the preceding input), the value of the configuration option is the default value. If the input prompt is displayed
The default value is displayed to the user and can be modified by the user.
You can use "if" to add the default dependency. (Optional)

-Dependency: "depends on"/"requires" <expr>
Define dependencies for the menu options. If multiple dependencies are defined, separate them. Dependencies can also be applied
All other options in this menu (the same if expression is accepted), so the following two examples are equivalent:

Bool "foo" If bar
Default y if Bar
And
Depends on bar
Bool "foo"
Default y

-Reverse dependency: "select" <symbol> ["if" <expr>]
Although normal dependency can reduce the upper limit of one option, reverse dependency can lower this limit. The value of the current menu option is symbol.
. If the symbol is selected multiple times, the upper limit is the maximum value.
The reverse dependency can only be used on the Boolean OR tristate options.

-Data range: "range" <symbol> ["if" <expr>]
The input value range is acceptable for int and hex options. The user can only enter equal to or greater than the first symbol, less than or equal to the second
The value of the symbol.

-Help: "Help" or "--- help ---"
Define help information. The end of the help information is determined by the indentation level, which means that the information is in the first line
The end of the line with a small indentation.
"--- Help ---" and "help" have no difference in implementation. "--- help ---" helps to compare the configuration logic in the file
Separate prompts for developers.

Menu dependency
------------

Dependency determines whether the menu options are visible or not. It can also reduce the input range of tristate. Tristate logic compared with Boolean logic in the table
More States are used to indicate the status of a module. The syntax of the dependency expression is as follows:

<Expr >::= <symbol> (1)
<Symbol> '=' <symbol> (2)
<Symbol> '! = '<Symbol> (3)
'(' <Expr> ')' (4)
'! '<Expr> (5)
<Expr> '&' <expr> (6)
<Expr> '|' <expr> (7)

Expressions are listed in descending order of priority.

(1) Assign the symbol to the expression. The Boolean and tristate types are directly assigned to the expression. All other types of Symbol
All are assigned 'n '.
(2) If two symbrs are equal, 'y' is returned; otherwise, 'n' is returned '.
(3) If two symbrs are equal, 'n' is returned; otherwise, 'y' is returned '.
(4) return the value of the expression. Used to change the priority.
(5) return the result of (2-/expr.
(6) return the results of min (/expr/,/expr.
(7) return the result of max (/expr/,/expr.

The value of an expression can be 'n', M', or 'y' (or the result 0, 1, 2 ). When the expression value is 'M' or 'y ',
A single item is visible.

There are two types of Symbol: immutable and mutable. The immutable symbol is the most common, defined by the 'config' statement and completely composed of numbers
Alphanumeric characters or underscores ).
Immutable symbol is only part of the expression. It is often enclosed in single or double quotation marks. Any character can be used in quotation marks.
Escape Character '/'.

Menu structure
--------

The menu position in the tree can be determined by two methods. The first method can be as follows:

Menu "network device support"
Depends net

Config netdevices
...

Endmenu

All sub-menus between "menu"... "endmenu" are "network device support. All sub-menu options
All inherit the dependency of the parent menu. For example, the dependency of "net" is added to the dependency list of the configuration option netdevices.

In addition, the menu structure is generated by analyzing dependencies. If the menu option depends on the previous option to a certain extent, it can become
Sub-menu. First, the preceding (parent) options must be part of the dependency list and must have options that meet the following two conditions:
-If the parent option is 'n', the sub-options must be invisible.
-If the parent option is visible, the Child option can be visible.

Config modules
Bool "enable loadable module support"

Config modversions
Bool "set version information on all module symbols"
Depends modules

Comment "module support disabled"
Depends! Modules

Modversions depends on modules directly, which means that this option is visible if modules is not 'n. In other words, when
When modules is visible, options are visible (the (null) Dependency of modules is also part of the Option dependency ).

Kconfig syntax
------------

The configuration file describes the menu options. Each line starts with a keyword (except the help information ). The following keyword ends a menu option:
-Config
-Menuconfig
-Choice/endchoice
-Comment
-Menu/endmenu
-If/endif
-Source
The first five can also be used at the beginning of the menu option definition.

Config:

"Config" <symbol>
<Config Options>

A configuration option <symbol> is defined and can accept any attribute described above.

Menuconfig:
"Menuconfig" <symbol>
<Config Options>

This keyword is similar to the previous keyword, but it requires that all sub-options be displayed as independent rows on the basis of the previous keyword. (This is
Similar to the simple config entry above, but it also gives a hint to front
Ends, that all suboptions shoshould be displayed as a separate list of options .)

Choices:

"Choice"
<Choice options>
<Choice block>
"Endchoice"

This keyword defines a set of selection items, and the options can be any attribute described above. Although Boolean allows only one configuration option,
Tristate can be set to 'M' for multiple configuration options, but the option can only be Boolean OR tristate type. This can be achieved through multiple
Only one driver is compiled into/loaded into the kernel, but all the drivers can be compiled into modules.
Another option that is acceptable is "optional", so that the option is set to 'n', not selected.

Comment:

"Comment" <prompt>
<Comment Options>

The comment displayed to the user during the configuration process is defined here and will be written into the output file. The only available option is dependency.

Menu:

"Menu" <prompt>
<Menu Options>
<Menu block>
"Endmenu"

A menu is defined here. For more information, see "menu structure ". The only available option is dependency.

If:

"If" <expr>
<If block>
"Endif"

The IF structure is defined here. Dependency <expr> is added to all menu options in if... endif. The following is an example of a new driver on my tq2440 Embedded Board: config embedsky_hello
Tristate "tq2440/sky2440 Hello driver" // This option is displayed when you make menuconfig.
Depends on arch_s3c2440
Help
Embedsky tq2440/sky2440 hello.

I feel like I can understand this as long as I can understand it. I will learn it later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.