xref: /openbmc/qemu/include/hw/acpi/memory_hotplug.h (revision 0b2ff2ce)
1 #ifndef QEMU_HW_ACPI_MEMORY_HOTPLUG_H
2 #define QEMU_HW_ACPI_MEMORY_HOTPLUG_H
3 
4 #include "hw/qdev-core.h"
5 #include "hw/acpi/acpi.h"
6 #include "migration/vmstate.h"
7 
8 #define ACPI_MEMORY_HOTPLUG_STATUS 8
9 
10 /**
11  * MemStatus:
12  * @is_removing: the memory device in slot has been requested to be ejected.
13  *
14  * This structure stores memory device's status.
15  */
16 typedef struct MemStatus {
17     DeviceState *dimm;
18     bool is_enabled;
19     bool is_inserting;
20     bool is_removing;
21     uint32_t ost_event;
22     uint32_t ost_status;
23 } MemStatus;
24 
25 typedef struct MemHotplugState {
26     bool is_enabled; /* true if memory hotplug is supported */
27     MemoryRegion io;
28     uint32_t selector;
29     uint32_t dev_count;
30     MemStatus *devs;
31 } MemHotplugState;
32 
33 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
34                               MemHotplugState *state);
35 
36 void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
37                          DeviceState *dev, Error **errp);
38 void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
39                                    MemHotplugState *mem_st,
40                                    DeviceState *dev, Error **errp);
41 void acpi_memory_unplug_cb(MemHotplugState *mem_st,
42                            DeviceState *dev, Error **errp);
43 
44 extern const VMStateDescription vmstate_memory_hotplug;
45 #define VMSTATE_MEMORY_HOTPLUG(memhp, state) \
46     VMSTATE_STRUCT(memhp, state, 1, \
47                    vmstate_memory_hotplug, MemHotplugState)
48 
49 void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
50 #endif
51