All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Marcel Apfelbaum <marcel@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Richard Henderson <rth@twiddle.net>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL 07/55] pc: Move option_rom_has_mr/rom_file_has_mr globals to MachineClass
Date: Tue, 22 Dec 2015 18:52:57 +0200	[thread overview]
Message-ID: <1450803119-4223-8-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1450803119-4223-1-git-send-email-mst@redhat.com>

From: Eduardo Habkost <ehabkost@redhat.com>

This way, these settings can be simply set on the corresponding
machine_options() function, instead of requiring code in
pc_compat_*() functions.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
---
 include/hw/boards.h |  2 ++
 hw/core/loader.c    | 10 +++++-----
 hw/core/machine.c   |  1 +
 hw/i386/pc_piix.c   |  8 ++++----
 hw/i386/pc_q35.c    |  4 ++--
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index f19df97..051db5e 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -93,6 +93,8 @@ struct MachineClass {
     GlobalProperty *compat_props;
     const char *hw_version;
     ram_addr_t default_ram_size;
+    bool option_rom_has_mr;
+    bool rom_file_has_mr;
 
     HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
                                            DeviceState *dev);
diff --git a/hw/core/loader.c b/hw/core/loader.c
index eb67f05..6b69852 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -51,12 +51,10 @@
 #include "hw/nvram/fw_cfg.h"
 #include "exec/memory.h"
 #include "exec/address-spaces.h"
+#include "hw/boards.h"
 
 #include <zlib.h>
 
-bool option_rom_has_mr = false;
-bool rom_file_has_mr = true;
-
 static int roms_loaded;
 
 /* return the size or -1 if error */
