Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Aug 2014 08:58:51 +0000 (UTC)
From:      Roger Pau Monné <royger@FreeBSD.org>
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
Message-ID:  <53df4b4b.5c85.6bb31891@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53df4b4b.5c85.6bb31891>