A Fletcher Platform. Links during run-time and abstracts access to lower-level platform-specific libraries / API's.
More...
#include <platform.h>
|
| ~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 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.
|
|
|
void * | init_data = nullptr |
| Data for platform initialization.
|
|
void * | terminate_data = nullptr |
| Data for platform termination.
|
|
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.
◆ ~Platform()
fletcher::Platform::~Platform |
( |
| ) |
|
|
inline |
◆ 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_source | Source pointer in host memory. |
[out] | device_destination | Destination pointer in device memory. |
[in] | size | The 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_source | Source pointer in device memory. |
[in] | host_destination | Destination pointer in host memory. |
[in] | size | The 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_source | Source pointer in host memory. |
[in] | device_destination | Destination pointer in device memory. |
[in] | size | The 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_address | The 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_address | The resulting device address |
[in] | size | The 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] | name | The name of the platform. |
[out] | platform_out | A pointer to a shared pointer that will point to the new platform instance. |
[in] | quiet | Whether 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_out | A pointer to a shared pointer that will point to the new platform instance. |
[in] | quiet | Suppresses 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_source | Source pointer in host memory. |
[out] | device_destination | Destination pointer in device memory. |
[in] | size | The amount of bytes to copy. |
[out] | alloced | Whether 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] | offset | Register offset to read from. |
[out] | value | Pointer 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] | offset | Register offset to read from. |
[out] | value | Pointer 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] | offset | Register offset to write to. |
[in] | value | Value to write. |
- Returns
- Status::OK() if successful, otherwise a descriptive error status.
Definition at line 74 of file platform.h.
◆ 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: