2018-07-30 17:11:32 +03:00
|
|
|
/*
|
|
|
|
* QEMU PowerPC sPAPR IRQ backend definitions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2018, IBM Corporation.
|
|
|
|
*
|
|
|
|
* This code is licensed under the GPL version 2 or later. See the
|
|
|
|
* COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HW_SPAPR_IRQ_H
|
|
|
|
#define HW_SPAPR_IRQ_H
|
|
|
|
|
2019-08-12 08:23:31 +03:00
|
|
|
#include "target/ppc/cpu-qom.h"
|
|
|
|
|
2018-07-30 17:11:32 +03:00
|
|
|
/*
|
|
|
|
* IRQ range offsets per device type
|
|
|
|
*/
|
2018-12-12 01:38:12 +03:00
|
|
|
#define SPAPR_IRQ_IPI 0x0
|
2018-07-30 17:11:32 +03:00
|
|
|
|
spapr: Clarify and fix handling of nr_irqs
Both the XICS and XIVE interrupt backends have a "nr-irqs" property, but
it means slightly different things. For XICS (or, strictly, the ICS) it
indicates the number of "real" external IRQs. Those start at XICS_IRQ_BASE
(0x1000) and don't include the special IPI vector. For XIVE, however, it
includes the whole IRQ space, including XIVE's many IPI vectors.
The spapr code currently doesn't handle this sensibly, with the
nr_irqs value in SpaprIrq having different meanings depending on the
backend. We fix this by renaming nr_irqs to nr_xirqs and making it
always indicate just the number of external irqs, adjusting the value
we pass to XIVE accordingly. We also move to using common constants
in most of the irq configurations, to make it clearer that the IRQ
space looks the same to the guest (and emulated devices), even if the
backend is different.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
2019-09-24 03:53:50 +03:00
|
|
|
#define SPAPR_XIRQ_BASE XICS_IRQ_BASE /* 0x1000 */
|
|
|
|
#define SPAPR_IRQ_EPOW (SPAPR_XIRQ_BASE + 0x0000)
|
|
|
|
#define SPAPR_IRQ_HOTPLUG (SPAPR_XIRQ_BASE + 0x0001)
|
|
|
|
#define SPAPR_IRQ_VIO (SPAPR_XIRQ_BASE + 0x0100) /* 256 VIO devices */
|
|
|
|
#define SPAPR_IRQ_PCI_LSI (SPAPR_XIRQ_BASE + 0x0200) /* 32+ PHBs devices */
|
|
|
|
|
|
|
|
/* Offset of the dynamic range covered by the bitmap allocator */
|
|
|
|
#define SPAPR_IRQ_MSI (SPAPR_XIRQ_BASE + 0x0300)
|
|
|
|
|
|
|
|
#define SPAPR_NR_XIRQS 0x1000
|
2018-07-30 17:11:32 +03:00
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 07:35:37 +03:00
|
|
|
typedef struct SpaprMachineState SpaprMachineState;
|
2018-07-30 17:11:32 +03:00
|
|
|
|
2019-09-24 09:25:08 +03:00
|
|
|
typedef struct SpaprInterruptController SpaprInterruptController;
|
|
|
|
|
|
|
|
#define TYPE_SPAPR_INTC "spapr-interrupt-controller"
|
|
|
|
#define SPAPR_INTC(obj) \
|
|
|
|
INTERFACE_CHECK(SpaprInterruptController, (obj), TYPE_SPAPR_INTC)
|
|
|
|
#define SPAPR_INTC_CLASS(klass) \
|
|
|
|
OBJECT_CLASS_CHECK(SpaprInterruptControllerClass, (klass), TYPE_SPAPR_INTC)
|
|
|
|
#define SPAPR_INTC_GET_CLASS(obj) \
|
|
|
|
OBJECT_GET_CLASS(SpaprInterruptControllerClass, (obj), TYPE_SPAPR_INTC)
|
|
|
|
|
|
|
|
typedef struct SpaprInterruptControllerClass {
|
|
|
|
InterfaceClass parent;
|
2019-09-26 07:11:23 +03:00
|
|
|
|
2019-09-26 08:41:39 +03:00
|
|
|
int (*activate)(SpaprInterruptController *intc, Error **errp);
|
|
|
|
void (*deactivate)(SpaprInterruptController *intc);
|
|
|
|
|
2019-09-26 07:11:23 +03:00
|
|
|
/*
|
|
|
|
* These methods will typically be called on all intcs, active and
|
|
|
|
* inactive
|
|
|
|
*/
|
|
|
|
int (*cpu_intc_create)(SpaprInterruptController *intc,
|
|
|
|
PowerPCCPU *cpu, Error **errp);
|
2019-10-22 19:38:10 +03:00
|
|
|
void (*cpu_intc_reset)(SpaprInterruptController *intc, PowerPCCPU *cpu);
|
2019-09-26 07:31:13 +03:00
|
|
|
int (*claim_irq)(SpaprInterruptController *intc, int irq, bool lsi,
|
|
|
|
Error **errp);
|
|
|
|
void (*free_irq)(SpaprInterruptController *intc, int irq);
|
2019-09-26 09:09:46 +03:00
|
|
|
|
|
|
|
/* These methods should only be called on the active intc */
|
|
|
|
void (*set_irq)(SpaprInterruptController *intc, int irq, int val);
|
2019-09-26 09:12:05 +03:00
|
|
|
void (*print_info)(SpaprInterruptController *intc, Monitor *mon);
|
2019-09-30 05:35:06 +03:00
|
|
|
void (*dt)(SpaprInterruptController *intc, uint32_t nr_servers,
|
|
|
|
void *fdt, uint32_t phandle);
|
2019-09-27 03:53:53 +03:00
|
|
|
int (*post_load)(SpaprInterruptController *intc, int version_id);
|
2019-09-24 09:25:08 +03:00
|
|
|
} SpaprInterruptControllerClass;
|
|
|
|
|
2019-09-26 08:41:39 +03:00
|
|
|
void spapr_irq_update_active_intc(SpaprMachineState *spapr);
|
|
|
|
|
2019-09-26 07:11:23 +03:00
|
|
|
int spapr_irq_cpu_intc_create(SpaprMachineState *spapr,
|
|
|
|
PowerPCCPU *cpu, Error **errp);
|
2019-10-22 19:38:10 +03:00
|
|
|
void spapr_irq_cpu_intc_reset(SpaprMachineState *spapr, PowerPCCPU *cpu);
|
2019-09-26 09:12:05 +03:00
|
|
|
void spapr_irq_print_info(SpaprMachineState *spapr, Monitor *mon);
|
2019-09-30 05:35:06 +03:00
|
|
|
void spapr_irq_dt(SpaprMachineState *spapr, uint32_t nr_servers,
|
|
|
|
void *fdt, uint32_t phandle);
|
2019-09-26 07:11:23 +03:00
|
|
|
|
2019-09-27 06:44:58 +03:00
|
|
|
uint32_t spapr_irq_nr_msis(SpaprMachineState *spapr);
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 07:35:37 +03:00
|
|
|
int spapr_irq_msi_alloc(SpaprMachineState *spapr, uint32_t num, bool align,
|
2018-07-30 17:11:32 +03:00
|
|
|
Error **errp);
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 07:35:37 +03:00
|
|
|
void spapr_irq_msi_free(SpaprMachineState *spapr, int irq, uint32_t num);
|
2018-07-30 17:11:32 +03:00
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 07:35:37 +03:00
|
|
|
typedef struct SpaprIrq {
|
2019-09-25 08:12:07 +03:00
|
|
|
bool xics;
|
|
|
|
bool xive;
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 07:35:37 +03:00
|
|
|
} SpaprIrq;
|
2018-07-30 17:11:33 +03:00
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 07:35:37 +03:00
|
|
|
extern SpaprIrq spapr_irq_xics;
|
|
|
|
extern SpaprIrq spapr_irq_xics_legacy;
|
|
|
|
extern SpaprIrq spapr_irq_xive;
|
|
|
|
extern SpaprIrq spapr_irq_dual;
|
2018-07-30 17:11:33 +03:00
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 07:35:37 +03:00
|
|
|
void spapr_irq_init(SpaprMachineState *spapr, Error **errp);
|
|
|
|
int spapr_irq_claim(SpaprMachineState *spapr, int irq, bool lsi, Error **errp);
|
|
|
|
void spapr_irq_free(SpaprMachineState *spapr, int irq, int num);
|
|
|
|
qemu_irq spapr_qirq(SpaprMachineState *spapr, int irq);
|
|
|
|
int spapr_irq_post_load(SpaprMachineState *spapr, int version_id);
|
|
|
|
void spapr_irq_reset(SpaprMachineState *spapr, Error **errp);
|
|
|
|
int spapr_irq_get_phandle(SpaprMachineState *spapr, void *fdt, Error **errp);
|
2019-09-26 16:58:36 +03:00
|
|
|
int spapr_irq_init_kvm(int (*fn)(SpaprInterruptController *, Error **),
|
|
|
|
SpaprInterruptController *intc,
|
|
|
|
Error **errp);
|
2018-07-30 17:11:33 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XICS legacy routines
|
|
|
|
*/
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 07:35:37 +03:00
|
|
|
int spapr_irq_find(SpaprMachineState *spapr, int num, bool align, Error **errp);
|
2018-07-30 17:11:33 +03:00
|
|
|
#define spapr_irq_findone(spapr, errp) spapr_irq_find(spapr, 1, false, errp)
|
|
|
|
|
2018-07-30 17:11:32 +03:00
|
|
|
#endif
|