freePCtech (click here to return to the first page) Search the
    siteHelp on using this siteHome

    Articles / Reviews

BIOS Basics

by Drew Dunn

You deal with your computer’s BIOS every time you turn it on. You’ve probably looked at its settings, maybe even upgraded it. But do you really know what’s going on with it? Beyond flashing some info on the screen when your computer starts, what does it do? Why is it so important? And what makes it so special?

The Basic Input/Output System chip installed on your computer’s motherboard is a little bit like the starter motor in your car. Until you turn the key and crank over the motor, that shiny auto in your driveway is a lot of steel and plastic that just takes up space. The same sort of thing happens with your computer. When you hit the power switch, the BIOS tells the computer what it’s supposed to do. Without it, your computer is just a pile of parts in a box.

So if it’s that simple, what’s the big deal? Well, it’s not really that simple, of course. A typical computer BIOS is really quite a programming marvel. A ton of code is packed into that chip, code that not only has to jump-start your CPU, but also maintain compatibility with any operating system that runs on your system, from DOS to Windows to UNIX.

What happens when you turn on your computer? Since 32-bit Intel-compatible processors can address up to 4GB of RAM, the motherboard’s chipset tells the CPU to look at the very top 16 bytes of that memory. An instruction is strategically placed there that redirects the CPU to a special area of memory, the top 16 bytes of the first megabyte of memory. Why is this area special? Going back to the first days of Intel processors, a megabyte was all that a memory address controller could see. So a standard was established that reserved 16 bytes of the top of that memory space for some critical functions of the BIOS, a highly compressed computer program typically written in assembly language and customized for a particular chipset and processor type.

So power hits the system, the CPU wakes up and tells the chipset to look at the top of the memory stack. It gets redirected to the top of the first megabyte and executes the code that it finds there. That code activates enough of the CPU to enable it to decompress the BIOS code. Once that happens, the BIOS code identifies the system, setting values in certain chipset registers, such as the number of CPUs present, the CPU stepping and brand (among others).

Next, the BIOS looks at memory. If the system memory modules have a serial presence device (SPD), the BIOS will use that data to configure how the chipset and processor handle the memory. An SPD contains information about each memory module, including the CAS latency, amount of memory on each module, how many banks of memory are on each module, as well as some additional timing data. If there is no SPD present, the BIOS will simply assume worst case conditions for memory performance for any memory parameter that can’t be determined by probing the memory.

There are some differences between how a BIOS handles single data rate versus double data rate memories. For SDR, the BIOS relies on the chipset to probe all of the memory to determine how much is installed. This isn’t the familiar memory counting display that you see when the system starts…by the time that happens, the BIOS has already finished its work. For DDR, the job is much more complicated.

The BIOS depends on the SPD to contain all of the above parameters for DDR memory. That data is stored in CPU registers as the BIOS configures the chipset to control the memory. Since there are relatively few CPU registers available for this, the BIOS uses a lot of small SPD reads to effectively manage the limited storage space.

Timing is absolutely critical for DDR memory, much more so than with SDR. The strobe signals that cause data to be clocked in and out of memory have to be perfectly centered with the data signals. The BIOS directs the chipset to accomplish this through trial and error, by sending a series of strobe and data signals with increasing delays

Once the memory is configured, the BIOS directs the chipset to copy the BIOS code into an area of memory, a process called shadowing. The BIOS is shadowed in a very specific area of RAM, from address E0000h to FFFFFh, the end of the first megabyte of RAM. Since the system’s memory typically runs much faster than the read-only memory of the BIOS, the BIOS code executes much more efficiently here. Also, the entire BIOS program becomes available to the processor for execution, instead of just the small portion that uses the CPU’s registers.

After the BIOS is shadowed, the BIOS looks out to other devices on the PCI bus. The PCI specification requires that all “option” BIOSes on the bus be shadowed. What kinds of cards have BIOSes that need to be shadowed? Typically things like SCSI controllers and a few network cards. They are copied into memory addresses C8000h through E0000h, right below the area of the system BIOS. The video BIOS has a special area of its own, C0000h to C8000h. While this allows the video system to run much more quickly, it poses some special problems that we’ll look at a bit later.

Once all of the shadowing is done, the PCI bus gets initialized. Interrupts and DMA channels are assigned to those devices that are required for the computer to boot, but other devices are left alone for the operating system to initialize later. This is particularly important for plug and play operating systems like Windows and recent versions of Linux.

At this point, the computer knows that it’s a computer. You see the video card flash its banner screen and the boot-up screen pops up, counting memory and displaying a bit of system information. Now the BIOS turns to the task of loading the operating system.

The last thing that the BIOS does is execute the boot loader. This is a piece of code that sits in a very specific are of the lower 640K of memory, again dating back to the days of the earliest PCs. A table of all of the interrupt vectors is created in the first kilobyte of memory, the boot loader executes and the computer loads the operating system based on the device location that was previously specified by the user. When the operating system loads (except for DOS), the interrupt vector table is moved to a different area of memory (as dictated by the OS being loaded) and the BIOS is no longer running.

In the case of DOS, the BIOS continues handling the real time clock and services interrupts using the vector table. Other operating systems handle both tasks themselves, effectively ignoring the BIOS.

A feature controlled by the BIOS is the System Management Interrupt. It maintains the highest priority in the system. When this interrupt is activated, the computer goes to “sleep”. The area that is being used by the video shadow is replaced with blank RAM and the contents, or state, of the CPU is swapped into it. The BIOS code for an SMI interrupt is also swapped into that area and executed to gracefully shut down the computer and retain the last state that it was in.

The problem with SMI is that it is transparent to the operating system. That means that Microsoft isn’t particularly happy about it, so an alternative has become more popular: ACPI. The Advanced Configuration and Power Interface is an extension to the BIOS code that is shadowed near the top of the 4GB memory space and is controlled by the operating system.

When a suspend to RAM command is received, the ACPI extensions are activated. The state of the system is saved to RAM and the system then shuts off. In its earliest incarnations, this created a problem for video cards that were not ACPI aware. The video BIOS would be shadowed, but would not know that the card was off. When the system was restarted, the video card would go through its power on process, but the shadowed information would not match the state that the video card was in, causing some serious display problems. This issue was overcome two ways. First, most BIOSes will save a copy of the video BIOS both pre and post shadowing and manipulate them into tricking the video card that nothing is wrong. The second way, and the way that all modern video cards work, is that ACPI support is now built into the video cards themselves.

So now you have it in a nutshell. Turning on your computer isn’t just as simple as flicking a switch and waiting for bootup. A lot goes on between the time that your finger hits the button and the time that your monitor comes to life.

If you’re looking for more information on BIOSes, try these sites:

Award Software BIOSes
Phoenix Technologies BIOSes
Wim’s BIOS Page

Or, just do a Google search on BIOS.


Articles / Reviews



Free PC Tech

Copyright The NOSPIN Group, Inc. 1991-2006.  All rights reserved.