xref: /qemu/include/hw/acpi/cpu.h (revision 9a4fedcf12ae388722fa5430df92d0f41e3ba9be)
15e1b5d93SIgor Mammedov /*
25e1b5d93SIgor Mammedov  * QEMU ACPI hotplug utilities
35e1b5d93SIgor Mammedov  *
45e1b5d93SIgor Mammedov  * Copyright (C) 2016 Red Hat Inc
55e1b5d93SIgor Mammedov  *
65e1b5d93SIgor Mammedov  * Authors:
75e1b5d93SIgor Mammedov  *   Igor Mammedov <imammedo@redhat.com>
85e1b5d93SIgor Mammedov  *
95e1b5d93SIgor Mammedov  * This work is licensed under the terms of the GNU GPL, version 2 or later.
105e1b5d93SIgor Mammedov  * See the COPYING file in the top-level directory.
115e1b5d93SIgor Mammedov  */
125e1b5d93SIgor Mammedov #ifndef ACPI_CPU_H
135e1b5d93SIgor Mammedov #define ACPI_CPU_H
145e1b5d93SIgor Mammedov 
155e1b5d93SIgor Mammedov #include "hw/qdev-core.h"
165e1b5d93SIgor Mammedov #include "hw/acpi/acpi.h"
175e1b5d93SIgor Mammedov #include "hw/acpi/aml-build.h"
18*9a4fedcfSBernhard Beschow #include "hw/boards.h"
195e1b5d93SIgor Mammedov #include "hw/hotplug.h"
205e1b5d93SIgor Mammedov 
215e1b5d93SIgor Mammedov typedef struct AcpiCpuStatus {
225e1b5d93SIgor Mammedov     struct CPUState *cpu;
235e1b5d93SIgor Mammedov     uint64_t arch_id;
24d2238cb6SIgor Mammedov     bool is_inserting;
258872c25aSIgor Mammedov     bool is_removing;
261e6107d9SIgor Mammedov     bool fw_remove;
2776623d00SIgor Mammedov     uint32_t ost_event;
2876623d00SIgor Mammedov     uint32_t ost_status;
295e1b5d93SIgor Mammedov } AcpiCpuStatus;
305e1b5d93SIgor Mammedov 
315e1b5d93SIgor Mammedov typedef struct CPUHotplugState {
325e1b5d93SIgor Mammedov     MemoryRegion ctrl_reg;
335e1b5d93SIgor Mammedov     uint32_t selector;
34d2238cb6SIgor Mammedov     uint8_t command;
355e1b5d93SIgor Mammedov     uint32_t dev_count;
365e1b5d93SIgor Mammedov     AcpiCpuStatus *devs;
375e1b5d93SIgor Mammedov } CPUHotplugState;
385e1b5d93SIgor Mammedov 
395e1b5d93SIgor Mammedov void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
405e1b5d93SIgor Mammedov                       CPUHotplugState *cpu_st, DeviceState *dev, Error **errp);
415e1b5d93SIgor Mammedov 
428872c25aSIgor Mammedov void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
438872c25aSIgor Mammedov                                 CPUHotplugState *cpu_st,
448872c25aSIgor Mammedov                                 DeviceState *dev, Error **errp);
458872c25aSIgor Mammedov 
468872c25aSIgor Mammedov void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
478872c25aSIgor Mammedov                         DeviceState *dev, Error **errp);
488872c25aSIgor Mammedov 
495e1b5d93SIgor Mammedov void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
505e1b5d93SIgor Mammedov                          CPUHotplugState *state, hwaddr base_addr);
515e1b5d93SIgor Mammedov 
525e1b5d93SIgor Mammedov typedef struct CPUHotplugFeatures {
5389cb0c04SDr. David Alan Gilbert     bool acpi_1_compatible;
54679dd1a9SIgor Mammedov     bool has_legacy_cphp;
5569dea9d6SIgor Mammedov     bool fw_unplugs_cpu;
56998ba950SIgor Mammedov     const char *smi_path;
575e1b5d93SIgor Mammedov } CPUHotplugFeatures;
585e1b5d93SIgor Mammedov 
59*9a4fedcfSBernhard Beschow typedef void (*build_madt_cpu_fn)(int uid, const CPUArchIdList *apic_ids,
60*9a4fedcfSBernhard Beschow                                   GArray *entry, bool force_enabled);
61*9a4fedcfSBernhard Beschow 
625e1b5d93SIgor Mammedov void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
63*9a4fedcfSBernhard Beschow                     build_madt_cpu_fn build_madt_cpu, hwaddr io_base,
64d2238cb6SIgor Mammedov                     const char *res_root,
65d2238cb6SIgor Mammedov                     const char *event_handler_method);
665e1b5d93SIgor Mammedov 
6776623d00SIgor Mammedov void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list);
6876623d00SIgor Mammedov 
695e1b5d93SIgor Mammedov extern const VMStateDescription vmstate_cpu_hotplug;
705e1b5d93SIgor Mammedov #define VMSTATE_CPU_HOTPLUG(cpuhp, state) \
715e1b5d93SIgor Mammedov     VMSTATE_STRUCT(cpuhp, state, 1, \
725e1b5d93SIgor Mammedov                    vmstate_cpu_hotplug, CPUHotplugState)
735e1b5d93SIgor Mammedov 
745e1b5d93SIgor Mammedov #endif
75