xref: /openbmc/qemu/include/hw/acpi/cpu.h (revision cc6cb422)
1 /*
2  * QEMU ACPI hotplug utilities
3  *
4  * Copyright (C) 2016 Red Hat Inc
5  *
6  * Authors:
7  *   Igor Mammedov <imammedo@redhat.com>
8  *
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.
11  */
12 #ifndef ACPI_CPU_H
13 #define ACPI_CPU_H
14 
15 #include "qapi/qapi-types-acpi.h"
16 #include "hw/qdev-core.h"
17 #include "hw/acpi/acpi.h"
18 #include "hw/acpi/aml-build.h"
19 #include "hw/boards.h"
20 #include "hw/hotplug.h"
21 
22 typedef struct AcpiCpuStatus {
23     CPUState *cpu;
24     uint64_t arch_id;
25     bool is_inserting;
26     bool is_removing;
27     bool fw_remove;
28     uint32_t ost_event;
29     uint32_t ost_status;
30 } AcpiCpuStatus;
31 
32 typedef struct CPUHotplugState {
33     MemoryRegion ctrl_reg;
34     uint32_t selector;
35     uint8_t command;
36     uint32_t dev_count;
37     AcpiCpuStatus *devs;
38 } CPUHotplugState;
39 
40 void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
41                       CPUHotplugState *cpu_st, DeviceState *dev, Error **errp);
42 
43 void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
44                                 CPUHotplugState *cpu_st,
45                                 DeviceState *dev, Error **errp);
46 
47 void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
48                         DeviceState *dev, Error **errp);
49 
50 void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
51                          CPUHotplugState *state, hwaddr base_addr);
52 
53 typedef struct CPUHotplugFeatures {
54     bool acpi_1_compatible;
55     bool has_legacy_cphp;
56     bool fw_unplugs_cpu;
57     const char *smi_path;
58 } CPUHotplugFeatures;
59 
60 typedef void (*build_madt_cpu_fn)(int uid, const CPUArchIdList *apic_ids,
61                                   GArray *entry, bool force_enabled);
62 
63 void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
64                     build_madt_cpu_fn build_madt_cpu, hwaddr io_base,
65                     const char *res_root,
66                     const char *event_handler_method);
67 
68 void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list);
69 
70 extern const VMStateDescription vmstate_cpu_hotplug;
71 #define VMSTATE_CPU_HOTPLUG(cpuhp, state) \
72     VMSTATE_STRUCT(cpuhp, state, 1, \
73                    vmstate_cpu_hotplug, CPUHotplugState)
74 
75 #endif
76