Linux Kernel Core Chinese Manual (13) - Core Source Program

xiaoxiao2021-03-06  41

Linux Kernel Sources This chapter describes what you should start to view specific core functions in the Linux core source program. This book does not rely on the knowledge of 'c' language or requires you to have Linux core sources to understand how Linux core works. It is said that the practice View the core source program can have an in-depth understanding of the Linux operating system. This chapter gives an overview of the core source program: How do they organize, where do you start to find a specific code. WHERE TO GET The Linux Kernel Sources (where to get Linux core source program) All primary Linux distributions have core source programs in the middle of Craftworks, Debian, Slackware, Redhat. Usually l is installed on your Linux system to be built with these source programs. In fact, these source programs seems to be somewhat, so you may want to get the latest source program to get the Web site mentioned by Appendix C. They put them

ftp://ftp.cs.helsinki.fi

And other mirrored web sites. Helsinki's Web site is the latest, but other sites such as MIT and SunSite will not be too backward. If you can't access the web, there are many CDROM manufacturers to provide a block of the world's main web site with a very reasonable fee. Some even provide booking services, updates from quarter or months. Your local Linux user group is also a good source of a source. The Linux core source program has a very simple number system. Any even core (e.g., 2.0.30) is a stable core, and any odd core (eg 2.1.42) is a core of development. This book is based on a stable 2.0.30 source code. The core of the development version has all the latest features and all the support of all the latest devices, but they may be unstable, may not be what you want, but let Linux community test the latest cores. This allows the entire community to test. Remember, even if you test the core of non-production, it is best to back up your system. For the change of the core source program, the Patch file is distributed. Tools Patch can apply a series of modifications for a series of source files. For example, if you have a 2.0.29 source tree, you want to transfer to 2.0.30, you can take the 2.0.30 Patch file and apply these patches to the source tree: $ CD / USR / SRC / Linux $ PATCH -P1

http://www.linuxhq.com

How The Kernel Sources Are Arranged (How to organize the core ") In the top of the source tree, you will see some directory: The Arch Arch subdirectory includes all and architectural core code. It also has a deeper subdirectory, each represents a supported architecture, such as I386 and Alpha. The incrude include subdirectory includes most of the include files needed to compile the core. It also has a deeper subdirectory, each supported architecture. Include / ASM is a soft link for the true Include directory required for this architecture, such as include / ASM-I386. In order to change the architecture, you need to edit the core Makefile, re-run Linux's core configuration program init, contain the core initialization code, at this time a very good starting point for how to work. MM This directory includes all memory management code. And architecture-related memory management code is located in the ARCH / * / MM /, such as all device drivers for the ARCH / I386 / MM / Fault.c Drivers system in this directory. They are divided into equipment drivers, such as Block. IPC This directory contains the code between the core process Modules This is just a file system code for the directory FS used to hold the created module. It is divided into a sub-directory, each supported file system, such as the main core code of VFAT and EXT2 KERNEL. Similarly, and the system-related core code places the core library code for the arch / * / kernel net core network code lib. And architecture-related library code contains scripts (such as awk and tk scripts), used to configure core Where to start looking (where to start watching) Look like Linux core such a huge complex program Quite difficult. It is like a huge shuttlecock, which shows no end. A part of the code to see the core is usually introduced to see several other related files, and you will forget what you have seen. The next section gives you a prompt, for a given theme, it is best to see the place of the source tree. System Startup and Initialization (System Startup and Initialization) On an Intel System, when loadlin.exe or lilo loads the core into memory and handles the control to it, the core begins to start. This part looks at Arch / I386 / Kernel / Head.s. Head.s performs some and architectural settings work and jump to the main () routine in init / main.c. Memory Management code is mostly in MM but the code related to the architecture in Arch / * / mm. Page Fault Processing Code In MM / Memory.c, memory mapping and page caching code are in mm / filemap.c. Buffercache is implemented in MM / Buffer.c, and the swap cache is in mm / swap_state.c and mm / swapfile.c. Most of the relatively universal code is in the Kernel, and the architecture related code in Arch / * / kernel. The scheduler is in kernel / sched.c, the fork code is in kernel / fork.c. Bottom Half Processing code in include / Linux / Interrupt.h. The TASK_STRUCT data structure can be found in include / Linux / Sched.h in Drivers / PCI / PCI.C, system-wide definitions in include / Linux / PCI.h.

Each architecture has some special PCI BIOS code, Alpha AXP is located in Arch / Alpha / Kernel / Bios32.c Interprocess Communication is all in the IPC directory. All system V IPC objects include IPC_PERM data structures, which can be found in include / Linux / IPC.H. The system V message is implemented in IPC / MSG.C, and there is IPC / SHM.C in the shared, and the signal light is in IPC / SEM.C. The pipe is implemented in IPC / PIPE.C. Interrupt Handling core interrupt processing code is almost all related to microprocessor (usually also and platform). Intel interrupt processing code in Arch / I386 / Kernel / Irq.c It is defined in Incude / ASM-I386 / IRQ.H. DEVICE Drivers (Device Drivers) Linux Core Source Codes Most code rows in its device driver. All device driver source code in Linux is in Drivers, but they are further classified: / Block block device driver, such as IDE (IDE.c). If you want to see how all the devices that may contain a file system is initialized, you can see Device_Setup () in drivers / block / genhd.c. It not only initializes the hard disk, but also initializes the network because the network is required when you install NFS file system. The block device includes an IDE and SCSI devices. / CHAR You can view character-based devices such as TTY, serial ports, and more. / CDROM Linux All CDROM code. Special CDROM devices (such as SoundBlaster CDROM) can be found here. Note The IDE CD driver is the IDE-CD.c in Drivers / Block, while the SCSI CD driver is in the DRivers / SCSI / SCSI.C / PCI PCI Pseudo-Drive. This is a good place to observe how the PCI subsystem is mapped and initialized. Alpha AxP PCI finishing code is also worth viewing in Arch / Alpha / Kernel / Bios32.c, but also finds all Linux supported SCSI devices, but also find all SCSI code / Net here you can find Network device drivers such as DEC CHIP 21040 PCI Ethernet drivers in Tulip.c / Sound All Sound Card Drivers Location File Systems Ext2 File System Source of FS / EXT2 / subdirectory, data structure The definition is in include / Linux / ext2_fs.h, ext2_fs_i.h, and ext2_fs_sb.h. The data structure of the virtual file system is described in INCLUDE / Linux / Fs.h, and the code is fs / *. Buffer Cache and Update The core daemon is all NetWork (network) network code implemented with FS / Buffer.c in the NET subdirectory, most of the include files in include / Net. BSDSocket code in Net / Socket.c, IPv4 INET Socket code in Net / IPv4 / AF_INET.C. The support code of the general protocol (including SK_BUFF Processing Routines) In NET / CORE, TCP / IP network code is in NET / IPv4. Network Device Drivers At the core module code part in the DRIVERS / NET MODULES (module) core, part in the modules package.

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

New Post(0)