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" 730bd0cf4SIgor 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 35*0058c082SIgor Mammedov void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st, 363ef77acaSIgor Mammedov DeviceState *dev, Error **errp); 37*0058c082SIgor Mammedov void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev, 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); 4930bd0cf4SIgor Mammedov 50f84548ddSIgor Mammedov #define MEMORY_HOTPLUG_DEVICE "MHPD" 51f84548ddSIgor Mammedov #define MEMORY_SLOT_SCAN_METHOD "MSCN" 527f4495e1SIgor Mammedov #define MEMORY_HOTPLUG_HANDLER_PATH "\\_SB.PCI0." \ 53f84548ddSIgor Mammedov MEMORY_HOTPLUG_DEVICE "." MEMORY_SLOT_SCAN_METHOD 547f4495e1SIgor Mammedov 5530bd0cf4SIgor Mammedov void build_memory_hotplug_aml(Aml *ctx, uint32_t nr_mem, 5630bd0cf4SIgor Mammedov uint16_t io_base, uint16_t io_len); 573ef77acaSIgor Mammedov #endif 58