MBR BIOS will read 0x7C00 at the address (under x86 platform)

MBR BIOS will read 0x7C00 at the address (under x86 platform)

https://www.cnblogs.com/jikebiancheng/p/6193953.html

http://www.ruanyifeng.com/blog/2015/09/0x7c00.html

https://www.glamenv-septzen.net/en/view/6

 

Author:  Ruan Yifeng

Date:  September 28, 2015

 

"Computer Principle" of books that start, the master boot record will be stored in the memory address 0x7C00.

This strange address, is how come, textbooks do not explain. I always have a question, why not stored in the memory of the head, tail, or other location, but had little into this than 32KB 1024 bytes of place?

Yesterday, I read an article , finally solved the mystery.

 

First of all, if you do not know, master boot record (Master boot record, abbreviated as MBR) what is, you can read "How the computer is started? " .

 

BIOS accordance with the "boot order", the control is transferred to ranked first storage device.

In this case, the computer reads the first sector of the device, i.e. the foremost reads 512 bytes. If the last two bytes of this 512 bytes are 0x55 and 0xAA, indicating that this device can be used to start; if not, indicating that the device can not be used to start, control is then transferred to the next device "startup sequence" in .

This top 512 bytes, called "Master Boot Record" (Master Boot Record, abbreviated as MBR).

 

Master boot record structure

"Master Boot Record" is only 512 bytes, not to put too many things. Its main role is to tell the computer where to look for a position hard disk operating system.

The master boot record consists of three parts:

  (1) The first byte 1-446: call the operating system of machine code.

  (2) The 447-510 byte: partition table (Partition table).

  (3) The first byte of 511-512: The master boot record signature (0x55 and 0xAA).

Wherein the action of the second part of the "Partition Table", and the hard disk is divided into several zones.

 

Partition Table

Hard disk partition has many benefits . Considering that each zone can install different operating systems, "Master Boot Record" must know which transfers control to the area.

Only 56 byte partition table, which is divided into four, each 16 bytes. So, a hard disk can only be divided up to four a partition, also called "primary partition."

16 bytes of each primary partition consists of 6 components:

  (1) First byte: if it is 0x80, it means that the primary partition the partition is active, control should be transferred to the partition. Four primary partitions which only one is active.

  (2) 2-4 bytes: a first physical sector of the primary partition location (cylinder, head, sector number, etc.).

  (3) the fifth byte: primary partition type .

  (4) bytes 6-8: primary partitions a physical location of the last sector.

  (5) the first byte 9-12: Logical address of the first sector of the primary partition.

  (6) Byte 13 to 16: Total number of sectors of the primary partition.

The last four bytes ( "total number of primary partition sector"), determines the length of the primary partition. That is, a main branch of the total number of sectors up to a maximum of 2 ^ 32.

If each sector is 512 bytes, it means that a single partition does not exceed the maximum 2TB. Taking into account the logical address of the sector is 32, a single hard disk space available does not exceed the maximum 2TB. If you want to use a larger hard drive, only two ways: First, increase the number of bytes per sector, and second, increasing the total number of sectors .

 

Hard disk

At this time, control of the computer would turn a partition to the hard drive, here is divided into three cases.

Case A: the volume boot record

In the previous section, four primary partitions which only one is active. The computer reads the first sector of the active partition, called the "volume boot record " (Volume boot record, abbreviated to VBR).

The main role of "Volume Boot Record" that tells the computer, the operating system partition in this position. Then, the computer will load the operating system.

Case B: extended and logical partitions

With increasingly hard drive, four primary partitions no longer enough, we need more partitions. However, only four partition table, so there is one and only one predetermined zone may be defined as "extended partition" (Extended partition).

The so-called "extended partition", which refers to this area is divided into multiple zones. This partitioning the inside of the partition, called "logical partitions" (logical partition).

The computer first reads the first sector of the extended partition, called the "Extended Boot Record" (Extended Boot Record, abbreviated as EBR). Inside it also contains a 64-byte partition table, but only a maximum of two (i.e., two logical partitions).

