Path: blob/master/arch/unicore32/lib/copy_template.S
10817 views
/*1* linux/arch/unicore32/lib/copy_template.S2*3* Code specific to PKUnity SoC and UniCore ISA4*5* Copyright (C) 2001-2010 GUAN Xue-tao6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License version 2 as9* published by the Free Software Foundation.10*/1112/*13* Theory of operation14* -------------------15*16* This file provides the core code for a forward memory copy used in17* the implementation of memcopy(), copy_to_user() and copy_from_user().18*19* The including file must define the following accessor macros20* according to the need of the given function:21*22* ldr1w ptr reg abort23*24* This loads one word from 'ptr', stores it in 'reg' and increments25* 'ptr' to the next word. The 'abort' argument is used for fixup tables.26*27* ldr4w ptr reg1 reg2 reg3 reg4 abort28* ldr8w ptr, reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort29*30* This loads four or eight words starting from 'ptr', stores them31* in provided registers and increments 'ptr' past those words.32* The'abort' argument is used for fixup tables.33*34* ldr1b ptr reg cond abort35*36* Similar to ldr1w, but it loads a byte and increments 'ptr' one byte.37* It also must apply the condition code if provided, otherwise the38* "al" condition is assumed by default.39*40* str1w ptr reg abort41* str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort42* str1b ptr reg cond abort43*44* Same as their ldr* counterparts, but data is stored to 'ptr' location45* rather than being loaded.46*47* enter48*49* Preserve the provided registers on the stack plus any additional50* data as needed by the implementation including this code. Called51* upon code entry.52*53* exit54*55* Restore registers with the values previously saved with the56* 'preserv' macro. Called upon code termination.57*/585960enter6162sub.a r2, r2, #463bsl 8f64and.a ip, r0, #365bne 9f66and.a ip, r1, #367bne 10f68691: sub.a r2, r2, #(28)70stm.w (r5 - r8), [sp-]71bsl 5f72733:744: ldr8w r1, r3, r4, r5, r6, r7, r8, r10, r11, abort=20f75sub.a r2, r2, #3276str8w r0, r3, r4, r5, r6, r7, r8, r10, r11, abort=20f77beg 3b78795: and.a ip, r2, #2880rsub ip, ip, #3281beq 7f82add pc, pc, ip @ C is always clear here83nop8485ldr1w r1, r3, abort=20f86ldr1w r1, r4, abort=20f87ldr1w r1, r5, abort=20f88ldr1w r1, r6, abort=20f89ldr1w r1, r7, abort=20f90ldr1w r1, r8, abort=20f91ldr1w r1, r11, abort=20f9293add pc, pc, ip94nop9596str1w r0, r3, abort=20f97str1w r0, r4, abort=20f98str1w r0, r5, abort=20f99str1w r0, r6, abort=20f100str1w r0, r7, abort=20f101str1w r0, r8, abort=20f102str1w r0, r11, abort=20f1031047: ldm.w (r5 - r8), [sp]+1051068: mov.a r2, r2 << #31107ldr1b r1, r3, ne, abort=21f108ldr1b r1, r4, ea, abort=21f109ldr1b r1, r10, ea, abort=21f110str1b r0, r3, ne, abort=21f111str1b r0, r4, ea, abort=21f112str1b r0, r10, ea, abort=21f113114exit1151169: rsub ip, ip, #4117csub.a ip, #2118ldr1b r1, r3, sg, abort=21f119ldr1b r1, r4, eg, abort=21f120ldr1b r1, r11, abort=21f121str1b r0, r3, sg, abort=21f122str1b r0, r4, eg, abort=21f123sub.a r2, r2, ip124str1b r0, r11, abort=21f125bsl 8b126and.a ip, r1, #3127beq 1b12812910: andn r1, r1, #3130csub.a ip, #2131ldr1w r1, r11, abort=21f132beq 17f133bsg 18f134135136.macro forward_copy_shift a b137138sub.a r2, r2, #28139bsl 14f14014111: stm.w (r5 - r9), [sp-]14214312:144ldr4w r1, r4, r5, r6, r7, abort=19f145mov r3, r11 pull #\a146sub.a r2, r2, #32147ldr4w r1, r8, r9, r10, r11, abort=19f148or r3, r3, r4 push #\b149mov r4, r4 pull #\a150or r4, r4, r5 push #\b151mov r5, r5 pull #\a152or r5, r5, r6 push #\b153mov r6, r6 pull #\a154or r6, r6, r7 push #\b155mov r7, r7 pull #\a156or r7, r7, r8 push #\b157mov r8, r8 pull #\a158or r8, r8, r9 push #\b159mov r9, r9 pull #\a160or r9, r9, r10 push #\b161mov r10, r10 pull #\a162or r10, r10, r11 push #\b163str8w r0, r3, r4, r5, r6, r7, r8, r9, r10, , abort=19f164beg 12b165166ldm.w (r5 - r9), [sp]+16716814: and.a ip, r2, #28169beq 16f17017115: mov r3, r11 pull #\a172ldr1w r1, r11, abort=21f173sub.a ip, ip, #4174or r3, r3, r11 push #\b175str1w r0, r3, abort=21f176bsg 15b17717816: sub r1, r1, #(\b / 8)179b 8b180181.endm182183184forward_copy_shift a=8 b=2418518617: forward_copy_shift a=16 b=1618718818: forward_copy_shift a=24 b=8189190191/*192* Abort preamble and completion macros.193* If a fixup handler is required then those macros must surround it.194* It is assumed that the fixup code will handle the private part of195* the exit macro.196*/197198.macro copy_abort_preamble19919: ldm.w (r5 - r9), [sp]+200b 21f201299: .word 0 @ store lr202@ to avoid function call in fixup20320: ldm.w (r5 - r8), [sp]+20421:205adr r1, 299b206stw lr, [r1]207.endm208209.macro copy_abort_end210adr lr, 299b211ldw pc, [lr]212.endm213214215216