~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/alpha/lib/stxncpy.S

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/alpha/lib/stxncpy.S (Version linux-6.11.5) and /arch/alpha/lib/stxncpy.S (Version linux-2.4.37.11)


  1 /* SPDX-License-Identifier: GPL-2.0 */         << 
  2 /*                                                  1 /*
  3  * arch/alpha/lib/stxncpy.S                         2  * arch/alpha/lib/stxncpy.S
  4  * Contributed by Richard Henderson (rth@tamu.      3  * Contributed by Richard Henderson (rth@tamu.edu)
  5  *                                                  4  *
  6  * Copy no more than COUNT bytes of the null-t      5  * Copy no more than COUNT bytes of the null-terminated string from
  7  * SRC to DST.                                      6  * SRC to DST.
  8  *                                                  7  *
  9  * This is an internal routine used by strncpy      8  * This is an internal routine used by strncpy, stpncpy, and strncat.
 10  * As such, it uses special linkage convention      9  * As such, it uses special linkage conventions to make implementation
 11  * of these public functions more efficient.       10  * of these public functions more efficient.
 12  *                                                 11  *
 13  * On input:                                       12  * On input:
 14  *      t9 = return address                        13  *      t9 = return address
 15  *      a0 = DST                                   14  *      a0 = DST
 16  *      a1 = SRC                                   15  *      a1 = SRC
 17  *      a2 = COUNT                                 16  *      a2 = COUNT
 18  *                                                 17  *
 19  * Furthermore, COUNT may not be zero.             18  * Furthermore, COUNT may not be zero.
 20  *                                                 19  *
 21  * On output:                                      20  * On output:
 22  *      t0  = last word written                    21  *      t0  = last word written
 23  *      t10 = bitmask (with one bit set) indic     22  *      t10 = bitmask (with one bit set) indicating the byte position of
 24  *            the end of the range specified b     23  *            the end of the range specified by COUNT
 25  *      t12 = bitmask (with one bit set) indic     24  *      t12 = bitmask (with one bit set) indicating the last byte written
 26  *      a0  = unaligned address of the last *w     25  *      a0  = unaligned address of the last *word* written
 27  *      a2  = the number of full words left in     26  *      a2  = the number of full words left in COUNT
 28  *                                                 27  *
 29  * Furthermore, v0, a3-a5, t11, and $at are un     28  * Furthermore, v0, a3-a5, t11, and $at are untouched.
 30  */                                                29  */
 31                                                    30 
 32 #include <asm/regdef.h>                            31 #include <asm/regdef.h>
 33                                                    32 
 34         .set noat                                  33         .set noat
 35         .set noreorder                             34         .set noreorder
 36                                                    35 
 37         .text                                      36         .text
 38                                                    37 
 39 /* There is a problem with either gdb (as of 4     38 /* There is a problem with either gdb (as of 4.16) or gas (as of 2.7) that
 40    doesn't like putting the entry point for a      39    doesn't like putting the entry point for a procedure somewhere in the
 41    middle of the procedure descriptor.  Work a     40    middle of the procedure descriptor.  Work around this by putting the
 42    aligned copy in its own procedure descripto     41    aligned copy in its own procedure descriptor */
 43                                                    42 
 44         .ent stxncpy_aligned                       43         .ent stxncpy_aligned
 45         .align 3                                   44         .align 3
 46 stxncpy_aligned:                                   45 stxncpy_aligned:
 47         .frame sp, 0, t9, 0                        46         .frame sp, 0, t9, 0
 48         .prologue 0                                47         .prologue 0
 49                                                    48 
 50         /* On entry to this basic block:           49         /* On entry to this basic block:
 51            t0 == the first destination word fo     50            t0 == the first destination word for masking back in
 52            t1 == the first source word.  */        51            t1 == the first source word.  */
 53                                                    52 
 54         /* Create the 1st output word and dete     53         /* Create the 1st output word and detect 0's in the 1st input word.  */
 55         lda     t2, -1          # e1    : buil     54         lda     t2, -1          # e1    : build a mask against false zero
 56         mskqh   t2, a1, t2      # e0    :   de     55         mskqh   t2, a1, t2      # e0    :   detection in the src word
 57         mskqh   t1, a1, t3      # e0    :          56         mskqh   t1, a1, t3      # e0    :
 58         ornot   t1, t2, t2      # .. e1 :          57         ornot   t1, t2, t2      # .. e1 :
 59         mskql   t0, a1, t0      # e0    : asse     58         mskql   t0, a1, t0      # e0    : assemble the first output word
 60         cmpbge  zero, t2, t8    # .. e1 : bits     59         cmpbge  zero, t2, t8    # .. e1 : bits set iff null found
 61         or      t0, t3, t0      # e0    :          60         or      t0, t3, t0      # e0    :
 62         beq     a2, $a_eoc      # .. e1 :          61         beq     a2, $a_eoc      # .. e1 :
 63         bne     t8, $a_eos      # .. e1 :          62         bne     t8, $a_eos      # .. e1 :
 64                                                    63 
 65         /* On entry to this basic block:           64         /* On entry to this basic block:
 66            t0 == a source word not containing      65            t0 == a source word not containing a null.  */
 67                                                    66 
 68 $a_loop:                                           67 $a_loop:
 69         stq_u   t0, 0(a0)       # e0    :          68         stq_u   t0, 0(a0)       # e0    :
 70         addq    a0, 8, a0       # .. e1 :          69         addq    a0, 8, a0       # .. e1 :
 71         ldq_u   t0, 0(a1)       # e0    :          70         ldq_u   t0, 0(a1)       # e0    :
 72         addq    a1, 8, a1       # .. e1 :          71         addq    a1, 8, a1       # .. e1 :
 73         subq    a2, 1, a2       # e0    :          72         subq    a2, 1, a2       # e0    :
 74         cmpbge  zero, t0, t8    # .. e1 (stall     73         cmpbge  zero, t0, t8    # .. e1 (stall)
 75         beq     a2, $a_eoc      # e1    :          74         beq     a2, $a_eoc      # e1    :
 76         beq     t8, $a_loop     # e1    :          75         beq     t8, $a_loop     # e1    :
 77                                                    76 
 78         /* Take care of the final (partial) wo     77         /* Take care of the final (partial) word store.  At this point
 79            the end-of-count bit is set in t8 i     78            the end-of-count bit is set in t8 iff it applies.
 80                                                    79 
 81            On entry to this basic block we hav     80            On entry to this basic block we have:
 82            t0 == the source word containing th     81            t0 == the source word containing the null
 83            t8 == the cmpbge mask that found it     82            t8 == the cmpbge mask that found it.  */
 84                                                    83 
 85 $a_eos:                                            84 $a_eos:
 86         negq    t8, t12         # e0    : find     85         negq    t8, t12         # e0    : find low bit set
 87         and     t8, t12, t12    # e1 (stall)       86         and     t8, t12, t12    # e1 (stall)
 88                                                    87 
 89         /* For the sake of the cache, don't re     88         /* For the sake of the cache, don't read a destination word
 90            if we're not going to need it.  */      89            if we're not going to need it.  */
 91         and     t12, 0x80, t6   # e0    :          90         and     t12, 0x80, t6   # e0    :
 92         bne     t6, 1f          # .. e1 (zdb)      91         bne     t6, 1f          # .. e1 (zdb)
 93                                                    92 
 94         /* We're doing a partial word store an     93         /* We're doing a partial word store and so need to combine
 95            our source and original destination     94            our source and original destination words.  */
 96         ldq_u   t1, 0(a0)       # e0    :          95         ldq_u   t1, 0(a0)       # e0    :
 97         subq    t12, 1, t6      # .. e1 :          96         subq    t12, 1, t6      # .. e1 :
 98         or      t12, t6, t8     # e0    :          97         or      t12, t6, t8     # e0    :
 99         unop                    #                  98         unop                    #
