static void mpt_set_options(struct mpt_softc *mpt) { int bitmap; bitmap = 0; if (kgetenv_int("mpt_disable", &bitmap)) { if (bitmap & (1 << mpt->unit)) { mpt->disabled = 1; } } bitmap = 0; if (kgetenv_int("mpt_debug", &bitmap)) { if (bitmap & (1 << mpt->unit)) { mpt->verbose = MPT_PRT_DEBUG; } } bitmap = 0; if (kgetenv_int("mpt_debug1", &bitmap)) { if (bitmap & (1 << mpt->unit)) { mpt->verbose = MPT_PRT_DEBUG1; } } bitmap = 0; if (kgetenv_int("mpt_debug2", &bitmap)) { if (bitmap & (1 << mpt->unit)) { mpt->verbose = MPT_PRT_DEBUG2; } } bitmap = 0; if (kgetenv_int("mpt_debug3", &bitmap)) { if (bitmap & (1 << mpt->unit)) { mpt->verbose = MPT_PRT_DEBUG3; } } mpt->cfg_role = MPT_ROLE_DEFAULT; bitmap = 0; if (kgetenv_int("mpt_nil_role", &bitmap)) { if (bitmap & (1 << mpt->unit)) { mpt->cfg_role = 0; } mpt->do_cfg_role = 1; } bitmap = 0; if (kgetenv_int("mpt_tgt_role", &bitmap)) { if (bitmap & (1 << mpt->unit)) { mpt->cfg_role |= MPT_ROLE_TARGET; } mpt->do_cfg_role = 1; } bitmap = 0; if (kgetenv_int("mpt_ini_role", &bitmap)) { if (bitmap & (1 << mpt->unit)) { mpt->cfg_role |= MPT_ROLE_INITIATOR; } mpt->do_cfg_role = 1; } mpt->msi_enable = 0; }
static int ioapic_abi_gsi_cpuid(int irq, int gsi) { char envpath[32]; int cpuid = -1; KKASSERT(gsi >= 0); if (irq == 0 || gsi == 0) { KKASSERT(irq >= 0); if (bootverbose) { kprintf("IOAPIC: irq %d, gsi %d -> cpu0 (0)\n", irq, gsi); } return 0; } if (irq >= 0 && irq == acpi_sci_irqno()) { if (bootverbose) { kprintf("IOAPIC: irq %d, gsi %d -> cpu0 (sci)\n", irq, gsi); } return 0; } ksnprintf(envpath, sizeof(envpath), "hw.ioapic.gsi.%d.cpu", gsi); kgetenv_int(envpath, &cpuid); if (cpuid < 0) { if (!ioapic_abi_gsi_balance) { if (irq >= 0 && bootverbose) { kprintf("IOAPIC: irq %d, gsi %d -> cpu0 " "(fixed)\n", irq, gsi); } return 0; } cpuid = gsi % ncpus; if (irq >= 0 && bootverbose) { kprintf("IOAPIC: irq %d, gsi %d -> cpu%d (auto)\n", irq, gsi, cpuid); } } else if (cpuid >= ncpus) { cpuid = ncpus - 1; if (irq >= 0 && bootverbose) { kprintf("IOAPIC: irq %d, gsi %d -> cpu%d (fixup)\n", irq, gsi, cpuid); } } else { if (irq >= 0 && bootverbose) { kprintf("IOAPIC: irq %d, gsi %d -> cpu%d (user)\n", irq, gsi, cpuid); } } return cpuid; }
static void madt_lapic_enum_register(void) { int prio; prio = LAPIC_ENUM_PRIO_MADT; kgetenv_int("hw.madt_lapic_prio", &prio); madt_lapic_enumerator.lapic_prio = prio; lapic_enumerator_register(&madt_lapic_enumerator); }
static void ioapic_abi_initmap(void) { int cpu; kgetenv_int("hw.ioapic.gsi.balance", &ioapic_abi_gsi_balance); kgetenv_int("hw.ioapic.msi_start", &ioapic_abi_msi_start); ioapic_abi_msi_start &= ~0x1f; /* MUST be 32 aligned */ /* * NOTE: ncpus is not ready yet */ for (cpu = 0; cpu < MAXCPU; ++cpu) { int i; for (i = 0; i < IOAPIC_HWI_VECTORS; ++i) { ioapic_irqmaps[cpu][i].im_gsi = -1; ioapic_irqmaps[cpu][i].im_msi_base = -1; } ioapic_irqmaps[cpu][IOAPIC_HWI_SYSCALL].im_type = IOAPIC_IMT_SYSCALL; } }
static void fadt_probe(void) { struct acpi_fadt *fadt; vm_paddr_t fadt_paddr; enum intr_trigger trig; enum intr_polarity pola; int enabled = 1; char *env; fadt_paddr = sdt_search(ACPI_FADT_SIG); if (fadt_paddr == 0) { kprintf("fadt_probe: can't locate FADT\n"); return; } fadt = sdt_sdth_map(fadt_paddr); KKASSERT(fadt != NULL); /* * FADT in ACPI specification 1.0 - 4.0 */ if (fadt->fadt_hdr.sdth_rev < 1 || fadt->fadt_hdr.sdth_rev > 4) { kprintf("fadt_probe: unsupported FADT revision %d\n", fadt->fadt_hdr.sdth_rev); goto back; } if (fadt->fadt_hdr.sdth_len < sizeof(*fadt)) { kprintf("fadt_probe: invalid FADT length %u\n", fadt->fadt_hdr.sdth_len); goto back; } kgetenv_int("hw.acpi.sci.enabled", &enabled); if (!enabled) goto back; acpi_sci_irq = fadt->fadt_sci_int; env = kgetenv("hw.acpi.sci.trigger"); if (env == NULL) goto back; trig = INTR_TRIGGER_CONFORM; if (strcmp(env, "edge") == 0) trig = INTR_TRIGGER_EDGE; else if (strcmp(env, "level") == 0) trig = INTR_TRIGGER_LEVEL; kfreeenv(env); if (trig == INTR_TRIGGER_CONFORM) goto back; env = kgetenv("hw.acpi.sci.polarity"); if (env == NULL) goto back; pola = INTR_POLARITY_CONFORM; if (strcmp(env, "high") == 0) pola = INTR_POLARITY_HIGH; else if (strcmp(env, "low") == 0) pola = INTR_POLARITY_LOW; kfreeenv(env); if (pola == INTR_POLARITY_CONFORM) goto back; acpi_sci_trig = trig; acpi_sci_pola = pola; back: if (acpi_sci_irq >= 0) { FADT_VPRINTF("SCI irq %d, %s/%s\n", acpi_sci_irq, intr_str_trigger(acpi_sci_trig), intr_str_polarity(acpi_sci_pola)); } else { FADT_VPRINTF("SCI is disabled\n"); } sdt_sdth_unmap(&fadt->fadt_hdr); }
static void fadt_probe(void) { ACPI_TABLE_FADT *fadt; vm_paddr_t fadt_paddr; enum intr_trigger trig; enum intr_polarity pola; int enabled = 1; char *env; fadt_paddr = sdt_search(ACPI_SIG_FADT); if (fadt_paddr == 0) { kprintf("fadt_probe: can't locate FADT\n"); return; } fadt = sdt_sdth_map(fadt_paddr); KKASSERT(fadt != NULL); /* * FADT in ACPI specification 1.0 - 6.0 */ if (fadt->Header.Revision < 1 || fadt->Header.Revision > 6) { kprintf("fadt_probe: unknown FADT revision %d\n", fadt->Header.Revision); } if (fadt->Header.Length < ACPI_FADT_V1_SIZE) { kprintf("fadt_probe: invalid FADT length %u (< %u)\n", fadt->Header.Length, ACPI_FADT_V1_SIZE); goto back; } kgetenv_int("hw.acpi.sci.enabled", &enabled); if (!enabled) goto back; acpi_sci_irq = fadt->SciInterrupt; env = kgetenv("hw.acpi.sci.trigger"); if (env == NULL) goto back; trig = INTR_TRIGGER_CONFORM; if (strcmp(env, "edge") == 0) trig = INTR_TRIGGER_EDGE; else if (strcmp(env, "level") == 0) trig = INTR_TRIGGER_LEVEL; kfreeenv(env); if (trig == INTR_TRIGGER_CONFORM) goto back; env = kgetenv("hw.acpi.sci.polarity"); if (env == NULL) goto back; pola = INTR_POLARITY_CONFORM; if (strcmp(env, "high") == 0) pola = INTR_POLARITY_HIGH; else if (strcmp(env, "low") == 0) pola = INTR_POLARITY_LOW; kfreeenv(env); if (pola == INTR_POLARITY_CONFORM) goto back; acpi_sci_trig = trig; acpi_sci_pola = pola; back: if (acpi_sci_irq >= 0) { FADT_VPRINTF("SCI irq %d, %s/%s\n", acpi_sci_irq, intr_str_trigger(acpi_sci_trig), intr_str_polarity(acpi_sci_pola)); } else { FADT_VPRINTF("SCI is disabled\n"); } sdt_sdth_unmap(&fadt->Header); }