1. Preface
The first question that came to the students who had just come into contact with Linux kernel was: Where do I start? 、
The way Linux kernel is opened is a variety of ways: starting with a simple device driver, starting with the directory structure of the source code, starting from the kernel process, starting with a large functional module, and so on. In any case, each is a straight path (all Roads pass Romama).
This article (and the subsequent series) will start with the Linux kernel configuration and understand the Linux kernel as a whole. There are two reasons why this is done:
1) The number of configuration items of Linux kernel, so that when the kernel transplant, see Menuconfig interface, there will be deep fear (see picture 1 below).
2) The purpose of the configuration items is the function configuration and function switch, from a certain extent can be seen a software function module division. In the case of Linux kernel, the tree structure presented by Kconfig, from the point of view of function division, is clearer than the directory structure of source code.
Note 1: The Linux kernel version used in this article series is the "Linux 4.6-RC5" used by "X Project", for reference "https://github.com/ Wowotechx/linux.git".
2. Initial knowledge of the kernel configuration
The configuration items for Linux kernel are organized in the architecture (ARCH), which is kconfig language. In the case of ARM64, the entrance to the Kconfig is located at:
Arch/arm64/kconfig
In the kernel root directory with "arch=arm64" as the parameter, execute make menuconfig, you can get the following configuration interface:
Make arch=arm64 Menuconfig
Image 1 Kernel_menuconfig
The first picture, also can accept, after all, the painting breeze refreshing. But in the two-level menu, the head is big. But don't worry, we have a layer of analysis.
Before you start, explain the means of analysis, very simple, the main points are four:
Combined with Kconfig file;
Follow Menuconfig's menu item;
Plus the powerful Google;
Read source code if necessary.
In addition, in view of the space issue, this article only introduces Kconfig's first-level menu (which is what the picture 1 can see), the equivalent of an index, the subsequent article will be an expanded description.
3. First Level Menu
In this chapter we will perform a brief analysis of Menuconfig's first-level menu based on the Arch/arm64/kconfig file, with the aim of understanding the syntax of the Kconfig language and the overall structure of the first-level Linux kernel configuration from a practical example. Please refer to the following table for details:
Matching Items |
Kconfig File Location |
Function description |
Default configuration items for the ARM64 schema |
Arch/arm64/kconfig |
After you specify arch as ARM64, ARM64 's kconfig will default to help us identify a number of configuration items, such as Config_64bit, Config_mmu, config_of, and so on. These configuration items are not reflected in the Menuconfig menu, but can be seen in the final generated config file. |
General Setup |
Init/kconfig Located between the menu "General Setup" and the corresponding Endmenu |
This configuration item is defined by "menu ... endmenu" and is a configuration menu representing a collection of a class of configurations (refer to Picture 1 above, "--->" at the end of the configuration items are menu items, press Enter directly into the corresponding menu interface); Used primarily for configuration and function-independent general options, such as the version number of the kernel, compression, and so on. |
Loadable Module |
Init/kconfig Defined by "Menuconfig MODULES" |
Menuconfig and menu are different, is a can choose whether to open the menu (refer to Picture 1 "[*]"); The features used to configure the kernel "module". |
Block device |
Block/kconfig Defined by "Menuconfig BLOCK" |
Kernel-block device-related features. |
Platform selection |
Arch/arm64/kconfig.platforms Located between menu "Platform selection" and Endmenu |
Configuration items for configuration and platform-specific, such as Sunix, HiSi, etc.; Since ARM64 abandoned the "mach-xxx" directory, this is probably the last space for each platform to play itself. |
PCI Bus Support |
Arch/arm64/kconfig Drivers/pci/kconfi |
PCI bus-related features. |
ACPI Support |
Drivers/acpi/kconfig |
ACPI bus-related attributes. |
Kernel Features |
Arch/arm64/kconfig Kernel/kconfig.preempt Kernel/kconfig.hz Mm/kconfig Located between the menu "Kernel Features" and the corresponding Endmenu |
The configuration of core functions of Linux kernel, such as process management, memory management, and so on. Is the most complex class of Linux kernel configuration items. |
Boot Options |
Arch/arm64/kconfig Located between the menu "Boot options" and the corresponding Endmenu |
Features for configuration and kernel boot, such as default command line, UEFI support, and so on. |
Userspace binary formats |
Arch/arm64/kconfig Fs/kconfig.binfmt Located between the menu "userspace binary formats" and the corresponding Endmenu |
The format used to configure the user space binary. |
Power Management |
Arch/arm64/kconfig Kernel/power/kconfig Located between the menu "Power management Options" and the corresponding Endmenu |
Linux kernel features related to power management. |
CPU Power Management |
Arch/arm64/kconfig Drivers/cpuidle/kconfig Drivers/cpufreq/kconfig Located between the menu "CPU Power Management" and the corresponding Endmenu |
CPU-related power management features, such as Cpuidle, cpufreq, etc.; This is a big improvement of the new kernel, which will be the CPU-related power management function, which is abstracted into a top-level function, and the system's power management is tied. |
Networking Support |
Net/kconfig |
Network-related features. |
Device Drivers |
Drivers/kconfig |
Device driver-related configuration items. |
Firmware Drivers |
Drivers/firmware/kconfig ... |
Firmware about the configuration item. |
File Systems |
Fs/kconfig |
A file system-related configuration item. |
Virtualization |
Arch/arm64/kvm/kconfig |
Virtualization-related configuration items. |
Kernel hacking |
Arch/arm64/kconfig.debug |
Kernel debug-related configuration items. |
Security Options |
Security/kconfig |
The configuration item for the security feature. |
Cryptographic API |
Crypto/kconfig Arch/arm64/crypto/kconfig |
The configuration item for the cryptographic algorithm. |
Library Routines |
Lib/kconfig |
Used to configure commonly used libraries, such as CRC16. |
Linux kernel Configuration Resolution-Overview (based on ARM64 architecture)