/*1* linux/arch/arm/lib/memzero.S2*3* Copyright (C) 1995-2000 Russell King4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 2 as7* published by the Free Software Foundation.8*/9#include <linux/linkage.h>10#include <asm/assembler.h>1112.text13.align 514.word 015/*16* Align the pointer in r0. r3 contains the number of bytes that we are17* mis-aligned by, and r1 is the number of bytes. If r1 < 4, then we18* don't bother; we use byte stores instead.19*/201: subs r1, r1, #4 @ 1 do we have enough21blt 5f @ 1 bytes to align with?22cmp r3, #2 @ 123strltb r2, [r0], #1 @ 124strleb r2, [r0], #1 @ 125strb r2, [r0], #1 @ 126add r1, r1, r3 @ 1 (r1 = r1 - (4 - r3))27/*28* The pointer is now aligned and the length is adjusted. Try doing the29* memzero again.30*/3132ENTRY(__memzero)33mov r2, #0 @ 134ands r3, r0, #3 @ 1 unaligned?35bne 1b @ 136/*37* r3 = 0, and we know that the pointer in r0 is aligned to a word boundary.38*/39cmp r1, #16 @ 1 we can skip this chunk if we40blt 4f @ 1 have < 16 bytes4142#if ! CALGN(1)+04344/*45* We need an extra register for this loop - save the return address and46* use the LR47*/48str lr, [sp, #-4]! @ 149mov ip, r2 @ 150mov lr, r2 @ 151523: subs r1, r1, #64 @ 1 write 32 bytes out per loop53stmgeia r0!, {r2, r3, ip, lr} @ 454stmgeia r0!, {r2, r3, ip, lr} @ 455stmgeia r0!, {r2, r3, ip, lr} @ 456stmgeia r0!, {r2, r3, ip, lr} @ 457bgt 3b @ 158ldmeqfd sp!, {pc} @ 1/2 quick exit59/*60* No need to correct the count; we're only testing bits from now on61*/62tst r1, #32 @ 163stmneia r0!, {r2, r3, ip, lr} @ 464stmneia r0!, {r2, r3, ip, lr} @ 465tst r1, #16 @ 1 16 bytes or more?66stmneia r0!, {r2, r3, ip, lr} @ 467ldr lr, [sp], #4 @ 16869#else7071/*72* This version aligns the destination pointer in order to write73* whole cache lines at once.74*/7576stmfd sp!, {r4-r7, lr}77mov r4, r278mov r5, r279mov r6, r280mov r7, r281mov ip, r282mov lr, r28384cmp r1, #9685andgts ip, r0, #3186ble 3f8788rsb ip, ip, #3289sub r1, r1, ip90movs ip, ip, lsl #(32 - 4)91stmcsia r0!, {r4, r5, r6, r7}92stmmiia r0!, {r4, r5}93movs ip, ip, lsl #294strcs r2, [r0], #495963: subs r1, r1, #6497stmgeia r0!, {r2-r7, ip, lr}98stmgeia r0!, {r2-r7, ip, lr}99bgt 3b100ldmeqfd sp!, {r4-r7, pc}101102tst r1, #32103stmneia r0!, {r2-r7, ip, lr}104tst r1, #16105stmneia r0!, {r4-r7}106ldmfd sp!, {r4-r7, lr}107108#endif1091104: tst r1, #8 @ 1 8 bytes or more?111stmneia r0!, {r2, r3} @ 2112tst r1, #4 @ 1 4 bytes or more?113strne r2, [r0], #4 @ 1114/*115* When we get here, we've got less than 4 bytes to zero. We116* may have an unaligned pointer as well.117*/1185: tst r1, #2 @ 1 2 bytes or more?119strneb r2, [r0], #1 @ 1120strneb r2, [r0], #1 @ 1121tst r1, #1 @ 1 a byte left over122strneb r2, [r0], #1 @ 1123mov pc, lr @ 1124ENDPROC(__memzero)125126127