17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*12cc75c8Scindi  * Common Development and Distribution License (the "License").
6*12cc75c8Scindi  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*12cc75c8Scindi  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267aec1d6eScindi #include <umem.h>
277aec1d6eScindi #include <topo_alloc.h>
287aec1d6eScindi #include <topo_module.h>
29822fb41dStsien 
307aec1d6eScindi /*ARGSUSED*/
317aec1d6eScindi void *
topo_nv_alloc(nv_alloc_t * nva,size_t size)327aec1d6eScindi topo_nv_alloc(nv_alloc_t *nva, size_t size)
337aec1d6eScindi {
347aec1d6eScindi 	return (topo_zalloc(size, UMEM_DEFAULT));
357aec1d6eScindi }
36822fb41dStsien 
377aec1d6eScindi /*ARGSUSED*/
387aec1d6eScindi void
topo_nv_free(nv_alloc_t * nva,void * data,size_t size)397aec1d6eScindi topo_nv_free(nv_alloc_t *nva, void *data, size_t size)
407aec1d6eScindi {
417aec1d6eScindi 	topo_free(data, size);
427aec1d6eScindi }
43822fb41dStsien 
447aec1d6eScindi int
topo_mod_nvalloc(topo_mod_t * mod,nvlist_t ** nvlp,uint_t nvflag)457aec1d6eScindi topo_mod_nvalloc(topo_mod_t *mod, nvlist_t **nvlp, uint_t nvflag)
467aec1d6eScindi {
47*12cc75c8Scindi 	if (nvlist_xalloc(nvlp, nvflag, &mod->tm_alloc->ta_nva) != 0)
48*12cc75c8Scindi 		return (-1);
49*12cc75c8Scindi 
50*12cc75c8Scindi 	return (0);
517aec1d6eScindi }
52822fb41dStsien 
537aec1d6eScindi int
topo_mod_nvdup(topo_mod_t * mod,nvlist_t * nvl,nvlist_t ** nvlp)547aec1d6eScindi topo_mod_nvdup(topo_mod_t *mod, nvlist_t *nvl, nvlist_t **nvlp)
557aec1d6eScindi {
56*12cc75c8Scindi 	if (nvlist_xdup(nvl, nvlp, &mod->tm_alloc->ta_nva) != 0)
57*12cc75c8Scindi 		return (-1);
58*12cc75c8Scindi 
59*12cc75c8Scindi 	return (0);
607aec1d6eScindi }
617c478bd9Sstevel@tonic-gate 
627aec1d6eScindi int
topo_hdl_nvalloc(topo_hdl_t * thp,nvlist_t ** nvlp,uint_t nvflag)637aec1d6eScindi topo_hdl_nvalloc(topo_hdl_t *thp, nvlist_t **nvlp, uint_t nvflag)
647aec1d6eScindi {
657c478bd9Sstevel@tonic-gate 
66*12cc75c8Scindi 	if (nvlist_xalloc(nvlp, nvflag, &thp->th_alloc->ta_nva) != 0)
67*12cc75c8Scindi 		return (-1);
68*12cc75c8Scindi 
69*12cc75c8Scindi 	return (0);
707c478bd9Sstevel@tonic-gate }
717c478bd9Sstevel@tonic-gate 
727aec1d6eScindi int
topo_hdl_nvdup(topo_hdl_t * thp,nvlist_t * nvl,nvlist_t ** nvlp)737aec1d6eScindi topo_hdl_nvdup(topo_hdl_t *thp, nvlist_t *nvl, nvlist_t **nvlp)
747aec1d6eScindi {
75*12cc75c8Scindi 	if (nvlist_xdup(nvl, nvlp, &thp->th_alloc->ta_nva) != 0)
76*12cc75c8Scindi 		return (-1);
77*12cc75c8Scindi 
78*12cc75c8Scindi 	return (0);
797aec1d6eScindi }
80