From f59eab75d2bb20e44aff84ccadf65e4024db6eb4 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Wed, 14 Mar 2018 17:37:49 +0200 Subject: [PATCH] edk2, OVMF: Build on aarch64 And also build in parallel. I don't understand why we manually tediously link every single directory from the source, but I don't want to investigate too much. --- .../virtualization/OVMF/default.nix | 40 ++++++++++++++----- pkgs/development/compilers/edk2/default.nix | 4 +- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/pkgs/applications/virtualization/OVMF/default.nix b/pkgs/applications/virtualization/OVMF/default.nix index dca29e28cbb2..ee4ea4346e4a 100644 --- a/pkgs/applications/virtualization/OVMF/default.nix +++ b/pkgs/applications/virtualization/OVMF/default.nix @@ -2,10 +2,12 @@ let - targetArch = if stdenv.isi686 then - "Ia32" + projectDscPath = if stdenv.isi686 then + "OvmfPkg/OvmfPkgIa32.dsc" else if stdenv.isx86_64 then - "X64" + "OvmfPkg/OvmfPkgX64.dsc" + else if stdenv.isAarch64 then + "ArmVirtPkg/ArmVirtQemu.dsc" else throw "Unsupported architecture"; @@ -14,7 +16,7 @@ let src = edk2.src; in -stdenv.mkDerivation (edk2.setup "OvmfPkg/OvmfPkg${targetArch}.dsc" { +stdenv.mkDerivation (edk2.setup projectDscPath { name = "OVMF-${version}"; inherit src; @@ -36,7 +38,13 @@ stdenv.mkDerivation (edk2.setup "OvmfPkg/OvmfPkg${targetArch}.dsc" { ln -sv "$file" . done - ${if seabios != null then '' + ${if stdenv.isAarch64 then '' + ln -sv ${src}/ArmPkg . + ln -sv ${src}/ArmPlatformPkg . + ln -sv ${src}/ArmVirtPkg . + ln -sv ${src}/EmbeddedPkg . + ln -sv ${src}/OvmfPkg . + '' else if seabios != null then '' cp -r ${src}/OvmfPkg . chmod +w OvmfPkg/Csm/Csm16 cp ${seabios}/Csm16.bin OvmfPkg/Csm/Csm16/Csm16.bin @@ -50,13 +58,25 @@ stdenv.mkDerivation (edk2.setup "OvmfPkg/OvmfPkg${targetArch}.dsc" { ''} ''; - buildPhase = if seabios == null then '' - build ${lib.optionalString secureBoot "-DSECURE_BOOT_ENABLE=TRUE"} + buildPhase = if stdenv.isAarch64 then '' + build -n $NIX_BUILD_CORES + '' else if seabios == null then '' + build -n $NIX_BUILD_CORES ${lib.optionalString secureBoot "-DSECURE_BOOT_ENABLE=TRUE"} '' else '' - build -D CSM_ENABLE -D FD_SIZE_2MB ${lib.optionalString secureBoot "-DSECURE_BOOT_ENABLE=TRUE"} + build -n $NIX_BUILD_CORES -D CSM_ENABLE -D FD_SIZE_2MB ${lib.optionalString secureBoot "-DSECURE_BOOT_ENABLE=TRUE"} ''; - postFixup = '' + 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 + # FIXME: why is it different from Debian dir layout? https://anonscm.debian.org/cgit/pkg-qemu/edk2.git/tree/debian/rules + 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 '' mkdir -vp $OUTPUT_FD/FV mv -v $out/FV/OVMF{,_CODE,_VARS}.fd $OUTPUT_FD/FV ''; @@ -67,6 +87,6 @@ stdenv.mkDerivation (edk2.setup "OvmfPkg/OvmfPkg${targetArch}.dsc" { description = "Sample UEFI firmware for QEMU and KVM"; homepage = https://sourceforge.net/apps/mediawiki/tianocore/index.php?title=OVMF; license = stdenv.lib.licenses.bsd2; - platforms = ["x86_64-linux" "i686-linux"]; + platforms = ["x86_64-linux" "i686-linux" "aarch64-linux"]; }; }) diff --git a/pkgs/development/compilers/edk2/default.nix b/pkgs/development/compilers/edk2/default.nix index 5cc4846d3ae5..1dc4430dc6a7 100644 --- a/pkgs/development/compilers/edk2/default.nix +++ b/pkgs/development/compilers/edk2/default.nix @@ -7,6 +7,8 @@ targetArch = if stdenv.isi686 then "IA32" else if stdenv.isx86_64 then "X64" +else if stdenv.isAarch64 then + "AARCH64" else throw "Unsupported architecture"; @@ -48,7 +50,7 @@ edk2 = stdenv.mkDerivation { homepage = https://sourceforge.net/projects/edk2/; license = stdenv.lib.licenses.bsd2; branch = "UDK2017"; - platforms = ["x86_64-linux" "i686-linux"]; + platforms = ["x86_64-linux" "i686-linux" "aarch64-linux"]; }; passthru = {