Lines Matching +full:dev +full:- +full:handle

1 /*-
67 #include <contrib/dev/acpica/include/acpi.h>
68 #include <contrib/dev/acpica/include/accommon.h>
69 #include <contrib/dev/acpica/include/acnamesp.h>
71 #include <dev/acpica/acpivar.h>
72 #include <dev/acpica/acpiio.h>
74 #include <dev/pci/pcivar.h>
113 static void acpi_lookup(void *arg, const char *name, device_t *dev);
154 static void acpi_reserve_resources(device_t dev);
155 static int acpi_sysres_alloc(device_t dev);
156 static uint32_t acpi_isa_get_logicalid(device_t dev);
157 static int acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count);
161 static void acpi_platform_osc(device_t dev);
163 static void acpi_probe_order(ACPI_HANDLE handle, int *order);
164 static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level,
172 static int acpi_wake_sleep_prep(ACPI_HANDLE handle, int sstate);
173 static int acpi_wake_run_prep(ACPI_HANDLE handle, int sstate);
175 static int acpi_wake_sysctl_walk(device_t dev);
186 static void acpi_reset_interfaces(device_t dev);
264 acpi_ca_version, 0, "Version of Intel ACPI-CA");
369 * Pre-allocate space for RSDT/XSDT and DSDT tables and allow resizing in acpi_Startup()
382 /* If the user manually set the disabled hint to 0, force-enable ACPI. */ in acpi_Startup()
429 if (rsdp->Revision > 1 && rsdp->XsdtPhysicalAddress != 0) in acpi_identify()
430 paddr = (ACPI_PHYSICAL_ADDRESS)rsdp->XsdtPhysicalAddress; in acpi_identify()
432 paddr = (ACPI_PHYSICAL_ADDRESS)rsdp->RsdtPhysicalAddress; in acpi_identify()
438 sbuf_bcat(&sb, rsdt->OemId, ACPI_OEM_ID_SIZE); in acpi_identify()
441 sbuf_bcat(&sb, rsdt->OemTableId, ACPI_OEM_TABLE_ID_SIZE); in acpi_identify()
456 acpi_probe(device_t dev) in acpi_probe() argument
461 device_set_desc(dev, acpi_desc); in acpi_probe()
467 acpi_attach(device_t dev) in acpi_attach() argument
478 sc = device_get_softc(dev); in acpi_attach()
479 sc->acpi_dev = dev; in acpi_attach()
480 callout_init(&sc->susp_force_to, 1); in acpi_attach()
496 resource_list_init(&sc->sysres_rl); in acpi_attach()
502 * Set the globals from our tunables. This is needed because ACPI-CA in acpi_attach()
518 acpi_reset_interfaces(dev); in acpi_attach()
523 device_printf(dev, "Could not load Namespace: %s\n", in acpi_attach()
528 /* Handle MCFG table if present. */ in acpi_attach()
548 device_printf(dev, "Could not enable ACPI: %s\n", in acpi_attach()
561 acpi_ec_ecdt_probe(dev); in acpi_attach()
565 device_printf(dev, "Could not initialize ACPI objects: %s\n", in acpi_attach()
575 sysctl_ctx_init(&sc->acpi_sysctl_ctx); in acpi_attach()
576 sc->acpi_sysctl_tree = SYSCTL_ADD_NODE(&sc->acpi_sysctl_ctx, in acpi_attach()
577 SYSCTL_STATIC_CHILDREN(_hw), OID_AUTO, device_get_name(dev), in acpi_attach()
579 SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
584 SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
587 &sc->acpi_power_button_sx, 0, acpi_sleep_state_sysctl, "A", in acpi_attach()
589 SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
592 &sc->acpi_sleep_button_sx, 0, acpi_sleep_state_sysctl, "A", in acpi_attach()
594 SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
597 &sc->acpi_lid_switch_sx, 0, acpi_sleep_state_sysctl, "A", in acpi_attach()
599 SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
602 &sc->acpi_standby_sx, 0, acpi_sleep_state_sysctl, "A", ""); in acpi_attach()
603 SYSCTL_ADD_PROC(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
606 &sc->acpi_suspend_sx, 0, acpi_sleep_state_sysctl, "A", ""); in acpi_attach()
607 SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
608 OID_AUTO, "sleep_delay", CTLFLAG_RW, &sc->acpi_sleep_delay, 0, in acpi_attach()
610 SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
611 OID_AUTO, "s4bios", CTLFLAG_RW, &sc->acpi_s4bios, 0, "S4BIOS mode"); in acpi_attach()
612 SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
613 OID_AUTO, "verbose", CTLFLAG_RW, &sc->acpi_verbose, 0, "verbose mode"); in acpi_attach()
614 SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
616 &sc->acpi_do_disable, 0, "Disable ACPI when rebooting/halting system"); in acpi_attach()
617 SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
619 &sc->acpi_handle_reboot, 0, "Use ACPI Reset Register to reboot"); in acpi_attach()
628 SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), in acpi_attach()
631 "Force active-hi polarity for edge-triggered ISA IRQs"); in acpi_attach()
638 sc->acpi_sleep_delay = 1; in acpi_attach()
640 sc->acpi_verbose = 1; in acpi_attach()
643 sc->acpi_verbose = 1; in acpi_attach()
649 sc->acpi_handle_reboot = 1; in acpi_attach()
653 if (AcpiGbl_FACS != NULL && AcpiGbl_FACS->Flags & ACPI_FACS_S4_BIOS_PRESENT) in acpi_attach()
654 sc->acpi_s4bios = 1; in acpi_attach()
669 sc->acpi_power_button_sx = acpi_sleep_states[ACPI_STATE_S5] ? in acpi_attach()
671 sc->acpi_lid_switch_sx = ACPI_STATE_UNKNOWN; in acpi_attach()
672 sc->acpi_standby_sx = acpi_sleep_states[ACPI_STATE_S1] ? in acpi_attach()
674 sc->acpi_suspend_sx = acpi_sleep_states[ACPI_STATE_S3] ? in acpi_attach()
678 sc->acpi_sleep_button_sx = ACPI_STATE_UNKNOWN; in acpi_attach()
681 sc->acpi_sleep_button_sx = state; in acpi_attach()
705 sc->acpi_enabled = TRUE; in acpi_attach()
706 sc->acpi_sstate = ACPI_STATE_S0; in acpi_attach()
707 sc->acpi_sleep_disabled = TRUE; in acpi_attach()
710 sc->acpi_dev_t = make_dev(&acpi_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0664, in acpi_attach()
712 sc->acpi_dev_t->si_drv1 = sc; in acpi_attach()
714 if ((error = acpi_machdep_init(dev))) in acpi_attach()
720 acpi_platform_osc(dev); in acpi_attach()
724 acpi_probe_children(dev); in acpi_attach()
730 device_printf(dev, "Could not update all GPEs: %s\n", in acpi_attach()
745 acpi_set_power_children(device_t dev, int state) in acpi_set_power_children() argument
751 if (device_get_children(dev, &devlist, &numdevs) != 0) in acpi_set_power_children()
755 * Retrieve and set D-state for the sleep state if _SxD is present. in acpi_set_power_children()
762 acpi_device_pwr_for_sleep(dev, child, &dstate) == 0) in acpi_set_power_children()
769 acpi_suspend(device_t dev) in acpi_suspend() argument
775 error = bus_generic_suspend(dev); in acpi_suspend()
777 acpi_set_power_children(dev, ACPI_STATE_D3); in acpi_suspend()
783 acpi_resume(device_t dev) in acpi_resume() argument
788 acpi_set_power_children(dev, ACPI_STATE_D0); in acpi_resume()
790 return (bus_generic_resume(dev)); in acpi_resume()
794 acpi_shutdown(device_t dev) in acpi_shutdown() argument
800 bus_generic_shutdown(dev); in acpi_shutdown()
803 * Enable any GPEs that are able to power-on the system (i.e., RTC). in acpi_shutdown()
812 * Handle a new device being added
823 ad->ad_domain = ACPI_DEV_DOMAIN_UNKNOWN; in acpi_add_child()
824 resource_list_init(&ad->ad_rl); in acpi_add_child()
838 struct resource_list *rl = &adev->ad_rl; in acpi_print_child()
876 acpi_driver_added(device_t dev, driver_t *driver) in acpi_driver_added() argument
881 DEVICE_IDENTIFY(driver, dev); in acpi_driver_added()
882 if (device_get_children(dev, &devlist, &numdevs)) in acpi_driver_added()
906 if (dinfo->ad_handle) { in acpi_child_location_method()
907 sbuf_printf(sb, "handle=%s", acpi_name(dinfo->ad_handle)); in acpi_child_location_method()
908 if (ACPI_SUCCESS(acpi_GetInteger(dinfo->ad_handle, "_PXM", &pxm))) { in acpi_child_location_method()
917 acpi_pnpinfo(ACPI_HANDLE handle, struct sbuf *sb) in acpi_pnpinfo() argument
921 if (ACPI_FAILURE(AcpiGetObjectInfo(handle, &adinfo))) { in acpi_pnpinfo()
927 (adinfo->Valid & ACPI_VALID_HID) ? in acpi_pnpinfo()
928 adinfo->HardwareId.String : "none", in acpi_pnpinfo()
929 (adinfo->Valid & ACPI_VALID_UID) ? in acpi_pnpinfo()
930 strtoul(adinfo->UniqueId.String, NULL, 10) : 0UL, in acpi_pnpinfo()
931 ((adinfo->Valid & ACPI_VALID_CID) && in acpi_pnpinfo()
932 adinfo->CompatibleIdList.Count > 0) ? in acpi_pnpinfo()
933 adinfo->CompatibleIdList.Ids[0].String : "none"); in acpi_pnpinfo()
944 return (acpi_pnpinfo(dinfo->ad_handle, sb)); in acpi_child_pnpinfo_method()
956 ACPI_HANDLE *handle = acpi_get_handle(child); in acpi_get_acpi_device_path() local
958 if (handle != NULL) in acpi_get_acpi_device_path()
959 sbuf_printf(sb, "%s", acpi_name(handle)); in acpi_get_acpi_device_path()
976 if (!ACPI_FAILURE(AcpiGetObjectInfo(dinfo->ad_handle, &adinfo)) && in acpi_get_device_path()
977 dinfo->ad_handle != 0 && (adinfo->Valid & ACPI_VALID_HID)) { in acpi_get_device_path()
978 const char *hid = adinfo->HardwareId.String; in acpi_get_device_path()
979 u_long uid = (adinfo->Valid & ACPI_VALID_UID) ? in acpi_get_device_path()
980 strtoul(adinfo->UniqueId.String, NULL, 10) : 0UL; in acpi_get_device_path()
1025 * Handle device deletion.
1028 acpi_child_deleted(device_t dev, device_t child) in acpi_child_deleted() argument
1032 if (acpi_get_device(dinfo->ad_handle) == child) in acpi_child_deleted()
1033 AcpiDetachData(dinfo->ad_handle, acpi_fake_objhandler); in acpi_child_deleted()
1037 * Handle per-device ivars
1040 acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) in acpi_read_ivar() argument
1052 *(ACPI_HANDLE *)result = ad->ad_handle; in acpi_read_ivar()
1055 *(void **)result = ad->ad_private; in acpi_read_ivar()
1058 *(int *)result = ad->ad_flags; in acpi_read_ivar()
1061 *(int *)result = ad->ad_domain; in acpi_read_ivar()
1066 *(int *)result = -1; in acpi_read_ivar()
1072 *(uint8_t*)result = (ad->ad_cls_class >> 16) & 0xff; in acpi_read_ivar()
1075 *(uint8_t*)result = (ad->ad_cls_class >> 8) & 0xff; in acpi_read_ivar()
1078 *(uint8_t*)result = (ad->ad_cls_class >> 0) & 0xff; in acpi_read_ivar()
1088 acpi_write_ivar(device_t dev, device_t child, int index, uintptr_t value) in acpi_write_ivar() argument
1099 ad->ad_handle = (ACPI_HANDLE)value; in acpi_write_ivar()
1102 ad->ad_private = (void *)value; in acpi_write_ivar()
1105 ad->ad_flags = (int)value; in acpi_write_ivar()
1108 ad->ad_domain = (int)value; in acpi_write_ivar()
1119 * Handle child resource allocation/removal
1122 acpi_get_rlist(device_t dev, device_t child) in acpi_get_rlist() argument
1127 return (&ad->ad_rl); in acpi_get_rlist()
1131 acpi_match_resource_hint(device_t dev, int type, long value) in acpi_match_resource_hint() argument
1133 struct acpi_device *ad = device_get_ivars(dev); in acpi_match_resource_hint()
1134 struct resource_list *rl = &ad->ad_rl; in acpi_match_resource_hint()
1138 if (rle->type != type) in acpi_match_resource_hint()
1140 if (rle->start <= value && rle->end >= value) in acpi_match_resource_hint()
1255 * -2 is returned. If any other error occurs, -1 is returned.
1258 acpi_pxm_parse(device_t dev) in acpi_pxm_parse() argument
1262 ACPI_HANDLE handle; in acpi_pxm_parse() local
1266 handle = acpi_get_handle(dev); in acpi_pxm_parse()
1267 if (handle == NULL) in acpi_pxm_parse()
1268 return (-2); in acpi_pxm_parse()
1269 status = acpi_GetInteger(handle, "_PXM", &pxm); in acpi_pxm_parse()
1273 return (-2); in acpi_pxm_parse()
1276 return (-1); in acpi_pxm_parse()
1280 acpi_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t setsize, in acpi_get_cpus() argument
1287 return (bus_generic_get_cpus(dev, child, op, setsize, cpuset)); in acpi_get_cpus()
1296 error = bus_generic_get_cpus(dev, child, op, setsize, cpuset); in acpi_get_cpus()
1304 return (bus_generic_get_cpus(dev, child, op, setsize, cpuset)); in acpi_get_cpus()
1309 acpi_get_domain_method(device_t dev, device_t child, int *domain) in acpi_get_domain_method() argument
1313 error = acpi_read_ivar(dev, child, ACPI_IVAR_DOMAIN, in acpi_get_domain_method()
1335 * Pre-allocate/manage all memory and IO resources. Since rman can't handle
1339 acpi_sysres_alloc(device_t dev) in acpi_sysres_alloc() argument
1341 struct acpi_softc *sc = device_get_softc(dev); in acpi_sysres_alloc()
1350 * had multi-pass probe/attach. in acpi_sysres_alloc()
1352 if (device_get_children(dev, &children, &child_count) != 0) in acpi_sysres_alloc()
1355 if (ACPI_ID_PROBE(dev, children[i], sysres_ids, NULL) <= 0) in acpi_sysres_alloc()
1360 STAILQ_FOREACH(rle, &sc->sysres_rl, link) { in acpi_sysres_alloc()
1361 if (rle->res != NULL) { in acpi_sysres_alloc()
1362 device_printf(dev, "duplicate resource for %jx\n", rle->start); in acpi_sysres_alloc()
1367 rm = acpi_get_rman(dev, rle->type, 0); in acpi_sysres_alloc()
1371 /* Pre-allocate resource and add to our rman pool. */ in acpi_sysres_alloc()
1372 res = bus_alloc_resource(dev, rle->type, in acpi_sysres_alloc()
1373 &rle->rid, rle->start, rle->start + rle->count - 1, rle->count, in acpi_sysres_alloc()
1377 rle->res = res; in acpi_sysres_alloc()
1379 device_printf(dev, "reservation of %jx, %jx (%d) failed\n", in acpi_sysres_alloc()
1380 rle->start, rle->count, rle->type); in acpi_sysres_alloc()
1387 * namespace scan once the boot-time attach of devices has completed.
1389 * Ideally reserving firmware-assigned resources would work in a
1390 * depth-first traversal of the device namespace, but this is
1399 acpi_reserve_resources(device_t dev) in acpi_reserve_resources() argument
1407 if (device_get_children(dev, &children, &child_count) != 0) in acpi_reserve_resources()
1411 rl = &ad->ad_rl; in acpi_reserve_resources()
1414 if (ACPI_ID_PROBE(dev, children[i], sysres_ids, NULL) <= 0) in acpi_reserve_resources()
1423 if (rle->type == SYS_RES_IRQ) in acpi_reserve_resources()
1431 if (rle->res != NULL) in acpi_reserve_resources()
1440 * acpi_alloc_resource() will sub-alloc from the system in acpi_reserve_resources()
1443 resource_list_reserve(rl, dev, children[i], rle->type, &rle->rid, in acpi_reserve_resources()
1444 rle->start, rle->end, rle->count, 0); in acpi_reserve_resources()
1451 acpi_set_resource(device_t dev, device_t child, int type, int rid, in acpi_set_resource() argument
1455 struct resource_list *rl = &ad->ad_rl; in acpi_set_resource()
1471 resource_list_unreserve(rl, dev, child, type, rid); in acpi_set_resource()
1474 end = (start + count - 1); in acpi_set_resource()
1494 * use resource_list_alloc() to handle reserved resources. For in acpi_alloc_resource()
1499 rl = &ad->ad_rl; in acpi_alloc_resource()
1503 * devices. That is, if a non-default range is specified for in acpi_alloc_resource()
1520 * XXX: Should we handle the lookup failing? in acpi_alloc_resource()
1536 start = rle->start; in acpi_alloc_resource()
1537 end = rle->end; in acpi_alloc_resource()
1538 count = rle->count; in acpi_alloc_resource()
1550 if (res == NULL && start + count - 1 == end) in acpi_alloc_resource()
1576 STAILQ_FOREACH(rle, &sc->sysres_rl, link) { in acpi_managed_resource()
1577 if (rle->type != rman_get_type(r) || rle->res == NULL) in acpi_managed_resource()
1579 if (rman_get_start(r) >= rman_get_start(rle->res) && in acpi_managed_resource()
1580 rman_get_end(r) <= rman_get_end(rle->res)) in acpi_managed_resource()
1581 return (rle->res); in acpi_managed_resource()
1666 args.offset = start - rman_get_start(sysres); in acpi_map_resource()
1688 acpi_bus_alloc_gas(device_t dev, int *type, int *rid, ACPI_GENERIC_ADDRESS *gas, in acpi_bus_alloc_gas() argument
1698 switch (gas->SpaceId) { in acpi_bus_alloc_gas()
1713 if (gas->BitWidth && gas->BitWidth < 8) in acpi_bus_alloc_gas()
1714 gas->BitWidth = 8; in acpi_bus_alloc_gas()
1717 if (gas->Address == 0 || gas->BitWidth == 0) in acpi_bus_alloc_gas()
1720 bus_set_resource(dev, res_type, *rid, gas->Address, in acpi_bus_alloc_gas()
1721 gas->BitWidth / 8); in acpi_bus_alloc_gas()
1722 *res = bus_alloc_resource_any(dev, res_type, rid, RF_ACTIVE | flags); in acpi_bus_alloc_gas()
1727 bus_delete_resource(dev, res_type, *rid); in acpi_bus_alloc_gas()
1734 acpi_isa_get_logicalid(device_t dev) in acpi_isa_get_logicalid() argument
1743 if ((h = acpi_get_handle(dev)) == NULL || in acpi_isa_get_logicalid()
1747 pnpid = (devinfo->Valid & ACPI_VALID_HID) != 0 && in acpi_isa_get_logicalid()
1748 devinfo->HardwareId.Length >= ACPI_EISAID_STRING_SIZE ? in acpi_isa_get_logicalid()
1749 PNP_EISAID(devinfo->HardwareId.String) : 0; in acpi_isa_get_logicalid()
1756 acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count) in acpi_isa_get_compatid() argument
1769 if ((h = acpi_get_handle(dev)) == NULL || in acpi_isa_get_compatid()
1773 if ((devinfo->Valid & ACPI_VALID_CID) == 0) { in acpi_isa_get_compatid()
1778 if (devinfo->CompatibleIdList.Count < count) in acpi_isa_get_compatid()
1779 count = devinfo->CompatibleIdList.Count; in acpi_isa_get_compatid()
1780 ids = devinfo->CompatibleIdList.Ids; in acpi_isa_get_compatid()
1793 acpi_device_id_probe(device_t bus, device_t dev, char **ids, char **match) in acpi_device_id_probe() argument
1800 h = acpi_get_handle(dev); in acpi_device_id_probe()
1803 t = acpi_get_type(dev); in acpi_device_id_probe()
1823 acpi_device_eval_obj(device_t bus, device_t dev, ACPI_STRING pathname, in acpi_device_eval_obj() argument
1828 if (dev == NULL) in acpi_device_eval_obj()
1830 else if ((h = acpi_get_handle(dev)) == NULL) in acpi_device_eval_obj()
1836 acpi_device_get_prop(device_t bus, device_t dev, ACPI_STRING propname, in acpi_device_get_prop() argument
1844 ad = device_get_ivars(dev); in acpi_device_get_prop()
1848 if (ad->dsd_pkg == NULL) { in acpi_device_get_prop()
1849 if (ad->dsd.Pointer == NULL) { in acpi_device_get_prop()
1858 for (i = 0; i < ad->dsd_pkg->Package.Count; i ++) { in acpi_device_get_prop()
1859 pkg = &ad->dsd_pkg->Package.Elements[i]; in acpi_device_get_prop()
1860 if (pkg->Type != ACPI_TYPE_PACKAGE || pkg->Package.Count != 2) in acpi_device_get_prop()
1863 name = &pkg->Package.Elements[0]; in acpi_device_get_prop()
1864 val = &pkg->Package.Elements[1]; in acpi_device_get_prop()
1865 if (name->Type != ACPI_TYPE_STRING) in acpi_device_get_prop()
1867 if (strncmp(propname, name->String.Pointer, name->String.Length) == 0) { in acpi_device_get_prop()
1884 ad->dsd.Length = ACPI_ALLOCATE_BUFFER; in acpi_find_dsd()
1885 ad->dsd.Pointer = NULL; in acpi_find_dsd()
1886 ad->dsd_pkg = NULL; in acpi_find_dsd()
1888 status = AcpiEvaluateObject(ad->ad_handle, "_DSD", NULL, &ad->dsd); in acpi_find_dsd()
1892 dsd = ad->dsd.Pointer; in acpi_find_dsd()
1893 guid = &dsd->Package.Elements[0]; in acpi_find_dsd()
1894 pkg = &dsd->Package.Elements[1]; in acpi_find_dsd()
1896 if (guid->Type != ACPI_TYPE_BUFFER || pkg->Type != ACPI_TYPE_PACKAGE || in acpi_find_dsd()
1897 guid->Buffer.Length != sizeof(acpi_dsd_uuid)) in acpi_find_dsd()
1899 if (memcmp(guid->Buffer.Pointer, &acpi_dsd_uuid, in acpi_find_dsd()
1902 ad->dsd_pkg = pkg; in acpi_find_dsd()
1915 if (hobj->Type != ACPI_TYPE_PACKAGE) in acpi_bus_get_prop_handle()
1917 if (hobj->Package.Count != 1) in acpi_bus_get_prop_handle()
1920 pobj = &hobj->Package.Elements[0]; in acpi_bus_get_prop_handle()
1923 if (pobj->Type != ACPI_TYPE_LOCAL_REFERENCE) in acpi_bus_get_prop_handle()
1935 return (-1); in acpi_bus_get_prop_handle()
1948 return (-1); in acpi_bus_get_prop()
1959 return (-1); in acpi_bus_get_prop()
1962 switch (obj->Type) { in acpi_bus_get_prop()
1966 *((uint32_t *)propvalue) = obj->Integer.Value; in acpi_bus_get_prop()
1970 *((uint64_t *) propvalue) = obj->Integer.Value; in acpi_bus_get_prop()
1976 return (-1); in acpi_bus_get_prop()
1979 memcpy(propvalue, obj->String.Pointer, in acpi_bus_get_prop()
1980 MIN(size, obj->String.Length)); in acpi_bus_get_prop()
1981 return (obj->String.Length); in acpi_bus_get_prop()
1985 memcpy(propvalue, obj->Buffer.Pointer, in acpi_bus_get_prop()
1986 MIN(size, obj->Buffer.Length)); in acpi_bus_get_prop()
1987 return (obj->Buffer.Length); in acpi_bus_get_prop()
2011 acpi_device_pwr_for_sleep(device_t bus, device_t dev, int *dstate) in acpi_device_pwr_for_sleep() argument
2014 ACPI_HANDLE handle; in acpi_device_pwr_for_sleep() local
2018 handle = acpi_get_handle(dev); in acpi_device_pwr_for_sleep()
2026 if (dstate == NULL || handle == NULL || in acpi_device_pwr_for_sleep()
2027 acpi_MatchHid(handle, "PNP0500") || in acpi_device_pwr_for_sleep()
2028 acpi_MatchHid(handle, "PNP0501") || in acpi_device_pwr_for_sleep()
2029 acpi_MatchHid(handle, "PNP0502") || in acpi_device_pwr_for_sleep()
2030 acpi_MatchHid(handle, "PNP0510") || in acpi_device_pwr_for_sleep()
2031 acpi_MatchHid(handle, "PNP0511")) in acpi_device_pwr_for_sleep()
2039 snprintf(sxd, sizeof(sxd), "_S%dD", sc->acpi_sstate); in acpi_device_pwr_for_sleep()
2040 status = acpi_GetInteger(handle, sxd, dstate); in acpi_device_pwr_for_sleep()
2042 device_printf(dev, "failed to get %s on %s: %s\n", sxd, in acpi_device_pwr_for_sleep()
2043 acpi_name(handle), AcpiFormatException(status)); in acpi_device_pwr_for_sleep()
2061 device_t dev, old_dev; in acpi_device_scan_cb() local
2070 if (acpi_avoid(h) || h == ctx->parent) in acpi_device_scan_cb()
2082 * afterwards, return. Otherwise, we update the handle to the new dev. in acpi_device_scan_cb()
2085 dev = old_dev; in acpi_device_scan_cb()
2086 status = ctx->user_fn(h, &dev, level, ctx->arg); in acpi_device_scan_cb()
2087 if (ACPI_FAILURE(status) || old_dev == dev) in acpi_device_scan_cb()
2090 /* Remove the old child and its connection to the handle. */ in acpi_device_scan_cb()
2094 /* Recreate the handle association if the user created a device. */ in acpi_device_scan_cb()
2095 if (dev != NULL) in acpi_device_scan_cb()
2096 AcpiAttachData(h, acpi_fake_objhandler, dev); in acpi_device_scan_cb()
2102 acpi_device_scan_children(device_t bus, device_t dev, int max_depth, in acpi_device_scan_children() argument
2111 if (dev == NULL) in acpi_device_scan_children()
2113 else if ((h = acpi_get_handle(dev)) == NULL) in acpi_device_scan_children()
2161 * ISA-style drivers attached to ACPI may persist and in acpi_isa_pnp_probe()
2170 while (ids && ids->ip_id) { in acpi_isa_pnp_probe()
2171 if (lid == ids->ip_id) { in acpi_isa_pnp_probe()
2176 if (cids[i] == ids->ip_id) { in acpi_isa_pnp_probe()
2185 if (result == 0 && ids->ip_desc) in acpi_isa_pnp_probe()
2186 device_set_desc(child, ids->ip_desc); in acpi_isa_pnp_probe()
2196 * On non-x86 architectures (arm64 for now), this will be done from the
2211 end = (ACPI_MCFG_ALLOCATION *)((char *)hdr + hdr->Length); in acpi_enable_pcie()
2214 pcie_cfgregopen(alloc->Address, alloc->PciSegment, in acpi_enable_pcie()
2215 alloc->StartBusNumber, alloc->EndBusNumber); in acpi_enable_pcie()
2222 acpi_platform_osc(device_t dev) in acpi_platform_osc() argument
2228 /* 0811B06E-4A27-44F9-8D60-3CBBC22E7B48 */ in acpi_platform_osc()
2243 device_printf(dev, "_OSC failed: %s\n", in acpi_platform_osc()
2277 /* Pre-allocate resources for our rman from any sysresource devices. */ in acpi_probe_children()
2305 acpi_probe_order(ACPI_HANDLE handle, int *order) in acpi_probe_order() argument
2312 * 2. Clocks and timers (to handle early accesses) in acpi_probe_order()
2313 * 3. Embedded controllers (to handle early accesses) in acpi_probe_order()
2316 AcpiGetType(handle, &type); in acpi_probe_order()
2319 else if (acpi_MatchHid(handle, "PNP0C01") || in acpi_probe_order()
2320 acpi_MatchHid(handle, "PNP0C02")) in acpi_probe_order()
2322 else if (acpi_MatchHid(handle, "PNP0100") || in acpi_probe_order()
2323 acpi_MatchHid(handle, "PNP0103") || in acpi_probe_order()
2324 acpi_MatchHid(handle, "PNP0B00")) in acpi_probe_order()
2326 else if (acpi_MatchHid(handle, "PNP0C09")) in acpi_probe_order()
2328 else if (acpi_MatchHid(handle, "PNP0C0F")) in acpi_probe_order()
2337 acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status) in acpi_probe_child() argument
2354 if (acpi_avoid(handle)) in acpi_probe_child()
2358 if (ACPI_SUCCESS(AcpiGetType(handle, &type))) { in acpi_probe_child()
2359 handle_str = acpi_name(handle); in acpi_probe_child()
2371 if (acpi_parse_prw(handle, &prw) == 0) in acpi_probe_child()
2372 AcpiSetupGpeForWake(handle, prw.gpe_handle, prw.gpe_bit); in acpi_probe_child()
2378 if (!acpi_has_hid(handle)) in acpi_probe_child()
2387 * breadth-first. Orders less than ACPI_DEV_BASE_ORDER in acpi_probe_child()
2393 acpi_probe_order(handle, &order); in acpi_probe_child()
2398 /* Associate the handle with the device_t and vice versa. */ in acpi_probe_child()
2399 acpi_set_handle(child, handle); in acpi_probe_child()
2400 AcpiAttachData(handle, acpi_fake_objhandler, child); in acpi_probe_child()
2405 * the handle, but we don't probe it). in acpi_probe_child()
2413 if (acpi_MatchHid(handle, "PNP0C0F")) in acpi_probe_child()
2421 if (acpi_MatchHid(handle, "PNP0B00")) in acpi_probe_child()
2428 if (ACPI_SUCCESS(AcpiGetHandle(handle, "_DCK", &h))) in acpi_probe_child()
2442 acpi_parse_resources(child, handle, &acpi_res_parse_set, NULL); in acpi_probe_child()
2445 ad->ad_cls_class = 0xffffff; in acpi_probe_child()
2446 if (ACPI_SUCCESS(AcpiGetObjectInfo(handle, &devinfo))) { in acpi_probe_child()
2447 if ((devinfo->Valid & ACPI_VALID_CLS) != 0 && in acpi_probe_child()
2448 devinfo->ClassCode.Length >= ACPI_PCICLS_STRING_SIZE) { in acpi_probe_child()
2449 ad->ad_cls_class = strtoul(devinfo->ClassCode.String, in acpi_probe_child()
2457 ad->ad_domain = d; in acpi_probe_child()
2489 device_printf(sc->acpi_dev, "AcpiEnterSleepStatePrep failed - %s\n", in acpi_shutdown_final()
2493 device_printf(sc->acpi_dev, "Powering system off\n"); in acpi_shutdown_final()
2498 device_printf(sc->acpi_dev, "power-off failed - %s\n", in acpi_shutdown_final()
2503 device_printf(sc->acpi_dev, "power-off failed - timeout\n"); in acpi_shutdown_final()
2505 } else if ((howto & RB_HALT) == 0 && sc->acpi_handle_reboot) { in acpi_shutdown_final()
2510 device_printf(sc->acpi_dev, "reset failed - timeout\n"); in acpi_shutdown_final()
2512 device_printf(sc->acpi_dev, "reset failed - %s\n", in acpi_shutdown_final()
2514 } else if (sc->acpi_do_disable && !KERNEL_PANICKED()) { in acpi_shutdown_final()
2519 device_printf(sc->acpi_dev, "Shutting down\n"); in acpi_shutdown_final()
2535 device_printf(sc->acpi_dev, "Power Button (fixed)\n"); in acpi_enable_fixed_events()
2542 device_printf(sc->acpi_dev, "Sleep Button (fixed)\n"); in acpi_enable_fixed_events()
2550 * be attached to. This requires the present, enabled, UI-visible
2551 * and diagnostics-passed bits to be set.
2554 acpi_DeviceIsPresent(device_t dev) in acpi_DeviceIsPresent() argument
2560 h = acpi_get_handle(dev); in acpi_DeviceIsPresent()
2567 * only returns non-zero for the OS string "Windows 2015". Otherwise it in acpi_DeviceIsPresent()
2591 acpi_BatteryIsPresent(device_t dev) in acpi_BatteryIsPresent() argument
2597 h = acpi_get_handle(dev); in acpi_BatteryIsPresent()
2626 if ((devinfo->Valid & ACPI_VALID_HID) != 0) in acpi_has_hid()
2628 else if ((devinfo->Valid & ACPI_VALID_CID) != 0) in acpi_has_hid()
2629 if (devinfo->CompatibleIdList.Count > 0) in acpi_has_hid()
2637 * Match a HID string against a handle
2654 if ((devinfo->Valid & ACPI_VALID_HID) != 0 && in acpi_MatchHid()
2655 strcmp(hid, devinfo->HardwareId.String) == 0) in acpi_MatchHid()
2657 else if ((devinfo->Valid & ACPI_VALID_CID) != 0) in acpi_MatchHid()
2658 for (i = 0; i < devinfo->CompatibleIdList.Count; i++) { in acpi_MatchHid()
2659 if (strcmp(hid, devinfo->CompatibleIdList.Ids[i].String) == 0) { in acpi_MatchHid()
2670 * Return the handle of a named object within our scope, ie. that of (parent)
2696 acpi_GetProperty(device_t dev, ACPI_STRING propname, in acpi_GetProperty() argument
2699 device_t bus = device_get_parent(dev); in acpi_GetProperty()
2701 return (ACPI_GET_PROPERTY(bus, dev, propname, value)); in acpi_GetProperty()
2714 buf->Length = size; in acpi_AllocBuffer()
2715 buf->Pointer = (void *)(buf + 1); in acpi_AllocBuffer()
2720 acpi_SetInteger(ACPI_HANDLE handle, char *path, UINT32 number) in acpi_SetInteger() argument
2730 return (AcpiEvaluateObject(handle, path, &args, NULL)); in acpi_SetInteger()
2737 acpi_GetInteger(ACPI_HANDLE handle, char *path, UINT32 *number) in acpi_GetInteger() argument
2743 if (handle == NULL) in acpi_GetInteger()
2744 handle = ACPI_ROOT_OBJECT; in acpi_GetInteger()
2752 status = AcpiEvaluateObject(handle, path, NULL, &buf); in acpi_GetInteger()
2772 status = AcpiEvaluateObject(handle, path, NULL, &buf); in acpi_GetInteger()
2788 p = (ACPI_OBJECT *)bufp->Pointer; in acpi_ConvertBufferToInteger()
2789 if (p->Type == ACPI_TYPE_INTEGER) { in acpi_ConvertBufferToInteger()
2790 *number = p->Integer.Value; in acpi_ConvertBufferToInteger()
2793 if (p->Type != ACPI_TYPE_BUFFER) in acpi_ConvertBufferToInteger()
2795 if (p->Buffer.Length > sizeof(int)) in acpi_ConvertBufferToInteger()
2799 val = p->Buffer.Pointer; in acpi_ConvertBufferToInteger()
2800 for (i = 0; i < p->Buffer.Length; i++) in acpi_ConvertBufferToInteger()
2818 if (pkg == NULL || pkg->Type != ACPI_TYPE_PACKAGE) in acpi_ForeachPackageObject()
2823 comp = pkg->Package.Elements; in acpi_ForeachPackageObject()
2824 for (; i < pkg->Package.Count; i++, comp++) in acpi_ForeachPackageObject()
2839 rp = (ACPI_RESOURCE *)buf->Pointer; in acpi_FindIndexedResource()
2841 while (i-- > 0) { in acpi_FindIndexedResource()
2843 if (rp > (ACPI_RESOURCE *)((u_int8_t *)buf->Pointer + buf->Length)) in acpi_FindIndexedResource()
2847 if (rp->Type == ACPI_RESOURCE_TYPE_END_TAG || rp->Length == 0) in acpi_FindIndexedResource()
2874 if (buf->Pointer == NULL) { in acpi_AppendBufferResource()
2875 buf->Length = ACPI_INITIAL_RESOURCE_BUFFER_SIZE; in acpi_AppendBufferResource()
2876 if ((buf->Pointer = AcpiOsAllocate(buf->Length)) == NULL) in acpi_AppendBufferResource()
2878 rp = (ACPI_RESOURCE *)buf->Pointer; in acpi_AppendBufferResource()
2879 rp->Type = ACPI_RESOURCE_TYPE_END_TAG; in acpi_AppendBufferResource()
2880 rp->Length = ACPI_RS_SIZE_MIN; in acpi_AppendBufferResource()
2890 rp = (ACPI_RESOURCE *)buf->Pointer; in acpi_AppendBufferResource()
2893 if (rp >= (ACPI_RESOURCE *)((u_int8_t *)buf->Pointer + buf->Length)) in acpi_AppendBufferResource()
2895 if (rp->Type == ACPI_RESOURCE_TYPE_END_TAG || rp->Length == 0) in acpi_AppendBufferResource()
2911 while ((((u_int8_t *)rp - (u_int8_t *)buf->Pointer) + in acpi_AppendBufferResource()
2912 res->Length + ACPI_RS_SIZE_NO_DATA + in acpi_AppendBufferResource()
2913 ACPI_RS_SIZE_MIN) >= buf->Length) { in acpi_AppendBufferResource()
2914 if ((newp = AcpiOsAllocate(buf->Length * 2)) == NULL) in acpi_AppendBufferResource()
2916 bcopy(buf->Pointer, newp, buf->Length); in acpi_AppendBufferResource()
2918 ((u_int8_t *)rp - (u_int8_t *)buf->Pointer)); in acpi_AppendBufferResource()
2919 AcpiOsFree(buf->Pointer); in acpi_AppendBufferResource()
2920 buf->Pointer = newp; in acpi_AppendBufferResource()
2921 buf->Length += buf->Length; in acpi_AppendBufferResource()
2925 bcopy(res, rp, res->Length + ACPI_RS_SIZE_NO_DATA); in acpi_AppendBufferResource()
2929 rp->Type = ACPI_RESOURCE_TYPE_END_TAG; in acpi_AppendBufferResource()
2930 rp->Length = ACPI_RS_SIZE_MIN; in acpi_AppendBufferResource()
2965 switch (obj->Type) { in acpi_DSMQuery()
2967 for (i = 0; i < MIN(obj->Buffer.Length, sizeof(ret)); i++) in acpi_DSMQuery()
2968 ret |= (((uint64_t)obj->Buffer.Pointer[i]) << (i * 8)); in acpi_DSMQuery()
2973 ret = obj->Integer.Value; in acpi_DSMQuery()
2976 ACPI_WARNING((AE_INFO, "Unexpected return type %u\n", obj->Type)); in acpi_DSMQuery()
2989 acpi_EvaluateDSM(ACPI_HANDLE handle, const uint8_t *uuid, int revision, in acpi_EvaluateDSM() argument
2992 return (acpi_EvaluateDSMTyped(handle, uuid, revision, function, in acpi_EvaluateDSM()
2997 acpi_EvaluateDSMTyped(ACPI_HANDLE handle, const uint8_t *uuid, int revision, in acpi_EvaluateDSMTyped() argument
3028 status = AcpiEvaluateObjectTyped(handle, "_DSM", &arglist, &buf, type); in acpi_EvaluateDSMTyped()
3039 acpi_EvaluateOSC(ACPI_HANDLE handle, uint8_t *uuid, int revision, int count, in acpi_EvaluateOSC() argument
3062 status = AcpiEvaluateObjectTyped(handle, "_OSC", &arglist, &buf, in acpi_EvaluateOSC()
3068 if (ret->Buffer.Length != count * sizeof(*caps_out)) { in acpi_EvaluateOSC()
3072 bcopy(ret->Buffer.Pointer, caps_out, ret->Buffer.Length); in acpi_EvaluateOSC()
3102 if (entry->Length < sizeof(ACPI_SUBTABLE_HEADER)) in acpi_walk_subtables()
3106 entry = ACPI_ADD_PTR(ACPI_SUBTABLE_HEADER, entry, entry->Length); in acpi_walk_subtables()
3123 device_printf(sc->acpi_dev, in acpi_SetSleepState()
3136 if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) in acpi_sleep_force_task()
3137 device_printf(sc->acpi_dev, "force sleep state S%d failed\n", in acpi_sleep_force_task()
3138 sc->acpi_next_sstate); in acpi_sleep_force_task()
3146 device_printf(sc->acpi_dev, in acpi_sleep_force()
3154 device_printf(sc->acpi_dev, "AcpiOsExecute() for sleeping failed\n"); in acpi_sleep_force()
3159 * Request that the system enter the given suspend state. All /dev/apm
3180 if (rebooting || sc->acpi_next_sstate != 0 || suspend_blocked) { in acpi_ReqSleepState()
3185 while (sc->acpi_sleep_disabled) { in acpi_ReqSleepState()
3191 sc->acpi_next_sstate = state; in acpi_ReqSleepState()
3193 /* S5 (soft-off) should be entered directly with no waiting. */ in acpi_ReqSleepState()
3201 STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { in acpi_ReqSleepState()
3202 clone->notify_status = APM_EV_NONE; in acpi_ReqSleepState()
3203 if ((clone->flags & ACPI_EVF_DEVD) == 0) { in acpi_ReqSleepState()
3204 selwakeuppri(&clone->sel_read, PZERO); in acpi_ReqSleepState()
3205 KNOTE_LOCKED(&clone->sel_read.si_note, 0); in acpi_ReqSleepState()
3223 callout_reset(&sc->susp_force_to, 10 * hz, acpi_sleep_force, sc); in acpi_ReqSleepState()
3239 * error argument is non-zero, it indicates suspend should be cancelled
3252 sc = clone->acpi_sc; in acpi_AckSleepState()
3253 if (sc->acpi_next_sstate == 0) { in acpi_AckSleepState()
3260 sc->acpi_next_sstate = 0; in acpi_AckSleepState()
3261 callout_stop(&sc->susp_force_to); in acpi_AckSleepState()
3262 device_printf(sc->acpi_dev, in acpi_AckSleepState()
3264 devtoname(clone->cdev)); in acpi_AckSleepState()
3272 * are writable since read-only devices couldn't ack the request. in acpi_AckSleepState()
3275 clone->notify_status = APM_EV_ACKED; in acpi_AckSleepState()
3276 STAILQ_FOREACH(clone, &sc->apm_cdevs, entries) { in acpi_AckSleepState()
3277 if ((clone->flags & ACPI_EVF_WRITE) != 0 && in acpi_AckSleepState()
3278 clone->notify_status != APM_EV_ACKED) { in acpi_AckSleepState()
3286 callout_stop(&sc->susp_force_to); in acpi_AckSleepState()
3290 if (ACPI_FAILURE(acpi_EnterSleepState(sc, sc->acpi_next_sstate))) in acpi_AckSleepState()
3313 sc->acpi_sleep_disabled = FALSE; in acpi_sleep_enable()
3326 status = sc->acpi_sleep_disabled ? AE_ERROR : AE_OK; in acpi_sleep_disable()
3327 sc->acpi_sleep_disabled = TRUE; in acpi_sleep_disable()
3344 * Currently we support S1-S5 but S4 is only S4BIOS
3360 device_printf(sc->acpi_dev, "Sleep state S%d not supported by BIOS\n", in acpi_EnterSleepState()
3365 /* Re-entry once we're suspending is not allowed. */ in acpi_EnterSleepState()
3368 device_printf(sc->acpi_dev, in acpi_EnterSleepState()
3407 sc->acpi_sstate = state; in acpi_EnterSleepState()
3417 * XXX Note that a better two-pass approach with a 'veto' pass in acpi_EnterSleepState()
3422 device_printf(sc->acpi_dev, "device_suspend failed\n"); in acpi_EnterSleepState()
3429 device_printf(sc->acpi_dev, "AcpiEnterSleepStatePrep failed - %s\n", in acpi_EnterSleepState()
3435 if (sc->acpi_sleep_delay > 0) in acpi_EnterSleepState()
3436 DELAY(sc->acpi_sleep_delay * 1000000); in acpi_EnterSleepState()
3446 * by ACPI platform (BIOS, firmware) to its pre-sleep state. in acpi_EnterSleepState()
3458 * Prevent mis-interpretation of the wakeup by power button in acpi_EnterSleepState()
3474 device_printf(sc->acpi_dev, in acpi_EnterSleepState()
3486 if (sleep_result == -1) in acpi_EnterSleepState()
3489 /* Re-enable ACPI hardware on wakeup from sleep state 4. */ in acpi_EnterSleepState()
3497 device_printf(sc->acpi_dev, "AcpiEnterSleepState failed - %s\n", in acpi_EnterSleepState()
3513 sc->acpi_sstate = ACPI_STATE_S0; in acpi_EnterSleepState()
3527 sc->acpi_next_sstate = 0; in acpi_EnterSleepState()
3565 (void)timecounter->tc_get_timecount(timecounter); in acpi_resync_clock()
3566 inittodr(time_second + sc->acpi_sleep_delay); in acpi_resync_clock()
3571 acpi_wake_set_enable(device_t dev, int enable) in acpi_wake_set_enable() argument
3578 if (acpi_parse_prw(acpi_get_handle(dev), &prw) != 0) in acpi_wake_set_enable()
3581 flags = acpi_get_flags(dev); in acpi_wake_set_enable()
3586 device_printf(dev, "enable wake failed\n"); in acpi_wake_set_enable()
3589 acpi_set_flags(dev, flags | ACPI_FLAG_WAKE_ENABLED); in acpi_wake_set_enable()
3594 device_printf(dev, "disable wake failed\n"); in acpi_wake_set_enable()
3597 acpi_set_flags(dev, flags & ~ACPI_FLAG_WAKE_ENABLED); in acpi_wake_set_enable()
3604 acpi_wake_sleep_prep(ACPI_HANDLE handle, int sstate) in acpi_wake_sleep_prep() argument
3607 device_t dev; in acpi_wake_sleep_prep() local
3609 /* Check that this is a wake-capable device and get its GPE. */ in acpi_wake_sleep_prep()
3610 if (acpi_parse_prw(handle, &prw) != 0) in acpi_wake_sleep_prep()
3612 dev = acpi_get_device(handle); in acpi_wake_sleep_prep()
3624 device_printf(dev, "wake_prep disabled wake for %s (S%d)\n", in acpi_wake_sleep_prep()
3625 acpi_name(handle), sstate); in acpi_wake_sleep_prep()
3626 } else if (dev && (acpi_get_flags(dev) & ACPI_FLAG_WAKE_ENABLED) != 0) { in acpi_wake_sleep_prep()
3627 acpi_pwr_wake_enable(handle, 1); in acpi_wake_sleep_prep()
3628 acpi_SetInteger(handle, "_PSW", 1); in acpi_wake_sleep_prep()
3630 device_printf(dev, "wake_prep enabled for %s (S%d)\n", in acpi_wake_sleep_prep()
3631 acpi_name(handle), sstate); in acpi_wake_sleep_prep()
3638 acpi_wake_run_prep(ACPI_HANDLE handle, int sstate) in acpi_wake_run_prep() argument
3641 device_t dev; in acpi_wake_run_prep() local
3644 * Check that this is a wake-capable device and get its GPE. Return in acpi_wake_run_prep()
3647 if (acpi_parse_prw(handle, &prw) != 0) in acpi_wake_run_prep()
3649 dev = acpi_get_device(handle); in acpi_wake_run_prep()
3650 if (dev == NULL || (acpi_get_flags(dev) & ACPI_FLAG_WAKE_ENABLED) == 0) in acpi_wake_run_prep()
3655 * disabled before going to sleep so re-enable it. If it was enabled, in acpi_wake_run_prep()
3661 device_printf(dev, "run_prep re-enabled %s\n", acpi_name(handle)); in acpi_wake_run_prep()
3663 acpi_SetInteger(handle, "_PSW", 0); in acpi_wake_run_prep()
3664 acpi_pwr_wake_enable(handle, 0); in acpi_wake_run_prep()
3666 device_printf(dev, "run_prep cleaned up for %s\n", in acpi_wake_run_prep()
3667 acpi_name(handle)); in acpi_wake_run_prep()
3674 acpi_wake_prep(ACPI_HANDLE handle, UINT32 level, void *context, void **status) in acpi_wake_prep() argument
3681 acpi_wake_sleep_prep(handle, sstate); in acpi_wake_prep()
3683 acpi_wake_run_prep(handle, sstate); in acpi_wake_prep()
3699 /* Walk the tree rooted at acpi0 to attach per-device wake sysctls. */
3701 acpi_wake_sysctl_walk(device_t dev) in acpi_wake_sysctl_walk() argument
3708 error = device_get_children(dev, &devlist, &numdevs); in acpi_wake_sysctl_walk()
3737 device_t dev; in acpi_wake_set_sysctl() local
3739 dev = (device_t)arg1; in acpi_wake_set_sysctl()
3740 enable = (acpi_get_flags(dev) & ACPI_FLAG_WAKE_ENABLED) ? 1 : 0; in acpi_wake_set_sysctl()
3743 if (error != 0 || req->newptr == NULL) in acpi_wake_set_sysctl()
3748 return (acpi_wake_set_enable(dev, enable)); in acpi_wake_set_sysctl()
3785 if (acpi_PkgInt32(res, 1, &prw->lowest_wake) != 0) in acpi_parse_prw()
3791 switch (res->Package.Elements[0].Type) { in acpi_parse_prw()
3799 prw->gpe_handle = NULL; in acpi_parse_prw()
3800 prw->gpe_bit = res->Package.Elements[0].Integer.Value; in acpi_parse_prw()
3817 res2 = &res->Package.Elements[0]; in acpi_parse_prw()
3820 prw->gpe_handle = acpi_GetReference(NULL, &res2->Package.Elements[0]); in acpi_parse_prw()
3821 if (prw->gpe_handle == NULL) in acpi_parse_prw()
3823 if (acpi_PkgInt32(res2, 1, &prw->gpe_bit) != 0) in acpi_parse_prw()
3832 power_count = res->Package.Count - 2; in acpi_parse_prw()
3837 prw->power_res_count = power_count; in acpi_parse_prw()
3839 prw->power_res[i] = res->Package.Elements[i]; in acpi_parse_prw()
3868 device_printf(sc->acpi_dev, in acpi_system_eventhandler_sleep()
3915 acpi_invoke_sleep_eventhandler, &sc->acpi_power_button_sx))) in acpi_event_power_button_sleep()
3932 acpi_invoke_wake_eventhandler, &sc->acpi_power_button_sx))) in acpi_event_power_button_wake()
3945 acpi_invoke_sleep_eventhandler, &sc->acpi_sleep_button_sx))) in acpi_event_sleep_button_sleep()
3958 acpi_invoke_wake_eventhandler, &sc->acpi_sleep_button_sx))) in acpi_event_sleep_button_wake()
3965 * use this for single-threaded callers.
3968 acpi_name(ACPI_HANDLE handle) in acpi_name() argument
3976 if (handle && ACPI_SUCCESS(AcpiGetName(handle, ACPI_FULL_PATHNAME, &buf))) in acpi_name()
3982 * Debugging/bug-avoidance. Avoid trying to fetch info on various
3986 acpi_avoid(ACPI_HANDLE handle) in acpi_avoid() argument
3991 np = acpi_name(handle); in acpi_avoid()
4019 * Debugging/bug-avoidance. Disable ACPI subsystem components.
4056 acpi_lookup(void *arg, const char *name, device_t *dev) in acpi_lookup() argument
4058 ACPI_HANDLE handle; in acpi_lookup() local
4060 if (*dev != NULL) in acpi_lookup()
4064 * Allow any handle name that is specified as an absolute path and in acpi_lookup()
4075 &handle))) in acpi_lookup()
4077 *dev = acpi_get_device(handle); in acpi_lookup()
4084 * drivers wanting to be accessible via /dev/acpi should use the
4105 hp->cmd = cmd; in acpi_register_ioctl()
4106 hp->fn = fn; in acpi_register_ioctl()
4107 hp->arg = arg; in acpi_register_ioctl()
4127 if (hp->cmd == cmd && hp->fn == fn) in acpi_deregister_ioctl()
4138 acpiopen(struct cdev *dev, int flag, int fmt, struct thread *td) in acpiopen() argument
4144 acpiclose(struct cdev *dev, int flag, int fmt, struct thread *td) in acpiclose() argument
4150 acpiioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) in acpiioctl() argument
4158 sc = dev->si_drv1; in acpiioctl()
4166 if (hp->cmd == cmd) in acpiioctl()
4171 return (hp->fn(cmd, addr, hp->arg)); in acpiioctl()
4174 * Core ioctls are not permitted for non-writable user. in acpiioctl()
4187 device_printf(sc->acpi_dev, "power off via acpi ioctl not supported\n"); in acpiioctl()
4192 error = acpi_AckSleepState(sc->acpi_clone, error); in acpiioctl()
4217 sstate = sname[1] - '0'; in acpi_sname2sstate()
4223 return (-1); in acpi_sname2sstate()
4262 old_state = *(int *)oidp->oid_arg1; in acpi_sleep_state_sysctl()
4265 if (error == 0 && req->newptr != NULL) { in acpi_sleep_state_sysctl()
4272 *(int *)oidp->oid_arg1 = new_state; in acpi_sleep_state_sysctl()
4380 /* Exceptionally verbose output -- also used in the global "DebugLevel" */
4412 l = ep - cp; in acpi_parse_debug()
4469 if (strcmp(oidp->oid_arg1, "debug.acpi.layer") == 0) { in acpi_debug_sysctl()
4481 } else if (req->newptr == NULL) { in acpi_debug_sysctl()
4482 for (; tag->name != NULL; tag++) { in acpi_debug_sysctl()
4483 if ((*dbg & tag->value) == tag->value) in acpi_debug_sysctl()
4484 sbuf_printf(&sb, "%s ", tag->name); in acpi_debug_sysctl()
4495 if (error == 0 && req->newptr != NULL) { in acpi_debug_sysctl()
4497 kern_setenv((char *)oidp->oid_arg1, temp); in acpi_debug_sysctl()
4523 if (error != 0 || req->newptr == NULL) in acpi_debug_objects_sysctl()
4564 iface->data = malloc(sizeof(*iface->data) * j, M_TEMP, M_WAITOK); in acpi_parse_interfaces()
4565 iface->num = j; in acpi_parse_interfaces()
4571 iface->data[j] = p + i; in acpi_parse_interfaces()
4583 free(iface->data[0], M_TEMP); in acpi_free_interfaces()
4584 free(iface->data, M_TEMP); in acpi_free_interfaces()
4588 acpi_reset_interfaces(device_t dev) in acpi_reset_interfaces() argument
4598 device_printf(dev, in acpi_reset_interfaces()
4602 device_printf(dev, "installed _OSI(\"%s\")\n", in acpi_reset_interfaces()
4611 device_printf(dev, in acpi_reset_interfaces()
4615 device_printf(dev, "removed _OSI(\"%s\")\n", in acpi_reset_interfaces()
4645 acpi_state = sc->acpi_standby_sx; in acpi_pm_func()
4648 acpi_state = sc->acpi_suspend_sx; in acpi_pm_func()