Location: Home Page > Article Article

Popularization of basic computer knowledge for Xiaobai: BIOS, EFI and UEFI detailed explanation!

2023-03-16

It is estimated that many beginners cannot understand this article, but I still recommend that you bite bullet and read it. This article mainly explains such "BIOS" startup methods, and it will be helpful to understand solution of computer startup problems.

BIOS is a program stored in BIOS chip, and now newer computers mostly use UEFI to boot, while early transition computers use EFI to boot. In fact, part of EFI or UEFI is also stored in chip. Since they are similar to BIOS in terms of surface shape and main functions, we also call chip that stores EFI/UEFI EFI/UEFI BIOS chip, and EFI/UEFI is also called BIOS chip EFI / UEFI BIOS, but in fact they are completely different from BIOS, so it's better to remove "bios" tail from back. Let's talk about BIOS, EFI and UEFI in detail.

Popularization of basic computer knowledge for Xiaobai: BIOS, EFI and UEFI detailed explanation!

BIOS is used to perform four main functions: computer hardware self-test, CMOS setup, operating system boot, hardware I/O, hardware interrupt, etc. Therefore, BIOS program can be divided into several modules, mainly Boot Module block management module, CMOS configuration module, advanced configuration data (ESCD) module and DMI hardware data acquisition module, among which boot module is directly responsible for executing BIOS program entry itself, detecting and initializing main computer hardware, ESCD is used to exchange hardware configuration data between BIOS and OS, while DMI acts as an interface between hardware management tool and system level. Through DMI, users can intuitively get any information about equipment. The CMOS setup module is designed to set hardware information and save it to CMOS. This is a BIOS program other than startup initialization. The most commonly used functions.

The BIOS itself is assembly language code that is executed by calling interrupt INT 13H in 16-bit real mode. Since x86-64 is a highly compatible instruction set, and in order to adapt to 16-bit BIOS real mode operating environment, so even if current processor is 64-bit, if it is still running in BIOS (mostly seen on motherboards before 2009), it still runs in 16-bit real mode on boot. The memory that can be directly accessed in 16-bit real mode is only 1MB. Even if you install 4G, 8G, 16G, or 32G memory, only first 1MB will be recognized in BIOS. In this 1 MB of memory, first 640 KB is called main memory, and last 384 KB of memory is reserved for necessary hardware to boot and various BIOSes. After understanding this, let's talk about specific process of starting a computer's BIOS.

When you press power switch, power supply starts supplying power to motherboard and other devices. At this time, voltage is still unstable. On motherboards with northbridge and southbridge, northbridge sends a reset signal to CPU to initialize CPU, voltage stabilization Then reset signal is removed. For current motherboard with one southbridge, CPU regulates a stable voltage to achieve initialization goal. When voltage is stable, CPU executes a command to jump to beginning of BIOS at memory address reserved by system BIOS and starts to perform POST.

During POST, BIOS only checks for problems with required underlying system hardware, mainly CPU, 640 KB main memory, graphics card, PS/2 keyboard controller is working. , system clock is correct, and so on. Since POST check occurs before video card is initialized, if onAt this stage, an error occurs, it cannot be displayed on screen. However, there is an emergency speaker on motherboard, and if motherboard's 8255 peripheral programmable interface chip is not damaged, POST signal will sound, it should exit. You can roughly judge error by different beeps. In general, a short "beep" basically means a normal start, and different errors are different combinations of a short "beep" and a long "beep". After POST is completed, BIOS begins to call interrupts to perform various hardware initialization tasks.

There are two main points to explain when initializing hardware. First, after POST is detected on computer, boot screen finally appears, which means that graphics card is detected and initialization is completed. But note that since BIOS is running in 16-bit real mode, screen is displayed in VGA resolution (640*480, 4:3 aspect ratio), because VGA is highest supported real mode. Small 14-17" CRT monitors in past had a 4:3 aspect ratio and maximum resolution was relatively low, so this boot screen didn't seem incompatible, but current LCD monitors mostly have a 16:9 widescreen aspect ratio. even higher, so under such a display everything on start screen can be said "terrible" - graphics are stretched, fonts are large and blurry, jaggedness of displayed fonts is clearly visible. Secondly, BIOS only recognizes hard drives initialized with Master Boot Record (MBR), because later EFI or UEFI use new GUID disk partition system (GPT) format, which is not recognized by BIOS. After initializing all hardware, next step is to update ESCD.

During update phase of ESCD, BIOS will detect hardware configuration data stored in CMOS and exchanged with operating system. If system hardware changes, it will update data, otherwise it will not be updated and remain same ESCD detection or After completion BIOS update will perform last task - it will load operating system.

In last step, BIOS reads boot or boot record of corresponding device according to hardware startup sequence specified by user in CMOS, directs operating system on corresponding device to start, and enters operating system. The operating system then takes responsibility for BIOS interaction between hardware and software. If all hardware is found to be unable to load operating system, an appropriate error message will be displayed on screen and computer will be maintained in 16-bit real mode.

Although BIOS is an integral part of turning on and starting a computer, almost 30 years since its introduction in 1975, 16-bitAssembler code, 1M memory addressing, concept of serial call and execution interrupt, and method has not changed at all. Although BIOS has some innovations such as ACPI, USB device support, PnP plug-and- play, but it does not change essence. BIOS in general. These older technologies must retain 16-bit real mode across generations of processors (otherwise they cannot be enabled at all). However, in 2001, Intel developed new Itanium processor, adopted IA-64 architecture, and introduced new EFI. It was later proven that Itanium processor and IA-64 architecture were not popularized, and that EFI and its successor UEFI were ported and have become main pre-boot environment for computers today.

EFI is an acronym for Extensible Firmware Interface. Literally, this translates as Extensible Firmware Interface. It is a miniature system built in a high-level modular language (mostly C). Like BIOS, it basically works. Hardware initialization is completed during process, but directly uses EFI driver boot method to identify system hardware and complete hardware initialization, completely refusing to execute various interrupts. The EFI driver does not target CPU code directly, but is written in EFI bytecode. EFI bytecode is a virtual machine instruction that targets EFI. It must be interpreted and run in EFI DXE driver operating environment in order for EFI to implement communication. It also provides good compatibility. In addition, EFI is fully 32-bit or 64-bit. Rejecting 16-bit real mode, maximum processor addressing can be implemented in EFI, so any information can be stored at any memory address. In addition, since EFI driver development is very simple, EFI-based driver model can in principle make EFI access to all hardware functions, and it is completely possible to read and write files and browse Internet on EFI. i, CMOS setup program in BIOS runs as EFI programs on EFI, hardware setup is a hardware setup program, and boot control is a different program, and CMOS save is a different program, although they are in form of a shell together.

EFI is fully equivalent to a lightweight OS (operating system) in terms of features, but EFI was not sufficiently positioned to be a professional OS when it was formulated. First of all, it is simply an interface between hardware and operating system. ;Secondly, EFI does not provide an interrupt access mechanism. EFI has to check and explain hardware in polling mode, which is less efficient than executing driver under OS. Finally, EFI only has a simple memory management mechanism. segment protection mode, only memory segmentation, all programs can access any location segment, no real protection service is providedprovided. Along with EFI, a completely new GUID Disk Partition System (GPT) has been introduced to support. Traditional MBR disks can only have 4 primary partitions. Only when less than 4 primary partitions can be created can you create an extended partition and then create logical partitions that are recognized by system. There are also a number of logical partitions. Too many logical partitions will seriously affect system startup. MBR hard disk partitions only support a maximum capacity of 2T, which is a waste for today's large-capacity hard drives. GPT supports any number of partitions. In principle, size of each partition is unlimited, but in fact it cannot be unlimited due to OS restrictions. However, this is a very important improvement over 2T MBR limit. The GPT partition type is uniquely determined by GUID table, and duplication is basically impossible. EFI can access EFI system partition to access some drivers and applications, although this in principle will make EFI system partition insecure, but in general some "marginal" " data. Even if it is corrupted, it will generally not cause serious consequences, and it can be easily restored.

