next up previous contents index
Next: 16.8.9 amm_free_func: Free an Up: 16.8 API reference Previous: 16.8.7 amm_find_addr: Locate the

16.8.8 amm_find_gen: Locate a map entry matching specified criteria

 

SYNOPSIS

#include <oskit/amm.h>

amm_entry_t *amm_find_gen(amm_t *amm, [in/out] oskit_addr_t *addrp, oskit_size_t size, int flags, int flagmask, int align_bits, oskit_addr_t align_off, int find_flags);

DESCRIPTION

Returns a pointer to a map entry in the map amm with the indicated attributes which contains an address range of the given size and alignment. If no range can be found, amm_find_gen returns zero.

On call, *addrp contains a ``hint'' at which to start searching for the range. On a successful return, *addrp contains the address chosen; i.e., [*addrp - *addrp+size-1] is the desired range. This address may not be the same as the start address of the chosen map entry.

Flags and flagmask specify the attributes that the returned range must match. Only entries which satisfy ((entry->flags & flagmask) == flags) are considered when looking for a range.

Align_bits and align_off specify the alignment of the returned range. Align_bits specifies an alignment boundary as a power of two, and align_ofs specifies an offset from ``natural'' alignment; i.e. the lowest align_bits bits of the returned address must match the lowest align_bits of align_ofs. For example, align_bits == 12 and align_ofs == 8 would return a range starting 8 bytes past a 4096 byte boundary.

Find_flags can be used to modify the behavior of the lookup:

AMM_EXACT_ADDR. Range must start at the specified address. If that address is unsuitable, amm_find_gen returns zero.

AMM_FORWARD. Search forward from the hint address looking for a match. This is the default behavior.

AMM_BACKWARD. Search backward from the hint address looking for a match. Not implemented.

AMM_FIRSTFIT. Return the first entry found that contains a suitable range. This is the default behavior.

AMM_BESTFIT. Of all entries containing a suitable range, return the entry which is the closest fit. Not implemented.

PARAMETERS

amm
A pointer to the amm_t structure representing the address map.
addrp
On call, pointer to a search hint address. On return, the actual address found.
size
Size of the desired address range.
flags
Attribute flags that an entry must possess after masking with flagmask.
flagmask
Attribute mask to bitwise-AND with when matching an entry.
align_bits
The number of low bits of the returned address that must match the corresponding bits in align_ofs.
align_ofs
The required offset from natural power-of-two alignment. If align_ofs is zero, then the returned address will be naturally aligned on a tex2html_wrap_inline33869 boundary.
find_flags
Flags modifying the behavior of the address space search.

RETURNS

Returns a pointer to the entry containing the desired range, or zero if no suitable range could be found.


next up previous contents index
Next: 16.8.9 amm_free_func: Free an Up: 16.8 API reference Previous: 16.8.7 amm_find_addr: Locate the

University of Utah Flux Research Group