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