FreeBSD/sys/x86/acpica/madt.c
/*
 * Enumerate I/O APICs and setup interrupt sources.
 */
Enumerate I/O APICs and setup interrupt sources.
Enumerate I / O APICs and setup interrupt sources .
static int
madt_setup_io(void)
{
	void *ioapic;
	u_int pin;
	int i;
	i = acpi_Startup();
	if (ACPI_FAILURE(i)) {
		printf("MADT: ACPI Startup failed with %s\n",
		    AcpiFormatException(i));
		printf("Try disabling either ACPI or apic support.\n");
		panic("Using MADT but ACPI doesn't work");
	}
	ioapics = malloc(sizeof(*ioapics) * (MAX_APIC_ID + 1), M_MADT,
	    M_WAITOK | M_ZERO);
	madt_walk_table(madt_parse_apics, NULL);
	madt_walk_table(madt_parse_ints, NULL);
	if (!madt_found_sci_override) {
		if (madt_find_interrupt(AcpiGbl_FADT.SciInterrupt, &ioapic,
		    &pin) != 0)
			printf("MADT: Could not find APIC for SCI IRQ %u\n",
			    AcpiGbl_FADT.SciInterrupt);
		else {
			printf(
	"MADT: Forcing active-low polarity and level trigger for SCI\n");
			ioapic_set_polarity(ioapic, pin, INTR_POLARITY_LOW);
			ioapic_set_triggermode(ioapic, pin, INTR_TRIGGER_LEVEL);
		}
	}
	for (i = 0; i <= MAX_APIC_ID; i++)
		if (ioapics[i].io_apic != NULL)
			ioapic_register(ioapics[i].io_apic);
	acpi_SetDefaultIntrModel(ACPI_INTR_APIC);
	free(ioapics, M_MADT);
	ioapics = NULL;
	return (0);
}
static int madt_setup_io ( void ) { void * ioapic ; u_int pin ; int i ; i = acpi_Startup ( ) ; if ( ACPI_FAILURE ( i ) ) { printf ( " \n " , AcpiFormatException ( i ) ) ; printf ( " \n " ) ; panic ( " " ) ; } ioapics = malloc ( sizeof ( * ioapics ) * ( MAX_APIC_ID + 1 ) , M_MADT , M_WAITOK | M_ZERO ) ; madt_walk_table ( madt_parse_apics , NULL ) ; madt_walk_table ( madt_parse_ints , NULL ) ; if ( ! madt_found_sci_override ) { if ( madt_find_interrupt ( AcpiGbl_FADT . SciInterrupt , & ioapic , & pin ) != 0 ) printf ( " \n " , AcpiGbl_FADT . SciInterrupt ) ; else { printf ( " \n " ) ; ioapic_set_polarity ( ioapic , pin , INTR_POLARITY_LOW ) ; ioapic_set_triggermode ( ioapic , pin , INTR_TRIGGER_LEVEL ) ; } } for ( i = 0 ; i <= MAX_APIC_ID ; i ++ ) if ( ioapics [ i ] . io_apic != NULL ) ioapic_register ( ioapics [ i ] . io_apic ) ; acpi_SetDefaultIntrModel ( ACPI_INTR_APIC ) ; free ( ioapics , M_MADT ) ; ioapics = NULL ; return ( 0 ) ; }
Enumerate I/O APICs and setup interrupt sources.
Enumerate I / O APICs and setup interrupt sources .
/* Try to initialize ACPI so that we can access the FADT. */ /* First, we run through adding I/O APIC's. */ /* Second, we run through the table tweaking interrupt sources. */ /*
	 * If there was not an explicit override entry for the SCI,
	 * force it to use level trigger and active-low polarity.
	 */ /* Third, we register all the I/O APIC's. */ /* Finally, we throw the switch to enable the I/O APIC's. */