China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-22 15:25
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » Question: How does a computer boot from ROM... View 6,090 Replies 31
Original Poster Posted 2004-08-04 00:00 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 191
Posts 22
Joined 2004-07-30 00:00
21-year member
UID 29317
Gender Male
Status Offline
I don't know if it's appropriate to ask this here, let's ask first. That is, how does the computer execute the first instruction when it starts up? According to my guess, it should be that the first instruction is in the address space pointed to by the initial IP (I remember that Motorola single-chip microcomputers are like this, defaulting to starting at ffff). But the question is: Is the ROM addressing combined with the RAM?

Also: Can the masters provide relevant information and tutorials about the programs in the ROM? The process of the computer booting is too amazing, and I've been wanting to figure it out recently.
Thanks
Floor 2 Posted 2004-08-05 00:00 ·  中国 辽宁 抚顺 联通
银牌会员
★★★
Credits 1,186
Posts 510
Joined 2004-07-30 00:00
21-year member
UID 29279
Gender Male
Status Offline
I want to know too
Floor 3 Posted 2004-08-05 00:00 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 191
Posts 22
Joined 2004-07-30 00:00
21-year member
UID 29317
Gender Male
Status Offline
Comprehensive Understanding of the Computer Boot Process


First, let's understand some basic concepts. The first one is the very familiar BIOS (Basic Input/Output System). BIOS is the bottom-layer code that directly interacts with hardware, and it provides the basic functions for the operating system to control hardware devices. BIOS includes system BIOS (commonly known as the motherboard BIOS), graphics card BIOS, and BIOS of other devices (such as IDE controllers, SCSI cards, or network cards, etc.). Among them, system BIOS is the protagonist of this discussion because the computer boot process is carried out under its control. BIOS is generally stored in ROM (read-only storage chips), and even when the computer is powered off or loses power, these codes will not disappear.

The second basic concept is the memory address. Our machine generally has 32MB, 64MB, or 128MB of memory installed. Each byte of this memory is assigned an address for the CPU to access the memory. The address range of 32MB in hexadecimal is 0 - 1FFFFFFH. Among them, the low-end 1MB memory from 0 - FFFFFH is very special because the initial 8086 processor can only access a maximum of 1MB of memory. The low-end 640KB of this 1MB is called base memory, while A0000H - BFFFFH is reserved for the video memory of the graphics card, and C0000H - FFFFFH is reserved for BIOS. Among them, system BIOS generally occupies the last 64KB or a little more space, graphics card BIOS is generally at C0000H - C7FFFH, and IDE controller BIOS is at C8000H - CBFFFH.

Step 1: When we press the power switch, the power supply starts to supply power to the motherboard and other devices. At this time, the voltage is not very stable. The control chipset on the motherboard will send and maintain a RESET signal to the CPU, so that the CPU internal automatically restores to the initial state, but the CPU will not execute instructions immediately at this moment. When the chipset detects that the power supply has started to supply power stably (of course, the process from unstable to stable is just a moment), it will remove the RESET signal (if it is restarting the machine by manually pressing the Reset button on the computer panel, then when the button is released, the chipset will remove the RESET signal). The CPU immediately starts to execute instructions from address FFFF0H. From the previous introduction, this address is actually within the address range of system BIOS. Whether it is Award BIOS or AMI BIOS, only a jump instruction is placed here, jumping to the real boot code in system BIOS.

Step 2: The boot code of system BIOS first needs to do POST (Power-On Self Test). The main task of POST is to detect whether some key devices in the system exist and can work normally, such as memory and graphics card, etc. Since POST is the earliest detection process, at this time the graphics card has not been initialized. If system BIOS finds some fatal errors during the POST process, such as not finding memory or having problems with memory (at this time, only 640K conventional memory is checked), then system BIOS will directly control the speaker to make a sound to report the error. The length and number of sounds represent the type of error. Under normal circumstances, the POST process is very fast, and we can hardly feel its existence. After POST ends, other codes will be called to perform more complete hardware detection.

