Count the number of GIC redistributors in the ACPI tables. The GICv3 driver

needs this to allocate memory, and connect the CPUs to the interrupt
controller.

Sponsored by:	DARPA, AFRL
Sponsored by:	Cavium (Hardware)
This commit is contained in:
andrew 2018-02-28 15:25:47 +00:00
parent 36b410d9ac
commit 92b7e35d58

View File

@ -206,6 +206,41 @@ gic_v3_acpi_probe(device_t dev)
return (BUS_PROBE_NOWILDCARD);
}
static void
madt_count_redistrib(ACPI_SUBTABLE_HEADER *entry, void *arg)
{
struct gic_v3_softc *sc = arg;
if (entry->Type == ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR)
sc->gic_redists.nregions++;
}
static int
gic_v3_acpi_count_regions(device_t dev)
{
struct gic_v3_softc *sc;
ACPI_TABLE_MADT *madt;
vm_paddr_t physaddr;
sc = device_get_softc(dev);
physaddr = acpi_find_table(ACPI_SIG_MADT);
if (physaddr == 0)
return (ENXIO);
madt = acpi_map_table(physaddr, ACPI_SIG_MADT);
if (madt == NULL) {
device_printf(dev, "Unable to map the MADT\n");
return (ENXIO);
}
acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length,
madt_count_redistrib, sc);
acpi_unmap_table(madt);
return (sc->gic_redists.nregions > 0 ? 0 : ENXIO);
}
static int
gic_v3_acpi_attach(device_t dev)
{
@ -216,8 +251,9 @@ gic_v3_acpi_attach(device_t dev)
sc->dev = dev;
sc->gic_bus = GIC_BUS_ACPI;
/* TODO: Count these correctly */
sc->gic_redists.nregions = 1;
err = gic_v3_acpi_count_regions(dev);
if (err != 0)
goto error;
err = gic_v3_attach(dev);
if (err != 0)