11414Scindi /*
21414Scindi * CDDL HEADER START
31414Scindi *
41414Scindi * The contents of this file are subject to the terms of the
5*4328Scindi * Common Development and Distribution License (the "License").
6*4328Scindi * You may not use this file except in compliance with the License.
71414Scindi *
81414Scindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91414Scindi * or http://www.opensolaris.org/os/licensing.
101414Scindi * See the License for the specific language governing permissions
111414Scindi * and limitations under the License.
121414Scindi *
131414Scindi * When distributing Covered Code, include this CDDL HEADER in each
141414Scindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151414Scindi * If applicable, add the following below this CDDL HEADER, with the
161414Scindi * fields enclosed by brackets "[]" replaced with your own identifying
171414Scindi * information: Portions Copyright [yyyy] [name of copyright owner]
181414Scindi *
191414Scindi * CDDL HEADER END
201414Scindi */
211414Scindi /*
22*4328Scindi * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
231414Scindi * Use is subject to license terms.
241414Scindi */
251414Scindi
261414Scindi #pragma ident "%Z%%M% %I% %E% SMI"
271414Scindi
281414Scindi #include <umem.h>
291414Scindi #include <topo_alloc.h>
301414Scindi #include <topo_module.h>
311414Scindi
321414Scindi /*ARGSUSED*/
331414Scindi void *
topo_nv_alloc(nv_alloc_t * nva,size_t size)341414Scindi topo_nv_alloc(nv_alloc_t *nva, size_t size)
351414Scindi {
361414Scindi return (topo_zalloc(size, UMEM_DEFAULT));
371414Scindi }
381414Scindi
391414Scindi /*ARGSUSED*/
401414Scindi void
topo_nv_free(nv_alloc_t * nva,void * data,size_t size)411414Scindi topo_nv_free(nv_alloc_t *nva, void *data, size_t size)
421414Scindi {
431414Scindi topo_free(data, size);
441414Scindi }
451414Scindi
461414Scindi int
topo_mod_nvalloc(topo_mod_t * mod,nvlist_t ** nvlp,uint_t nvflag)471414Scindi topo_mod_nvalloc(topo_mod_t *mod, nvlist_t **nvlp, uint_t nvflag)
481414Scindi {
49*4328Scindi if (nvlist_xalloc(nvlp, nvflag, &mod->tm_alloc->ta_nva) != 0)
50*4328Scindi return (-1);
51*4328Scindi
52*4328Scindi return (0);
531414Scindi }
541414Scindi
551414Scindi int
topo_mod_nvdup(topo_mod_t * mod,nvlist_t * nvl,nvlist_t ** nvlp)561414Scindi topo_mod_nvdup(topo_mod_t *mod, nvlist_t *nvl, nvlist_t **nvlp)
571414Scindi {
58*4328Scindi if (nvlist_xdup(nvl, nvlp, &mod->tm_alloc->ta_nva) != 0)
59*4328Scindi return (-1);
60*4328Scindi
61*4328Scindi return (0);
621414Scindi }
631414Scindi
641414Scindi int
topo_hdl_nvalloc(topo_hdl_t * thp,nvlist_t ** nvlp,uint_t nvflag)651414Scindi topo_hdl_nvalloc(topo_hdl_t *thp, nvlist_t **nvlp, uint_t nvflag)
661414Scindi {
671414Scindi
68*4328Scindi if (nvlist_xalloc(nvlp, nvflag, &thp->th_alloc->ta_nva) != 0)
69*4328Scindi return (-1);
70*4328Scindi
71*4328Scindi return (0);
721414Scindi }
731414Scindi
741414Scindi int
topo_hdl_nvdup(topo_hdl_t * thp,nvlist_t * nvl,nvlist_t ** nvlp)751414Scindi topo_hdl_nvdup(topo_hdl_t *thp, nvlist_t *nvl, nvlist_t **nvlp)
761414Scindi {
77*4328Scindi if (nvlist_xdup(nvl, nvlp, &thp->th_alloc->ta_nva) != 0)
78*4328Scindi return (-1);
79*4328Scindi
80*4328Scindi return (0);
811414Scindi }
82