xref: /openbmc/qemu/include/hw/acpi/cpu.h (revision cde3c425)
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 #define ACPI_CPU_HOTPLUG_REG_LEN 12
23 
24 typedef struct AcpiCpuStatus {
25     CPUState *cpu;
26     uint64_t arch_id;
27     bool is_inserting;
28     bool is_removing;
29     bool fw_remove;
30     uint32_t ost_event;
31     uint32_t ost_status;
32 } AcpiCpuStatus;
33 
34 typedef struct CPUHotplugState {
35     MemoryRegion ctrl_reg;
36     uint32_t selector;
37     uint8_t command;
38     uint32_t dev_count;
39     AcpiCpuStatus *devs;
40 } CPUHotplugState;
41 
42 void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
43                       CPUHotplugState *cpu_st, DeviceState *dev, Error **errp);
44 
45 void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
46                                 CPUHotplugState *cpu_st,
47                                 DeviceState *dev, Error **errp);
48 
49 void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
50                         DeviceState *dev, Error **errp);
51 
52 void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
53                          CPUHotplugState *state, hwaddr base_addr);
54 
55 typedef struct CPUHotplugFeatures {
56     bool acpi_1_compatible;
57     bool has_legacy_cphp;
58     bool fw_unplugs_cpu;
59     const char *smi_path;
60 } CPUHotplugFeatures;
61 
62 typedef void (*build_madt_cpu_fn)(int uid, const CPUArchIdList *apic_ids,
63                                   GArray *entry, bool force_enabled);
64 
65 void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
66                     build_madt_cpu_fn build_madt_cpu, hwaddr base_addr,
67                     const char *res_root,
68                     const char *event_handler_method,
69                     AmlRegionSpace rs);
70 
71 void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list);
72 
73 extern const VMStateDescription vmstate_cpu_hotplug;
74 #define VMSTATE_CPU_HOTPLUG(cpuhp, state) \
75     VMSTATE_STRUCT(cpuhp, state, 1, \
76                    vmstate_cpu_hotplug, CPUHotplugState)
77 
78 #endif
79