From: stefano.stabellini@eu.citrix.com
To: qemu-devel@nongnu.org
Cc: Anthony.Perard@citrix.com,
Anthony PERARD <anthony.perard@citrix.com>,
xen-devel@lists.xensource.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [Qemu-devel] [PATCH 12/15] piix_pci: introduce a write_config notifier
Date: Thu, 12 Aug 2010 15:09:59 +0100 [thread overview]
Message-ID: <1281622202-3453-12-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1008121244200.2545@kaball-desktop>
From: Anthony PERARD <anthony.perard@citrix.com>
Introduce a write config notifier in piix_pci, so that clients can be
notified every time a pci config write happens.
The patch also makes use of the notification mechanism in
xen_machine_fv.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
hw/pc.h | 1 +
hw/piix_pci.c | 28 ++++++++++++++++++++++++++++
hw/xen_machine_fv.c | 16 ++++++++++++++++
3 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/hw/pc.h b/hw/pc.h
index ee562cd..3a745ae 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -141,6 +141,7 @@ typedef struct PCII440FXState PCII440FXState;
void piix3_register_set_irq(pci_set_irq_fn set_irq);
void piix3_register_map_irq(pci_map_irq_fn map_irq);
+void piix_pci_register_write_config_notifier(PCII440FXState *d, PCIConfigWriteFunc *write_config);
PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq *pic, ram_addr_t ram_size);
void i440fx_init_memory_mappings(PCII440FXState *d);
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 56e3f61..afa9e9d 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -49,6 +49,13 @@ struct PCII440FXState {
PIIX3State *piix3;
};
+typedef struct PCII440FXWriteConfigNotifier {
+ PCIConfigWriteFunc *write_config;
+ QLIST_ENTRY(PCII440FXWriteConfigNotifier) next;
+} PCII440FXWriteConfigNotifier;
+
+static QLIST_HEAD(write_config_list, PCII440FXWriteConfigNotifier) write_config_list
+ = QLIST_HEAD_INITIALIZER(write_config_list);
#define I440FX_PAM 0x59
#define I440FX_PAM_SIZE 7
@@ -71,6 +78,25 @@ void piix3_register_map_irq(pci_map_irq_fn map_irq)
piix3_map_irq_handler = map_irq;
}
+void piix_pci_register_write_config_notifier(PCII440FXState *d, PCIConfigWriteFunc *write_config)
+{
+ PCII440FXWriteConfigNotifier *new_notifier;
+
+ assert(write_config);
+ new_notifier = qemu_mallocz(sizeof(PCII440FXWriteConfigNotifier));
+ new_notifier->write_config = write_config;
+ QLIST_INSERT_HEAD(&write_config_list, new_notifier, next);
+}
+
+static void piix_pci_notify_write_config(PCIDevice *dev, uint32_t address, uint32_t val, int len)
+{
+ PCII440FXWriteConfigNotifier *notifier;
+
+ QLIST_FOREACH(notifier, &write_config_list, next) {
+ notifier->write_config(dev, address, val, len);
+ }
+}
+
/* return the global irq number corresponding to a given device irq
pin. We could also use the bus number to have a more precise
mapping. */
@@ -157,6 +183,8 @@ static void i440fx_write_config(PCIDevice *dev,
{
PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev);
+ piix_pci_notify_write_config(dev, address, val, len);
+
/* XXX: implement SMRAM.D_LOCK */
pci_default_write_config(dev, address, val, len);
if (ranges_overlap(address, len, I440FX_PAM, I440FX_PAM_SIZE) ||
diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
index 5d553b6..77563db 100644
--- a/hw/xen_machine_fv.c
+++ b/hw/xen_machine_fv.c
@@ -61,6 +61,21 @@ static void xen_piix3_set_irq(void *opaque, int irq_num, int level)
irq_num & 3, level);
}
+static void xen_piix_pci_write_config_client(PCIDevice *dev,
+ uint32_t address, uint32_t val, int len)
+{
+ int i;
+
+ /* Scan for updates to PCI link routes (0x60-0x63). */
+ for (i = 0; i < len; i++) {
+ uint8_t v = (val >> (8*i)) & 0xff;
+ if (v & 0x80)
+ v = 0;
+ v &= 0xf;
+ if (((address+i) >= 0x60) && ((address+i) <= 0x63))
+ xc_hvm_set_pci_link_route(xen_xc, xen_domid, address + i - 0x60, v);
+ }
+}
static void xen_init_fv(ram_addr_t ram_size,
const char *boot_device,
@@ -141,6 +156,7 @@ static void xen_init_fv(ram_addr_t ram_size,
piix3_register_set_irq(xen_piix3_set_irq);
piix3_register_map_irq(xen_piix3_map_irq);
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq, ram_size);
+ piix_pci_register_write_config_notifier(i440fx_state, xen_piix_pci_write_config_client);
isa_bus_irqs(isa_irq);
pc_register_ferr_irq(isa_reserve_irq(13));
--
1.7.0.4
next prev parent reply other threads:[~2010-08-12 14:12 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-12 14:08 [Qemu-devel] [PATCH 00/15] RFC xen device model support Stefano Stabellini
2010-08-12 14:09 ` [Qemu-devel] [PATCH 01/15] xen: Update libxc calls stefano.stabellini
2010-08-12 14:19 ` [Qemu-devel] " Paolo Bonzini
2010-08-12 14:28 ` Stefano Stabellini
2010-08-12 14:29 ` Stefano Stabellini
2010-08-18 9:50 ` Gerd Hoffmann
2010-08-18 11:47 ` Stefano Stabellini
2010-08-12 14:09 ` [Qemu-devel] [PATCH 02/15] xen: Add xen_machine_fv stefano.stabellini
2010-08-16 13:42 ` Kevin Wolf
2010-08-16 14:04 ` Stefano Stabellini
2010-08-16 14:13 ` Kevin Wolf
2010-08-16 14:38 ` Anthony Liguori
2010-08-16 14:51 ` Kevin Wolf
2010-08-16 15:00 ` Stefano Stabellini
2010-08-16 15:07 ` Anthony Liguori
2010-08-12 14:09 ` [Qemu-devel] [PATCH 03/15] xen: Add a new target to qemu: target-xen stefano.stabellini
2010-08-12 18:56 ` Blue Swirl
2010-08-13 12:47 ` [Xen-devel] " Ian Jackson
2010-08-13 17:35 ` Blue Swirl
2010-08-13 13:10 ` Stefano Stabellini
2010-08-13 17:46 ` Blue Swirl
2010-08-13 18:50 ` [Qemu-devel] " Anthony Liguori
2010-08-12 14:09 ` [Qemu-devel] [PATCH 04/15] xen: xen_machine_fv, initialize xenstore stefano.stabellini
2010-08-12 14:09 ` [Qemu-devel] [PATCH 05/15] xen: add a 8259 Interrupt Controller stefano.stabellini
2010-08-12 14:09 ` [Qemu-devel] [PATCH 06/15] xen: Add the Xen platform pci device stefano.stabellini
2010-08-12 18:26 ` Blue Swirl
2010-08-13 13:09 ` Stefano Stabellini
2010-08-12 14:09 ` [Qemu-devel] [PATCH 07/15] xen: handle xenstore events stefano.stabellini
2010-08-12 14:09 ` [Qemu-devel] [PATCH 08/15] xen: Read and write the state of the VM in xenstore stefano.stabellini
2010-08-13 18:53 ` [Qemu-devel] " Anthony Liguori
2010-08-15 14:12 ` Paolo Bonzini
2010-08-16 11:15 ` Stefano Stabellini
2010-08-16 12:13 ` Paolo Bonzini
2010-08-16 12:59 ` Stefano Stabellini
2010-08-12 14:09 ` [Qemu-devel] [PATCH 09/15] xen: Initialize event channels and io rings stefano.stabellini
2010-08-12 18:42 ` Blue Swirl
2010-08-13 13:10 ` Stefano Stabellini
2010-08-13 18:54 ` [Qemu-devel] " Anthony Liguori
2010-08-12 14:09 ` [Qemu-devel] [PATCH 10/15] xen: Introduce the Xen mapcache stefano.stabellini
2010-08-13 18:55 ` [Qemu-devel] " Anthony Liguori
2010-08-12 14:09 ` [Qemu-devel] [PATCH 11/15] piix3: introduce register_set_irq and register_map_irq stefano.stabellini
2010-08-12 18:44 ` Blue Swirl
2010-08-13 13:10 ` Stefano Stabellini
2010-08-12 14:09 ` stefano.stabellini [this message]
2010-08-12 18:35 ` [Qemu-devel] [PATCH 12/15] piix_pci: introduce a write_config notifier Blue Swirl
2010-08-13 13:10 ` Stefano Stabellini
2010-09-05 7:34 ` [Qemu-devel] " Michael S. Tsirkin
2010-08-12 14:10 ` [Qemu-devel] [PATCH 13/15] vl.c: Introduce getter for shutdown_requested and reset_requested stefano.stabellini
2010-08-12 14:10 ` [Qemu-devel] [PATCH 14/15] xen: destroy the VM when shutdown is requested stefano.stabellini
2010-08-13 18:56 ` [Qemu-devel] " Anthony Liguori
2010-08-12 14:10 ` [Qemu-devel] [PATCH 15/15] xen: Add a Xen specific ACPI Implementation to target-xen stefano.stabellini
2010-08-12 18:46 ` Blue Swirl
2010-08-13 13:10 ` Stefano Stabellini
2010-08-13 18:57 ` [Qemu-devel] " Anthony Liguori
2010-08-13 19:37 ` Stefano Stabellini
2010-08-13 20:51 ` Anthony Liguori
2010-08-16 11:10 ` Stefano Stabellini
2010-08-13 19:09 ` [Qemu-devel] Re: [PATCH 00/15] RFC xen device model support Anthony Liguori
2010-08-13 19:35 ` Stefano Stabellini
2010-08-13 20:48 ` Anthony Liguori
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=1281622202-3453-12-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=Anthony.Perard@citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=xen-devel@lists.xensource.com \
/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 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).