xref: /illumos-gate/usr/src/man/man9f/rmfree.9f (revision 5422785d352a2bb398daceab3d1898a8aa64d006)
te
Copyright (c) 2006, Sun Microsystems, Inc.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
RMFREE 9F "Jan 16, 2006"
NAME
rmfree - free space back into a resource map
SYNOPSIS

#include <sys/map.h>
#include <sys/ddi.h>



void rmfree(struct map *mp, size_t size, ulong_t index);
INTERFACE LEVEL

Architecture independent level 1 (DDI/DKI).

PARAMETERS
mp

Pointer to the map structure.

size

Number of units being freed.

index

Index of the first unit of the allocated resource.

DESCRIPTION

The rmfree() function releases space back into a resource map. It is the opposite of rmalloc(9F), which allocates space that is controlled by a resource map structure.

When releasing resources using rmfree() the size and index passed to rmfree() must exactly match the size and index values passed to and returned from a previous call to rmalloc(). Resources cannot be returned piecemeal.

Drivers may define resource maps for resource allocation, in terms of arbitrary units, using the rmallocmap(9F) function. The system maintains the resource map structure by size and index, computed in units appropriate for the resource. For example, units may be byte addresses, pages of memory, or blocks. rmfree() frees up unallocated space for re-use.

The rmfree() function can also be used to initialize a resource map, in which case the size and index should cover the entire resource area.

CONTEXT

The rmfree() function can be called from user, interrupt, or kernel context.

SEE ALSO

rmalloc(9F), rmalloc_wait(9F), rmallocmap(9F), rmfreemap(9F)

Writing Device Drivers