qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/9] pci: misc cleanups
@ 2013-06-04  8:07 Michael S. Tsirkin
  2013-06-04  8:07 ` [Qemu-devel] [PULL 1/9] q35: set fw_name Michael S. Tsirkin
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:07 UTC (permalink / raw)
  To: qemu-devel, Anthony Liguori; +Cc: akong, lersek, afaerber

The following changes since commit 87d23f78aa79b72da022afda358bbc8a8509ca70:

  virtio-pci: drop unused wmb macro (2013-05-29 08:16:21 -0500)

are available in the git repository at:

  git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony

for you to fetch changes up to c3c4fe35be9f6c37388ba7615c6c33e8f4034438:

  pvpanic: use FWCfgState explicitly (2013-06-02 18:14:15 +0300)

----------------------------------------------------------------
pci: misc cleanups

This includes some pci-related cleanups,
and fw cfg cleanups which will be useful for on-going
pci related work.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

----------------------------------------------------------------
Laszlo Ersek (1):
      refer to FWCfgState explicitly

Michael S. Tsirkin (8):
      q35: set fw_name
      dec.c - move to pci-bridge
      firmware_abi: move to include/hw/nvram/
      apic: rename apic specific bitopts
      fw_cfg: move typedef to qemu/typedefs.h
      fw_cfg: add API to find FW cfg object
      fw_cfg: fw_cfg is a singleton
      pvpanic: use FWCfgState explicitly

 hw/acpi/piix4.c                                    |  2 +-
 hw/core/loader.c                                   |  2 +-
 hw/i386/multiboot.c                                |  2 +-
 hw/i386/multiboot.h                                |  4 ++-
 hw/i386/pc.c                                       | 24 ++++++-------
 hw/i386/pc_piix.c                                  |  2 +-
 hw/intc/apic.c                                     | 42 +++++++++++-----------
 hw/misc/pvpanic.c                                  |  4 +--
 hw/nvram/fw_cfg.c                                  | 18 +++++++---
 hw/nvram/mac_nvram.c                               |  2 +-
 hw/pci-bridge/Makefile.objs                        |  2 ++
 hw/{pci-host => pci-bridge}/dec.c                  |  0
 hw/{pci-host => pci-bridge}/dec.h                  |  0
 hw/pci-host/Makefile.objs                          |  1 -
 hw/pci-host/q35.c                                  |  1 +
 hw/sparc/sun4m.c                                   |  4 +--
 hw/sparc64/sun4u.c                                 |  4 +--
 include/hw/i386/pc.h                               | 18 +++++-----
 include/hw/loader.h                                |  3 +-
 include/hw/nvram/fw_cfg.h                          |  4 ++-
 .../openbios_firmware_abi.h}                       |  0
 include/qemu/typedefs.h                            |  1 +
 22 files changed, 78 insertions(+), 62 deletions(-)
 rename hw/{pci-host => pci-bridge}/dec.c (100%)
 rename hw/{pci-host => pci-bridge}/dec.h (100%)
 rename include/hw/{sparc/firmware_abi.h => nvram/openbios_firmware_abi.h} (100%)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PULL 1/9] q35: set fw_name
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
@ 2013-06-04  8:07 ` Michael S. Tsirkin
  2013-06-04  8:07 ` [Qemu-devel] [PULL 2/9] dec.c - move to pci-bridge Michael S. Tsirkin
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-stable

PCI host bridges need to set fw_name to be discoverable
by bios for boot device selection.

In particular, seabios expects root device to be called
"/pci/@i0cf8", so let's set it up like that for Q35.

Cc: qemu-stable@nongnu.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Amos Kong <akong@redhat.com>
---
 hw/pci-host/q35.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 8467f86..24df6b5 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -76,6 +76,7 @@ static void q35_host_class_init(ObjectClass *klass, void *data)
 
     k->init = q35_host_init;
     dc->props = mch_props;
+    dc->fw_name = "pci";
 }
 
 static void q35_host_initfn(Object *obj)
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PULL 2/9] dec.c - move to pci-bridge
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
  2013-06-04  8:07 ` [Qemu-devel] [PULL 1/9] q35: set fw_name Michael S. Tsirkin
