| 1 | /*************************************************************** |
|---|
| 2 | ** |
|---|
| 3 | ** Broadcom Corp. Confidential |
|---|
| 4 | ** Copyright 1998-2000 Broadcom Corp. All Rights Reserved. |
|---|
| 5 | ** |
|---|
| 6 | ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED |
|---|
| 7 | ** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM. |
|---|
| 8 | ** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT |
|---|
| 9 | ** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 10 | ** |
|---|
| 11 | ** File: bcmMemMgr.c |
|---|
| 12 | ** Description: Broadcom Hardware Device Memory Manager |
|---|
| 13 | ** Created: |
|---|
| 14 | ** |
|---|
| 15 | ** REVISION: |
|---|
| 16 | ** |
|---|
| 17 | ** $Log: bcmmemmgr.h,v $ |
|---|
| 18 | ** Revision 1.1.1.1 2003/11/21 18:44:37 root |
|---|
| 19 | ** Initial DP922 Checkin |
|---|
| 20 | ** |
|---|
| 21 | ** |
|---|
| 22 | ** |
|---|
| 23 | ****************************************************************/ |
|---|
| 24 | #ifndef _BCM_MEM_MGR_H_ |
|---|
| 25 | #define _BCM_MEM_MGR_H_ |
|---|
| 26 | |
|---|
| 27 | #include "bstd.h" |
|---|
| 28 | |
|---|
| 29 | #define MEM_SIGLEN 8 |
|---|
| 30 | #define MEM_MAX_FILENAME 32 |
|---|
| 31 | |
|---|
| 32 | /* Alignment values */ |
|---|
| 33 | #define DEFAULT_ALIGN_BITS 2 |
|---|
| 34 | #define ALIGN_4K 12 /* Align to a 4K byte boundary. */ |
|---|
| 35 | |
|---|
| 36 | #ifdef __cplusplus |
|---|
| 37 | extern "C" { |
|---|
| 38 | #endif |
|---|
| 39 | typedef struct bcm_chunk_t bcm_chunk_t; |
|---|
| 40 | |
|---|
| 41 | /* Heap control structure */ |
|---|
| 42 | typedef struct bcm_heap_t |
|---|
| 43 | { |
|---|
| 44 | void *start_addr; /* start of heap memory */ |
|---|
| 45 | void *end_addr; /* end of heap memory */ |
|---|
| 46 | |
|---|
| 47 | bcm_chunk_t *first_free; /* first free memory chunk */ |
|---|
| 48 | bcm_chunk_t *last_free; /* last free memory chunk */ |
|---|
| 49 | |
|---|
| 50 | bcm_chunk_t *first; /* first allocated memory chunk */ |
|---|
| 51 | bcm_chunk_t *last; /* last allocated memory chunk */ |
|---|
| 52 | } bcm_heap_t; |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | void heap_init(bcm_heap_t * p_heap, unsigned long *p_buf, |
|---|
| 56 | unsigned long numbytes); |
|---|
| 57 | |
|---|
| 58 | void * mem_tagalloc(bcm_heap_t* p_heap, unsigned long size, char alignbits, char* file, int line); |
|---|
| 59 | #define mem_alloc(x,y,z) mem_tagalloc(x,y,z,__FILE__,__LINE__) |
|---|
| 60 | |
|---|
| 61 | void mem_tagfree(bcm_heap_t* p_heap, void* p_ref, char *file, int line); |
|---|
| 62 | #define mem_free(x,y) mem_tagfree(x,y,__FILE__,__LINE__) |
|---|
| 63 | |
|---|
| 64 | unsigned long mem_available(bcm_heap_t* p_heap); |
|---|
| 65 | |
|---|
| 66 | #ifdef BCM_DEBUG |
|---|
| 67 | void mem_report(bcm_heap_t* p_heap); |
|---|
| 68 | /* reportbrief prints a readable table of the heap */ |
|---|
| 69 | void mem_reportbrief(bcm_heap_t* p_heap); |
|---|
| 70 | char mem_validate(bcm_heap_t* p_heap); |
|---|
| 71 | void mem_debug(bcm_heap_t *p_heap,unsigned char* buf, |
|---|
| 72 | int width, int height); |
|---|
| 73 | #if SUPPORT_DST_PLATFORM |
|---|
| 74 | |
|---|
| 75 | struct bcm_heap_status |
|---|
| 76 | { |
|---|
| 77 | int size_heap; // size of entire heap |
|---|
| 78 | |
|---|
| 79 | int num_alloc_chunk; // number of alloc chunk |
|---|
| 80 | int size_alloc; // total byte size alloc chunk |
|---|
| 81 | |
|---|
| 82 | int num_free_chunk; // number of free chunk |
|---|
| 83 | int size_free; // total byte size free chunk |
|---|
| 84 | }; |
|---|
| 85 | |
|---|
| 86 | void mem_reportbrief_ex(bcm_heap_t *p_heap, int threshold); |
|---|
| 87 | int mem_status(bcm_heap_t *p_heap, struct bcm_heap_status *p_status); |
|---|
| 88 | #endif |
|---|
| 89 | |
|---|
| 90 | #endif |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | #ifdef __cplusplus |
|---|
| 94 | } |
|---|
| 95 | #endif |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | #endif /* _BCM_MEM_MGR_H_ */ |
|---|