1 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. PC BIOS, EFI and other animals in the wild Daniel Kiper

E-mail: [email protected] Presentation agenda

. . PC BIOS . EFI . . QEMU . Open Virtual Machine Firmware . Documentation . Questions and Answers ?

3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. FIRMWARE Definitions

. The combination of software and data that reside on readonly memory (IEEE 100 The Authoritative Dictionary of IEEE Standards Terms, Seventh Edition) . A program, typically stored in read-only memory, that controls a computer from the time that it is turned on until the time that the primary operating system assumes control of the computer (IEEE 100 The Authoritative Dictionary of IEEE Standards Terms, Seventh Edition) . There are more of them and all of them are not precise . And some of them have a notice: The confusion surrounding this term has led some to suggest that it be avoided altogether (IEEE 100 The Authoritative Dictionary of IEEE Standards Terms, Seventh Edition) 

4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. PC Basic Input Output System (BIOS) Properties

. PC BIOS/ROM BIOS was only one proprietary thing in original IBM PC (but source code is publicly available, sic!) . It has many implementations (proprietary and open) . De facto standard but with a bunch of deviations . It initializes hardware after power on and tries to load operating system . It hides hardware details and exposes something that is called the Hardware Abstraction Layer (HAL) to a given OS . Due to shortcomings later it was extended by ACPI, SMBIOS and other stuff

5 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. PC BIOS Shortcomings

. Very buggy . New hardware with advanced features cannot be handled easily (e.g. new large disks or SSD) . Slow especially without BIOS caching feature . It runs in real mode only . Today used mainly to initialize hardware after power on and to load operating system . New operating systems sometimes use BIOS to get info about hardware configuration . New drivers access hardware directly

6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. EFI History

. Initial development was done under the Intel® Boot Initiative program which began in 1998 . New specification was named the Extensible Firmware Interface (EFI) and was targeted to the next generation of IA architecture- based computers . In 2005 the Unified EFI Forum was established and took over work on EFI . Specification was renamed the Unified Extensible Firmware Interface (UEFI) and its development was based on Intel’s EFI 1.10 Specification . Original EFI Specification ends with version 1.10 . Latest UEFI 2.4 Specification was released on July 11, 2013

7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. UEFI Goals

. Coherent, scalable platform environment . Abstraction of the OS from the firmware . Reasonable device abstraction free of legacy interfaces . Abstraction of Option ROMs from the firmware . Architecturally shareable system partition

. Evolutionary, not revolutionary . Compatibility by design . Simplifies addition of OS-neutral platform value-add . Built on existing investment

Copyright 2006-2013 Unified EFI, Inc. All Rights Reserved.

8 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. UEFI Conceptual Overview

Copyright 2006-2013 Unified EFI, Inc. All Rights Reserved.

9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. UEFI Sequence

Copyright 2006-2013 Unified EFI, Inc. All Rights Reserved.

10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. coreboot History

. coreboot is a project aimed at replacing the proprietary BIOS (firmware) found in most computers (http://www.coreboot.org/Welcome_to_coreboot) . Project started in 1999 at the Advanced Computing Laboratory at Los Alamos National Laboratory (LANL) by Ron Minnich . It was named LinuxBIOS = (core boot code) + (Linux kernel) . LinuxBIOS = ((core boot code) + (Linux 2.2 kernel)) < 512 KiB . LinuxBIOS = ((core boot code) + (Linux 2.4 kernel)) > 1 MiB . By 2001 flash chips were downsized to 256 KiB . So there was no chance to use Linux with those flash chips . Hmm… LinuxBIOS = (core boot code) + (e.g. Etherboot) . BIOS ROM = (LinuxBIOS) + (e.g. Etherboot) . Hence, LinuxBIOS = core boot code => coreboot

11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. coreboot Usage

. coreboot currently supports over 230 different mainboards (http://www.coreboot.org/Welcome_to_coreboot) . Clusters . Servers . Desktop PCs . Laptops . Embedded systems . …

12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. coreboot How it works

. coreboot initializes hardware first . Later it loads payload(s) . Payload can be: – SeaBIOS, a legacy PC BIOS implementation – GRUB 2 – Etherboot / GPXE / iPXE – OpenBIOS, an IEEE1275-1994 implementation – Tiano Core, an UEFI implementation – Linux Kernel – …

13 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. QEMU How to play with payloads without soldering equipment

. QEMU is a generic and open source machine emulator and virtualizer (http://wiki.qemu.org/Main_Page) . Good to do some arch testing and virtualization (as is) but also excellent for debugging

. # … -L

. should contain at least .bin and keymaps directory but some versions require also kvmvapic.bin, pxe-e1000.rom and vgabios-cirrus.bin

14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Open Virtual Machine Firmware (OVMF) How to work with UEFI under QEMU

. OVMF is a project to enable support for UEFI within Virtual Machines. It is built upon the EDK II code base. (http://tianocore.sourceforge.net/) . OVMF-X64-r11337-alpha.zip and OVMF-IA32-r11337-alpha.zip files with OVMF binaries for QEMU are available at TianoCore site . They are quite old and do not work well . Some companies/individuals (e.g. SUSE) publish own OVMF releases . You can also build your own OVMF binaries . Relevant instructions are available at TianoCore site and http://wiki.ubuntu.com/UEFI/EDK2 or http://www.linux-kvm.org/page/OVMF . But this process is quite complicated

15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Summary

. It looks that PC BIOS is slowly dying . Probably UEFI will replace legacy PC BIOS . In spite of appearances PC BIOS and UEFI have strong competition . coreboot and companions are a good alternative . coreboot is mature project but limited access to a hardware documentation can harm it substantially

16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Documentation

. http://www.classiccomputers.info/manuals.html . http://www.intel.com/ . http://www.uefi.org/ . http://www.coreboot.org/ . http://wiki.qemu.org/Main_Page . http://tianocore.sourceforge.net/ . http://wiki.ubuntu.com/UEFI/EDK2 . http://www.linux-kvm.org/page/OVMF

17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Documentation

. http://www.kraxel.org/repos/ . git://git.code.sf.net/p/tianocore/edk2

. Intel BIOS Writer’s Guide (BWG) - Intel Confidential  – http://datasheets.chipdb.org/Intel/x86/Pentium%20Pro/PPPBIOS.PDF

. AMD BIOS and Kernel Developer’s Guide (BKDG) - freely available – http://developer.amd.com/resources/documentation-articles/developer- guides-manuals/

. EPROM pictures were taken by Richard Wheeler (http://www.richardwheeler.net/)

18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Questions and Answers ?

19 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.