17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
512cc75ccindi * Common Development and Distribution License (the "License").
612cc75ccindi * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
217c478bdstevel@tonic-gate/*
2212cc75ccindi * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bdstevel@tonic-gate * Use is subject to license terms.
247c478bdstevel@tonic-gate */
257c478bdstevel@tonic-gate
267c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bdstevel@tonic-gate
287aec1d6cindi#include <umem.h>
297aec1d6cindi#include <topo_alloc.h>
307aec1d6cindi#include <topo_module.h>
31822fb41tsien
327aec1d6cindi/*ARGSUSED*/
337aec1d6cindivoid *
347aec1d6cinditopo_nv_alloc(nv_alloc_t *nva, size_t size)
357aec1d6cindi{
367aec1d6cindi	return (topo_zalloc(size, UMEM_DEFAULT));
377aec1d6cindi}
38822fb41tsien
397aec1d6cindi/*ARGSUSED*/
407aec1d6cindivoid
417aec1d6cinditopo_nv_free(nv_alloc_t *nva, void *data, size_t size)
427aec1d6cindi{
437aec1d6cindi	topo_free(data, size);
447aec1d6cindi}
45822fb41tsien
467aec1d6cindiint
477aec1d6cinditopo_mod_nvalloc(topo_mod_t *mod, nvlist_t **nvlp, uint_t nvflag)
487aec1d6cindi{
4912cc75ccindi	if (nvlist_xalloc(nvlp, nvflag, &mod->tm_alloc->ta_nva) != 0)
5012cc75ccindi		return (-1);
5112cc75ccindi
5212cc75ccindi	return (0);
537aec1d6cindi}
54822fb41tsien
557aec1d6cindiint
567aec1d6cinditopo_mod_nvdup(topo_mod_t *mod, nvlist_t *nvl, nvlist_t **nvlp)
577aec1d6cindi{
5812cc75ccindi	if (nvlist_xdup(nvl, nvlp, &mod->tm_alloc->ta_nva) != 0)
5912cc75ccindi		return (-1);
6012cc75ccindi
6112cc75ccindi	return (0);
627aec1d6cindi}
637c478bdstevel@tonic-gate
647aec1d6cindiint
657aec1d6cinditopo_hdl_nvalloc(topo_hdl_t *thp, nvlist_t **nvlp, uint_t nvflag)
667aec1d6cindi{
677c478bdstevel@tonic-gate
6812cc75ccindi	if (nvlist_xalloc(nvlp, nvflag, &thp->th_alloc->ta_nva) != 0)
6912cc75ccindi		return (-1);
7012cc75ccindi
7112cc75ccindi	return (0);
727c478bdstevel@tonic-gate}
737c478bdstevel@tonic-gate
747aec1d6cindiint
757aec1d6cinditopo_hdl_nvdup(topo_hdl_t *thp, nvlist_t *nvl, nvlist_t **nvlp)
767aec1d6cindi{
7712cc75ccindi	if (nvlist_xdup(nvl, nvlp, &thp->th_alloc->ta_nva) != 0)
7812cc75ccindi		return (-1);
7912cc75ccindi
8012cc75ccindi	return (0);
817aec1d6cindi}
82