How BIOS Works

2022/4/12 6:16:20

本文主要是介绍How BIOS Works,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

http://flint.cs.yale.edu/feng/cos/resources/BIOS/

What is BIOS

Every computer with a motherboard includes a special chip referred to as the BIOS or ROM BIOS (Read Only Memory Basic Input/Output System). The BIOS includes instructions on how to load basic computer hardware. The BIOS also includes a test referred to as a POST (Power On Self Test) which will ensure that the computer meets requirements to boot up properly. If the computer does not pass the POST you will receive a combination of beeps indicating what is malfunctioning within the computer.

The BIOS has 4 main functions:

POST - Test computer hardware insuring hardware is properly functioning before starting process of loading Operating System.

Bootstrap Loader - Process of locating the operating system. If capable Operating system located BIOS will pass the control to it.

BIOS - Software / Drivers which interfaces between the operating system and your hardware. When running DOS or Windows you are using complete BIOS support.

CMOS Setup - Configuration program. Which allows you to configure hardware settings including system settings such as computer passwords, time, and date.

What role does the BIOS play with during the system boot up?

How does system bootstrap

The system BIOS is what starts the computer running when you turn it on. The following are the steps that a typical boot sequence involves.

  1. The internal power supply turns on and initializes. The power supply takes some time until it can generate reliable power for the rest of the computer, and having it turn on prematurely could potentially lead to damage. Therefore, the chipset will generate a reset signal to the processor (the same as if you held the reset button down for a while on your case) until it receives the Power Good signal from the power supply.
  2. When the reset button is released, the processor will be ready to start executing. When the processor first starts up, it is suffering from amnesia; there is nothing at all in the memory to execute. Of course processor makers know this will happen, so they pre-program the processor to always look at the same place in the system BIOS ROM for the start of the BIOS boot program. This is normally location FFFF0h, right at the end of the system memory. They put it there so that the size of the ROM can be changed without creating compatibility problems. Since there are only 16 bytes left from there to the end of conventional memory, this location just contains a "jump" instruction telling the processor where to go to find the real BIOS startup program.
  3. The BIOS performs the power-on self test (POST). If there are any fatal errors, the boot process stops. POST beep codes can be found in this area of the Troubleshooting Expert.
  4. The BIOS looks for the video card. In particular, it looks for the video card's built in BIOS program and runs it. This BIOS is normally found at location C000h in memory. The system BIOS executes the video card BIOS, which initializes the video card. Most modern cards will display information on the screen about the video card. (This is why on a modern PC you usually see something on the screen about the video card before you see the messages from the system BIOS itself).
  5. The BIOS then looks for other devices' ROMs to see if any of them have BIOSes. Normally, the IDE/ATA hard disk BIOS will be found at C8000h and executed. If any other device BIOSes are found, they are executed as well.
  6. The BIOS displays its startup screen.
  7. The BIOS does more tests on the system, including the memory count-up test which you see on the screen. The BIOS will generally display a text error message on the screen if it encounters an error at this point; these error messages and their explanations can be found in this part of the Troubleshooting Expert.
  8. The BIOS performs a "system inventory" of sorts, doing more tests to determine what sort of hardware is in the system. Modern BIOSes have many automatic settings and will determine memory timing (for example) based on what kind of memory it finds. Many BIOSes can also dynamically set hard drive parameters and access modes, and will determine these at roughly this time. Some will display a message on the screen for each drive they detect and configure this way. The BIOS will also now search for and label logical devices (COM and LPT ports).
  9. If the BIOS supports the Plug and Play standard, it will detect and configure Plug and Play devices at this time and display a message on the screen for each one it finds. See here for more details on how PnP detects devices and assigns resources.
  10. The BIOS will display a summary screen about your system's configuration. Checking this page of data can be helpful in diagnosing setup problems, although it can be hard to see because sometimes it flashes on the screen very quickly before scrolling off the top.
  11. The BIOS begins the search for a drive to boot from. Most modern BIOSes contain a setting that controls if the system should first try to boot from the floppy disk (A:) or first try the hard disk (C:). Some BIOSes will even let you boot from your CD-ROM drive or other devices, depending on the boot sequence BIOS setting.
  12. Having identified its target boot drive, the BIOS looks for boot information to start the operating system boot process. If it is searching a hard disk, it looks for a master boot record at cylinder 0, head 0, sector 1 (the first sector on the disk); if it is searching a floppy disk, it looks at the same address on the floppy disk for a volume boot sector.
  13. If it finds what it is looking for, the BIOS starts the process of booting the operating system, using the information in the boot sector. At this point, the code in the boot sector takes over from the BIOS. The DOS boot process is described in detail here. If the first device that the system tries (floppy, hard disk, etc.) is not found, the BIOS will then try the next device in the boot sequence, and continue until it finds a bootable device.
  14. If no boot device at all can be found, the system will normally display an error message and then freeze up the system. What the error message is depends entirely on the BIOS, and can be anything from the rather clear "No boot device available" to the very cryptic "NO ROM BASIC - SYSTEM HALTED". This will also happen if you have a bootable hard disk partition but forget to set it active.

 

