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 15*1017e887SPhilippe 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 225e1b5d93SIgor Mammedov typedef struct AcpiCpuStatus { 235e1b5d93SIgor Mammedov struct CPUState *cpu; 245e1b5d93SIgor Mammedov uint64_t arch_id; 25d2238cb6SIgor Mammedov bool is_inserting; 268872c25aSIgor Mammedov bool is_removing; 271e6107d9SIgor Mammedov bool fw_remove; 2876623d00SIgor Mammedov uint32_t ost_event; 2976623d00SIgor Mammedov uint32_t ost_status; 305e1b5d93SIgor Mammedov } AcpiCpuStatus; 315e1b5d93SIgor Mammedov 325e1b5d93SIgor Mammedov typedef struct CPUHotplugState { 335e1b5d93SIgor Mammedov MemoryRegion ctrl_reg; 345e1b5d93SIgor Mammedov uint32_t selector; 35d2238cb6SIgor Mammedov uint8_t command; 365e1b5d93SIgor Mammedov uint32_t dev_count; 375e1b5d93SIgor Mammedov AcpiCpuStatus *devs; 385e1b5d93SIgor Mammedov } CPUHotplugState; 395e1b5d93SIgor Mammedov 405e1b5d93SIgor Mammedov void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, 415e1b5d93SIgor Mammedov CPUHotplugState *cpu_st, DeviceState *dev, Error **errp); 425e1b5d93SIgor Mammedov 438872c25aSIgor Mammedov void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, 448872c25aSIgor Mammedov CPUHotplugState *cpu_st, 458872c25aSIgor Mammedov DeviceState *dev, Error **errp); 468872c25aSIgor Mammedov 478872c25aSIgor Mammedov void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st, 488872c25aSIgor Mammedov DeviceState *dev, Error **errp); 498872c25aSIgor Mammedov 505e1b5d93SIgor Mammedov void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, 515e1b5d93SIgor Mammedov CPUHotplugState *state, hwaddr base_addr); 525e1b5d93SIgor Mammedov 535e1b5d93SIgor Mammedov typedef struct CPUHotplugFeatures { 5489cb0c04SDr. David Alan Gilbert bool acpi_1_compatible; 55679dd1a9SIgor Mammedov bool has_legacy_cphp; 5669dea9d6SIgor Mammedov bool fw_unplugs_cpu; 57998ba950SIgor Mammedov const char *smi_path; 585e1b5d93SIgor Mammedov } CPUHotplugFeatures; 595e1b5d93SIgor Mammedov 609a4fedcfSBernhard Beschow typedef void (*build_madt_cpu_fn)(int uid, const CPUArchIdList *apic_ids, 619a4fedcfSBernhard Beschow GArray *entry, bool force_enabled); 629a4fedcfSBernhard Beschow 635e1b5d93SIgor Mammedov void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, 649a4fedcfSBernhard Beschow build_madt_cpu_fn build_madt_cpu, hwaddr io_base, 65d2238cb6SIgor Mammedov const char *res_root, 66d2238cb6SIgor Mammedov const char *event_handler_method); 675e1b5d93SIgor Mammedov 6876623d00SIgor Mammedov void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list); 6976623d00SIgor Mammedov 705e1b5d93SIgor Mammedov extern const VMStateDescription vmstate_cpu_hotplug; 715e1b5d93SIgor Mammedov #define VMSTATE_CPU_HOTPLUG(cpuhp, state) \ 725e1b5d93SIgor Mammedov VMSTATE_STRUCT(cpuhp, state, 1, \ 735e1b5d93SIgor Mammedov vmstate_cpu_hotplug, CPUHotplugState) 745e1b5d93SIgor Mammedov 755e1b5d93SIgor Mammedov #endif 76