Why should the Linux boot program load itself to the memory 7c00h?

Source: Internet
Author: User

Introduction to the System Startup Process

The system startup process consists of the following steps (taking the hard disk as an example ):

1. Boot;
2. after the BIOS is powered on or press the reset key, the system must be reset. After the reset, the command address is 0 FFFF: fff0. There is only one JMP command in this place, jump to system self-check (power on self test -- Post)Program;
3. After the system self-check is completed, read the first sector of the hard disk (0-headed, 0-way, 1-sector, that is, Boot Sector) into the memory address 0000: 7c00;
4. Check (Word) 0000: 7dfe whether it is equal to 0xaa55. If it is not equal to, switch to another startup media. If there is no other startup media, the system displays "no rom basic" and then crashes;
5. Jump to 0000: Execute the MBR program at 7c00;
6. the MBR program will first copy itself to 0000: 0600, and then continue to execute;
7. Search for active partitions in the primary partition table. If no active partition is found or more than one active partition exists, stop the operation;
8. Read the first sector of the active partition into the memory address 0000: 7c00;
9. Check (Word) 0000: 7dfe whether it is equal to 0xaa55. If it is not equal, "missing Operating System" is displayed and then stopped, or try a floppy disk to start or;
10. Jump to 0000: 7c00 and continue executing the Startup Program of the specific system;
11. Start the system...

In the above steps, steps 2, 3, and 4 are completed by the BIOS boot program. 6, 7, 8, 9, and 10 are completed by the MBR boot program.

Introduction to the boot sector structure

1. Composition of Boot Sector

The boot sector is the first sector of the hard disk. It consists of three parts: MBR (Master Boot Record), DPT (Disk Partition Table), and Boot Record ID (magic number.

MBR, also known as the Master Boot Record, occupies the first 446 bytes (0 to 0x1bd) of the boot sector and contains a series of Hard Disk parameters and a system main boot program. The Bootstrap program is mainly used to load and run the System Bootstrap program (pilot the operating system) from the active partition after the system hardware self-check is completed ). Its last execution statement is a JMP command, which jumps to the operating system's boot program. This is often the injection point of the boot virus, but also the injection point of various multi-system boot programs. However, because the functions completed by the Bootstrap program are relatively simple, we can fully determine the legitimacy of the Bootstrap program (for example, check the legitimacy of the JMP command) and therefore it is easy to fix. Like the command fdisk/MBR, the MBR and kv300 can be used to kill any type of boot virus.
DPT is the primary partition table. It occupies 64 bytes (0x1be to 0x1fd) and records the basic partition information of the disk. The primary Partition Table is divided into four partition items, each of which is 16 bytes and records the information of each primary partition respectively (therefore, a maximum of four primary partitions can be created ).
The Boot Record ID is the boot zone identifier, which occupies two bytes (0x1fe and 0x1ff). For a valid boot zone, it is equal to 0xaa55, which indicates whether the boot zone is valid.
The detailed structure of the boot sector is shown in:

0000 | ------------------------------------------------ |
|
|
| Master Boot Record |
|
|
| Master Boot Record (446 bytes) |
|
|
|
01bd |
01be | ------------------------------------------------ |
|
01cd | partition information 1 (16 bytes) |
01ce | ------------------------------------------------ |
|
01dd | partition information 2 (16 bytes) |
01de | ------------------------------------------------ |
|
01ed | partition information 3 (16 bytes) |
01ee | ------------------------------------------------ |
|
01fd | partition information 4 (16 bytes) |
| ---------------------------------------------- |
| 01fe | 01ff |
| 55 | AA |
| ---------------------------------------------- |

Hard Disk MBR Master BootCodeAnalysis

1. Procedure

(Boot Sector refers to the first sector in the corresponding partition of the hard disk, which is related to the operating system, and the boot of the operating system is done by it; the MBR Main Boot Program is not responsible for guiding the operating system. MBR is irrelevant to the operating system. Its task is to transfer control to the operating system's boot program .)

1. Move the program code from 0: 7c00h to 0: 0600 H (Note: BIOS places MBR at 0: 7c00h)
2. Search for bootable partitions, that is, the 80 h flag.
Success: goto 3
Failed: Jump to Rom basic
Invalid Partition Table: goto 5
3. Read Boot Sector
Failed: goto 5
Success: goto 4
4. Verify that the final Boot Sector is 55aah
Failed: goto 5
Success: goto 6
5 print errors into infinite Loops
6. Jump to 0: 7c00h to start the next step.

Read the full text

Category:View comments by default

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.