Mistake on this page?
Report an issue in GitHub or email us
cc.h
1 /*
2  * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 #ifndef __CC_H__
33 #define __CC_H__
34 
35 #include <stdint.h>
36 #include <stddef.h> /* for size_t */
37 #include "mbed_toolchain.h"
38 #include "lwipopts.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /* ARM/LPC17xx is little endian only */
45 #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
46 #ifdef BYTE_ORDER
47 #undef BYTE_ORDER
48 #endif
49 #define BYTE_ORDER LITTLE_ENDIAN
50 #endif
51 
52 #ifndef LWIP_PROVIDE_ERRNO
53 /* Use LWIP error codes */
54 #define LWIP_PROVIDE_ERRNO
55 #endif
56 
57 #if defined (__IAR_SYSTEMS_ICC__)
58  /* IAR Embedded Workbench tools */
59  #define PACK_STRUCT_BEGIN __packed
60  #define PACK_STRUCT_STRUCT
61  #define PACK_STRUCT_END
62  #define PACK_STRUCT_FIELD(fld) fld
63  #define IAR_STR(a) #a
64  #define ALIGNED(n) _Pragma(IAR_STR(data_alignment= ## n ##))
65 #else
66  /* GCC tools (CodeSourcery) */
67  #define PACK_STRUCT_BEGIN
68  #define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
69  #define PACK_STRUCT_END
70  #define PACK_STRUCT_FIELD(fld) fld
71  #define ALIGNED(n) __attribute__((aligned (n)))
72 #endif
73 
74 /* Provide Thumb-2 routines for GCC to improve performance */
75 #if defined(TOOLCHAIN_GCC) && defined(__thumb2__)
76  #define MEMCPY(dst,src,len) thumb2_memcpy(dst,src,len)
77  #define LWIP_CHKSUM thumb2_checksum
78  /* Set algorithm to 0 so that unused lwip_standard_chksum function
79  doesn't generate compiler warning */
80  #define LWIP_CHKSUM_ALGORITHM 0
81 
82  void* thumb2_memcpy(void* pDest, const void* pSource, size_t length);
83  uint16_t thumb2_checksum(const void* pData, int length);
84 #else
85  /* Used with IP headers only */
86  #define LWIP_CHKSUM_ALGORITHM 1
87 #endif
88 
89 
90 #ifdef LWIP_DEBUG
91 
92 #if MBED_CONF_LWIP_USE_MBED_TRACE
93 void lwip_mbed_tracef_debug(const char *fmt, ...);
94 void lwip_mbed_tracef_error(const char *fmt, ...);
95 void lwip_mbed_tracef_warn(const char *fmt, ...);
96 MBED_NORETURN void lwip_mbed_assert_fail(const char *msg, const char *func, const char *file, unsigned int line);
97 
98 #define LWIP_PLATFORM_DIAG(vars) lwip_mbed_tracef_debug vars
99 #define LWIP_PLATFORM_DIAG_SEVERE(vars) lwip_mbed_tracef_error vars
100 #define LWIP_PLATFORM_DIAG_SERIOUS(vars) lwip_mbed_tracef_error vars
101 #define LWIP_PLATFORM_DIAG_WARNING(vars) lwip_mbed_tracef_warn vars
102 
103 #define LWIP_PLATFORM_ASSERT(message) lwip_mbed_assert_fail(message, __func__, __FILE__, __LINE__)
104 
105 #else // MBED_CONF_LWIP_USE_MBED_TRACE
106 #include <stdio.h>
107 
108 MBED_NORETURN void assert_printf(const char *msg, int line, const char *file);
109 
110 /* Plaform specific diagnostic output */
111 #define LWIP_PLATFORM_DIAG(vars) printf vars
112 #define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); }
113 #endif // MBED_CONF_LWIP_USE_MBED_TRACE
114 #endif
115 
116 #if TRACE_TO_ASCII_HEX_DUMP
117 #define TRACE_TO_ASCII_HEX_DUMPF(prefix, len, data) trace_to_ascii_hex_dump(prefix, len, data)
118 void trace_to_ascii_hex_dump(char* prefix, int len, char *data);
119 #else
120 #define TRACE_TO_ASCII_HEX_DUMPF(prefix, len, data) ((void)0)
121 #endif
122 
123 #include "cmsis.h"
124 #define LWIP_PLATFORM_HTONS(x) __REV16(x)
125 #define LWIP_PLATFORM_HTONL(x) __REV(x)
126 
127 // Provide inline replacements for htons() and htonl()
128 #define lwip_htons(x) __REV16(x)
129 #define lwip_htonl(x) __REV(x)
130 
131 /* Define the memory area for the lwip's memory pools */
132 #ifndef MEMP_SECTION
133 #if defined(TARGET_LPC1768)
134 # if defined (__ICCARM__)
135 # define MEMP_SECTION
136 # elif defined(TOOLCHAIN_GCC_CR)
137 # define MEMP_SECTION __attribute__((section(".data.$RamPeriph32")))
138 # else
139 # define MEMP_SECTION __attribute__((section("AHBSRAM1"),aligned))
140 # endif
141 #endif
142 #endif
143 
144 #ifdef MEMP_SECTION
145 #define SET_MEMP_SECTION(name) extern uint8_t MEMP_SECTION name[]
146 
147 #if defined (__ICCARM__)
148 #pragma default_variable_attributes = @ ".ethusbram"
149 #endif
150 SET_MEMP_SECTION(memp_memory_REASSDATA_base);
151 SET_MEMP_SECTION(memp_memory_TCP_PCB_LISTEN_base);
152 SET_MEMP_SECTION(memp_memory_PBUF_POOL_base);
153 SET_MEMP_SECTION(memp_memory_NETCONN_base);
154 SET_MEMP_SECTION(memp_memory_IGMP_GROUP_base);
155 SET_MEMP_SECTION(memp_memory_UDP_PCB_base);
156 SET_MEMP_SECTION(memp_memory_TCP_PCB_base);
157 SET_MEMP_SECTION(memp_memory_FRAG_PBUF_base);
158 SET_MEMP_SECTION(memp_memory_PBUF_base);
159 SET_MEMP_SECTION(memp_memory_MLD6_GROUP_base);
160 SET_MEMP_SECTION(memp_memory_IP6_REASSDATA_base);
161 SET_MEMP_SECTION(memp_memory_NETBUF_base);
162 SET_MEMP_SECTION(memp_memory_TCPIP_MSG_INPKT_base);
163 SET_MEMP_SECTION(memp_memory_SYS_TIMEOUT_base);
164 SET_MEMP_SECTION(memp_memory_TCP_SEG_base);
165 SET_MEMP_SECTION(memp_memory_TCPIP_MSG_API_base);
166 #if defined (__ICCARM__)
167 #pragma default_variable_attributes =
168 #endif
169 #endif
170 
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 #endif /* __CC_H__ */
#define MBED_NORETURN
MBED_NORETURN Declare a function that will never return.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.