blob: 999caaf510600dda467b91dfa77c8ab9c0450068 [file] [log] [blame]
Igor Mammedov5e1b5d92016-06-14 16:02:06 +02001/*
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
20typedef struct AcpiCpuStatus {
21 struct CPUState *cpu;
22 uint64_t arch_id;
Igor Mammedovd2238cb2016-06-14 16:13:32 +020023 bool is_inserting;
Igor Mammedov8872c252016-06-14 16:14:02 +020024 bool is_removing;
Igor Mammedov1e6107d2020-12-07 09:07:33 -050025 bool fw_remove;
Igor Mammedov76623d02016-04-22 19:06:36 +020026 uint32_t ost_event;
27 uint32_t ost_status;
Igor Mammedov5e1b5d92016-06-14 16:02:06 +020028} AcpiCpuStatus;
29
30typedef struct CPUHotplugState {
31 MemoryRegion ctrl_reg;
32 uint32_t selector;
Igor Mammedovd2238cb2016-06-14 16:13:32 +020033 uint8_t command;
Igor Mammedov5e1b5d92016-06-14 16:02:06 +020034 uint32_t dev_count;
35 AcpiCpuStatus *devs;
36} CPUHotplugState;
37
38void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
39 CPUHotplugState *cpu_st, DeviceState *dev, Error **errp);
40
Igor Mammedov8872c252016-06-14 16:14:02 +020041void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
42 CPUHotplugState *cpu_st,
43 DeviceState *dev, Error **errp);
44
45void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
46 DeviceState *dev, Error **errp);
47
Igor Mammedov5e1b5d92016-06-14 16:02:06 +020048void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
49 CPUHotplugState *state, hwaddr base_addr);
50
51typedef struct CPUHotplugFeatures {
Dr. David Alan Gilbert89cb0c02019-01-25 09:40:46 +000052 bool acpi_1_compatible;
Igor Mammedov679dd1a2016-06-15 11:25:23 +020053 bool has_legacy_cphp;
Igor Mammedov69dea9d2020-12-07 09:07:36 -050054 bool fw_unplugs_cpu;
Igor Mammedov998ba952020-09-23 05:46:47 -040055 const char *smi_path;
Igor Mammedov5e1b5d92016-06-14 16:02:06 +020056} CPUHotplugFeatures;
57
58void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
59 hwaddr io_base,
Igor Mammedovd2238cb2016-06-14 16:13:32 +020060 const char *res_root,
61 const char *event_handler_method);
Igor Mammedov5e1b5d92016-06-14 16:02:06 +020062
Igor Mammedov76623d02016-04-22 19:06:36 +020063void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list);
64
Igor Mammedov5e1b5d92016-06-14 16:02:06 +020065extern const VMStateDescription vmstate_cpu_hotplug;
66#define VMSTATE_CPU_HOTPLUG(cpuhp, state) \
67 VMSTATE_STRUCT(cpuhp, state, 1, \
68 vmstate_cpu_hotplug, CPUHotplugState)
69
70#endif