xref: /qemu/include/hw/pci/msi.h (revision 14de9bab9e4aa47215c26d87de7385afbcb37afa)
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 
24e4c7d2aeSIsaku Yamahata #include "qemu-common.h"
25e4c7d2aeSIsaku Yamahata #include "pci.h"
26e4c7d2aeSIsaku Yamahata 
27*14de9babSJan Kiszka struct MSIMessage {
28*14de9babSJan Kiszka     uint64_t address;
29*14de9babSJan Kiszka     uint32_t data;
30*14de9babSJan Kiszka };
31*14de9babSJan Kiszka 
3260ba3cc2SJan Kiszka extern bool msi_supported;
3360ba3cc2SJan Kiszka 
34e4c7d2aeSIsaku Yamahata bool msi_enabled(const PCIDevice *dev);
35e4c7d2aeSIsaku Yamahata int msi_init(struct PCIDevice *dev, uint8_t offset,
36e4c7d2aeSIsaku Yamahata              unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask);
37e4c7d2aeSIsaku Yamahata void msi_uninit(struct PCIDevice *dev);
38e4c7d2aeSIsaku Yamahata void msi_reset(PCIDevice *dev);
39e4c7d2aeSIsaku Yamahata void msi_notify(PCIDevice *dev, unsigned int vector);
40e4c7d2aeSIsaku Yamahata void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len);
41e4c7d2aeSIsaku Yamahata unsigned int msi_nr_vectors_allocated(const PCIDevice *dev);
42e4c7d2aeSIsaku Yamahata 
43e4c7d2aeSIsaku Yamahata static inline bool msi_present(const PCIDevice *dev)
44e4c7d2aeSIsaku Yamahata {
45e4c7d2aeSIsaku Yamahata     return dev->cap_present & QEMU_PCI_CAP_MSI;
46e4c7d2aeSIsaku Yamahata }
47e4c7d2aeSIsaku Yamahata 
48e4c7d2aeSIsaku Yamahata #endif /* QEMU_MSI_H */
49