/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Determine whether this machine is capable of suspending.
*
* This is done for the i386 architecture by determining if the machine has
* S3 capability, then ensuring it is on the whitelist.
*/
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stropts.h>
#include <string.h>
#include <kstat.h>
#include <stdlib.h>
#include <libuutil.h>
#include <libpower.h>
#include <libpower_impl.h>
/*
* Determine if this machine supports suspend by identifying
* if the hardware supports a usable "S" state. For now, we only
* care about S3, but this function should change when more are
* supported.
*/
pm_get_suspendenable(void)
{
/*
* All we care about currently on x86 platforms, is if the
* kstats indicate suspend is valid. It would probably be
* better if there were some API that returned the platform
* capabilities, but for now the only thing that isn't
* dependent on actual enablement, are the kstats.
*/
return (pm_has_sx(SYSTEM_POWER_S3));
}
/*
* Determine if the hardware supports suspend by probing the acpi kstat module.
* For now, we are only interested in "S3" support on x86, but when there
* are API's that allow for more specific suspend state selection, this
* function will be able to handle checking those states as well.
*/
static boolean_t
{
char *name;
/* Assume capability not valid until proven otherwise */
errno = 0;
return (B_FALSE);
}
"%s kstat_lookup \"%s\" failed errno %d (%s)\n",
(void) kstat_close(kc);
return (B_FALSE);
}
"%s kstat_read \"%s\" failed errno %d (%s)\n",
(void) kstat_close(kc);
return (B_FALSE);
}
/*
* Construct a name to pass for the interested state
*/
(void) kstat_close(kc);
return (B_FALSE);
}
"%s kstat_data_lookup machine does not support \"%s\"\n",
__FUNCTION__, name);
/*
* Not having this state is not an error, but we done
* checking now
*/
(void) kstat_close(kc);
return (B_FALSE);
}
(void) kstat_close(kc);
"%s kstat_data_lookup machine supports \"%s\" %ld\n",
/*
* The kstat indicates this machine has this "S" state
* support.
*/
}
return (result);
}