xref: /dpdk/drivers/raw/ifpga/base/osdep_raw/osdep_generic.h (revision 473c88f9b391c2cd8b8622dcc488116cb09b624a)
1*473c88f9SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2*473c88f9SBruce Richardson  * Copyright(c) 2010-2018 Intel Corporation
3*473c88f9SBruce Richardson  */
4*473c88f9SBruce Richardson 
5*473c88f9SBruce Richardson #ifndef _OSDEP_RAW_GENERIC_H
6*473c88f9SBruce Richardson #define _OSDEP_RAW_GENERIC_H
7*473c88f9SBruce Richardson 
8*473c88f9SBruce Richardson #define	compiler_barrier() (asm volatile ("" : : : "memory"))
9*473c88f9SBruce Richardson 
10*473c88f9SBruce Richardson #define io_wmb() compiler_barrier()
11*473c88f9SBruce Richardson #define io_rmb() compiler_barrier()
12*473c88f9SBruce Richardson 
opae_readb(const volatile void * addr)13*473c88f9SBruce Richardson static inline uint8_t opae_readb(const volatile void *addr)
14*473c88f9SBruce Richardson {
15*473c88f9SBruce Richardson 	uint8_t val;
16*473c88f9SBruce Richardson 
17*473c88f9SBruce Richardson 	val = *(const volatile uint8_t *)addr;
18*473c88f9SBruce Richardson 	io_rmb();
19*473c88f9SBruce Richardson 	return val;
20*473c88f9SBruce Richardson }
21*473c88f9SBruce Richardson 
opae_readw(const volatile void * addr)22*473c88f9SBruce Richardson static inline uint16_t opae_readw(const volatile void *addr)
23*473c88f9SBruce Richardson {
24*473c88f9SBruce Richardson 	uint16_t val;
25*473c88f9SBruce Richardson 
26*473c88f9SBruce Richardson 	val = *(const volatile uint16_t *)addr;
27*473c88f9SBruce Richardson 	io_rmb();
28*473c88f9SBruce Richardson 	return val;
29*473c88f9SBruce Richardson }
30*473c88f9SBruce Richardson 
opae_readl(const volatile void * addr)31*473c88f9SBruce Richardson static inline uint32_t opae_readl(const volatile void *addr)
32*473c88f9SBruce Richardson {
33*473c88f9SBruce Richardson 	uint32_t val;
34*473c88f9SBruce Richardson 
35*473c88f9SBruce Richardson 	val = *(const volatile uint32_t *)addr;
36*473c88f9SBruce Richardson 	io_rmb();
37*473c88f9SBruce Richardson 	return val;
38*473c88f9SBruce Richardson }
39*473c88f9SBruce Richardson 
opae_readq(const volatile void * addr)40*473c88f9SBruce Richardson static inline uint64_t opae_readq(const volatile void *addr)
41*473c88f9SBruce Richardson {
42*473c88f9SBruce Richardson 	uint64_t val;
43*473c88f9SBruce Richardson 
44*473c88f9SBruce Richardson 	val = *(const volatile uint64_t *)addr;
45*473c88f9SBruce Richardson 	io_rmb();
46*473c88f9SBruce Richardson 	return val;
47*473c88f9SBruce Richardson }
48*473c88f9SBruce Richardson 
opae_writeb(uint8_t value,volatile void * addr)49*473c88f9SBruce Richardson static inline void opae_writeb(uint8_t value, volatile void *addr)
50*473c88f9SBruce Richardson {
51*473c88f9SBruce Richardson 	io_wmb();
52*473c88f9SBruce Richardson 	*(volatile uint8_t *)addr = value;
53*473c88f9SBruce Richardson }
54*473c88f9SBruce Richardson 
opae_writew(uint16_t value,volatile void * addr)55*473c88f9SBruce Richardson static inline void opae_writew(uint16_t value, volatile void *addr)
56*473c88f9SBruce Richardson {
57*473c88f9SBruce Richardson 	io_wmb();
58*473c88f9SBruce Richardson 	*(volatile uint16_t *)addr = value;
59*473c88f9SBruce Richardson }
60*473c88f9SBruce Richardson 
opae_writel(uint32_t value,volatile void * addr)61*473c88f9SBruce Richardson static inline void opae_writel(uint32_t value, volatile void *addr)
62*473c88f9SBruce Richardson {
63*473c88f9SBruce Richardson 	io_wmb();
64*473c88f9SBruce Richardson 	*(volatile uint32_t *)addr = value;
65*473c88f9SBruce Richardson }
66*473c88f9SBruce Richardson 
opae_writeq(uint64_t value,volatile void * addr)67*473c88f9SBruce Richardson static inline void opae_writeq(uint64_t value, volatile void *addr)
68*473c88f9SBruce Richardson {
69*473c88f9SBruce Richardson 	io_wmb();
70*473c88f9SBruce Richardson 	*(volatile uint64_t *)addr = value;
71*473c88f9SBruce Richardson }
72*473c88f9SBruce Richardson 
73*473c88f9SBruce Richardson #define opae_free(addr) free(addr)
74*473c88f9SBruce Richardson #define opae_memcpy(a, b, c) memcpy((a), (b), (c))
75*473c88f9SBruce Richardson 
76*473c88f9SBruce Richardson #endif
77