xref: /openbmc/qemu/include/hw/acpi/cpu.h (revision 09a274d8)
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 "hw/qdev-core.h"
16 #include "hw/acpi/acpi.h"
17 #include "hw/acpi/aml-build.h"
18 #include "hw/hotplug.h"
19 
20 typedef struct AcpiCpuStatus {
21     struct CPUState *cpu;
22     uint64_t arch_id;
23     bool is_inserting;
24     bool is_removing;
25     uint32_t ost_event;
26     uint32_t ost_status;
27 } AcpiCpuStatus;
28 
29 typedef struct CPUHotplugState {
30     MemoryRegion ctrl_reg;
31     uint32_t selector;
32     uint8_t command;
33     uint32_t dev_count;
34     AcpiCpuStatus *devs;
35 } CPUHotplugState;
36 
37 void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
38                       CPUHotplugState *cpu_st, DeviceState *dev, Error **errp);
39 
40 void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
41                                 CPUHotplugState *cpu_st,
42                                 DeviceState *dev, Error **errp);
43 
44 void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
45                         DeviceState *dev, Error **errp);
46 
47 void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
48                          CPUHotplugState *state, hwaddr base_addr);
49 
50 typedef struct CPUHotplugFeatures {
51     bool acpi_1_compatible;
52     bool has_legacy_cphp;
53 } CPUHotplugFeatures;
54 
55 void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
56                     hwaddr io_base,
57                     const char *res_root,
58                     const char *event_handler_method);
59 
60 void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list);
61 
62 extern const VMStateDescription vmstate_cpu_hotplug;
63 #define VMSTATE_CPU_HOTPLUG(cpuhp, state) \
64     VMSTATE_STRUCT(cpuhp, state, 1, \
65                    vmstate_cpu_hotplug, CPUHotplugState)
66 
67 #endif
68