[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [patch 05/24] QEMU/KVM: pci hotplug GPE support
From: |
Marcelo Tosatti |
Subject: |
[Qemu-devel] [patch 05/24] QEMU/KVM: pci hotplug GPE support |
Date: |
Tue, 11 Mar 2008 17:11:56 -0300 |
User-agent: |
quilt/0.46-1 |
Enable the corresponding bit on the PCIST region and trigger the SCI.
Signed-off-by: Marcelo Tosatti <address@hidden>
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);
+}
--
- [Qemu-devel] [patch 00/24] QEMU ACPI PCI hotplug support, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 01/24] QEMU/KVM: add devices to represent PCI slots with _EJ0 method, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 02/24] QEMU/KVM: add OperationRegion and GPE handler for add/removal notification, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 05/24] QEMU/KVM: pci hotplug GPE support,
Marcelo Tosatti <=
- [Qemu-devel] [patch 03/24] QEMU/KVM: add pci_find_bus, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 07/24] QEMU/KVM: dynamic nic info index allocation, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 06/24] QEMU/KVM: dynamic drive/drive_opt index allocation, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 04/24] QEMU/KVM: return PCIDevice on net device init and record devfn, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 09/24] QEMU/KVM: record devfn on block driver instance, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 13/24] QEMU/KVM: export get_param_value/check_params, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 10/24] QEMU/KVM: move drives_opt for external use, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 12/24] QEMU/KVM: add net_client_uninit, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 14/24] QEMU/KVM: add pci_find_device, Marcelo Tosatti, 2008/03/12
- [Qemu-devel] [patch 15/24] QEMU/KVM: virtio_blk_init return PCIDevice pointer, Marcelo Tosatti, 2008/03/12