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 
267c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate 
287aec1d6eScindi #include <umem.h>
297aec1d6eScindi #include <topo_alloc.h>
307aec1d6eScindi #include <topo_module.h>
31822fb41dStsien 
327aec1d6eScindi /*ARGSUSED*/
337aec1d6eScindi void *
topo_nv_alloc(nv_alloc_t * nva,size_t size)347aec1d6eScindi topo_nv_alloc(nv_alloc_t *nva, size_t size)
357aec1d6eScindi {
367aec1d6eScindi 	return (topo_zalloc(size, UMEM_DEFAULT));
377aec1d6eScindi }
38822fb41dStsien 
397aec1d6eScindi /*ARGSUSED*/
407aec1d6eScindi void
topo_nv_free(nv_alloc_t * nva,void * data,size_t size)417aec1d6eScindi topo_nv_free(nv_alloc_t *nva, void *data, size_t size)
427aec1d6eScindi {
437aec1d6eScindi 	topo_free(data, size);
447aec1d6eScindi }
45822fb41dStsien 
467aec1d6eScindi int
topo_mod_nvalloc(topo_mod_t * mod,nvlist_t ** nvlp,uint_t nvflag)477aec1d6eScindi topo_mod_nvalloc(topo_mod_t *mod, nvlist_t **nvlp, uint_t nvflag)
487aec1d6eScindi {
49*12cc75c8Scindi 	if (nvlist_xalloc(nvlp, nvflag, &mod->tm_alloc->ta_nva) != 0)
50*12cc75c8Scindi 		return (-1);
51*12cc75c8Scindi 
52*12cc75c8Scindi 	return (0);
537aec1d6eScindi }
54822fb41dStsien 
557aec1d6eScindi int
topo_mod_nvdup(topo_mod_t * mod,nvlist_t * nvl,nvlist_t ** nvlp)567aec1d6eScindi topo_mod_nvdup(topo_mod_t *mod, nvlist_t *nvl, nvlist_t **nvlp)
577aec1d6eScindi {
58*12cc75c8Scindi 	if (nvlist_xdup(nvl, nvlp, &mod->tm_alloc->ta_nva) != 0)
59*12cc75c8Scindi 		return (-1);
60*12cc75c8Scindi 
61*12cc75c8Scindi 	return (0);
627aec1d6eScindi }
637c478bd9Sstevel@tonic-gate 
647aec1d6eScindi int
topo_hdl_nvalloc(topo_hdl_t * thp,nvlist_t ** nvlp,uint_t nvflag)657aec1d6eScindi topo_hdl_nvalloc(topo_hdl_t *thp, nvlist_t **nvlp, uint_t nvflag)
667aec1d6eScindi {
677c478bd9Sstevel@tonic-gate 
68*12cc75c8Scindi 	if (nvlist_xalloc(nvlp, nvflag, &thp->th_alloc->ta_nva) != 0)
69*12cc75c8Scindi 		return (-1);
70*12cc75c8Scindi 
71*12cc75c8Scindi 	return (0);
727c478bd9Sstevel@tonic-gate }
737c478bd9Sstevel@tonic-gate 
747aec1d6eScindi int
topo_hdl_nvdup(topo_hdl_t * thp,nvlist_t * nvl,nvlist_t ** nvlp)757aec1d6eScindi topo_hdl_nvdup(topo_hdl_t *thp, nvlist_t *nvl, nvlist_t **nvlp)
767aec1d6eScindi {
77*12cc75c8Scindi 	if (nvlist_xdup(nvl, nvlp, &thp->th_alloc->ta_nva) != 0)
78*12cc75c8Scindi 		return (-1);
79*12cc75c8Scindi 
80*12cc75c8Scindi 	return (0);
817aec1d6eScindi }
82