/*************************************************************** ** ** Broadcom Corp. Confidential ** Copyright 1998-2000 Broadcom Corp. All Rights Reserved. ** ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED ** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM. ** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT ** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. ** ** File: bcmMemMgr.c ** Description: Broadcom Hardware Device Memory Manager ** Created: ** ** REVISION: ** ** $Log: bcmmemmgr.h,v $ ** Revision 1.1.1.1 2003/11/21 18:44:37 root ** Initial DP922 Checkin ** ** ** ****************************************************************/ #ifndef _BCM_MEM_MGR_H_ #define _BCM_MEM_MGR_H_ #include "bstd.h" #define MEM_SIGLEN 8 #define MEM_MAX_FILENAME 32 /* Alignment values */ #define DEFAULT_ALIGN_BITS 2 #define ALIGN_4K 12 /* Align to a 4K byte boundary. */ #ifdef __cplusplus extern "C" { #endif typedef struct bcm_chunk_t bcm_chunk_t; /* Heap control structure */ typedef struct bcm_heap_t { void *start_addr; /* start of heap memory */ void *end_addr; /* end of heap memory */ bcm_chunk_t *first_free; /* first free memory chunk */ bcm_chunk_t *last_free; /* last free memory chunk */ bcm_chunk_t *first; /* first allocated memory chunk */ bcm_chunk_t *last; /* last allocated memory chunk */ } bcm_heap_t; void heap_init(bcm_heap_t * p_heap, unsigned long *p_buf, unsigned long numbytes); void * mem_tagalloc(bcm_heap_t* p_heap, unsigned long size, char alignbits, char* file, int line); #define mem_alloc(x,y,z) mem_tagalloc(x,y,z,__FILE__,__LINE__) void mem_tagfree(bcm_heap_t* p_heap, void* p_ref, char *file, int line); #define mem_free(x,y) mem_tagfree(x,y,__FILE__,__LINE__) unsigned long mem_available(bcm_heap_t* p_heap); #ifdef BCM_DEBUG void mem_report(bcm_heap_t* p_heap); /* reportbrief prints a readable table of the heap */ void mem_reportbrief(bcm_heap_t* p_heap); char mem_validate(bcm_heap_t* p_heap); void mem_debug(bcm_heap_t *p_heap,unsigned char* buf, int width, int height); #if SUPPORT_DST_PLATFORM struct bcm_heap_status { int size_heap; // size of entire heap int num_alloc_chunk; // number of alloc chunk int size_alloc; // total byte size alloc chunk int num_free_chunk; // number of free chunk int size_free; // total byte size free chunk }; void mem_reportbrief_ex(bcm_heap_t *p_heap, int threshold); int mem_status(bcm_heap_t *p_heap, struct bcm_heap_status *p_status); #endif #endif #ifdef __cplusplus } #endif #endif /* _BCM_MEM_MGR_H_ */