Main Page | Modules | Directories | File List | Globals | Related Pages

gm_zone.c File Reference

#include "gm_call_trace.h"
#include "gm_internal.h"
#include "gm_malloc_debug.h"

Functions

GM_ENTRY_POINT struct gm_zone * gm_zone_create_zone (void *base, gm_size_t length)
GM_ENTRY_POINT void gm_zone_destroy_zone (struct gm_zone *zone)
GM_ENTRY_POINT void * gm_zone_free (struct gm_zone *zone, void *a)
GM_ENTRY_POINT void * gm_zone_malloc (struct gm_zone *zone, gm_size_t length)
GM_ENTRY_POINT void * gm_zone_calloc (struct gm_zone *zone, gm_size_t count, gm_size_t length)
GM_ENTRY_POINT int gm_zone_addr_in_zone (struct gm_zone *zone, void *p)

Detailed Description

This file contains the GM API functions gm_zone_create_zone(), gm_zone_destroy_zone(), gm_zone_free(), gm_zone_malloc(), and gm_zone_calloc(), gm_zone_addr_in_zone().

This file provides alloc, calloc, and free routines to manage an externally specified "zone" of memory.

This package use buddy-system memory allocation to allocate (2^n)-byte regions of memory, where "n" is referred to as the "size" of the allocated area of memory.

All allocated (or freed) areas are maximally aligned. A zone is a chunk of memory starting and ending on page boundaries. The size and state of each area are encoded in a pair of bit-arrays. One array has a bit set for each position corresponding to a buddy- boundary. The second array has a bit set for each position corresponding to an area that is not free.

In the code, variables named with "size" are in logarithmic units and those named "length" are in real units.

DEBUGGING

If debugging is turned on, we "mark" all valid areas in the zone, using the gm_mark API, and we check each area passed to a function. This should catch any DMA overruns type corruption of the data structures stored in the managed memory.


Function Documentation

GM_ENTRY_POINT struct gm_zone* gm_zone_create_zone void *  base,
gm_size_t  length
 

gm_zone_create_zone()

Return values:
gm_zone Handle to the GM zone.
Parameters:
base 
length 
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)

GM_ENTRY_POINT void gm_zone_destroy_zone struct gm_zone *  zone  ) 
 

gm_zone_destroy_zone()

Parameters:
zone (IN) Pointer to the GM zone.
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)

GM_ENTRY_POINT void* gm_zone_free struct gm_zone *  zone,
void *  a
 

gm_zone_free()

Parameters:
zone (IN) Pointer to the GM zone.
a 
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)

GM_ENTRY_POINT void* gm_zone_malloc struct gm_zone *  zone,
gm_size_t  length
 

gm_zone_malloc() mallocs a GM zone.

Parameters:
zone (IN) Pointer to the GM zone.
length 
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)

GM_ENTRY_POINT void* gm_zone_calloc struct gm_zone *  zone,
gm_size_t  count,
gm_size_t  length
 

gm_zone_calloc() callocs a GM zone.

Parameters:
zone (IN) Pointer to the GM zone.
count 
length 
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)

GM_ENTRY_POINT int gm_zone_addr_in_zone struct gm_zone *  zone,
void *  p
 

gm_zone_addr_in_zone()

Parameters:
zone (IN) Pointer to the GM zone.
p 
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)


Generated on Sat May 20 19:20:42 2006 for GM by  doxygen 1.4.4