2019-07-15 07:35:30 -07:00
|
|
|
{ stdenv, lib, edk2, utillinux, nasm, iasl
|
|
|
|
, csmSupport ? false, seabios ? null
|
|
|
|
, secureBoot ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert csmSupport -> seabios != null;
|
2012-03-13 23:57:58 -07:00
|
|
|
|
2012-03-14 00:29:11 -07:00
|
|
|
let
|
|
|
|
|
2018-03-14 08:37:49 -07:00
|
|
|
projectDscPath = if stdenv.isi686 then
|
|
|
|
"OvmfPkg/OvmfPkgIa32.dsc"
|
2012-03-14 00:29:11 -07:00
|
|
|
else if stdenv.isx86_64 then
|
2018-03-14 08:37:49 -07:00
|
|
|
"OvmfPkg/OvmfPkgX64.dsc"
|
|
|
|
else if stdenv.isAarch64 then
|
|
|
|
"ArmVirtPkg/ArmVirtQemu.dsc"
|
2012-03-14 00:29:11 -07:00
|
|
|
else
|
|
|
|
throw "Unsupported architecture";
|
|
|
|
|
2019-11-24 09:22:28 -08:00
|
|
|
version = lib.getVersion edk2;
|
2012-03-14 00:29:11 -07:00
|
|
|
in
|
|
|
|
|
2019-07-15 07:35:30 -07:00
|
|
|
edk2.mkDerivation projectDscPath {
|
2017-04-22 02:57:23 -07:00
|
|
|
name = "OVMF-${version}";
|
2012-03-13 23:57:58 -07:00
|
|
|
|
2017-05-18 03:46:14 -07:00
|
|
|
outputs = [ "out" "fd" ];
|
|
|
|
|
2019-07-15 07:35:30 -07:00
|
|
|
buildInputs = [ utillinux nasm iasl ];
|
2016-02-08 15:18:03 -08:00
|
|
|
|
2019-07-15 07:35:30 -07:00
|
|
|
hardeningDisable = [ "format" "stackprotector" "pic" "fortify" ];
|
2017-05-29 03:20:05 -07:00
|
|
|
|
2019-07-15 07:35:30 -07:00
|
|
|
buildFlags =
|
|
|
|
lib.optional secureBoot "-DSECURE_BOOT_ENABLE=TRUE"
|
|
|
|
++ lib.optionals csmSupport [ "-D CSM_ENABLE" "-D FD_SIZE_2MB" ];
|
2015-01-26 12:13:31 -08:00
|
|
|
|
2019-07-15 07:35:30 -07:00
|
|
|
postPatch = lib.optionalString csmSupport ''
|
|
|
|
cp ${seabios}/Csm16.bin OvmfPkg/Csm/Csm16/Csm16.bin
|
2018-03-14 06:52:32 -07:00
|
|
|
'';
|
2015-01-26 12:13:31 -08:00
|
|
|
|
2018-03-14 08:37:49 -07:00
|
|
|
postFixup = if stdenv.isAarch64 then ''
|
|
|
|
mkdir -vp $fd/FV
|
|
|
|
mkdir -vp $fd/AAVMF
|
|
|
|
mv -v $out/FV/QEMU_{EFI,VARS}.fd $fd/FV
|
|
|
|
|
|
|
|
# Uses Fedora dir layout: https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/edk2.spec
|
2019-10-04 03:42:21 -07:00
|
|
|
# FIXME: why is it different from Debian dir layout? https://salsa.debian.org/qemu-team/edk2/blob/debian/debian/rules
|
2018-03-14 08:37:49 -07:00
|
|
|
dd of=$fd/AAVMF/QEMU_EFI-pflash.raw if=/dev/zero bs=1M count=64
|
|
|
|
dd of=$fd/AAVMF/QEMU_EFI-pflash.raw if=$fd/FV/QEMU_EFI.fd conv=notrunc
|
|
|
|
dd of=$fd/AAVMF/vars-template-pflash.raw if=/dev/zero bs=1M count=64
|
|
|
|
'' else ''
|
2019-07-15 07:35:30 -07:00
|
|
|
mkdir -vp $fd/FV
|
|
|
|
mv -v $out/FV/OVMF{,_CODE,_VARS}.fd $fd/FV
|
2017-05-18 03:46:14 -07:00
|
|
|
'';
|
|
|
|
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
2012-03-13 23:57:58 -07:00
|
|
|
meta = {
|
|
|
|
description = "Sample UEFI firmware for QEMU and KVM";
|
2020-03-31 18:11:51 -07:00
|
|
|
homepage = "https://github.com/tianocore/tianocore.github.io/wiki/OVMF";
|
2014-12-20 15:00:35 -08:00
|
|
|
license = stdenv.lib.licenses.bsd2;
|
2018-03-14 08:37:49 -07:00
|
|
|
platforms = ["x86_64-linux" "i686-linux" "aarch64-linux"];
|
2012-03-13 23:57:58 -07:00
|
|
|
};
|
2019-07-15 07:35:30 -07:00
|
|
|
}
|