| Index: embios/trunk/arm/memset-arm.S |
| — | — | @@ -1,118 +1,118 @@ |
| 2 | | -/*************************************************************************** |
| 3 | | - * __________ __ ___. |
| 4 | | - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 5 | | - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 6 | | - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 7 | | - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 8 | | - * \/ \/ \/ \/ \/ |
| 9 | | - * $Id$ |
| 10 | | - * |
| 11 | | - * Copyright (C) 2006 by Thom Johansen |
| 12 | | - * |
| 13 | | - * This program is free software; you can redistribute it and/or |
| 14 | | - * modify it under the terms of the GNU General Public License |
| 15 | | - * as published by the Free Software Foundation; either version 2 |
| 16 | | - * of the License, or (at your option) any later version. |
| 17 | | - * |
| 18 | | - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 | | - * KIND, either express or implied. |
| 20 | | - * |
| 21 | | - ****************************************************************************/ |
| 22 | | - |
| | 2 | +/***************************************************************************
|
| | 3 | + * __________ __ ___.
|
| | 4 | + * Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
| | 5 | + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
| | 6 | + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
| | 7 | + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
| | 8 | + * \/ \/ \/ \/ \/
|
| | 9 | + * $Id$
|
| | 10 | + *
|
| | 11 | + * Copyright (C) 2006 by Thom Johansen
|
| | 12 | + *
|
| | 13 | + * This program is free software; you can redistribute it and/or
|
| | 14 | + * modify it under the terms of the GNU General Public License
|
| | 15 | + * as published by the Free Software Foundation; either version 2
|
| | 16 | + * of the License, or (at your option) any later version.
|
| | 17 | + *
|
| | 18 | + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
| | 19 | + * KIND, either express or implied.
|
| | 20 | + *
|
| | 21 | + ****************************************************************************/
|
| | 22 | +
|
| 23 | 23 | #define ASM_FILE
|
| 24 | 24 | #include "global.h"
|
| 25 | | - |
| 26 | | -/* ARMv4T doesn't switch the T bit when popping pc directly, we must use BX */ |
| 27 | | -.macro ldmpc cond="", order="ia", regs |
| 28 | | -#if ARM_ARCH == 4 && defined(USE_THUMB) |
| 29 | | - ldm\cond\order sp!, { \regs, lr } |
| 30 | | - bx\cond lr |
| 31 | | -#else |
| 32 | | - ldm\cond\order sp!, { \regs, pc } |
| 33 | | -#endif |
| 34 | | -.endm |
| 35 | | -.macro ldrpc cond="" |
| 36 | | -#if ARM_ARCH == 4 && defined(USE_THUMB) |
| 37 | | - ldr\cond lr, [sp], #4 |
| 38 | | - bx\cond lr |
| 39 | | -#else |
| 40 | | - ldr\cond pc, [sp], #4 |
| 41 | | -#endif |
| 42 | | -.endm |
| 43 | | - |
| 44 | | - .section .icode,"ax",%progbits |
| 45 | | - |
| 46 | | - .align 2 |
| 47 | | - |
| 48 | | -/* The following code is based on code found in Linux kernel version 2.6.15.3 |
| 49 | | - * linux/arch/arm/lib/memset.S |
| 50 | | - * |
| 51 | | - * Copyright (C) 1995-2000 Russell King |
| 52 | | - */ |
| 53 | | - |
| 54 | | -/* This code will align a pointer for memset, if needed */ |
| 55 | | -1: cmp r2, #4 @ 1 do we have enough |
| 56 | | - blt 5f @ 1 bytes to align with? |
| 57 | | - cmp r3, #2 @ 1 |
| 58 | | - strgtb r1, [r0, #-1]! @ 1 |
| 59 | | - strgeb r1, [r0, #-1]! @ 1 |
| 60 | | - strb r1, [r0, #-1]! @ 1 |
| 61 | | - sub r2, r2, r3 @ 1 r2 = r2 - r3 |
| 62 | | - b 2f |
| 63 | | - |
| 64 | | - .global memset |
| 65 | | - .type memset,%function |
| 66 | | -memset: |
| 67 | | - add r0, r0, r2 @ we'll write backwards in memory |
| 68 | | - ands r3, r0, #3 @ 1 unaligned? |
| 69 | | - bne 1b @ 1 |
| 70 | | -2: |
| 71 | | -/* |
| 72 | | - * we know that the pointer in r0 is aligned to a word boundary. |
| 73 | | - */ |
| 74 | | - orr r1, r1, r1, lsl #8 |
| 75 | | - orr r1, r1, r1, lsl #16 |
| 76 | | - mov r3, r1 |
| 77 | | - cmp r2, #16 |
| 78 | | - blt 5f |
| 79 | | -/* |
| 80 | | - * We need an extra register for this loop - save the return address and |
| 81 | | - * use the LR |
| 82 | | - */ |
| 83 | | - str lr, [sp, #-4]! |
| 84 | | - mov ip, r1 |
| 85 | | - mov lr, r1 |
| 86 | | - |
| 87 | | -3: subs r2, r2, #64 |
| 88 | | - stmgedb r0!, {r1, r3, ip, lr} @ 64 bytes at a time. |
| 89 | | - stmgedb r0!, {r1, r3, ip, lr} |
| 90 | | - stmgedb r0!, {r1, r3, ip, lr} |
| 91 | | - stmgedb r0!, {r1, r3, ip, lr} |
| 92 | | - bgt 3b |
| 93 | | - ldrpc cond=eq @ Now <64 bytes to go. |
| 94 | | -/* |
| 95 | | - * No need to correct the count; we're only testing bits from now on |
| 96 | | - */ |
| 97 | | - tst r2, #32 |
| 98 | | - stmnedb r0!, {r1, r3, ip, lr} |
| 99 | | - stmnedb r0!, {r1, r3, ip, lr} |
| 100 | | - tst r2, #16 |
| 101 | | - stmnedb r0!, {r1, r3, ip, lr} |
| 102 | | - ldr lr, [sp], #4 |
| 103 | | - |
| 104 | | -5: tst r2, #8 |
| 105 | | - stmnedb r0!, {r1, r3} |
| 106 | | - tst r2, #4 |
| 107 | | - strne r1, [r0, #-4]! |
| 108 | | -/* |
| 109 | | - * When we get here, we've got less than 4 bytes to zero. We |
| 110 | | - * may have an unaligned pointer as well. |
| 111 | | - */ |
| 112 | | -6: tst r2, #2 |
| 113 | | - strneb r1, [r0, #-1]! |
| 114 | | - strneb r1, [r0, #-1]! |
| 115 | | - tst r2, #1 |
| 116 | | - strneb r1, [r0, #-1]! |
| 117 | | - bx lr |
| 118 | | -.end: |
| 119 | | - .size memset,.end-memset |
| | 25 | +
|
| | 26 | +/* ARMv4T doesn't switch the T bit when popping pc directly, we must use BX */
|
| | 27 | +.macro ldmpc cond="", order="ia", regs
|
| | 28 | +#if ARM_ARCH == 4 && defined(USE_THUMB)
|
| | 29 | + ldm\cond\order sp!, { \regs, lr }
|
| | 30 | + bx\cond lr
|
| | 31 | +#else
|
| | 32 | + ldm\cond\order sp!, { \regs, pc }
|
| | 33 | +#endif
|
| | 34 | +.endm
|
| | 35 | +.macro ldrpc cond=""
|
| | 36 | +#if ARM_ARCH == 4 && defined(USE_THUMB)
|
| | 37 | + ldr\cond lr, [sp], #4
|
| | 38 | + bx\cond lr
|
| | 39 | +#else
|
| | 40 | + ldr\cond pc, [sp], #4
|
| | 41 | +#endif
|
| | 42 | +.endm
|
| | 43 | +
|
| | 44 | + .section .icode,"ax",%progbits
|
| | 45 | +
|
| | 46 | + .align 2
|
| | 47 | +
|
| | 48 | +/* The following code is based on code found in Linux kernel version 2.6.15.3
|
| | 49 | + * linux/arch/arm/lib/memset.S
|
| | 50 | + *
|
| | 51 | + * Copyright (C) 1995-2000 Russell King
|
| | 52 | + */
|
| | 53 | +
|
| | 54 | +/* This code will align a pointer for memset, if needed */
|
| | 55 | +1: cmp r2, #4 @ 1 do we have enough
|
| | 56 | + blt 5f @ 1 bytes to align with?
|
| | 57 | + cmp r3, #2 @ 1
|
| | 58 | + strgtb r1, [r0, #-1]! @ 1
|
| | 59 | + strgeb r1, [r0, #-1]! @ 1
|
| | 60 | + strb r1, [r0, #-1]! @ 1
|
| | 61 | + sub r2, r2, r3 @ 1 r2 = r2 - r3
|
| | 62 | + b 2f
|
| | 63 | +
|
| | 64 | + .global memset
|
| | 65 | + .type memset,%function
|
| | 66 | +memset:
|
| | 67 | + add r0, r0, r2 @ we'll write backwards in memory
|
| | 68 | + ands r3, r0, #3 @ 1 unaligned?
|
| | 69 | + bne 1b @ 1
|
| | 70 | +2:
|
| | 71 | +/*
|
| | 72 | + * we know that the pointer in r0 is aligned to a word boundary.
|
| | 73 | + */
|
| | 74 | + orr r1, r1, r1, lsl #8
|
| | 75 | + orr r1, r1, r1, lsl #16
|
| | 76 | + mov r3, r1
|
| | 77 | + cmp r2, #16
|
| | 78 | + blt 5f
|
| | 79 | +/*
|
| | 80 | + * We need an extra register for this loop - save the return address and
|
| | 81 | + * use the LR
|
| | 82 | + */
|
| | 83 | + str lr, [sp, #-4]!
|
| | 84 | + mov ip, r1
|
| | 85 | + mov lr, r1
|
| | 86 | +
|
| | 87 | +3: subs r2, r2, #64
|
| | 88 | + stmgedb r0!, {r1, r3, ip, lr} @ 64 bytes at a time.
|
| | 89 | + stmgedb r0!, {r1, r3, ip, lr}
|
| | 90 | + stmgedb r0!, {r1, r3, ip, lr}
|
| | 91 | + stmgedb r0!, {r1, r3, ip, lr}
|
| | 92 | + bgt 3b
|
| | 93 | + ldrpc cond=eq @ Now <64 bytes to go.
|
| | 94 | +/*
|
| | 95 | + * No need to correct the count; we're only testing bits from now on
|
| | 96 | + */
|
| | 97 | + tst r2, #32
|
| | 98 | + stmnedb r0!, {r1, r3, ip, lr}
|
| | 99 | + stmnedb r0!, {r1, r3, ip, lr}
|
| | 100 | + tst r2, #16
|
| | 101 | + stmnedb r0!, {r1, r3, ip, lr}
|
| | 102 | + ldr lr, [sp], #4
|
| | 103 | +
|
| | 104 | +5: tst r2, #8
|
| | 105 | + stmnedb r0!, {r1, r3}
|
| | 106 | + tst r2, #4
|
| | 107 | + strne r1, [r0, #-4]!
|
| | 108 | +/*
|
| | 109 | + * When we get here, we've got less than 4 bytes to zero. We
|
| | 110 | + * may have an unaligned pointer as well.
|
| | 111 | + */
|
| | 112 | +6: tst r2, #2
|
| | 113 | + strneb r1, [r0, #-1]!
|
| | 114 | + strneb r1, [r0, #-1]!
|
| | 115 | + tst r2, #1
|
| | 116 | + strneb r1, [r0, #-1]!
|
| | 117 | + bx lr
|
| | 118 | +.end:
|
| | 119 | + .size memset,.end-memset
|