Subject: [PATCH 9/9] gnu: Add ovmf-loongarch64.

From: Efraim Flashner <[email-masked]>
Date: Fri, 21 Mar 2025 10:53:10 +0200

* gnu/packages/firmware.scm (ovmf-loongarch64): New variable.
(make-ovmf-firmware)[arguments]: Adjust the 'build phase to add a case
for loongarch64.

Change-Id: Ibb916b50fd3dc7831ac895cb8b59695688750377
---
 gnu/packages/firmware.scm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index fe2956fbfdf..6f784a281d3 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -1090,6 +1090,8 @@ (define* (make-ovmf-firmware arch)
                                 "ArmVirtPkg/ArmVirtQemu.dsc")
                                ("riscv64"
                                 "OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc")
+                               ("loongarch64"
+                                "OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc")
                                (_ #t)))))
             (add-before 'install 'install-efi-shell
               (lambda _
@@ -1247,6 +1249,25 @@ (define-public ovmf-riscv64
                       (install-file "RISCV_VIRT_CODE.fd" fmw)
                       (install-file "RISCV_VIRT_VARS.fd" fmw))))))))))))
 
+(define-public ovmf-loongarch64
+  (let ((base (make-ovmf-firmware "loongarch64")))
+    (package
+      (inherit base)
+      (arguments
+        (substitute-keyword-arguments (package-arguments base)
+          ((#:phases phases)
+           #~(modify-phases #$phases
+               (replace 'install
+                 (lambda _
+                   (let ((fmw (string-append #$output "/share/firmware")))
+                     (mkdir-p fmw)
+                     (with-directory-excursion "Build/LoongArchVirtQemu/RELEASE_GCC/FV"
+                       ;; Make the files the desired length and then install them
+                       (truncate-file "QEMU_EFI.fd" (* 16 1024 1024))
+                       (truncate-file "QEMU_VARS.fd" (* 16 1024 1024))
+                       (install-file "QEMU_EFI.fd" fmw)
+                       (install-file "QEMU_VARS.fd" fmw))))))))))))
+
 (define-public ovmf
   (deprecated-package "ovmf" ovmf-x86-64))
 
-- 
Efraim Flashner   <[email-masked]>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted