Merge pull request #297475 from astro/ovmf-chv

OVMF: add cloudHypervisorSupport
This commit is contained in:
Adam C. Stephens 2024-04-19 13:27:37 -04:00 committed by GitHub
commit 716b484fae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 25 deletions

View file

@ -24,41 +24,39 @@
# Usually, this option is broken, do not use it except if you know what you are # Usually, this option is broken, do not use it except if you know what you are
# doing. # doing.
, sourceDebug ? false , sourceDebug ? false
, projectDscPath ? {
i686 = "OvmfPkg/OvmfPkgIa32.dsc";
x86_64 = "OvmfPkg/OvmfPkgX64.dsc";
aarch64 = "ArmVirtPkg/ArmVirtQemu.dsc";
riscv64 = "OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc";
}.${stdenv.hostPlatform.parsed.cpu.name}
or (throw "Unsupported OVMF `projectDscPath` on ${stdenv.hostPlatform.parsed.cpu.name}")
, fwPrefix ? {
i686 = "OVMF";
x86_64 = "OVMF";
aarch64 = "AAVMF";
riscv64 = "RISCV_VIRT";
}.${stdenv.hostPlatform.parsed.cpu.name}
or (throw "Unsupported OVMF `fwPrefix` on ${stdenv.hostPlatform.parsed.cpu.name}")
, metaPlatforms ? edk2.meta.platforms
}: }:
let let
platformSpecific = { platformSpecific = {
i686 = { x86_64.msVarsArgs = {
projectDscPath = "OvmfPkg/OvmfPkgIa32.dsc"; flavor = "OVMF_4M";
fwPrefix = "OVMF"; archDir = "X64";
}; };
x86_64 = { aarch64.msVarsArgs = {
projectDscPath = "OvmfPkg/OvmfPkgX64.dsc"; flavor = "AAVMF";
fwPrefix = "OVMF"; archDir = "AARCH64";
msVarsArgs = {
flavor = "OVMF_4M";
archDir = "X64";
};
};
aarch64 = {
projectDscPath = "ArmVirtPkg/ArmVirtQemu.dsc";
fwPrefix = "AAVMF";
msVarsArgs = {
flavor = "AAVMF";
archDir = "AARCH64";
};
};
riscv64 = {
projectDscPath = "OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc";
fwPrefix = "RISCV_VIRT";
}; };
}; };
cpuName = stdenv.hostPlatform.parsed.cpu.name; cpuName = stdenv.hostPlatform.parsed.cpu.name;
inherit (platformSpecific.${cpuName}) inherit (platformSpecific.${cpuName}) msVarsArgs;
projectDscPath fwPrefix msVarsArgs;
version = lib.getVersion edk2; version = lib.getVersion edk2;
@ -152,6 +150,9 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
# release notes accordingly. # release notes accordingly.
postInstall = '' postInstall = ''
mkdir -vp $fd/FV mkdir -vp $fd/FV
'' + lib.optionalString (builtins.elem fwPrefix [
"OVMF" "AAVMF" "RISCV_VIRT"
]) ''
mv -v $out/FV/${fwPrefix}_{CODE,VARS}.fd $fd/FV mv -v $out/FV/${fwPrefix}_{CODE,VARS}.fd $fd/FV
'' + lib.optionalString stdenv.hostPlatform.isx86 '' '' + lib.optionalString stdenv.hostPlatform.isx86 ''
mv -v $out/FV/${fwPrefix}.fd $fd/FV mv -v $out/FV/${fwPrefix}.fd $fd/FV
@ -184,7 +185,7 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
description = "Sample UEFI firmware for QEMU and KVM"; description = "Sample UEFI firmware for QEMU and KVM";
homepage = "https://github.com/tianocore/tianocore.github.io/wiki/OVMF"; homepage = "https://github.com/tianocore/tianocore.github.io/wiki/OVMF";
license = lib.licenses.bsd2; license = lib.licenses.bsd2;
inherit (edk2.meta) platforms; platforms = metaPlatforms;
maintainers = with lib.maintainers; [ adamcstephens raitobezarius ]; maintainers = with lib.maintainers; [ adamcstephens raitobezarius ];
broken = stdenv.isDarwin; broken = stdenv.isDarwin;
}; };

View file

@ -0,0 +1,7 @@
{ lib, OVMF }:
OVMF.override {
projectDscPath = "OvmfPkg/CloudHv/CloudHvX64.dsc";
fwPrefix = "CLOUDHV";
metaPlatforms = builtins.filter (lib.hasPrefix "x86_64-") OVMF.meta.platforms;
}