From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uhogv-0000J2-V8 for qemu-devel@nongnu.org; Wed, 29 May 2013 18:18:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhogR-00077b-JS for qemu-devel@nongnu.org; Wed, 29 May 2013 18:17:57 -0400 Received: from vms173023pub.verizon.net ([206.46.173.23]:39408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhogR-000771-BR for qemu-devel@nongnu.org; Wed, 29 May 2013 18:17:27 -0400 Received: from wf-rch.minyard.home ([unknown] [173.74.121.95]) by vms173023.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0MNK00LYIZ8D2E40@vms173023.mailsrvcs.net> for qemu-devel@nongnu.org; Wed, 29 May 2013 17:17:03 -0500 (CDT) From: minyard@acm.org Date: Wed, 29 May 2013 17:08:13 -0500 Message-id: <1369865296-19584-18-git-send-email-minyard@acm.org> In-reply-to: <1369865296-19584-1-git-send-email-minyard@acm.org> References: <1369865296-19584-1-git-send-email-minyard@acm.org> Subject: [Qemu-devel] [PATCH 17/20] pc: Postpone adding ACPI and SMBIOS to fw_cfg List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Corey Minyard , openipmi-developer@lists.sourceforge.net, Corey Minyard From: Corey Minyard Postpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables. Signed-off-by: Corey Minyard --- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 197d218..d3143a4 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -598,8 +598,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus) static void *bochs_bios_init(void) { void *fw_cfg; - uint8_t *smbios_table; - size_t smbios_len; uint64_t *numa_fw_cfg; int i, j; unsigned int apic_id_limit = pc_apic_id_limit(max_cpus); @@ -622,14 +620,8 @@ static void *bochs_bios_init(void) fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)apic_id_limit); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); - fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, - acpi_tables, acpi_tables_len); fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override()); - smbios_table = smbios_get_table(&smbios_len); - if (smbios_table) - fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, - smbios_table, smbios_len); fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE, &e820_table, sizeof(e820_table)); @@ -1012,6 +1004,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { + Notifier post_init; + void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized. + * This gives devices a chance to add to those tables. + */ +static void pc_bios_post_initfn(Notifier *n, void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init, + post_init); + uint8_t *smbios_table; + size_t smbios_len; + + fw_cfg_add_bytes(p->fw_cfg, FW_CFG_ACPI_TABLES, + acpi_tables, acpi_tables_len); + smbios_table = smbios_get_table(&smbios_len); + if (smbios_table) + fw_cfg_add_bytes(p->fw_cfg, FW_CFG_SMBIOS_ENTRIES, + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + void *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline, @@ -1071,6 +1088,11 @@ void *pc_memory_init(MemoryRegion *system_memory, for (i = 0; i < nb_option_roms; i++) { rom_add_option(option_rom[i].name, option_rom[i].bootindex); } + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; + qemu_add_machine_init_done_notifier(&post_init.post_init); + return fw_cfg; } -- 1.7.9.5