xref: /qemu/include/hw/acpi/memory_hotplug.h (revision 30bd0cf465c9c66f22e82f2aa1f1fbca7dafe102)
13ef77acaSIgor Mammedov #ifndef QEMU_HW_ACPI_MEMORY_HOTPLUG_H
23ef77acaSIgor Mammedov #define QEMU_HW_ACPI_MEMORY_HOTPLUG_H
33ef77acaSIgor Mammedov 
43ef77acaSIgor Mammedov #include "hw/qdev-core.h"
53ef77acaSIgor Mammedov #include "hw/acpi/acpi.h"
6f816a62dSIgor Mammedov #include "migration/vmstate.h"
7*30bd0cf4SIgor Mammedov #include "hw/acpi/aml-build.h"
83ef77acaSIgor Mammedov 
964fec58eSTang Chen /**
1064fec58eSTang Chen  * MemStatus:
1164fec58eSTang Chen  * @is_removing: the memory device in slot has been requested to be ejected.
1264fec58eSTang Chen  *
1364fec58eSTang Chen  * This structure stores memory device's status.
1464fec58eSTang Chen  */
153ef77acaSIgor Mammedov typedef struct MemStatus {
163ef77acaSIgor Mammedov     DeviceState *dimm;
173ef77acaSIgor Mammedov     bool is_enabled;
183ef77acaSIgor Mammedov     bool is_inserting;
1964fec58eSTang Chen     bool is_removing;
203ef77acaSIgor Mammedov     uint32_t ost_event;
213ef77acaSIgor Mammedov     uint32_t ost_status;
223ef77acaSIgor Mammedov } MemStatus;
233ef77acaSIgor Mammedov 
243ef77acaSIgor Mammedov typedef struct MemHotplugState {
2534774320SIgor Mammedov     bool is_enabled; /* true if memory hotplug is supported */
263ef77acaSIgor Mammedov     MemoryRegion io;
273ef77acaSIgor Mammedov     uint32_t selector;
283ef77acaSIgor Mammedov     uint32_t dev_count;
293ef77acaSIgor Mammedov     MemStatus *devs;
303ef77acaSIgor Mammedov } MemHotplugState;
313ef77acaSIgor Mammedov 
323ef77acaSIgor Mammedov void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
333ef77acaSIgor Mammedov                               MemHotplugState *state);
343ef77acaSIgor Mammedov 
353ef77acaSIgor Mammedov void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st,
363ef77acaSIgor Mammedov                          DeviceState *dev, Error **errp);
3764fec58eSTang Chen void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq,
3864fec58eSTang Chen                                    MemHotplugState *mem_st,
3964fec58eSTang Chen                                    DeviceState *dev, Error **errp);
40f7d3e29dSTang Chen void acpi_memory_unplug_cb(MemHotplugState *mem_st,
41f7d3e29dSTang Chen                            DeviceState *dev, Error **errp);
42f816a62dSIgor Mammedov 
43f816a62dSIgor Mammedov extern const VMStateDescription vmstate_memory_hotplug;
44f816a62dSIgor Mammedov #define VMSTATE_MEMORY_HOTPLUG(memhp, state) \
45f816a62dSIgor Mammedov     VMSTATE_STRUCT(memhp, state, 1, \
46f816a62dSIgor Mammedov                    vmstate_memory_hotplug, MemHotplugState)
47f816a62dSIgor Mammedov 
4843f50410SIgor Mammedov void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
49*30bd0cf4SIgor Mammedov 
50*30bd0cf4SIgor Mammedov void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem,
51*30bd0cf4SIgor Mammedov                               uint16_t io_base, uint16_t io_len);
523ef77acaSIgor Mammedov #endif
53