Skip to content

File mmio.h

FileList > docs > sw > include > opae > mmio.h

Go to the source code of this file.

Functions for mapping and accessing MMIO space. More...

  • #include <opae/types.h>

Public Functions

Type Name
fpga_result fpgaMapMMIO (fpga_handle handle, uint32_t mmio_num, uint64_t ** mmio_ptr)
Map MMIO space.
fpga_result fpgaReadMMIO32 (fpga_handle handle, uint32_t mmio_num, uint64_t offset, uint32_t * value)
Read 32 bit value from MMIO space.
fpga_result fpgaReadMMIO64 (fpga_handle handle, uint32_t mmio_num, uint64_t offset, uint64_t * value)
Read 64 bit value from MMIO space.
fpga_result fpgaUnmapMMIO (fpga_handle handle, uint32_t mmio_num)
Unmap MMIO space.
fpga_result fpgaWriteMMIO32 (fpga_handle handle, uint32_t mmio_num, uint64_t offset, uint32_t value)
Write 32 bit value to MMIO space.
fpga_result fpgaWriteMMIO512 (fpga_handle handle, uint32_t mmio_num, uint64_t offset, const void * value)
Write 512 bit value to MMIO space.
fpga_result fpgaWriteMMIO64 (fpga_handle handle, uint32_t mmio_num, uint64_t offset, uint64_t value)
Write 64 bit value to MMIO space.

Detailed Description

Most FPGA accelerators provide access to control registers through memory-mappable address spaces, commonly referred to as "MMIO spaces". This file provides functions to map, unmap, read, and write MMIO spaces.

Note that an accelerator may have multiple MMIO spaces, denoted by the mmio_num argument of the APIs below. The meaning and properties of each MMIO space are up to the accelerator designer.

Public Functions Documentation

function fpgaMapMMIO

Map MMIO space.

fpga_result fpgaMapMMIO (
    fpga_handle handle,
    uint32_t mmio_num,
    uint64_t ** mmio_ptr
) 

This function will return a pointer to the specified MMIO space of the target object in process virtual memory, if supported by the target. Some MMIO spaces may be restricted to privileged processes, depending on the used handle and type.

After mapping the respective MMIO space, you can access it through direct pointer operations (observing supported access sizes and alignments of the target platform and accelerator).

Note:

Some targets (such as the ASE simulator) do not support memory-mapping of IO register spaces and will not return a pointer to an actually mapped space. Instead, they will return FPGA_NOT_SUPPORTED. Usually, these platforms still allow the application to issue MMIO operations using fpgaReadMMIO32(), fpgaWriteMMIO32(), fpgeReadMMIO64(), and fpgaWriteMMIO64().

If the caller passes in NULL for mmio_ptr, no mapping will be performed, and no virtual address will be returned, though the call will return FPGA_OK. This implies that all accesses will be performed through fpgaReadMMIO32(), fpgaWriteMMIO32(), fpgeReadMMIO64(), and fpgaWriteMMIO64(). This is the only supported case for ASE.

The number of available MMIO spaces can be retrieved through the num_mmio property (fpgaPropertyGetNumMMIO()).

Parameters:

  • handle Handle to previously opened resource
  • mmio_num Number of MMIO space to access
  • mmio_ptr Pointer to memory where a pointer to the MMIO space will be returned. May be NULL, in which case no pointer is returned. Returned address may be NULL if underlying platform does not support memory mapping for register access.

Returns:

FPGA_OK on success. FPGA_INVALID_PARAM if any of the supplied parameters is invalid. FPGA_EXCEPTION if an internal exception occurred while trying to access the handle. FPGA_NO_ACCESS if the process' permissions are not sufficient to map the requested MMIO space. FPGA_NOT_SUPPORTED if platform does not support memory mapped IO.

function fpgaReadMMIO32

Read 32 bit value from MMIO space.

fpga_result fpgaReadMMIO32 (
    fpga_handle handle,
    uint32_t mmio_num,
    uint64_t offset,
    uint32_t * value
) 

