diff mbox series

[3/3] hw/i386/pc_sysfw: Do not create BIOS region if MTD is present

Message ID 20231018115231.3547102-4-patrick.rudolph@9elements.com
State New
Headers show
Series hw/i386: Add MTD controller on ICH9 | expand

Commit Message

Patrick Rudolph Oct. 18, 2023, 11:52 a.m. UTC
The newly introduced ICH9 SPI MTD controller creates the BIOS
region itself as it needs to update the mmaped BIOS region as
well when the MTD device is updated though the SPI controller.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
 hw/i386/pc_sysfw.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index c8d9e71b88..b98077422c 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -211,6 +211,12 @@  void pc_system_firmware_init(PCMachineState *pcms,
         x86_bios_rom_init(MACHINE(pcms), "bios.bin", rom_memory, true);
         return;
     }
+    DriveInfo *dinfo = drive_get(IF_MTD, 0, 0);
+    if (dinfo) {
+        /* SPI flash and BIOS will be emulated by MTD controller */
+        pc_system_flash_cleanup_unused(pcms);
+        return;
+    }
 
     /* Map legacy -drive if=pflash to machine properties */
     for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) {