Linux-0.11 startup process analysis

  

When the PC is powered on, the 80x86 architecture CPU will automatically enter the real mode (refer to the same 16-bit segment and offset as the 8086 addressing, the maximum addressing space is 1MB, the maximum score Segment 64KB. 32-bit instructions can be used. 32-bit x86 CPUs are used for high-speed 8086), and the code is automatically executed from address 0xF000:0xFFF0 (this address is usually the address in the BIOS ROM). This code is a far jump. Command: jmp far 0xF000: 0xE05B. At this time, the BIOS starts to perform some system detection and setting (POST power-on self-test, interrupt routine, system setup program, etc., and starts to initialize the interrupt vector at physical address 0. After that, it will start the device first. The sector (disk boot sector, 512 bytes) is read into the memory absolute address 0x0000: 0x7C00, which is 31KB, and jumps to this place to start execution. The file being read is written in 8086 assembly (boot/bootsect .s).

bootect.s will move itself to the absolute address of memory 0x90000 (576KB) and read the 2KB byte code (boot/setup.s) after booting the device into memory 0x90200 The other part of the kernel (systen module) is read into the memory address 0x10000 (64KB),

setup.s The program will move the system module to the physical memory start position. Obtain the system data in the BIOS and put the data into the appropriate location in the system memory. Then load the interrupt descriptor table register (idtr) and the global descriptor table register (gdtr), open the A20 address line, and reset the two interrupt controls. Chip 8259A, will be in the hardware The break number is reset to 0x20~0x2f. Finally, the CPU's control register CR0 (machine status word) is set, so that it enters the 32-bit protection mode and jumps to the head.s program at the foremost part of the system module to continue execution.

head.s program completion, has officially completed the memory page directory and page table settings, and reset the kernel actually used interrupt description table idt and global descriptor table gdt. Also opened for the floppy disk driver 1 KB byte buffer.

Copyright © Windows knowledge All Rights Reserved