promif_prop.c revision d3d50737e566cade9a08d73d2af95105ac7cd960
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER START
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
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 *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * or http://www.opensolaris.org/os/licensing.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * See the License for the specific language governing permissions
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * and limitations under the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
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 *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER END
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
d3d50737e566cade9a08d73d2af95105ac7cd960Rafael Vanoni * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Use is subject to license terms.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/types.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/ddi.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/sunddi.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/promif_impl.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/ds.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/modctl.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/ksynch.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/varconfig.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#ifndef _KMDB
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define PROMIF_DS_TIMEOUT_SEC 15
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic kmutex_t promif_prop_lock;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic kcondvar_t promif_prop_cv;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic var_config_msg_t promif_ds_resp;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic var_config_resp_t *cfg_rsp = &promif_ds_resp.var_config_resp;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic int (*ds_send)();
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic int (*ds_init)();
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Domains Services interaction
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic ds_svc_hdl_t ds_primary_handle;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic ds_svc_hdl_t ds_backup_handle;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic ds_ver_t vc_version[] = { { 1, 0 } };
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define VC_NVERS (sizeof (vc_version) / sizeof (vc_version[0]))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic ds_capability_t vc_primary_cap = {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo "var-config", /* svc_id */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo vc_version, /* vers */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo VC_NVERS /* nvers */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo};
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic ds_capability_t vc_backup_cap = {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo "var-config-backup", /* svc_id */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo vc_version, /* vers */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo VC_NVERS /* nvers */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo};
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic void vc_reg_handler(ds_cb_arg_t, ds_ver_t *, ds_svc_hdl_t);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic void vc_unreg_handler(ds_cb_arg_t);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic void vc_data_handler(ds_cb_arg_t, void *, size_t);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic ds_clnt_ops_t vc_primary_ops = {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo vc_reg_handler, /* ds_primary_reg_cb */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo vc_unreg_handler, /* ds_primary_unreg_cb */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo vc_data_handler, /* ds_data_cb */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo &ds_primary_handle /* cb_arg */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo};
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic ds_clnt_ops_t vc_backup_ops = {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo vc_reg_handler, /* ds_backup_reg_cb */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo vc_unreg_handler, /* ds_backup_unreg_cb */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo vc_data_handler, /* ds_data_cb */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo &ds_backup_handle /* cb_arg */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo};
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic void
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppovc_reg_handler(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo _NOTE(ARGUNUSED(ver))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((ds_svc_hdl_t *)arg == &ds_primary_handle)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ds_primary_handle = hdl;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo else if ((ds_svc_hdl_t *)arg == &ds_backup_handle)
d1a9c4c143aaef0b57cf9531ab060cc86dddaf09jm ds_backup_handle = hdl;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic void
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppovc_unreg_handler(ds_cb_arg_t arg)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((ds_svc_hdl_t *)arg == &ds_primary_handle)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ds_primary_handle = DS_INVALID_HDL;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo else if ((ds_svc_hdl_t *)arg == &ds_backup_handle)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ds_backup_handle = DS_INVALID_HDL;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic void
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppovc_data_handler(ds_cb_arg_t arg, void *buf, size_t buflen)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo _NOTE(ARGUNUSED(arg))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo bcopy(buf, &promif_ds_resp, buflen);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo mutex_enter(&promif_prop_lock);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cv_signal(&promif_prop_cv);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo mutex_exit(&promif_prop_lock);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Initialize the linkage with DS (Domain Services). We assume that
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * the DS module has already been loaded by the platmod.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
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 */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostatic void
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppopromif_ds_init(void)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo static char *me = "promif_ds_init";
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int rv;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((ds_init =
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo (int (*)())modgetsymvalue("ds_cap_init", 0)) == 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmn_err(CE_WARN, "%s: can't find ds_cap_init", me);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo }
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((ds_send =
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo (int (*)())modgetsymvalue("ds_cap_send", 0)) == 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmn_err(CE_WARN, "%s: can't find ds_cap_send", me);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo }
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = (*ds_init)(&vc_primary_cap, &vc_primary_ops)) != 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmn_err(CE_NOTE,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo "%s: ds_cap_init failed (primary): %d", me, rv);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo }
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = (*ds_init)(&vc_backup_cap, &vc_backup_ops)) != 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmn_err(CE_NOTE,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo "%s: ds_cap_init failed (backup): %d", me, rv);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo }
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Prepare for ldom variable requests.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppovoid
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppopromif_prop_init(void)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo mutex_init(&promif_prop_lock, NULL, MUTEX_DEFAULT, NULL);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cv_init(&promif_prop_cv, NULL, CV_DEFAULT, NULL);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo promif_ds_init();
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Replace the current value of a property string given its name and
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * new value.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppopromif_ldom_setprop(char *name, void *value, int valuelen)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo var_config_msg_t *req;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo var_config_set_req_t *setp;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo var_config_cmd_t cmd;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ds_svc_hdl_t ds_handle;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int rv;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int namelen = strlen(name);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int paylen = namelen + 1 + valuelen; /* valuelen includes the null */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo static char *me = "promif_ldom_setprop";
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (ds_primary_handle != DS_INVALID_HDL)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ds_handle = ds_primary_handle;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo else if (ds_backup_handle != DS_INVALID_HDL)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ds_handle = ds_backup_handle;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo else
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return (-1);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
c8fcc830223bbda01aa320090635c8c1772e1e1ajm /*
c8fcc830223bbda01aa320090635c8c1772e1e1ajm * Since we are emulating OBP, we must comply with the promif
c8fcc830223bbda01aa320090635c8c1772e1e1ajm * infrastructure and execute only on the originating cpu.
c8fcc830223bbda01aa320090635c8c1772e1e1ajm */
de81a4f48d467f6d0263221cbf4a199b6a925948jm thread_affinity_set(curthread, CPU->cpu_id);
c8fcc830223bbda01aa320090635c8c1772e1e1ajm
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo req = kmem_zalloc(sizeof (var_config_hdr_t) + paylen, KM_SLEEP);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo req->var_config_cmd = VAR_CONFIG_SET_REQ;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo setp = &req->var_config_set;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo (void) strcpy(setp->name_and_value, name);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo (void) strncpy(&setp->name_and_value[namelen + 1], value, valuelen);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if ((rv = (*ds_send)(ds_handle, req,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo sizeof (var_config_hdr_t) + paylen)) != 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmn_err(CE_WARN, "%s: ds_cap_send failed: %d", me, rv);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmem_free(req, sizeof (var_config_hdr_t) + paylen);
c8fcc830223bbda01aa320090635c8c1772e1e1ajm thread_affinity_clear(curthread);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return (-1);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo }
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmem_free(req, sizeof (var_config_hdr_t) + paylen);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo mutex_enter(&promif_prop_lock);
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: ds response timeout", me);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo rv = -1;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo goto out;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo }
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmd = promif_ds_resp.vc_hdr.cmd;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (cmd != VAR_CONFIG_SET_RESP) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cmn_err(CE_WARN, "%s: bad response type: %d", me, cmd);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo rv = -1;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo goto out;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo }
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo rv = (cfg_rsp->result == VAR_CONFIG_SUCCESS) ? valuelen : -1;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoout:
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo mutex_exit(&promif_prop_lock);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo thread_affinity_clear(curthread);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return (rv);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppopromif_setprop(void *p)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cell_t *ci = (cell_t *)p;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo pnode_t node;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t name;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t value;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int len;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ASSERT(ci[1] == 4);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo node = p1275_cell2dnode(ci[3]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ASSERT(node == prom_optionsnode());
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo name = p1275_cell2ptr(ci[4]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo value = p1275_cell2ptr(ci[5]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo len = p1275_cell2int(ci[6]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (promif_stree_getproplen(node, name) != -1)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo len = promif_ldom_setprop(name, value, len);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (len >= 0)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo len = promif_stree_setprop(node, name, (void *)value, len);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ci[7] = p1275_int2cell(len);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return ((len == -1) ? len : 0);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#endif
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppopromif_getprop(void *p)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cell_t *ci = (cell_t *)p;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo pnode_t node;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t name;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t value;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int len;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ASSERT(ci[1] == 4);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo node = p1275_cell2dnode(ci[3]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo name = p1275_cell2ptr(ci[4]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo value = p1275_cell2ptr(ci[5]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo len = promif_stree_getprop(node, name, value);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ci[7] = p1275_int2cell(len);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return ((len == -1) ? len : 0);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppopromif_getproplen(void *p)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cell_t *ci = (cell_t *)p;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo pnode_t node;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t name;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int len;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ASSERT(ci[1] == 2);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo node = p1275_cell2dnode(ci[3]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo name = p1275_cell2ptr(ci[4]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo len = promif_stree_getproplen(node, name);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ci[5] = p1275_int2cell(len);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return (0);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppopromif_nextprop(void *p)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo{
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cell_t *ci = (cell_t *)p;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo pnode_t node;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t prev;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t next;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ASSERT(ci[1] == 3);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo node = p1275_cell2dnode(ci[3]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo prev = p1275_cell2ptr(ci[4]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo next = p1275_cell2ptr(ci[5]);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo (void) promif_stree_nextprop(node, prev, next);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo return (0);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}