Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
cc.h
00001 /* 00002 * Copyright (c) 2001-2003 Swedish Institute of Computer Science. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * 3. The name of the author may not be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00019 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00024 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00025 * OF SUCH DAMAGE. 00026 * 00027 * This file is part of the lwIP TCP/IP stack. 00028 * 00029 * Author: Adam Dunkels <adam@sics.se> 00030 * 00031 */ 00032 #ifndef __CC_H__ 00033 #define __CC_H__ 00034 00035 #include <stdint.h> 00036 #include <stddef.h> /* for size_t */ 00037 #include "mbed_toolchain.h" 00038 #include "lwipopts.h" 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /* ARM/LPC17xx is little endian only */ 00045 #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) 00046 #ifdef BYTE_ORDER 00047 #undef BYTE_ORDER 00048 #endif 00049 #define BYTE_ORDER LITTLE_ENDIAN 00050 #endif 00051 00052 #ifndef LWIP_PROVIDE_ERRNO 00053 /* Use LWIP error codes */ 00054 #define LWIP_PROVIDE_ERRNO 00055 #endif 00056 00057 #if defined(__arm__) && defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6010050) 00058 /* Keil uVision4 tools */ 00059 #define PACK_STRUCT_BEGIN __packed 00060 #define PACK_STRUCT_STRUCT 00061 #define PACK_STRUCT_END 00062 #define PACK_STRUCT_FIELD(fld) fld 00063 #define ALIGNED(n) __align(n) 00064 #elif defined (__IAR_SYSTEMS_ICC__) 00065 /* IAR Embedded Workbench tools */ 00066 #define PACK_STRUCT_BEGIN __packed 00067 #define PACK_STRUCT_STRUCT 00068 #define PACK_STRUCT_END 00069 #define PACK_STRUCT_FIELD(fld) fld 00070 #define IAR_STR(a) #a 00071 #define ALIGNED(n) _Pragma(IAR_STR(data_alignment= ## n ##)) 00072 #else 00073 /* GCC tools (CodeSourcery) */ 00074 #define PACK_STRUCT_BEGIN 00075 #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) 00076 #define PACK_STRUCT_END 00077 #define PACK_STRUCT_FIELD(fld) fld 00078 #define ALIGNED(n) __attribute__((aligned (n))) 00079 #endif 00080 00081 /* Provide Thumb-2 routines for GCC to improve performance */ 00082 #if defined(TOOLCHAIN_GCC) && defined(__thumb2__) 00083 #define MEMCPY(dst,src,len) thumb2_memcpy(dst,src,len) 00084 #define LWIP_CHKSUM thumb2_checksum 00085 /* Set algorithm to 0 so that unused lwip_standard_chksum function 00086 doesn't generate compiler warning */ 00087 #define LWIP_CHKSUM_ALGORITHM 0 00088 00089 void* thumb2_memcpy(void* pDest, const void* pSource, size_t length); 00090 uint16_t thumb2_checksum(const void* pData, int length); 00091 #else 00092 /* Used with IP headers only */ 00093 #define LWIP_CHKSUM_ALGORITHM 1 00094 #endif 00095 00096 00097 #ifdef LWIP_DEBUG 00098 00099 #if MBED_CONF_LWIP_USE_MBED_TRACE 00100 void lwip_mbed_tracef_debug(const char *fmt, ...); 00101 void lwip_mbed_tracef_error(const char *fmt, ...); 00102 void lwip_mbed_tracef_warn(const char *fmt, ...); 00103 MBED_NORETURN void lwip_mbed_assert_fail(const char *msg, const char *func, const char *file, unsigned int line); 00104 00105 #define LWIP_PLATFORM_DIAG(vars) lwip_mbed_tracef_debug vars 00106 #define LWIP_PLATFORM_DIAG_SEVERE(vars) lwip_mbed_tracef_error vars 00107 #define LWIP_PLATFORM_DIAG_SERIOUS(vars) lwip_mbed_tracef_error vars 00108 #define LWIP_PLATFORM_DIAG_WARNING(vars) lwip_mbed_tracef_warn vars 00109 00110 #define LWIP_PLATFORM_ASSERT(message) lwip_mbed_assert_fail(message, __func__, __FILE__, __LINE__) 00111 00112 #else // MBED_CONF_LWIP_USE_MBED_TRACE 00113 #include <stdio.h> 00114 00115 MBED_NORETURN void assert_printf(const char *msg, int line, const char *file); 00116 00117 /* Plaform specific diagnostic output */ 00118 #define LWIP_PLATFORM_DIAG(vars) printf vars 00119 #define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); } 00120 #endif // MBED_CONF_LWIP_USE_MBED_TRACE 00121 #endif 00122 00123 #if TRACE_TO_ASCII_HEX_DUMP 00124 #define TRACE_TO_ASCII_HEX_DUMPF(prefix, len, data) trace_to_ascii_hex_dump(prefix, len, data) 00125 void trace_to_ascii_hex_dump(char* prefix, int len, char *data); 00126 #else 00127 #define TRACE_TO_ASCII_HEX_DUMPF(prefix, len, data) ((void)0) 00128 #endif 00129 00130 #include "cmsis.h" 00131 #define LWIP_PLATFORM_HTONS(x) __REV16(x) 00132 #define LWIP_PLATFORM_HTONL(x) __REV(x) 00133 00134 /* Define the memory area for the lwip's memory pools */ 00135 #ifndef MEMP_SECTION 00136 #if defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) 00137 # if defined (__ICCARM__) 00138 # define MEMP_SECTION 00139 # elif defined(TOOLCHAIN_GCC_CR) 00140 # define MEMP_SECTION __attribute__((section(".data.$RamPeriph32"))) 00141 # else 00142 # define MEMP_SECTION __attribute__((section("AHBSRAM0"),aligned)) 00143 # endif 00144 #elif defined(TARGET_LPC1768) 00145 # if defined (__ICCARM__) 00146 # define MEMP_SECTION 00147 # elif defined(TOOLCHAIN_GCC_CR) 00148 # define MEMP_SECTION __attribute__((section(".data.$RamPeriph32"))) 00149 # else 00150 # define MEMP_SECTION __attribute__((section("AHBSRAM1"),aligned)) 00151 # endif 00152 #endif 00153 #endif 00154 00155 #ifdef MEMP_SECTION 00156 #define SET_MEMP_SECTION(name) extern uint8_t MEMP_SECTION name[] 00157 00158 #if defined (__ICCARM__) 00159 #pragma default_variable_attributes = @ ".ethusbram" 00160 #endif 00161 SET_MEMP_SECTION(memp_memory_REASSDATA_base); 00162 SET_MEMP_SECTION(memp_memory_TCP_PCB_LISTEN_base); 00163 SET_MEMP_SECTION(memp_memory_PBUF_POOL_base); 00164 SET_MEMP_SECTION(memp_memory_NETCONN_base); 00165 SET_MEMP_SECTION(memp_memory_IGMP_GROUP_base); 00166 SET_MEMP_SECTION(memp_memory_UDP_PCB_base); 00167 SET_MEMP_SECTION(memp_memory_TCP_PCB_base); 00168 SET_MEMP_SECTION(memp_memory_FRAG_PBUF_base); 00169 SET_MEMP_SECTION(memp_memory_PBUF_base); 00170 SET_MEMP_SECTION(memp_memory_MLD6_GROUP_base); 00171 SET_MEMP_SECTION(memp_memory_IP6_REASSDATA_base); 00172 SET_MEMP_SECTION(memp_memory_NETBUF_base); 00173 SET_MEMP_SECTION(memp_memory_TCPIP_MSG_INPKT_base); 00174 SET_MEMP_SECTION(memp_memory_SYS_TIMEOUT_base); 00175 SET_MEMP_SECTION(memp_memory_TCP_SEG_base); 00176 SET_MEMP_SECTION(memp_memory_TCPIP_MSG_API_base); 00177 #if defined (__ICCARM__) 00178 #pragma default_variable_attributes = 00179 #endif 00180 #endif 00181 00182 #ifdef __cplusplus 00183 } 00184 #endif 00185 00186 #endif /* __CC_H__ */
Generated on Tue Jul 12 2022 13:54:04 by
