static int acpi_button_probe(device_t dev) { struct acpi_button_softc *sc; char *str; if (acpi_disabled("button") || (str = ACPI_ID_PROBE(device_get_parent(dev), dev, btn_ids)) == NULL) return (ENXIO); sc = device_get_softc(dev); if (strcmp(str, "PNP0C0C") == 0) { device_set_desc(dev, "Power Button"); sc->button_type = ACPI_POWER_BUTTON; } else if (strcmp(str, "ACPI_FPB") == 0) { device_set_desc(dev, "Power Button (fixed)"); sc->button_type = ACPI_POWER_BUTTON; sc->fixed = 1; } else if (strcmp(str, "PNP0C0E") == 0) { device_set_desc(dev, "Sleep Button"); sc->button_type = ACPI_SLEEP_BUTTON; } else if (strcmp(str, "ACPI_FSB") == 0) { device_set_desc(dev, "Sleep Button (fixed)"); sc->button_type = ACPI_SLEEP_BUTTON; sc->fixed = 1; } return (0); }
/* * Locate the ACPI timer using the FADT, set up and allocate the I/O resources * we will be using. */ static int acpi_timer_identify(driver_t *driver, device_t parent) { device_t dev; /* * Just try once, do nothing if the 'acpi' bus is rescanned. */ if (device_get_state(parent) == DS_ATTACHED) return (0); ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); if (acpi_disabled("timer") || (acpi_quirks & ACPI_Q_TIMER) || acpi_timer_dev) return (ENXIO); if ((dev = BUS_ADD_CHILD(parent, parent, 0, "acpi_timer", 0)) == NULL) { device_printf(parent, "could not add acpi_timer0\n"); return (ENXIO); } acpi_timer_dev = dev; return (0); }
static int acpi_cpu_cst_probe(device_t dev) { int cpu_id; if (acpi_disabled("cpu_cst") || acpi_get_type(dev) != ACPI_TYPE_PROCESSOR) return (ENXIO); cpu_id = acpi_get_magic(dev); if (cpu_softc == NULL) cpu_softc = kmalloc(sizeof(struct acpi_cpu_softc *) * SMP_MAXCPU, M_TEMP /* XXX */, M_INTWAIT | M_ZERO); /* * Check if we already probed this processor. We scan the bus twice * so it's possible we've already seen this one. */ if (cpu_softc[cpu_id] != NULL) { device_printf(dev, "CPU%d cstate already exist\n", cpu_id); return (ENXIO); } /* Mark this processor as in-use and save our derived id for attach. */ cpu_softc[cpu_id] = (void *)1; device_set_desc(dev, "ACPI CPU C-State"); return (0); }
/* * Locate the ACPI timer using the FADT, set up and allocate the I/O resources * we will be using. */ static void acpi_timer_identify(driver_t *driver, device_t parent) { device_t dev; u_long rlen, rstart; int rid, rtype; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); if (acpi_disabled("timer") || (acpi_quirks & ACPI_Q_TIMER) || acpi_timer_dev) return_VOID; if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_timer", 0)) == NULL) { device_printf(parent, "could not add acpi_timer0\n"); return_VOID; } acpi_timer_dev = dev; rid = 0; rtype = AcpiGbl_FADT.XPmTimerBlock.SpaceId ? SYS_RES_IOPORT : SYS_RES_MEMORY; rlen = AcpiGbl_FADT.PmTimerLength; rstart = AcpiGbl_FADT.XPmTimerBlock.Address; if (bus_set_resource(dev, rtype, rid, rstart, rlen)) device_printf(dev, "couldn't set resource (%s 0x%lx+0x%lx)\n", (rtype == SYS_RES_IOPORT) ? "port" : "mem", rstart, rlen); return_VOID; }
static void dmar_identify(driver_t *driver, device_t parent) { ACPI_TABLE_DMAR *dmartbl; ACPI_DMAR_HARDWARE_UNIT *dmarh; ACPI_STATUS status; int i, error; if (acpi_disabled("dmar")) return; TUNABLE_INT_FETCH("hw.dmar.enable", &dmar_enable); if (!dmar_enable) return; #ifdef INVARIANTS TUNABLE_INT_FETCH("hw.dmar.check_free", &dmar_check_free); #endif TUNABLE_INT_FETCH("hw.dmar.match_verbose", &dmar_match_verbose); status = AcpiGetTable(ACPI_SIG_DMAR, 1, (ACPI_TABLE_HEADER **)&dmartbl); if (ACPI_FAILURE(status)) return; haw = dmartbl->Width + 1; if ((1ULL << (haw + 1)) > BUS_SPACE_MAXADDR) dmar_high = BUS_SPACE_MAXADDR; else dmar_high = 1ULL << (haw + 1); if (bootverbose) { printf("DMAR HAW=%d flags=<%b>\n", dmartbl->Width, (unsigned)dmartbl->Flags, "\020\001INTR_REMAP\002X2APIC_OPT_OUT"); } AcpiPutTable((ACPI_TABLE_HEADER *)dmartbl); dmar_iterate_tbl(dmar_count_iter, NULL); if (dmar_devcnt == 0) return; dmar_devs = malloc(sizeof(device_t) * dmar_devcnt, M_DEVBUF, M_WAITOK | M_ZERO); for (i = 0; i < dmar_devcnt; i++) { dmarh = dmar_find_by_index(i); if (dmarh == NULL) { printf("dmar_identify: cannot find HWUNIT %d\n", i); continue; } dmar_devs[i] = BUS_ADD_CHILD(parent, 1, "dmar", i); if (dmar_devs[i] == NULL) { printf("dmar_identify: cannot create instance %d\n", i); continue; } error = bus_set_resource(dmar_devs[i], SYS_RES_MEMORY, DMAR_REG_RID, dmarh->Address, PAGE_SIZE); if (error != 0) { printf( "dmar%d: unable to alloc register window at 0x%08jx: error %d\n", i, (uintmax_t)dmarh->Address, error); device_delete_child(parent, dmar_devs[i]); dmar_devs[i] = NULL; } } }
static int acpi_cpu_probe(device_t dev) { int acpi_id, cpu_id; ACPI_BUFFER buf; ACPI_HANDLE handle; ACPI_OBJECT *obj; ACPI_STATUS status; if (acpi_disabled("cpu") || acpi_get_type(dev) != ACPI_TYPE_PROCESSOR || acpi_cpu_disabled) return (ENXIO); handle = acpi_get_handle(dev); if (cpu_softc == NULL) cpu_softc = malloc(sizeof(struct acpi_cpu_softc *) * (mp_maxid + 1), M_TEMP /* XXX */, M_WAITOK | M_ZERO); /* Get our Processor object. */ buf.Pointer = NULL; buf.Length = ACPI_ALLOCATE_BUFFER; status = AcpiEvaluateObject(handle, NULL, NULL, &buf); if (ACPI_FAILURE(status)) { device_printf(dev, "probe failed to get Processor obj - %s\n", AcpiFormatException(status)); return (ENXIO); } obj = (ACPI_OBJECT *)buf.Pointer; if (obj->Type != ACPI_TYPE_PROCESSOR) { device_printf(dev, "Processor object has bad type %d\n", obj->Type); AcpiOsFree(obj); return (ENXIO); } /* * Find the processor associated with our unit. We could use the * ProcId as a key, however, some boxes do not have the same values * in their Processor object as the ProcId values in the MADT. */ acpi_id = obj->Processor.ProcId; AcpiOsFree(obj); if (acpi_pcpu_get_id(dev, &acpi_id, &cpu_id) != 0) return (ENXIO); /* * Check if we already probed this processor. We scan the bus twice * so it's possible we've already seen this one. */ if (cpu_softc[cpu_id] != NULL) return (ENXIO); /* Mark this processor as in-use and save our derived id for attach. */ cpu_softc[cpu_id] = (void *)1; acpi_set_private(dev, (void*)(intptr_t)cpu_id); device_set_desc(dev, "ACPI CPU"); return (0); }
static int aibs_probe(device_t dev) { if (acpi_disabled("aibs") || ACPI_ID_PROBE(device_get_parent(dev), dev, aibs_hids) == NULL) return ENXIO; device_set_desc(dev, "ASUSTeK AI Booster (ACPI ASOC ATK0110)"); return 0; }
static int acpi_lid_probe(device_t dev) { if ((acpi_get_type(dev) == ACPI_TYPE_DEVICE) && !acpi_disabled("lid") && acpi_MatchHid(dev, "PNP0C0D")) { device_set_desc(dev, "Control Method Lid Switch"); return(0); } return(ENXIO); }
static int acpi_cmbat_probe(device_t dev) { static char *cmbat_ids[] = { "PNP0C0A", NULL }; if (acpi_disabled("cmbat") || ACPI_ID_PROBE(device_get_parent(dev), dev, cmbat_ids) == NULL) return (ENXIO); device_set_desc(dev, "ACPI Control Method Battery"); return (0); }
static int intelspi_probe(device_t dev) { static char *gpio_ids[] = { "80860F0E", NULL }; if (acpi_disabled("spi") || ACPI_ID_PROBE(device_get_parent(dev), dev, gpio_ids) == NULL) return (ENXIO); device_set_desc(dev, "Intel SPI Controller"); return (0); }
static int acpi_acad_probe(device_t dev) { static char *acad_ids[] = { "ACPI0003", NULL }; if (acpi_disabled("acad") || ACPI_ID_PROBE(device_get_parent(dev), dev, acad_ids) == NULL) return (ENXIO); device_set_desc(dev, "AC Adapter"); return (0); }
static int bytgpio_probe(device_t dev) { static char *gpio_ids[] = { "INT33FC", NULL }; if (acpi_disabled("gpio") || ACPI_ID_PROBE(device_get_parent(dev), dev, gpio_ids) == NULL) return (ENXIO); device_set_desc(dev, "Intel Baytrail GPIO Controller"); return (0); }
static int acpi_lid_probe(device_t dev) { static char *lid_ids[] = { "PNP0C0D", NULL }; if (acpi_disabled("lid") || ACPI_ID_PROBE(device_get_parent(dev), dev, lid_ids) == NULL) return (ENXIO); device_set_desc(dev, "Control Method Lid Switch"); return (0); }
static int acpi_tz_probe(device_t dev) { int result; if (acpi_get_type(dev) == ACPI_TYPE_THERMAL && !acpi_disabled("thermal")) { device_set_desc(dev, "Thermal Zone"); result = -10; } else result = ENXIO; return (result); }
static int acpi_isab_probe(device_t dev) { static char *isa_ids[] = { "PNP0A05", "PNP0A06", NULL }; if (acpi_disabled("isab") || ACPI_ID_PROBE(device_get_parent(dev), dev, isa_ids) == NULL || devclass_get_device(isab_devclass, 0) != dev) return (ENXIO); device_set_desc(dev, "ACPI Generic ISA bridge"); return (0); }
static int acpi_sysres_probe(device_t dev) { static char *sysres_ids[] = { "PNP0C01", "PNP0C02", NULL }; if (acpi_disabled("sysresource") || ACPI_ID_PROBE(device_get_parent(dev), dev, sysres_ids) == NULL) return (ENXIO); device_set_desc(dev, "System Resource"); device_quiet(dev); return (BUS_PROBE_DEFAULT); }
static int acpi_panasonic_probe(device_t dev) { static char *mat_ids[] = { "MAT0019", NULL }; if (acpi_disabled("panasonic") || ACPI_ID_PROBE(device_get_parent(dev), dev, mat_ids) == NULL || device_get_unit(dev) != 0) return (ENXIO); device_set_desc(dev, "Panasonic Notebook Hotkeys"); return (0); }
static int acpi_syscont_probe(device_t dev) { static char *syscont_ids[] = { "ACPI0004", "PNP0A05", "PNP0A06", NULL }; int rv; if (acpi_disabled("syscontainer")) return (ENXIO); rv = ACPI_ID_PROBE(device_get_parent(dev), dev, syscont_ids, NULL); if (rv <= 0) device_set_desc(dev, "System Container"); return (rv); }
static int ig4iic_acpi_probe(device_t dev) { if (acpi_disabled("ig4iic") || ACPI_ID_PROBE(device_get_parent(dev), dev, ig4iic_ids) == NULL) return (ENXIO); device_set_desc(dev, "Intel SoC I2C Controller"); return (BUS_PROBE_DEFAULT); }
static int acpi_pcib_acpi_probe(device_t dev) { static char *pcib_ids[] = { "PNP0A03", NULL }; if (acpi_disabled("pcib") || ACPI_ID_PROBE(device_get_parent(dev), dev, pcib_ids) == NULL) return (ENXIO); if (pci_cfgregopen() == 0) return (ENXIO); device_set_desc(dev, "ACPI Host-PCI bridge"); return (0); }
static int acpi_cpu_probe(device_t dev) { int acpi_id, cpu_id; ACPI_BUFFER buf; ACPI_HANDLE handle; ACPI_STATUS status; ACPI_OBJECT *obj; if (acpi_disabled("cpu") || acpi_get_type(dev) != ACPI_TYPE_PROCESSOR) return ENXIO; handle = acpi_get_handle(dev); /* * Get our Processor object. */ buf.Pointer = NULL; buf.Length = ACPI_ALLOCATE_BUFFER; status = AcpiEvaluateObject(handle, NULL, NULL, &buf); if (ACPI_FAILURE(status)) { device_printf(dev, "probe failed to get Processor obj - %s\n", AcpiFormatException(status)); return ENXIO; } obj = (ACPI_OBJECT *)buf.Pointer; if (obj->Type != ACPI_TYPE_PROCESSOR) { device_printf(dev, "Processor object has bad type %d\n", obj->Type); AcpiOsFree(obj); return ENXIO; } acpi_id = obj->Processor.ProcId; AcpiOsFree(obj); /* * Find the processor associated with our unit. We could use the * ProcId as a key, however, some boxes do not have the same values * in their Processor object as the ProcId values in the MADT. */ if (acpi_cpu_get_id(device_get_unit(dev), &acpi_id, &cpu_id) != 0) return ENXIO; acpi_set_magic(dev, cpu_id); device_set_desc(dev, "ACPI CPU"); return 0; }
static int acpi_cmbat_probe(device_t dev) { if ((acpi_get_type(dev) == ACPI_TYPE_DEVICE) && !acpi_disabled("cmbat") && acpi_MatchHid(dev, "PNP0C0A")) { /* * Set device description. */ device_set_desc(dev, "Control method Battery"); return (0); } return (ENXIO); }
static int acpi_smbat_probe(device_t dev) { static char *smbat_ids[] = {"ACPI0001", "ACPI0005", NULL}; ACPI_STATUS status; if (acpi_disabled("smbat") || ACPI_ID_PROBE(device_get_parent(dev), dev, smbat_ids) == NULL) return (ENXIO); status = AcpiEvaluateObject(acpi_get_handle(dev), "_EC", NULL, NULL); if (ACPI_FAILURE(status)) return (ENXIO); device_set_desc(dev, "ACPI Smart Battery"); return (0); }
static int acpi_fujitsu_probe(device_t dev) { char *name; char buffer[64]; name = ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids); if (acpi_disabled("fujitsu") || name == NULL || device_get_unit(dev) > 1) return (ENXIO); sprintf(buffer, "Fujitsu Function Hotkeys %s", name); device_set_desc_copy(dev, buffer); return (0); }
static int acpi_hpet_probe(device_t dev) { ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__); if (acpi_disabled("hpet")) return ENXIO; if (!DEV_HPET(dev) && (ACPI_ID_PROBE(device_get_parent(dev), dev, hpet_ids) == NULL || device_get_unit(dev) != 0)) return ENXIO; device_set_desc(dev, "High Precision Event Timer"); return 0; }
static int acpi_pcib_pci_probe(device_t dev) { if (pci_get_class(dev) != PCIC_BRIDGE || pci_get_subclass(dev) != PCIS_BRIDGE_PCI || acpi_disabled("pci")) return (ENXIO); if (acpi_get_handle(dev) == NULL) return (ENXIO); if (pci_cfgregopen() == 0) return (ENXIO); device_set_desc(dev, "ACPI PCI-PCI bridge"); return (-1000); }
int ipmi_acpi_probe(device_t dev) { static char *ipmi_ids[] = {"IPI0001", NULL}; if (ipmi_attached) return (EBUSY); if (acpi_disabled("ipmi") || ACPI_ID_PROBE(device_get_parent(dev), dev, ipmi_ids) == NULL) return (ENXIO); device_set_desc(dev, "IPMI System Interface"); return (0); }
static int acpi_pcib_pci_probe(device_t dev) { int error; if (pci_get_class(dev) != PCIC_BRIDGE || pci_get_subclass(dev) != PCIS_BRIDGE_PCI || acpi_disabled("pci")) return (ENXIO); error = acpi_pcib_probe(dev); if (error) return (error); device_set_desc(dev, "ACPI PCI-PCI bridge"); return (-100); }
/* * We could setup resources in the probe routine in order to have them printed * when the device is attached. */ static int acpi_ec_probe(device_t dev) { if ((acpi_get_type(dev) == ACPI_TYPE_DEVICE) && !acpi_disabled("ec") && acpi_MatchHid(dev, "PNP0C09")) { /* * Set device description */ device_set_desc(dev, "embedded controller"); return(0); } return(ENXIO); }
/* * Locate the ACPI timer using the FADT, set up and allocate the I/O resources * we will be using. */ static int acpi_timer_identify(driver_t *driver, device_t parent) { device_t dev; u_long rlen, rstart; int rid, rtype; /* * Just try once, do nothing if the 'acpi' bus is rescanned. */ if (device_get_state(parent) == DS_ATTACHED) return (0); ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); if (acpi_disabled("timer") || (acpi_quirks & ACPI_Q_TIMER) || acpi_timer_dev) return (ENXIO); if ((dev = BUS_ADD_CHILD(parent, parent, 0, "acpi_timer", 0)) == NULL) { device_printf(parent, "could not add acpi_timer0\n"); return (ENXIO); } acpi_timer_dev = dev; switch (AcpiGbl_FADT.XPmTimerBlock.SpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: rtype = SYS_RES_MEMORY; break; case ACPI_ADR_SPACE_SYSTEM_IO: rtype = SYS_RES_IOPORT; break; default: return (ENXIO); } rid = 0; rlen = AcpiGbl_FADT.PmTimerLength; rstart = AcpiGbl_FADT.XPmTimerBlock.Address; if (bus_set_resource(dev, rtype, rid, rstart, rlen, -1)) { device_printf(dev, "couldn't set resource (%s 0x%lx+0x%lx)\n", (rtype == SYS_RES_IOPORT) ? "port" : "mem", rstart, rlen); return (ENXIO); } return (0); }