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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/arm64/fp/asm-utils.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 // Copyright (C) 2015-2021 ARM Limited.
  3 // Original author: Dave Martin <Dave.Martin@arm.com>
  4 //
  5 // Utility functions for assembly code.
  6 
  7 #include <asm/unistd.h>
  8 #include "assembler.h"
  9 
 10 // Print a single character x0 to stdout
 11 // Clobbers x0-x2,x8
 12 function putc
 13         str     x0, [sp, #-16]!
 14 
 15         mov     x0, #1                  // STDOUT_FILENO
 16         mov     x1, sp
 17         mov     x2, #1
 18         mov     x8, #__NR_write
 19         svc     #0
 20 
 21         add     sp, sp, #16
 22         ret
 23 endfunction
 24 .globl  putc
 25         
 26 // Print a NUL-terminated string starting at address x0 to stdout
 27 // Clobbers x0-x3,x8
 28 function puts
 29         mov     x1, x0
 30 
 31         mov     x2, #0
 32 0:      ldrb    w3, [x0], #1
 33         cbz     w3, 1f
 34         add     x2, x2, #1
 35         b       0b
 36 
 37 1:      mov     w0, #1                  // STDOUT_FILENO
 38         mov     x8, #__NR_write
 39         svc     #0
 40 
 41         ret
 42 endfunction
 43 .globl  puts
 44 
 45 // Print an unsigned decimal number x0 to stdout
 46 // Clobbers x0-x4,x8
 47 function putdec
 48         mov     x1, sp
 49         str     x30, [sp, #-32]!        // Result can't be > 20 digits
 50 
 51         mov     x2, #0
 52         strb    w2, [x1, #-1]!          // Write the NUL terminator
 53 
 54         mov     x2, #10
 55 0:      udiv    x3, x0, x2              // div-mod loop to generate the digits
 56         msub    x0, x3, x2, x0
 57         add     w0, w0, #'0'
 58         strb    w0, [x1, #-1]!
 59         mov     x0, x3
 60         cbnz    x3, 0b
 61 
 62         ldrb    w0, [x1]
 63         cbnz    w0, 1f
 64         mov     w0, #'0'                // Print "0" for 0, not ""
 65         strb    w0, [x1, #-1]!
 66 
 67 1:      mov     x0, x1
 68         bl      puts
 69 
 70         ldr     x30, [sp], #32
 71         ret
 72 endfunction
 73 .globl  putdec
 74 
 75 // Print an unsigned decimal number x0 to stdout, followed by a newline
 76 // Clobbers x0-x5,x8
 77 function putdecn
 78         mov     x5, x30
 79 
 80         bl      putdec
 81         mov     x0, #'\n'
 82         bl      putc
 83 
 84         ret     x5
 85 endfunction
 86 .globl  putdecn
 87 
 88 // Clobbers x0-x3,x8
 89 function puthexb
 90         str     x30, [sp, #-0x10]!
 91 
 92         mov     w3, w0
 93         lsr     w0, w0, #4
 94         bl      puthexnibble
 95         mov     w0, w3
 96 
 97         ldr     x30, [sp], #0x10
 98         // fall through to puthexnibble
 99 endfunction
100 .globl  puthexb
101 
102 // Clobbers x0-x2,x8
103 function puthexnibble
104         and     w0, w0, #0xf
105         cmp     w0, #10
106         blo     1f
107         add     w0, w0, #'a' - ('9' + 1)
108 1:      add     w0, w0, #'0'
109         b       putc
110 endfunction
111 .globl  puthexnibble
112 
113 // x0=data in, x1=size in, clobbers x0-x5,x8
114 function dumphex
115         str     x30, [sp, #-0x10]!
116 
117         mov     x4, x0
118         mov     x5, x1
119 
120 0:      subs    x5, x5, #1
121         b.lo    1f
122         ldrb    w0, [x4], #1
123         bl      puthexb
124         b       0b
125 
126 1:      ldr     x30, [sp], #0x10
127         ret
128 endfunction
129 .globl  dumphex
130 
131         // Trivial memory copy: copy x2 bytes, starting at address x1, to address x0.
132 // Clobbers x0-x3
133 function memcpy
134         cmp     x2, #0
135         b.eq    1f
136 0:      ldrb    w3, [x1], #1
137         strb    w3, [x0], #1
138         subs    x2, x2, #1
139         b.ne    0b
140 1:      ret
141 endfunction
142 .globl  memcpy
143 
144 // Fill x1 bytes starting at x0 with 0xae (for canary purposes)
145 // Clobbers x1, x2.
146 function memfill_ae
147         mov     w2, #0xae
148         b       memfill
149 endfunction
150 .globl  memfill_ae
151         
152 // Fill x1 bytes starting at x0 with 0.
153 // Clobbers x1, x2.
154 function memclr
155         mov     w2, #0
156 endfunction
157 .globl  memclr
158         // fall through to memfill
159 
160 // Trivial memory fill: fill x1 bytes starting at address x0 with byte w2
161 // Clobbers x1
162 function memfill
163         cmp     x1, #0
164         b.eq    1f
165 
166 0:      strb    w2, [x0], #1
167         subs    x1, x1, #1
168         b.ne    0b
169 
170 1:      ret
171 endfunction
172 .globl  memfill

~ [ 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