The computer then reads a second sector of the first logical partition, to find the position of a third logical partition in the partition table from the inside, and so on until a logical partition in the partition table contains only itself up ( That is only one partition entry). Thus, the extended partition can contain many logical partitions.

However, few seem to start the operating system in this way. If the operating system is actually installed in the extended partition, commonly used at one way to start.

 

Simply put, the computer starts is such a process.

  1. power ups
  2. Inside the program ROM BIOS, hardware used to check
  3. By checking hardware
  4. According to the order specified BIOS, checking first sector of the boot device (i.e., the master boot record), the memory address loaded 0x7C00
  5. The operation of the master boot record to the operating system

Therefore, the master boot record is to guide the "operating system" is a small program into the memory, the size of not more than one sector (512 bytes).

 

 

0x7C00 the address of the first generation of personal computer chips from Intel in 8088 , after the CPU in order to maintain compatibility, has been using this address.

 

 

August 1981, IBM's first personal computer company IBM PC 5150 listed on the use of this chip.

 

 

At that time, with the operating system 86-DOS . The operating system requires a minimum of memory is 32KB. We know that memory address numbering starts at 0x0000, 32KB of memory is 0x0000~0x7FFF.

8088 chip itself needs to occupy 0x0000~0x03FF, to hold various interrupt handler storage location. (Master boot record is itself an interrupt signal INT 19h handler.) Therefore, only the memory 0x0400~0x7FFFmay be used.

In order to leave as much contiguous memory operating system, the master boot record is placed in the tail of the memory address. Since one sector is 512 bytes, the master boot record itself may generate the data, leaving 512 bytes requires additional storage. So, it becomes a placeholder:


  0x7FFF - 512 - 512 + 1 = 0x7C00 

0x7C00 comes out of this.

After the computer starts, 32KB memory usage as follows.


+--------------------- 0x0 | Interrupts vectors +--------------------- 0x400 | BIOS data area +--------------------- 0x5?? | OS load area +--------------------- 0x7C00 | Boot sector +--------------------- 0x7E00 | Boot data/stack +--------------------- 0x7FFF | (not used) +--------------------- (...)

 

============== End

 

Author:  Ruan Yifeng

Date:  September 28, 2015

 

"Computer Principle" of books that start, the master boot record will be stored in the memory address 0x7C00.

This strange address, is how come, textbooks do not explain. I always have a question, why not stored in the memory of the head, tail, or other location, but had little into this than 32KB 1024 bytes of place?

Yesterday, I read an article , finally solved the mystery.

 

首先,如果你不知道,主引导记录(Master boot record,缩写为MBR)是什么,可以先读《计算机是如何启动的?》

 

BIOS按照"启动顺序",把控制权转交给排在第一位的储存设备。

这时,计算机读取该设备的第一个扇区,也就是读取最前面的512个字节。如果这512个字节的最后两个字节是0x55和0xAA,表明这个设备可以用于启动;如果不是,表明设备不能用于启动,控制权于是被转交给"启动顺序"中的下一个设备。

这最前面的512个字节,就叫做"主引导记录"(Master boot record,缩写为MBR)。

 

主引导记录的结构

"主引导记录"只有512个字节,放不了太多东西。它的主要作用是,告诉计算机到硬盘的哪一个位置去找操作系统。

主引导记录由三个部分组成:

  (1) 第1-446字节:调用操作系统的机器码。

  (2) 第447-510字节:分区表(Partition table)。

  (3) 第511-512字节:主引导记录签名(0x55和0xAA)。

其中,第二部分"分区表"的作用,是将硬盘分成若干个区。

 

分区表

硬盘分区有很多好处。考虑到每个区可以安装不同的操作系统,"主引导记录"因此必须知道将控制权转交给哪个区。

分区表的长度只有64个字节,里面又分成四项,每项16个字节。所以,一个硬盘最多只能分四个一级分区,又叫做"主分区"。

