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