00001
00002
00003
00004
00005
00006
00007
00019 #ifndef OSCL_MEM_AUDIT_INTERNALS_H
00020 #define OSCL_MEM_AUDIT_INTERNALS_H
00021
00022
00023 #include "oscl_base.h"
00024 #include "oscl_mem_audit.h"
00025 #include "oscl_mem_inst.h"
00026
00027 #define OSCL_DISABLE_WARNING_TRUNCATE_DEBUG_MESSAGE
00028 #include "osclconfig_compiler_warnings.h"
00029
00030 #if(PVMEM_INST_LEVEL>0)
00031 #define MM_AUDIT_ALLOC_NODE_SUPPORT 1
00032 #define MM_AUDIT_FENCE_SUPPORT 1
00033 #define MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION 1
00034 #define MM_AUDIT_FILL_SUPPORT 1
00035 #define MM_AUDIT_FAILURE_SIMULATION_SUPPORT 1
00036 #else
00037 #define MM_AUDIT_ALLOC_NODE_SUPPORT 1
00038 #define MM_AUDIT_FENCE_SUPPORT 0
00039 #define MM_AUDIT_INCLUDE_ALL_HEAP_VALIDATION 1
00040 #define MM_AUDIT_FILL_SUPPORT 0
00041 #define MM_AUDIT_FAILURE_SIMULATION_SUPPORT 1
00042 #endif
00043
00044 #define FENCE_PATTERN 0xAA
00045 #define MIN_FENCE_SIZE 4
00046
00047 #ifdef MEM_ALIGN_4
00048 #define MEM_ALIGN_SIZE 4
00049 #else
00050 #define MEM_ALIGN_SIZE 8
00051 #endif
00052
00053
00054
00055
00056
00057
00058
00059
00060 struct MM_AllocBlockHdr
00061 {
00062 void *pNode;
00063 uint32 size;
00064
00065 void *pRootNode;
00066 uint32 pad;
00067
00068
00069
00070
00071
00072 static const uint32 ALLOC_NODE_FLAG;
00073
00074 bool isAllocNodePtr()
00075 {
00076 return ((size & ALLOC_NODE_FLAG) != 0);
00077 };
00078 void setAllocNodeFlag()
00079 {
00080 size |= ALLOC_NODE_FLAG;
00081 };
00082
00083 MM_AllocBlockHdr(): pNode(0), size(0), pRootNode(0) {};
00084 MM_AllocBlockHdr(void* ptr, uint32 inSize): pNode(ptr), size(inSize) {};
00085 };
00086
00087
00088 const uint32 MM_AllocBlockHdr::ALLOC_NODE_FLAG = 0x80000000;
00089
00090 #define COMPUTE_MEM_ALIGN_SIZE(x,y,z) (y+(((x+y)%z) ? (z - (x+y)%z) : 0))
00091
00092 struct MM_AllocBlockFence
00093 {
00094
00095 uint8 pad[COMPUTE_MEM_ALIGN_SIZE(sizeof(MM_AllocBlockHdr), MIN_FENCE_SIZE, MEM_ALIGN_SIZE)];
00096 MM_AllocBlockFence()
00097 {
00098 fill_fence();
00099 };
00100
00101 void fill_fence()
00102 {
00103 oscl_memset(pad, FENCE_PATTERN, sizeof(pad));
00104 };
00105
00106 bool check_fence()
00107 {
00108 for (uint ii = 0; ii < sizeof(pad); ++ii)
00109 {
00110 if (pad[ii] != FENCE_PATTERN) return false;
00111 }
00112 return true;
00113 };
00114 };
00115
00116
00117
00118
00119 #define DEFAULT_PREFILL_PATTERN 0x96
00120 #define DEFAULT_POSTFILL_PATTERN 0x5A
00121
00122
00123
00124
00125
00126 #endif
00127