Files
2017-10-26 19:57:24 +02:00

116 lines
3.8 KiB
C
Executable File

#ifndef MOC_INTERNAL_GET_DATA_H_
#define MOC_INTERNAL_GET_DATA_H_
#include <stdint.h>
#include "../../moc.h"
/**
* \addtogroup internal_p2p_dma
**/
//@{
/**
* @name SPU-only
**/
//@{
/**
* Internal wrapper-function for a blocking DMA-get operation.
* Data can be of any size, constraints of low-level DMA-functions
* are dealt by this function.
* However data-addresses have to be at least 16-byte aligned.
*
* This function actually always reads a multiple of 16 from the source,
* but copies only size bytes of it to target. This means however that up
* to 15 bytes are read from an invalid location. As it is never written to
* them this should always be safe.
*
* @param target \b in ls-address of buffer
* @param source \b in ea-address of data
* @param size \b in size of data in byte
* @return 0 when success otherwise error-code
**/
int IMOC_get_data(void* target, uint64_t source, uint32_t size);
/**
* Internal wrapper-function for a blocking DMA-put operation.
* Data-size should be a multiple of 16 because of low-level constraints, but
* there is no upper limit of transfer-size.
* Data-addresses have to be at least 16-byte aligned.
*
* This function actually always reads a multiple of 16 from the source, and copies
* it to target. This means however that up to 15 bytes are written to and invalid
* location, so if one wants to use it with invalid sizes precautions have to be taken
* in order to make it safe.
*
* @param source \b in ls-address of data
* @param target \b in ea-address of buffer
* @param size \b in size of data in byte
* @return 0 when success otherwise error-code
**/
int IMOC_put_data(void* source, uint64_t target, uint32_t size);
/**
* Internal wrapper-function for a non-blocking DMA-get operation.
* Data can be of any size, constraints of low-level DMA-functions
* are dealt by this function.
* However data-addresses have to be at least 16-byte aligned.
*
* This function actually always reads a multiple of 16 from the source,
* but copies only size bytes of it to target. This means however that up
* to 15 bytes are read from an invalid location. As it is never written to
* them this should always be safe.
*
* @param target \b in ls-address of buffer
* @param source \b in ea-address of data
* @param size \b in size of data in byte
* @param request \b out request-handle
* @return 0 when success otherwise error-code
**/
int IMOC_iget_data(void* target, uint64_t source, uint32_t size, imoc_dma_request* request);
/**
* Internal wrapper-function for a blocking DMA-put operation.
* Data-size should be a multiple of 16 because of low-level constraints, but
* there is no upper limit of transfer-size.
* Data-addresses have to be at least 16-byte aligned.
*
* This function actually always reads a multiple of 16 from the source, and copies
* it to target. This means however that up to 15 bytes are written to and invalid
* location, so if one wants to use it with invalid sizes precautions have to be taken
* in order to make it safe.
*
* @param source \b in ls-address of data
* @param target \b in ea-address of buffer
* @param size \b in size of data in byte
* @param request \b out request-handle
* @return 0 when success otherwise error-code
**/
int IMOC_iput_data(void* source, uint64_t target, uint32_t size, imoc_dma_request* request);
/**
* Waits till a IMOC_iget_data or IMOC_iput_data is completed.
*
* @param request \b in request-handle
* @return 0 when success otherwise error-code
**/
int IMOC_wait_dma(imoc_dma_request* request);
/**
* Tests if a IMOC_iget_data or IMOC_iput_data is completed.
*
* @param request \b in request-handle
* @param flag \b out true if operation is completed
* @return 0 when success otherwise error-code
**/
int IMOC_test_dma(imoc_dma_request* request, int *flag);
//@}
//@}
#endif /*MOC_INTERNAL_GET_DATA_H_*/