xref: /qemu/include/hw/pci/shpc.h (revision 5cd5e7015962d8d559afb5154888fd34a8526ddd)
11dc324d2SMichael S. Tsirkin #ifndef SHPC_H
21dc324d2SMichael S. Tsirkin #define SHPC_H
31dc324d2SMichael S. Tsirkin 
41dc324d2SMichael S. Tsirkin #include "qemu-common.h"
5022c62cbSPaolo Bonzini #include "exec/memory.h"
6caf71f86SPaolo Bonzini #include "migration/vmstate.h"
75d268704SIgor Mammedov #include "qapi/error.h"
85d268704SIgor Mammedov #include "hw/hotplug.h"
91dc324d2SMichael S. Tsirkin 
101dc324d2SMichael S. Tsirkin struct SHPCDevice {
111dc324d2SMichael S. Tsirkin     /* Capability offset in device's config space */
121dc324d2SMichael S. Tsirkin     int cap;
131dc324d2SMichael S. Tsirkin 
141dc324d2SMichael S. Tsirkin     /* # of hot-pluggable slots */
151dc324d2SMichael S. Tsirkin     int nslots;
161dc324d2SMichael S. Tsirkin 
171dc324d2SMichael S. Tsirkin     /* SHPC WRS: working register set */
181dc324d2SMichael S. Tsirkin     uint8_t *config;
191dc324d2SMichael S. Tsirkin 
201dc324d2SMichael S. Tsirkin     /* Used to enable checks on load. Note that writable bits are
211dc324d2SMichael S. Tsirkin      * never checked even if set in cmask. */
221dc324d2SMichael S. Tsirkin     uint8_t *cmask;
231dc324d2SMichael S. Tsirkin 
241dc324d2SMichael S. Tsirkin     /* Used to implement R/W bytes */
251dc324d2SMichael S. Tsirkin     uint8_t *wmask;
261dc324d2SMichael S. Tsirkin 
271dc324d2SMichael S. Tsirkin     /* Used to implement RW1C(Write 1 to Clear) bytes */
281dc324d2SMichael S. Tsirkin     uint8_t *w1cmask;
291dc324d2SMichael S. Tsirkin 
301dc324d2SMichael S. Tsirkin     /* MMIO for the SHPC BAR */
311dc324d2SMichael S. Tsirkin     MemoryRegion mmio;
321dc324d2SMichael S. Tsirkin 
331dc324d2SMichael S. Tsirkin     /* Bus controlled by this SHPC */
341dc324d2SMichael S. Tsirkin     PCIBus *sec_bus;
351dc324d2SMichael S. Tsirkin 
361dc324d2SMichael S. Tsirkin     /* MSI already requested for this event */
371dc324d2SMichael S. Tsirkin     int msi_requested;
381dc324d2SMichael S. Tsirkin };
391dc324d2SMichael S. Tsirkin 
401dc324d2SMichael S. Tsirkin void shpc_reset(PCIDevice *d);
411dc324d2SMichael S. Tsirkin int shpc_bar_size(PCIDevice *dev);
421dc324d2SMichael S. Tsirkin int shpc_init(PCIDevice *dev, PCIBus *sec_bus, MemoryRegion *bar, unsigned off);
431dc324d2SMichael S. Tsirkin void shpc_cleanup(PCIDevice *dev, MemoryRegion *bar);
44*5cd5e701SPaolo Bonzini void shpc_free(PCIDevice *dev);
451dc324d2SMichael S. Tsirkin void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len);
461dc324d2SMichael S. Tsirkin 
475d268704SIgor Mammedov 
485d268704SIgor Mammedov void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
495d268704SIgor Mammedov                             Error **errp);
5014d5a28fSIgor Mammedov void shpc_device_hot_unplug_request_cb(HotplugHandler *hotplug_dev,
5114d5a28fSIgor Mammedov                                        DeviceState *dev, Error **errp);
525d268704SIgor Mammedov 
531dc324d2SMichael S. Tsirkin extern VMStateInfo shpc_vmstate_info;
541dc324d2SMichael S. Tsirkin #define SHPC_VMSTATE(_field, _type) \
551dc324d2SMichael S. Tsirkin     VMSTATE_BUFFER_UNSAFE_INFO(_field, _type, 0, shpc_vmstate_info, 0)
561dc324d2SMichael S. Tsirkin 
571dc324d2SMichael S. Tsirkin #endif
58