Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/lib/io-writesw-armv4.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 | |
| 13 | .macro outword, rd |
| 14 | #ifndef __ARMEB__ |
| 15 | strh \rd, [r0] |
| 16 | mov \rd, \rd, lsr #16 |
| 17 | strh \rd, [r0] |
| 18 | #else |
| 19 | mov lr, \rd, lsr #16 |
| 20 | strh lr, [r0] |
| 21 | strh \rd, [r0] |
| 22 | #endif |
| 23 | .endm |
| 24 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 25 | .Loutsw_align: movs ip, r1, lsl #31 |
| 26 | bne .Loutsw_noalign |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | ldrh r3, [r1], #2 |
| 29 | sub r2, r2, #1 |
| 30 | strh r3, [r0] |
| 31 | |
| 32 | ENTRY(__raw_writesw) |
| 33 | teq r2, #0 |
| 34 | moveq pc, lr |
| 35 | ands r3, r1, #3 |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 36 | bne .Loutsw_align |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | stmfd sp!, {r4, r5, lr} |
| 39 | |
| 40 | subs r2, r2, #8 |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 41 | bmi .Lno_outsw_8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 43 | .Loutsw_8_lp: ldmia r1!, {r3, r4, r5, ip} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | subs r2, r2, #8 |
| 45 | outword r3 |
| 46 | outword r4 |
| 47 | outword r5 |
| 48 | outword ip |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 49 | bpl .Loutsw_8_lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 51 | .Lno_outsw_8: tst r2, #4 |
| 52 | beq .Lno_outsw_4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | ldmia r1!, {r3, ip} |
| 55 | outword r3 |
| 56 | outword ip |
| 57 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 58 | .Lno_outsw_4: movs r2, r2, lsl #31 |
| 59 | bcc .Lno_outsw_2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
| 61 | ldr r3, [r1], #4 |
| 62 | outword r3 |
| 63 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 64 | .Lno_outsw_2: ldrneh r3, [r1] |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | strneh r3, [r0] |
| 66 | |
| 67 | ldmfd sp!, {r4, r5, pc} |
| 68 | |
| 69 | #ifdef __ARMEB__ |
| 70 | #define pull_hbyte0 lsl #8 |
| 71 | #define push_hbyte1 lsr #24 |
| 72 | #else |
| 73 | #define pull_hbyte0 lsr #24 |
| 74 | #define push_hbyte1 lsl #8 |
| 75 | #endif |
| 76 | |
Nicolas Pitre | a9c4814 | 2005-11-11 21:51:48 +0000 | [diff] [blame] | 77 | .Loutsw_noalign: |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 78 | ARM( ldr r3, [r1, -r3]! ) |
| 79 | THUMB( rsb r3, r3, #0 ) |
| 80 | THUMB( ldr r3, [r1, r3] ) |
| 81 | THUMB( sub r1, r3 ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | subcs r2, r2, #1 |
| 83 | bcs 2f |
| 84 | subs r2, r2, #2 |
| 85 | bmi 3f |
| 86 | |
| 87 | 1: mov ip, r3, lsr #8 |
| 88 | strh ip, [r0] |
| 89 | 2: mov ip, r3, pull_hbyte0 |
| 90 | ldr r3, [r1, #4]! |
| 91 | subs r2, r2, #2 |
| 92 | orr ip, ip, r3, push_hbyte1 |
| 93 | strh ip, [r0] |
Nicolas Pitre | aeabbbb | 2005-06-08 19:00:16 +0100 | [diff] [blame] | 94 | bpl 1b |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
Nicolas Pitre | aeabbbb | 2005-06-08 19:00:16 +0100 | [diff] [blame] | 96 | tst r2, #1 |
| 97 | 3: movne ip, r3, lsr #8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | strneh ip, [r0] |
| 99 | mov pc, lr |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 100 | ENDPROC(__raw_writesw) |