13ef77acaSIgor Mammedov #ifndef QEMU_HW_ACPI_MEMORY_HOTPLUG_H 23ef77acaSIgor Mammedov #define QEMU_HW_ACPI_MEMORY_HOTPLUG_H 33ef77acaSIgor Mammedov 4*1017e887SPhilippe Mathieu-Daudé #include "qapi/qapi-types-acpi.h" 53ef77acaSIgor Mammedov #include "hw/qdev-core.h" 63ef77acaSIgor Mammedov #include "hw/acpi/acpi.h" 730bd0cf4SIgor Mammedov #include "hw/acpi/aml-build.h" 83ef77acaSIgor Mammedov 9091c466eSShameer Kolothum #define MEMORY_SLOT_SCAN_METHOD "MSCN" 10091c466eSShameer Kolothum #define MEMORY_DEVICES_CONTAINER "\\_SB.MHPC" 11091c466eSShameer Kolothum #define MEMORY_HOTPLUG_IO_LEN 24 12091c466eSShameer Kolothum 1364fec58eSTang Chen /** 1464fec58eSTang Chen * MemStatus: 1564fec58eSTang Chen * @is_removing: the memory device in slot has been requested to be ejected. 1664fec58eSTang Chen * 1764fec58eSTang Chen * This structure stores memory device's status. 1864fec58eSTang Chen */ 193ef77acaSIgor Mammedov typedef struct MemStatus { 203ef77acaSIgor Mammedov DeviceState *dimm; 213ef77acaSIgor Mammedov bool is_enabled; 223ef77acaSIgor Mammedov bool is_inserting; 2364fec58eSTang Chen bool is_removing; 243ef77acaSIgor Mammedov uint32_t ost_event; 253ef77acaSIgor Mammedov uint32_t ost_status; 263ef77acaSIgor Mammedov } MemStatus; 273ef77acaSIgor Mammedov 283ef77acaSIgor Mammedov typedef struct MemHotplugState { 2934774320SIgor Mammedov bool is_enabled; /* true if memory hotplug is supported */ 303ef77acaSIgor Mammedov MemoryRegion io; 313ef77acaSIgor Mammedov uint32_t selector; 323ef77acaSIgor Mammedov uint32_t dev_count; 333ef77acaSIgor Mammedov MemStatus *devs; 343ef77acaSIgor Mammedov } MemHotplugState; 353ef77acaSIgor Mammedov 363ef77acaSIgor Mammedov void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, 37091c466eSShameer Kolothum MemHotplugState *state, hwaddr io_base); 383ef77acaSIgor Mammedov 390058c082SIgor Mammedov void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st, 403ef77acaSIgor Mammedov DeviceState *dev, Error **errp); 410058c082SIgor Mammedov void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev, 4264fec58eSTang Chen MemHotplugState *mem_st, 4364fec58eSTang Chen DeviceState *dev, Error **errp); 44f7d3e29dSTang Chen void acpi_memory_unplug_cb(MemHotplugState *mem_st, 45f7d3e29dSTang Chen DeviceState *dev, Error **errp); 46f816a62dSIgor Mammedov 47f816a62dSIgor Mammedov extern const VMStateDescription vmstate_memory_hotplug; 48f816a62dSIgor Mammedov #define VMSTATE_MEMORY_HOTPLUG(memhp, state) \ 49f816a62dSIgor Mammedov VMSTATE_STRUCT(memhp, state, 1, \ 50f816a62dSIgor Mammedov vmstate_memory_hotplug, MemHotplugState) 51f816a62dSIgor Mammedov 5243f50410SIgor Mammedov void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list); 5330bd0cf4SIgor Mammedov 548dfba500SIgor Mammedov void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, 55d1957dacSIgor Mammedov const char *res_root, 56091c466eSShameer Kolothum const char *event_handler_method, 57091c466eSShameer Kolothum AmlRegionSpace rs, hwaddr memhp_io_base); 583ef77acaSIgor Mammedov #endif 59