Archived
1
0
Fork 0

gnu: SeaBIOS: Build more BIOSen.

* gnu/packages/firmware.scm (seabios)[arguments]: Build the "128k" and
"microvm" BIOSen expected by QEMU.  Fix installation of vgabios.
This commit is contained in:
Marius Bakke 2022-12-19 01:23:25 +01:00
parent 16f2cc5a8f
commit 5877dc88a2
No known key found for this signature in database
GPG key ID: A2A06DF2A33A54FA

View file

@ -444,49 +444,76 @@ executing in M-mode.")
(invoke "make" "iasl") (invoke "make" "iasl")
;; Clear temporary files added by the iasl target. ;; Clear temporary files added by the iasl target.
(invoke "make" "clean"))) (invoke "make" "clean")))
(add-after 'build 'build-vgabios (replace 'build
(lambda* (#:key (make-flags #~'()) #:allow-other-keys) (lambda* (#:key (make-flags #~'()) #:allow-other-keys)
(for-each ;; Note: These BIOS configurations are taken from QEMUs roms/
(match-lambda ;; directory.
((target . config) (let ((biosen
(let* ((dot-config (string-append (getcwd) "/" target "/.config")) '(;; The standard BIOS using default options.
(flags (append make-flags ("bios-256k" . ("QEMU=y" "ROM_SIZE=256" "ATA_DMA=n"))
(list (string-append "KCONFIG_CONFIG=" ;; A minimal BIOS for old QEMU machine types.
dot-config) ("bios-128k"
(string-append "OUT=" target "/"))))) . ("QEMU=y" "ROM_SIZE=128" "ATA_DMA=n" "BOOTSPLASH=n"
(mkdir target) "XEN=n" "USB_OHCI=n" "USB_XHCI=n" "USB_UAS=n"
(call-with-output-file dot-config "SDCARD=n" "TCGBIOS=n" "MPT_SCSI=n" "ESP_SCSI=n"
(lambda (port) "MEGASAS=n" "PVSCSI=n" "NVME=n" "USE_SMM=n"
(for-each (lambda (entry) "VGAHOOKS=n" "HOST_BIOS_GEOMETRY=n" "ACPI_PARSE=n"))
(if (string-suffix? "=n" entry) ;; Minimal BIOS for the "microvm" machine type.
(format port "# CONFIG_~a is not set~%" ("bios-microvm"
(string-drop-right entry 2)) . ("QEMU=y" "ROM_SIZE=128" "XEN=n" "BOOTSPLASH=n" "ATA=n"
(format port "CONFIG_~a~%" entry))) "AHCI=n" "SDCARD=n" "PVSCSI=n" "ESP_SCSI=n" "LSI_SCSI=n"
(cons "BUILD_VGABIOS=y" config)))) "MEGASAS=n" "MPT_SCSI=n" "FLOPPY=n" "FLASH_FLOPPY=n"
(apply invoke "make" "oldnoconfig" flags) "NVME=n" "PS2PORT=n" "USB=n" "LPT=n" "RTC_TIMER=n"
(apply invoke "make" flags) "USE_SMM=n" "PMTIMER=n" "TCGBIOS=n" "HARDWARE_IRQ=n"
(link (string-append target "/bios.bin") "ACPI_PARSE=y"))))
(string-append "out/" target ".bin"))))) (vgabiosen
;; These tuples are modelled after Debians packaging: '(("ati" . ("VGA_ATI=y" "VGA_PCI=y"))
;; https://salsa.debian.org/qemu-team/seabios/-/blob/master/debian/rules ("bochs-display" . ("DISPLAY_BOCHS=y" "VGA_PCI=y"))
'(("ati" . ("VGA_ATI=y" "VGA_PCI=y")) ("cirrus" . ("VGA_CIRRUS=y" "VGA_PCI=y"))
("bochs-display" . ("DISPLAY_BOCHS=y" "VGA_PCI=y")) ("stdvga" . ("VGA_BOCHS=y" "VGA_PCI=y"))
("cirrus" . ("VGA_CIRRUS=y" "VGA_PCI=y")) ("virtio" . ("VGA_BOCHS=y" "VGA_BOCHS_VIRTIO=y" "VGA_PCI=y"))
("stdvga" . ("VGA_BOCHS=y" "VGA_PCI=y")) ("vmware" . ("VGA_BOCHS=y" "VGA_BOCHS_VMWARE=y" "VGA_PCI=y"))
("virtio" . ("VGA_BOCHS_VIRTIO=y" "VGA_PCI=y")) ("qxl" . ("VGA_BOCHS=y" "VGA_BOCHS_QXL=y" "VGA_PCI=y"))
("vmware" . ("VGA_BOCHS_VMWARE=y" "VGA_PCI=y")) ("isavga" . ("VGA_BOCHS=y" "VGA_PCI=n"))
("qxl" . ("VGA_BOCHS_QXL=y" "VGA_PCI=y")) ("ramfb" . ("VGA_RAMFB=y" "VGA_PCI=n")))))
("isavga" . ("VGA_BOCHS=y" "VGA_PCI=n")) (mkdir "out")
("ramfb" . ("VGA_RAMFB=y" "VGA_PCI=n")))))) (for-each
(match-lambda
((target . config)
(let* ((dot-config (string-append (getcwd) "/" target
"/.config"))
(flags (append make-flags
(list (string-append "KCONFIG_CONFIG="
dot-config)
(string-append "OUT=" target "/")))))
(mkdir target)
(call-with-output-file dot-config
(lambda (port)
(for-each (lambda (entry)
(format port "CONFIG_~a~%" entry))
config)))
(apply invoke "make" "oldnoconfig" flags)
(apply invoke "make" flags)
(link (string-append target "/"
(if (string-prefix? "vgabios" target)
"vgabios.bin" "bios.bin"))
(string-append "out/" target ".bin")))))
(append biosen
(map (lambda (pair)
`(,(string-append "vgabios-" (car pair))
.
,(cons "BUILD_VGABIOS=y" (cdr pair))))
vgabiosen))))))
(replace 'install (replace 'install
(lambda _ (lambda _
(let ((fmw (string-append #$output "/share/firmware"))) (let ((firmware (string-append #$output "/share/firmware")))
(for-each (lambda (bios) (for-each (lambda (bios)
(install-file bios fmw)) (install-file bios firmware))
(find-files "out" "\\.bin$")) (find-files "out" "\\.bin$"))
(with-directory-excursion fmw (with-directory-excursion firmware
;; QEMU 1.7 and later looks only for the latter. ;; Compatibility symlinks for QEMU.
(symlink "bios.bin" "bios-256k.bin")))))))) (symlink "bios-128k.bin" "bios.bin")
(symlink "vgabios-isavga.bin" "vgabios.bin"))))))))
(home-page "https://www.seabios.org/SeaBIOS") (home-page "https://www.seabios.org/SeaBIOS")
(synopsis "x86 BIOS implementation") (synopsis "x86 BIOS implementation")
(description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS