Linux and the BIOS
The x86 kernel has direct and indirect dependencies on the system BIOS. Here’s a look at some of the guts.
Thursday, December 15th, 2005
Parts of the x86 kernel, such as Advanced Power Management (APM) and the video framebuffer driver, vesafb, explicitly use BIOS services to realize certain features. Other sections of the kernel like the serial driver, implicitly depend on the BIOS to initialize I/O base addresses and interrupt levels, and real-mode kernel code makes extensive use of BIOS calls during boot up to perform tasks like assembling the system memory map. (On BIOS-less embedded architectures, similar responsibilities — for example, waking the kernel from suspend on ARM Linux — rest with the bootloader.)
In this month’s “Gearheads” column, let’s learn to interact with the BIOS using some examples. But first, let’s look at the different facets of assembly programming on Linux.
A Peek into Linux Assembly
Figure One shows the Linux boot sequence on an x86-based desktop or laptop. The firmware components in the figure are usually implemented using different assembly syntaxes:
*The BIOS is typically wholly written in assembly. Some of the popular BIOSes are coded using assemblers like the Microsoft Macro Assembler (MASM).
*Linux bootloaders like LILO and GRUB are implemented using a mix of C and assembly. The SYSLINUX bootloader is written entirely in assembly using the Netwide Assembler (NASM).
*Real-mode Linux startup code uses the GNU Assembler (GAS).