lwip operating system abstraction layer implementation based on CMSIS-RTOS
Dependents: LwIPNetworking NetServicesMin EthernetInterface EthernetInterface_RSF ... more
memcpy.c
00001 /* Copyright (C) 2013 - Adam Green (https://github.com/adamgreen) 00002 00003 Licensed under the Apache License, Version 2.0 (the "License"); 00004 you may not use this file except in compliance with the License. 00005 You may obtain a copy of the License at 00006 00007 http://www.apache.org/licenses/LICENSE-2.0 00008 00009 Unless required by applicable law or agreed to in writing, software 00010 distributed under the License is distributed on an "AS IS" BASIS, 00011 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 See the License for the specific language governing permissions and 00013 limitations under the License. 00014 */ 00015 #if defined(TOOLCHAIN_GCC) && defined(__thumb2__) 00016 00017 #include <stdio.h> 00018 00019 00020 /* This is a hand written Thumb-2 assembly language version of the 00021 standard C memcpy() function that can be used by the lwIP networking 00022 stack to improve its performance. It copies 4 bytes at a time and 00023 unrolls the loop to perform 4 of these copies per loop iteration. 00024 */ 00025 __attribute__((naked)) void thumb2_memcpy(void* pDest, const void* pSource, size_t length) 00026 { 00027 __asm ( 00028 ".syntax unified\n" 00029 ".thumb\n" 00030 00031 // Copy 16 bytes at a time first. 00032 " lsrs r3, r2, #4\n" 00033 " beq.n 2$\n" 00034 "1$: ldr r12, [r1], #4\n" 00035 " str r12, [r0], #4\n" 00036 " ldr r12, [r1], #4\n" 00037 " str r12, [r0], #4\n" 00038 " ldr r12, [r1], #4\n" 00039 " str r12, [r0], #4\n" 00040 " ldr r12, [r1], #4\n" 00041 " str r12, [r0], #4\n" 00042 " subs r3, #1\n" 00043 " bne 1$\n" 00044 00045 // Copy byte by byte for what is left. 00046 "2$:\n" 00047 " ands r3, r2, #0xf\n" 00048 " beq.n 4$\n" 00049 "3$: ldrb r12, [r1], #1\n" 00050 " strb r12, [r0], #1\n" 00051 " subs r3, #1\n" 00052 " bne 3$\n" 00053 00054 // Return to caller. 00055 "4$: bx lr\n" 00056 ); 00057 } 00058 00059 #endif
Generated on Tue Jul 12 2022 18:38:06 by
