From Lazarus wiki
Revision as of 11:05, 9 January 2016 by Chronos (talk | contribs)
Jump to navigationJump to search

Motivations behind this target

The Unified Extensible Firmware Interface (UEFI) now replaces BIOS in most current PCs.

Currently, there are two main options to develop UEFI applications:

Both solutions require a tedious setup process.

Thank to its internal linker, Free Pascal can become the easiest option to develop UEFI applications, as no external tools would be required to start hacking.

Technical requirements

UEFI applications are PE binaries like the Windows target, which Free Pascal already supports. The only difference is the subsystem in the PE header.

Calling conventions under UEFI are identical to the ones under Windows on the same architecture, which Free Pascal already supports, too.

Current state

My current patch against trunk is here : http://nan.tf/download/uefi_all_03_01_2016.diff.

It is not yet a clean patch : lots of debug output inside.

Known problems

Affectation of string constant to string variable does not work. It is currently necessary to create strings through an array of WideChar.

  s : string;
  s := 'Hello world !';

Maybe it is related to Position Independent Code generation in the case of PE executables ?

Any hints in this area are welcome ;-)

Testing UEFI applications with qemu

See OSDev UEFI Emulation with QEMU and OVMF

To avoid creating an image, i use FAT emulation to a local directory where my UEFI application is located :

qemu-system-i386-x86 -pflash /path/to/OVMF.fd -hda fat:local_directory -net none

"-net none" avoid net booting to save a few seconds in the boot process.

From UEFI shell, then write :


to switch to the directory where are located your application then you can launch it :


External resources

Some interesting development resources around UEFI :