Deprecated fork of old network stack source from github. Please use official library instead: https://mbed.org/users/mbed_official/code/EthernetInterface/
lwip-sys/arch/cc.h@1:eadc868c2acf, 2013-10-26 (annotated)
- Committer:
- AdamGreen
- Date:
- Sat Oct 26 08:51:36 2013 +0000
- Revision:
- 1:eadc868c2acf
- Parent:
- 0:3b00827bb0b7
Fix TCP checksum bug and stranded large TCP segments.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AdamGreen | 0:3b00827bb0b7 | 1 | /* |
AdamGreen | 0:3b00827bb0b7 | 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
AdamGreen | 0:3b00827bb0b7 | 3 | * All rights reserved. |
AdamGreen | 0:3b00827bb0b7 | 4 | * |
AdamGreen | 0:3b00827bb0b7 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AdamGreen | 0:3b00827bb0b7 | 6 | * are permitted provided that the following conditions are met: |
AdamGreen | 0:3b00827bb0b7 | 7 | * |
AdamGreen | 0:3b00827bb0b7 | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
AdamGreen | 0:3b00827bb0b7 | 9 | * this list of conditions and the following disclaimer. |
AdamGreen | 0:3b00827bb0b7 | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
AdamGreen | 0:3b00827bb0b7 | 11 | * this list of conditions and the following disclaimer in the documentation |
AdamGreen | 0:3b00827bb0b7 | 12 | * and/or other materials provided with the distribution. |
AdamGreen | 0:3b00827bb0b7 | 13 | * 3. The name of the author may not be used to endorse or promote products |
AdamGreen | 0:3b00827bb0b7 | 14 | * derived from this software without specific prior written permission. |
AdamGreen | 0:3b00827bb0b7 | 15 | * |
AdamGreen | 0:3b00827bb0b7 | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
AdamGreen | 0:3b00827bb0b7 | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
AdamGreen | 0:3b00827bb0b7 | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
AdamGreen | 0:3b00827bb0b7 | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
AdamGreen | 0:3b00827bb0b7 | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
AdamGreen | 0:3b00827bb0b7 | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
AdamGreen | 0:3b00827bb0b7 | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
AdamGreen | 0:3b00827bb0b7 | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
AdamGreen | 0:3b00827bb0b7 | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
AdamGreen | 0:3b00827bb0b7 | 25 | * OF SUCH DAMAGE. |
AdamGreen | 0:3b00827bb0b7 | 26 | * |
AdamGreen | 0:3b00827bb0b7 | 27 | * This file is part of the lwIP TCP/IP stack. |
AdamGreen | 0:3b00827bb0b7 | 28 | * |
AdamGreen | 0:3b00827bb0b7 | 29 | * Author: Adam Dunkels <adam@sics.se> |
AdamGreen | 0:3b00827bb0b7 | 30 | * |
AdamGreen | 0:3b00827bb0b7 | 31 | */ |
AdamGreen | 0:3b00827bb0b7 | 32 | #ifndef __CC_H__ |
AdamGreen | 0:3b00827bb0b7 | 33 | #define __CC_H__ |
AdamGreen | 0:3b00827bb0b7 | 34 | |
AdamGreen | 0:3b00827bb0b7 | 35 | #include <stdint.h> |
AdamGreen | 0:3b00827bb0b7 | 36 | |
AdamGreen | 0:3b00827bb0b7 | 37 | /* Types based on stdint.h */ |
AdamGreen | 0:3b00827bb0b7 | 38 | typedef uint8_t u8_t; |
AdamGreen | 0:3b00827bb0b7 | 39 | typedef int8_t s8_t; |
AdamGreen | 0:3b00827bb0b7 | 40 | typedef uint16_t u16_t; |
AdamGreen | 0:3b00827bb0b7 | 41 | typedef int16_t s16_t; |
AdamGreen | 0:3b00827bb0b7 | 42 | typedef uint32_t u32_t; |
AdamGreen | 0:3b00827bb0b7 | 43 | typedef int32_t s32_t; |
AdamGreen | 0:3b00827bb0b7 | 44 | typedef uintptr_t mem_ptr_t; |
AdamGreen | 0:3b00827bb0b7 | 45 | |
AdamGreen | 0:3b00827bb0b7 | 46 | /* Define (sn)printf formatters for these lwIP types */ |
AdamGreen | 0:3b00827bb0b7 | 47 | #define U16_F "hu" |
AdamGreen | 0:3b00827bb0b7 | 48 | #define S16_F "hd" |
AdamGreen | 0:3b00827bb0b7 | 49 | #define X16_F "hx" |
AdamGreen | 0:3b00827bb0b7 | 50 | #define U32_F "lu" |
AdamGreen | 0:3b00827bb0b7 | 51 | #define S32_F "ld" |
AdamGreen | 0:3b00827bb0b7 | 52 | #define X32_F "lx" |
AdamGreen | 0:3b00827bb0b7 | 53 | #define SZT_F "uz" |
AdamGreen | 0:3b00827bb0b7 | 54 | |
AdamGreen | 0:3b00827bb0b7 | 55 | /* ARM/LPC17xx is little endian only */ |
AdamGreen | 0:3b00827bb0b7 | 56 | #define BYTE_ORDER LITTLE_ENDIAN |
AdamGreen | 0:3b00827bb0b7 | 57 | |
AdamGreen | 0:3b00827bb0b7 | 58 | /* Use LWIP error codes */ |
AdamGreen | 0:3b00827bb0b7 | 59 | #define LWIP_PROVIDE_ERRNO |
AdamGreen | 0:3b00827bb0b7 | 60 | |
AdamGreen | 0:3b00827bb0b7 | 61 | #if defined(__arm__) && defined(__ARMCC_VERSION) |
AdamGreen | 0:3b00827bb0b7 | 62 | /* Keil uVision4 tools */ |
AdamGreen | 0:3b00827bb0b7 | 63 | #define PACK_STRUCT_BEGIN __packed |
AdamGreen | 0:3b00827bb0b7 | 64 | #define PACK_STRUCT_STRUCT |
AdamGreen | 0:3b00827bb0b7 | 65 | #define PACK_STRUCT_END |
AdamGreen | 0:3b00827bb0b7 | 66 | #define PACK_STRUCT_FIELD(fld) fld |
AdamGreen | 0:3b00827bb0b7 | 67 | #define ALIGNED(n) __align(n) |
AdamGreen | 0:3b00827bb0b7 | 68 | #elif defined (__IAR_SYSTEMS_ICC__) |
AdamGreen | 0:3b00827bb0b7 | 69 | /* IAR Embedded Workbench tools */ |
AdamGreen | 0:3b00827bb0b7 | 70 | #define PACK_STRUCT_BEGIN __packed |
AdamGreen | 0:3b00827bb0b7 | 71 | #define PACK_STRUCT_STRUCT |
AdamGreen | 0:3b00827bb0b7 | 72 | #define PACK_STRUCT_END |
AdamGreen | 0:3b00827bb0b7 | 73 | #define PACK_STRUCT_FIELD(fld) fld |
AdamGreen | 0:3b00827bb0b7 | 74 | // #define PACK_STRUCT_USE_INCLUDES |
AdamGreen | 0:3b00827bb0b7 | 75 | #error NEEDS ALIGNED // FIXME TBD |
AdamGreen | 0:3b00827bb0b7 | 76 | #else |
AdamGreen | 0:3b00827bb0b7 | 77 | /* GCC tools (CodeSourcery) */ |
AdamGreen | 0:3b00827bb0b7 | 78 | #define PACK_STRUCT_BEGIN |
AdamGreen | 0:3b00827bb0b7 | 79 | #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) |
AdamGreen | 0:3b00827bb0b7 | 80 | #define PACK_STRUCT_END |
AdamGreen | 0:3b00827bb0b7 | 81 | #define PACK_STRUCT_FIELD(fld) fld |
AdamGreen | 0:3b00827bb0b7 | 82 | #define ALIGNED(n) __attribute__((aligned (n))) |
AdamGreen | 0:3b00827bb0b7 | 83 | #endif |
AdamGreen | 0:3b00827bb0b7 | 84 | |
AdamGreen | 0:3b00827bb0b7 | 85 | /* Provide Thumb-2 routines for GCC to improve performance */ |
AdamGreen | 0:3b00827bb0b7 | 86 | #if defined(TOOLCHAIN_GCC) && defined(__thumb2__) |
AdamGreen | 0:3b00827bb0b7 | 87 | #define MEMCPY(dst,src,len) thumb2_memcpy(dst,src,len) |
AdamGreen | 0:3b00827bb0b7 | 88 | #define LWIP_CHKSUM thumb2_checksum |
AdamGreen | 0:3b00827bb0b7 | 89 | /* Set algorithm to 0 so that unused lwip_standard_chksum function |
AdamGreen | 0:3b00827bb0b7 | 90 | doesn't generate compiler warning */ |
AdamGreen | 0:3b00827bb0b7 | 91 | #define LWIP_CHKSUM_ALGORITHM 0 |
AdamGreen | 0:3b00827bb0b7 | 92 | |
AdamGreen | 0:3b00827bb0b7 | 93 | void* thumb2_memcpy(void* pDest, const void* pSource, size_t length); |
AdamGreen | 0:3b00827bb0b7 | 94 | u16_t thumb2_checksum(void* pData, int length); |
AdamGreen | 0:3b00827bb0b7 | 95 | #else |
AdamGreen | 0:3b00827bb0b7 | 96 | /* Used with IP headers only */ |
AdamGreen | 0:3b00827bb0b7 | 97 | #define LWIP_CHKSUM_ALGORITHM 1 |
AdamGreen | 0:3b00827bb0b7 | 98 | #endif |
AdamGreen | 0:3b00827bb0b7 | 99 | |
AdamGreen | 0:3b00827bb0b7 | 100 | |
AdamGreen | 0:3b00827bb0b7 | 101 | #ifdef LWIP_DEBUG |
AdamGreen | 0:3b00827bb0b7 | 102 | |
AdamGreen | 0:3b00827bb0b7 | 103 | #include "stdio.h" |
AdamGreen | 0:3b00827bb0b7 | 104 | |
AdamGreen | 0:3b00827bb0b7 | 105 | void assert_printf(char *msg, int line, char *file); |
AdamGreen | 0:3b00827bb0b7 | 106 | |
AdamGreen | 0:3b00827bb0b7 | 107 | /* Plaform specific diagnostic output */ |
AdamGreen | 0:3b00827bb0b7 | 108 | #define LWIP_PLATFORM_DIAG(vars) printf vars |
AdamGreen | 0:3b00827bb0b7 | 109 | #define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); } |
AdamGreen | 0:3b00827bb0b7 | 110 | #else |
AdamGreen | 0:3b00827bb0b7 | 111 | #define LWIP_PLATFORM_DIAG(msg) { ; } |
AdamGreen | 0:3b00827bb0b7 | 112 | #define LWIP_PLATFORM_ASSERT(flag) { ; } |
AdamGreen | 0:3b00827bb0b7 | 113 | #endif |
AdamGreen | 0:3b00827bb0b7 | 114 | |
AdamGreen | 0:3b00827bb0b7 | 115 | #include "cmsis.h" |
AdamGreen | 0:3b00827bb0b7 | 116 | #define LWIP_PLATFORM_HTONS(x) __REV16(x) |
AdamGreen | 0:3b00827bb0b7 | 117 | #define LWIP_PLATFORM_HTONL(x) __REV(x) |
AdamGreen | 0:3b00827bb0b7 | 118 | |
AdamGreen | 0:3b00827bb0b7 | 119 | #endif /* __CC_H__ */ |