master
h 87 lines 2.47 KB
Raw
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/core/qdev.h"
17 #include "hw/acpi/acpi.h"
18 #include "hw/acpi/aml-build.h"
19 #include "hw/core/boards.h"
20 #include "hw/core/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 fw_unplugs_cpu;
58 const char *smi_path;
59 } CPUHotplugFeatures;
60
61 typedef void (*build_madt_cpu_fn)(int uid, const CPUArchIdList *apic_ids,
62 GArray *entry, bool force_enabled);
63
64 void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
65 build_madt_cpu_fn build_madt_cpu, hwaddr base_addr,
66 const char *res_root,
67 const char *event_handler_method,
68 AmlRegionSpace rs);
69
70 void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list);
71
72 struct CPUPPTTCaches {
73 enum CacheType type;
74 uint32_t sets;
75 uint32_t size;
76 uint32_t level;
77 uint16_t linesize;
78 uint8_t attributes; /* write policy: 0x0 write back, 0x1 write through */
79 uint8_t associativity;
80 };
81
82 extern const VMStateDescription vmstate_cpu_hotplug;
83 #define VMSTATE_CPU_HOTPLUG(cpuhp, state) \
84 VMSTATE_STRUCT(cpuhp, state, 1, \
85 vmstate_cpu_hotplug, CPUHotplugState)
86
87 #endif