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