Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/lib/io-readsb.S |
| 3 | * |
| 4 | * Copyright (C) 1995-2000 Russell King |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | #include <linux/linkage.h> |
| 11 | #include <asm/assembler.h> |
| 12 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 13 | .Linsb_align: rsb ip, ip, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | cmp ip, r2 |
| 15 | movgt ip, r2 |
| 16 | cmp ip, #2 |
| 17 | ldrb r3, [r0] |
| 18 | strb r3, [r1], #1 |
| 19 | ldrgeb r3, [r0] |
| 20 | strgeb r3, [r1], #1 |
| 21 | ldrgtb r3, [r0] |
| 22 | strgtb r3, [r1], #1 |
| 23 | subs r2, r2, ip |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 24 | bne .Linsb_aligned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | ENTRY(__raw_readsb) |
| 27 | teq r2, #0 @ do we have to check for the zero len? |
| 28 | moveq pc, lr |
| 29 | ands ip, r1, #3 |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 30 | bne .Linsb_align |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 32 | .Linsb_aligned: stmfd sp!, {r4 - r6, lr} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
| 34 | subs r2, r2, #16 |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 35 | bmi .Linsb_no_16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 37 | .Linsb_16_lp: ldrb r3, [r0] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | ldrb r4, [r0] |
| 39 | ldrb r5, [r0] |
| 40 | mov r3, r3, put_byte_0 |
| 41 | ldrb r6, [r0] |
| 42 | orr r3, r3, r4, put_byte_1 |
| 43 | ldrb r4, [r0] |
| 44 | orr r3, r3, r5, put_byte_2 |
| 45 | ldrb r5, [r0] |
| 46 | orr r3, r3, r6, put_byte_3 |
| 47 | ldrb r6, [r0] |
| 48 | mov r4, r4, put_byte_0 |
| 49 | ldrb ip, [r0] |
| 50 | orr r4, r4, r5, put_byte_1 |
| 51 | ldrb r5, [r0] |
| 52 | orr r4, r4, r6, put_byte_2 |
| 53 | ldrb r6, [r0] |
| 54 | orr r4, r4, ip, put_byte_3 |
| 55 | ldrb ip, [r0] |
| 56 | mov r5, r5, put_byte_0 |
| 57 | ldrb lr, [r0] |
| 58 | orr r5, r5, r6, put_byte_1 |
| 59 | ldrb r6, [r0] |
| 60 | orr r5, r5, ip, put_byte_2 |
| 61 | ldrb ip, [r0] |
| 62 | orr r5, r5, lr, put_byte_3 |
| 63 | ldrb lr, [r0] |
| 64 | mov r6, r6, put_byte_0 |
| 65 | orr r6, r6, ip, put_byte_1 |
| 66 | ldrb ip, [r0] |
| 67 | orr r6, r6, lr, put_byte_2 |
| 68 | orr r6, r6, ip, put_byte_3 |
| 69 | stmia r1!, {r3 - r6} |
| 70 | |
| 71 | subs r2, r2, #16 |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 72 | bpl .Linsb_16_lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | tst r2, #15 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 75 | ldmeqfd sp!, {r4 - r6, pc} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 77 | .Linsb_no_16: tst r2, #8 |
| 78 | beq .Linsb_no_8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
| 80 | ldrb r3, [r0] |
| 81 | ldrb r4, [r0] |
| 82 | ldrb r5, [r0] |
| 83 | mov r3, r3, put_byte_0 |
| 84 | ldrb r6, [r0] |
| 85 | orr r3, r3, r4, put_byte_1 |
| 86 | ldrb r4, [r0] |
| 87 | orr r3, r3, r5, put_byte_2 |
| 88 | ldrb r5, [r0] |
| 89 | orr r3, r3, r6, put_byte_3 |
| 90 | ldrb r6, [r0] |
| 91 | mov r4, r4, put_byte_0 |
| 92 | ldrb ip, [r0] |
| 93 | orr r4, r4, r5, put_byte_1 |
| 94 | orr r4, r4, r6, put_byte_2 |
| 95 | orr r4, r4, ip, put_byte_3 |
| 96 | stmia r1!, {r3, r4} |
| 97 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 98 | .Linsb_no_8: tst r2, #4 |
| 99 | beq .Linsb_no_4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
| 101 | ldrb r3, [r0] |
| 102 | ldrb r4, [r0] |
| 103 | ldrb r5, [r0] |
| 104 | ldrb r6, [r0] |
| 105 | mov r3, r3, put_byte_0 |
| 106 | orr r3, r3, r4, put_byte_1 |
| 107 | orr r3, r3, r5, put_byte_2 |
| 108 | orr r3, r3, r6, put_byte_3 |
| 109 | str r3, [r1], #4 |
| 110 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 111 | .Linsb_no_4: ands r2, r2, #3 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 112 | ldmeqfd sp!, {r4 - r6, pc} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | cmp r2, #2 |
| 115 | ldrb r3, [r0] |
| 116 | strb r3, [r1], #1 |
| 117 | ldrgeb r3, [r0] |
| 118 | strgeb r3, [r1], #1 |
| 119 | ldrgtb r3, [r0] |
| 120 | strgtb r3, [r1] |
| 121 | |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 122 | ldmfd sp!, {r4 - r6, pc} |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame^] | 123 | ENDPROC(__raw_readsb) |