Lines Matching +full:io +full:- +full:multiplex
1 /*-
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()
479 sc->acpi_dev = dev; in acpi_attach()
480 callout_init(&sc->susp_force_to, 1); in acpi_attach()
490 panic("acpi rman_init IO ports failed"); 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()
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()
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()
755 * Retrieve and set D-state for the sleep state if _SxD is present. in acpi_set_power_children()
803 * Enable any GPEs that are able to power-on the system (i.e., RTC). in acpi_shutdown()
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()
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()
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()
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()
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
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()
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()
1127 return (&ad->ad_rl); in acpi_get_rlist()
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.
1268 return (-2); in acpi_pxm_parse()
1273 return (-2); in acpi_pxm_parse()
1276 return (-1); in acpi_pxm_parse()
1323 /* Only memory and IO resources are managed. */ in acpi_get_rman()
1335 * Pre-allocate/manage all memory and IO resources. Since rman can't handle
1350 * had multi-pass probe/attach. 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()
1366 /* Only memory and IO resources are valid here. */ 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()
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
1411 rl = &ad->ad_rl; 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()
1455 struct resource_list *rl = &ad->ad_rl; in acpi_set_resource()
1474 end = (start + count - 1); in acpi_set_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()
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()
1686 /* Allocate an IO port or memory resource, given its GAS. */
1697 /* We only support memory and IO spaces. */ in acpi_bus_alloc_gas()
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()
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()
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()
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()
2039 snprintf(sxd, sizeof(sxd), "_S%dD", sc->acpi_sstate); in acpi_device_pwr_for_sleep()
2070 if (acpi_avoid(h) || h == ctx->parent) in acpi_device_scan_cb()
2086 status = ctx->user_fn(h, &dev, level, ctx->arg); in acpi_device_scan_cb()
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()
2228 /* 0811B06E-4A27-44F9-8D60-3CBBC22E7B48 */ in acpi_platform_osc()
2277 /* Pre-allocate resources for our rman from any sysresource devices. */ in acpi_probe_children()
2387 * breadth-first. Orders less than ACPI_DEV_BASE_ORDER in acpi_probe_child()
2445 ad->ad_cls_class = 0xffffff; 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.
2567 * only returns non-zero for the OS string "Windows 2015". Otherwise it in acpi_DeviceIsPresent()
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()
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()
2714 buf->Length = size; in acpi_AllocBuffer()
2715 buf->Pointer = (void *)(buf + 1); in acpi_AllocBuffer()
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()
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()
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()
3609 /* Check that this is a wake-capable device and get its GPE. */ in acpi_wake_sleep_prep()
3644 * Check that this is a wake-capable device and get its GPE. Return 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()
3699 /* Walk the tree rooted at acpi0 to attach per-device wake sysctls. */
3743 if (error != 0 || req->newptr == NULL) 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.
3982 * Debugging/bug-avoidance. Avoid trying to fetch info on various
4019 * Debugging/bug-avoidance. Disable ACPI subsystem components.
4083 * We multiplex ioctls for all participating ACPI devices here. Individual
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()
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()
4645 acpi_state = sc->acpi_standby_sx; in acpi_pm_func()
4648 acpi_state = sc->acpi_suspend_sx; in acpi_pm_func()