da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER START
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner * The contents of this file are subject to the terms of the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Common Development and Distribution License, Version 1.0 only
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * (the "License"). You may not use this file except in compliance
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * See the License for the specific language governing permissions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * When distributing Covered Code, include this CDDL HEADER in each
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If applicable, add the following below this CDDL HEADER, with the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fields enclosed by brackets "[]" replaced with your own identifying
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * information: Portions Copyright [yyyy] [name of copyright owner]
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * CDDL HEADER END
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner * Use is subject to license terms.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#pragma ident "%Z%%M% %I% %E% SMI"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This module implements the PICL Interface used by PICL clients
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * to access services of the PICL daemon
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Locking Strategy
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * A single reader/writer lock (icl_lock) protects the access to the interface
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * to the picl daemon, and the reference count, refcnt, variable.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * A reader lock is obtained to send a request to the daemon.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * A writer lock is obtained to initialize, reinitialize, or shutdown
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * the interface.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Module variables
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "No error",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "General system failure",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Daemon not responding",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Unknown PICL service",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Session not initialized",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Invalid arguments",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Argument too big",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Property not found",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Not a table property handle",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Not a node handle",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Not a property handle",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "End of property list",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Property already exists",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Property not writable",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Insufficient permissions",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Invalid handle",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Stale handle",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Unsupported version",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Wait timed out",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Attempting to destroy before delete",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "PICL Tree is busy",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Already has a parent",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Property name is reserved",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Invalid reference value",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Continue tree walk",
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin "Terminate tree walk",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Node not found",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Not enough space available",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Property not readable",
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Property value unavailable"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define N_ERRORS (sizeof (picl_errmsg)/sizeof (picl_errmsg[0]))
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This function sends the client request to the daemon using a door call.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If door_handle is -1, it returns PICL_NOTINITIALIZED.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * If the door_call fails, it returns PICL_NORESPONSE. Otherwise, it
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * checks the response from the daemon for error. If an error is returned
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * this function returns the error code returned and unmaps any
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * memory mapped by the door call. For successful results, the caller is
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * responsible to unmap the mapped memory after retrieving the results.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This function does not attempt to reinitialize the interface if the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * initial door_call fails. It is called from handshake() , shutdown()
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * and trysend_req() routines.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinpost_req(door_arg_t *dargp, void *data_ptr, size_t data_size,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin door_desc_t *desc_ptr, uint_t desc_num, void *rbuf, size_t rsize)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /*LINTED*/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This function posts an INIT message to the daemon to
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * verify communication channel.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if ((err = post_req(&darg, &req, sizeof (picl_reqinit_t), NULL,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin 0, &outargs, sizeof (picl_retinit_t))) != PICL_SUCCESS)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This function calls post_req() to make door_call and reinitializes
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * the interface is post_req() fails.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintrysend_req(door_arg_t *dargp, void *data_ptr, size_t data_size,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin door_desc_t *desc_ptr, uint_t desc_num, void *rbuf, size_t rsize,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned int trycount)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (refcnt == 0) {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin while ((err = post_req(dargp, data_ptr, data_size, desc_ptr, desc_num,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Upgrade read to a write lock
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * if picl_shutdown happens during lock upgrade
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin if (refcnt == 0) {
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (void) rw_unlock(&picl_lock); /* read or write unlock */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Initialize the PICL interface
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Increment the reference count.
++refcnt;
return (err);
return (err);
return (PICL_NORESPONSE);
++refcnt;
return (err);
if (refcnt == 0) {
return (PICL_NOTINITIALIZED);
--refcnt;
if (refcnt == 0)
return (err);
return (PICL_SUCCESS);
return (err);
return (err);
return (err);
return (PICL_SUCCESS);
return (PICL_VALUETOOBIG);
return (err);
return (err);
return (PICL_VALUETOOBIG);
return (err);
return (err);
return (PICL_VALUETOOBIG);
return (PICL_VALUETOOBIG);
return (err);
return (PICL_SUCCESS);
return (PICL_VALUETOOBIG);
return (PICL_VALUETOOBIG);
return (err);
return (PICL_SUCCESS);
return (err);
return (PICL_SUCCESS);
return (err);
return (PICL_SUCCESS);
return (err);
return (PICL_SUCCESS);
return (err);
return (PICL_SUCCESS);
return (err);
return (PICL_SUCCESS);
return (err);
return (PICL_SUCCESS);
return ((char *)NULL);
sizeof (chdh));
return (err);
return (err);
return (err);
sizeof (chdh));
return (PICL_WALK_CONTINUE);
return (err);
return (PICL_INVALIDARG);
return (PICL_SUCCESS);
return (err);
return (err);
return (err);
return (PICL_SUCCESS);
return (PICL_VALUETOOBIG);
return (err);
return (err);
return (PICL_VALUETOOBIG);
return (PICL_VALUETOOBIG);
return (err);
return (err);
return (err);
return (err);