xref: /qemu/include/hw/pci/msi.h (revision c61d1a066cb6cf90662c82d0e35660fc0ccacbaf)
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 
24edf5ca5dSMarkus 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);
36*6096cf78SDavid Woodhouse void msi_set_enabled(PCIDevice *dev);
37e4c7d2aeSIsaku Yamahata int msi_init(struct PCIDevice *dev, uint8_t offset,
381108b2f8SCao jin              unsigned int nr_vectors, bool msi64bit,
391108b2f8SCao jin              bool msi_per_vector_mask, Error **errp);
40e4c7d2aeSIsaku Yamahata void msi_uninit(struct PCIDevice *dev);
41e4c7d2aeSIsaku Yamahata void msi_reset(PCIDevice *dev);
42afa26eccSPeter Xu bool msi_is_masked(const PCIDevice *dev, unsigned int vector);
43e4c7d2aeSIsaku Yamahata void msi_notify(PCIDevice *dev, unsigned int vector);
4438d40ff1SPavel Fedin void msi_send_message(PCIDevice *dev, MSIMessage msg);
45e4c7d2aeSIsaku Yamahata void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len);
46e4c7d2aeSIsaku Yamahata unsigned int msi_nr_vectors_allocated(const PCIDevice *dev);
4708cf3dc6SJagannathan Raman void msi_set_mask(PCIDevice *dev, int vector, bool mask, Error **errp);
48e4c7d2aeSIsaku Yamahata 
msi_present(const PCIDevice * dev)49e4c7d2aeSIsaku Yamahata static inline bool msi_present(const PCIDevice *dev)
50e4c7d2aeSIsaku Yamahata {
51e4c7d2aeSIsaku Yamahata     return dev->cap_present & QEMU_PCI_CAP_MSI;
52e4c7d2aeSIsaku Yamahata }
53e4c7d2aeSIsaku Yamahata 
54e4c7d2aeSIsaku Yamahata #endif /* QEMU_MSI_H */
55