Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/lib/io-writesb.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> |
Al Viro | 4dd1837 | 2016-01-13 13:46:22 -0500 | [diff] [blame] | 12 | #include <asm/export.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | .macro outword, rd |
| 15 | #ifndef __ARMEB__ |
| 16 | strb \rd, [r0] |
| 17 | mov \rd, \rd, lsr #8 |
| 18 | strb \rd, [r0] |
| 19 | mov \rd, \rd, lsr #8 |
| 20 | strb \rd, [r0] |
| 21 | mov \rd, \rd, lsr #8 |
| 22 | strb \rd, [r0] |
| 23 | #else |
| 24 | mov lr, \rd, lsr #24 |
| 25 | strb lr, [r0] |
| 26 | mov lr, \rd, lsr #16 |
| 27 | strb lr, [r0] |
| 28 | mov lr, \rd, lsr #8 |
| 29 | strb lr, [r0] |
| 30 | strb \rd, [r0] |
| 31 | #endif |
| 32 | .endm |
| 33 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 34 | .Loutsb_align: rsb ip, ip, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | cmp ip, r2 |
| 36 | movgt ip, r2 |
| 37 | cmp ip, #2 |
| 38 | ldrb r3, [r1], #1 |
| 39 | strb r3, [r0] |
| 40 | ldrgeb r3, [r1], #1 |
| 41 | strgeb r3, [r0] |
| 42 | ldrgtb r3, [r1], #1 |
| 43 | strgtb r3, [r0] |
| 44 | subs r2, r2, ip |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 45 | bne .Loutsb_aligned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | ENTRY(__raw_writesb) |
| 48 | teq r2, #0 @ do we have to check for the zero len? |
Russell King | 6ebbf2c | 2014-06-30 16:29:12 +0100 | [diff] [blame] | 49 | reteq lr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | ands ip, r1, #3 |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 51 | bne .Loutsb_align |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 53 | .Loutsb_aligned: |
| 54 | stmfd sp!, {r4, r5, lr} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | subs r2, r2, #16 |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 57 | bmi .Loutsb_no_16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 59 | .Loutsb_16_lp: ldmia r1!, {r3, r4, r5, ip} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | outword r3 |
| 61 | outword r4 |
| 62 | outword r5 |
| 63 | outword ip |
| 64 | subs r2, r2, #16 |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 65 | bpl .Loutsb_16_lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | tst r2, #15 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 68 | ldmeqfd sp!, {r4, r5, pc} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 70 | .Loutsb_no_16: tst r2, #8 |
| 71 | beq .Loutsb_no_8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | ldmia r1!, {r3, r4} |
| 74 | outword r3 |
| 75 | outword r4 |
| 76 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 77 | .Loutsb_no_8: tst r2, #4 |
| 78 | beq .Loutsb_no_4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
| 80 | ldr r3, [r1], #4 |
| 81 | outword r3 |
| 82 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 83 | .Loutsb_no_4: ands r2, r2, #3 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 84 | ldmeqfd sp!, {r4, r5, pc} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | cmp r2, #2 |
| 87 | ldrb r3, [r1], #1 |
| 88 | strb r3, [r0] |
| 89 | ldrgeb r3, [r1], #1 |
| 90 | strgeb r3, [r0] |
| 91 | ldrgtb r3, [r1] |
| 92 | strgtb r3, [r0] |
| 93 | |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 94 | ldmfd sp!, {r4, r5, pc} |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 95 | ENDPROC(__raw_writesb) |
Al Viro | 4dd1837 | 2016-01-13 13:46:22 -0500 | [diff] [blame] | 96 | EXPORT_SYMBOL(__raw_writesb) |