NetBurner 3.4.0f
PDF Version


 
Loading...
Searching...
No Matches
constants.h
Go to the documentation of this file.
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
10#include <predef.h>
11
12#ifndef _CONSTANTS_H
13#define _CONSTANTS_H
14
15#define TICK_IRQ_LEVEL (5) /* System clock IRQ level */
16#define SERIAL_IRQ_LEVEL (3)
17#define SERIAL_VECTOR_BASE (64)
18
19/*
20
21PLEASE READ THIS BEFORE MODIFYING TICKS_PER_SECOND
22
23Before you change this value understand what changing it does.
24Making it faster only slows things down. It does not speed up task switches,
25If only changes the granularity of time delays and timeouts.
26Task switches happen much much faster than the tick interval. They happen as
27soon as one task blocks or an interrupt /or task causes a higher priority task
28to be unblocked. The Time tick has NOTHING to do with task switches.
29
30If you change it to the maximum 200 you have increased the RTOS overhead by a factor
31of 10 and have actually slowed your system.
32*/
33
34#define TICKS_PER_SECOND (20) /* System clock tick */
35
36/*
37 *****************************************************************************
38 * OS Maximum Interrupt Level
39 *
40 * OS_MAX_IRQ_MASK - Optional, Maximum IRQ level that the RTOS is
41 * allowed to mask. RTOS objects may not be used
42 * in ISRs above this level.
43 *****************************************************************************
44 */
45/* #define OS_MAX_IRQ (3) */
46
47/* Ethernet buffer defines */
48#define ETHER_BUFFER_SIZE 1548
49#define ETH_MAX_PAYLOAD (1500)
50#define ETH_MAX_SIZE (1522)
51#define ETH_MIN_SIZE (46)
52#define IP_HEADER_SIZE (20)
53#define UDP_HEADER_SIZE (8)
54#define MAX_UDPDATA (ETH_MAX_PAYLOAD - (IP_HEADER_SIZE + UDP_HEADER_SIZE))
55
56#define SERIAL_TX_BUFFERS (2) /* ETHERN_BUFFER_SIZE = bytes of serial TX fifo */
57#define SERIAL_RX_BUFFERS (2) /* ETHERN_BUFFER_SIZE = bytes of serial RX fifo */
58#define stdin_buffer_size (200)
59
60#define OS_MAX_TASKS 32 /* Max number of system tasks */
61
62#define OS_MAX_PRIOS 64 /* Maximum number of system priorities */
63
64/*
65 ******************************************************************************
66 *
67 * System task priorities
68 *
69 * Restating the NBRTOS RTOS Library document (NBRtosLibrary.pdf)
70 * Lowest priority is OS_MAX_PRIOS-1, 1 is the highest.
71 * There can only be one task at each priority level.
72 * Idle task is created at priority 63.
73 *
74 * UserMain is created at priority 10. It is recommended and is supported by
75 * examples and default projects that a call to
76 * OSChangePrio( MAIN_PRIO );
77 * be made to lower the priority to the range recommended for the main
78 * application.
79 *
80 * Factory applications use priorities 46 through 56.
81 *
82 * Netburner Runtime library support and driver tasks use 36 through 45.
83 *
84 * Care should be taken in use of priorities it can affect reliability and
85 * performance.
86 *
87 ******************************************************************************
88 */
89
90/* Recommend UserMain priority */
91#define MAIN_PRIO (50)
92
93/* Runtime library driver and support task priorities */
94#define USB_HW_PRIO (45)
95#define PPP_PRIO (44)
96#define SECURITY_TASK_PRIO (43)
97#define WIFI_STATION_TASK_PRIO (42)
98#define WIFI_TASK_PRIO (41)
99#define CONFIG_SERVER_PRIO (40)
100#define HTTP_PRIO (39)
101#define ETHER_SEND_PRIO (38)
102
103/* Features */
104/* SSH server must be lower than main for progress displays */
105#define SSH_TASK_PRIORITY (56)
106
107/*
108 ******************************************************************************
109 *
110 * Stack size definitions
111 *
112 * SSH requires larger stacks for session key generation see predef.h
113 *
114 ******************************************************************************
115 */
116#if defined NB_SSH_SUPPORTED || defined NB_SSL_SUPPORTED
117#define MAIN_TASK_STK_SIZE (3072)
118#define IP_STK_SIZE (2048)
119#define TCP_STK_SIZE (3072)
120#define HTTP_STK_SIZE (3072)
121#define IDLE_STK_SIZE (2048)
122#define ETHER_SEND_STK_SIZE (2048)
123#define PPP_STK_SIZE (2048)
124#define USB_HW_STK_SIZE (2048)
125#define USER_TASK_STK_SIZE (3072)
126#else /* #ifdef NB_SSH_SUPPORTED */
127#define MAIN_TASK_STK_SIZE (2048)
128#define IP_STK_SIZE (2048)
129#define TCP_STK_SIZE (2048)
130#define HTTP_STK_SIZE (2048)
131#define IDLE_STK_SIZE (2048)
132#define ETHER_SEND_STK_SIZE (2048)
133#define PPP_STK_SIZE (2048)
134#define USB_HW_STK_SIZE (2048)
135#define USER_TASK_STK_SIZE (2048)
136#endif /* #ifdef NB_SSH_SUPPORTED */
137
138/* TCP definitions */
139#define DEFAULT_TCP4_MSS (512)
140#define DEFAULT_TCP6_MSS (1200)
141#define DEFAULT_TCP_RTTVAR \
142 ((TICKS_PER_SECOND * 3) / 4) /*See RFC 1122 for a 50msec tick 60 ticks=3 sec 4*15=60 (The 4 comes from stevens Vol1-300) */
143#define TCP_CONN_TO (75 * TICKS_PER_SECOND) /* 75 seconds Min */
144#define TCP_ACK_TICK_DLY (TICKS_PER_SECOND / 5) /* 200 msec delayed ACK timer */
145#define DEFAULT_INITAL_RTO (TICKS_PER_SECOND * 3)
146#define TCP_MAX_RTO (64 * TICKS_PER_SECOND)
147#define TCP_MIN_RTO (TICKS_PER_SECOND / 2)
148#define TCP_2MSL_WAIT (60 * TICKS_PER_SECOND)
149#define MAX_TCP_RETRY (12)
150#define TCP_WRITE_TIMEOUT (TICKS_PER_SECOND * 10)
151#define TCP_BUFFER_SEGMENTS (5) /* Store 4 segments max in tx and rx buffers allows fast retransmit when packets lost*/
152
153#define MAX_MULTICAST_GROUPS (32)
154
155#define HTTP_TIMEOUT (TICKS_PER_SECOND * 10) /* 10 idle Seconds and a partially received request is abandoned */
156#define HTTP_READ_TIME_LIMIT (30) /* Seconds to allow reading to avoid denial of service*/
157#define HTTP_RX_BUFFERSIZE (10000)
158#define MAX_HTTP_PENDING_SOCKETS (5) // Number of sockets allowed to be pending on listening socket, performance will degrade < 3
159#define MAX_HTTP_CONNECTED_SOCKETS (5) // Number of sockets allowed to be connected to http server simultaneously
160#define MAX_HTTP_POST_VAR_NAME_SIZE (256) // Max HTTP POST variable name length
161#define MAX_HTTP_POST_VAR_VALUE_SIZE (256) // Max HTTP POST variable value length
162
163// FDs are preallocated
164// STDOUT
165// STDIN
166// STDERR
167// <-SERIAL_SOCKET_OFFSET
168// Serial 0
169// Serial 1
170// <-TCP_SOCKET_OFFSET
171// TCP FD's
172// <-EXTRA_IO_OFFSET
173// Extra FDS
174
175#define SERIAL_SOCKET_OFFSET (3)
176#define TCP_SOCKET_OFFSET (5)
177#define TCP_SOCKET_STRUCTS (128)
178#define EXTRA_IO_OFFSET (TCP_SOCKET_OFFSET + TCP_SOCKET_STRUCTS)
179#define EXTRA_FDS (122)
180#define TOTAL_FDS (TCP_SOCKET_OFFSET + TCP_SOCKET_STRUCTS + EXTRA_FDS)
181#define FDSET_ELEMENTS ((TOTAL_FDS) / 32)
182
183#define TASK_TABLE_SIZE 2
184
185#define MAX_IP_ERRS 3
186
187#define BUFFER_POOL_SIZE (256) /* was 64 in last release, we increased buffer segments to handle higher throughput events*/
188#define POOL_BUFFER_SIZE (sizeof(pool_buffer)) // Size of each buffer - 1712 bytes by default
189#define UDP_DISPATCH_SIZE (15)
190#define UDP_MIN_BUFFER_THRESHOLD (10)
191#define ARP_ENTRY_SIZE (256)
192
193#define UDP_NETBURNERID_PORT (0x4E42) /* NB */
194#define UDP_DHCP_SERVER_PORT (67)
195#define UDP_DHCP_CLIENT_PORT (68)
196#define UDP_MDNS_PORT (5353)
197
198#define TFTP_RX_PORT (1414)
199
200#define LINK_STATUS_CHECK_INTERVAL (2 * TICKS_PER_SECOND)
201
202#define FTPD_SOCKET_TIMEOUT (5 * 60 * TICKS_PER_SECOND)
203
204#ifndef _DEBUG
205#define ENABLE_SRAM_SYS
206#endif
207
208/* If ENABLE _SRAM_SYS is TRUE, then the processor's on-chip SRAM will be
209 used for fast network buffering and OS tasks as defined below:
210*/
211#ifdef ENABLE_SRAM_SYS
212#define FAST_SYSTEM_VARIABLES
213
214// Uncommented system tasks will be stored in SRAM, otherwise SDRAM will be used.
215//#define FAST_IDLE_STACK
216#define FAST_MAIN_STACK
217#define FAST_ETHERNET_VARIABLES
218#define FAST_ETHERNET_STACK
219#define FAST_BUFFERS_VARIABLES
220#define FAST_BUFFERS
221#define FAST_IP_VARIABLES
222#define FAST_IP_STACK
223#define FAST_TCP_VARIABLES
224#define FAST_TCP_STACK
225#define FAST_USB_VARIABLES
226#define FAST_USB_STACK
227//#define FAST_HTTP_STACK
228//#define FAST_FTP_STACK
229//#define FAST_WIFI_STACK
230//#define FAST_PPP_STACK
231//#define FAST_COMMAND_STACK
232
233/* If these defines are enabled, any user variables or tasks declared with
234 FAST_USR_STK or FAST_USR_VAR will be stored in SRAM.
235*/
236#define FAST_USER_VARIABLES
237#define FAST_USER_STACK
238
239#define FAST_TLS_VARIABLES
240
241#endif
242
243#ifdef FAST_SYSTEM_VARIABLES
244#define FAST_SYS_VAR __attribute__((section("SYS_VAR_SECT")))
245#define FAST_SYS_VAR_REL __attribute__((section("SYS_VAR_SECT_REL")))
246#define FAST_SYS_VAR_REL_STR __attribute__((section("SYS_VAR_SECT_REL_STR")))
247#else
248#define FAST_SYS_VAR
249#define FAST_SYS_VAR_REL
250#define FAST_SYS_VAR_REL_STR
251#endif
252#ifdef FAST_IDLE_STACK
253#define FAST_IDLE_STK __attribute__((section("IDLE_STK_SECT")))
254#else
255#define FAST_IDLE_STK
256#endif
257#ifdef FAST_MAIN_STACK
258#define FAST_MAIN_STK __attribute__((section("MAIN_STK_SECT")))
259#else
260#define FAST_MAIN_STK
261#endif
262#ifdef FAST_USER_STACK
263#define FAST_USER_STK __attribute__((section("USER_STK_SECT")))
264#else
265#define FAST_USER_STK
266#endif
267#ifdef FAST_USER_VARIABLES
268#define FAST_USER_VAR __attribute__((section("USER_VAR_SECT")))
269#else
270#define FAST_USER_VAR
271#endif
272#ifdef FAST_ETHERNET_VARIABLES
273#define FAST_ETHER_VAR __attribute__((section("ETHER_VAR_SECT")))
274#define FAST_ETHER_VAR_REL __attribute__((section("ETHER_VAR_SECT_REL")))
275#else
276#define FAST_ETHER_VAR
277#define FAST_ETHER_VAR_REL
278#endif
279#ifdef FAST_ETHERNET_STACK
280#define FAST_ETHER_STK __attribute__((section("ETHER_STK_SECT")))
281#else
282#define FAST_ETHER_STK
283#endif
284#ifdef FAST_IP_VARIABLES
285#define FAST_IP_VAR __attribute__((section("IP_VAR_SECT")))
286#define FAST_IP_VAR_REL __attribute__((section("IP_VAR_SECT_REL")))
287#else
288#define FAST_IP_VAR
289#define FAST_IP_VAR_REL
290#endif
291#ifdef FAST_IP_STACK
292#define FAST_IP_STK __attribute__((section("IP_STK_SECT")))
293#else
294#define FAST_IP_STK
295#endif
296#ifdef FAST_TCP_VARIABLES
297#define FAST_TCP_VAR __attribute__((section("TCP_VAR_SECT")))
298#define FAST_TCP_VAR_REL __attribute__((section("TCP_VAR_SECT_REL")))
299#else
300#define FAST_TCP_VAR
301#define FAST_TCP_VAR_REL
302#endif
303#ifdef FAST_TCP_STACK
304#define FAST_TCP_STK __attribute__((section("TCP_STK_SECT")))
305#else
306#define FAST_TCP_STK
307#endif
308#ifdef FAST_HTTP_STACK
309#define FAST_HTTP_STK __attribute__((section("HTTP_STK_SECT")))
310#else
311#define FAST_HTTP_STK
312#endif
313#ifdef FAST_FTP_STACK
314#define FAST_FTP_STK __attribute__((section("FTP_STK_SECT")))
315#else
316#define FAST_FTP_STK
317#endif
318#ifdef FAST_WIFI_STACK
319#define FAST_WIFI_STK __attribute__((section("WIFI_STK_SECT")))
320#else
321#define FAST_WIFI_STK
322#endif
323#ifdef FAST_PPP_STACK
324#define FAST_PPP_STK __attribute__((section("PPP_STK_SECT")))
325#else
326#define FAST_PPP_STK
327#endif
328#ifdef FAST_COMMAND_STACK
329#define FAST_COMMAND_STK __attribute__((section("COMMAND_STK_SECT")))
330#else
331#define FAST_COMMAND_STK
332#endif
333#ifdef FAST_BUFFERS_VARIABLES
334#define FAST_BUFF_VAR __attribute__((section("BUFFERS_VAR_SECT")))
335#define FAST_BUFF_VAR_REL __attribute__((section("BUFFERS_VAR_SECT_REL")))
336#else
337#define FAST_BUFF_VAR
338#define FAST_BUFF_VAR_REL
339#endif
340#ifdef FAST_TLS_VARIABLES
341#define FAST_TLS_VAR __attribute__((section("TLS_VAR_SECT")))
342#define FAST_TLS_VAR_REL __attribute__((section("TLS_VAR_SECT_REL")))
343#else
344#define FAST_TLS_VAR
345#define FAST_TLS_VAR_REL
346#endif
347#ifdef FAST_USB_VARIABLES
348#define FAST_USB_VAR __attribute__((section("USB_VAR_SECT")))
349#define FAST_USB_VAR_REL __attribute__((section("USB_VAR_SECT_REL")))
350#else
351#define FAST_USB_VAR
352#define FAST_USB_VAR_REL
353#endif
354#ifdef FAST_USB_STACK
355#define FAST_USB_STK __attribute__((section("USB_STK_SECT")))
356#else
357#define FAST_USB_STK
358#endif
359
360#define DO_NOT_CACHE __attribute__((section("NO_CACHE_SECT")))
361
362#define FIRST_UNUSED_TIMER (-1)
363
364/* Config server stuff */
365#define NumberOfConfigWebChannels 12
366#define ConfigActionIdleTimeout (TICKS_PER_SECOND * 30)
367#define MAX_HDR_SIZE (256) /* Size of web client recieve single header maximum*/
368
369
370#define NUM_DNS_CACHE (16)
371
372#endif /* #ifndef _CONSTANTS_H */