Deprecated fork of old network stack source from github. Please use official library instead: https://mbed.org/users/mbed_official/code/EthernetInterface/

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?

UserRevisionLine numberNew contents of line
AdamGreen 0:3b00827bb0b7 1 /* Copyright (C) 2013 - Adam Green (https://github.com/adamgreen)
AdamGreen 0:3b00827bb0b7 2
AdamGreen 0:3b00827bb0b7 3 Licensed under the Apache License, Version 2.0 (the "License");
AdamGreen 0:3b00827bb0b7 4 you may not use this file except in compliance with the License.
AdamGreen 0:3b00827bb0b7 5 You may obtain a copy of the License at
AdamGreen 0:3b00827bb0b7 6
AdamGreen 0:3b00827bb0b7 7 http://www.apache.org/licenses/LICENSE-2.0
AdamGreen 0:3b00827bb0b7 8
AdamGreen 0:3b00827bb0b7 9 Unless required by applicable law or agreed to in writing, software
AdamGreen 0:3b00827bb0b7 10 distributed under the License is distributed on an "AS IS" BASIS,
AdamGreen 0:3b00827bb0b7 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AdamGreen 0:3b00827bb0b7 12 See the License for the specific language governing permissions and
AdamGreen 0:3b00827bb0b7 13 limitations under the License.
AdamGreen 0:3b00827bb0b7 14 */
AdamGreen 0:3b00827bb0b7 15 #if defined(TOOLCHAIN_GCC) && defined(__thumb2__)
AdamGreen 0:3b00827bb0b7 16
AdamGreen 0:3b00827bb0b7 17 #include <stdio.h>
AdamGreen 0:3b00827bb0b7 18
AdamGreen 0:3b00827bb0b7 19
AdamGreen 0:3b00827bb0b7 20 /* This is a hand written Thumb-2 assembly language version of the
AdamGreen 0:3b00827bb0b7 21 standard C memcpy() function that can be used by the lwIP networking
AdamGreen 0:3b00827bb0b7 22 stack to improve its performance. It copies 4 bytes at a time and
AdamGreen 0:3b00827bb0b7 23 unrolls the loop to perform 4 of these copies per loop iteration.
AdamGreen 0:3b00827bb0b7 24 */
AdamGreen 0:3b00827bb0b7 25 __attribute__((naked)) void thumb2_memcpy(void* pDest, const void* pSource, size_t length)
AdamGreen 0:3b00827bb0b7 26 {
AdamGreen 0:3b00827bb0b7 27 __asm (
AdamGreen 0:3b00827bb0b7 28 ".syntax unified\n"
AdamGreen 0:3b00827bb0b7 29 ".thumb\n"
AdamGreen 0:3b00827bb0b7 30
AdamGreen 0:3b00827bb0b7 31 // Copy 16 bytes at a time first.
AdamGreen 0:3b00827bb0b7 32 " lsrs r3, r2, #4\n"
AdamGreen 0:3b00827bb0b7 33 " beq.n 2$\n"
AdamGreen 0:3b00827bb0b7 34 "1$: ldr r12, [r1], #4\n"
AdamGreen 0:3b00827bb0b7 35 " str r12, [r0], #4\n"
AdamGreen 0:3b00827bb0b7 36 " ldr r12, [r1], #4\n"
AdamGreen 0:3b00827bb0b7 37 " str r12, [r0], #4\n"
AdamGreen 0:3b00827bb0b7 38 " ldr r12, [r1], #4\n"
AdamGreen 0:3b00827bb0b7 39 " str r12, [r0], #4\n"
AdamGreen 0:3b00827bb0b7 40 " ldr r12, [r1], #4\n"
AdamGreen 0:3b00827bb0b7 41 " str r12, [r0], #4\n"
AdamGreen 0:3b00827bb0b7 42 " subs r3, #1\n"
AdamGreen 0:3b00827bb0b7 43 " bne 1$\n"
AdamGreen 0:3b00827bb0b7 44
AdamGreen 0:3b00827bb0b7 45 // Copy byte by byte for what is left.
AdamGreen 0:3b00827bb0b7 46 "2$:\n"
AdamGreen 0:3b00827bb0b7 47 " ands r3, r2, #0xf\n"
AdamGreen 0:3b00827bb0b7 48 " beq.n 4$\n"
AdamGreen 0:3b00827bb0b7 49 "3$: ldrb r12, [r1], #1\n"
AdamGreen 0:3b00827bb0b7 50 " strb r12, [r0], #1\n"
AdamGreen 0:3b00827bb0b7 51 " subs r3, #1\n"
AdamGreen 0:3b00827bb0b7 52 " bne 3$\n"
AdamGreen 0:3b00827bb0b7 53
AdamGreen 0:3b00827bb0b7 54 // Return to caller.
AdamGreen 0:3b00827bb0b7 55 "4$: bx lr\n"
AdamGreen 0:3b00827bb0b7 56 );
AdamGreen 0:3b00827bb0b7 57 }
AdamGreen 0:3b00827bb0b7 58
AdamGreen 0:3b00827bb0b7 59 #endif