4 * Copyright (C) Cavium networks Ltd. 2016.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Cavium networks nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _RTE_IO_ARM64_H_
34 #define _RTE_IO_ARM64_H_
42 #define RTE_OVERRIDE_IO_H
44 #include "generic/rte_io.h"
45 #include "rte_atomic_64.h"
47 static __rte_always_inline uint8_t
48 rte_read8_relaxed(const volatile void *addr)
53 "ldrb %w[val], [%x[addr]]"
59 static __rte_always_inline uint16_t
60 rte_read16_relaxed(const volatile void *addr)
65 "ldrh %w[val], [%x[addr]]"
71 static __rte_always_inline uint32_t
72 rte_read32_relaxed(const volatile void *addr)
77 "ldr %w[val], [%x[addr]]"
83 static __rte_always_inline uint64_t
84 rte_read64_relaxed(const volatile void *addr)
89 "ldr %x[val], [%x[addr]]"
95 static __rte_always_inline void
96 rte_write8_relaxed(uint8_t val, volatile void *addr)
99 "strb %w[val], [%x[addr]]"
101 : [val] "r" (val), [addr] "r" (addr));
104 static __rte_always_inline void
105 rte_write16_relaxed(uint16_t val, volatile void *addr)
108 "strh %w[val], [%x[addr]]"
110 : [val] "r" (val), [addr] "r" (addr));
113 static __rte_always_inline void
114 rte_write32_relaxed(uint32_t val, volatile void *addr)
117 "str %w[val], [%x[addr]]"
119 : [val] "r" (val), [addr] "r" (addr));
122 static __rte_always_inline void
123 rte_write64_relaxed(uint64_t val, volatile void *addr)
126 "str %x[val], [%x[addr]]"
128 : [val] "r" (val), [addr] "r" (addr));
131 static __rte_always_inline uint8_t
132 rte_read8(const volatile void *addr)
135 val = rte_read8_relaxed(addr);
140 static __rte_always_inline uint16_t
141 rte_read16(const volatile void *addr)
144 val = rte_read16_relaxed(addr);
149 static __rte_always_inline uint32_t
150 rte_read32(const volatile void *addr)
153 val = rte_read32_relaxed(addr);
158 static __rte_always_inline uint64_t
159 rte_read64(const volatile void *addr)
162 val = rte_read64_relaxed(addr);
167 static __rte_always_inline void
168 rte_write8(uint8_t value, volatile void *addr)
171 rte_write8_relaxed(value, addr);
174 static __rte_always_inline void
175 rte_write16(uint16_t value, volatile void *addr)
178 rte_write16_relaxed(value, addr);
181 static __rte_always_inline void
182 rte_write32(uint32_t value, volatile void *addr)
185 rte_write32_relaxed(value, addr);
188 static __rte_always_inline void
189 rte_write64(uint64_t value, volatile void *addr)
192 rte_write64_relaxed(value, addr);
199 #endif /* _RTE_IO_ARM64_H_ */