/** * Initialize this module. * * Carves out memp_memory into linked lists for each pool-type. */ void memp_init(void) { struct memp *memp; u16_t i, j; for (i = 0; i < MEMP_MAX; ++i) { MEMP_STATS_AVAIL(used, i, 0); MEMP_STATS_AVAIL(max, i, 0); MEMP_STATS_AVAIL(err, i, 0); MEMP_STATS_AVAIL(avail, i, memp_num[i]); } memp = LWIP_MEM_ALIGN(memp_memory); /* for every pool: */ for (i = 0; i < MEMP_MAX; ++i) { memp_tab[i] = NULL; /* create a linked list of memp elements */ for (j = 0; j < memp_num[i]; ++j) { memp->next = memp_tab[i]; memp_tab[i] = memp; memp = (struct memp *)((u8_t *)memp + MEMP_SIZE + memp_sizes[i] #if MEMP_OVERFLOW_CHECK + MEMP_SANITY_REGION_AFTER_ALIGNED #endif ); } } #if MEMP_OVERFLOW_CHECK memp_overflow_init(); /* check everything a first time to see if it worked */ memp_overflow_check_all(); #endif /* MEMP_OVERFLOW_CHECK */ }
/** * Initialize this module. * * Carves out memp_memory into linked lists for each pool-type. */ void memp_init(void) { struct memp *memp; u16_t i, j; #if MEMP_STATS for (i = 0; i < MEMP_MAX; ++i) { lwip_stats.memp[i].used = lwip_stats.memp[i].max = lwip_stats.memp[i].err = 0; lwip_stats.memp[i].avail = memp_num[i]; } #endif /* MEMP_STATS */ memp = LWIP_MEM_ALIGN(memp_memory); /* for every pool: */ for (i = 0; i < MEMP_MAX; ++i) { memp_tab[i] = NULL; /* create a linked list of memp elements */ for (j = 0; j < memp_num[i]; ++j) { memp->next = memp_tab[i]; memp_tab[i] = memp; memp = (struct memp *)((u8_t *)memp + MEMP_SIZE + memp_sizes[i]); } } #if MEMP_OVERFLOW_CHECK memp_overflow_init(); /* check everything a first time to see if it worked */ memp_overflow_check_all(); #endif /* MEMP_OVERFLOW_CHECK */ }
void memp_initialize_pbuf_list(void) { assert(memp_memory != NULL); struct memp *memp; uintptr_t uimemp; u16_t k, i, j; for (i = 0; i < MEMP_MAX; ++i) { MEMP_STATS_AVAIL(used, i, 0); MEMP_STATS_AVAIL(max, i, 0); MEMP_STATS_AVAIL(err, i, 0); MEMP_STATS_AVAIL(avail, i, memp_num[i]); } memp = LWIP_MEM_ALIGN(memp_memory); /* printf("memp_init: total types of pools %d\n", MEMP_MAX ); printf("memp_init: total types of pools %d, memp_mem %p\n", MEMP_MAX, memp_memory); printf("memp_init: total types of pools %d, memp %p\n", MEMP_MAX, memp); */ memp->next = NULL; /* for every pool: */ for (k = 0; k < MEMP_MAX; ++k) { i = memp_sorted[k]; memp_tab[i] = NULL; // Align memp to element size uimemp = (uintptr_t) memp; if (uimemp % memp_sizes[i] > 0) { uimemp += memp_sizes[i] - (uimemp % memp_sizes[i]); } memp = (struct memp *) uimemp; /* create a linked list of memp elements */ for (j = 0; j < memp_num[i]; ++j) { memp->next = NULL; memp->next = memp_tab[i]; memp_tab[i] = memp; memp = (struct memp *) ((u8_t *) memp + memp_sizes[i]); } } // Set how many free pbuf_pools are there // printf("memp_num[PBUF_POOL] %" PRIu16 "\n", memp_num[MEMP_MAX - 1]); pbuf_pool_counter = 0; #if MEMP_OVERFLOW_CHECK memp_overflow_init(); /* check everything a first time to see if it worked */ memp_overflow_check_all(); #endif /* MEMP_OVERFLOW_CHECK */ // mem_barrelfish_register_buf(RX_BUFFER_ID, memp_memory_size); }
void memp_initialize_pbuf_list(void) { assert(memp_memory != NULL); struct memp *memp; u16_t i, j; for (i = 0; i < MEMP_MAX; ++i) { MEMP_STATS_AVAIL(used, i, 0); MEMP_STATS_AVAIL(max, i, 0); MEMP_STATS_AVAIL(err, i, 0); MEMP_STATS_AVAIL(avail, i, memp_num[i]); } memp = LWIP_MEM_ALIGN(memp_memory); /* printf("memp_init: total types of pools %d\n", MEMP_MAX ); printf("memp_init: total types of pools %d, memp_mem %p\n", MEMP_MAX, memp_memory); printf("memp_init: total types of pools %d, memp %p\n", MEMP_MAX, memp); */ memp->next = NULL; /* for every pool: */ for (i = 0; i < MEMP_MAX; ++i) { memp_tab[i] = NULL; /* printf("memp_init: %" PRIu16 "(%s) size %" PRIu16 " num %" PRIu16 "\n", i, memp_desc[i], memp_sizes[i], memp_num[i]); */ /* create a linked list of memp elements */ for (j = 0; j < memp_num[i]; ++j) { memp->next = NULL; memp->next = memp_tab[i]; memp_tab[i] = memp; memp = (struct memp *) ((u8_t *) memp + MEMP_SIZE + memp_sizes[i] #if MEMP_OVERFLOW_CHECK + MEMP_SANITY_REGION_AFTER_ALIGNED #endif ); } } // Set how many free pbuf_pools are there // printf("memp_num[PBUF_POOL] %" PRIu16 "\n", memp_num[MEMP_MAX - 1]); pbuf_pool_counter = 0; #if MEMP_OVERFLOW_CHECK memp_overflow_init(); /* check everything a first time to see if it worked */ memp_overflow_check_all(); #endif /* MEMP_OVERFLOW_CHECK */ // mem_barrelfish_register_buf(RX_BUFFER_ID, memp_memory_size); }
void memp_init_pool(const struct memp_desc *desc) { int i; struct memp *memp; *desc->tab = NULL; memp = (struct memp*)LWIP_MEM_ALIGN(desc->base); /* create a linked list of memp elements */ for (i = 0; i < desc->num; ++i) { memp->next = *desc->tab; *desc->tab = memp; memp = (struct memp *)(void *)((u8_t *)memp + MEMP_SIZE + desc->size #if MEMP_OVERFLOW_CHECK + MEMP_SANITY_REGION_AFTER_ALIGNED #endif ); } #if MEMP_OVERFLOW_CHECK memp_overflow_init(desc); #endif /* MEMP_OVERFLOW_CHECK */ }