xref: /netbsd-src/sys/external/bsd/drm2/include/asm/io.h (revision 752d42263ccac42d808c73bed01135c318389f0f)
1*752d4226Sriastradh /*	$NetBSD: io.h,v 1.10 2022/10/25 23:33:18 riastradh Exp $	*/
26cb10275Sriastradh 
36cb10275Sriastradh /*-
46cb10275Sriastradh  * Copyright (c) 2013 The NetBSD Foundation, Inc.
56cb10275Sriastradh  * All rights reserved.
66cb10275Sriastradh  *
76cb10275Sriastradh  * This code is derived from software contributed to The NetBSD Foundation
86cb10275Sriastradh  * by Taylor R. Campbell.
96cb10275Sriastradh  *
106cb10275Sriastradh  * Redistribution and use in source and binary forms, with or without
116cb10275Sriastradh  * modification, are permitted provided that the following conditions
126cb10275Sriastradh  * are met:
136cb10275Sriastradh  * 1. Redistributions of source code must retain the above copyright
146cb10275Sriastradh  *    notice, this list of conditions and the following disclaimer.
156cb10275Sriastradh  * 2. Redistributions in binary form must reproduce the above copyright
166cb10275Sriastradh  *    notice, this list of conditions and the following disclaimer in the
176cb10275Sriastradh  *    documentation and/or other materials provided with the distribution.
186cb10275Sriastradh  *
196cb10275Sriastradh  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
206cb10275Sriastradh  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
216cb10275Sriastradh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
226cb10275Sriastradh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
236cb10275Sriastradh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
246cb10275Sriastradh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
256cb10275Sriastradh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
266cb10275Sriastradh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
276cb10275Sriastradh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
286cb10275Sriastradh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
296cb10275Sriastradh  * POSSIBILITY OF SUCH DAMAGE.
306cb10275Sriastradh  */
316cb10275Sriastradh 
326cb10275Sriastradh #ifndef _ASM_IO_H_
336cb10275Sriastradh #define _ASM_IO_H_
346cb10275Sriastradh 
3577b5597aSriastradh #include <sys/cdefs.h>
3677b5597aSriastradh #include <sys/systm.h>
376cb10275Sriastradh 
38a27e15b5Sriastradh #include <linux/string.h>
39*752d4226Sriastradh #include <linux/vmalloc.h>
40a27e15b5Sriastradh 
41c17d3228Sriastradh #define	memcpy_fromio(d,s,n)	memcpy((d),__UNVOLATILE(s),(n))
42c17d3228Sriastradh #define	memcpy_toio(d,s,n)	memcpy(__UNVOLATILE(d),(s),(n))
436ac14ff8Sjmcneill 
446ac14ff8Sjmcneill #if defined(__NetBSD__) && defined(__aarch64__)
45136ac01dSriastradh static inline void
memset_io(volatile void * b,int c,size_t len)46c17d3228Sriastradh memset_io(volatile void *b, int c, size_t len)
476ac14ff8Sjmcneill {
48c17d3228Sriastradh 	volatile uint8_t *ptr = b;
49878019c9Sjmcneill 
50878019c9Sjmcneill 	while (len > 0) {
516ac14ff8Sjmcneill 		*ptr++ = c;
52878019c9Sjmcneill 		len--;
536ac14ff8Sjmcneill 	}
546ac14ff8Sjmcneill }
556ac14ff8Sjmcneill #else
56c17d3228Sriastradh #define	memset_io(b,c,n)	memset(__UNVOLATILE(b),(c),(n))
576ac14ff8Sjmcneill #endif
586cb10275Sriastradh 
5977b5597aSriastradh /* XXX wrong place */
6077b5597aSriastradh #define	__force
616cb10275Sriastradh 
626cb10275Sriastradh #endif  /* _ASM_IO_H_ */
63