xref: /qemu/include/hw/pci/shpc.h (revision 5d268704d7c2bc58c38b87d7d94804639ef100ec)
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"
7*5d268704SIgor Mammedov #include "qapi/error.h"
8*5d268704SIgor 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);
441dc324d2SMichael S. Tsirkin void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len);
451dc324d2SMichael S. Tsirkin 
46*5d268704SIgor Mammedov 
47*5d268704SIgor Mammedov void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
48*5d268704SIgor Mammedov                             Error **errp);
49*5d268704SIgor Mammedov void shpc_device_hot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
50*5d268704SIgor Mammedov                                Error **errp);
51*5d268704SIgor Mammedov 
521dc324d2SMichael S. Tsirkin extern VMStateInfo shpc_vmstate_info;
531dc324d2SMichael S. Tsirkin #define SHPC_VMSTATE(_field, _type) \
541dc324d2SMichael S. Tsirkin     VMSTATE_BUFFER_UNSAFE_INFO(_field, _type, 0, shpc_vmstate_info, 0)
551dc324d2SMichael S. Tsirkin 
561dc324d2SMichael S. Tsirkin #endif
57