1168404Spjd/*
2168404Spjd * CDDL HEADER START
3168404Spjd *
4168404Spjd * The contents of this file are subject to the terms of the
5168404Spjd * Common Development and Distribution License, Version 1.0 only
6168404Spjd * (the "License").  You may not use this file except in compliance
7168404Spjd * with the License.
8168404Spjd *
9168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10168404Spjd * or http://www.opensolaris.org/os/licensing.
11168404Spjd * See the License for the specific language governing permissions
12168404Spjd * and limitations under the License.
13168404Spjd *
14168404Spjd * When distributing Covered Code, include this CDDL HEADER in each
15168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16168404Spjd * If applicable, add the following below this CDDL HEADER, with the
17168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying
18168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner]
19168404Spjd *
20168404Spjd * CDDL HEADER END
21168404Spjd */
22168404Spjd/*
23168404Spjd * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24168404Spjd * Use is subject to license terms.
25168404Spjd */
26168404Spjd
27168404Spjd#pragma ident	"%Z%%M%	%I%	%E% SMI"
28168404Spjd
29168404Spjd#include <sys/nvpair.h>
30168404Spjd
31168404Spjdstatic void *
32168404Spjdnv_alloc_sys(nv_alloc_t *nva, size_t size)
33168404Spjd{
34168404Spjd	return (kmem_alloc(size, (int)(uintptr_t)nva->nva_arg));
35168404Spjd}
36168404Spjd
37168404Spjd/*ARGSUSED*/
38168404Spjdstatic void
39168404Spjdnv_free_sys(nv_alloc_t *nva, void *buf, size_t size)
40168404Spjd{
41168404Spjd	kmem_free(buf, size);
42168404Spjd}
43168404Spjd
44168404Spjdstatic const nv_alloc_ops_t system_ops = {
45168404Spjd	NULL,			/* nv_ao_init() */
46168404Spjd	NULL,			/* nv_ao_fini() */
47168404Spjd	nv_alloc_sys,		/* nv_ao_alloc() */
48168404Spjd	nv_free_sys,		/* nv_ao_free() */
49168404Spjd	NULL			/* nv_ao_reset() */
50168404Spjd};
51168404Spjd
52168404Spjdnv_alloc_t nv_alloc_sleep_def = {
53168404Spjd	&system_ops,
54168404Spjd	(void *)KM_SLEEP
55168404Spjd};
56168404Spjd
57168404Spjdnv_alloc_t nv_alloc_nosleep_def = {
58168404Spjd	&system_ops,
59168404Spjd	(void *)KM_NOSLEEP
60168404Spjd};
61168404Spjd
62168404Spjdnv_alloc_t *nv_alloc_sleep = &nv_alloc_sleep_def;
63168404Spjdnv_alloc_t *nv_alloc_nosleep = &nv_alloc_nosleep_def;
64