Subversion Repositories freemyipod

Rev

Rev 286 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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