xref: /openbmc/qemu/include/hw/ppc/spapr_irq.h (revision 438c78da)
1 /*
2  * QEMU PowerPC sPAPR IRQ backend definitions
3  *
4  * Copyright (c) 2018, IBM Corporation.
5  *
6  * This code is licensed under the GPL version 2 or later. See the
7  * COPYING file in the top-level directory.
8  */
9 
10 #ifndef HW_SPAPR_IRQ_H
11 #define HW_SPAPR_IRQ_H
12 
13 /*
14  * IRQ range offsets per device type
15  */
16 #define SPAPR_IRQ_EPOW       0x1000  /* XICS_IRQ_BASE offset */
17 #define SPAPR_IRQ_HOTPLUG    0x1001
18 #define SPAPR_IRQ_VIO        0x1100  /* 256 VIO devices */
19 #define SPAPR_IRQ_PCI_LSI    0x1200  /* 32+ PHBs devices */
20 
21 #define SPAPR_IRQ_MSI        0x1300  /* Offset of the dynamic range covered
22                                       * by the bitmap allocator */
23 
24 typedef struct sPAPRMachineState sPAPRMachineState;
25 
26 void spapr_irq_msi_init(sPAPRMachineState *spapr, uint32_t nr_msis);
27 int spapr_irq_msi_alloc(sPAPRMachineState *spapr, uint32_t num, bool align,
28                         Error **errp);
29 void spapr_irq_msi_free(sPAPRMachineState *spapr, int irq, uint32_t num);
30 void spapr_irq_msi_reset(sPAPRMachineState *spapr);
31 
32 typedef struct sPAPRIrq {
33     uint32_t    nr_irqs;
34     uint32_t    nr_msis;
35 
36     void (*init)(sPAPRMachineState *spapr, Error **errp);
37     int (*claim)(sPAPRMachineState *spapr, int irq, bool lsi, Error **errp);
38     void (*free)(sPAPRMachineState *spapr, int irq, int num);
39     qemu_irq (*qirq)(sPAPRMachineState *spapr, int irq);
40     void (*print_info)(sPAPRMachineState *spapr, Monitor *mon);
41 } sPAPRIrq;
42 
43 extern sPAPRIrq spapr_irq_xics;
44 extern sPAPRIrq spapr_irq_xics_legacy;
45 
46 int spapr_irq_claim(sPAPRMachineState *spapr, int irq, bool lsi, Error **errp);
47 void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num);
48 qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq);
49 
50 /*
51  * XICS legacy routines
52  */
53 int spapr_irq_find(sPAPRMachineState *spapr, int num, bool align, Error **errp);
54 #define spapr_irq_findone(spapr, errp) spapr_irq_find(spapr, 1, false, errp)
55 
56 #endif
57