fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int null_power(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*pw_power_lost)(int); /* callback power lost(rideout) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*pw_power_ok)(void); /* callback power ok */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* callback power down (shutdown imminent) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _P(x) (((long)(&((_nsc_power_t *)0)->x))/sizeof (long))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Power_Lost", (uintptr_t)null_power, _P(pw_power_lost),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Power_OK", (uintptr_t)null_power, _P(pw_power_ok),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Power_Down", (uintptr_t)null_power, _P(pw_power_down),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * init null_power - dummy power routine for clients that choose not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to implement all the power hooks.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _nsc_power
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Call registered clients of the generic power ioctls.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Calls all the registered clients with a message describing the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * current state of the power for the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (copyin((void *) argp, &opc, sizeof (nsc_power_ctl_t)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _nsc_init_power (void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialise power ioctl subsystem.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called at driver initialisation time to allocate necessary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data structures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&_power_mutex, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _nsc_deinit_power (void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialise power ioctl subsystem.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called at driver initialisation time to allocate necessary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data structures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nsc_register_power (char *name, nsc_def_t *def)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Register an power ioctl client.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns a token for use in future calls to nsc_unregister_power.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If a client with the same name is already registered then NULL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is return to indicate failure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If registration fails NULL is returned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Registers an power ioctl client for notifications during subsequent
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ioctl from UPS/PCU management.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte entry = nsc_kmem_alloc(sizeof (_nsc_power_t), 0, _nsc_local_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_decode_param(def, _nsc_power_def, (long *)entry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nsc_unregister_power (blind_t powerp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Un-register a power ioctl client.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns 0 on success, otherwise returns an error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The specified power ioctl client is un-registered if possible.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Zero is returned on success otherwise an error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (xpp = &_power_clients; *xpp; xpp = &(*xpp)->next)