mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-29 12:14:28 +00:00
patch #6822 (Add option to place memory pools in separate arrays) - new config option MEMP_SEPARATE_POOLS
This commit is contained in:
parent
13c9d2dade
commit
763760503b
@ -19,6 +19,10 @@ HISTORY
|
||||
|
||||
++ 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
|
||||
* init.c, igmp.c: patch #6463 (IGMP - Adding Random Delay): added define
|
||||
LWIP_RAND() for lwip-wide randomization (to be defined in cc.h)
|
||||
|
@ -143,12 +143,33 @@ static const char *memp_desc[MEMP_MAX] = {
|
||||
};
|
||||
#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
|
||||
#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )
|
||||
#include "lwip/memp_std.h"
|
||||
];
|
||||
|
||||
#endif /* MEMP_SEPARATE_POOLS */
|
||||
|
||||
#if MEMP_SANITY_CHECK
|
||||
/**
|
||||
* Check that memp-lists don't form a circle
|
||||
@ -270,10 +291,15 @@ memp_init(void)
|
||||
MEMP_STATS_AVAIL(avail, i, memp_num[i]);
|
||||
}
|
||||
|
||||
#if !MEMP_SEPARATE_POOLS
|
||||
memp = LWIP_MEM_ALIGN(memp_memory);
|
||||
#endif /* !MEMP_SEPARATE_POOLS */
|
||||
/* for every pool: */
|
||||
for (i = 0; i < MEMP_MAX; ++i) {
|
||||
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 */
|
||||
for (j = 0; j < memp_num[i]; ++j) {
|
||||
memp->next = memp_tab[i];
|
||||
|
@ -124,6 +124,15 @@
|
||||
#define MEM_SIZE 1600
|
||||
#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
|
||||
* amount of bytes before and after each memp element in every pool and fills
|
||||
|
Loading…
Reference in New Issue
Block a user