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