每个主分区的16个字节,由6个部分组成:

  (1) 第1个字节:如果为0x80,就表示该主分区是激活分区,控制权要转交给这个分区。四个主分区里面只能有一个是激活的。

  (2) 第2-4个字节:主分区第一个扇区的物理位置(柱面、磁头、扇区号等等)。

  (3) 第5个字节:主分区类型

  (4) 第6-8个字节:主分区最后一个扇区的物理位置。

  (5) 第9-12字节:该主分区第一个扇区的逻辑地址。

  (6) 第13-16字节:主分区的扇区总数。

最后的四个字节("主分区的扇区总数"),决定了这个主分区的长度。也就是说,一个主分区的扇区总数最多不超过2的32次方。

如果每个扇区为512个字节,就意味着单个分区最大不超过2TB。再考虑到扇区的逻辑地址也是32位,所以单个硬盘可利用的空间最大也不超过2TB。如果想使用更大的硬盘,只有2个方法:一是提高每个扇区的字节数,二是增加扇区总数

 

硬盘启动

这时,计算机的控制权就要转交给硬盘的某个分区了,这里又分成三种情况。

情况A:卷引导记录

上一节提到,四个主分区里面,只有一个是激活的。计算机会读取激活分区的第一个扇区,叫做"卷引导记录"(Volume boot record,缩写为VBR)。

"卷引导记录"的主要作用是,告诉计算机,操作系统在这个分区里的位置。然后,计算机就会加载操作系统了。

情况B:扩展分区和逻辑分区

随着硬盘越来越大,四个主分区已经不够了,需要更多的分区。但是,分区表只有四项,因此规定有且仅有一个区可以被定义成"扩展分区"(Extended partition)。

所谓"扩展分区",就是指这个区里面又分成多个区。这种分区里面的分区,就叫做"逻辑分区"(logical partition)。

计算机先读取扩展分区的第一个扇区,叫做"扩展引导记录"(Extended boot record,缩写为EBR)。它里面也包含一张64字节的分区表,但是最多只有两项(也就是两个逻辑分区)。

计算机接着读取第二个逻辑分区的第一个扇区,再从里面的分区表中找到第三个逻辑分区的位置,以此类推,直到某个逻辑分区的分区表只包含它自身为止(即只有一个分区项)。因此,扩展分区可以包含无数个逻辑分区。

但是,似乎很少通过这种方式启动操作系统。如果操作系统确实安装在扩展分区,一般采用下一种方式启动。

 

简单说,计算机启动是这样一个过程。

  1. 通电
  2. 读取ROM里面的BIOS,用来检查硬件
  3. 硬件检查通过
  4. BIOS根据指定的顺序,检查引导设备的第一个扇区(即主引导记录),加载在内存地址 0x7C00
  5. 主引导记录把操作权交给操作系统

所以,主引导记录就是引导"操作系统"进入内存的一段小程序,大小不超过1个扇区(512字节)。

 

 

0x7C00这个地址来自Intel的第一代个人电脑芯片8088,以后的CPU为了保持兼容,一直使用这个地址。

 

 

1981年8月,IBM公司最早的个人电脑IBM PC 5150上市,就用了这个芯片。

 

 

当时,搭配的操作系统是86-DOS。这个操作系统需要的内存最少是32KB。我们知道,内存地址从0x0000开始编号,32KB的内存就是0x0000~0x7FFF

8088芯片本身需要占用0x0000~0x03FF,用来保存各种中断处理程序的储存位置。(主引导记录本身就是中断信号INT 19h的处理程序。)所以,内存只剩下0x0400~0x7FFF可以使用。

In order to leave as much contiguous memory operating system, the master boot record is placed in the tail of the memory address. Since one sector is 512 bytes, the master boot record itself may generate the data, leaving 512 bytes requires additional storage. So, it becomes a placeholder:


  0x7FFF - 512 - 512 + 1 = 0x7C00 

0x7C00 comes out of this.

After the computer starts, 32KB memory usage as follows.


+--------------------- 0x0 | Interrupts vectors +--------------------- 0x400 | BIOS data area +--------------------- 0x5?? | OS load area +--------------------- 0x7C00 | Boot sector +--------------------- 0x7E00 | Boot data/stack +--------------------- 0x7FFF | (not used) +--------------------- (...)

Guess you like

Origin www.cnblogs.com/lsgxeva/p/11183693.html