xref: /openbmc/qemu/include/hw/acpi/cpu.h (revision 5885bcef3d760e84d17eb4113e85f2aea0bd0582)
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 
151017e887SPhilippe Mathieu-Daudé #include "qapi/qapi-types-acpi.h"
165e1b5d93SIgor Mammedov #include "hw/qdev-core.h"
175e1b5d93SIgor Mammedov #include "hw/acpi/acpi.h"
185e1b5d93SIgor Mammedov #include "hw/acpi/aml-build.h"
199a4fedcfSBernhard Beschow #include "hw/boards.h"
205e1b5d93SIgor Mammedov #include "hw/hotplug.h"
215e1b5d93SIgor Mammedov 
222f1a85daSSalil Mehta #define ACPI_CPU_HOTPLUG_REG_LEN 12
232f1a85daSSalil Mehta 
245e1b5d93SIgor Mammedov typedef struct AcpiCpuStatus {
25b8492bd4SPhilippe Mathieu-Daudé     CPUState *cpu;
265e1b5d93SIgor Mammedov     uint64_t arch_id;
27d2238cb6SIgor Mammedov     bool is_inserting;
288872c25aSIgor Mammedov     bool is_removing;
291e6107d9SIgor Mammedov     bool fw_remove;
3076623d00SIgor Mammedov     uint32_t ost_event;
3176623d00SIgor Mammedov     uint32_t ost_status;
325e1b5d93SIgor Mammedov } AcpiCpuStatus;
335e1b5d93SIgor Mammedov 
345e1b5d93SIgor Mammedov typedef struct CPUHotplugState {
355e1b5d93SIgor Mammedov     MemoryRegion ctrl_reg;
365e1b5d93SIgor Mammedov     uint32_t selector;
37d2238cb6SIgor Mammedov     uint8_t command;
385e1b5d93SIgor Mammedov     uint32_t dev_count;
395e1b5d93SIgor Mammedov     AcpiCpuStatus *devs;
405e1b5d93SIgor Mammedov } CPUHotplugState;
415e1b5d93SIgor Mammedov 
425e1b5d93SIgor Mammedov void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
435e1b5d93SIgor Mammedov                       CPUHotplugState *cpu_st, DeviceState *dev, Error **errp);
445e1b5d93SIgor Mammedov 
458872c25aSIgor Mammedov void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
468872c25aSIgor Mammedov                                 CPUHotplugState *cpu_st,
478872c25aSIgor Mammedov                                 DeviceState *dev, Error **errp);
488872c25aSIgor Mammedov 
498872c25aSIgor Mammedov void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
508872c25aSIgor Mammedov                         DeviceState *dev, Error **errp);
518872c25aSIgor Mammedov 
525e1b5d93SIgor Mammedov void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
535e1b5d93SIgor Mammedov                          CPUHotplugState *state, hwaddr base_addr);
545e1b5d93SIgor Mammedov 
555e1b5d93SIgor Mammedov typedef struct CPUHotplugFeatures {
5689cb0c04SDr. David Alan Gilbert     bool acpi_1_compatible;
57679dd1a9SIgor Mammedov     bool has_legacy_cphp;
5869dea9d6SIgor Mammedov     bool fw_unplugs_cpu;
59998ba950SIgor Mammedov     const char *smi_path;
605e1b5d93SIgor Mammedov } CPUHotplugFeatures;
615e1b5d93SIgor Mammedov 
629a4fedcfSBernhard Beschow typedef void (*build_madt_cpu_fn)(int uid, const CPUArchIdList *apic_ids,
639a4fedcfSBernhard Beschow                                   GArray *entry, bool force_enabled);
649a4fedcfSBernhard Beschow 
655e1b5d93SIgor Mammedov void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
66*efdb43b8SSalil Mehta                     build_madt_cpu_fn build_madt_cpu, hwaddr base_addr,
67d2238cb6SIgor Mammedov                     const char *res_root,
68*efdb43b8SSalil Mehta                     const char *event_handler_method,
69*efdb43b8SSalil Mehta                     AmlRegionSpace rs);
705e1b5d93SIgor Mammedov 
7176623d00SIgor Mammedov void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list);
7276623d00SIgor Mammedov 
735e1b5d93SIgor Mammedov extern const VMStateDescription vmstate_cpu_hotplug;
745e1b5d93SIgor Mammedov #define VMSTATE_CPU_HOTPLUG(cpuhp, state) \
755e1b5d93SIgor Mammedov     VMSTATE_STRUCT(cpuhp, state, 1, \
765e1b5d93SIgor Mammedov                    vmstate_cpu_hotplug, CPUHotplugState)
775e1b5d93SIgor Mammedov 
785e1b5d93SIgor Mammedov #endif
79