xref: /dflybsd-src/sys/dev/drm/include/asm/string_64.h (revision 3f2dd94a569761201b5b0a18b2f697f97fe1b9dc)
1*3f2dd94aSFrançois Tigeot /*
2*3f2dd94aSFrançois Tigeot  * Copyright (c) 2020 François Tigeot <ftigeot@wolfpond.org>
3*3f2dd94aSFrançois Tigeot  * All rights reserved.
4*3f2dd94aSFrançois Tigeot  *
5*3f2dd94aSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6*3f2dd94aSFrançois Tigeot  * modification, are permitted provided that the following conditions
7*3f2dd94aSFrançois Tigeot  * are met:
8*3f2dd94aSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9*3f2dd94aSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10*3f2dd94aSFrançois Tigeot  *    disclaimer.
11*3f2dd94aSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12*3f2dd94aSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13*3f2dd94aSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14*3f2dd94aSFrançois Tigeot  *
15*3f2dd94aSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*3f2dd94aSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*3f2dd94aSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*3f2dd94aSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*3f2dd94aSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*3f2dd94aSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*3f2dd94aSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*3f2dd94aSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*3f2dd94aSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*3f2dd94aSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*3f2dd94aSFrançois Tigeot  */
26*3f2dd94aSFrançois Tigeot 
27*3f2dd94aSFrançois Tigeot #ifndef _ASM_STRING_64_H
28*3f2dd94aSFrançois Tigeot #define _ASM_STRING_64_H
29*3f2dd94aSFrançois Tigeot 
30*3f2dd94aSFrançois Tigeot #include <linux/jump_label.h>
31*3f2dd94aSFrançois Tigeot 
32*3f2dd94aSFrançois Tigeot static inline void *
memset64(u64 * s,uint64_t v,size_t n)33*3f2dd94aSFrançois Tigeot memset64(u64 *s, uint64_t v, size_t n)
34*3f2dd94aSFrançois Tigeot {
35*3f2dd94aSFrançois Tigeot 	u64 *dest = s;
36*3f2dd94aSFrançois Tigeot 
37*3f2dd94aSFrançois Tigeot 	__asm __volatile("rep stosq"
38*3f2dd94aSFrançois Tigeot 		: "+D" (dest), "+c" (n)	/* output operands (modified input) */
39*3f2dd94aSFrançois Tigeot 		: "a" (v)		/* unmodified input operands */
40*3f2dd94aSFrançois Tigeot 		: "memory");		/* clobbers */
41*3f2dd94aSFrançois Tigeot 
42*3f2dd94aSFrançois Tigeot 	return s;
43*3f2dd94aSFrançois Tigeot }
44*3f2dd94aSFrançois Tigeot 
45*3f2dd94aSFrançois Tigeot #endif	/* _ASM_STRING_64_H */
46