Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* bzero.S: Simple prefetching memset, bzero, and clear_user |
| 2 | * implementations. |
| 3 | * |
| 4 | * Copyright (C) 2005 David S. Miller <davem@davemloft.net> |
| 5 | */ |
| 6 | |
| 7 | .text |
| 8 | |
| 9 | .globl __memset |
| 10 | .type __memset, #function |
| 11 | __memset: /* %o0=buf, %o1=pat, %o2=len */ |
| 12 | |
| 13 | .globl memset |
| 14 | .type memset, #function |
| 15 | memset: /* %o0=buf, %o1=pat, %o2=len */ |
| 16 | and %o1, 0xff, %o3 |
| 17 | mov %o2, %o1 |
| 18 | sllx %o3, 8, %g1 |
| 19 | or %g1, %o3, %o2 |
| 20 | sllx %o2, 16, %g1 |
| 21 | or %g1, %o2, %o2 |
| 22 | sllx %o2, 32, %g1 |
| 23 | ba,pt %xcc, 1f |
| 24 | or %g1, %o2, %o2 |
| 25 | |
| 26 | .globl __bzero |
| 27 | .type __bzero, #function |
| 28 | __bzero: /* %o0=buf, %o1=len */ |
| 29 | clr %o2 |
| 30 | 1: mov %o0, %o3 |
| 31 | brz,pn %o1, __bzero_done |
| 32 | cmp %o1, 16 |
| 33 | bl,pn %icc, __bzero_tiny |
| 34 | prefetch [%o0 + 0x000], #n_writes |
| 35 | andcc %o0, 0x3, %g0 |
| 36 | be,pt %icc, 2f |
| 37 | 1: stb %o2, [%o0 + 0x00] |
| 38 | add %o0, 1, %o0 |
| 39 | andcc %o0, 0x3, %g0 |
| 40 | bne,pn %icc, 1b |
| 41 | sub %o1, 1, %o1 |
| 42 | 2: andcc %o0, 0x7, %g0 |
| 43 | be,pt %icc, 3f |
| 44 | stw %o2, [%o0 + 0x00] |
| 45 | sub %o1, 4, %o1 |
| 46 | add %o0, 4, %o0 |
| 47 | 3: and %o1, 0x38, %g1 |
| 48 | cmp %o1, 0x40 |
| 49 | andn %o1, 0x3f, %o4 |
| 50 | bl,pn %icc, 5f |
| 51 | and %o1, 0x7, %o1 |
| 52 | prefetch [%o0 + 0x040], #n_writes |
| 53 | prefetch [%o0 + 0x080], #n_writes |
| 54 | prefetch [%o0 + 0x0c0], #n_writes |
| 55 | prefetch [%o0 + 0x100], #n_writes |
| 56 | prefetch [%o0 + 0x140], #n_writes |
| 57 | 4: prefetch [%o0 + 0x180], #n_writes |
| 58 | stx %o2, [%o0 + 0x00] |
| 59 | stx %o2, [%o0 + 0x08] |
| 60 | stx %o2, [%o0 + 0x10] |
| 61 | stx %o2, [%o0 + 0x18] |
| 62 | stx %o2, [%o0 + 0x20] |
| 63 | stx %o2, [%o0 + 0x28] |
| 64 | stx %o2, [%o0 + 0x30] |
| 65 | stx %o2, [%o0 + 0x38] |
| 66 | subcc %o4, 0x40, %o4 |
| 67 | bne,pt %icc, 4b |
| 68 | add %o0, 0x40, %o0 |
| 69 | brz,pn %g1, 6f |
| 70 | nop |
| 71 | 5: stx %o2, [%o0 + 0x00] |
| 72 | subcc %g1, 8, %g1 |
| 73 | bne,pt %icc, 5b |
| 74 | add %o0, 0x8, %o0 |
| 75 | 6: brz,pt %o1, __bzero_done |
| 76 | nop |
| 77 | __bzero_tiny: |
| 78 | 1: stb %o2, [%o0 + 0x00] |
| 79 | subcc %o1, 1, %o1 |
| 80 | bne,pt %icc, 1b |
| 81 | add %o0, 1, %o0 |
| 82 | __bzero_done: |
| 83 | retl |
| 84 | mov %o3, %o0 |
| 85 | .size __bzero, .-__bzero |
| 86 | .size __memset, .-__memset |
| 87 | .size memset, .-memset |
| 88 | |
| 89 | #define EX_ST(x,y) \ |
| 90 | 98: x,y; \ |
David S. Miller | 4d000d5 | 2006-03-04 23:23:56 -0800 | [diff] [blame] | 91 | .section __ex_table,"a";\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | .align 4; \ |
David S. Miller | 40bdac7 | 2009-02-08 22:00:55 -0800 | [diff] [blame] | 93 | .word 98b, __retl_o1; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | .text; \ |
| 95 | .align 4; |
| 96 | |
David S. Miller | c857e3f | 2006-02-17 10:35:23 -0800 | [diff] [blame] | 97 | .globl __clear_user |
| 98 | .type __clear_user, #function |
| 99 | __clear_user: /* %o0=buf, %o1=len */ |
| 100 | brz,pn %o1, __clear_user_done |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | cmp %o1, 16 |
David S. Miller | c857e3f | 2006-02-17 10:35:23 -0800 | [diff] [blame] | 102 | bl,pn %icc, __clear_user_tiny |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | EX_ST(prefetcha [%o0 + 0x00] %asi, #n_writes) |
| 104 | andcc %o0, 0x3, %g0 |
| 105 | be,pt %icc, 2f |
| 106 | 1: EX_ST(stba %g0, [%o0 + 0x00] %asi) |
| 107 | add %o0, 1, %o0 |
| 108 | andcc %o0, 0x3, %g0 |
| 109 | bne,pn %icc, 1b |
| 110 | sub %o1, 1, %o1 |
| 111 | 2: andcc %o0, 0x7, %g0 |
| 112 | be,pt %icc, 3f |
| 113 | EX_ST(stwa %g0, [%o0 + 0x00] %asi) |
| 114 | sub %o1, 4, %o1 |
| 115 | add %o0, 4, %o0 |
| 116 | 3: and %o1, 0x38, %g1 |
| 117 | cmp %o1, 0x40 |
| 118 | andn %o1, 0x3f, %o4 |
| 119 | bl,pn %icc, 5f |
| 120 | and %o1, 0x7, %o1 |
| 121 | EX_ST(prefetcha [%o0 + 0x040] %asi, #n_writes) |
| 122 | EX_ST(prefetcha [%o0 + 0x080] %asi, #n_writes) |
| 123 | EX_ST(prefetcha [%o0 + 0x0c0] %asi, #n_writes) |
| 124 | EX_ST(prefetcha [%o0 + 0x100] %asi, #n_writes) |
| 125 | EX_ST(prefetcha [%o0 + 0x140] %asi, #n_writes) |
| 126 | 4: EX_ST(prefetcha [%o0 + 0x180] %asi, #n_writes) |
| 127 | EX_ST(stxa %g0, [%o0 + 0x00] %asi) |
| 128 | EX_ST(stxa %g0, [%o0 + 0x08] %asi) |
| 129 | EX_ST(stxa %g0, [%o0 + 0x10] %asi) |
| 130 | EX_ST(stxa %g0, [%o0 + 0x18] %asi) |
| 131 | EX_ST(stxa %g0, [%o0 + 0x20] %asi) |
| 132 | EX_ST(stxa %g0, [%o0 + 0x28] %asi) |
| 133 | EX_ST(stxa %g0, [%o0 + 0x30] %asi) |
| 134 | EX_ST(stxa %g0, [%o0 + 0x38] %asi) |
| 135 | subcc %o4, 0x40, %o4 |
| 136 | bne,pt %icc, 4b |
| 137 | add %o0, 0x40, %o0 |
| 138 | brz,pn %g1, 6f |
| 139 | nop |
| 140 | 5: EX_ST(stxa %g0, [%o0 + 0x00] %asi) |
| 141 | subcc %g1, 8, %g1 |
| 142 | bne,pt %icc, 5b |
| 143 | add %o0, 0x8, %o0 |
David S. Miller | c857e3f | 2006-02-17 10:35:23 -0800 | [diff] [blame] | 144 | 6: brz,pt %o1, __clear_user_done |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | nop |
David S. Miller | c857e3f | 2006-02-17 10:35:23 -0800 | [diff] [blame] | 146 | __clear_user_tiny: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | 1: EX_ST(stba %g0, [%o0 + 0x00] %asi) |
| 148 | subcc %o1, 1, %o1 |
| 149 | bne,pt %icc, 1b |
| 150 | add %o0, 1, %o0 |
David S. Miller | c857e3f | 2006-02-17 10:35:23 -0800 | [diff] [blame] | 151 | __clear_user_done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | retl |
| 153 | clr %o0 |
David S. Miller | c857e3f | 2006-02-17 10:35:23 -0800 | [diff] [blame] | 154 | .size __clear_user, .-__clear_user |