C++ Run-time Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
fletcher::Platform Class Reference

A Fletcher Platform. Links during run-time and abstracts access to lower-level platform-specific libraries / API's. More...

#include <platform.h>

Public Member Functions

 ~Platform ()
 Platform destructor.
 
std::string name ()
 Return the name of the platform.
 
Status MmioToString (std::string *str, uint64_t start, uint64_t stop, bool quiet=false)
 Print the contents of the MMIO registers within some range.
 
Status Init () const
 Initialize the platform.
 
Status WriteMMIO (uint64_t offset, uint32_t value) const
 Write to an MMIO register.
 
Status ReadMMIO (uint64_t offset, uint32_t *value) const
 Read from an MMIO register.
 
Status ReadMMIO64 (uint64_t offset, uint64_t *value)
 Read 64 bit value from two successive 32 bit MMIO registers. The lower register will go to the lower bits.
 
Status DeviceMalloc (da_t *device_address, const int64_t size) const
 Allocate a region of memory on the device.
 
Status DeviceFree (const da_t device_address) const
 Free a previously allocated memory region on the device.
 
Status CopyHostToDevice (const uint8_t *host_source, const da_t device_destination, const int64_t size) const
 Copy data from host memory to device memory.
 
Status CopyDeviceToHost (const da_t device_source, uint8_t *host_destination, const int64_t size) const
 Copy data from device memory to host memory.
 
Status PrepareHostBuffer (const uint8_t *host_source, da_t *device_destination, int64_t size, bool *alloced) const
 Prepare a memory region of the host for use by the device. May or may not involve a copy (see MemType).
 
Status CacheHostBuffer (const uint8_t *host_source, da_t *device_destination, const int64_t size) const
 Cache a memory region of the host for use by the device. Always causes an allocation and copy.
 
Status Terminate ()
 Terminate the platform.
 

Static Public Member Functions

static Status Make (const std::string &name, std::shared_ptr< Platform > *platform_out, bool quiet=true)
 Create a new platform instance.
 
static Status Make (std::shared_ptr< Platform > *platform_out, bool quiet=true)
 Create a new platform by attempting to autodetect the platform driver.
 

Public Attributes

void * init_data = nullptr
 Data for platform initialization.
 
void * terminate_data = nullptr
 Data for platform termination.
 

Detailed Description

A Fletcher Platform. Links during run-time and abstracts access to lower-level platform-specific libraries / API's.

Definition at line 33 of file platform.h.

Constructor & Destructor Documentation

◆ ~Platform()

fletcher::Platform::~Platform ( )
inline

Platform destructor.

Definition at line 36 of file platform.h.

Member Function Documentation

◆ CacheHostBuffer()

Status fletcher::Platform::CacheHostBuffer ( const uint8_t *  host_source,
da_t *  device_destination,
const int64_t  size 
) const
inline

Cache a memory region of the host for use by the device. Always causes an allocation and copy.

Parameters
[in]host_sourceSource pointer in host memory.
[out]device_destinationDestination pointer in device memory.
[in]sizeThe amount of bytes to copy.
Returns
Status::OK() if successful, otherwise a descriptive error status.

Definition at line 154 of file platform.h.

◆ CopyDeviceToHost()

Status fletcher::Platform::CopyDeviceToHost ( const da_t  device_source,
uint8_t *  host_destination,
const int64_t  size 
) const
inline

Copy data from device memory to host memory.

Parameters
[in]device_sourceSource pointer in device memory.
[in]host_destinationDestination pointer in host memory.
[in]sizeThe amount of bytes to copy.
Returns
Status::OK() if successful, otherwise a descriptive error status.

Definition at line 127 of file platform.h.

◆ CopyHostToDevice()

Status fletcher::Platform::CopyHostToDevice ( const uint8_t *  host_source,
const da_t  device_destination,
const int64_t  size 
) const
inline

Copy data from host memory to device memory.

Parameters
[in]host_sourceSource pointer in host memory.
[in]device_destinationDestination pointer in device memory.
[in]sizeThe amount of bytes to copy.
Returns
Status::OK() if successful, otherwise a descriptive error status.

Definition at line 116 of file platform.h.

◆ DeviceFree()

Status fletcher::Platform::DeviceFree ( const da_t  device_address) const
inline

