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