Main Page Modules Data Structures File List Data Fields Globals Related Pages
gm_zone.c File Reference
#include "gm_call_trace.h"
#include "gm_internal.h"
#include "gm_malloc_debug.h"
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.
Define Documentation
#define GM_AREA_FOR_PTR |
( |
ptr |
|
) |
|
|
Typedef Documentation
|
Zones are divided into managed buffers called "areas", which may either represent free buffers or buffers holding user data. |
|
State of a zone, which is a region of memory from which one can allocate memory using the zone allocation functions. |
Function Documentation
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_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 Mon Nov 3 15:39:26 2003 for GM by
1.2.15