From db9b8f36df1ae8fe6bc0337d8f25ea7b7031301e Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 25 Nov 2023 13:12:30 +0100 Subject: [PATCH] OVMF: support RISC-V Built according to https://github.com/tianocore/edk2/tree/master/OvmfPkg/RiscVVirt and https://salsa.debian.org/qemu-team/edk2/-/commit/884f2fa7ed958d1469567a8a2648662541f138dc. --- .../virtualization/OVMF/default.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/virtualization/OVMF/default.nix b/pkgs/applications/virtualization/OVMF/default.nix index 20353696d161..d46932006f49 100644 --- a/pkgs/applications/virtualization/OVMF/default.nix +++ b/pkgs/applications/virtualization/OVMF/default.nix @@ -22,6 +22,8 @@ let "OvmfPkg/OvmfPkgX64.dsc" else if stdenv.hostPlatform.isAarch then "ArmVirtPkg/ArmVirtQemu.dsc" + else if stdenv.hostPlatform.isRiscV then + "OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc" else throw "Unsupported architecture"; @@ -69,7 +71,8 @@ edk2.mkDerivation projectDscPath (finalAttrs: { cp ${seabios}/Csm16.bin OvmfPkg/Csm/Csm16/Csm16.bin ''; - postFixup = if stdenv.hostPlatform.isAarch then '' + postFixup = ( + if stdenv.hostPlatform.isAarch then '' mkdir -vp $fd/FV mkdir -vp $fd/AAVMF mv -v $out/FV/QEMU_{EFI,VARS}.fd $fd/FV @@ -82,10 +85,18 @@ edk2.mkDerivation projectDscPath (finalAttrs: { # 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 - '' else '' + '' + else if stdenv.hostPlatform.isRiscV then '' + mkdir -vp $fd/FV + + mv -v $out/FV/RISCV_VIRT_{CODE,VARS}.fd $fd/FV/ + truncate -s 32M $fd/FV/RISCV_VIRT_CODE.fd + truncate -s 32M $fd/FV/RISCV_VIRT_VARS.fd + '' + else '' mkdir -vp $fd/FV mv -v $out/FV/OVMF{,_CODE,_VARS}.fd $fd/FV - ''; + ''); dontPatchELF = true;