From bff3c41c4de5c9e27a10a8b95fa0a86378ee07b7 Mon Sep 17 00:00:00 2001 From: NicJA Date: Fri, 3 Mar 2017 02:17:15 +0000 Subject: [PATCH] try to allocate the requested block. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@54026 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/all-pc/kernel/apic_msi.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/all-pc/kernel/apic_msi.c b/arch/all-pc/kernel/apic_msi.c index dd84414795..905f7f093d 100644 --- a/arch/all-pc/kernel/apic_msi.c +++ b/arch/all-pc/kernel/apic_msi.c @@ -25,7 +25,7 @@ ULONG core_APIC_AllocMSI(ULONG count) apicid_t cpuNo = KrnGetCPUNumber(); apicidt_t *IGATES = (apicidt_t *)apicPrivate->cores[cpuNo].cpu_IDT; ULONG msiID = APIC_MSI_BASE; - int cpuIRQ = 0, irq; + int startIRQ = -1, cpuIRQ = -1, irq; D(bug("[APIC:MSI] %s()\n")); @@ -33,19 +33,25 @@ ULONG core_APIC_AllocMSI(ULONG count) { if (KERNELIRQ_LIST(irq).lh_Type == APICInt_IntrController.ic_Node.ln_Type) { - if (!IGATES[HW_IRQ_BASE + irq].p) + if (startIRQ == -1) + startIRQ = HW_IRQ_BASE + irq; + else if ((HW_IRQ_BASE + irq) == (startIRQ + count)) { - IGATES[HW_IRQ_BASE + irq].p = 1; - cpuIRQ = HW_IRQ_BASE + irq; + cpuIRQ = startIRQ; break; } } + else + cpuIRQ = -1; } - if (cpuIRQ != 0) + if (cpuIRQ != -1) { msiID += ((cpuNo << 8) | (cpuIRQ)); - D(bug("[APIC:MSI] %s: New MSI IRQ ID = %d\n", __func__, (int)msiID)); + for (irq = cpuIRQ; irq < (cpuIRQ + count); irq++) + IGATES[irq].p = 1; + + D(bug("[APIC:MSI] %s: New MSI IRQ ID Base = %d, for %d IRQs\n", __func__, (int)msiID, count)); } else msiID = (ULONG)-1; -- 2.11.4.GIT