100         zapnot  t0, t8, t0      # e0    : clea     99         zapnot  t0, t8, t0      # e0    : clear src bytes > null
101         zap     t1, t8, t1      # .. e1 : clea    100         zap     t1, t8, t1      # .. e1 : clear dst bytes <= null
102         or      t0, t1, t0      # e1    :         101         or      t0, t1, t0      # e1    :
103                                                   102 
104 1:      stq_u   t0, 0(a0)       # e0    :         103 1:      stq_u   t0, 0(a0)       # e0    :
105         ret     (t9)            # e1    :         104         ret     (t9)            # e1    :
106                                                   105 
107         /* Add the end-of-count bit to the eos    106         /* Add the end-of-count bit to the eos detection bitmask.  */
108 $a_eoc:                                           107 $a_eoc:
109         or      t10, t8, t8                       108         or      t10, t8, t8
110         br      $a_eos                            109         br      $a_eos
111                                                   110 
112         .end stxncpy_aligned                      111         .end stxncpy_aligned
113                                                   112 
114         .align 3                                  113         .align 3
115         .ent __stxncpy                            114         .ent __stxncpy
116         .globl __stxncpy                          115         .globl __stxncpy
117 __stxncpy:                                        116 __stxncpy:
118         .frame sp, 0, t9, 0                       117         .frame sp, 0, t9, 0
119         .prologue 0                               118         .prologue 0
120                                                   119 
121         /* Are source and destination co-align    120         /* Are source and destination co-aligned?  */
122         xor     a0, a1, t1      # e0    :         121         xor     a0, a1, t1      # e0    :
123         and     a0, 7, t0       # .. e1 : find    122         and     a0, 7, t0       # .. e1 : find dest misalignment
124         and     t1, 7, t1       # e0    :         123         and     t1, 7, t1       # e0    :
125         addq    a2, t0, a2      # .. e1 : bias    124         addq    a2, t0, a2      # .. e1 : bias count by dest misalignment
126         subq    a2, 1, a2       # e0    :         125         subq    a2, 1, a2       # e0    :
127         and     a2, 7, t2       # e1    :         126         and     a2, 7, t2       # e1    :
128         srl     a2, 3, a2       # e0    : a2 =    127         srl     a2, 3, a2       # e0    : a2 = loop counter = (count - 1)/8
129         addq    zero, 1, t10    # .. e1 :         128         addq    zero, 1, t10    # .. e1 :
130         sll     t10, t2, t10    # e0    : t10     129         sll     t10, t2, t10    # e0    : t10 = bitmask of last count byte
131         bne     t1, $unaligned  # .. e1 :         130         bne     t1, $unaligned  # .. e1 :
132                                                   131 
133         /* We are co-aligned; take care of a p    132         /* We are co-aligned; take care of a partial first word.  */
134                                                   133 
135         ldq_u   t1, 0(a1)       # e0    : load    134         ldq_u   t1, 0(a1)       # e0    : load first src word
136         addq    a1, 8, a1       # .. e1 :         135         addq    a1, 8, a1       # .. e1 :
137                                                   136 
138         beq     t0, stxncpy_aligned     # avoi    137         beq     t0, stxncpy_aligned     # avoid loading dest word if not needed
139         ldq_u   t0, 0(a0)       # e0    :         138         ldq_u   t0, 0(a0)       # e0    :
140         br      stxncpy_aligned # .. e1 :         139         br      stxncpy_aligned # .. e1 :
141                                                   140 
142                                                   141 
143 /* The source and destination are not co-align    142 /* The source and destination are not co-aligned.  Align the destination
144    and cope.  We have to be very careful about    143    and cope.  We have to be very careful about not reading too much and
145    causing a SEGV.  */                            144    causing a SEGV.  */
146                                                   145 
147         .align 3                                  146         .align 3
148 $u_head:                                          147 $u_head:
149         /* We know just enough now to be able     148         /* We know just enough now to be able to assemble the first
150            full source word.  We can still fin    149            full source word.  We can still find a zero at the end of it
151            that prevents us from outputting th    150            that prevents us from outputting the whole thing.
152                                                   151 
153            On entry to this basic block:          152            On entry to this basic block:
154            t0 == the first dest word, unmasked    153            t0 == the first dest word, unmasked
155            t1 == the shifted low bits of the f    154            t1 == the shifted low bits of the first source word
156            t6 == bytemask that is -1 in dest w    155            t6 == bytemask that is -1 in dest word bytes */
157                                                   156 
158         ldq_u   t2, 8(a1)       # e0    : load    157         ldq_u   t2, 8(a1)       # e0    : load second src word
159         addq    a1, 8, a1       # .. e1 :         158         addq    a1, 8, a1       # .. e1 :
160         mskql   t0, a0, t0      # e0    : mask    159         mskql   t0, a0, t0      # e0    : mask trailing garbage in dst
161         extqh   t2, a1, t4      # e0    :         160         extqh   t2, a1, t4      # e0    :
162         or      t1, t4, t1      # e1    : firs    161         or      t1, t4, t1      # e1    : first aligned src word complete
163         mskqh   t1, a0, t1      # e0    : mask    162         mskqh   t1, a0, t1      # e0    : mask leading garbage in src
164         or      t0, t1, t0      # e0    : firs    163         or      t0, t1, t0      # e0    : first output word complete
165         or      t0, t6, t6      # e1    : mask    164         or      t0, t6, t6      # e1    : mask original data for zero test
166         cmpbge  zero, t6, t8    # e0    :         165         cmpbge  zero, t6, t8    # e0    :
167         beq     a2, $u_eocfin   # .. e1 :         166         beq     a2, $u_eocfin   # .. e1 :
168         lda     t6, -1          # e0    :         167         lda     t6, -1          # e0    :
169         bne     t8, $u_final    # .. e1 :         168         bne     t8, $u_final    # .. e1 :
170                                                   169 
171         mskql   t6, a1, t6      # e0    : mask    170         mskql   t6, a1, t6      # e0    : mask out bits already seen
172         nop                     # .. e1 :         171         nop                     # .. e1 :
173         stq_u   t0, 0(a0)       # e0    : stor    172         stq_u   t0, 0(a0)       # e0    : store first output word
174         or      t6, t2, t2      # .. e1 :         173         or      t6, t2, t2      # .. e1 :
175         cmpbge  zero, t2, t8    # e0    : find    174         cmpbge  zero, t2, t8    # e0    : find nulls in second partial
176         addq    a0, 8, a0       # .. e1 :         175         addq    a0, 8, a0       # .. e1 :
177         subq    a2, 1, a2       # e0    :         176         subq    a2, 1, a2       # e0    :
178         bne     t8, $u_late_head_exit   # .. e    177         bne     t8, $u_late_head_exit   # .. e1 :
179                                                   178 
180         /* Finally, we've got all the stupid l    179         /* Finally, we've got all the stupid leading edge cases taken care
181            of and we can set up to enter the m    180            of and we can set up to enter the main loop.  */
182                                                   181 
183         extql   t2, a1, t1      # e0    : posi    182         extql   t2, a1, t1      # e0    : position hi-bits of lo word
184         beq     a2, $u_eoc      # .. e1 :         183         beq     a2, $u_eoc      # .. e1 :
185         ldq_u   t2, 8(a1)       # e0    : read    184         ldq_u   t2, 8(a1)       # e0    : read next high-order source word
186         addq    a1, 8, a1       # .. e1 :         185         addq    a1, 8, a1       # .. e1 :
187         extqh   t2, a1, t0      # e0    : posi    186         extqh   t2, a1, t0      # e0    : position lo-bits of hi word (stall)
188         cmpbge  zero, t2, t8    # .. e1 :         187         cmpbge  zero, t2, t8    # .. e1 :
189         nop                     # e0    :         188         nop                     # e0    :
190         bne     t8, $u_eos      # .. e1 :         189         bne     t8, $u_eos      # .. e1 :
191                                                   190 
192         /* Unaligned copy main loop.  In order    191         /* Unaligned copy main loop.  In order to avoid reading too much,
193            the loop is structured to detect ze    192            the loop is structured to detect zeros in aligned source words.
194            This has, unfortunately, effectivel    193            This has, unfortunately, effectively pulled half of a loop
195            iteration out into the head and hal    194            iteration out into the head and half into the tail, but it does
196            prevent nastiness from accumulating    195            prevent nastiness from accumulating in the very thing we want
197            to run as fast as possible.            196            to run as fast as possible.
198                                                   197 
199            On entry to this basic block:          198            On entry to this basic block:
200            t0 == the shifted low-order bits fr    199            t0 == the shifted low-order bits from the current source word
201            t1 == the shifted high-order bits f    200            t1 == the shifted high-order bits from the previous source word
202            t2 == the unshifted current source     201            t2 == the unshifted current source word
203                                                   202 
204            We further know that t2 does not co    203            We further know that t2 does not contain a null terminator.  */
205                                                   204 
206         .align 3                                  205         .align 3
207 $u_loop:                                          206 $u_loop:
208         or      t0, t1, t0      # e0    : curr    207         or      t0, t1, t0      # e0    : current dst word now complete
209         subq    a2, 1, a2       # .. e1 : decr    208         subq    a2, 1, a2       # .. e1 : decrement word count
210         stq_u   t0, 0(a0)       # e0    : save    209         stq_u   t0, 0(a0)       # e0    : save the current word
211         addq    a0, 8, a0       # .. e1 :         210         addq    a0, 8, a0       # .. e1 :
212         extql   t2, a1, t1      # e0    : extr    211         extql   t2, a1, t1      # e0    : extract high bits for next time
213         beq     a2, $u_eoc      # .. e1 :         212         beq     a2, $u_eoc      # .. e1 :
214         ldq_u   t2, 8(a1)       # e0    : load    213         ldq_u   t2, 8(a1)       # e0    : load high word for next time
215         addq    a1, 8, a1       # .. e1 :         214         addq    a1, 8, a1       # .. e1 :
216         nop                     # e0    :         215         nop                     # e0    :
217         cmpbge  zero, t2, t8    # e1    : test    216         cmpbge  zero, t2, t8    # e1    : test new word for eos (stall)
218         extqh   t2, a1, t0      # e0    : extr    217         extqh   t2, a1, t0      # e0    : extract low bits for current word
219         beq     t8, $u_loop     # .. e1 :         218         beq     t8, $u_loop     # .. e1 :
220                                                   219 
221         /* We've found a zero somewhere in the    220         /* We've found a zero somewhere in the source word we just read.
222            If it resides in the lower half, we    221            If it resides in the lower half, we have one (probably partial)
223            word to write out, and if it reside    222            word to write out, and if it resides in the upper half, we
224            have one full and one partial word     223            have one full and one partial word left to write out.
225                                                   224 
226            On entry to this basic block:          225            On entry to this basic block:
227            t0 == the shifted low-order bits fr    226            t0 == the shifted low-order bits from the current source word
228            t1 == the shifted high-order bits f    227            t1 == the shifted high-order bits from the previous source word
229            t2 == the unshifted current source     228            t2 == the unshifted current source word.  */
230 $u_eos:                                           229 $u_eos:
231         or      t0, t1, t0      # e0    : firs    230         or      t0, t1, t0      # e0    : first (partial) source word complete
232         nop                     # .. e1 :         231         nop                     # .. e1 :
233         cmpbge  zero, t0, t8    # e0    : is t    232         cmpbge  zero, t0, t8    # e0    : is the null in this first bit?
234         bne     t8, $u_final    # .. e1 (zdb)     233         bne     t8, $u_final    # .. e1 (zdb)
235                                                   234 
236         stq_u   t0, 0(a0)       # e0    : the     235         stq_u   t0, 0(a0)       # e0    : the null was in the high-order bits
237         addq    a0, 8, a0       # .. e1 :         236         addq    a0, 8, a0       # .. e1 :
238         subq    a2, 1, a2       # e1    :         237         subq    a2, 1, a2       # e1    :
239                                                   238 
240 $u_late_head_exit:                                239 $u_late_head_exit:
241         extql   t2, a1, t0      # .. e0 :         240         extql   t2, a1, t0      # .. e0 :
242         cmpbge  zero, t0, t8    # e0    :         241         cmpbge  zero, t0, t8    # e0    :
243         or      t8, t10, t6     # e1    :         242         or      t8, t10, t6     # e1    :
244         cmoveq  a2, t6, t8      # e0    :         243         cmoveq  a2, t6, t8      # e0    :
245         nop                     # .. e1 :         244         nop                     # .. e1 :
246                                                   245 
247         /* Take care of a final (probably part    246         /* Take care of a final (probably partial) result word.
248            On entry to this basic block:          247            On entry to this basic block:
249            t0 == assembled source word            248            t0 == assembled source word
250            t8 == cmpbge mask that found the nu    249            t8 == cmpbge mask that found the null.  */
251 $u_final:                                         250 $u_final:
252         negq    t8, t6          # e0    : isol    251         negq    t8, t6          # e0    : isolate low bit set
253         and     t6, t8, t12     # e1    :         252         and     t6, t8, t12     # e1    :
254                                                   253 
255         and     t12, 0x80, t6   # e0    : avoi    254         and     t12, 0x80, t6   # e0    : avoid dest word load if we can
256         bne     t6, 1f          # .. e1 (zdb)     255         bne     t6, 1f          # .. e1 (zdb)
257                                                   256 
258         ldq_u   t1, 0(a0)       # e0    :         257         ldq_u   t1, 0(a0)       # e0    :
259         subq    t12, 1, t6      # .. e1 :         258         subq    t12, 1, t6      # .. e1 :
260         or      t6, t12, t8     # e0    :         259         or      t6, t12, t8     # e0    :
261         zapnot  t0, t8, t0      # .. e1 : kill    260         zapnot  t0, t8, t0      # .. e1 : kill source bytes > null
262         zap     t1, t8, t1      # e0    : kill    261         zap     t1, t8, t1      # e0    : kill dest bytes <= null
263         or      t0, t1, t0      # e1    :         262         or      t0, t1, t0      # e1    :
264                                                   263 
265 1:      stq_u   t0, 0(a0)       # e0    :         264 1:      stq_u   t0, 0(a0)       # e0    :
266         ret     (t9)            # .. e1 :         265         ret     (t9)            # .. e1 :
267                                                   266 
268         /* Got to end-of-count before end of s    267         /* Got to end-of-count before end of string.  
269            On entry to this basic block:          268            On entry to this basic block:
270            t1 == the shifted high-order bits f    269            t1 == the shifted high-order bits from the previous source word  */
271 $u_eoc:                                           270 $u_eoc:
272         and     a1, 7, t6       # e1    :         271         and     a1, 7, t6       # e1    :
273         sll     t10, t6, t6     # e0    :         272         sll     t10, t6, t6     # e0    :
274         and     t6, 0xff, t6    # e0    :         273         and     t6, 0xff, t6    # e0    :
275         bne     t6, 1f          # .. e1 :         274         bne     t6, 1f          # .. e1 :
276                                                   275 
277         ldq_u   t2, 8(a1)       # e0    : load    276         ldq_u   t2, 8(a1)       # e0    : load final src word
278         nop                     # .. e1 :         277         nop                     # .. e1 :
279         extqh   t2, a1, t0      # e0    : extr    278         extqh   t2, a1, t0      # e0    : extract low bits for last word
280         or      t1, t0, t1      # e1    :         279         or      t1, t0, t1      # e1    :
281                                                   280 
282 1:      cmpbge  zero, t1, t8                      281 1:      cmpbge  zero, t1, t8
283         mov     t1, t0                            282         mov     t1, t0
284                                                   283 
285 $u_eocfin:                      # end-of-count    284 $u_eocfin:                      # end-of-count, final word
286         or      t10, t8, t8                       285         or      t10, t8, t8
287         br      $u_final                          286         br      $u_final
288                                                   287 
289         /* Unaligned copy entry point.  */        288         /* Unaligned copy entry point.  */
290         .align 3                                  289         .align 3
291 $unaligned:                                       290 $unaligned:
292                                                   291 
293         ldq_u   t1, 0(a1)       # e0    : load    292         ldq_u   t1, 0(a1)       # e0    : load first source word
294                                                   293 
295         and     a0, 7, t4       # .. e1 : find    294         and     a0, 7, t4       # .. e1 : find dest misalignment
296         and     a1, 7, t5       # e0    : find    295         and     a1, 7, t5       # e0    : find src misalignment
297                                                   296 
298         /* Conditionally load the first destin    297         /* Conditionally load the first destination word and a bytemask
299            with 0xff indicating that the desti    298            with 0xff indicating that the destination byte is sacrosanct.  */
300                                                   299 
301         mov     zero, t0        # .. e1 :         300         mov     zero, t0        # .. e1 :
302         mov     zero, t6        # e0    :         301         mov     zero, t6        # e0    :
303         beq     t4, 1f          # .. e1 :         302         beq     t4, 1f          # .. e1 :
304         ldq_u   t0, 0(a0)       # e0    :         303         ldq_u   t0, 0(a0)       # e0    :
305         lda     t6, -1          # .. e1 :         304         lda     t6, -1          # .. e1 :
306         mskql   t6, a0, t6      # e0    :         305         mskql   t6, a0, t6      # e0    :
307         subq    a1, t4, a1      # .. e1 : sub     306         subq    a1, t4, a1      # .. e1 : sub dest misalignment from src addr
308                                                   307 
309         /* If source misalignment is larger th    308         /* If source misalignment is larger than dest misalignment, we need
310            extra startup checks to avoid SEGV.    309            extra startup checks to avoid SEGV.  */
311                                                   310 
312 1:      cmplt   t4, t5, t12     # e1    :         311 1:      cmplt   t4, t5, t12     # e1    :
313         extql   t1, a1, t1      # .. e0 : shif    312         extql   t1, a1, t1      # .. e0 : shift src into place
314         lda     t2, -1          # e0    : for     313         lda     t2, -1          # e0    : for creating masks later
315         beq     t12, $u_head    # .. e1 :         314         beq     t12, $u_head    # .. e1 :
316                                                   315 
317         extql   t2, a1, t2      # e0    :         316         extql   t2, a1, t2      # e0    :
318         cmpbge  zero, t1, t8    # .. e1 : is t    317         cmpbge  zero, t1, t8    # .. e1 : is there a zero?
319         andnot  t2, t6, t2      # e0    : dest !! 318         andnot  t2, t6, t12     # e0    : dest mask for a single word copy
320         or      t8, t10, t5     # .. e1 : test    319         or      t8, t10, t5     # .. e1 : test for end-of-count too
321         cmpbge  zero, t2, t3    # e0    :      !! 320         cmpbge  zero, t12, t3   # e0    :
322         cmoveq  a2, t5, t8      # .. e1 :         321         cmoveq  a2, t5, t8      # .. e1 :
323         andnot  t8, t3, t8      # e0    :         322         andnot  t8, t3, t8      # e0    :
324         beq     t8, $u_head     # .. e1 (zdb)     323         beq     t8, $u_head     # .. e1 (zdb)
325                                                   324 
326         /* At this point we've found a zero in    325         /* At this point we've found a zero in the first partial word of
327            the source.  We need to isolate the    326            the source.  We need to isolate the valid source data and mask
328            it into the original destination da    327            it into the original destination data.  (Incidentally, we know
329            that we'll need at least one byte o    328            that we'll need at least one byte of that original dest word.) */
330                                                   329 
331         ldq_u   t0, 0(a0)       # e0    :         330         ldq_u   t0, 0(a0)       # e0    :
332         negq    t8, t6          # .. e1 : buil    331         negq    t8, t6          # .. e1 : build bitmask of bytes <= zero
333         mskqh   t1, t4, t1      # e0    :         332         mskqh   t1, t4, t1      # e0    :
334         and     t6, t8, t12     # .. e1 :      !! 333         and     t6, t8, t2      # .. e1 :
335         subq    t12, 1, t6      # e0    :      !! 334         subq    t2, 1, t6       # e0    :
336         or      t6, t12, t8     # e1    :      !! 335         or      t6, t2, t8      # e1    :
337                                                   336 
338         zapnot  t2, t8, t2      # e0    : prep !! 337         zapnot  t12, t8, t12    # e0    : prepare source word; mirror changes
339         zapnot  t1, t8, t1      # .. e1 : to s    338         zapnot  t1, t8, t1      # .. e1 : to source validity mask
340                                                   339 
341         andnot  t0, t2, t0      # e0    : zero !! 340         andnot  t0, t12, t0     # e0    : zero place for source to reside
342         or      t0, t1, t0      # e1    : and     341         or      t0, t1, t0      # e1    : and put it there
343         stq_u   t0, 0(a0)       # e0    :         342         stq_u   t0, 0(a0)       # e0    :
344         ret     (t9)            # .. e1 :         343         ret     (t9)            # .. e1 :
345                                                   344 
346         .end __stxncpy                            345         .end __stxncpy
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php