BIOS

From Gentoo Wiki
Jump to:navigation Jump to:search

The BIOS (Basic Input/Output System) was the standard firmware of IBM-PC-compatible computers until it was phased out in 2020. On a cold start, the BIOS performs system initialization, then hands loads the Master Boot Record of the boot device specified in CMOS memory, and hands off execution to the boot loader.

When it was originally released in 1983, BIOS was an entirely proprietary IBM product. Eventually, companies reverse engineered and documented the inner workings of the BIOS leading to a de facto standard. At first, this compatibility was incomplete but it grew and evolved over time until essentially 100% software compatibility existed between BIOS vendors.

Early BIOS implementations were written to ROM or EEPROM. This meant that upgrading the BIOS to address a required physically replacing the ROM chip. This is contrast to very late BIOS implementations and modern UEFI implementations where the firmware code is stored on flash memory. This change from read only memory to flash memory has security implications: malicious code can sometimes attach itself to the flash storage of firmware to evade detection or complicate removal.

Configuration

In order to configure the system, users need to enter the BIOS setup program by pressing a specific key at startup, usually within 2 seconds of hearing the start-up beep. This key press is not initially standardized and required users to check documentation in order to gain access to the system's firmware settings. By the mid 1990's a de facto standard began to emerge around a few possible keyboard combinations, with F2 being the most common.

By the late 1980's some BIOS manufacturers printed a notice on cold start indicating what button combination to press in order to enter the firmware configuration screen. Unfortunately, this practice was not uniform and early systems could have quite obscure keyboard input combintation requirements. This often lead to system administrators performing cold boots and simply guessing as to the correct keyboard input combination until their attempts were sucessful or all known combinations had been tried.

In the setup program's menu, users can configure several features:

  • Enable or disable built-in hardware devices.
  • Configure hardware features.
  • Set date and time.
  • Select boot drives and set a preference order.
  • Specify a boot password.

To operate the setup program with a USB keyboard, users may have to enable a function called USB Legacy, or something similar.

Set boot drive and order

Users can use the BIOS setup menu to change the boot drive and to set a preference order. They should set the drive where they installed the bootloader as their first preference, to speed up boot time. It takes time to check optical and floppy disk drives for a valid boot loader, so if those are placed first, the system will not boot as quickly as it might.

For USB boot drives users must enable a function called USB Legacy, or something similar.

Newer BIOS versions let users press a key during boot to open a menu, where they can select the boot drive. This is handy, if they want to boot from a LiveCD. Possible keys are:

  • F11
  • F12

Users can find the right key in their motherboard or computer manual, but it may also be shown at boot time, right after after power on. To show the boot option menu, users must press the right key about two seconds after power on, even if there is no screen displayed.

BIOS Memory Map

Once the BIOS has been initialized, RAM below 1MiB looks like this:

Start Stop Size Description
0x00000000 0x000003ff 1KiB Interrupt Vector Table (IVT) in Protected Mode.
0x00000400 0x000004ff 256B BIOS Data Area (BDA).
0x00000500 0x00007bff 29.75KiB Conventional memory available to programs.
0x00007c00 0x00007dff 512B Reserved for Boot Sector.
0x00007e00 0x0007ffff 480.5KiB Conventional memory available to programs.
0x00080000 0x0009ffff 128KiB Extended BIOS Data Area (EBDA).
0x000a0000 0x000bffff 128KiB Video memory.
0x000c0000 0x000c7fff 32KiB Video card BIOS.
0x000c8000 0x000effff 160KiB BIOS Extensions.
0x000f0000 0x000fffff 64KiB Motherboard BIOS

BIOS as a UEFI Application for Backwards Compatibility

When a EFI or UEFI system is set to BIOS compatibility mode, then an EFI application called Compatibility Support Module (CSM) is loaded. The CSM operates as a shim that intercepts BIOS system calls and translates them into their UEFI equivalents, effectively acting as a BIOS emulation.

Booting from a Master Boot Record (MBR) partition means that the firmware must give the system a BIOS-like environment as a starting point, so that BIOS bootsectors and BIOS bootloaders continue to work. When an EFI/UEFI system (with Secure Boot disabled) is booted with an MBR partitioned media, the firmware will automatically load the CSM. It is not available when Secure Boot is enabled, which is the standard setting on computers with Microsoft Windows 10 and newer.

In UEFI after 2020 the Compatibility Support Module was discontinued, and with it all BIOS compatibility. In native (U)EFI mode, the firmware will directly load a compatible EFI bootloader from the EFI System Partition (ESP), which requires a GUID Partition Table (GPT). In theory, none of this prevents the creation of an open source UEFI application that can be installed to the UEFI partition and act as a BIOS emulator. In practice, it's not clear what barriers OEM's might erect to prevent this.

BIOS and Coreboot

Coreboot provides just enough firmware to initialize a system from a cold start and pass execution to a designated payload. While Coreboot itself provides any of several payloads, a UEFI payload is perhaps the most common. Several Coreboot distributions reject UEFI and prefer a SeaBIOS payload by default, but offer alternatives such as booting directly to GRUB or a Linux kernel. From the perspective these Coreboot forks, such as Libreboot, there is a simple reason for preferring a BIOS payload: it provides a much smaller attack surface relative to a UEFI implementation.

See Also

  • BIOS Update — describes how to apply a BIOS update on a Gentoo system.
  • CMOS BIOS Memory — a few bytes of battery-backed SRAM used to preserve BIOS settings and Real Time Clock data when a PC is off.
  • Coreboot — a free and opensource hardware initializing firmware which supports multiple boot ROM payloads.
  • dmidecode — a software tool that enables extraction of detailed hardware information from a system by decoding the DMI (Desktop Management Interface) table
  • Master Boot Record — the boot sector of an IBM PC compatible with BIOS firmware running UEFI firmware in BIOS compatibility mode.
  • Open Firmware — an IEEE 1275-1994 standard Forth-based firmware popularized by PowerPC Macs which sees continued use with the OpenBIOS project.
  • System Initialization of Intel x86 with BIOS Firmware — the process of bringing an Intel x86 system up from a cold start.
  • UEFI — a firmware standard for boot ROM designed to provide a stable API for interacting with system hardware. On x86 it replaced the legacy BIOS.

External Resources

  • Coreboot — open source firmware that can deploy BIOS and UEFI (among others) as second stage payloads.
  • GLaBIOS — A modern, scratch-built, open-source ROM BIOS for PC, XT, 8088 PCs.