The Pedigree Project 0.1
memp_std.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
28/*
29 * SETUP: Make sure we define everything we will need.
30 *
31 * We have create three types of pools:
32 * 1) MEMPOOL - standard pools
33 * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c
34 * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct
35 *
36 * If the include'r doesn't require any special treatment of each of the types
37 * above, then will declare #2 & #3 to be just standard mempools.
38 */
39#ifndef LWIP_MALLOC_MEMPOOL
40/* This treats "malloc pools" just like any other pool.
41 The pools are a little bigger to provide 'size' as the amount of user data. */
42#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))), "MALLOC_"#size)
43#define LWIP_MALLOC_MEMPOOL_START
44#define LWIP_MALLOC_MEMPOOL_END
45#endif /* LWIP_MALLOC_MEMPOOL */
46
47#ifndef LWIP_PBUF_MEMPOOL
48/* This treats "pbuf pools" just like any other pool.
49 * Allocates buffers for a pbuf struct AND a payload size */
50#define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc)
51#endif /* LWIP_PBUF_MEMPOOL */
52
53
54/*
55 * A list of internal pools used by LWIP.
56 *
57 * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
58 * creates a pool name MEMP_pool_name. description is used in stats.c
59 */
60#if LWIP_RAW
61LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB")
62#endif /* LWIP_RAW */
63
64#if LWIP_UDP
65LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB")
66#endif /* LWIP_UDP */
67
68#if LWIP_TCP
69LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB")
70LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN")
71LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG")
72#endif /* LWIP_TCP */
73
74#if LWIP_IPV4 && IP_REASSEMBLY
75LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA")
76#endif /* LWIP_IPV4 && IP_REASSEMBLY */
77#if (IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG)
78LWIP_MEMPOOL(FRAG_PBUF, MEMP_NUM_FRAG_PBUF, sizeof(struct pbuf_custom_ref),"FRAG_PBUF")
79#endif /* IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF || (LWIP_IPV6 && LWIP_IPV6_FRAG) */
80
81#if LWIP_NETCONN || LWIP_SOCKET
82LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF")
83LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN")
84#endif /* LWIP_NETCONN || LWIP_SOCKET */
85
86#if NO_SYS==0
87LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API")
88#if LWIP_MPU_COMPATIBLE
89LWIP_MEMPOOL(API_MSG, MEMP_NUM_API_MSG, sizeof(struct api_msg), "API_MSG")
90#if LWIP_DNS
91LWIP_MEMPOOL(DNS_API_MSG, MEMP_NUM_DNS_API_MSG, sizeof(struct dns_api_msg), "DNS_API_MSG")
92#endif
93#if LWIP_SOCKET && !LWIP_TCPIP_CORE_LOCKING
94LWIP_MEMPOOL(SOCKET_SETGETSOCKOPT_DATA, MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA, sizeof(struct lwip_setgetsockopt_data), "SOCKET_SETGETSOCKOPT_DATA")
95#endif
96#if LWIP_NETIF_API
97LWIP_MEMPOOL(NETIFAPI_MSG, MEMP_NUM_NETIFAPI_MSG, sizeof(struct netifapi_msg), "NETIFAPI_MSG")
98#endif
99#endif /* LWIP_MPU_COMPATIBLE */
100#if !LWIP_TCPIP_CORE_LOCKING_INPUT
101LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT")
102#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */
103#endif /* NO_SYS==0 */
104
105#if LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING
106LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE")
107#endif /* LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING */
108
109#if LWIP_IGMP
110LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP")
111#endif /* LWIP_IGMP */
112
113#if LWIP_TIMERS && !LWIP_TIMERS_CUSTOM
114LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT")
115#endif /* LWIP_TIMERS && !LWIP_TIMERS_CUSTOM */
116
117#if LWIP_DNS && LWIP_SOCKET
118LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB")
119#endif /* LWIP_DNS && LWIP_SOCKET */
120#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
121LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST")
122#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
123
124#if LWIP_IPV6 && LWIP_ND6_QUEUEING
125LWIP_MEMPOOL(ND6_QUEUE, MEMP_NUM_ND6_QUEUE, sizeof(struct nd6_q_entry), "ND6_QUEUE")
126#endif /* LWIP_IPV6 && LWIP_ND6_QUEUEING */
127
128#if LWIP_IPV6 && LWIP_IPV6_REASS
129LWIP_MEMPOOL(IP6_REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip6_reassdata), "IP6_REASSDATA")
130#endif /* LWIP_IPV6 && LWIP_IPV6_REASS */
131
132#if LWIP_IPV6 && LWIP_IPV6_MLD
133LWIP_MEMPOOL(MLD6_GROUP, MEMP_NUM_MLD6_GROUP, sizeof(struct mld_group), "MLD6_GROUP")
134#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
135
136
137/*
138 * A list of pools of pbuf's used by LWIP.
139 *
140 * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description)
141 * creates a pool name MEMP_pool_name. description is used in stats.c
142 * This allocates enough space for the pbuf struct and a payload.
143 * (Example: pbuf_payload_size=0 allocates only size for the struct)
144 */
145LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM")
147
148
149/*
150 * Allow for user-defined pools; this must be explicitly set in lwipopts.h
151 * since the default is to NOT look for lwippools.h
152 */
153#if MEMP_USE_CUSTOM_POOLS
154#include "lwippools.h"
155#endif /* MEMP_USE_CUSTOM_POOLS */
156
157/*
158 * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
159 * (#undef is ignored for something that is not defined)
160 */
161#undef LWIP_MEMPOOL
162#undef LWIP_MALLOC_MEMPOOL
163#undef LWIP_MALLOC_MEMPOOL_START
164#undef LWIP_MALLOC_MEMPOOL_END
165#undef LWIP_PBUF_MEMPOOL
#define MEMP_NUM_TCP_PCB_LISTEN
Definition opt.h:401
#define MEMP_NUM_ARP_QUEUE
Definition opt.h:438
#define MEMP_NUM_REASSDATA
Definition opt.h:417
#define MEMP_NUM_FRAG_PBUF
Definition opt.h:428
#define MEMP_NUM_NETDB
Definition opt.h:499
#define MEMP_NUM_UDP_PCB
Definition opt.h:385
#define MEMP_NUM_RAW_PCB
Definition opt.h:376
#define MEMP_NUM_DNS_API_MSG
Definition opt.h:527
#define MEMP_NUM_SYS_TIMEOUT
Definition opt.h:457
#define PBUF_POOL_SIZE
Definition opt.h:514
#define MEMP_NUM_API_MSG
Definition opt.h:521
#define MEMP_NUM_NETBUF
Definition opt.h:465
#define MEMP_NUM_TCP_PCB
Definition opt.h:393
#define MEMP_NUM_PBUF
Definition opt.h:368
#define MEMP_NUM_TCP_SEG
Definition opt.h:409
#define MEMP_NUM_LOCALHOSTLIST
Definition opt.h:507
#define MEMP_NUM_TCPIP_MSG_INPKT
Definition opt.h:491
#define MEMP_NUM_IGMP_GROUP
Definition opt.h:448
#define MEMP_NUM_NETCONN
Definition opt.h:473
#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA
Definition opt.h:534
#define MEMP_NUM_NETIFAPI_MSG
Definition opt.h:541
#define MEMP_NUM_TCPIP_MSG_API
Definition opt.h:482
#define MEMP_NUM_MLD6_GROUP
Definition opt.h:2279
#define MEMP_NUM_ND6_QUEUE
Definition opt.h:2302
#define PBUF_POOL_BUFSIZE
Definition opt.h:1392
@ PBUF_POOL
Definition pbuf.h:142