Linux kernel source code essential skills

xiaoxiao2021-03-06  48

Since the kernels of the operating system are close to the hardware, it is necessary to understand the architecture of the computer, such as the working principle, interface characteristics, and BIOS calls of the CPU. Readers don't think because of these expectations, here will introduce some skills necessary to read Linux kernel source code. Getting the kernel is usually in the Linux system /usr, representing the kernel version, such as the 2.4.23) directory is the kernel source code (if there is no similar directory, because I haven't installed the kernel code yet). Also download from the interconnection. Note, don't always go to http://www.kernel.org/ to download, it is best to use its mirror site download. Please find a suitable download point in http://www.kernel.org/mirrors/, go to the Pub / Linux / Kernel / V2.6 / directory to download 2.4.23 kernel. There are two types of code packages, Linux-2.4.23.tar.gz and Linux-2.4.23.tar.bz2. The two code pack content is the same, just the compressed program. .gz is compressed with Gzip; .bz2 is compressed with Bzip2. BZIP2 compact compression is better than GZIP. The code directory structure should know the overall distribution of the Linux kernel source before reading the source code. Modern operating systems are generally composed of process management, memory management, file systems, drivers, and networks. The various directories of the Linux kernel source code corresponds to this corresponding, which make up as follows (assuming relative to Linux-2.4.23 directories): ◆ The Arch directory includes all core code related to the architecture. Each subdirectory below represents a Linux supported architecture, such as the I386 is an Intel CPU and a subdirectory with the compatible architecture. The PC is generally based on this directory. ◆ The include directory includes most of the header files needed to compile the core, such as the header file-independent header file in the include / linux subdirectory. ◆ The init directory contains the core initialization code (not a boot code of the system), two files with main.c and version.c. This is a good starting point to study how the core works. ◆ The MM directory contains all memory management code. The memory management code associated with the specific hardware architecture is located in the Arch / * / mm directory. ◆ DRIVERS directory is all device drivers in the system. It is further divided into several types of equipment drivers, each with corresponding subdirectory, such as the sound card drive, corresponds to Drivers / Sound. ◆ The IPC directory contains communication code between the core processes. ◆ The modules directory stores the entered, dynamically loaded modules. ◆ FS directory stores Linux supported file system code. Different file systems have different subdirectories, such as the EXT3 file system, the EXT3 subdirectory. The core code of kernel kernel management is placed here. At the same time, it is placed in the Arch / * / kernel directory with the processor structure. ◆ The NET directory is the core network part code, and each subdirectory corresponds to an aspect of the network. ◆ The lib directory contains the core library code, but the library code associated with the processor structure is placed in the Arch / * / lib / directory. ◆ The scripts directory contains script files for configuring the core. ◆ The Documentation directory is some documents, which are specific instructions for each directory. Generally there is a .depend file and a Makefile file in each directory. Both files are compiled auxiliary files. Read the two files carefully and the relationship between the links and relying on each file is very helpful. There are also readme files in another directory, which is some instructions on the files in this directory, which is also conducive to the understanding of the kernel source. Reading starts in reading methods or sequences, with longitudinal and horizontal points. The so-called longitudinal direction is gradually performed in the order of execution of the program; the so-called lateral direction is made according to the module. They are often combined together.

转载请注明原文地址:https://www.9cbs.com/read-117668.html

New Post(0)