NetBSD/share/man/man9/powerhook_establish.9

105 lines
3.5 KiB
Groff
Raw Normal View History

2009-05-15 10:40:15 +04:00
.\" $NetBSD: powerhook_establish.9,v 1.11 2009/05/15 06:40:15 wiz Exp $
1999-12-06 17:50:02 +03:00
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Lennart Augustsson.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd May 14, 2009
1999-12-06 17:50:02 +03:00
.Dt POWERHOOK_ESTABLISH 9
.Os
.Sh NAME
.Nm powerhook_establish ,
.Nm powerhook_disestablish
.Nd add or remove a power change hook
.Sh SYNOPSIS
.Ft void *
.Fn powerhook_establish "const char *name" "void (*fn)(int why, void *a)" \
"void *arg"
1999-12-06 17:50:02 +03:00
.Ft void
.Fn powerhook_disestablish "void *cookie"
.Sh DESCRIPTION
.Em The
2009-05-15 10:40:15 +04:00
.Nm
.Em API is deprecated.
.Pp
1999-12-06 17:50:02 +03:00
The
.Fn powerhook_establish
function adds
.Fa fn
of the list of hooks invoked by
.Xr dopowerhooks 9
2002-10-14 17:43:14 +04:00
at power change.
When invoked, the hook function
1999-12-06 17:50:02 +03:00
.Fa fn
will be passed the new power state as the first argument and
.Fa arg
as its second argument.
.Pp
The
.Fn powerhook_disestablish
function removes the hook described by the opaque pointer
.Fa cookie
2002-10-14 17:43:14 +04:00
from the list of hooks to be invoked at power change.
If
1999-12-06 17:50:02 +03:00
.Fa cookie
is invalid, the result of
.Fn powerhook_disestablish
is undefined.
.Pp
Power hooks should be used to perform activities
2002-10-14 17:43:14 +04:00
that must happen when the power situation to the computer changes.
2002-12-09 16:22:48 +03:00
Because of the environment in which they are run, power hooks cannot
1999-12-06 17:50:02 +03:00
rely on many system services (including file systems, and timeouts
and other interrupt-driven services).
2001-06-21 15:59:00 +04:00
The power hooks are typically executed from an interrupt context.
1999-12-06 17:50:02 +03:00
.Pp
The different reasons for calling the power hooks are: suspend, standby, and
2002-10-14 17:43:14 +04:00
resume.
The reason is reflected in the
1999-12-06 17:50:02 +03:00
.Fa why
argument and the values
.Dv PWR_SOFTSUSPEND ,
1999-12-06 17:50:02 +03:00
.Dv PWR_SUSPEND ,
.Dv PWR_SOFTSTANDBY ,
1999-12-06 17:50:02 +03:00
.Dv PWR_STANDBY ,
.Dv PWR_SOFTRESUME ,
1999-12-06 17:50:02 +03:00
and
.Dv PWR_RESUME .
It calls with PWR_SOFTxxx in the normal priority level while the other
callings are protected with
.Xr splhigh 9 .
1999-12-06 17:50:02 +03:00
At suspend the system is going to lose (almost) all power, standby retains
some power (e.g., minimal power to USB devices), and at resume power is
back to normal.
.Sh RETURN VALUES
2001-06-21 15:59:00 +04:00
If successful,
1999-12-06 17:50:02 +03:00
.Fn powerhook_establish
returns an opaque pointer describing the newly-established
2002-12-09 16:22:48 +03:00
power hook.
2002-10-14 17:43:14 +04:00
Otherwise, it returns NULL.
1999-12-06 17:50:02 +03:00
.Sh SEE ALSO
.Xr dopowerhooks 9