当前位置:网站首页>BIOS of operating system

BIOS of operating system

2020-11-09 07:30:00 open_veyfyz58

What happened after the system was powered up

bios It's every chip that comes out and every manufacturer writes about it rom A piece of code , This code runs first after the system is powered on , Responsible for checking whether there are problems with the computer hardware , After confirming that there are no problems , Will go to memory to find the main boot sector mbr, Load the primary boot sector to 0c7c00 The address of ( This part will be explained in detail later ),mbr Will be responsible for loading the operating system in the disk , And then give control to the operating system , thus , Control is left to the operating system .

bios Related content

bios The code is written from the beginning , Put it in rom Inside , therefore ,cpu In the beginning, we should find rom in bios The address of , Then load it to cpu Implementation of , How is this part realized ?
First , The original operating system was 8086 System , The later operating systems are compatible with 8086, So in the first real mode, it's like 8086 System , So let's talk about 8086 System .
8086 yes 16 Bit cpu, But there are 20 Root address bus , therefore , Use base address + Address by offset , Increase the addressing space to 2^20, That is to say 1M Space ( high 16 Bit shift left 4 position , Add low 16 position ).
therefore , At the start of the rom The location determines which address the back system will address at the beginning of power up .
Because different computer manufacturers produce computers with different peripherals , therefore , The size of this program is limited to different models , If the manufacturer A Of rom The size is 1K, manufacturer B Of rom The size is 2K, Then the programmer's starting address will be inconsistent , For the convenience of programmers , It was decided that rom The code for is in 1M At the back of , In this way, programmers can use it from 0 Start writing code , So here comes the question , take BIOS This program is placed in 1M Top of memory , If the program size is 1K, So we should start from 0xFFC00 Let's go . If the size of this program is 2K, that We should start from 0xFF800 Let's go , about CPU for , In the end, we should start from 0xFFC00 It should start with 0xFF800 It's starting to work ?
To solve this problem ,8086 gauge set ,CPU All from 0xFFFF0 Start execution , And in the 0xFFFF0 It's about , Put an unconditional transfer instruction JMP. If A Factory BIOS It's from 0xFFC00 It started to play , So this one The transfer command jumps to 0xFFC00 Start execution . If B Factory BIOS It's from 0xFF800 It started to play , Then the transfer command jumps to 0xFF800 Start execution , Every factory Home can follow what it produces BIOS The size of the program , To determine the specific jump position of the transfer instruction .
thus , The system already knows what to do when powered on ,bios After checking the hardware , Then I decided to load os.
PS: We said bios Put it in rom in , So why does it affect memory , As shown in the figure below :
rom and ram Unified addressing , At the beginning 1M To include rom Of .
 Insert picture description here








mbr Related content

mbr Also called the primary boot sector , To make responsible for will os Load from disk to memory , Why not let bios Direct will os Loading to memory ?
Because when the machine leaves the factory , You can't limit the disk to just one file system , and BIOS It's impossible to identify programs that support all file systems . So for flexibility , Just read through the loader OS.
mbr Its size is 512 Bytes , The last two bytes are 0x55 and 0xAA, Why are these two bytes ?( Baidu to always have an end sign ), These two bytes are used as mbr The end sign of , If you don't have these two end marks ,cpu The disk is not initialized ,
mbr Why 512 Bytes? , This is because mbr It's responsible for loading os The binary code of 446 Bytes , Then the disk has 4 Zones , The information for each partition is 64bytes, And the last two bytes as the end mark ,446+64+2=512bytes
What does the primary boot sector do ? Mainly responsible for reading and writing disk , First, turn on protected mode , Then initialize gdt, Access disk .
Why? mbr Put it on 0x7c00 The location of ?
Operating systems need 32KB Size , It's also at the end .
0x7ffff-512-512+1=0x7c00, Another one 512 Data generated by the primary boot sector itself .






Where is the operating system ?
0x100000, That is to say bios1M Behind . Insert picture description here
thus , The loading of the operating system has finished .

At the end

This article refers to many articles , If you feel copied , Please contact me in time , And I'm so sorry .

版权声明
本文为[open_veyfyz58]所创,转载请带上原文链接,感谢