drctl.c revision 8fea755a86ff6c596183a4366bfbd59f1bfdfe55
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * DR control module for LDoms * Configuration data structures D_MP |
D_NEW,
/* driver compatibility flag */ NULL,
/* bus operations */ "DR Control pseudo driver v%I%",
* One of the reasons for this module's existence is to serialize * DR requests which might be coming from different sources. Only * one operation is allowed to be in progress at any given time. * A single lock word (the 'drc_busy' element below) is NULL * when there is no operation in progress. When a client of this * module initiates an operation it grabs the mutex 'drc_lock' in * order to examine the lock word ('drc_busy'). If no other * operation is in progress, the lock word will be NULL. If so, * a cookie which uniquely identifies the requestor is stored in * the lock word, and the mutex is released. Attempts by other * clients to initiate an operation will fail. * When the lock-holding client's operation is completed, the * client will call a "finalize" function in this module, providing * the cookie passed with the original request. Since the cookie * matches, the operation will succeed and the lock word will be * cleared. At this point, an new operation may be initiated. /* identifier for caller */ int drc_cmd;
/* the cmd underway (or -1) */ int drc_flags;
/* saved flag from above cmd */ char *
str =
"drctl_do_attach";
* This driver guarantees that if drctl_config_init returns 0, * a valid response buffer will be passed back to the caller. This * routine can be used to generate that response in cases where the * upcall has not resulted in a response message from userland. static const char me[] =
"drctl_config_common";
* If the operation is a FORCE, we don't send a message to * the daemon. But, the upstream clients still expect a * response, so generate a response with all ops 'allowed'. DR_DBG_CTL(
"%s: from pack_message, bufp = %p size %ld\n",
* For failure, as part of our contract with the caller, * generate a response message, but mark all proposed * Since the response comes from userland, make sure it is * at least the minimum size and, if it contains error * strings, that the string area is null-terminated. static const char me[] =
"verify_response";
DR_DBG_CTL(
"%s: unterm. strings: resp %p size %ld char %d\n",
/* Don't fail the transaction, but don't advertise strings */ * Prepare for a reconfig operation. static char me[] =
"drctl_config_init";
DR_DBG_CTL(
"%s: cmd %d flags %d res %p count %d\n",
/* Mark the link busy. Below we will fill in the actual cookie. */ * If there wasn't a valid response msg passed back, * create a response with each resource op denied. * Complete a reconfig operation. * Flip the saved _REQUEST command to its corresponding /* none of the above should have been accepted in _init */ * Accept a preformatted request from caller and send a message to * the daemon. A pointer to the daemon's response buffer is passed * back in obufp, its size in osize. "drctl: pack_message received invalid cmd %d",
cmd);