Skip to contentSkip to conversation

qemu: target library, use it in msix

PATCH New Michael S. Tsirkin 1 participant 1 message Sep 29, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 qemu: target library, use it in msix

This creates target.c, which builds per-target, and makes it possible for devices to become target-independent. Use it in msix, reverting part of 5e520a7d500ec2569d22d80f9ef4272a34cb3c80, as we no longer have to pass target page around.

---
 Makefile.target |    3 +++
 hw/msix.c       |   52 +++++++++++++++++++++++++++-------------------------
 hw/msix.h       |    5 ++---
 hw/pci.h        |    6 ------
 hw/virtio-pci.c |    3 +--
 target.c        |   21 +++++++++++++++++++++
 target.h        |    6 ++++++
 7 files changed, 60 insertions(+), 36 deletions(-)
 create mode 100644 target.c
 create mode 100644 target.h
Makefile.target +3 -0
index 0ebef17..c0f143a 100644
@@ -55,6 +55,9 @@ libobj-$(CONFIG_S390_DIS) += s390-dis.o
 libobj-$(CONFIG_SH4_DIS) += sh4-dis.o
 libobj-$(CONFIG_SPARC_DIS) += sparc-dis.o
 
+# Target library: makes devices target-independent
+libobj-y += target.o
+
 # libqemu
 
 libqemu.a: $(libobj-y)
hw/msix.c +27 -25

137 lines not on this page · raw message

hw/msix.h +2 -3
index 9367ba3..3427778 100644
@@ -3,9 +3,8 @@
 
 #include "qemu-common.h"
 
-int msix_init(struct PCIDevice *dev, unsigned short nentries,
-              unsigned bar_nr, unsigned bar_size,
-              target_phys_addr_t page_size);
+int msix_init(PCIDevice *pdev, unsigned short nentries,
+              unsigned bar_nr, unsigned bar_size);
 
 void msix_write_config(PCIDevice *pci_dev, uint32_t address,
                        uint32_t val, int len);
hw/pci.h +0 -6
index dddd599..8cfc38d 100644
@@ -214,12 +214,6 @@ struct PCIDevice {
     uint32_t msix_bar_size;
     /* Version id needed for VMState */
     int32_t version_id;
-    /* How much space does an MSIX table need. */
-    /* The spec requires giving the table structure
-     * a 4K aligned region all by itself. Align it to
-     * target pages so that drivers can do passthrough
-     * on the rest of the region. */
-    target_phys_addr_t msix_page_size;
 };
 
 PCIDevice *pci_register_device(PCIBus *bus, const char *name,
hw/virtio-pci.c +1 -2
index 1f14c5e..3a0231e 100644
@@ -410,8 +410,7 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
 
     config[0x3d] = 1;
 
-    if (vdev->nvectors && !msix_init(&proxy->pci_dev, vdev->nvectors, 1, 0,
-                                     TARGET_PAGE_SIZE)) {
+    if (vdev->nvectors && !msix_init(&proxy->pci_dev, vdev->nvectors, 1, 0)) {
         pci_register_bar(&proxy->pci_dev, 1,
                          msix_bar_size(&proxy->pci_dev),
                          PCI_ADDRESS_SPACE_MEM,
target.c new file +21 -0
new file mode 100644
index 0000000..67e9bc7
@@ -0,0 +1,21 @@
+/* 
+ * Target definitions for use by devices.
+ *
+ * Author: Michael S. Tsirkin <[email protected]>
+ *
+ * Copyright (c) 2009, Red Hat Inc, Michael S. Tsirkin ([email protected])
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+#include "qemu-common.h"
+#include "target.h"
+
+/* Align a 32 bit value to target page size.
+ * If you ever need to align a value of another type,
+ * add another function here.
+ */
+unsigned target_page_align32(unsigned value)
+{
+	return TARGET_PAGE_ALIGN(value);
+}
target.h new file +6 -0
new file mode 100644
index 0000000..bfbbab5
@@ -0,0 +1,6 @@
+#ifndef QEMU_TARGET_H
+#define QEMU_TARGET_H
+
+unsigned target_page_align32(unsigned value);
+
+#endif
Signature · 1 line
1.6.5.rc2