All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel@nongnu.org, kvm-devel@lists.sourceforge.net
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 05/24] QEMU/KVM: pci hotplug GPE support
Date: Tue, 11 Mar 2008 17:11:56 -0300	[thread overview]
Message-ID: <20080311201417.592220218@localhost.localdomain> (raw)
In-Reply-To: 20080311201151.959635433@localhost.localdomain

[-- Attachment #1: acpi --]
[-- Type: text/plain, Size: 3107 bytes --]

Enable the corresponding bit on the PCIST region and trigger the SCI.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: kvm-userspace.hotplug2/qemu/hw/acpi.c
===================================================================
--- kvm-userspace.hotplug2.orig/qemu/hw/acpi.c
+++ kvm-userspace.hotplug2/qemu/hw/acpi.c
@@ -538,6 +538,7 @@ void qemu_system_powerdown(void)
 #endif
 #define GPE_BASE 0xafe0
 #define PROC_BASE 0xaf00
+#define PCI_BASE 0xae00
 
 struct gpe_regs {
     uint16_t sts; /* status */
@@ -546,7 +547,13 @@ struct gpe_regs {
     uint8_t down;
 };
 
+struct pci_status {
+    uint32_t up;
+    uint32_t down;
+};
+
 static struct gpe_regs gpe;
+static struct pci_status pci0_status;
 
 static uint32_t gpe_readb(void *opaque, uint32_t addr)
 {
@@ -614,6 +621,45 @@ static void gpe_writeb(void *opaque, uin
 #endif
 }
 
+static uint32_t pcihotplug_read(void *opaque, uint32_t addr)
+{
+    uint32_t val = 0;
+    struct pci_status *g = opaque;
+    switch (addr) {
+        case PCI_BASE:
+            val = g->up;
+            break;
+        case PCI_BASE + 4:
+            val = g->down;
+            break;
+        default:
+            break;
+    }
+
+#if defined(DEBUG)
+    printf("pcihotplug read %lx == %lx\n", addr, val);
+#endif
+    return val;
+}
+
+static void pcihotplug_write(void *opaque, uint32_t addr, uint32_t val)
+{
+    struct pci_status *g = opaque;
+    switch (addr) {
+        case PCI_BASE:
+            g->up = val;
+            break;
+        case PCI_BASE + 4:
+            g->down = val;
+            break;
+   }
+
+#if defined(DEBUG)
+    printf("pcihotplug write %lx <== %d\n", addr, val);
+#endif
+}
+
+
 static char *model;
 
 void qemu_system_hot_add_init(char *cpu_model)
@@ -624,6 +670,9 @@ void qemu_system_hot_add_init(char *cpu_
     register_ioport_write(PROC_BASE, 4, 1, gpe_writeb, &gpe);
     register_ioport_read(PROC_BASE, 4, 1,  gpe_readb, &gpe);
 
+    register_ioport_write(PCI_BASE, 8, 4, pcihotplug_write, &pci0_status);
+    register_ioport_read(PCI_BASE, 8, 4,  pcihotplug_read, &pci0_status);
+
     model = cpu_model;
 }
 
@@ -665,3 +714,29 @@ void qemu_system_cpu_hot_add(int cpu, in
         disable_processor(&gpe, cpu);
     qemu_set_irq(pm_state->irq, 0);
 }
+
+static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot)
+{
+    g->sts |= 2;
+    g->en |= 2;
+    p->up |= (1 << slot);
+}
+
+static void disable_device(struct pci_status *p, struct gpe_regs *g, int slot)
+{
+    g->sts |= 2;
+    g->en |= 2;
+    p->down |= (1 << slot);
+}
+
+void qemu_system_device_hot_add(int slot, int state)
+{
+    qemu_set_irq(pm_state->irq, 1);
+    pci0_status.up = 0;
+    pci0_status.down = 0;
+    if (state)
+        enable_device(&pci0_status, &gpe, slot);
+    else
+        disable_device(&pci0_status, &gpe, slot);
+    qemu_set_irq(pm_state->irq, 0);
+}

-- 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel@nongnu.org, kvm-devel@lists.sourceforge.net
Cc: aliguori@us.ibm.com, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [Qemu-devel] [patch 05/24] QEMU/KVM: pci hotplug GPE support
Date: Tue, 11 Mar 2008 17:11:56 -0300	[thread overview]
Message-ID: <20080311201417.592220218@localhost.localdomain> (raw)
In-Reply-To: 20080311201151.959635433@localhost.localdomain

[-- Attachment #1: acpi --]
[-- Type: text/plain, Size: 2876 bytes --]

Enable the corresponding bit on the PCIST region and trigger the SCI.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: kvm-userspace.hotplug2/qemu/hw/acpi.c
===================================================================
--- kvm-userspace.hotplug2.orig/qemu/hw/acpi.c
+++ kvm-userspace.hotplug2/qemu/hw/acpi.c
@@ -538,6 +538,7 @@ void qemu_system_powerdown(void)
 #endif
 #define GPE_BASE 0xafe0
 #define PROC_BASE 0xaf00
+#define PCI_BASE 0xae00
 
 struct gpe_regs {
     uint16_t sts; /* status */
@@ -546,7 +547,13 @@ struct gpe_regs {
     uint8_t down;
 };
 
+struct pci_status {
+    uint32_t up;
+    uint32_t down;
+};
+
 static struct gpe_regs gpe;
+static struct pci_status pci0_status;
 
 static uint32_t gpe_readb(void *opaque, uint32_t addr)
 {
@@ -614,6 +621,45 @@ static void gpe_writeb(void *opaque, uin
 #endif
 }
 
+static uint32_t pcihotplug_read(void *opaque, uint32_t addr)
+{
+    uint32_t val = 0;
+    struct pci_status *g = opaque;
+    switch (addr) {
+        case PCI_BASE:
+            val = g->up;
+            break;
+        case PCI_BASE + 4:
+            val = g->down;
+            break;
+        default:
+            break;
+    }
+
+#if defined(DEBUG)
+    printf("pcihotplug read %lx == %lx\n", addr, val);
+#endif
+    return val;
+}
+
+static void pcihotplug_write(void *opaque, uint32_t addr, uint32_t val)
+{
+    struct pci_status *g = opaque;
+    switch (addr) {
+        case PCI_BASE:
+            g->up = val;
+            break;
+        case PCI_BASE + 4:
+            g->down = val;
+            break;
+   }
+
+#if defined(DEBUG)
+    printf("pcihotplug write %lx <== %d\n", addr, val);
+#endif
+}
+
+
 static char *model;
 
 void qemu_system_hot_add_init(char *cpu_model)
@@ -624,6 +670,9 @@ void qemu_system_hot_add_init(char *cpu_
     register_ioport_write(PROC_BASE, 4, 1, gpe_writeb, &gpe);
     register_ioport_read(PROC_BASE, 4, 1,  gpe_readb, &gpe);
 
+    register_ioport_write(PCI_BASE, 8, 4, pcihotplug_write, &pci0_status);
+    register_ioport_read(PCI_BASE, 8, 4,  pcihotplug_read, &pci0_status);
+
     model = cpu_model;
 }
 
@@ -665,3 +714,29 @@ void qemu_system_cpu_hot_add(int cpu, in
         disable_processor(&gpe, cpu);
     qemu_set_irq(pm_state->irq, 0);
 }
+
+static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot)
+{
+    g->sts |= 2;
+    g->en |= 2;
+    p->up |= (1 << slot);
+}
+
+static void disable_device(struct pci_status *p, struct gpe_regs *g, int slot)
+{
+    g->sts |= 2;
+    g->en |= 2;
+    p->down |= (1 << slot);
+}
+
+void qemu_system_device_hot_add(int slot, int state)
+{
+    qemu_set_irq(pm_state->irq, 1);
+    pci0_status.up = 0;
+    pci0_status.down = 0;
+    if (state)
+        enable_device(&pci0_status, &gpe, slot);
+    else
+        disable_device(&pci0_status, &gpe, slot);
+    qemu_set_irq(pm_state->irq, 0);
+}

-- 

  parent reply	other threads:[~2008-03-11 20:11 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-11 20:11 [patch 00/24] QEMU ACPI PCI hotplug support Marcelo Tosatti
2008-03-11 20:11 ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 01/24] QEMU/KVM: add devices to represent PCI slots with _EJ0 method Marcelo Tosatti
2008-03-11 20:11   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 02/24] QEMU/KVM: add OperationRegion and GPE handler for add/removal notification Marcelo Tosatti
2008-03-11 20:11   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 03/24] QEMU/KVM: add pci_find_bus Marcelo Tosatti
2008-03-11 20:11   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 04/24] QEMU/KVM: return PCIDevice on net device init and record devfn Marcelo Tosatti
2008-03-11 20:11   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` Marcelo Tosatti [this message]
2008-03-11 20:11   ` [Qemu-devel] [patch 05/24] QEMU/KVM: pci hotplug GPE support Marcelo Tosatti
2008-03-11 20:11 ` [patch 06/24] QEMU/KVM: dynamic drive/drive_opt index allocation Marcelo Tosatti
2008-03-11 20:11   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 07/24] QEMU/KVM: dynamic nic info " Marcelo Tosatti
2008-03-11 20:11   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:11 ` [patch 08/24] QEMU/KVM: drive removal support Marcelo Tosatti
2008-03-11 20:11   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 09/24] QEMU/KVM: record devfn on block driver instance Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 10/24] QEMU/KVM: move drives_opt for external use Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 11/24] QEMU/KVM: net/drive add/remove tweaks Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 12/24] QEMU/KVM: add net_client_uninit Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 13/24] QEMU/KVM: export get_param_value/check_params Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 14/24] QEMU/KVM: add pci_find_device Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 15/24] QEMU/KVM: virtio_blk_init return PCIDevice pointer Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 16/24] QEMU/KVM: device and disk hot-add Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 17/24] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-18 12:32   ` Amit Shah
2008-03-18 12:32     ` [Qemu-devel] Re: [kvm-devel] " Amit Shah
2008-03-18 13:54     ` Marcelo Tosatti
2008-03-18 13:54       ` [Qemu-devel] Re: [kvm-devel] " Marcelo Tosatti
2008-03-18 14:13       ` Amit Shah
2008-03-18 14:13         ` [Qemu-devel] RE: [kvm-devel] " Amit Shah
2008-03-18 15:22         ` Avi Kivity
2008-03-18 15:22           ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity
2008-03-11 20:12 ` [patch 18/24] QEMU/KVM: notify _EJ0 through _SEJ OperationRegion Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 19/24] QEMU/KVM: handle SEJ notifications Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 20/24] QEMU/KVM: add qemu_free_irqs Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 21/24] QEMU/KVM: add pci_unregister_device Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 22/24] QEMU/KVM: LSI SCSI and e1000 unregister callbacks Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 23/24] QEMU/KVM: zero ioport_opaque on isa_unassign_ioport Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-11 20:12 ` [patch 24/24] QEMU/KVM: device hot-remove Marcelo Tosatti
2008-03-11 20:12   ` [Qemu-devel] " Marcelo Tosatti
2008-03-16 12:30 ` [patch 00/24] QEMU ACPI PCI hotplug support Avi Kivity
2008-03-16 12:30   ` [Qemu-devel] Re: [kvm-devel] " Avi Kivity

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=20080311201417.592220218@localhost.localdomain \
    --to=mtosatti@redhat.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=qemu-devel@nongnu.org \
    /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.