From owner-svn-src-all@FreeBSD.ORG Mon Aug 4 08:58:51 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 61461A94 for ; Mon, 4 Aug 2014 08:58:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 418172836 for ; Mon, 4 Aug 2014 08:58:51 +0000 (UTC) Received: from royger (uid 1332) (envelope-from royger@FreeBSD.org) id 5c85 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Mon, 04 Aug 2014 08:58:51 +0000 From: Roger Pau Monné Date: Mon, 4 Aug 2014 08:58:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r269512 - in head/sys/x86: acpica include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53df4b4b.5c85.6bb31891@svn.freebsd.org> X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Aug 2014 08:58:51 -0000 Author: royger Date: Mon Aug 4 08:58:50 2014 New Revision: 269512 URL: http://svnweb.freebsd.org/changeset/base/269512 Log: x86/madt: make the interrupt override parser a public function Split a portion of the code in madt_parse_interrupt_override to a separate function, that is public and can be used from other code. This will be needed by the Xen port, since FreeBSD needs to parse the interrupt overrides and notify Xen about them. This commit should not introduce any functional change. Sponsored by: Citrix Systems R&D Reviewed by: jhb, gibbs x86/acpica/madt.c: - Introduce madt_parse_interrupt_values() that parses the intr information from ACPI and returns the triggering and the polarity. This is a subset of the functionality that used to be part of madt_parse_interrupt_override(). - Make madt_found_sci_override a global variable that can be used from other files. x86/include/acpica_machdep.h: - Prototype of madt_parse_interrupt_values. - Extern declaration of madt_found_sci_override. Modified: head/sys/x86/acpica/madt.c head/sys/x86/include/acpica_machdep.h Modified: head/sys/x86/acpica/madt.c ============================================================================== --- head/sys/x86/acpica/madt.c Mon Aug 4 08:56:20 2014 (r269511) +++ head/sys/x86/acpica/madt.c Mon Aug 4 08:58:50 2014 (r269512) @@ -57,7 +57,7 @@ static struct lapic_info { u_int la_acpi_id:8; } lapics[MAX_APIC_ID + 1]; -static int madt_found_sci_override; +int madt_found_sci_override; static ACPI_TABLE_MADT *madt; static vm_paddr_t madt_physaddr; static vm_offset_t madt_length; @@ -380,41 +380,27 @@ madt_find_interrupt(int intr, void **api return (0); } -/* - * Parse an interrupt source override for an ISA interrupt. - */ -static void -madt_parse_interrupt_override(ACPI_MADT_INTERRUPT_OVERRIDE *intr) +void +madt_parse_interrupt_values(void *entry, + enum intr_trigger *trig, enum intr_polarity *pol) { - void *new_ioapic, *old_ioapic; - u_int new_pin, old_pin; - enum intr_trigger trig; - enum intr_polarity pol; + ACPI_MADT_INTERRUPT_OVERRIDE *intr; char buf[64]; - if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->SourceIrq == 0 && - intr->GlobalIrq == 2) { - if (bootverbose) - printf("MADT: Skipping timer override\n"); - return; - } + intr = entry; + if (bootverbose) printf("MADT: Interrupt override: source %u, irq %u\n", intr->SourceIrq, intr->GlobalIrq); KASSERT(intr->Bus == 0, ("bus for interrupt overrides must be zero")); - if (madt_find_interrupt(intr->GlobalIrq, &new_ioapic, &new_pin) != 0) { - printf("MADT: Could not find APIC for vector %u (IRQ %u)\n", - intr->GlobalIrq, intr->SourceIrq); - return; - } /* * Lookup the appropriate trigger and polarity modes for this * entry. */ - trig = interrupt_trigger(intr->IntiFlags, intr->SourceIrq); - pol = interrupt_polarity(intr->IntiFlags, intr->SourceIrq); - + *trig = interrupt_trigger(intr->IntiFlags, intr->SourceIrq); + *pol = interrupt_polarity(intr->IntiFlags, intr->SourceIrq); + /* * If the SCI is identity mapped but has edge trigger and * active-hi polarity or the force_sci_lo tunable is set, @@ -424,29 +410,56 @@ madt_parse_interrupt_override(ACPI_MADT_ madt_found_sci_override = 1; if (getenv_string("hw.acpi.sci.trigger", buf, sizeof(buf))) { if (tolower(buf[0]) == 'e') - trig = INTR_TRIGGER_EDGE; + *trig = INTR_TRIGGER_EDGE; else if (tolower(buf[0]) == 'l') - trig = INTR_TRIGGER_LEVEL; + *trig = INTR_TRIGGER_LEVEL; else panic( "Invalid trigger %s: must be 'edge' or 'level'", buf); printf("MADT: Forcing SCI to %s trigger\n", - trig == INTR_TRIGGER_EDGE ? "edge" : "level"); + *trig == INTR_TRIGGER_EDGE ? "edge" : "level"); } if (getenv_string("hw.acpi.sci.polarity", buf, sizeof(buf))) { if (tolower(buf[0]) == 'h') - pol = INTR_POLARITY_HIGH; + *pol = INTR_POLARITY_HIGH; else if (tolower(buf[0]) == 'l') - pol = INTR_POLARITY_LOW; + *pol = INTR_POLARITY_LOW; else panic( "Invalid polarity %s: must be 'high' or 'low'", buf); printf("MADT: Forcing SCI to active %s polarity\n", - pol == INTR_POLARITY_HIGH ? "high" : "low"); + *pol == INTR_POLARITY_HIGH ? "high" : "low"); } } +} + +/* + * Parse an interrupt source override for an ISA interrupt. + */ +static void +madt_parse_interrupt_override(ACPI_MADT_INTERRUPT_OVERRIDE *intr) +{ + void *new_ioapic, *old_ioapic; + u_int new_pin, old_pin; + enum intr_trigger trig; + enum intr_polarity pol; + + if (acpi_quirks & ACPI_Q_MADT_IRQ0 && intr->SourceIrq == 0 && + intr->GlobalIrq == 2) { + if (bootverbose) + printf("MADT: Skipping timer override\n"); + return; + } + + if (madt_find_interrupt(intr->GlobalIrq, &new_ioapic, &new_pin) != 0) { + printf("MADT: Could not find APIC for vector %u (IRQ %u)\n", + intr->GlobalIrq, intr->SourceIrq); + return; + } + + madt_parse_interrupt_values(intr, &trig, &pol); /* Remap the IRQ if it is mapped to a different interrupt vector. */ if (intr->SourceIrq != intr->GlobalIrq) { Modified: head/sys/x86/include/acpica_machdep.h ============================================================================== --- head/sys/x86/include/acpica_machdep.h Mon Aug 4 08:56:20 2014 (r269511) +++ head/sys/x86/include/acpica_machdep.h Mon Aug 4 08:58:50 2014 (r269512) @@ -69,11 +69,18 @@ int acpi_release_global_lock(volatile ui (Acq) = acpi_release_global_lock(&((GLptr)->GlobalLock)); \ } while (0) +enum intr_trigger; +enum intr_polarity; + void acpi_SetDefaultIntrModel(int model); void acpi_cpu_c1(void); void *acpi_map_table(vm_paddr_t pa, const char *sig); void acpi_unmap_table(void *table); vm_paddr_t acpi_find_table(const char *sig); +void madt_parse_interrupt_values(void *entry, + enum intr_trigger *trig, enum intr_polarity *pol); + +extern int madt_found_sci_override; #endif /* _KERNEL */