Step 3: Next, system BIOS will look for the BIOS of the graphics card. As mentioned earlier, the starting address of the ROM chip storing graphics card BIOS is usually set at C0000H. After system BIOS finds the graphics card BIOS here, it will call its initialization code, and the graphics card BIOS will initialize the graphics card. At this time, most graphics cards will display some initialization information on the screen, introducing the manufacturer, graphics chip type, etc., but this screen almost flashes by. System BIOS then will look for the BIOS programs of other devices. After finding them, it will also call the initialization codes inside these BIOS to initialize the relevant devices.

Step 4: After finding the BIOS of all other devices, system BIOS will display its own boot screen, which includes the type, serial number, and version number of system BIOS, etc.

Step 5: Then system BIOS will detect and display the type and working frequency of the CPU, and then start testing all RAM and at the same time display the progress of memory testing on the screen. We can decide in the CMOS settings to use a simple and time-consuming test or a detailed and time-consuming test method.

Step 6: After the memory test passes, system BIOS will start to detect some standard hardware devices installed in the system, including hard disks, CD-ROMs, serial ports, parallel ports, floppy drives, etc. In addition, most relatively new versions of system BIOS will also automatically detect and set memory timing parameters, hard disk parameters, and access modes, etc., in this process.

Step 7: After the detection of standard devices is completed, the code in system BIOS that supports plug and play will start to detect and configure the plug and play devices installed in the system. After each device is found, system BIOS will display the name and model of the device on the screen, and at the same time allocate interrupts, DMA channels, and I/O ports, etc., for this device.

Step 8: Up to this step, all hardware has been detected and configured. Most system BIOS will clear the screen again and display a table at the top of the screen, which roughly lists various standard hardware devices installed in the system, as well as the resources they use and some relevant working parameters.

Step 9: Next, system BIOS will update ESCD (Extended System Configuration Data). ESCD is a means for system BIOS to exchange hardware configuration information with the operating system. These data are stored in CMOS (a small piece of special RAM powered by the battery on the motherboard). Usually, ESCD data are only updated when the system hardware configuration changes. So we cannot see the information like "Update ESCD... Success" every time we start the machine. However, the system BIOS of some motherboards uses a different data format from Windows 9x when saving ESCD data. Then Windows 9x will modify the ESCD data into its own format during its own boot process. But when starting the machine next time, even if the hardware configuration has not changed, system BIOS will change the ESCD data format back. In this way, a cycle will occur, which will lead to system BIOS updating ESCD every time the machine is started. This is the reason why some machines display relevant information every time they are started.

Step 10: After ESCD is updated, the boot code of system BIOS will carry out its last task, that is, boot from a floppy disk, hard disk, or CD-ROM according to the boot sequence specified by the user. Taking booting from the C drive as an example, system BIOS will read and execute the master boot record on the hard disk. The master boot record then finds the first active partition from the partition table, and then reads and executes the partition boot record of this active partition. The partition boot record will be responsible for reading and executing IO.SYS, which is the most basic system file of DOS and Windows 9x. IO.SYS of Windows 9x first needs to initialize some important system data, and then display the familiar blue sky and white clouds. Under this screen, Windows will continue to carry out the boot and initialization work of the DOS part and the GUI (Graphical User Interface) part.

If there is a tool software that can boot multiple operating systems installed in the system, usually the master boot record will be replaced with the boot code of this software. These codes will allow the user to select an operating system, and then read and execute the basic boot code of this operating system (the basic boot code of DOS and Windows is the partition boot record).