@ 2013-06-04  8:07 ` Michael S. Tsirkin
  2013-06-04  8:07 ` [Qemu-devel] [PULL 3/9] firmware_abi: move to include/hw/nvram/ Michael S. Tsirkin
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:07 UTC (permalink / raw)
  To: qemu-devel

Looks like dec.c is in pci-host by mistake.
Moving it over to pci-bridge.

Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci-bridge/Makefile.objs       | 2 ++
 hw/{pci-host => pci-bridge}/dec.c | 0
 hw/{pci-host => pci-bridge}/dec.h | 0
 hw/pci-host/Makefile.objs         | 1 -
 4 files changed, 2 insertions(+), 1 deletion(-)
 rename hw/{pci-host => pci-bridge}/dec.c (100%)
 rename hw/{pci-host => pci-bridge}/dec.h (100%)

diff --git a/hw/pci-bridge/Makefile.objs b/hw/pci-bridge/Makefile.objs
index 5dd92d2..968b369 100644
--- a/hw/pci-bridge/Makefile.objs
+++ b/hw/pci-bridge/Makefile.objs
@@ -1,3 +1,5 @@
 common-obj-y += pci_bridge_dev.o
 common-obj-y += ioh3420.o xio3130_upstream.o xio3130_downstream.o
 common-obj-y += i82801b11.o
+# NewWorld PowerMac
+common-obj-$(CONFIG_DEC_PCI) += dec.o
diff --git a/hw/pci-host/dec.c b/hw/pci-bridge/dec.c
similarity index 100%
rename from hw/pci-host/dec.c
rename to hw/pci-bridge/dec.c
diff --git a/hw/pci-host/dec.h b/hw/pci-bridge/dec.h
similarity index 100%
rename from hw/pci-host/dec.h
rename to hw/pci-bridge/dec.h
diff --git a/hw/pci-host/Makefile.objs b/hw/pci-host/Makefile.objs
index 909e702..bb65f9c 100644
--- a/hw/pci-host/Makefile.objs
+++ b/hw/pci-host/Makefile.objs
@@ -5,7 +5,6 @@ common-obj-$(CONFIG_PREP_PCI) += prep.o
 common-obj-$(CONFIG_GRACKLE_PCI) += grackle.o
 # NewWorld PowerMac
 common-obj-$(CONFIG_UNIN_PCI) += uninorth.o
-common-obj-$(CONFIG_DEC_PCI) += dec.o
 # PowerPC E500 boards
 common-obj-$(CONFIG_PPCE500_PCI) += ppce500.o
 
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PULL 3/9] firmware_abi: move to include/hw/nvram/
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
  2013-06-04  8:07 ` [Qemu-devel] [PULL 1/9] q35: set fw_name Michael S. Tsirkin
  2013-06-04  8:07 ` [Qemu-devel] [PULL 2/9] dec.c - move to pci-bridge Michael S. Tsirkin
@ 2013-06-04  8:07 ` Michael S. Tsirkin
  2013-06-04  8:07 ` [Qemu-devel] [PULL 4/9] apic: rename apic specific bitopts Michael S. Tsirkin
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl

firmware_abi.h with structs for OpenBIOS landed in hw/sparc/ by mistake
- move it to hw/nvram/ alongside fw_cfg.h.  In addition to sparc it's
included from ppc mac_nvram.c and will need to include it from prep.c in
the future.

Acked-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/nvram/mac_nvram.c                                               | 2 +-
 hw/sparc/sun4m.c                                                   | 2 +-
 hw/sparc64/sun4u.c                                                 | 2 +-
 include/hw/{sparc/firmware_abi.h => nvram/openbios_firmware_abi.h} | 0
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename include/hw/{sparc/firmware_abi.h => nvram/openbios_firmware_abi.h} (100%)

diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index 5223330..d76a06c 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -23,7 +23,7 @@
  * THE SOFTWARE.
  */
 #include "hw/hw.h"
-#include "hw/sparc/firmware_abi.h"
+#include "hw/nvram/openbios_firmware_abi.h"
 #include "sysemu/sysemu.h"
 #include "hw/ppc/mac.h"
 
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 8840881..6e62d17 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -30,7 +30,7 @@
 #include "sysemu/sysemu.h"
 #include "net/net.h"
 #include "hw/boards.h"
