acpi.c (cc538081ef1de6cd3f85a8009c9dcecadd24dd79) acpi.c (99e6980fcf5e12654c3e89b97b774de807d740a4)
1/*-
2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org>
3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
4 * Copyright (c) 2000, 2001 Michael Smith
5 * Copyright (c) 2000 BSDi
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 1910 unchanged lines hidden (view full) ---

1919 ad->dsd_pkg = pkg;
1920 return (AE_OK);
1921 }
1922
1923 return (AE_NOT_FOUND);
1924}
1925
1926static ssize_t
1/*-
2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org>
3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
4 * Copyright (c) 2000, 2001 Michael Smith
5 * Copyright (c) 2000 BSDi
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 1910 unchanged lines hidden (view full) ---

1919 ad->dsd_pkg = pkg;
1920 return (AE_OK);
1921 }
1922
1923 return (AE_NOT_FOUND);
1924}
1925
1926static ssize_t
1927acpi_bus_get_prop_handle(const ACPI_OBJECT *hobj, void *propvalue, size_t size)
1928{
1929 ACPI_OBJECT *pobj;
1930 ACPI_HANDLE h;
1931
1932 if (hobj->Type != ACPI_TYPE_PACKAGE)
1933 goto err;
1934 if (hobj->Package.Count != 1)
1935 goto err;
1936
1937 pobj = &hobj->Package.Elements[0];
1938 if (pobj == NULL)
1939 goto err;
1940 if (pobj->Type != ACPI_TYPE_LOCAL_REFERENCE)
1941 goto err;
1942
1943 h = acpi_GetReference(NULL, pobj);
1944 if (h == NULL)
1945 goto err;
1946
1947 if (propvalue != NULL && size >= sizeof(ACPI_HANDLE))
1948 *(ACPI_HANDLE *)propvalue = h;
1949 return (sizeof(ACPI_HANDLE));
1950
1951err:
1952 return (-1);
1953}
1954
1955static ssize_t
1927acpi_bus_get_prop(device_t bus, device_t child, const char *propname,
1928 void *propvalue, size_t size, device_property_type_t type)
1929{
1930 ACPI_STATUS status;
1931 const ACPI_OBJECT *obj;
1932
1933 status = acpi_device_get_prop(bus, child, __DECONST(char *, propname),
1934 &obj);
1935 if (ACPI_FAILURE(status))
1936 return (-1);
1937
1938 switch (type) {
1939 case DEVICE_PROP_ANY:
1940 case DEVICE_PROP_BUFFER:
1941 case DEVICE_PROP_UINT32:
1942 case DEVICE_PROP_UINT64:
1943 break;
1956acpi_bus_get_prop(device_t bus, device_t child, const char *propname,
1957 void *propvalue, size_t size, device_property_type_t type)
1958{
1959 ACPI_STATUS status;
1960 const ACPI_OBJECT *obj;
1961
1962 status = acpi_device_get_prop(bus, child, __DECONST(char *, propname),
1963 &obj);
1964 if (ACPI_FAILURE(status))
1965 return (-1);
1966
1967 switch (type) {
1968 case DEVICE_PROP_ANY:
1969 case DEVICE_PROP_BUFFER:
1970 case DEVICE_PROP_UINT32:
1971 case DEVICE_PROP_UINT64:
1972 break;
1973 case DEVICE_PROP_HANDLE:
1974 return (acpi_bus_get_prop_handle(obj, propvalue, size));
1944 default:
1945 return (-1);
1946 }
1947
1948 switch (obj->Type) {
1949 case ACPI_TYPE_INTEGER:
1950 if (type == DEVICE_PROP_UINT32) {
1951 if (propvalue != NULL && size >= sizeof(uint32_t))

--- 15 unchanged lines hidden (view full) ---

1967 return (obj->String.Length);
1968
1969 case ACPI_TYPE_BUFFER:
1970 if (propvalue != NULL && size > 0)
1971 memcpy(propvalue, obj->Buffer.Pointer,
1972 MIN(size, obj->Buffer.Length));
1973 return (obj->Buffer.Length);
1974
1975 default:
1976 return (-1);
1977 }
1978
1979 switch (obj->Type) {
1980 case ACPI_TYPE_INTEGER:
1981 if (type == DEVICE_PROP_UINT32) {
1982 if (propvalue != NULL && size >= sizeof(uint32_t))

--- 15 unchanged lines hidden (view full) ---

1998 return (obj->String.Length);
1999
2000 case ACPI_TYPE_BUFFER:
2001 if (propvalue != NULL && size > 0)
2002 memcpy(propvalue, obj->Buffer.Pointer,
2003 MIN(size, obj->Buffer.Length));
2004 return (obj->Buffer.Length);
2005
2006 case ACPI_TYPE_PACKAGE:
2007 if (propvalue != NULL && size >= sizeof(ACPI_OBJECT *)) {
2008 *((ACPI_OBJECT **) propvalue) =
2009 __DECONST(ACPI_OBJECT *, obj);
2010 }
2011 return (sizeof(ACPI_OBJECT *));
2012
2013 case ACPI_TYPE_LOCAL_REFERENCE:
2014 if (propvalue != NULL && size >= sizeof(ACPI_HANDLE)) {
2015 ACPI_HANDLE h;
2016
2017 h = acpi_GetReference(NULL,
2018 __DECONST(ACPI_OBJECT *, obj));
2019 memcpy(propvalue, h, sizeof(ACPI_HANDLE));
2020 }
2021 return (sizeof(ACPI_HANDLE));
1975 default:
1976 return (0);
1977 }
1978}
1979
1980int
1981acpi_device_pwr_for_sleep(device_t bus, device_t dev, int *dstate)
1982{

--- 2654 unchanged lines hidden ---
2022 default:
2023 return (0);
2024 }
2025}
2026
2027int
2028acpi_device_pwr_for_sleep(device_t bus, device_t dev, int *dstate)
2029{

--- 2654 unchanged lines hidden ---