20199314 Linux kernel principle and analysis of the fourth week of work .md

MenuOS construction

A, Linux kernel source code Introduction

The directory structure of the Linux kernel source code is shown

Which contains a number of subdirectories to store different types of code.

  1. arch: This is the directory schema is associated, stored inside a lot of CPU architectures, such as arm, x86, MIPS, PPC and so on. The study is mainly based on X86 systems, so the focus X86 directory.

  2. block: In linux block, a block device (blocks (integral multiple of bytes, a sector like) in units of access to the whole), SD card, say, iNand, Nand, hard drives and other devices are block. You can almost think block device is the storage device. some directory block decentralization linux system code stored on the device management block.

  3. crypto: English meaning is encrypted. This directory decentralization of some C language code for a variety of common encryption algorithm. For example crc32, md5, sha1 like.

  4. Documentation: which put some documents.

  5. drivers: drive directory, which lists all the categories of hardware device driver source code of linux kernel supports. Is the need to focus on learning part.

  6. firmware: the firmware. What is firmware? In fact firmware is software, but the software is fixed to the inside running IC called firmware: like S5PV210 in the iROM code.
  7. FS: FS is a file system, file system, which lists the realization of various file systems supported by linux.
  8. include: the header file directories, public (various CPU architecture shared) header files are here. Each CPU architecture-specific header files in arch / arm / include directory and its subdirectories.
  9. the init: the init initialization is the meaning of the kernel initialization code when the code is the linux kernel starts this directory.

Two, Linux kernel boot threshold issue

As we all know, high-level language and assembly language, read first from the beginning main.c function, by which the main function is activated, the switching process. But the Linux kernel, although there main.c function, but it is to start by start_kernel function.

Third, the structure (under laboratory building environment) a simple kernel --MenuOS

Step: The Linux system and a simple file system up and running.
First with qemu simulation kernel, bzImage is vmLinux file through the gzip compression, a compressed kernel image. bImage and zImage represent the size of the kernel. Initrd root file system was replaced with rootfs.img.
code show as below:

    $ cd ~/LinuxKernel/
    $ qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img

Since the process of building the Linux kernel on their computers, speed is too slow, no download is unsuccessful download.

Fourth, the use gdb debugging kernel tracking

Gbd trace debugging kernel process, you need to perform the following code:

 qemu -kernel linux-3.18.6/arch/x86/boot/bzImage -initrd rootfs.img -s -S

Which represents the -s freeze up before the gpu initialization, -s representatives create a gdb-server using the default port 1234.

在gdb界面中targe remote之前加载符号表,并用1234这个端口进行连接,代码如下:

 (gdb)file linux-3.18.6/vmlinux 
   target remote:1234

V. Summary

Three main process creation process is init_task (), kernel_init (), kthreadd (). No. 0,1,2 respectively process. Wherein the init_task () derived from the initial process kernel_init (), kthreadd () both the former run user processes, which run the kernel daemons.

Guess you like

Origin www.cnblogs.com/morvalhe/p/11618596.html