NetBSD/share/man/man9/vmem_xalloc.9

115 lines
3.5 KiB
Groff

.\" $NetBSD: vmem_xalloc.9,v 1.2 2006/11/04 17:16:24 wiz Exp $
.\"
.\" Copyright (c)2006 YAMAMOTO Takashi,
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" ------------------------------------------------------------
.Dd November 4, 2006
.Dt VMEM_XALLOC 9
.Os
.\" ------------------------------------------------------------
.Sh NAME
.Nm vmem_xalloc
.Nd Allocate resource from arena
.\" ------------------------------------------------------------
.Sh SYNOPSIS
.In sys/vmem.h
.\" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.Ft vmem_addr_t
.Fn vmem_xalloc \
"vmem_t *vm" "vmem_size_t size" "vmem_size_t align" \
"vmem_size_t phase" "vmem_size_t nocross" "vmem_addr_t minaddr" \
"vmem_addr_t maxaddr" "vm_flag_t flags"
.\" ------------------------------------------------------------
.Sh DESCRIPTION
.Fn vmem_xalloc
allocates a resource from the arena.
.Pp
.Bl -tag -width nocross
.It Fa vm
The arena which we allocate from.
.It Fa size
Specify the size of the allocation.
.It Fa align
If zero, don't care about the alignment of the allocation.
Otherwise, request a resource segment starting at
offset
.Fa phase
from an
.Fa align
aligned boundary.
.It Fa phase
See the above description of
.Fa align .
If
.Fa align
is zero,
.Fa phase
should be zero.
Otherwise,
.Fa phase
should be smaller than
.Fa align .
.It Fa nocross
Request a resource which doesn't cross
.Fa nocross
aligned boundary.
.It Fa minaddr
If non-zero, specify the minimum address which can be allocated.
.It Fa maxaddr
If non-zero, specify the maximum address + 1 which can be allocated.
.It Fa flags
A bitwise OR of an allocation strategy and a sleep flag.
.Pp
The allocation strategy is one of:
.Bl -tag -width VM_INSTANTFIT
.It Dv VM_BESTFIT
Prefer space efficiency.
.It Dv VM_INSTANTFIT
Prefer performance.
.El
.Pp
The sleep flag should be one of:
.Bl -tag -width VM_NOSLEEP
.It Dv VM_SLEEP
Can sleep until enough resources are available.
.It Dv VM_NOSLEEP
Don't sleep.
Immediately return
.Dv VMEM_ADDR_NULL
if there are not enough resources available.
.El
.El
.\" ------------------------------------------------------------
.Sh RETURN VALUES
On success,
.Fn vmem_xalloc
returns an allocated vmem_addr_t.
Otherwise, it returns
.Dv VMEM_ADDR_NULL .
.\" ------------------------------------------------------------
.Sh SEE ALSO
.Xr intro 9 ,
.Xr vmem 9