diff --git a/52-edk2-riscv-qcow2.json b/52-edk2-riscv-qcow2.json new file mode 100644 index 0000000000000000000000000000000000000000..fabc11239973ad1b1b7f7f16818bd1bad591ffc0 --- /dev/null +++ b/52-edk2-riscv-qcow2.json @@ -0,0 +1,32 @@ +{ + "description": "UEFI firmware for RISC-V virtual machines", + "interface-types": [ + "uefi" + ], + "mapping": { + "device": "flash", + "mode" : "split", + "executable": { + "filename": "/usr/share/edk2/riscv/RISCV_VIRT_CODE.qcow2", + "format": "qcow2" + }, + "nvram-template": { + "filename": "/usr/share/edk2/riscv/RISCV_VIRT_VARS.qcow2", + "format": "qcow2" + } + }, + "targets": [ + { + "architecture": "riscv64", + "machines": [ + "virt-*" + ] + } + ], + "features": [ + + ], + "tags": [ + + ] +} diff --git a/add_support_for_riscv64.patch b/add_support_for_riscv64.patch new file mode 100644 index 0000000000000000000000000000000000000000..5ab44f2e49734cde94cab3d039d5427af9aec6b9 --- /dev/null +++ b/add_support_for_riscv64.patch @@ -0,0 +1,58 @@ +diff -ruN rpm_ori/SOURCES/50-edk2-riscv-qcow2.json SOURCES/50-edk2-riscv-qcow2.json +--- rpm_ori/SOURCES/50-edk2-riscv-qcow2.json 1969-12-31 19:00:00.000000000 -0500 ++++ SOURCES/50-edk2-riscv-qcow2.json 2025-05-09 04:39:33.961317297 -0400 +@@ -0,0 +1,32 @@ ++{ ++ "description": "UEFI firmware for RISC-V virtual machines", ++ "interface-types": [ ++ "uefi" ++ ], ++ "mapping": { ++ "device": "flash", ++ "mode" : "split", ++ "executable": { ++ "filename": "/usr/share/edk2/riscv/RISCV_VIRT_CODE.qcow2", ++ "format": "qcow2" ++ }, ++ "nvram-template": { ++ "filename": "/usr/share/edk2/riscv/RISCV_VIRT_VARS.qcow2", ++ "format": "qcow2" ++ } ++ }, ++ "targets": [ ++ { ++ "architecture": "riscv64", ++ "machines": [ ++ "virt-*" ++ ] ++ } ++ ], ++ "features": [ ++ ++ ], ++ "tags": [ ++ ++ ] ++} +diff -ruN rpm_ori/SOURCES/edk2-build SOURCES/edk2-build +--- rpm_ori/SOURCES/edk2-build 2024-11-30 02:30:46.000000000 -0500 ++++ SOURCES/edk2-build 2025-05-09 04:45:37.862189455 -0400 +@@ -155,3 +155,18 @@ + cpy1 = FV/QEMU_EFI.fd QEMU_EFI.silent.fd + cpy2 = FV/QEMU_EFI.fd QEMU_EFI-silent-pflash.raw + pad2 = QEMU_EFI-silent-pflash.raw 4m ++ ++##################################################################### ++# riscv ++ ++[build.riscv.qemu] ++conf = OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc ++arch = RISCV64 ++plat = RiscVVirtQemu ++dest = edk2-build-dir/riscv ++cpy1 = FV/RISCV_VIRT_CODE.fd ++cpy2 = FV/RISCV_VIRT_CODE.fd RISCV_VIRT_CODE.raw ++cpy3 = FV/RISCV_VIRT_VARS.fd ++cpy4 = FV/RISCV_VIRT_VARS.fd RISCV_VIRT_VARS.raw ++pad1 = RISCV_VIRT_CODE.raw 32m ++pad2 = RISCV_VIRT_VARS.raw 32m diff --git a/edk2.spec b/edk2.spec index d1ca2f13e272a1c683f6f90fd6fd8a52abb8e3ee..1fae1d9dca01866016944fe7fb61fd0f44dd2467 100644 --- a/edk2.spec +++ b/edk2.spec @@ -1,7 +1,7 @@ -%define anolis_release 12 +%define anolis_release 13 %undefine _auto_set_build_flags -ExclusiveArch: x86_64 aarch64 loongarch64 +ExclusiveArch: x86_64 aarch64 loongarch64 riscv64 # edk2-stable202402 %define GITDATE 20240214 @@ -12,6 +12,7 @@ ExclusiveArch: x86_64 aarch64 loongarch64 %define build_ovmf 0 %define build_aarch64 0 %define build_loongarch64 0 +%define build_riscv64 0 %ifarch x86_64 %define build_ovmf 1 %endif @@ -21,7 +22,9 @@ ExclusiveArch: x86_64 aarch64 loongarch64 %ifarch loongarch64 %define build_loongarch64 1 %endif -%define build_riscv64 0 +%ifarch riscv64 + %define build_riscv64 1 +%endif %global softfloat_version 20180726-gitb64af41 @@ -57,6 +60,8 @@ Source44: 60-edk2-ovmf-x64-inteltdx.json Source50: 50-edk2-loongarch64.json Source51: 51-edk2-loongarch64-verbose.json +Source52: 52-edk2-riscv-qcow2.json + Source80: https://gitlab.com/kraxel/edk2-build-config/-/blob/master/bin/edk2-build.py Source81: edk2-build @@ -177,6 +182,16 @@ platform that enables UEFI support for QEMU/KVM LoongArch Virtual Machines. This package contains a 64-bit build. +%ifarch riscv64 +%package riscv64 +Summary: RISC-V Virtual Machine Firmware +BuildArch: noarch +License: BSD-2-Clause-Patent and OpenSSL +%description riscv64 +EFI Development Kit II +RISC-V UEFI Firmware +%endif + %package tools Summary: EFI Development Kit II Tools License: BSD-2-Clause-Patent @@ -258,11 +273,19 @@ mkdir -p CryptoPkg/Library/MbedTlsLib/mbedtls/library # Done by %setup, but we do not use it for the auxiliary tarballs chmod -Rf a+rX,u+w,g-w,o-w . +%ifarch riscv64 +cp -a -- \ + %{SOURCE10} %{SOURCE11} \ + %{SOURCE40} %{SOURCE41} %{SOURCE42} %{SOURCE43} %{SOURCE44} \ + %{SOURCE50} %{SOURCE51} %{SOURCE80} %{SOURCE81} %{SOURCE52} \ + . +%else cp -a -- \ %{SOURCE10} %{SOURCE11} \ %{SOURCE40} %{SOURCE41} %{SOURCE42} %{SOURCE43} %{SOURCE44} \ %{SOURCE50} %{SOURCE51} %{SOURCE80} %{SOURCE81} \ . +%endif # The following patches need to be applied in the Platform directory of edk2-platforms, # so the patches must be applied after edk2-platforms is unpacked. @@ -335,6 +358,14 @@ for raw in */loongarch64/*.raw; do done %endif +%if %{build_riscv64} +./edk2-build.py --config edk2-build --silent --release-date "$RELEASE_DATE" -m riscv +for raw in */riscv/*.raw; do + qcow2="${raw%.raw}.qcow2" + qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 "$raw" "$qcow2" +done +%endif + %install cp -a OvmfPkg/License.txt License.OvmfPkg.txt @@ -414,6 +445,14 @@ install -m 0644 \ # endif build_loongarch64 %endif +%if %{build_riscv64} +install -m 0644 \ + 50-edk2-riscv-qcow2.json \ + %{buildroot}%{_datadir}/qemu/firmware + +rm -f %{buildroot}%{_datadir}/edk2/riscv/*.raw +%endif + %generate_compatibility_deps %global common_files \ @@ -484,6 +523,14 @@ install -m 0644 \ # endif build_loongarch64 %endif +%if %{build_riscv64} +%files riscv64 +%common_files +%{_datadir}/%{name}/riscv/*.fd +%{_datadir}/%{name}/riscv/*.qcow2 +%{_datadir}/qemu/firmware/50-edk2-riscv-qcow2.json +%endif + %files tools %license License.txt %license License-History.txt @@ -512,6 +559,9 @@ install -m 0644 \ %changelog +* Thu Jun 05 2025 Shangtong Guo - 202402-13 +- add support for riscv64 + * Tue May 20 2025 Xiaotian Wu - 202402-12 - LoongArch: Fix function parameter type error - LoongArch: Add network support