promif_prop.c revision d3d50737e566cade9a08d73d2af95105ac7cd960
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER START
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The contents of this file are subject to the terms of the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Common Development and Distribution License (the "License").
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You may not use this file except in compliance with the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * See the License for the specific language governing permissions
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * and limitations under the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * When distributing Covered Code, include this CDDL HEADER in each
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * If applicable, add the following below this CDDL HEADER, with the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * fields enclosed by brackets "[]" replaced with your own identifying
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * information: Portions Copyright [yyyy] [name of copyright owner]
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER END
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Use is subject to license terms.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic var_config_resp_t *cfg_rsp = &promif_ds_resp.var_config_resp;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic int (*ds_send)();
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic int (*ds_init)();
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Domains Services interaction
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define VC_NVERS (sizeof (vc_version) / sizeof (vc_version[0]))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic void vc_reg_handler(ds_cb_arg_t, ds_ver_t *, ds_svc_hdl_t);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic void vc_data_handler(ds_cb_arg_t, void *, size_t);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppovc_reg_handler(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppovc_data_handler(ds_cb_arg_t arg, void *buf, size_t buflen)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Initialize the linkage with DS (Domain Services). We assume that
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * the DS module has already been loaded by the platmod.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The call to the DS init functions will eventually result in the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * invocation of our registration callback handlers, at which time DS
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * is able to accept requests.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = (*ds_init)(&vc_primary_cap, &vc_primary_ops)) != 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = (*ds_init)(&vc_backup_cap, &vc_backup_ops)) != 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Prepare for ldom variable requests.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo mutex_init(&promif_prop_lock, NULL, MUTEX_DEFAULT, NULL);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Replace the current value of a property string given its name and
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * new value.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppopromif_ldom_setprop(char *name, void *value, int valuelen)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int paylen = namelen + 1 + valuelen; /* valuelen includes the null */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return (-1);
c8fcc830223bbda01aa320090635c8c1772e1e1ajm * Since we are emulating OBP, we must comply with the promif
c8fcc830223bbda01aa320090635c8c1772e1e1ajm * infrastructure and execute only on the originating cpu.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo req = kmem_zalloc(sizeof (var_config_hdr_t) + paylen, KM_SLEEP);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo (void) strncpy(&setp->name_and_value[namelen + 1], value, valuelen);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmn_err(CE_WARN, "%s: ds_cap_send failed: %d", me, rv);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return (-1);
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni if (cv_reltimedwait(&promif_prop_cv, &promif_prop_lock,
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni PROMIF_DS_TIMEOUT_SEC * hz, TR_CLOCK_TICK) == -1) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmn_err(CE_WARN, "%s: bad response type: %d", me, cmd);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo rv = (cfg_rsp->result == VAR_CONFIG_SUCCESS) ? valuelen : -1;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo len = promif_stree_setprop(node, name, (void *)value, len);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return (0);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return (0);