Prusa MINI Firmware overview
memp_priv.h File Reference
#include "lwip/opt.h"
#include "lwip/mem.h"

Go to the source code of this file.

Classes

struct  memp
 
struct  memp_desc
 

Macros

#define MEMP_SIZE   0
 
#define MEMP_ALIGN_SIZE(x)   (LWIP_MEM_ALIGN_SIZE(x))
 
#define DECLARE_LWIP_MEMPOOL_DESC(desc)
 
#define LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(name)
 
#define LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(name)
 

Functions

void memp_init_pool (const struct memp_desc *desc)
 
voidmemp_malloc_pool (const struct memp_desc *desc)
 
void memp_free_pool (const struct memp_desc *desc, void *mem)
 

Detailed Description

memory pools lwIP internal implementations (do not use in application code)

Macro Definition Documentation

◆ MEMP_SIZE

#define MEMP_SIZE   0

◆ MEMP_ALIGN_SIZE

#define MEMP_ALIGN_SIZE (   x)    (LWIP_MEM_ALIGN_SIZE(x))

◆ DECLARE_LWIP_MEMPOOL_DESC

#define DECLARE_LWIP_MEMPOOL_DESC (   desc)

◆ LWIP_MEMPOOL_DECLARE_STATS_INSTANCE

#define LWIP_MEMPOOL_DECLARE_STATS_INSTANCE (   name)

◆ LWIP_MEMPOOL_DECLARE_STATS_REFERENCE

#define LWIP_MEMPOOL_DECLARE_STATS_REFERENCE (   name)

Function Documentation

◆ memp_init_pool()

void memp_init_pool ( const struct memp_desc desc)

Initialize custom memory pool. Related functions: memp_malloc_pool, memp_free_pool

Parameters
descpool to initialize
231 {
232 #if MEMP_MEM_MALLOC
233  LWIP_UNUSED_ARG(desc);
234 #else
235  int i;
236  struct memp *memp;
237 
238  *desc->tab = NULL;
239  memp = (struct memp*)LWIP_MEM_ALIGN(desc->base);
240  /* create a linked list of memp elements */
241  for (i = 0; i < desc->num; ++i) {
242  memp->next = *desc->tab;
243  *desc->tab = memp;
244 #if MEMP_OVERFLOW_CHECK
245  memp_overflow_init_element(memp, desc);
246 #endif /* MEMP_OVERFLOW_CHECK */
247  /* cast through void* to get rid of alignment warnings */
248  memp = (struct memp *)(void *)((u8_t *)memp + MEMP_SIZE + desc->size
250  + MEMP_SANITY_REGION_AFTER_ALIGNED
251 #endif
252  );
253  }
254 #if MEMP_STATS
255  desc->stats->avail = desc->num;
256 #endif /* MEMP_STATS */
257 #endif /* !MEMP_MEM_MALLOC */
258 
259 #if MEMP_STATS && (defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY)
260  desc->stats->name = desc->desc;
261 #endif /* MEMP_STATS && (defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY) */
262 }
Here is the caller graph for this function:

◆ memp_malloc_pool()

void* memp_malloc_pool ( const struct memp_desc desc)

Get an element from a custom pool.

Parameters
descthe pool to get an element from
Returns
a pointer to the allocated memory or a NULL pointer on error
363 {
364  LWIP_ASSERT("invalid pool desc", desc != NULL);
365  if (desc == NULL) {
366  return NULL;
367  }
368 
369 #if !MEMP_OVERFLOW_CHECK
370  return do_memp_malloc_pool(desc);
371 #else
372  return do_memp_malloc_pool_fn(desc, file, line);
373 #endif
374 }
Here is the call graph for this function:

◆ memp_free_pool()

void memp_free_pool ( const struct memp_desc desc,
void mem 
)

Put a custom pool element back into its pool.

Parameters
descthe pool where to put mem
memthe memp element to free
453 {
454  LWIP_ASSERT("invalid pool desc", desc != NULL);
455  if ((desc == NULL) || (mem == NULL)) {
456  return;
457  }
458 
459  do_memp_free_pool(desc, mem);
460 }
Here is the call graph for this function:
do_memp_malloc_pool
static void * do_memp_malloc_pool(const struct memp_desc *desc)
Definition: memp.c:292
LWIP_ASSERT
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
mem
Definition: mem.c:264
memp_desc::base
u8_t * base
Definition: memp_priv.h:148
i
uint8_t i
Definition: screen_test_graph.c:72
MEMP_SIZE
#define MEMP_SIZE
Definition: memp_priv.h:85
NULL
#define NULL
Definition: usbd_def.h:53
memp::next
struct memp * next
Definition: memp_priv.h:92
u8_t
uint8_t u8_t
Definition: arch.h:119
memp_desc::num
u16_t num
Definition: memp_priv.h:145
MEMP_OVERFLOW_CHECK
#define MEMP_OVERFLOW_CHECK
Definition: opt.h:269
memp_desc::size
u16_t size
Definition: memp_priv.h:141
LWIP_UNUSED_ARG
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:308
do_memp_free_pool
static void do_memp_free_pool(const struct memp_desc *desc, void *mem)
Definition: memp.c:407
LWIP_MEM_ALIGN
#define LWIP_MEM_ALIGN(addr)
Definition: arch.h:229
memp_desc::tab
struct memp ** tab
Definition: memp_priv.h:151
memp
Definition: memp_priv.h:91