-#include "hw/sparc/firmware_abi.h"
+#include "hw/nvram/openbios_firmware_abi.h"
 #include "hw/scsi/esp.h"
 #include "hw/i386/pc.h"
 #include "hw/isa/isa.h"
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 5c2bbd4..13672de 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -32,7 +32,7 @@
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
-#include "hw/sparc/firmware_abi.h"
+#include "hw/nvram/openbios_firmware_abi.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/sysbus.h"
 #include "hw/ide.h"
diff --git a/include/hw/sparc/firmware_abi.h b/include/hw/nvram/openbios_firmware_abi.h
similarity index 100%
rename from include/hw/sparc/firmware_abi.h
rename to include/hw/nvram/openbios_firmware_abi.h
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PULL 4/9] apic: rename apic specific bitopts
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
                   ` (2 preceding siblings ...)
  2013-06-04  8:07 ` [Qemu-devel] [PULL 3/9] firmware_abi: move to include/hw/nvram/ Michael S. Tsirkin
@ 2013-06-04  8:07 ` Michael S. Tsirkin
  2013-06-04  8:07 ` [Qemu-devel] [PULL 5/9] refer to FWCfgState explicitly Michael S. Tsirkin
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:07 UTC (permalink / raw)
  To: qemu-devel

apic has its own version of bitops, with the
difference that it works on u32 and not long.
Add apic_ prefix to avoid namespace clashes.

We should look into reusing standard bitops long-term,
but that's not entirely trivial.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/intc/apic.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/hw/intc/apic.c b/hw/intc/apic.c
index 756dff0..46cb097 100644
--- a/hw/intc/apic.c
+++ b/hw/intc/apic.c
@@ -40,18 +40,18 @@ static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask,
                                       uint8_t dest, uint8_t dest_mode);
 
 /* Find first bit starting from msb */
-static int fls_bit(uint32_t value)
+static int apic_fls_bit(uint32_t value)
 {
     return 31 - clz32(value);
 }
 
 /* Find first bit starting from lsb */
-static int ffs_bit(uint32_t value)
+static int apic_ffs_bit(uint32_t value)
 {
     return ctz32(value);
 }
 
-static inline void set_bit(uint32_t *tab, int index)
+static inline void apic_set_bit(uint32_t *tab, int index)
 {
     int i, mask;
     i = index >> 5;
@@ -59,7 +59,7 @@ static inline void set_bit(uint32_t *tab, int index)
     tab[i] |= mask;
 }
 
-static inline void reset_bit(uint32_t *tab, int index)
+static inline void apic_reset_bit(uint32_t *tab, int index)
 {
     int i, mask;
     i = index >> 5;
@@ -67,7 +67,7 @@ static inline void reset_bit(uint32_t *tab, int index)
     tab[i] &= ~mask;
 }
 
