xref: /openbmc/qemu/include/hw/acpi/memory_hotplug.h (revision 6a02465f)
1 #ifndef QEMU_HW_ACPI_MEMORY_HOTPLUG_H
2 #define QEMU_HW_ACPI_MEMORY_HOTPLUG_H
3 
4 #include "qapi/qapi-types-acpi.h"
5 #include "hw/qdev-core.h"
6 #include "hw/acpi/acpi.h"
7 #include "hw/acpi/aml-build.h"
8 
9 #define MEMORY_SLOT_SCAN_METHOD      "MSCN"
10 #define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
11 #define MEMORY_HOTPLUG_IO_LEN         24
12 
13 /**
14  * MemStatus:
15  * @is_removing: the memory device in slot has been requested to be ejected.
16  *
17  * This structure stores memory device's status.
18  */
19 typedef struct MemStatus {
20     DeviceState *dimm;
21     bool is_enabled;
22     bool is_inserting;
23     bool is_removing;
24     uint32_t ost_event;
25     uint32_t ost_status;
26 } MemStatus;
27 
28 typedef struct MemHotplugState {
29     bool is_enabled; /* true if memory hotplug is supported */
30     MemoryRegion io;
31     uint32_t selector;
32     uint32_t dev_count;
33     MemStatus *devs;
34 } MemHotplugState;
35 
36 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
37                               MemHotplugState *state, hwaddr io_base);
38 
39 void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
40                          DeviceState *dev, Error **errp);
41 void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev,
42                                    MemHotplugState *mem_st,
43                                    DeviceState *dev, Error **errp);
44 void acpi_memory_unplug_cb(MemHotplugState *mem_st,
45                            DeviceState *dev, Error **errp);
46 
47 extern const VMStateDescription vmstate_memory_hotplug;
48 #define VMSTATE_MEMORY_HOTPLUG(memhp, state) \
49     VMSTATE_STRUCT(memhp, state, 1, \
50                    vmstate_memory_hotplug, MemHotplugState)
51 
52 void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
53 
54 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
55                               const char *res_root,
56                               const char *event_handler_method,
57                               AmlRegionSpace rs, hwaddr memhp_io_base);
58 #endif
59