Reading Diary (1)

xiaoxiao2021-03-06  117

This article comes from: http: //os.silversand.net Author: sunmoon (2001-08-31 10:00:00)

The first time read the kernel, before the test, the exam is in the exam. Harihu passed, 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 First grasp it, then cut in some specific points. So in this way is very important, so I first use the dmesg command to check the message when Linux started. (I think the source file should be /usr/src/linux/init/main.c) The launch of the kernel is the last thing to start_kernel (in /init/main.c), that is, the start-up process is from Head.s (Arch / I386 / Boot /) Run to main.c. Its effect is to complete the startup settings and kernel initialization, then, the system is in an unlimited cycle waiting for the user's input, calling the Fork to generate a child process. Thus reaching interactive operation System design requirements. Part 1: Nuclear initialization and startup.. Startup system. When the PC is powered by power-on start, 80x86 processor (CPU) is self-test in real mode, start executing the physical address 0xfff0, ROM-BIOS The code at the start address. 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) Found AT PCI 13/0 (SCSI0) Wide Channel, SCSI ID = 7, 16/255 SCBS (SCSI0) Downloading Sequencer Code ... 419 Instructions Downloaded SCSI0: Adaptec AHA274X / 284X / 294X (EISA / VLB / PCI-FAST SCSI) 5.1.10 / 3.2.4 SCSI: 1 Host. Vendo r: SEAGATE Model: ST32155W Rev: 0596 ype: Direct-Access ANSI SCSI revision: 02 Detected scsi disk sda at scsi0, channel 0, id 0, lun 0 Vendor: SEAGATE Model: ST32155W Rev: 0596 Type: Direct-Access ANSI SCSI Revision: 02 Detected SCSI Disk SDB AT SCSI0, CHANNEL 0, ID 1, LUN 0 SCSI: Detected 2 SCSI Disks Total. (SCSI0: 0: 0: 0) Synchronous at 40.0 MByte / Sec, Offset 8. SCSI Device SDA: HDWR Sector = 512 BYTES. SECTORS = 4197405 [2049 MB] [2.0 GB] (SCSI0: 0: 1: 0) Synchronous at 40.0 mbyte / sec, offset 8. SCSI Device SDB: hdwr sector = 512 bytes. SECTORS = 4197405 [2049 MB] [2.0 GB] Partition CHECK: SDA: SDA1 | SDB: SDB1 SDB2

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

New Post(0)