Reading nuclear diary (a) This article comes from: http: //os.silversand.net Author: sunmoon (2001-08-31 10:00:00)
I started my reading today. I read the kernel for the first time. Before going to school, Harihu was painted, did not gain. This time I swear to completely read it. In the face of nearly 50 m source code , Confusion is inevitable, so I decided to first grasp it, and then cut in some specific points. So the LINUX startup process is very important, so I first use the dmesg command to check the message when Linux started. (I think source files should be in /usr/src/linux/init/main.c) The launch of the kernel is finally start_kernel (in /init/main.c) means that the start-up process is from Head.s ( Arch / i386 / boot /) has been running to main.c (start_kernel). Its role is to complete the initialization of the setup and kernel, then, the system is in an unlimited loop waiting for the user's input, calling for generation Sub process. The design requirements for interactive operating systems are achieved. The first part: the initialization of kernel and startup.. Start the system. When the PC is powered on, the 80x86 processor (CPU) is self-test in real mode, start execution Physical address 0xfff0 is the code at the start address of the ROM-BIOS. The BIOS of the PC performs system self-test, and initializes the interrupt vector table to the physical address 0x0. The first sector of the boot device is then loaded to the address 0x7c00, and the instructions are performed. It is not related to Linux, the X86 series hardware is set. Linux's kernel itself cannot be booted, so the role of LILO and Loadlin is to load the system kernel. The principle of LILO can refer to Lilo's readme. Load from power-up to kernel The process is: Power-Power -> Perform BIOS-> Loading the first sector -> LILO-> The initial part of the LINUX kernel is written in assembly language (file is boot / bootsect.s). (My assembly level is limited, I don't think about it). It first moves itself to the absolute address 0x90000, load the following 2K code from the boot device to the address 0x90200, the rest of the kernel is loaded to the address 0x10000. Display "Loading ..." when loading the system. Then, the program control is handed over to another real-mode assembler (boot / setup.s). Next, this program moves the entire system from the address 0x10000 to the address 0x1000, enters the protection mode. The program controls the rest of the system, that is, the address 0x1000.
The next step is the decompression process of the system kernel. This part of the code is at address 0x1000 (file /Boot/head.s), which initializes the register, then executes Decompress_kernel (), this function stems from zboot / inflate.c, zboot / Unzip.c and zboot / misc.c three files .... [bootsect.s] uncompress ..... [decompress_kernel ()] main.c ---> start_kernel () Start. Start Printk (banner) Linux Version 2.2.6 (Root @ Lance) (GCC Version 2.7.2.3) (Check the GCC version number, if the version number of the GCC is not enough in /init/main.c, it is not allowed to compile the kernel) # 40 Sun Apr 18 17:44:20 CST 1999 Calling init_time () Print out: detected 199908264 Hz Processor. Then run console_init () -> drivers / char / tty_io.c * / console: Color VGA 80x25 run a loop, Measurement MIPS - It is said to be real-time delay with a determined machine instruction cycle. Calibrating delay loop ... 199.48 BOGOMIPS initialization memory / * init_mem * / memory: 63396k / 65536k available (848k kernel code, 408k reserved, 856k DATA, 28K / ** DQUOTE_INIT () ** / VFS: Diskquotas Version DQUOT_6.4.0 Initialized DQUOT_6.4.0 Initialized to view the type of CPU (after 2.2.14, I heard the support for multiple CPUs, I will have a heart, IF I can Find a bug of intel kil1 ... CPU: Intel Pentium Pro STEPPING 09 Initial or Processor and Cooperator, for a relatively old processor, Linux uses software analog coprocessors? Checking 386/387 coupling .. OK, FPU US ING Exception 16 Error Reporting. Checking 'HLT' INSTRUCTION ... OK. POSIX Conformance Testing by Unifix Since then, Linux_thread (init, .., ..,) (Arch / i386 / kernel / process.c) Create a process running init. Enter the second phase user mode (user_mode) end of start_kerne finally entered the initialization of the device for the initialization of the device for the first part of the device. INIT () - -> Do_basic_init () -
PCI_INIT () Initialization to the PCI device (such a paragraph of IFDEF PCI ... need to be taken on the main.c file) The following results: PCI: PCI BIOS Revision 2.10 Entry AT 0xFD8D1 PCI: Using Configuration Type 1 PCI: Probing PCI Hardware's initialization of socket, socket_init () (this may be Linux network secret, I will pay attention to my attention) -linux net4.0 for Linux 2.2 based Upon Swansea University Computer Society Net3.039 Net4: UNIX Domain Sockets 1.0 for . Linux NET4.0 NET4: Linux TCP / IP 1.0 for NET4.0 IP Protocols:. ICMP, UDP, TCP Starting kswapd v 1.5 kswapd_setup () call device_setup () Detected PS / 2 Mouse Port initialize the sound card Sound initialization started Sound initialization complete Initialization Floppy Drive (s): FD0 IS 1.44M FDC 0 IS A National Semiconductor PC87306 SCSI Device Initialization (SCSI0)