Free a previously allocated memory region on the device.

Parameters
[in]device_addressThe device address of the memory region.
Returns
Status::OK() if successful, otherwise a descriptive error status.

Definition at line 107 of file platform.h.

◆ DeviceMalloc()

Status fletcher::Platform::DeviceMalloc ( da_t *  device_address,
const int64_t  size 
) const
inline

Allocate a region of memory on the device.

Parameters
[out]device_addressThe resulting device address
[in]sizeThe amount of bytes to allocate
Returns
Status::OK() if successful, otherwise a descriptive error status.

Definition at line 98 of file platform.h.

◆ Init()

Status fletcher::Platform::Init ( ) const
inline

Initialize the platform.

Definition at line 66 of file platform.h.

◆ Make() [1/2]

static Status fletcher::Platform::Make ( const std::string &  name,
std::shared_ptr< Platform > *  platform_out,
bool  quiet = true 
)
static

Create a new platform instance.

Parameters
[in]nameThe name of the platform.
[out]platform_outA pointer to a shared pointer that will point to the new platform instance.
[in]quietWhether to suppress any logging messages
Returns
Status::OK() if successful, otherwise a descriptive error status with platform_out = nullptr.

◆ Make() [2/2]

static Status fletcher::Platform::Make ( std::shared_ptr< Platform > *  platform_out,
bool  quiet = true 
)
static

Create a new platform by attempting to autodetect the platform driver.

Parameters
[out]platform_outA pointer to a shared pointer that will point to the new platform instance.
[in]quietSuppresses logging messages when true.
Returns
Status::OK() if successful, otherwise a descriptive error status with platform_out = nullptr.

◆ MmioToString()

Status fletcher::Platform::MmioToString ( std::string *  str,
uint64_t  start,
uint64_t  stop,
bool  quiet = false 
)

Print the contents of the MMIO registers within some range.

◆ name()

std::string fletcher::Platform::name ( )

Return the name of the platform.

◆ PrepareHostBuffer()

Status fletcher::Platform::PrepareHostBuffer ( const uint8_t *  host_source,
da_t *  device_destination,
int64_t  size,
bool *  alloced 
) const
inline

Prepare a memory region of the host for use by the device. May or may not involve a copy (see MemType).

Parameters
[in]host_sourceSource pointer in host memory.
[out]device_destinationDestination pointer in device memory.
[in]sizeThe amount of bytes to copy.
[out]allocedWhether or not an allocation was made in device memory (that needs to be freed).
Returns
Status::OK() if successful, otherwise a descriptive error status.

Definition at line 139 of file platform.h.

◆ ReadMMIO()

Status fletcher::Platform::ReadMMIO ( uint64_t  offset,
uint32_t *  value 
) const
inline

Read from an MMIO register.

Parameters
[in]offsetRegister offset to read from.
[out]valuePointer to a value to store the result.
Returns
Status::OK() if successful, otherwise a descriptive error status.

Definition at line 82 of file platform.h.

◆ ReadMMIO64()

Status fletcher::Platform::ReadMMIO64 ( uint64_t  offset,
uint64_t *  value 
)

Read 64 bit value from two successive 32 bit MMIO registers. The lower register will go to the lower bits.

Parameters
[in]offsetRegister offset to read from.
[out]valuePointer to a value to store the result.
Returns
Status::OK() if successful, otherwise a descriptive error status.

◆ Terminate()

Status fletcher::Platform::Terminate ( )
inline

Terminate the platform.

Returns
Status::OK() if successful, otherwise a descriptive error status.

Definition at line 163 of file platform.h.

◆ WriteMMIO()

Status fletcher::Platform::WriteMMIO ( uint64_t  offset,
uint32_t  value 
) const
inline

Write to an MMIO register.

Parameters
[in]offsetRegister offset to write to.
[in]valueValue to write.
Returns
Status::OK() if successful, otherwise a descriptive error status.

Definition at line 74 of file platform.h.

Member Data Documentation

◆ init_data

void* fletcher::Platform::init_data = nullptr

Data for platform initialization.

Definition at line 170 of file platform.h.

◆ terminate_data

void* fletcher::Platform::terminate_data = nullptr

Data for platform termination.

Definition at line 172 of file platform.h.


The documentation for this class was generated from the following file: