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