-static inline int get_bit(uint32_t *tab, int index)
+static inline int apic_get_bit(uint32_t *tab, int index)
 {
     int i, mask;
     i = index >> 5;
@@ -81,7 +81,7 @@ static int get_highest_priority_int(uint32_t *tab)
     int i;
     for (i = 7; i >= 0; i--) {
         if (tab[i] != 0) {
-            return i * 32 + fls_bit(tab[i]);
+            return i * 32 + apic_fls_bit(tab[i]);
         }
     }
     return -1;
@@ -184,7 +184,7 @@ void apic_deliver_pic_intr(DeviceState *d, int level)
         case APIC_DM_FIXED:
             if (!(lvt & APIC_LVT_LEVEL_TRIGGER))
                 break;
-            reset_bit(s->irr, lvt & 0xff);
+            apic_reset_bit(s->irr, lvt & 0xff);
             /* fall through */
         case APIC_DM_EXTINT:
             cpu_reset_interrupt(CPU(s->cpu), CPU_INTERRUPT_HARD);
@@ -230,7 +230,7 @@ static void apic_bus_deliver(const uint32_t *deliver_bitmask,
                 d = -1;
                 for(i = 0; i < MAX_APIC_WORDS; i++) {
                     if (deliver_bitmask[i]) {
-                        d = i * 32 + ffs_bit(deliver_bitmask[i]);
+                        d = i * 32 + apic_ffs_bit(deliver_bitmask[i]);
                         break;
                     }
                 }
@@ -386,13 +386,13 @@ void apic_poll_irq(DeviceState *d)
 
 static void apic_set_irq(APICCommonState *s, int vector_num, int trigger_mode)
 {
-    apic_report_irq_delivered(!get_bit(s->irr, vector_num));
+    apic_report_irq_delivered(!apic_get_bit(s->irr, vector_num));
 
-    set_bit(s->irr, vector_num);
+    apic_set_bit(s->irr, vector_num);
     if (trigger_mode)
-        set_bit(s->tmr, vector_num);
+        apic_set_bit(s->tmr, vector_num);
     else
-        reset_bit(s->tmr, vector_num);
+        apic_reset_bit(s->tmr, vector_num);
     if (s->vapic_paddr) {
         apic_sync_vapic(s, SYNC_ISR_IRR_TO_VAPIC);
         /*
@@ -412,8 +412,8 @@ static void apic_eoi(APICCommonState *s)
     isrv = get_highest_priority_int(s->isr);
     if (isrv < 0)
         return;
-    reset_bit(s->isr, isrv);
-    if (!(s->spurious_vec & APIC_SV_DIRECTED_IO) && get_bit(s->tmr, isrv)) {
+    apic_reset_bit(s->isr, isrv);
+    if (!(s->spurious_vec & APIC_SV_DIRECTED_IO) && apic_get_bit(s->tmr, isrv)) {
         ioapic_eoi_broadcast(isrv);
     }
     apic_sync_vapic(s, SYNC_FROM_VAPIC | SYNC_TO_VAPIC);
@@ -452,7 +452,7 @@ static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask,
             int idx = apic_find_dest(dest);
             memset(deliver_bitmask, 0x00, MAX_APIC_WORDS * sizeof(uint32_t));
             if (idx >= 0)
-                set_bit(deliver_bitmask, idx);
+                apic_set_bit(deliver_bitmask, idx);
         }
     } else {
         /* XXX: cluster mode */
@@ -462,11 +462,11 @@ static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask,
             if (apic_iter) {
                 if (apic_iter->dest_mode == 0xf) {
                     if (dest & apic_iter->log_dest)
-                        set_bit(deliver_bitmask, i);
+                        apic_set_bit(deliver_bitmask, i);
                 } else if (apic_iter->dest_mode == 0x0) {
                     if ((dest & 0xf0) == (apic_iter->log_dest & 0xf0) &&
                         (dest & apic_iter->log_dest & 0x0f)) {
-                        set_bit(deliver_bitmask, i);
+                        apic_set_bit(deliver_bitmask, i);
                     }
                 }
             } else {
@@ -509,14 +509,14 @@ static void apic_deliver(DeviceState *d, uint8_t dest, uint8_t dest_mode,
         break;
     case 1:
         memset(deliver_bitmask, 0x00, sizeof(deliver_bitmask));
-        set_bit(deliver_bitmask, s->idx);
+        apic_set_bit(deliver_bitmask, s->idx);
         break;
     case 2:
         memset(deliver_bitmask, 0xff, sizeof(deliver_bitmask));
         break;
     case 3:
         memset(deliver_bitmask, 0xff, sizeof(deliver_bitmask));
-        reset_bit(deliver_bitmask, s->idx);
+        apic_reset_bit(deliver_bitmask, s->idx);
         break;
     }
 
@@ -573,8 +573,8 @@ int apic_get_interrupt(DeviceState *d)
         apic_sync_vapic(s, SYNC_TO_VAPIC);
         return s->spurious_vec & 0xff;
     }
-    reset_bit(s->irr, intno);
-    set_bit(s->isr, intno);
+    apic_reset_bit(s->irr, intno);
+    apic_set_bit(s->isr, intno);
     apic_sync_vapic(s, SYNC_TO_VAPIC);
 
     /* re-inject if there is still a pending PIC interrupt */
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PULL 5/9] refer to FWCfgState explicitly
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
                   ` (3 preceding siblings ...)
  2013-06-04  8:07 ` [Qemu-devel] [PULL 4/9] apic: rename apic specific bitopts Michael S. Tsirkin
@ 2013-06-04  8:07 ` Michael S. Tsirkin
  2013-06-04  8:07 ` [Qemu-devel] [PULL 6/9] fw_cfg: move typedef to qemu/typedefs.h Michael S. Tsirkin
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Anthony Liguori, Laszlo Ersek

From: Laszlo Ersek <lersek@redhat.com>

Currently some places use pointer-to-void even though they mean
pointer-to-FWCfgState. Clean them up.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/acpi/piix4.c      |  2 +-
 hw/core/loader.c     |  2 +-
 hw/i386/multiboot.c  |  2 +-
 hw/i386/multiboot.h  |  4 +++-
 hw/i386/pc.c         | 24 ++++++++++++------------
 hw/i386/pc_piix.c    |  2 +-
 hw/sparc/sun4m.c     |  2 +-
 hw/sparc64/sun4u.c   |  2 +-
 include/hw/i386/pc.h | 19 ++++++++++---------
 include/hw/loader.h  |  3 ++-
 10 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index c4af1cc..e6525ac 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -447,7 +447,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
 
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
-                       int kvm_enabled, void *fw_cfg)
+                       int kvm_enabled, FWCfgState *fw_cfg)
 {
     PCIDevice *dev;
     PIIX4PMState *s;
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 7507914..a711145 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -733,7 +733,7 @@ int rom_load_all(void)
     return 0;
 }
 
-void rom_set_fw(void *f)
+void rom_set_fw(FWCfgState *f)
 {
     fw_cfg = f;
 }
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
index d696507..09211e0 100644
--- a/hw/i386/multiboot.c
+++ b/hw/i386/multiboot.c
@@ -124,7 +124,7 @@ static void mb_add_mod(MultibootState *s,
     s->mb_mods_count++;
 }
 
-int load_multiboot(void *fw_cfg,
+int load_multiboot(FWCfgState *fw_cfg,
                    FILE *f,
                    const char *kernel_filename,
                    const char *initrd_filename,
diff --git a/hw/i386/multiboot.h b/hw/i386/multiboot.h
index 98fb1b7..60de309 100644
--- a/hw/i386/multiboot.h
+++ b/hw/i386/multiboot.h
@@ -1,7 +1,9 @@
 #ifndef QEMU_MULTIBOOT_H
 #define QEMU_MULTIBOOT_H
 
-int load_multiboot(void *fw_cfg,
+#include "hw/nvram/fw_cfg.h"
+
+int load_multiboot(FWCfgState *fw_cfg,
                    FILE *f,
                    const char *kernel_filename,
                    const char *initrd_filename,
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 197d218..4844a6b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -595,9 +595,9 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)
     return x86_cpu_apic_id_from_index(max_cpus - 1) + 1;
 }
 
-static void *bochs_bios_init(void)
+static FWCfgState *bochs_bios_init(void)
 {
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     uint8_t *smbios_table;
     size_t smbios_len;
     uint64_t *numa_fw_cfg;
@@ -674,7 +674,7 @@ static long get_file_size(FILE *f)
     return size;
 }
 
-static void load_linux(void *fw_cfg,
+static void load_linux(FWCfgState *fw_cfg,
                        const char *kernel_filename,
                        const char *initrd_filename,
                        const char *kernel_cmdline,
@@ -1012,19 +1012,19 @@ void pc_acpi_init(const char *default_dsdt)
     }
 }
 
-void *pc_memory_init(MemoryRegion *system_memory,
-                    const char *kernel_filename,
-                    const char *kernel_cmdline,
-                    const char *initrd_filename,
-                    ram_addr_t below_4g_mem_size,
-                    ram_addr_t above_4g_mem_size,
-                    MemoryRegion *rom_memory,
-                    MemoryRegion **ram_memory)
+FWCfgState *pc_memory_init(MemoryRegion *system_memory,
+                           const char *kernel_filename,
+                           const char *kernel_cmdline,
+                           const char *initrd_filename,
+                           ram_addr_t below_4g_mem_size,
+                           ram_addr_t above_4g_mem_size,
+                           MemoryRegion *rom_memory,
+                           MemoryRegion **ram_memory)
 {
     int linux_boot, i;
     MemoryRegion *ram, *option_rom_mr;
     MemoryRegion *ram_below_4g, *ram_above_4g;
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
 
     linux_boot = (kernel_filename != NULL);
 
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 530b6ab..d547548 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -89,7 +89,7 @@ static void pc_init1(MemoryRegion *system_memory,
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
     DeviceState *icc_bridge;
-    void *fw_cfg = NULL;
+    FWCfgState *fw_cfg = NULL;
 
     icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
     object_property_add_child(qdev_get_machine(), "icc-bridge",
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 6e62d17..0e86ca7 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -831,7 +831,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
     qemu_irq *cpu_halt;
     unsigned long kernel_size;
     DriveInfo *fd[MAX_FD];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     unsigned int num_vsimms;
 
     /* init CPUs */
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 13672de..2c2a111 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -818,7 +818,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
     qemu_irq *ivec_irqs, *pbm_irqs;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     DriveInfo *fd[MAX_FD];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
 
     /* init CPUs */
     cpu = cpu_devinit(cpu_model, hwdef);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 663426c..fa3bf24 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -8,6 +8,7 @@
 #include "hw/block/fdc.h"
 #include "net/net.h"
 #include "hw/i386/ioapic.h"
+#include "hw/nvram/fw_cfg.h"
 
 /* PC-style peripherals (also used by other machines).  */
 
@@ -80,14 +81,14 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge);
 void pc_hot_add_cpu(const int64_t id, Error **errp);
 void pc_acpi_init(const char *default_dsdt);
-void *pc_memory_init(MemoryRegion *system_memory,
-                    const char *kernel_filename,
-                    const char *kernel_cmdline,
-                    const char *initrd_filename,
-                    ram_addr_t below_4g_mem_size,
-                    ram_addr_t above_4g_mem_size,
-                    MemoryRegion *rom_memory,
-                    MemoryRegion **ram_memory);
+FWCfgState *pc_memory_init(MemoryRegion *system_memory,
+                           const char *kernel_filename,
+                           const char *kernel_cmdline,
+                           const char *initrd_filename,
+                           ram_addr_t below_4g_mem_size,
+                           ram_addr_t above_4g_mem_size,
+                           MemoryRegion *rom_memory,
+                           MemoryRegion **ram_memory);
 qemu_irq *pc_allocate_cpu_irq(void);
 DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
 void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
@@ -111,7 +112,7 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
 
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
-                       int kvm_enabled, void *fw_cfg);
+                       int kvm_enabled, FWCfgState *fw_cfg);
 void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
 
 /* hpet.c */
diff --git a/include/hw/loader.h b/include/hw/loader.h
index 0958f06..15d4cc9 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -1,6 +1,7 @@
 #ifndef LOADER_H
 #define LOADER_H
 #include "qapi/qmp/qdict.h"
+#include "hw/nvram/fw_cfg.h"
 
 /* loader.c */
 int get_image_size(const char *filename);
@@ -30,7 +31,7 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
 int rom_add_elf_program(const char *name, void *data, size_t datasize,
                         size_t romsize, hwaddr addr);
 int rom_load_all(void);
-void rom_set_fw(void *f);
+void rom_set_fw(FWCfgState *f);
 int rom_copy(uint8_t *dest, hwaddr addr, size_t size);
 void *rom_ptr(hwaddr addr);
 void do_info_roms(Monitor *mon, const QDict *qdict);
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PULL 6/9] fw_cfg: move typedef to qemu/typedefs.h
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
                   ` (4 preceding siblings ...)
  2013-06-04  8:07 ` [Qemu-devel] [PULL 5/9] refer to FWCfgState explicitly Michael S. Tsirkin
@ 2013-06-04  8:07 ` Michael S. Tsirkin
  2013-06-04  8:08 ` [Qemu-devel] [PULL 7/9] fw_cfg: add API to find FW cfg object Michael S. Tsirkin
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:07 UTC (permalink / raw)
  To: qemu-devel

Less header dependencies this way.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/i386/pc.h      | 1 -
 include/hw/nvram/fw_cfg.h | 2 +-
 include/qemu/typedefs.h   | 1 +
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index fa3bf24..b4c8a74 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -8,7 +8,6 @@
 #include "hw/block/fdc.h"
 #include "net/net.h"
 #include "hw/i386/ioapic.h"
-#include "hw/nvram/fw_cfg.h"
 
 /* PC-style peripherals (also used by other machines).  */
 
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 3e4a334..f37714e 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -6,6 +6,7 @@
 #include <stddef.h>
 
 #include "exec/hwaddr.h"
+#include "qemu/typedefs.h"
 #endif
 
 #define FW_CFG_SIGNATURE        0x00
@@ -60,7 +61,6 @@ typedef struct FWCfgFiles {
 
 typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
 
-typedef struct FWCfgState FWCfgState;
 void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len);
 void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value);
 void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value);
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 93aae81..afe4ec7 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -61,5 +61,6 @@ typedef struct EventNotifier EventNotifier;
 typedef struct VirtIODevice VirtIODevice;
 typedef struct QEMUSGList QEMUSGList;
 typedef struct SHPCDevice SHPCDevice;