This function will read from MMIO space of the target object at a specified offset.

Parameters:

  • handle Handle to previously opened accelerator resource
  • mmio_num Number of MMIO space to access
  • offset Byte offset into MMIO space
  • value Pointer to memory where read value is returned (32 bit)

Returns:

FPGA_OK on success. FPGA_INVALID_PARAM if any of the supplied parameters is invalid. FPGA_EXCEPTION if an internal exception occurred while trying to access the handle.

function fpgaReadMMIO64

Read 64 bit value from MMIO space.

fpga_result fpgaReadMMIO64 (
    fpga_handle handle,
    uint32_t mmio_num,
    uint64_t offset,
    uint64_t * value
) 

This function will read from MMIO space of the target object at a specified offset.

Parameters:

  • handle Handle to previously opened accelerator resource
  • mmio_num Number of MMIO space to access
  • offset Byte offset into MMIO space
  • value Pointer to memory where read value is returned (64 bit)

Returns:

FPGA_OK on success. FPGA_INVALID_PARAM if any of the supplied parameters is invalid. FPGA_EXCEPTION if an internal exception occurred while trying to access the handle.

function fpgaUnmapMMIO

Unmap MMIO space.

fpga_result fpgaUnmapMMIO (
    fpga_handle handle,
    uint32_t mmio_num
) 

This function will unmap a previously mapped MMIO space of the target object, rendering any pointers to it invalid.

Note:

This call is only supported by hardware targets, not by ASE simulation.

Parameters:

  • handle Handle to previously opened resource
  • mmio_num Number of MMIO space to access

Returns:

FPGA_OK on success. FPGA_INVALID_PARAM if any of the supplied parameters is invalid. FPGA_EXCEPTION if an internal exception occurred while trying to access the handle.

function fpgaWriteMMIO32

Write 32 bit value to MMIO space.

fpga_result fpgaWriteMMIO32 (
    fpga_handle handle,
    uint32_t mmio_num,
    uint64_t offset,
    uint32_t value
) 

This function will write to MMIO space of the target object at a specified offset.

Parameters:

  • handle Handle to previously opened accelerator resource
  • mmio_num Number of MMIO space to access
  • offset Byte offset into MMIO space
  • value Value to write (32 bit)

Returns:

FPGA_OK on success. FPGA_INVALID_PARAM if any of the supplied parameters is invalid. FPGA_EXCEPTION if an internal exception occurred while trying to access the handle.

function fpgaWriteMMIO512

Write 512 bit value to MMIO space.

fpga_result fpgaWriteMMIO512 (
    fpga_handle handle,
    uint32_t mmio_num,
    uint64_t offset,
    const void * value
) 

512 bit MMIO writes may not be supported on all platforms.

This function will write to MMIO space of the target object at a specified offset.

Parameters:

  • handle Handle to previously opened accelerator resource
  • mmio_num Number of MMIO space to access
  • offset Byte offset into MMIO space
  • value Pointer to memory holding value to write (512 bits)

Returns:

FPGA_OK on success. FPGA_INVALID_PARAM if any of the supplied parameters is invalid. FPGA_EXCEPTION if an internal exception occurred while trying to access the handle.

function fpgaWriteMMIO64

Write 64 bit value to MMIO space.

fpga_result fpgaWriteMMIO64 (
    fpga_handle handle,
    uint32_t mmio_num,
    uint64_t offset,
    uint64_t value
) 

This function will write to MMIO space of the target object at a specified offset.

Parameters:

  • handle Handle to previously opened accelerator resource
  • mmio_num Number of MMIO space to access
  • offset Byte offset into MMIO space
  • value Value to write (64 bit)

Returns:

FPGA_OK on success. FPGA_INVALID_PARAM if any of the supplied parameters is invalid. FPGA_EXCEPTION if an internal exception occurred while trying to access the handle.


The documentation for this class was generated from the following file docs/sw/include/opae/mmio.h