patch #6822 (Add option to place memory pools in separate arrays) - new config option MEMP_SEPARATE_POOLS

This commit is contained in:
goldsimon 2010-01-10 12:44:09 +00:00
parent 13c9d2dade
commit 763760503b
3 changed files with 40 additions and 1 deletions

View File

@ -19,6 +19,10 @@ HISTORY
++ New features: ++ New features:
2010-01-10: Simon Goldschmidt (Bill Auerbach)
* opt.h, memp.c: patch #6822 (Add option to place memory pools in
separate arrays)
2010-01-10: Simon Goldschmidt 2010-01-10: Simon Goldschmidt
* init.c, igmp.c: patch #6463 (IGMP - Adding Random Delay): added define * init.c, igmp.c: patch #6463 (IGMP - Adding Random Delay): added define
LWIP_RAND() for lwip-wide randomization (to be defined in cc.h) LWIP_RAND() for lwip-wide randomization (to be defined in cc.h)

View File

@ -143,12 +143,33 @@ static const char *memp_desc[MEMP_MAX] = {
}; };
#endif /* LWIP_DEBUG */ #endif /* LWIP_DEBUG */
/** This is the actual memory used by the pools. */ #if MEMP_SEPARATE_POOLS
/** This creates each memory pool. These are named memp_memory_XXX (where XXX
* is the name of the pool defined in memp_std.h).
* To relocate a pool, declare it as extern in cc.h. Example for GCC:
* extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB[];
*/
#define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name \
## [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))];
#include "lwip/memp_std.h"
/** This array holds the base of each memory pool. */
static u8_t *const memp_bases[] = {
#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name,
#include "lwip/memp_std.h"
};
#else /* MEMP_SEPARATE_POOLS */
/** This is the actual memory used by the pools (all pools in one big block). */
static u8_t memp_memory[MEM_ALIGNMENT - 1 static u8_t memp_memory[MEM_ALIGNMENT - 1
#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) #define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )
#include "lwip/memp_std.h" #include "lwip/memp_std.h"
]; ];
#endif /* MEMP_SEPARATE_POOLS */
#if MEMP_SANITY_CHECK #if MEMP_SANITY_CHECK
/** /**
* Check that memp-lists don't form a circle * Check that memp-lists don't form a circle
@ -270,10 +291,15 @@ memp_init(void)
MEMP_STATS_AVAIL(avail, i, memp_num[i]); MEMP_STATS_AVAIL(avail, i, memp_num[i]);
} }
#if !MEMP_SEPARATE_POOLS
memp = LWIP_MEM_ALIGN(memp_memory); memp = LWIP_MEM_ALIGN(memp_memory);
#endif /* !MEMP_SEPARATE_POOLS */
/* for every pool: */ /* for every pool: */
for (i = 0; i < MEMP_MAX; ++i) { for (i = 0; i < MEMP_MAX; ++i) {
memp_tab[i] = NULL; memp_tab[i] = NULL;
#if MEMP_SEPARATE_POOLS
memp = (struct memp*)memp_bases[i];
#endif /* MEMP_SEPARATE_POOLS */
/* create a linked list of memp elements */ /* create a linked list of memp elements */
for (j = 0; j < memp_num[i]; ++j) { for (j = 0; j < memp_num[i]; ++j) {
memp->next = memp_tab[i]; memp->next = memp_tab[i];

View File

@ -124,6 +124,15 @@
#define MEM_SIZE 1600 #define MEM_SIZE 1600
#endif #endif
/**
* MEMP_SEPARATE_POOLS: if defined to 1, each pool is placed in its own array.
* This can be used to individually change the location of each pool.
* Default is one big array for all pools
*/
#ifndef MEMP_SEPARATE_POOLS
#define MEMP_SEPARATE_POOLS 0
#endif
/** /**
* MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable
* amount of bytes before and after each memp element in every pool and fills * amount of bytes before and after each memp element in every pool and fills