2012-02-12 16:12:21 +04:00
|
|
|
#ifndef SHPC_H
|
|
|
|
#define SHPC_H
|
|
|
|
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/memory.h"
|
2014-02-05 19:36:50 +04:00
|
|
|
#include "hw/hotplug.h"
|
2022-12-22 13:03:28 +03:00
|
|
|
#include "hw/pci/pci_device.h"
|
2019-08-12 08:23:45 +03:00
|
|
|
#include "migration/vmstate.h"
|
2012-02-12 16:12:21 +04:00
|
|
|
|
|
|
|
struct SHPCDevice {
|
|
|
|
/* Capability offset in device's config space */
|
|
|
|
int cap;
|
|
|
|
|
|
|
|
/* # of hot-pluggable slots */
|
|
|
|
int nslots;
|
|
|
|
|
|
|
|
/* SHPC WRS: working register set */
|
|
|
|
uint8_t *config;
|
|
|
|
|
|
|
|
/* Used to enable checks on load. Note that writable bits are
|
|
|
|
* never checked even if set in cmask. */
|
|
|
|
uint8_t *cmask;
|
|
|
|
|
|
|
|
/* Used to implement R/W bytes */
|
|
|
|
uint8_t *wmask;
|
|
|
|
|
|
|
|
/* Used to implement RW1C(Write 1 to Clear) bytes */
|
|
|
|
uint8_t *w1cmask;
|
|
|
|
|
|
|
|
/* MMIO for the SHPC BAR */
|
|
|
|
MemoryRegion mmio;
|
|
|
|
|
|
|
|
/* Bus controlled by this SHPC */
|
|
|
|
PCIBus *sec_bus;
|
|
|
|
|
|
|
|
/* MSI already requested for this event */
|
|
|
|
int msi_requested;
|
|
|
|
};
|
|
|
|
|
|
|
|
void shpc_reset(PCIDevice *d);
|
|
|
|
int shpc_bar_size(PCIDevice *dev);
|
2017-06-27 09:16:53 +03:00
|
|
|
int shpc_init(PCIDevice *dev, PCIBus *sec_bus, MemoryRegion *bar,
|
|
|
|
unsigned off, Error **errp);
|
2012-02-12 16:12:21 +04:00
|
|
|
void shpc_cleanup(PCIDevice *dev, MemoryRegion *bar);
|
2015-02-12 23:39:20 +03:00
|
|
|
void shpc_free(PCIDevice *dev);
|
2012-02-12 16:12:21 +04:00
|
|
|
void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len);
|
|
|
|
|
2014-02-05 19:36:50 +04:00
|
|
|
|
2018-12-12 12:16:14 +03:00
|
|
|
void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
|
Error **errp);
|
2018-12-12 12:16:22 +03:00
|
|
|
void shpc_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
|
Error **errp);
|
2018-12-12 12:16:14 +03:00
|
|
|
void shpc_device_unplug_request_cb(HotplugHandler *hotplug_dev,
|
|
|
|
DeviceState *dev, Error **errp);
|
2014-02-05 19:36:50 +04:00
|
|
|
|
2012-02-12 16:12:21 +04:00
|
|
|
extern VMStateInfo shpc_vmstate_info;
|
2015-06-19 05:40:09 +03:00
|
|
|
#define SHPC_VMSTATE(_field, _type, _test) \
|
|
|
|
VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _type, _test, 0, \
|
|
|
|
shpc_vmstate_info, 0)
|
2012-02-12 16:12:21 +04:00
|
|
|
|
2015-06-19 05:40:12 +03:00
|
|
|
static inline bool shpc_present(const PCIDevice *dev)
|
|
|
|
{
|
|
|
|
return dev->cap_present & QEMU_PCI_CAP_SHPC;
|
|
|
|
}
|
|
|
|
|
2012-02-12 16:12:21 +04:00
|
|
|
#endif
|