per Intel policy to include file commit date using git cmd below. The policy does not apply to non-Intel (C) notices. git log --follow -C90% --format=%ad --date default <file> | tail -1 and then pull just the 4 digit year from the result. Intel copyrights were not added to files where Intel either had no contribution ot the contribution lacked substance (ie license header updates, formatting changes, etc). Contribution date used "--follow -C95%" to get the most accurate date. Note that several files in this patch didn't end the license/(c) block with a blank comment line so these were added as the vast majority of files do have this last blank line. Simply there for consistency. Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: Id5b7ce4f658fe87132f14139ead58d6e285c04d4 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15192 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Community-CI: Mellanox Build Bot
112 lines
1.9 KiB
C
112 lines
1.9 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright (C) 2015 Intel Corporation.
|
|
* All rights reserved.
|
|
*/
|
|
|
|
/** \file
|
|
* Memory-mapped I/O utility functions
|
|
*/
|
|
|
|
#ifndef SPDK_MMIO_H
|
|
#define SPDK_MMIO_H
|
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "spdk/barrier.h"
|
|
|
|
#ifdef __x86_64__
|
|
#define SPDK_MMIO_64BIT 1 /* Can do atomic 64-bit memory read/write (over PCIe) */
|
|
#else
|
|
#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)
|
|
{
|
|
spdk_compiler_barrier();
|
|
return *addr;
|
|
}
|
|
|
|
static inline void
|
|
spdk_mmio_write_4(volatile uint32_t *addr, uint32_t val)
|
|
{
|
|
spdk_compiler_barrier();
|
|
*addr = val;
|
|
}
|
|
|
|
static inline uint64_t
|
|
spdk_mmio_read_8(volatile uint64_t *addr)
|
|
{
|
|
uint64_t val;
|
|
volatile uint32_t *addr32 = (volatile uint32_t *)addr;
|
|
|
|
spdk_compiler_barrier();
|
|
|
|
if (SPDK_MMIO_64BIT) {
|
|
val = *addr;
|
|
} else {
|
|
/*
|
|
* Read lower 4 bytes before upper 4 bytes.
|
|
* This particular order is required by I/OAT.
|
|
* If the other order is required, use a pair of spdk_mmio_read_4() calls.
|
|
*/
|
|
val = addr32[0];
|
|
val |= (uint64_t)addr32[1] << 32;
|
|
}
|
|
|
|
return val;
|
|
}
|
|
|
|
static inline void
|
|
spdk_mmio_write_8(volatile uint64_t *addr, uint64_t val)
|
|
{
|
|
volatile uint32_t *addr32 = (volatile uint32_t *)addr;
|
|
|
|
spdk_compiler_barrier();
|
|
|
|
if (SPDK_MMIO_64BIT) {
|
|
*addr = val;
|
|
} else {
|
|
addr32[0] = (uint32_t)val;
|
|
addr32[1] = (uint32_t)(val >> 32);
|
|
}
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|