@@ -754,6 +752,7 @@ int rom_add_file(const char *file, const char *fw_dir,
                  hwaddr addr, int32_t bootindex,
                  bool option_rom)
 {
+    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
     Rom *rom;
     int rc, fd = -1;
     char devpath[100];
@@ -810,7 +809,7 @@ int rom_add_file(const char *file, const char *fw_dir,
                  basename);
         snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
 
-        if ((!option_rom || option_rom_has_mr) && rom_file_has_mr) {
+        if ((!option_rom || mc->option_rom_has_mr) && mc->rom_file_has_mr) {
             data = rom_set_mr(rom, OBJECT(fw_cfg), devpath);
         } else {
             data = rom->data;
@@ -838,6 +837,7 @@ MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
                    size_t max_len, hwaddr addr, const char *fw_file_name,
                    FWCfgReadCallback fw_callback, void *callback_opaque)
 {
+    MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
     Rom *rom;
     MemoryRegion *mr = NULL;
 
@@ -855,7 +855,7 @@ MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
 
         snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
 
-        if (rom_file_has_mr) {
+        if (mc->rom_file_has_mr) {
             data = rom_set_mr(rom, OBJECT(fw_cfg), devpath);
             mr = rom->mr;
         } else {
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 82be54e..c46ddc7 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -342,6 +342,7 @@ static void machine_class_init(ObjectClass *oc, void *data)
 
     /* Default 128 MB as guest ram size */
     mc->default_ram_size = 128 * M_BYTE;
+    mc->rom_file_has_mr = true;
 }
 
 static void machine_class_base_init(ObjectClass *oc, void *data)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index f058b3c..7d847b2 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -320,14 +320,12 @@ static void pc_compat_2_0(MachineState *machine)
 static void pc_compat_1_7(MachineState *machine)
 {
     pc_compat_2_0(machine);
-    option_rom_has_mr = true;
     x86_cpu_change_kvm_default("x2apic", NULL);
 }
 
 static void pc_compat_1_6(MachineState *machine)
 {
     pc_compat_1_7(machine);
-    rom_file_has_mr = false;
 }
 
 static void pc_compat_1_5(MachineState *machine)
@@ -361,8 +359,6 @@ static void pc_compat_0_13(MachineState *machine)
 
 static void pc_init_isa(MachineState *machine)
 {
-    option_rom_has_mr = true;
-    rom_file_has_mr = false;
     if (!machine->cpu_model) {
         machine->cpu_model = "486";
     }
@@ -527,6 +523,7 @@ static void pc_i440fx_1_7_machine_options(MachineClass *m)
     pc_i440fx_2_0_machine_options(m);
     m->hw_version = "1.7.0";
     m->default_machine_opts = NULL;
+    m->option_rom_has_mr = true;
     SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
     pcmc->smbios_defaults = false;
     pcmc->gigabyte_align = false;
@@ -542,6 +539,7 @@ static void pc_i440fx_1_6_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_1_7_machine_options(m);
     m->hw_version = "1.6.0";
+    m->rom_file_has_mr = false;
     SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
     pcmc->has_acpi_build = false;
 }
@@ -1026,6 +1024,8 @@ static void isapc_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     m->desc = "ISA-only PC";
     m->max_cpus = 1;
+    m->option_rom_has_mr = true;
+    m->rom_file_has_mr = false;
     pcmc->pci_enabled = false;
     pcmc->has_acpi_build = false;
     pcmc->smbios_defaults = false;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 2f644f9..6aaa0ee 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -304,14 +304,12 @@ static void pc_compat_2_0(MachineState *machine)
 static void pc_compat_1_7(MachineState *machine)
 {
     pc_compat_2_0(machine);
-    option_rom_has_mr = true;
     x86_cpu_change_kvm_default("x2apic", NULL);
 }
 
 static void pc_compat_1_6(MachineState *machine)
 {
     pc_compat_1_7(machine);
-    rom_file_has_mr = false;
 }
 
 static void pc_compat_1_5(MachineState *machine)
@@ -434,6 +432,7 @@ static void pc_q35_1_7_machine_options(MachineClass *m)
     pc_q35_2_0_machine_options(m);
     m->hw_version = "1.7.0";
     m->default_machine_opts = NULL;
+    m->option_rom_has_mr = true;
     SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
     pcmc->smbios_defaults = false;
     pcmc->gigabyte_align = false;
@@ -448,6 +447,7 @@ static void pc_q35_1_6_machine_options(MachineClass *m)
     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_q35_machine_options(m);
     m->hw_version = "1.6.0";
+    m->rom_file_has_mr = false;
     SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
     pcmc->has_acpi_build = false;
 }
-- 
MST

  parent reply	other threads:[~2015-12-22 16:53 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 16:52 [Qemu-devel] [PULL 00/55] acpi, pc features Michael S. Tsirkin
2015-12-22 16:52 ` [Qemu-devel] [PULL 01/55] mmap-alloc: tweak a comment on ppc64 Michael S. Tsirkin
2015-12-22 16:52 ` [Qemu-devel] [PULL 02/55] pc: Move compat boolean globals to PCMachineClass Michael S. Tsirkin
2015-12-22 16:52 ` [Qemu-devel] [PULL 03/55] pc: Move legacy_acpi_table_size global " Michael S. Tsirkin
2015-12-22 16:52 ` [Qemu-devel] [PULL 04/55] pc: Move acpi_data_size " Michael S. Tsirkin
2015-12-22 16:52 ` [Qemu-devel] [PULL 05/55] pc: Move enforce_aligned_dimm " Michael S. Tsirkin
2015-12-22 16:52 ` [Qemu-devel] [PULL 06/55] pc: Remove enforce-aligned-dimm QOM property Michael S. Tsirkin
2015-12-22 16:52 ` Michael S. Tsirkin [this message]
2015-12-22 16:52 ` [Qemu-devel] [PULL 08/55] hw/acpi: merge pxb adjacent memory/IO ranges Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 09/55] hw/pxb: introduce pxb-pcie expander for PCIe machines Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 10/55] hw/i386: extend pxb query for all PC machines Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 11/55] q35: Remove MCHPCIState.guest_info field Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 12/55] pc: Group and document related PCMachineState/PCMachineclass fields Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 13/55] Add a base IPMI interface Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 14/55] ipmi: Add a local BMC simulation Michael S. Tsirkin
2016-01-08  9:02   ` Paolo Bonzini
2016-01-08  9:05   ` Paolo Bonzini
2016-01-12 11:06     ` Michael S. Tsirkin
2016-01-12 12:02       ` Paolo Bonzini
2015-12-22 16:53 ` [Qemu-devel] [PULL 15/55] ipmi: Add an external connection simulation interface Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 16/55] ipmi: Add an ISA KCS low-level interface Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 17/55] ipmi: Add a BT " Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 18/55] ipmi: Add tests Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 19/55] ipmi: Add documentation Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 20/55] ipmi: Add migration capability to the IPMI devices Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 21/55] ipmi: Add a firmware configuration repository Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 22/55] ipmi: Add firmware registration to the ISA interface Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 23/55] ipmi: Add a force off function Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 24/55] q35: skip q35-acpi-dsdt.aml load if not needed Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 25/55] pc: Remove redundant code from pc-*-2.3 machine classes Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 26/55] pc: Add pc-*-2.6 " Michael S. Tsirkin
2015-12-22 16:53 ` [Qemu-devel] [PULL 27/55] pc: Change indentation of PC_COMPAT_* to 4 spaces Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 28/55] hw/compat.h: Change indentation of HW_COMPAT_* " Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 29/55] docs/pci_expander_bridge: fix typo Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 30/55] nvdimm: implement NVDIMM device abstract Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 31/55] acpi: support specified oem table id for build_header Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 32/55] nvdimm acpi: build ACPI NFIT table Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 33/55] nvdimm acpi: build ACPI nvdimm devices Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 34/55] nvdimm: add maintain info Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 35/55] acpi: add aml_derefof Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 36/55] acpi: add aml_sizeof Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 37/55] acpi: add aml_lgreater_equal() Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 38/55] acpi: add aml_mutex(), aml_acquire(), aml_release() Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 39/55] acpi: add aml_create_qword_field() Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 40/55] acpi: aml: add helper for Opcode Arg2 Arg2 [Dst] AML pattern Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 41/55] acpi: extend aml_add() to accept target argument Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 42/55] acpi: add aml_decrement() and aml_subtract() Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 43/55] acpi: add aml_call0() helper Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 44/55] acpi: add aml_to_integer() Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 45/55] acpi: extend aml_shiftright() to accept target argument Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 46/55] acpi: add aml_alias() Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 47/55] acpi: add aml_sleep() Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 48/55] acpi: add aml_lor() Michael S. Tsirkin
2015-12-22 16:54 ` [Qemu-devel] [PULL 49/55] acpi: add aml_lgreater() Michael S. Tsirkin
2015-12-22 16:55 ` [Qemu-devel] [PULL 50/55] acpi: extend aml_field() to support LockRule Michael S. Tsirkin
2015-12-22 16:55 ` [Qemu-devel] [PULL 51/55] acpi: add aml_to_hexstring() Michael S. Tsirkin
2015-12-22 16:55 ` [Qemu-devel] [PULL 52/55] acpi: add aml_to_buffer() Michael S. Tsirkin
2015-12-22 16:55 ` [Qemu-devel] [PULL 53/55] acpi add aml_dma() Michael S. Tsirkin
2015-12-22 16:55 ` [Qemu-devel] [PULL 54/55] acpi: extend aml_or() to accept target argument Michael S. Tsirkin
2015-12-22 16:55 ` [Qemu-devel] [PULL 55/55] acpi: extend aml_and() " Michael S. Tsirkin
2015-12-23 12:55 ` [Qemu-devel] [PULL 00/55] acpi, pc features Peter Maydell
2016-01-08 14:53 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450803119-4223-8-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.