Provide FW_CFG_EMULATOR info to the BIOS This option provides info to the BIOS informing it which emulator it is running on top of. The emulator version is designed as a master rev, for the upper 8 bits, and a minor version for the lower 8 bits. This allows one to specify QEMU_KVM vs QEMU_KQEMU for example. It should leave space for other emulators to register themselves too. If the BIOS' probe for FW_CFG fails, it is expected it sets it's emulator version to the same as CFG_EMU_NONE. I have a set of patches for Seabios using this to determine it is running on top of QEMU and KVM. This allows setting certain KVM specific bits, and also determining at runtime that Seabios is running on top of QEMU, eliminating the #define CONFIG_KVM. Signed-off-by: Jes Sorensen --- hw/fw_cfg.c | 3 +++ hw/fw_cfg.h | 11 ++++++++++- vl.c | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) Index: qemu/hw/fw_cfg.c =================================================================== --- qemu.orig/hw/fw_cfg.c +++ qemu/hw/fw_cfg.c @@ -38,6 +38,8 @@ #define FW_CFG_SIZE 2 +extern uint16_t emu_type; + typedef struct _FWCfgEntry { uint16_t len; uint8_t *data; @@ -281,6 +283,7 @@ void *fw_cfg_init(uint32_t ctl_port, uin fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu); + fw_cfg_add_i16(s, FW_CFG_EMULATOR, emu_type); register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s); qemu_register_reset(fw_cfg_reset, s); Index: qemu/hw/fw_cfg.h =================================================================== --- qemu.orig/hw/fw_cfg.h +++ qemu/hw/fw_cfg.h @@ -17,7 +17,8 @@ #define FW_CFG_NUMA 0x0d #define FW_CFG_BOOT_MENU 0x0e #define FW_CFG_MAX_CPUS 0x0f -#define FW_CFG_MAX_ENTRY 0x10 +#define FW_CFG_EMULATOR 0x10 +#define FW_CFG_MAX_ENTRY 0x11 #define FW_CFG_WRITE_CHANNEL 0x4000 #define FW_CFG_ARCH_LOCAL 0x8000 @@ -25,6 +26,14 @@ #define FW_CFG_INVALID 0xffff +/* + * Values for FW_CFG_EMULATOR + */ +#define CFG_EMU_NONE 0x0000 +#define CFG_EMU_QEMU 0x0100 +#define CFG_EMU_QEMU_KVM 0x0101 +#define CFG_EMU_QEMU_KQEMU 0x0102 + #ifndef NO_QEMU_PROTOS typedef void (*FWCfgCallback)(void *opaque, uint8_t *data); Index: qemu/vl.c =================================================================== --- qemu.orig/vl.c +++ qemu/vl.c @@ -142,6 +142,7 @@ int main(int argc, char **argv) #include "hw/smbios.h" #include "hw/xen.h" #include "hw/qdev.h" +#include "hw/fw_cfg.h" #include "bt-host.h" #include "net.h" #include "monitor.h" @@ -270,6 +271,8 @@ uint8_t qemu_uuid[16]; static QEMUBootSetHandler *boot_set_handler; static void *boot_set_opaque; +uint16_t emu_type = CFG_EMU_QEMU; + /***********************************************************/ /* x86 ISA bus support */ @@ -5426,14 +5429,17 @@ int main(int argc, char **argv, char **e #ifdef CONFIG_KQEMU case QEMU_OPTION_enable_kqemu: kqemu_allowed = 1; + emu_type = CFG_EMU_QEMU_KQEMU; break; case QEMU_OPTION_kernel_kqemu: kqemu_allowed = 2; + emu_type = CFG_EMU_QEMU_KQEMU; break; #endif #ifdef CONFIG_KVM case QEMU_OPTION_enable_kvm: kvm_allowed = 1; + emu_type = CFG_EMU_QEMU_KVM; #ifdef CONFIG_KQEMU kqemu_allowed = 0; #endif