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

149 lines
5.4 KiB
C
Executable File

#ifndef MOC_INTERNAL_DATA_TRANSFER_PPU_H_
#define MOC_INTERNAL_DATA_TRANSFER_PPU_H_
#include <stdint.h>
#include "../../moc.h"
/**
* \addtogroup internal_p2p_dma
**/
//@{
/**
* @name PPU-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.
*
* On the ppu the system for tag reservation is not present, so a hardcoded tag is used.
* It has also to be noted that the dma calls are actually initiated on the spu by the ppu.
*
* @param target \b in local-address of buffer
* @param source \b in ea-address of data
* @param size \b in size of data in byte
* @param dest \b in id of source spe
* @return 0 when success otherwise error-code
**/
int IMOC_get_data(void* target, uint64_t source, uint32_t size, int dest);
/**
* 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.
*
* On the ppu the system for tag reservation is not present, so a hardcoded tag is used.
* It has also to be noted that the dma calls are actually initiated on the spu by the ppu.
*
* @param source \b in local-address of data
* @param target \b in ea-address of buffer
* @param size \b in size of data in byte
* @param dest \b in id of source spe
* @return 0 when success otherwise error-code
**/
int IMOC_put_data(void* source, uint64_t target, uint32_t size, int dest);
/**
* 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.
*
* On the ppu the system for tag reservation is not present, so a hardcoded tag is used.
* It has also to be noted that the dma calls are actually initiated on the spu by the ppu.
*
* @param target \b in local-address of buffer
* @param source \b in ea-address of data
* @param size \b in size of data in byte
* @param dest \b in id of source spe
* @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, uint32_t dest, imoc_dma_request* request);
/**
* Internal wrapper-function for a non-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.
*
* On the ppu the system for tag reservation is not present, so a hardcoded tag is used.
* It has also to be noted that the dma calls are actually initiated on the spu by the ppu.
*
* @param source \b in local-address of data
* @param target \b in ea-address of buffer
* @param size \b in size of data in byte
* @param dest \b in id of source spe
* @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, uint32_t dest, 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);
/**
* Reserves a tag on the ppu, for communication with a given spu.
*
* @param speid \b id of spu to communicate with
* @return tag (0-14) when success otherwise error code
**/
int moc_tag_reserve(unsigned int speid);
/**
* Releases a reserved tag.
*
* @param speid \b id of spu for which the tag was reserved
* @param tag \b tag to be released
* @return 0 when success otherwise error-code
**/
int moc_tag_release(unsigned int speid, int tag);
//@}
//@}
#endif /*MOC_INTERNAL_DATA_TRANSFER_PPU_H_*/