summaryrefslogtreecommitdiff
path: root/hw/spapr.c
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2012-08-07 16:10:34 +0000
committerAlexander Graf <agraf@suse.de>2012-08-15 19:43:16 +0200
commitf4b9523ba6388f6f951933de3f9a76e2e9ea2ede (patch)
treeaef6991b1560973392e43e63a59b306395e27793 /hw/spapr.c
parentfa28f71b4a88cdb796f1e0a308205c6be604d3f3 (diff)
downloadqemu-f4b9523ba6388f6f951933de3f9a76e2e9ea2ede.zip
pseries: added allocator for a block of IRQs
The patch adds a simple helper which allocates a consecutive sequence of IRQs calling spapr_allocate_irq for each and checks that allocated IRQs go consequently. The patch is required for upcoming support of MSI/MSIX on POWER. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw/spapr.c')
-rw-r--r--hw/spapr.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/hw/spapr.c b/hw/spapr.c
index 8153c05636..afbdbc586e 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -105,6 +105,32 @@ int spapr_allocate_irq(int hint, enum xics_irq_type type)
return irq;
}
+/* Allocate block of consequtive IRQs, returns a number of the first */
+int spapr_allocate_irq_block(int num, enum xics_irq_type type)
+{
+ int first = -1;
+ int i;
+
+ for (i = 0; i < num; ++i) {
+ int irq;
+
+ irq = spapr_allocate_irq(0, type);
+ if (!irq) {
+ return -1;
+ }
+
+ if (0 == i) {
+ first = irq;
+ }
+
+ /* If the above doesn't create a consecutive block then that's
+ * an internal bug */
+ assert(irq == (first + i));
+ }
+
+ return first;
+}
+
static int spapr_set_associativity(void *fdt, sPAPREnvironment *spapr)
{
int ret = 0, offset;