From 15e978340d5fea9093cf1705042f331c3ae697ed Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 10 Oct 2017 16:41:18 -0700 Subject: [PATCH] mmio: add functions for 1 and 2 byte I/O accesses Change-Id: I7a325ddd8db3424207cf2e561c6d6e894f549989 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/382073 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Reviewed-by: Dariusz Stojaczyk --- include/spdk/mmio.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/spdk/mmio.h b/include/spdk/mmio.h index 1dbfa5823..68b16605f 100644 --- a/include/spdk/mmio.h +++ b/include/spdk/mmio.h @@ -52,6 +52,34 @@ extern "C" { #define SPDK_MMIO_64BIT 0 #endif +static inline uint8_t +spdk_mmio_read_1(const volatile uint8_t *addr) +{ + spdk_compiler_barrier(); + return *addr; +} + +static inline void +spdk_mmio_write_1(volatile uint8_t *addr, uint8_t val) +{ + spdk_compiler_barrier(); + *addr = val; +} + +static inline uint16_t +spdk_mmio_read_2(const volatile uint16_t *addr) +{ + spdk_compiler_barrier(); + return *addr; +} + +static inline void +spdk_mmio_write_2(volatile uint16_t *addr, uint16_t val) +{ + spdk_compiler_barrier(); + *addr = val; +} + static inline uint32_t spdk_mmio_read_4(const volatile uint32_t *addr) {