astyle --recursive --indent=spaces=2 --style=kr --indent-col1-comments --break-blocks --convert-tabs --max-code-length=200
This is done for better merging branch/LG_PRE_RELEASE_0.3 into trunk (same process is applied on this branch) git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7073 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
+165
-91
@@ -59,76 +59,95 @@ uint32_t counters[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
void *
|
||||
pool_buffer_init ()
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uint32_t index, mb_index, pool_index;
|
||||
mem_pool *memory = (mem_pool *) &mem_block_var;
|
||||
int pool_sizes[14] = { MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB1_NB_BLOCKS,
|
||||
MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB3_NB_BLOCKS,
|
||||
MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB5_NB_BLOCKS,
|
||||
MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB7_NB_BLOCKS,
|
||||
MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB9_NB_BLOCKS,
|
||||
MEM_MNGT_MB10_NB_BLOCKS, MEM_MNGT_MB11_NB_BLOCKS,
|
||||
MEM_MNGT_MB12_NB_BLOCKS, MEM_MNGT_MBCOPY_NB_BLOCKS
|
||||
};
|
||||
MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB3_NB_BLOCKS,
|
||||
MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB5_NB_BLOCKS,
|
||||
MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB7_NB_BLOCKS,
|
||||
MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB9_NB_BLOCKS,
|
||||
MEM_MNGT_MB10_NB_BLOCKS, MEM_MNGT_MB11_NB_BLOCKS,
|
||||
MEM_MNGT_MB12_NB_BLOCKS, MEM_MNGT_MBCOPY_NB_BLOCKS
|
||||
};
|
||||
|
||||
memset (memory, 0, sizeof (mem_pool));
|
||||
mb_index = 0;
|
||||
|
||||
// LG_TEST
|
||||
for (pool_index = 0; pool_index <= MEM_MNGT_POOL_ID_COPY; pool_index++) {
|
||||
list_init (&memory->mem_lists[pool_index], "POOL");
|
||||
|
||||
for (index = 0; index < pool_sizes[pool_index]; index++) {
|
||||
//memory->mem_blocks[mb_index + index].previous = NULL; -> done in memset 0
|
||||
//memory->mem_blocks[mb_index + index].next = NULL; -> done in memset 0
|
||||
switch (pool_index) {
|
||||
case 0:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool0[index][0]);
|
||||
break;
|
||||
case 1:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool1[index][0]);
|
||||
break;
|
||||
case 2:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool2[index][0]);
|
||||
break;
|
||||
case 3:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool3[index][0]);
|
||||
break;
|
||||
case 4:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool4[index][0]);
|
||||
break;
|
||||
case 5:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool5[index][0]);
|
||||
break;
|
||||
case 6:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool6[index][0]);
|
||||
break;
|
||||
case 7:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool7[index][0]);
|
||||
break;
|
||||
case 8:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool8[index][0]);
|
||||
break;
|
||||
case 9:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool9[index][0]);
|
||||
break;
|
||||
case 10:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool10[index][0]);
|
||||
break;
|
||||
case 11:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool11[index][0]);
|
||||
break;
|
||||
case 12:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool12[index][0]);
|
||||
break;
|
||||
default:;
|
||||
memory->mem_blocks[mb_index + index].data = NULL; // pool copy
|
||||
case 0:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool0[index][0]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool1[index][0]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool2[index][0]);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool3[index][0]);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool4[index][0]);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool5[index][0]);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool6[index][0]);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool7[index][0]);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool8[index][0]);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool9[index][0]);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool10[index][0]);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool11[index][0]);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
memory->mem_blocks[mb_index + index].data = (unsigned char*)&(memory->mem_pool12[index][0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
memory->mem_blocks[mb_index + index].data = NULL; // pool copy
|
||||
|
||||
}
|
||||
|
||||
memory->mem_blocks[mb_index + index].pool_id = pool_index;
|
||||
list_add_tail_eurecom (&memory->mem_blocks[mb_index + index], &memory->mem_lists[pool_index]);
|
||||
}
|
||||
|
||||
mb_index += pool_sizes[pool_index];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -136,31 +155,32 @@ pool_buffer_init ()
|
||||
void *
|
||||
pool_buffer_clean (void *arg)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
return 0;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
free_mem_block (mem_block_t * leP)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
if (!(leP)) {
|
||||
msg ("[MEM_MNGT][FREE] WARNING FREE NULL MEM_BLOCK\n");
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG_MEM_MNGT_FREE
|
||||
|
||||
#ifdef DEBUG_MEM_MNGT_FREE
|
||||
msg ("[MEM_MNGT][FREE] free_mem_block() %p pool: %d\n", leP, leP->pool_id);
|
||||
#endif
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
#endif
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
check_free_mem_block (leP);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (leP->pool_id <= MEM_MNGT_POOL_ID_COPY) {
|
||||
list_add_tail_eurecom (leP, &mem_block_var.mem_lists[leP->pool_id]);
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
counters[leP->pool_id] -= 1;
|
||||
#endif
|
||||
#endif
|
||||
leP = NULL; // this prevent from freeing the block twice
|
||||
} else {
|
||||
msg ("[MEM_MNGT][FREE] ERROR free_mem_block() unknown pool_id : %d\n", leP->pool_id);
|
||||
@@ -171,18 +191,18 @@ free_mem_block (mem_block_t * leP)
|
||||
mem_block_t *
|
||||
get_free_mem_block (uint16_t sizeP)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
mem_block_t *le = NULL;
|
||||
int pool_selected;
|
||||
int size;
|
||||
|
||||
// next block commented, because sizeP > MEM_MNGT_MB12_BLOCK_SIZE can never be true.
|
||||
// if (sizeP > MEM_MNGT_MB12_BLOCK_SIZE) {
|
||||
// msg ("[MEM_MNGT][ERROR][FATAL] size requested %d out of bounds\n", sizeP);
|
||||
// display_mem_load ();
|
||||
// mac_xface->macphy_exit("[MEM_MNGT][ERROR][FATAL] get_free_mem_block size requested out of bounds");
|
||||
// return NULL;
|
||||
// }
|
||||
// next block commented, because sizeP > MEM_MNGT_MB12_BLOCK_SIZE can never be true.
|
||||
// if (sizeP > MEM_MNGT_MB12_BLOCK_SIZE) {
|
||||
// msg ("[MEM_MNGT][ERROR][FATAL] size requested %d out of bounds\n", sizeP);
|
||||
// display_mem_load ();
|
||||
// mac_xface->macphy_exit("[MEM_MNGT][ERROR][FATAL] get_free_mem_block size requested out of bounds");
|
||||
// return NULL;
|
||||
// }
|
||||
size = sizeP >> 6;
|
||||
pool_selected = 0;
|
||||
|
||||
@@ -195,21 +215,22 @@ get_free_mem_block (uint16_t sizeP)
|
||||
// if no block is available pick one in an other pool
|
||||
do {
|
||||
if ((le = list_remove_head (&mem_block_var.mem_lists[pool_selected]))) {
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
counters[pool_selected] += 1;
|
||||
#endif
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC_SIZE
|
||||
#endif
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC_SIZE
|
||||
msg ("[MEM_MNGT][INFO] ALLOC MEM_BLOCK SIZE %d bytes pool %d (%p)\n", sizeP, pool_selected,le);
|
||||
#endif
|
||||
#endif
|
||||
return le;
|
||||
}
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
msg ("[MEM_MNGT][ERROR][MINOR] memory pool %d is empty trying next pool alloc count = %d\n", pool_selected, counters[pool_selected]);
|
||||
#ifdef USER_MODE
|
||||
#ifdef USER_MODE
|
||||
// display_mem_load ();
|
||||
// check_mem_area ((void *)&mem_block_var);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
} while (pool_selected++ < 12);
|
||||
|
||||
display_mem_load();
|
||||
@@ -221,12 +242,12 @@ get_free_mem_block (uint16_t sizeP)
|
||||
mem_block_t *
|
||||
get_free_copy_mem_block (void)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
mem_block_t *le;
|
||||
|
||||
if ((le = list_remove_head (&mem_block_var.mem_lists[MEM_MNGT_POOL_ID_COPY]))) {
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC_SIZE
|
||||
msg ("[MEM_MNGT][INFO] ALLOC COPY MEM BLOCK (%p)\n",le);
|
||||
msg ("[MEM_MNGT][INFO] ALLOC COPY MEM BLOCK (%p)\n",le);
|
||||
#endif
|
||||
return le;
|
||||
} else {
|
||||
@@ -245,13 +266,14 @@ get_free_copy_mem_block (void)
|
||||
mem_block_t *
|
||||
copy_mem_block (mem_block_t * leP, mem_block_t * destP)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
if ((destP != NULL) && (leP != NULL) && (destP->pool_id == MEM_MNGT_POOL_ID_COPY)) {
|
||||
destP->data = leP->data;
|
||||
} else {
|
||||
msg ("[MEM_MNGT][COPY] copy_mem_block() pool dest src or dest is NULL\n");
|
||||
}
|
||||
|
||||
return destP;
|
||||
}
|
||||
|
||||
@@ -259,7 +281,7 @@ copy_mem_block (mem_block_t * leP, mem_block_t * destP)
|
||||
void
|
||||
display_mem_load (void)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
mem_pool *memory = (mem_pool *) &mem_block_var;
|
||||
|
||||
@@ -297,7 +319,7 @@ display_mem_load (void)
|
||||
void
|
||||
check_mem_area (void)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
int index, mb_index;
|
||||
mem_pool *memory = (mem_pool *) &mem_block_var;
|
||||
|
||||
@@ -306,83 +328,109 @@ check_mem_area (void)
|
||||
msg ("[MEM] ERROR POOL0 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index = MEM_MNGT_MB0_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB1_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool1[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID1)) {
|
||||
msg ("[MEM] ERROR POOL1 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB1_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB2_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool2[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID2)) {
|
||||
msg ("[MEM] ERROR POOL2 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB2_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB3_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool3[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID3)) {
|
||||
msg ("[MEM] ERROR POOL3 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB3_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB4_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool4[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID4)) {
|
||||
msg ("[MEM] ERROR POOL4 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB4_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB5_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool5[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID5)) {
|
||||
msg ("[MEM] ERROR POOL5 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB5_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB6_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool6[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID6)) {
|
||||
msg ("[MEM] ERROR POOL6 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB6_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB7_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool7[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID7)) {
|
||||
msg ("[MEM] ERROR POOL7 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB7_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB8_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool8[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID8)) {
|
||||
msg ("[MEM] ERROR POOL8 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB8_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB9_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool9[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID9)) {
|
||||
msg ("[MEM] ERROR POOL9 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB9_NB_BLOCKS;
|
||||
|
||||
for (index = mb_index; index < MEM_MNGT_MB10_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool10[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID10)) {
|
||||
msg ("[MEM] ERROR POOL10 block index %d\n", index);
|
||||
}
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool10[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID10)) {
|
||||
msg ("[MEM] ERROR POOL10 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB10_NB_BLOCKS;
|
||||
|
||||
for (index = mb_index; index < MEM_MNGT_MB11_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool11[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID11)) {
|
||||
msg ("[MEM] ERROR POOL11 block index %d\n", index);
|
||||
}
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool11[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID11)) {
|
||||
msg ("[MEM] ERROR POOL11 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB11_NB_BLOCKS;
|
||||
|
||||
for (index = mb_index; index < MEM_MNGT_MB12_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool12[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID12)) {
|
||||
msg ("[MEM] ERROR POOL12 block index %d\n", index);
|
||||
}
|
||||
if ((memory->mem_blocks[mb_index + index].data != (unsigned char*)&(memory->mem_pool12[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID12)) {
|
||||
msg ("[MEM] ERROR POOL12 block index %d\n", index);
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB12_NB_BLOCKS;
|
||||
|
||||
for (index = mb_index; index < MEM_MNGT_NB_ELEMENTS; index++) {
|
||||
if ((memory->mem_blocks[index].data != NULL) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID_COPY)) {
|
||||
msg ("[MEM] ERROR POOL COPY block index %d\n", index);
|
||||
}
|
||||
if ((memory->mem_blocks[index].data != NULL) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID_COPY)) {
|
||||
msg ("[MEM] ERROR POOL COPY block index %d\n", index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,8 +438,9 @@ check_mem_area (void)
|
||||
void
|
||||
check_free_mem_block (mem_block_t * leP)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
ptrdiff_t block_index;
|
||||
|
||||
if ((leP >= mem_block_var.mem_blocks) && (leP <= &mem_block_var.mem_blocks[MEM_MNGT_NB_ELEMENTS-1])) {
|
||||
// the pointer is inside the memory region
|
||||
block_index = leP - mem_block_var.mem_blocks;
|
||||
@@ -401,102 +450,127 @@ check_free_mem_block (mem_block_t * leP)
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool0[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID0)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB0_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB1_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool1[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID1)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB1_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB2_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool2[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID2)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB2_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB3_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool3[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID3)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB3_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB4_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool4[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID4)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB4_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB5_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool5[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID5)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB5_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB6_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool6[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID6)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB6_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB7_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool7[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID7)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB7_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB8_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool8[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID8)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB8_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB9_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool9[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID9)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB9_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB10_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool10[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID10)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB10_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB11_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool11[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID11)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block_index -= MEM_MNGT_MB11_NB_BLOCKS;
|
||||
|
||||
if (block_index < MEM_MNGT_MB12_NB_BLOCKS) {
|
||||
if ((leP->data != (unsigned char*)mem_block_var.mem_pool12[block_index]) && (leP->pool_id != MEM_MNGT_POOL_ID12)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -48,12 +48,12 @@
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef struct mem_block_t{
|
||||
typedef struct mem_block_t {
|
||||
struct mem_block_t *next;
|
||||
struct mem_block_t *previous;
|
||||
unsigned char pool_id;
|
||||
unsigned char *data;
|
||||
}mem_block_t;
|
||||
} mem_block_t;
|
||||
#include "UTIL/LISTS/list.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -82,42 +82,42 @@ private_mem_block(void check_free_mem_block (mem_block_t * leP);)
|
||||
#endif
|
||||
// definition of the size of the allocated memory area
|
||||
# define MEM_MNGT_MB0_BLOCK_SIZE 64
|
||||
// 64
|
||||
// 64
|
||||
# define MEM_MNGT_MB0_NB_BLOCKS 4096 * MEM_SCALE
|
||||
# define MEM_MNGT_POOL_ID0 0
|
||||
|
||||
# define MEM_MNGT_MB1_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*2
|
||||
// 128
|
||||
// 128
|
||||
# define MEM_MNGT_MB1_NB_BLOCKS 4096 * MEM_SCALE
|
||||
# define MEM_MNGT_POOL_ID1 1
|
||||
|
||||
# define MEM_MNGT_MB2_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*4
|
||||
// 256
|
||||
// 256
|
||||
# define MEM_MNGT_MB2_NB_BLOCKS 2048 * MEM_SCALE
|
||||
# define MEM_MNGT_POOL_ID2 2
|
||||
|
||||
# define MEM_MNGT_MB3_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*8
|
||||
// 512
|
||||
// 512
|
||||
# define MEM_MNGT_MB3_NB_BLOCKS 2048 * MEM_SCALE
|
||||
# define MEM_MNGT_POOL_ID3 3
|
||||
|
||||
# define MEM_MNGT_MB4_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*16
|
||||
// 1024
|
||||
// 1024
|
||||
# define MEM_MNGT_MB4_NB_BLOCKS 1024 * MEM_SCALE
|
||||
# define MEM_MNGT_POOL_ID4 4
|
||||
|
||||
# define MEM_MNGT_MB5_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*32
|
||||
// 2048
|
||||
// 2048
|
||||
# define MEM_MNGT_MB5_NB_BLOCKS 1024 * MEM_SCALE // LG WAS 1024
|
||||
# define MEM_MNGT_POOL_ID5 5
|
||||
|
||||
# define MEM_MNGT_MB6_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*64
|
||||
// 4096
|
||||
// 4096
|
||||
# define MEM_MNGT_MB6_NB_BLOCKS 1024 * MEM_SCALE // LG WAS 256
|
||||
# define MEM_MNGT_POOL_ID6 6
|
||||
|
||||
# define MEM_MNGT_MB7_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*128
|
||||
// 8192
|
||||
// 8192
|
||||
# define MEM_MNGT_MB7_NB_BLOCKS 64* MEM_SCALE // LG WAS 32
|
||||
# define MEM_MNGT_POOL_ID7 7
|
||||
|
||||
@@ -127,27 +127,27 @@ private_mem_block(void check_free_mem_block (mem_block_t * leP);)
|
||||
# define MEM_MNGT_MB8_NB_BLOCKS 256 * MEM_SCALE
|
||||
#else
|
||||
# define MEM_MNGT_MB8_NB_BLOCKS 16 * MEM_SCALE
|
||||
// 16384
|
||||
// 16384
|
||||
#endif
|
||||
# define MEM_MNGT_POOL_ID8 8
|
||||
|
||||
# define MEM_MNGT_MB9_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*512
|
||||
// 32768
|
||||
// 32768
|
||||
# define MEM_MNGT_MB9_NB_BLOCKS 8 * MEM_SCALE
|
||||
# define MEM_MNGT_POOL_ID9 9
|
||||
|
||||
# define MEM_MNGT_MB10_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*1024
|
||||
// 65536
|
||||
// 65536
|
||||
# define MEM_MNGT_MB10_NB_BLOCKS 0 * MEM_SCALE
|
||||
# define MEM_MNGT_POOL_ID10 10
|
||||
|
||||
# define MEM_MNGT_MB11_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*2048
|
||||
// 131072
|
||||
// 131072
|
||||
# define MEM_MNGT_MB11_NB_BLOCKS 0 * MEM_SCALE
|
||||
# define MEM_MNGT_POOL_ID11 11
|
||||
|
||||
# define MEM_MNGT_MB12_BLOCK_SIZE MEM_MNGT_MB0_BLOCK_SIZE*4096
|
||||
// 262144
|
||||
// 262144
|
||||
# define MEM_MNGT_MB12_NB_BLOCKS 32 * MEM_SCALE
|
||||
# define MEM_MNGT_POOL_ID12 12
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
# define PRINT_MEM_MNGT_ADDR msg
|
||||
#else
|
||||
# define PRINT_MEM_MNGT_ADDR
|
||||
//
|
||||
//
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef USER_MODE
|
||||
@@ -67,66 +67,82 @@ uint32_t counters[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
void *
|
||||
pool_buffer_init (void *arg)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uint32_t index, mb_index, pool_index;
|
||||
mem_pool *memory = (mem_pool *) arg;
|
||||
int pool_sizes[11] = { MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB1_NB_BLOCKS,
|
||||
MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB3_NB_BLOCKS,
|
||||
MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB5_NB_BLOCKS,
|
||||
MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB7_NB_BLOCKS,
|
||||
MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB9_NB_BLOCKS,
|
||||
MEM_MNGT_MBCOPY_NB_BLOCKS
|
||||
};
|
||||
MEM_MNGT_MB2_NB_BLOCKS, MEM_MNGT_MB3_NB_BLOCKS,
|
||||
MEM_MNGT_MB4_NB_BLOCKS, MEM_MNGT_MB5_NB_BLOCKS,
|
||||
MEM_MNGT_MB6_NB_BLOCKS, MEM_MNGT_MB7_NB_BLOCKS,
|
||||
MEM_MNGT_MB8_NB_BLOCKS, MEM_MNGT_MB9_NB_BLOCKS,
|
||||
MEM_MNGT_MBCOPY_NB_BLOCKS
|
||||
};
|
||||
|
||||
memset (memory, 0, sizeof (mem_pool));
|
||||
mb_index = 0;
|
||||
|
||||
// LG_TEST
|
||||
for (pool_index = 0; pool_index <= MEM_MNGT_POOL_ID_COPY; pool_index++) {
|
||||
init_list (&memory->mem_lists[pool_index], "POOL");
|
||||
|
||||
for (index = 0; index < pool_sizes[pool_index]; index++) {
|
||||
//memory->mem_blocks[mb_index + index].previous = NULL; -> done in memset 0
|
||||
//memory->mem_blocks[mb_index + index].next = NULL; -> done in memset 0
|
||||
switch (pool_index) {
|
||||
case 0:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool0[index][0]);
|
||||
break;
|
||||
case 1:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool1[index][0]);
|
||||
break;
|
||||
case 2:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool2[index][0]);
|
||||
break;
|
||||
case 3:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool3[index][0]);
|
||||
break;
|
||||
case 4:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool4[index][0]);
|
||||
break;
|
||||
case 5:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool5[index][0]);
|
||||
break;
|
||||
case 6:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool6[index][0]);
|
||||
break;
|
||||
case 7:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool7[index][0]);
|
||||
break;
|
||||
case 8:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool8[index][0]);
|
||||
break;
|
||||
case 9:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool9[index][0]);
|
||||
break;
|
||||
default:;
|
||||
memory->mem_blocks[mb_index + index].data = NULL; // pool copy
|
||||
case 0:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool0[index][0]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool1[index][0]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool2[index][0]);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool3[index][0]);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool4[index][0]);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool5[index][0]);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool6[index][0]);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool7[index][0]);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool8[index][0]);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
memory->mem_blocks[mb_index + index].data = &(memory->mem_pool9[index][0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
memory->mem_blocks[mb_index + index].data = NULL; // pool copy
|
||||
|
||||
}
|
||||
|
||||
memory->mem_blocks[mb_index + index].pool_id = pool_index;
|
||||
add_tail (&memory->mem_blocks[mb_index + index], &memory->mem_lists[pool_index]);
|
||||
}
|
||||
|
||||
mb_index += pool_sizes[pool_index];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -134,7 +150,7 @@ pool_buffer_init (void *arg)
|
||||
void *
|
||||
pool_buffer_clean (void *arg)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef NO_THREAD_SAFE
|
||||
mem_pool *memory = (mem_pool *) arg;
|
||||
pthread_mutex_destroy (&memory->mem_lists[MEM_MNGT_POOL_ID0].mutex);
|
||||
@@ -155,12 +171,13 @@ pool_buffer_clean (void *arg)
|
||||
void
|
||||
free_mem_block (mem_block_t * leP)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
if (!(leP)) {
|
||||
msg ("[MEM_MNGT][FREE] WARNING FREE NULL MEM_BLOCK\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MEM_MNGT_FREE
|
||||
msg ("[MEM_MNGT][FREE] free_mem_block() %p pool: %d\n", leP, leP->pool_id);
|
||||
#endif
|
||||
@@ -184,7 +201,7 @@ free_mem_block (mem_block_t * leP)
|
||||
mem_block_t *
|
||||
get_free_mem_block (uint16_t sizeP)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
mem_block_t *le = NULL;
|
||||
int pool_selected;
|
||||
int size;
|
||||
@@ -194,6 +211,7 @@ get_free_mem_block (uint16_t sizeP)
|
||||
wcdma_handle_error (WCDMA_ERROR_OUT_OF_MEM_BLOCK);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size = sizeP >> 6;
|
||||
pool_selected = 0;
|
||||
|
||||
@@ -214,6 +232,7 @@ get_free_mem_block (uint16_t sizeP)
|
||||
#endif
|
||||
return le;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MEM_MNGT_ALLOC
|
||||
msg ("[MEM_MNGT][ERROR][MINOR] memory pool %d is empty trying next pool alloc count = %d\n", pool_selected, counters[pool_selected]);
|
||||
# ifdef USER_MODE
|
||||
@@ -222,6 +241,7 @@ get_free_mem_block (uint16_t sizeP)
|
||||
# endif
|
||||
#endif
|
||||
} while (pool_selected++ < 9);
|
||||
|
||||
msg ("[MEM_MNGT][ERROR][FATAL] size %d requested out of bounds or memory pools empty\n", sizeP);
|
||||
wcdma_handle_error (WCDMA_ERROR_OUT_OF_MEM_BLOCK);
|
||||
return NULL;
|
||||
@@ -231,7 +251,7 @@ get_free_mem_block (uint16_t sizeP)
|
||||
mem_block_t *
|
||||
get_free_copy_mem_block (void)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
mem_block_t *le;
|
||||
|
||||
if ((le = remove_head (&mem->mem_lists[MEM_MNGT_POOL_ID_COPY]))) {
|
||||
@@ -253,13 +273,14 @@ get_free_copy_mem_block (void)
|
||||
mem_block_t *
|
||||
copy_mem_block (mem_block_t * leP, mem_block_t * destP)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
if ((destP != NULL) && (leP != NULL) && (destP->pool_id == MEM_MNGT_POOL_ID_COPY)) {
|
||||
destP->data = leP->data;
|
||||
} else {
|
||||
msg ("[MEM_MNGT][COPY] copy_mem_block() pool dest src or dest is NULL\n");
|
||||
}
|
||||
|
||||
return destP;
|
||||
}
|
||||
|
||||
@@ -267,7 +288,7 @@ copy_mem_block (mem_block_t * leP, mem_block_t * destP)
|
||||
void
|
||||
display_mem_load (void)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
msg ("POOL 0 (%d elements of %d Bytes): \n", MEM_MNGT_MB0_NB_BLOCKS, MEM_MNGT_MB0_BLOCK_SIZE);
|
||||
display_list (&mem->mem_lists[MEM_MNGT_POOL_ID0]);
|
||||
@@ -297,7 +318,7 @@ display_mem_load (void)
|
||||
void
|
||||
check_mem_area (void *arg)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
int index, mb_index;
|
||||
mem_pool *memory = (mem_pool *) arg;
|
||||
|
||||
@@ -307,70 +328,90 @@ check_mem_area (void *arg)
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index = MEM_MNGT_MB0_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB1_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool1[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID1)) {
|
||||
msg ("[MEM] ERROR POOL1 block index %d\n", index);
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB1_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB2_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool2[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID2)) {
|
||||
msg ("[MEM] ERROR POOL2 block index %d\n", index);
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB2_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB3_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool3[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID3)) {
|
||||
msg ("[MEM] ERROR POOL3 block index %d\n", index);
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB3_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB4_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool4[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID4)) {
|
||||
msg ("[MEM] ERROR POOL4 block index %d\n", index);
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB4_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB5_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool5[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID5)) {
|
||||
msg ("[MEM] ERROR POOL5 block index %d\n", index);
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB5_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB6_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool6[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID6)) {
|
||||
msg ("[MEM] ERROR POOL6 block index %d\n", index);
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB6_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB7_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool7[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID7)) {
|
||||
msg ("[MEM] ERROR POOL7 block index %d\n", index);
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB7_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB8_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool8[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID8)) {
|
||||
msg ("[MEM] ERROR POOL8 block index %d\n", index);
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB8_NB_BLOCKS;
|
||||
|
||||
for (index = 0; index < MEM_MNGT_MB9_NB_BLOCKS; index++) {
|
||||
if ((memory->mem_blocks[mb_index + index].data != &(memory->mem_pool9[index][0])) && (memory->mem_blocks[mb_index + index].pool_id != MEM_MNGT_POOL_ID9)) {
|
||||
msg ("[MEM] ERROR POOL9 block index %d\n", index);
|
||||
break_point ();
|
||||
}
|
||||
}
|
||||
|
||||
mb_index += MEM_MNGT_MB9_NB_BLOCKS;
|
||||
|
||||
for (index = mb_index; index < MEM_MNGT_NB_ELEMENTS; index++) {
|
||||
if ((memory->mem_blocks[index].data != NULL) && (memory->mem_blocks[index].pool_id != MEM_MNGT_POOL_ID_COPY)) {
|
||||
msg ("[MEM] ERROR POOL COPY block index %d\n", index);
|
||||
@@ -383,10 +424,12 @@ check_mem_area (void *arg)
|
||||
void
|
||||
check_free_mem_block (mem_block_t * leP)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
int block_index;
|
||||
|
||||
if ((leP >= &mem->mem_blocks[0]) && (leP <= &mem->mem_blocks[MEM_MNGT_NB_ELEMENTS])) {
|
||||
block_index = ((uint32_t) leP - (uint32_t) (&mem->mem_blocks[0])) / sizeof (mem_block_t);
|
||||
|
||||
if (block_index < MEM_MNGT_MB0_NB_BLOCKS) {
|
||||
if (((uint32_t) (leP->data) != (uint32_t) (&(mem->mem_pool0[block_index][0]))) && (leP->pool_id != MEM_MNGT_POOL_ID0)) {
|
||||
msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
|
||||
@@ -445,7 +488,7 @@ check_free_mem_block (mem_block_t * leP)
|
||||
void
|
||||
break_point (void)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
int break_var;
|
||||
|
||||
msg ("[BREAK_POINT]\n");
|
||||
|
||||
Reference in New Issue
Block a user