'\"macro stdmacro
.if n .pH ddi_dki.kmem_alloc @(#)kmem_alloc	40.6 of 10/10/89
.\" Copyright 1989 AT&T
.de IX
.ie '\\n(.z'' .tm .Index: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9	\\n%
.el \\!.IX \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.nr X
.if \nX=0 .ds x} kmem_alloc D3DK "" "DDI/DKI" "\&"
.if \nX=1 .ds x} kmem_alloc D3DK "" "DDI/DKI"
.if \nX=2 .ds x} kmem_alloc D3DK "" "\&"
.if \nX=3 .ds x} kmem_alloc "" "" "\&"
.TH \*(x}
.SH NAME
\f4kmem_alloc\f1 \- allocate space from kernel free memory
.IX "\f4kmem_alloc\fP(D3DK)"
.SH SYNOPSIS
.nf
.na
\f4#include <sys/types.h>
#include <sys/kmem.h>
.sp 0.5
_VOID *kmem_alloc(size_t \f2size, \f4int \f2flag\f4);\f1
.ad
.fi
.SH ARGUMENTS
.RS 0n 10
.IP "\f2size\f1" 10n
Number of bytes to allocate.
.IP "\f2flag\f1" 10n
Determines if caller will sleep to wait for free space.  Possible flags
are \f4KM_SLEEP\f1 to sleep while waiting for free space, and
\f4KM_NOSLEEP\f1 to return NULL if space is not available.
.RE
.SH DESCRIPTION
The \f4kmem_alloc\f1 function allocates a specified amount of kernel
memory in bytes and returns a pointer to the allocated memory.  The
\f2flag\f1 argument determines whether the function will sleep while waiting
for free space to be released.  If \f2flag\f1 has \f4KM_SLEEP\f1 set,
the caller may sleep until free space is available.  If \f2flag\f1 has
\f4KM_NOSLEEP\f1 set and space is not available, \f4NULL\f1 will be
returned.
.P
\f3NOTE:\f1
Memory allocated by \f4kmem_alloc\f1 is not paged.
Available memory is therefore limited.  Excessive use of this memory is
likely to affect overall system performance.
.SH RETURN VALUE
If successfull, \f4kmem_alloc\f1 returns a pointer to the allocated
space.  \f4NULL\f1 is returned if \f4KM_NOSLEEP\f1 is set and memory
cannot be allocated.
.SH LEVEL
Base (interrupt only if \f4KM_NOSLEEP\f1 is set in \f2flag\f1)
.SH SEE ALSO
.na
\f4freerbuf\f1(D3DK),
\f4getrbuf\f1(D3DK),
\f4kmem_free\f1(D3DK),
\f4kmem_zalloc\f1(D3DK),
\f4rmalloc\f1(D3DK),
\f4rmfree\f1(D3DK),
\f4rminit\f1(D3DK),
\f4rmsetwant\f1(D3DK),
\f4rmwant\f1(D3DK)
.ad
