1e4c7d2aeSIsaku Yamahata /* 2e4c7d2aeSIsaku Yamahata * msi.h 3e4c7d2aeSIsaku Yamahata * 4e4c7d2aeSIsaku Yamahata * Copyright (c) 2010 Isaku Yamahata <yamahata at valinux co jp> 5e4c7d2aeSIsaku Yamahata * VA Linux Systems Japan K.K. 6e4c7d2aeSIsaku Yamahata * 7e4c7d2aeSIsaku Yamahata * This program is free software; you can redistribute it and/or modify 8e4c7d2aeSIsaku Yamahata * it under the terms of the GNU General Public License as published by 9e4c7d2aeSIsaku Yamahata * the Free Software Foundation; either version 2 of the License, or 10e4c7d2aeSIsaku Yamahata * (at your option) any later version. 11e4c7d2aeSIsaku Yamahata 12e4c7d2aeSIsaku Yamahata * This program is distributed in the hope that it will be useful, 13e4c7d2aeSIsaku Yamahata * but WITHOUT ANY WARRANTY; without even the implied warranty of 14e4c7d2aeSIsaku Yamahata * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15e4c7d2aeSIsaku Yamahata * GNU General Public License for more details. 16e4c7d2aeSIsaku Yamahata 17e4c7d2aeSIsaku Yamahata * You should have received a copy of the GNU General Public License along 18e4c7d2aeSIsaku Yamahata * with this program; if not, see <http://www.gnu.org/licenses/>. 19e4c7d2aeSIsaku Yamahata */ 20e4c7d2aeSIsaku Yamahata 21e4c7d2aeSIsaku Yamahata #ifndef QEMU_MSI_H 22e4c7d2aeSIsaku Yamahata #define QEMU_MSI_H 23e4c7d2aeSIsaku Yamahata 24*edf5ca5dSMarkus Armbruster #include "hw/pci/pci_device.h" 25e4c7d2aeSIsaku Yamahata 2614de9babSJan Kiszka struct MSIMessage { 2714de9babSJan Kiszka uint64_t address; 2814de9babSJan Kiszka uint32_t data; 2914de9babSJan Kiszka }; 3014de9babSJan Kiszka 31226419d6SMichael S. Tsirkin extern bool msi_nonbroken; 3260ba3cc2SJan Kiszka 33932d4a42SAlexey Kardashevskiy void msi_set_message(PCIDevice *dev, MSIMessage msg); 3439b9bc62SAlex Williamson MSIMessage msi_get_message(PCIDevice *dev, unsigned int vector); 35e4c7d2aeSIsaku Yamahata bool msi_enabled(const PCIDevice *dev); 36e4c7d2aeSIsaku Yamahata int msi_init(struct PCIDevice *dev, uint8_t offset, 371108b2f8SCao jin unsigned int nr_vectors, bool msi64bit, 381108b2f8SCao jin bool msi_per_vector_mask, Error **errp); 39e4c7d2aeSIsaku Yamahata void msi_uninit(struct PCIDevice *dev); 40e4c7d2aeSIsaku Yamahata void msi_reset(PCIDevice *dev); 41afa26eccSPeter Xu bool msi_is_masked(const PCIDevice *dev, unsigned int vector); 42e4c7d2aeSIsaku Yamahata void msi_notify(PCIDevice *dev, unsigned int vector); 4338d40ff1SPavel Fedin void msi_send_message(PCIDevice *dev, MSIMessage msg); 44e4c7d2aeSIsaku Yamahata void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len); 45e4c7d2aeSIsaku Yamahata unsigned int msi_nr_vectors_allocated(const PCIDevice *dev); 4608cf3dc6SJagannathan Raman void msi_set_mask(PCIDevice *dev, int vector, bool mask, Error **errp); 47e4c7d2aeSIsaku Yamahata 48e4c7d2aeSIsaku Yamahata static inline bool msi_present(const PCIDevice *dev) 49e4c7d2aeSIsaku Yamahata { 50e4c7d2aeSIsaku Yamahata return dev->cap_present & QEMU_PCI_CAP_MSI; 51e4c7d2aeSIsaku Yamahata } 52e4c7d2aeSIsaku Yamahata 53e4c7d2aeSIsaku Yamahata #endif /* QEMU_MSI_H */ 54