next up previous contents index
Next: 16.8.12 amm_iterate: Call a Up: 16.8 API reference Previous: 16.8.10 amm_init: initialize an

16.8.11 amm_init_gen: initialize an address map

 

SYNOPSIS

#include <oskit/amm.h>

void amm_init_gen(amm_t *amm, int flags, amm_entry_t *entry, amm_entry_t *(*amm_alloc_func)(), void (*amm_free_func)(), int (*amm_split_func)(), int (*amm_join_func)());

DESCRIPTION

This function initializes an address map. The caller must provide a pointer to an amm_t structure; the AMM system uses this structure to keep track of the state of the address map. In subsequent AMM operations, the caller must pass a pointer to the same amm_t structure, which acts as a handle for the address map.

The map is initialized to contain a single entry describing the maximum possible address range [AMM_MINADDR - AMM_MAXADDR] and have the attributes specified in flags. If the entry parameter is non-zero, it is used as the initial entry. This allows the caller to allocate a structure larger than the basic amm_entry_t and store additional attribute data in the extended structure. If the caller supplies such an entry they must have initialized any caller-private data in that entry, but amm_init_gen will initialize the AMM-private part (the actual amm_entry_t). If entry is zero, a standard entry will be allocated using the default or caller-provided entry allocation routine (described below).

The four function pointer parameters permit the caller to customize AMM entry management on a per-AMM basis. If non-zero, amm_alloc_func and amm_free_func specify routines that the AMM library will callout to whenever an AMM entry is to be created or destroyed. If zero, malloc and free are used to manage basic amm_entry_t structures.

If non-zero, amm_split_func and amm_join_func specify routines that the AMM library will callout to whenever an AMM entry needs to be split or two entries need to be joined. If zero, default split and join calls are used. Split and join calls only occur as a side-effect of an amm_modify call.

When using extended AMM structures, the caller needs to provide free, split and join functions. The alloc function is not strictly necessary since the two AMM functions which create entries, amm_init_gen and amm_modify, have explicit entry parameters, and the third function which can create an entry, amm_split_func, will be caller-provided. The allocation hook is primarily provided to allow the caller control over the placement of AMM entry storage.

PARAMETERS

amm
A pointer to an uninitialized structure of type amm_t which is to be used to represent the address map.
flags
Initial attribute flags to assign to the entry representing the entire address range.
entry
Initial entry to associate with the map.
amm_alloc_func
If non-zero, the function called whenever the AMM library needs to allocate a new map entry.
amm_free_func
If non-zero, the function called whenever the AMM library needs to destroy a map entry.
amm_split_func
If non-zero, the function called whenever the AMM library needs to split an existing map entry into two entries.
amm_join_func
If non-zero, the function called whenever the AMM library needs to join adjacent map entries.

RELATED INFORMATION

amm_alloc_func, amm_free_func, amm_join_func, amm_split_func


next up previous contents index
Next: 16.8.12 amm_iterate: Call a Up: 16.8 API reference Previous: 16.8.10 amm_init: initialize an

University of Utah Flux Research Group