The above introduction is the various initialization work that the computer needs to complete when turning on the power switch (or pressing the Reset key) for cold boot. If we press the Ctrl + Alt + Del combination key under DOS (or select to restart the computer from Windows) to perform hot boot, then the POST process will be skipped, and it will start directly from step 3. In addition, the detection of the CPU and the memory test in step 5 will not be carried out again. We can see that whether it is cold boot or hot boot, system BIOS repeatedly carries out these things that we usually don't pay much attention to. However, it is these monotonous hardware detection steps that provide the basis for us to use the computer normally.
Floor 4 Posted 2004-08-06 00:00 ·  中国 辽宁 抚顺 联通
银牌会员
★★★
Credits 1,186
Posts 510
Joined 2004-07-30 00:00
21-year member
UID 29279
Gender Male
Status Offline
Good
Floor 5 Posted 2004-08-06 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
The introduction is very detailed and accurate. It's hard to describe it so clearly and concisely just by memory without referring to materials.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 6 Posted 2004-08-06 00:00 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 191
Posts 22
Joined 2004-07-30 00:00
21-year member
UID 29317
Gender Male
Status Offline
I copied this from a website, definitely not written by myself, forgot to declare it~~
Floor 7 Posted 2004-08-06 00:00 ·  中国 辽宁 抚顺 联通
银牌会员
★★★
Credits 1,186
Posts 510
Joined 2004-07-30 00:00
21-year member
UID 29279
Gender Male
Status Offline
Floor 8 Posted 2004-08-06 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
Yes, when reposting an article, it's best to provide the original link. This is respect for others' copyright.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 9 Posted 2004-08-06 00:00 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 191
Posts 22
Joined 2004-07-30 00:00
21-year member
UID 29317
Gender Male
Status Offline
I'm used to saving good materials I come across and not being used to posting everywhere, so I don't care about the original post's source. I just want to post it here for those who want to see it this time. If it's inappropriate, I'll delete it.
Floor 10 Posted 2004-08-06 00:00 ·  中国 河北 石家庄 联通
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
Hehe, deleting it would be throwing the baby out with the bathwater. Let's post it back again. But just note it's a reprinted article when posting it back.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 11 Posted 2004-08-06 00:00 ·  中国 广东 清远 联通
中级用户
★★
Credits 378
Posts 88
Joined 2004-05-05 00:00
22-year member
UID 23815
Gender Male
Status Offline
There are no legitimate software on my computer, and my wallet doesn't allow me to "respect" the authors!
www.51ct.net
Floor 12 Posted 2004-08-07 00:00 ·  IANA 局域网IP(Private-Use)
初级用户
Credits 191
Posts 22
Joined 2004-07-30 00:00
21-year member
UID 29317
Gender Male
Status Offline
Okay, post it again, as you all say. It seems to be copied from chinaunix.
Floor 13 Posted 2004-10-02 00:00 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re All:
The CPU will immediately start executing instructions from address FFFF0H

I have some questions regarding this sentence. The concept of address seems to be related to RAM (memory), while BIOS code instructions are in ROM (whether erasable or not). And this address FFFF:0, as I know, is the starting address where ROM is "mapped" into RAM. This "mapping" process must occur after the POST process, because the validity of RAM must be detected first before mapping can be possible. That is to say, before POST, address FFFF:0 should not exist, so how can the CPU start executing from here?
There are similar issues with the BIOS of the graphics card. Also, C0000 does not seem to be "graphics card BIOS". I only know that in early PC machines, it was used as a screen buffer for color monitors (640*480*16), but modern graphics cards are no longer used in this way.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 14 Posted 2004-10-02 00:00 ·  中国 天津 南开区 联通
高级用户
★★
Credits 924
Posts 243
Joined 2003-07-09 00:00
22-year member
UID 6612
Gender Male
Status Offline
Hmm, I think that's determined by the hardware connection. At the beginning, there was no mapping. ffff:0 is actually the ROM area
Floor 15 Posted 2004-10-03 00:00 ·  中国 广东 珠海 联通
中级用户
★★
bbpc
Credits 340
Posts 107
Joined 2004-04-11 00:00
22-year member
UID 22257
Gender Male
Status Offline
The highest address of the 4G space in BIOS. In real mode, BIOS cannot be directly read. The first instruction of power-on reset is accurately placed at FFFFFFF0H. Hardware implements decoding, and the first instruction is a jump instruction, jumping to the real entry. Part of the BIOS code is executed in ROM. Before testing RAM, RAM cannot be used, and all registers can be used. The display buffer of VGA is from a000:0000 to b000:ffff, and the video extension BIOS is from C0000H to C7FFFH.
x86!dos!
爱你就象老鼠爱大米
http://www.baby-pc.com/
Forum Jump: