iotests: Make _filter_nbd drop log lines
[qemu/ar7.git] / hw / acpi / cpu_hotplug.c
blob2f99ec5455e5d415cfd0027d248c08e90bed7ab0
1 /*
2 * QEMU ACPI hotplug utilities
4 * Copyright (C) 2013 Red Hat Inc
6 * Authors:
7 * Igor Mammedov <imammedo@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
12 #include "qemu/osdep.h"
13 #include "hw/hw.h"
14 #include "hw/acpi/cpu_hotplug.h"
16 static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size)
18 AcpiCpuHotplug *cpus = opaque;
19 uint64_t val = cpus->sts[addr];
21 return val;
24 static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data,
25 unsigned int size)
27 /* TODO: implement VCPU removal on guest signal that CPU can be removed */
30 static const MemoryRegionOps AcpiCpuHotplug_ops = {
31 .read = cpu_status_read,
32 .write = cpu_status_write,
33 .endianness = DEVICE_LITTLE_ENDIAN,
34 .valid = {
35 .min_access_size = 1,
36 .max_access_size = 1,
40 static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu,
41 Error **errp)
43 CPUClass *k = CPU_GET_CLASS(cpu);
44 int64_t cpu_id;
46 cpu_id = k->get_arch_id(cpu);
47 if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) {
48 error_setg(errp, "acpi: invalid cpu id: %" PRIi64, cpu_id);
49 return;
52 g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
55 void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq,
56 AcpiCpuHotplug *g, DeviceState *dev, Error **errp)
58 acpi_set_cpu_present_bit(g, CPU(dev), errp);
59 if (*errp != NULL) {
60 return;
63 acpi_send_gpe_event(ar, irq, ACPI_CPU_HOTPLUG_STATUS);
66 void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
67 AcpiCpuHotplug *gpe_cpu, uint16_t base)
69 CPUState *cpu;
71 CPU_FOREACH(cpu) {
72 acpi_set_cpu_present_bit(gpe_cpu, cpu, &error_abort);
74 memory_region_init_io(&gpe_cpu->io, owner, &AcpiCpuHotplug_ops,
75 gpe_cpu, "acpi-cpu-hotplug", ACPI_GPE_PROC_LEN);
76 memory_region_add_subregion(parent, base, &gpe_cpu->io);