Carlos López has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85673?usp=email )
Change subject: mb/qemu-i440fx: refactor fw_cfg logic as separate driver ......................................................................
mb/qemu-i440fx: refactor fw_cfg logic as separate driver
The fw_cfg device can be used by other qemu boards outside i440fx (and q35, which manually includes the code). Factor out the fw_cfg code as a separate driver that qemu mainboards can enable.
Change-Id: I8c5c4cb5f5478abd21aab8e8d0b503db41d81d40 Signed-off-by: Carlos López carlos.lopez@openchip.com --- M src/drivers/emulation/qemu/Kconfig M src/drivers/emulation/qemu/Makefile.mk R src/drivers/emulation/qemu/fw_cfg.c R src/include/device/fw_cfg.h R src/include/device/fw_cfg_if.h M src/mainboard/emulation/qemu-i440fx/Kconfig M src/mainboard/emulation/qemu-i440fx/Makefile.mk M src/mainboard/emulation/qemu-i440fx/bootmode.c M src/mainboard/emulation/qemu-i440fx/memmap.c M src/mainboard/emulation/qemu-i440fx/northbridge.c M src/mainboard/emulation/qemu-q35/Kconfig M src/mainboard/emulation/qemu-q35/Makefile.mk M src/mainboard/emulation/qemu-q35/acpi_tables.c M src/mainboard/emulation/qemu-q35/cpu.c M src/mainboard/emulation/qemu-q35/memmap.c 15 files changed, 23 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/85673/1
diff --git a/src/drivers/emulation/qemu/Kconfig b/src/drivers/emulation/qemu/Kconfig index 5b01ae7..cab0694 100644 --- a/src/drivers/emulation/qemu/Kconfig +++ b/src/drivers/emulation/qemu/Kconfig @@ -35,3 +35,9 @@ default 600 depends on LINEAR_FRAMEBUFFER depends on DRIVERS_EMULATION_QEMU_BOCHS || DRIVERS_EMULATION_QEMU_CIRRUS + +config DRIVERS_EMULATION_QEMU_FW_CFG + bool "qemu fw_cfg" + default n + help + qemu fw_cfg driver diff --git a/src/drivers/emulation/qemu/Makefile.mk b/src/drivers/emulation/qemu/Makefile.mk index 619782f..76bd864 100644 --- a/src/drivers/emulation/qemu/Makefile.mk +++ b/src/drivers/emulation/qemu/Makefile.mk @@ -7,3 +7,9 @@
ramstage-$(CONFIG_DRIVERS_EMULATION_QEMU_BOCHS) += bochs.c ramstage-$(CONFIG_DRIVERS_EMULATION_QEMU_CIRRUS) += cirrus.c + +bootblock-$(CONFIG_DRIVERS_EMULATION_QEMU_FW_CFG) += fw_cfg.c +romstage-$(CONFIG_DRIVERS_EMULATION_QEMU_FW_CFG) += fw_cfg.c +verstage-$(CONFIG_DRIVERS_EMULATION_QEMU_FW_CFG) += fw_cfg.c +postcar-$(CONFIG_DRIVERS_EMULATION_QEMU_FW_CFG) += fw_cfg.c +ramstage-$(CONFIG_DRIVERS_EMULATION_QEMU_FW_CFG) += fw_cfg.c diff --git a/src/mainboard/emulation/qemu-i440fx/fw_cfg.c b/src/drivers/emulation/qemu/fw_cfg.c similarity index 99% rename from src/mainboard/emulation/qemu-i440fx/fw_cfg.c rename to src/drivers/emulation/qemu/fw_cfg.c index ad664a6..3725419 100644 --- a/src/mainboard/emulation/qemu-i440fx/fw_cfg.c +++ b/src/drivers/emulation/qemu/fw_cfg.c @@ -8,9 +8,8 @@ #include <arch/io.h> #include <acpi/acpi.h> #include <commonlib/endian.h> - -#include "fw_cfg.h" -#include "fw_cfg_if.h" +#include <device/fw_cfg.h> +#include <device/fw_cfg_if.h>
#define FW_CFG_PORT_CTL 0x0510 #define FW_CFG_PORT_DATA 0x0511 diff --git a/src/mainboard/emulation/qemu-i440fx/fw_cfg.h b/src/include/device/fw_cfg.h similarity index 100% rename from src/mainboard/emulation/qemu-i440fx/fw_cfg.h rename to src/include/device/fw_cfg.h diff --git a/src/mainboard/emulation/qemu-i440fx/fw_cfg_if.h b/src/include/device/fw_cfg_if.h similarity index 100% rename from src/mainboard/emulation/qemu-i440fx/fw_cfg_if.h rename to src/include/device/fw_cfg_if.h diff --git a/src/mainboard/emulation/qemu-i440fx/Kconfig b/src/mainboard/emulation/qemu-i440fx/Kconfig index 6d6181c..e17e25d 100644 --- a/src/mainboard/emulation/qemu-i440fx/Kconfig +++ b/src/mainboard/emulation/qemu-i440fx/Kconfig @@ -20,6 +20,7 @@ select BOOT_DEVICE_NOT_SPI_FLASH select BOOT_DEVICE_MEMORY_MAPPED select BOOT_DEVICE_SUPPORTS_WRITES + select DRIVERS_EMULATION_QEMU_FW_CFG
config VBOOT select VBOOT_MUST_REQUEST_DISPLAY diff --git a/src/mainboard/emulation/qemu-i440fx/Makefile.mk b/src/mainboard/emulation/qemu-i440fx/Makefile.mk index 6ff2f73..c20f427 100644 --- a/src/mainboard/emulation/qemu-i440fx/Makefile.mk +++ b/src/mainboard/emulation/qemu-i440fx/Makefile.mk @@ -9,5 +9,4 @@ ramstage-y += northbridge.c ramstage-y += rom_media.c
-all-y += fw_cfg.c all-y += bootmode.c diff --git a/src/mainboard/emulation/qemu-i440fx/bootmode.c b/src/mainboard/emulation/qemu-i440fx/bootmode.c index 12990b2..ce06478 100644 --- a/src/mainboard/emulation/qemu-i440fx/bootmode.c +++ b/src/mainboard/emulation/qemu-i440fx/bootmode.c @@ -2,7 +2,7 @@
#include <bootmode.h> #include <console/console.h> -#include "fw_cfg.h" +#include <device/fw_cfg.h>
/* * Enable recovery mode with fw_cfg option to qemu: diff --git a/src/mainboard/emulation/qemu-i440fx/memmap.c b/src/mainboard/emulation/qemu-i440fx/memmap.c index be730b7..a8033f2 100644 --- a/src/mainboard/emulation/qemu-i440fx/memmap.c +++ b/src/mainboard/emulation/qemu-i440fx/memmap.c @@ -5,8 +5,8 @@ #include <arch/romstage.h> #include <console/console.h> #include <cpu/x86/smm.h> +#include <device/fw_cfg.h> #include "memory.h" -#include "fw_cfg.h"
#define CMOS_ADDR_PORT 0x70 #define CMOS_DATA_PORT 0x71 diff --git a/src/mainboard/emulation/qemu-i440fx/northbridge.c b/src/mainboard/emulation/qemu-i440fx/northbridge.c index 609e389..5c8636c 100644 --- a/src/mainboard/emulation/qemu-i440fx/northbridge.c +++ b/src/mainboard/emulation/qemu-i440fx/northbridge.c @@ -9,15 +9,14 @@ #include <device/pci_def.h> #include <device/pci_ops.h> #include <device/device.h> +#include <device/fw_cfg.h> +#include <device/fw_cfg_if.h> #include <identity.h> #include <stdlib.h> #include <smbios.h> #include <types.h> #include "memory.h"
-#include "fw_cfg.h" -#include "fw_cfg_if.h" - #include "acpi.h"
static void qemu_reserve_ports(struct device *dev, unsigned int idx, diff --git a/src/mainboard/emulation/qemu-q35/Kconfig b/src/mainboard/emulation/qemu-q35/Kconfig index 70a7437..854c053 100644 --- a/src/mainboard/emulation/qemu-q35/Kconfig +++ b/src/mainboard/emulation/qemu-q35/Kconfig @@ -18,6 +18,7 @@ select BOOT_DEVICE_NOT_SPI_FLASH select BOOT_DEVICE_MEMORY_MAPPED select BOOT_DEVICE_SUPPORTS_WRITES + select DRIVERS_EMULATION_QEMU_FW_CFG
config VBOOT select VBOOT_MUST_REQUEST_DISPLAY diff --git a/src/mainboard/emulation/qemu-q35/Makefile.mk b/src/mainboard/emulation/qemu-q35/Makefile.mk index c1619f5..fc85e64 100644 --- a/src/mainboard/emulation/qemu-q35/Makefile.mk +++ b/src/mainboard/emulation/qemu-q35/Makefile.mk @@ -16,7 +16,6 @@ ramstage-y += memmap.c ramstage-y += cpu.c
-all-y += ../qemu-i440fx/fw_cfg.c all-y += ../qemu-i440fx/bootmode.c
ramstage-$(CONFIG_CHROMEOS) += chromeos.c diff --git a/src/mainboard/emulation/qemu-q35/acpi_tables.c b/src/mainboard/emulation/qemu-q35/acpi_tables.c index e85ce65..c1c483d 100644 --- a/src/mainboard/emulation/qemu-q35/acpi_tables.c +++ b/src/mainboard/emulation/qemu-q35/acpi_tables.c @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */
#include <acpi/acpi.h> +#include <device/fw_cfg.h>
-#include "../qemu-i440fx/fw_cfg.h" #include "../qemu-i440fx/acpi.h"
void mainboard_fill_fadt(acpi_fadt_t *fadt) diff --git a/src/mainboard/emulation/qemu-q35/cpu.c b/src/mainboard/emulation/qemu-q35/cpu.c index c57ec50..c30c833 100644 --- a/src/mainboard/emulation/qemu-q35/cpu.c +++ b/src/mainboard/emulation/qemu-q35/cpu.c @@ -7,7 +7,7 @@ #include <cpu/x86/legacy_save_state.h> #include <cpu/x86/mp.h> #include <cpu/x86/smm.h> -#include <mainboard/emulation/qemu-i440fx/fw_cfg.h> +#include <device/fw_cfg.h> #include <stddef.h> #include <stdint.h>
diff --git a/src/mainboard/emulation/qemu-q35/memmap.c b/src/mainboard/emulation/qemu-q35/memmap.c index d57b25c..3e8da5c 100644 --- a/src/mainboard/emulation/qemu-q35/memmap.c +++ b/src/mainboard/emulation/qemu-q35/memmap.c @@ -5,9 +5,9 @@ #include <assert.h> #include <console/console.h> #include <cpu/x86/smm.h> +#include <device/fw_cfg.h> #include <device/pci_ops.h> #include <mainboard/emulation/qemu-i440fx/memory.h> -#include <mainboard/emulation/qemu-i440fx/fw_cfg.h> #include <cpu/intel/smm_reloc.h>
#include "q35.h"