BIOS is a piece of program. When the system starts, the register EIP is initialized to FFFF0 to execute the JMP instruction there, which leads to the execution of the system BIOS code.

BIOS will initialize other devices; initialize the interrupt vector; find other BIOS programs and run them.

BIOS Extension

Shadowing

A technique used to increase a computer's speed by using high-speed RAM memory in place of slower ROM memory (RAM is about three times as fast as ROM). On PCs, for example, all code to control hardware devices, such as keyboards, is normally executed in a special ROM chip called the BIOS ROM. However, this chip is slower than the general-purpose RAM that comprises main memory. Many PC manufacturers, therefore, configure their PCs to copy the BIOS code into RAM when the computer boots. The RAM used to hold the BIOS code is called shadow RAM.

Links

Relationship between BIOS and Device Driver

 

http://flint.cs.yale.edu/feng/cos/resources/BIOS/model.htm

CPU

CPUID instruction: see Intel Architecture Software Developer's Manual, Volume 2, P3-114.

Control Registers: The five control registers (CR0 through CR5) determine the operating mode of the processor and the characteristics of the currently executing task (see the section titled "Control Registers" in Chapter 2 of the Intel Architecture Software Developer's Manual, Volume 3).

GDTR, LDTR: see Chapter 7 of "Protected Mode Software Architecture". They are used in protected mode for segment management.

 

I/O

Buses:

Connection of the PCI and ISA Busses in a Typical PC

AGP Bus Interface

See http://webster.cs.ucr.edu/Page_AoAWin/HTML/IOa2.html

Ports: 

totally there are 216 I/O ports.

There are 4 classes of ports:

Read-only port: A read-only port is (obviously) an input port. If the CPU can only read the data from the port, then that port is providing data appearing on lines external to the CPU. The system typically ignores any attempt to write data to a read-only port.

Write-only port: A write-only port is always an output port. Writing data to such a port presents the data for use by an external device. Attempting to read data from a write-only port generally returns garbage.

Read-Write Port: A read/write port is an output port as far as the outside world is concerned. However, the CPU can read as well as write data to such a port. Whenever the CPU reads data from a read/write port, it reads the data that was last written to the port.

Dual Port: A dual I/O port is also a read/write port, but reading the port reads data from some external device while writing data to the port transmits data to a different external device.

 

Ports allocation:

Port 00-FF are reserved for the system motherboard (not available for adapter card).  Most systems ignore address lines A1 through A4 for I/O addresses 20h-3Fh. Therefore, you can only see two ports between 20h - 3Fh, which are 1****0 and 1****1 (20h and 21h).

Many motherboards include adapter cards built onto the motherboard. All these built-in adapters use ports in the range 100h to 3ffh.

See undocumented PC page 800 and Ralf Brown's Interrupt List.

 

Input/Output Mechanisms:

There are three basic forms of input and output that a typical computer system will use: I/O-mapped I/O, memory-mapped I/O, and direct memory access (DMA). I/O-mapped input/output uses special instructions to transfer data between the computer system and the outside world; memory-mapped I/O uses special memory locations in the normal address space of the CPU to communicate with real-world devices; DMA is a special form of memory-mapped I/O where the peripheral device reads and writes data in memory without going through the CPU.

Memory-mapped I/O:A memory mapped peripheral device is connected to the CPU's address and data lines exactly like memory. The CPU can use any instruction that accesses memory to transfer data between the CPU and a memory-mapped I/O device.

I/O-mapped I/O: I/O-mapped input/output uses special instructions (In/Out instructions) to access I/O ports.

DMA:the peripheral device accesses memory directly, without using the CPU as an intermediary. A typical DMA controller consists of a pair of counters and other circuitry that interfaces with memory and the peripheral device. One of the counters serves as an address register. This counter supplies an address on the address bus for each transfer. The second counter specifies the number of transfers to complete. Each time the peripheral device wants to transfer data to or from memory, it sends a signal to the DMA controller. The DMA controller places the value of the address counter on the address bus. At the same time, the peripheral device places data on the data bus (if this is an input operation) or reads data from the data bus (if this is an output operation). After a successful data transfer, the DMA controller increments its address register and decrements the transfer counter. This process repeats until the transfer counter decrements to zero.

 

Chipsets: 

Keyboard controller; Super I/O Controller; DMA Controller; Interrupt Controller; AGP Support; Plug and Play support; USB support; Cache Support; memory support; power management support...

 

Memory

Memory Layout and the Memory Map

The High Memory Area and the A20 Line

The Processor Modes (real mode, protected mode, virtual real mode)



这篇关于How BIOS Works的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程