xref: /qemu/include/hw/ppc/spapr_xive.h (revision 7a5fd9343d758d077b6f783d02aa30d9789c4989)
13aa597f6SCédric Le Goater /*
23aa597f6SCédric Le Goater  * QEMU PowerPC sPAPR XIVE interrupt controller model
33aa597f6SCédric Le Goater  *
43aa597f6SCédric Le Goater  * Copyright (c) 2017-2018, IBM Corporation.
53aa597f6SCédric Le Goater  *
63aa597f6SCédric Le Goater  * This code is licensed under the GPL version 2 or later. See the
73aa597f6SCédric Le Goater  * COPYING file in the top-level directory.
83aa597f6SCédric Le Goater  */
93aa597f6SCédric Le Goater 
103aa597f6SCédric Le Goater #ifndef PPC_SPAPR_XIVE_H
113aa597f6SCédric Le Goater #define PPC_SPAPR_XIVE_H
123aa597f6SCédric Le Goater 
13ec150c7eSMarkus Armbruster #include "hw/ppc/spapr_irq.h"
143aa597f6SCédric Le Goater #include "hw/ppc/xive.h"
153aa597f6SCédric Le Goater 
163aa597f6SCédric Le Goater #define TYPE_SPAPR_XIVE "spapr-xive"
17ce2918cbSDavid Gibson #define SPAPR_XIVE(obj) OBJECT_CHECK(SpaprXive, (obj), TYPE_SPAPR_XIVE)
186cc64796SGreg Kurz #define SPAPR_XIVE_CLASS(klass)                                         \
196cc64796SGreg Kurz     OBJECT_CLASS_CHECK(SpaprXiveClass, (klass), TYPE_SPAPR_XIVE)
206cc64796SGreg Kurz #define SPAPR_XIVE_GET_CLASS(obj)                               \
216cc64796SGreg Kurz     OBJECT_GET_CLASS(SpaprXiveClass, (obj), TYPE_SPAPR_XIVE)
223aa597f6SCédric Le Goater 
23ce2918cbSDavid Gibson typedef struct SpaprXive {
243aa597f6SCédric Le Goater     XiveRouter    parent;
253aa597f6SCédric Le Goater 
263aa597f6SCédric Le Goater     /* Internal interrupt source for IPIs and virtual devices */
273aa597f6SCédric Le Goater     XiveSource    source;
283aa597f6SCédric Le Goater     hwaddr        vc_base;
293aa597f6SCédric Le Goater 
303aa597f6SCédric Le Goater     /* END ESB MMIOs */
313aa597f6SCédric Le Goater     XiveENDSource end_source;
323aa597f6SCédric Le Goater     hwaddr        end_base;
333aa597f6SCédric Le Goater 
34743ed566SGreg Kurz     /* DT */
35743ed566SGreg Kurz     gchar *nodename;
36743ed566SGreg Kurz 
373aa597f6SCédric Le Goater     /* Routing table */
383aa597f6SCédric Le Goater     XiveEAS       *eat;
393aa597f6SCédric Le Goater     uint32_t      nr_irqs;
403aa597f6SCédric Le Goater     XiveEND       *endt;
413aa597f6SCédric Le Goater     uint32_t      nr_ends;
423aa597f6SCédric Le Goater 
433aa597f6SCédric Le Goater     /* TIMA mapping address */
443aa597f6SCédric Le Goater     hwaddr        tm_base;
453aa597f6SCédric Le Goater     MemoryRegion  tm_mmio;
4638afd772SCédric Le Goater 
4738afd772SCédric Le Goater     /* KVM support */
4838afd772SCédric Le Goater     int           fd;
4938afd772SCédric Le Goater     void          *tm_mmap;
50981b1c62SCédric Le Goater     MemoryRegion  tm_mmio_kvm;
519b88cd76SCédric Le Goater     VMChangeStateEntry *change;
52*4f311a70SCédric Le Goater 
53*4f311a70SCédric Le Goater     uint8_t       hv_prio;
54ce2918cbSDavid Gibson } SpaprXive;
553aa597f6SCédric Le Goater 
566cc64796SGreg Kurz typedef struct SpaprXiveClass {
576cc64796SGreg Kurz     XiveRouterClass parent;
586cc64796SGreg Kurz 
596cc64796SGreg Kurz     DeviceRealize parent_realize;
606cc64796SGreg Kurz } SpaprXiveClass;
616cc64796SGreg Kurz 
627bfc759cSCédric Le Goater /*
637bfc759cSCédric Le Goater  * The sPAPR machine has a unique XIVE IC device. Assign a fixed value
647bfc759cSCédric Le Goater  * to the controller block id value. It can nevertheless be changed
657bfc759cSCédric Le Goater  * for testing purpose.
667bfc759cSCédric Le Goater  */
677bfc759cSCédric Le Goater #define SPAPR_XIVE_BLOCK_ID 0x0
687bfc759cSCédric Le Goater 
6982d1e74fSEduardo Habkost struct SpaprMachineState;
7082d1e74fSEduardo Habkost void spapr_xive_hcall_init(struct SpaprMachineState *spapr);
71ce2918cbSDavid Gibson void spapr_xive_mmio_set_enabled(SpaprXive *xive, bool enable);
7238afd772SCédric Le Goater void spapr_xive_map_mmio(SpaprXive *xive);
7338afd772SCédric Le Goater 
740c575703SCédric Le Goater int spapr_xive_end_to_target(uint8_t end_blk, uint32_t end_idx,
750c575703SCédric Le Goater                              uint32_t *out_server, uint8_t *out_prio);
760c575703SCédric Le Goater 
7738afd772SCédric Le Goater /*
7838afd772SCédric Le Goater  * KVM XIVE device helpers
7938afd772SCédric Le Goater  */
804ffb7496SGreg Kurz int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
814ffb7496SGreg Kurz                         Error **errp);
8298a39a79SDavid Gibson void kvmppc_xive_disconnect(SpaprInterruptController *intc);
830c575703SCédric Le Goater void kvmppc_xive_reset(SpaprXive *xive, Error **errp);
84d55daadcSGreg Kurz int kvmppc_xive_set_source_config(SpaprXive *xive, uint32_t lisn, XiveEAS *eas,
850c575703SCédric Le Goater                                   Error **errp);
860c575703SCédric Le Goater void kvmppc_xive_sync_source(SpaprXive *xive, uint32_t lisn, Error **errp);
870c575703SCédric Le Goater uint64_t kvmppc_xive_esb_rw(XiveSource *xsrc, int srcno, uint32_t offset,
880c575703SCédric Le Goater                             uint64_t data, bool write);
89f9a548edSGreg Kurz int kvmppc_xive_set_queue_config(SpaprXive *xive, uint8_t end_blk,
900c575703SCédric Le Goater                                  uint32_t end_idx, XiveEND *end,
910c575703SCédric Le Goater                                  Error **errp);
92f9a548edSGreg Kurz int kvmppc_xive_get_queue_config(SpaprXive *xive, uint8_t end_blk,
930c575703SCédric Le Goater                                  uint32_t end_idx, XiveEND *end,
940c575703SCédric Le Goater                                  Error **errp);
957bfc759cSCédric Le Goater void kvmppc_xive_synchronize_state(SpaprXive *xive, Error **errp);
96277dd3d7SCédric Le Goater int kvmppc_xive_pre_save(SpaprXive *xive);
97277dd3d7SCédric Le Goater int kvmppc_xive_post_load(SpaprXive *xive, int version_id);
9823bcd5ebSCédric Le Goater 
993aa597f6SCédric Le Goater #endif /* PPC_SPAPR_XIVE_H */
100