When EFI was developed before version 1.1, Intel decided to make EFI public, so subsequent version 2.0 attracted many companies, and EFI was no longer owned by Intel, but owned by international organization Unified EFI Form. After version 2.0 of EFI, it was also then renamed to UEFI, UEFI, where EFI and original mean same thing, and U is abbreviation of Unified (unified, unified), so UEFI stands for "unified extensible firmware interface". following improvements:

First of all, UEFI has a fully featured graphics driver feature. Although previous EFI added a graphics driver in principle to allow a good transition between EFI and BIOS, most of EFI is still DOS-like interface (still 640*480VGA resolution), only supports PS/2 keyboard (very few support mouse operation), does not support USB keyboard and mouse. When it comes to UEFI, it has a full graphics driver. No matter PS/2 or USB keyboard and mouse, UEFI supports it all, and when graphics card also supports GOP VBIOS, displayed UEFI setting interface is graphics card's high resolution button .The display is 640*480 or 1024*768, so picture is small but clear, but it will cause a large area around screen to be black, but you can't have both, unless UEFI default window size is also highest resolution .

Second, UEFI has a unique secure boot feature, while EFI doesn't have secure boot, Secure Boot, in fact, popular explanation is called firmware verification. After turning on safetyAfter a UEFI boot, motherboard will evaluate each hardware based on hardware signature written by TPM chip (or TPM built into CPU). Only hardware drivers that comply with certification will be downloaded. During hardware driver signature verification process, Windows can only load hardware that matches Windows entry, which reduces risk caused by preloading launcher before operating system starts, but also results in changes to system installation.

Either EFI or UEFI must have a preboot environment, driver runtime, driver, and other required components. To support some older devices (such as mounting traditional MBR hard drives in UEFI, graphics cards that do not support UEFI startup, still support running under UEFI, etc.), and CSM Compatibility Support Module is required. And EFI, and UEFI only support booting from a GPT disk. The following will specifically talk about process of starting a computer with EFI or UEFI.

Typically, preboot environment and driver runtime are stored on UEFI chip (UEFI BIOS). When power is turned on, main components of computer begin to receive power. Unlike BIOS, UEFI preboot starts first and is responsible for initializing CPU and memory (full capacity). If there is an important problem here, computer will not beep even if there is a beep, because UEFI does not control 8255 to emit sound, but preboot environment only checks CPU and memory, if there is a problem with these two main hardware, this can be confirmed immediately if screen is not displayed, and some other motherboards will display LED prompts, and malfunction can be roughly judged by indicators processor or memory.

After successful CPU and memory initialization, Driver Execution Environment (DXE) is loaded. When DXE is loaded, UEFI can enumerate and load UEFI drivers. At this stage, UEFI will enumerate and search for various hardware. The UEFI graphics card driver is loaded and loaded one by one to complete hardware initialization work, which is much faster than BIOS read interrupt boot speed. Similarly, if UEFI graphics card driver is successfully loaded, computer will also display startup screen. After all hardware drivers are loaded, finally, as in BIOS, you must start operating system.

At operating system startup stage, also based on boot record boot sequence, navigate to boot record of corresponding device (only for GPT devices, when starting a traditional MBR device, you need to enable CSM support), boot operating system and enter . It should be noted here that when UEFI detects that there is no operating system to start device, it will directly go to setup page.to UEFI instead of displaying corresponding information on a black background. screen like bios.

Summarizing, process of starting a computer with BIOS and UEFI can be summarized as follows: The BIOS first initializes CPU and then jumps to BIOS startup location to perform a POST. If there is a serious error in this process, computer will use different beeps, and then load different hardware with a read interrupt, and enter operating system startup process after hardware initialization is completed; while UEFI starts preboot environment and initializes CPU and memory black screen, and then start PXE to search for various hardware and load drivers by enumeration, complete hardware initialization, and then enter operating system startup process.

In addition, BIOS is a 16-bit assembly language program that can only run in 16-bit real mode, and amount of available memory is only 1 MB, while UEFI is a 32-bit or 64-bit high language. level. program (C program) that overcomes real mode limitation, maximum required addressing can be achieved.