xref: /qemu/include/hw/pci/msi.h (revision c759b24fae08c6c333df03e1db48e13b7f5eda30)
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"
25*c759b24fSMichael S. Tsirkin #include "hw/pci/pci.h"
26e4c7d2aeSIsaku Yamahata 
2714de9babSJan Kiszka struct MSIMessage {
2814de9babSJan Kiszka     uint64_t address;
2914de9babSJan Kiszka     uint32_t data;
3014de9babSJan Kiszka };
3114de9babSJan Kiszka 
3260ba3cc2SJan Kiszka extern bool msi_supported;
3360ba3cc2SJan Kiszka 
34932d4a42SAlexey Kardashevskiy void msi_set_message(PCIDevice *dev, MSIMessage msg);
3539b9bc62SAlex Williamson MSIMessage msi_get_message(PCIDevice *dev, unsigned int vector);
36e4c7d2aeSIsaku Yamahata bool msi_enabled(const PCIDevice *dev);
37e4c7d2aeSIsaku Yamahata int msi_init(struct PCIDevice *dev, uint8_t offset,
38e4c7d2aeSIsaku Yamahata              unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask);
39e4c7d2aeSIsaku Yamahata void msi_uninit(struct PCIDevice *dev);
40e4c7d2aeSIsaku Yamahata void msi_reset(PCIDevice *dev);
41e4c7d2aeSIsaku Yamahata void msi_notify(PCIDevice *dev, unsigned int vector);
42e4c7d2aeSIsaku Yamahata void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len);
43e4c7d2aeSIsaku Yamahata unsigned int msi_nr_vectors_allocated(const PCIDevice *dev);
44e4c7d2aeSIsaku Yamahata 
45e4c7d2aeSIsaku Yamahata static inline bool msi_present(const PCIDevice *dev)
46e4c7d2aeSIsaku Yamahata {
47e4c7d2aeSIsaku Yamahata     return dev->cap_present & QEMU_PCI_CAP_MSI;
48e4c7d2aeSIsaku Yamahata }
49e4c7d2aeSIsaku Yamahata 
50e4c7d2aeSIsaku Yamahata #endif /* QEMU_MSI_H */
51