+typedef struct FWCfgState FWCfgState;
 
 #endif /* QEMU_TYPEDEFS_H */
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PULL 7/9] fw_cfg: add API to find FW cfg object
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
                   ` (5 preceding siblings ...)
  2013-06-04  8:07 ` [Qemu-devel] [PULL 6/9] fw_cfg: move typedef to qemu/typedefs.h Michael S. Tsirkin
@ 2013-06-04  8:08 ` Michael S. Tsirkin
  2013-06-04  8:08 ` [Qemu-devel] [PULL 8/9] fw_cfg: fw_cfg is a singleton Michael S. Tsirkin
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:08 UTC (permalink / raw)
  To: qemu-devel

Remove some code duplication by adding a
function to look up the fw cfg file.
This way, we don't need to duplicate same strings everywhere.
Use by both fw cfg and pvpanic device.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/misc/pvpanic.c         |  2 +-
 hw/nvram/fw_cfg.c         | 15 ++++++++++++---
 include/hw/nvram/fw_cfg.h |  2 ++
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 31e1b1d..159340f 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -96,7 +96,7 @@ static int pvpanic_isa_initfn(ISADevice *dev)
     isa_register_ioport(dev, &s->io, s->ioport);
 
     if (!port_configured) {
-        fw_cfg = object_resolve_path("/machine/fw_cfg", NULL);
+        fw_cfg = fw_cfg_find();
         if (fw_cfg) {
             fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
                             g_memdup(&s->ioport, sizeof(s->ioport)),
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 479113b..df3f089 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -32,6 +32,9 @@
 
 #define FW_CFG_SIZE 2
 #define FW_CFG_DATA_SIZE 1
+#define TYPE_FW_CFG "fw_cfg"
+#define FW_CFG_NAME "fw_cfg"
+#define FW_CFG_PATH "/machine/" FW_CFG_NAME
 
 typedef struct FWCfgEntry {
     uint32_t len;
@@ -493,8 +496,8 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
 
     s = DO_UPCAST(FWCfgState, busdev.qdev, dev);
 
-    if (!object_resolve_path("/machine/fw_cfg", NULL)) {
-        object_property_add_child(qdev_get_machine(), "fw_cfg", OBJECT(s),
+    if (!object_resolve_path(FW_CFG_PATH, NULL)) {
+        object_property_add_child(qdev_get_machine(), FW_CFG_NAME, OBJECT(s),
                                   NULL);
     }
 
@@ -553,6 +556,12 @@ static Property fw_cfg_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+FWCfgState *fw_cfg_find(void)
+{
+    return OBJECT_CHECK(FWCfgState, object_resolve_path(FW_CFG_PATH, NULL),
+                        TYPE_FW_CFG);
+}
+
 static void fw_cfg_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -566,7 +575,7 @@ static void fw_cfg_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo fw_cfg_info = {
-    .name          = "fw_cfg",
+    .name          = TYPE_FW_CFG,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(FWCfgState),
     .class_init    = fw_cfg_class_init,
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index f37714e..f60dd67 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -73,6 +73,8 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data,
 FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
                         hwaddr crl_addr, hwaddr data_addr);
 
+FWCfgState *fw_cfg_find(void);
+
 #endif /* NO_QEMU_PROTOS */
 
 #endif
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PULL 8/9] fw_cfg: fw_cfg is a singleton
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
                   ` (6 preceding siblings ...)
  2013-06-04  8:08 ` [Qemu-devel] [PULL 7/9] fw_cfg: add API to find FW cfg object Michael S. Tsirkin
@ 2013-06-04  8:08 ` Michael S. Tsirkin
  2013-06-04  8:08 ` [Qemu-devel] [PULL 9/9] pvpanic: use FWCfgState explicitly Michael S. Tsirkin
  2013-06-17 21:17 ` [Qemu-devel] [PULL 0/9] pci: misc cleanups Anthony Liguori
  9 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:08 UTC (permalink / raw)
  To: qemu-devel

Make sure we only have a single instance ever:
because if it isn't we can't find it so it's
useless anyway.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/nvram/fw_cfg.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index df3f089..3c255ce 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -496,10 +496,9 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
 
     s = DO_UPCAST(FWCfgState, busdev.qdev, dev);
 
-    if (!object_resolve_path(FW_CFG_PATH, NULL)) {
-        object_property_add_child(qdev_get_machine(), FW_CFG_NAME, OBJECT(s),
-                                  NULL);
-    }
+    assert(!object_resolve_path(FW_CFG_PATH, NULL));
+
+    object_property_add_child(qdev_get_machine(), FW_CFG_NAME, OBJECT(s), NULL);
 
     qdev_init_nofail(dev);
 
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Qemu-devel] [PULL 9/9] pvpanic: use FWCfgState explicitly
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
                   ` (7 preceding siblings ...)
  2013-06-04  8:08 ` [Qemu-devel] [PULL 8/9] fw_cfg: fw_cfg is a singleton Michael S. Tsirkin
@ 2013-06-04  8:08 ` Michael S. Tsirkin
  2013-06-17 21:17 ` [Qemu-devel] [PULL 0/9] pci: misc cleanups Anthony Liguori
  9 siblings, 0 replies; 11+ messages in thread
From: Michael S. Tsirkin @ 2013-06-04  8:08 UTC (permalink / raw)
  To: qemu-devel

Use the type-safe FWCfgState structure instead
of the unsafe void *.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/misc/pvpanic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 159340f..910e44f 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -90,7 +90,7 @@ static int pvpanic_isa_initfn(ISADevice *dev)
 {
     PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
     static bool port_configured;
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
 
     memory_region_init_io(&s->io, &pvpanic_ops, s, "pvpanic", 1);
     isa_register_ioport(dev, &s->io, s->ioport);
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PULL 0/9] pci: misc cleanups
  2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
                   ` (8 preceding siblings ...)
  2013-06-04  8:08 ` [Qemu-devel] [PULL 9/9] pvpanic: use FWCfgState explicitly Michael S. Tsirkin
@ 2013-06-17 21:17 ` Anthony Liguori
  9 siblings, 0 replies; 11+ messages in thread
From: Anthony Liguori @ 2013-06-17 21:17 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel, Anthony Liguori; +Cc: akong, lersek, afaerber

Pulled.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-06-17 21:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-04  8:07 [Qemu-devel] [PULL 0/9] pci: misc cleanups Michael S. Tsirkin
2013-06-04  8:07 ` [Qemu-devel] [PULL 1/9] q35: set fw_name Michael S. Tsirkin
2013-06-04  8:07 ` [Qemu-devel] [PULL 2/9] dec.c - move to pci-bridge Michael S. Tsirkin
2013-06-04  8:07 ` [Qemu-devel] [PULL 3/9] firmware_abi: move to include/hw/nvram/ Michael S. Tsirkin
2013-06-04  8:07 ` [Qemu-devel] [PULL 4/9] apic: rename apic specific bitopts Michael S. Tsirkin
2013-06-04  8:07 ` [Qemu-devel] [PULL 5/9] refer to FWCfgState explicitly Michael S. Tsirkin
2013-06-04  8:07 ` [Qemu-devel] [PULL 6/9] fw_cfg: move typedef to qemu/typedefs.h Michael S. Tsirkin
2013-06-04  8:08 ` [Qemu-devel] [PULL 7/9] fw_cfg: add API to find FW cfg object Michael S. Tsirkin
2013-06-04  8:08 ` [Qemu-devel] [PULL 8/9] fw_cfg: fw_cfg is a singleton Michael S. Tsirkin
2013-06-04  8:08 ` [Qemu-devel] [PULL 9/9] pvpanic: use FWCfgState explicitly Michael S. Tsirkin
2013-06-17 21:17 ` [Qemu-devel] [PULL 0/9] pci: misc cleanups Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).