seabios: update binaries to release 1.9.0
[qemu/ar7.git] / hw / acpi / cpu_hotplug.c
blobf5b9972f2dce1d8e7b6560a2fd683cc1e947b27d
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 "hw/hw.h"
13 #include "hw/acpi/cpu_hotplug.h"
15 static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size)
17 AcpiCpuHotplug *cpus = opaque;
18 uint64_t val = cpus->sts[addr];
20 return val;
23 static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data,
24 unsigned int size)
26 /* TODO: implement VCPU removal on guest signal that CPU can be removed */
29 static const MemoryRegionOps AcpiCpuHotplug_ops = {
30 .read = cpu_status_read,
31 .write = cpu_status_write,
32 .endianness = DEVICE_LITTLE_ENDIAN,
33 .valid = {
34 .min_access_size = 1,
35 .max_access_size = 1,
39 static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu,
40 Error **errp)
42 CPUClass *k = CPU_GET_CLASS(cpu);
43 int64_t cpu_id;
45 cpu_id = k->get_arch_id(cpu);
46 if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) {
47 error_setg(errp, "acpi: invalid cpu id: %" PRIi64, cpu_id);
48 return;
51 g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
54 void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq,
55 AcpiCpuHotplug *g, DeviceState *dev, Error **errp)
57 acpi_set_cpu_present_bit(g, CPU(dev), errp);
58 if (*errp != NULL) {
59 return;
62 acpi_send_gpe_event(ar, irq, ACPI_CPU_HOTPLUG_STATUS);
65 void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
66 AcpiCpuHotplug *gpe_cpu, uint16_t base)
68 CPUState *cpu;
70 CPU_FOREACH(cpu) {
71 acpi_set_cpu_present_bit(gpe_cpu, cpu, &error_abort);
73 memory_region_init_io(&gpe_cpu->io, owner, &AcpiCpuHotplug_ops,
74 gpe_cpu, "acpi-cpu-hotplug", ACPI_GPE_PROC_LEN);
75 memory_region_add_subregion(parent, base, &gpe_cpu->io);