libsysve  3.1.0
VE DMA

VE DMA is a DMA data transfer feature for VE programs. More...

Data Structures

struct  ve_dma_handle_t
 This structure holds the state of the asynchronous DMA. More...
 

Functions

int ve_dma_init (void)
 This function initializes VE DMA feature. More...
 
int ve_dma_post (uint64_t dst, uint64_t src, int size, ve_dma_handle_t *handle)
 This function issues asynchronous DMA. More...
 
int ve_dma_poll (ve_dma_handle_t *handle)
 This function inquiries the completion of asynchronous DMA. More...
 
int ve_dma_wait (ve_dma_handle_t *handle)
 This function iterates over the inquiry until it completes the asynchronous DMA,. More...
 
int ve_dma_post_wait (uint64_t dst, uint64_t src, int size)
 This function issues synchronous DMA. More...
 
uint64_t ve_register_mem_to_dmaatb (void *vemva, size_t size)
 This function registers VE local memory to DMAATB. More...
 
int ve_unregister_mem_from_dmaatb (uint64_t vehva)
 This function unregisters VE local memory from DMAATB. More...
 

Variables

int ve_dma_handle_t::status
 
int ve_dma_handle_t::index
 

Detailed Description

VE DMA is a DMA data transfer feature for VE programs.

Please include "vedma.h" in the source file. Please specify "-lveio -pthread" option to the compiler driver to link libveio.

Note
A source and a destination of DMA data transfer are specified by VE host virtual address. To obtain VE host virtual address, you need to register memory to DMAATB.
A source and a destination of DMA data transfer needs to be aligned on a 4 byte boundary.
Data transfer size needs to be a multiple of 4 and less than 128MB.

Function Documentation

int ve_dma_init ( void  )

This function initializes VE DMA feature.

Note
When the VE program invokes this function multiple times, this function simply returns 0.
Before using VE DMA, invoke this function to initialize VE DMA.
When a child process is created by fork(), vfork(), the state of VE DMA is not inherited to the child process. This function should be invoked from the child process.
Return values
0On success
-1On failure
Examples:
vedma/dma.c.
int ve_dma_post ( uint64_t  dst,
uint64_t  src,
int  size,
ve_dma_handle_t handle 
)

This function issues asynchronous DMA.

Note
This function writes the DMA transfer request to the DMA descriptor table.
Parameters
[in]dst4 byte aligned VE host virtual address of destination
[in]src4 byte aligned VE host virtual address of source
[in]sizeTransfer size which is a multiple of 4 and less than 128MB
[out]handleHandle used to inquire DMA completion
Return values
0On success
-EAGAINThe DMA using the DMA descriptor to be used next is not yet completed
Need to call ve_dma_post() again.
int ve_dma_poll ( ve_dma_handle_t handle)

This function inquiries the completion of asynchronous DMA.

Note
This function inquiries the completion of DMA transfer request issued by ve_dma_post().
Parameters
[in]handleDMA transfer request issued by ve_dma_post()
Return values
0DMA completed normally
1-65535DMA failed
Exception value of DMA descriptor is returned.
DMA failed. The value is bitwise ORed combination of the values described below.
  • 0x8000: Memory protection exception
  • 0x4000: Missing page exception
  • 0x2000: Missing space exception
  • 0x1000: Memory access exception
  • 0x0800: I/O access exception
-EAGAINDMA has not completed yet
Need to call ve_dma_poll() again
int ve_dma_wait ( ve_dma_handle_t handle)

This function iterates over the inquiry until it completes the asynchronous DMA,.

Note
This function iterates over the inquiry the completion of DMA transfer request
issued by ve_dma_post(), until it completes the asynchronous DMA.
Parameters
[in]handleDMA transfer request issued by ve_dma_post()
Return values
0DMA completed normally
1-65535DMA failed
Exception value of DMA descriptor is returned.
DMA failed. The value is bitwise ORed combination of the values described below.
  • 0x8000: Memory protection exception
  • 0x4000: Missing page exception
  • 0x2000: Missing space exception
  • 0x1000: Memory access exception
  • 0x0800: I/O access exception
int ve_dma_post_wait ( uint64_t  dst,
uint64_t  src,
int  size 
)

This function issues synchronous DMA.

Note
This function writes the DMA transfer request to the DMA descriptor table, and waits for finish.
Parameters
[in]dst4 byte aligned VE host virtual address of destination
[in]src4 byte aligned VE host virtual address of source
[in]sizeTransfer size which is a multiple of 4 and less than 128MB
Return values
0On success
1-65535DMA failed
Exception value of DMA descriptor is returned.
DMA failed. The value is bitwise ORed combination of the values described below.
  • 0x8000: Memory protection exception
  • 0x4000: Missing page exception
  • 0x2000: Missing space exception
  • 0x1000: Memory access exception
  • 0x0800: I/O access exception
Examples:
vedma/dma.c.
uint64_t ve_register_mem_to_dmaatb ( void *  vemva,
size_t  size 
)

This function registers VE local memory to DMAATB.

Note
The default value of VE page size is 64MB.
In this case, values of vemva and size need to be aligned with 64MB boundary.
If VE page size is 2MB, values of vemva and size need to be aligned with 2MB boundary.
Parameters
[in]vemvaAn address of memory to be registered
The address needs to be aligned with 64MB boundary.
[in]sizeSize of memory aligned aligned with 64MB boundary
Return values
vehvaVE host virtual address on success
0xffffffffffffffffOn failure
  • EINVAL Invalid argument
  • EFAULT Bad address
  • ESRCH No such process
  • ENOENT No such memory
  • EACCES Permission denied
  • ECANCEL Operation canceled
Examples:
vedma/dma.c.
int ve_unregister_mem_from_dmaatb ( uint64_t  vehva)

This function unregisters VE local memory from DMAATB.

Parameters
[in]vehvaVE host virtual address of memory to be unregistered
Return values
0On success
-1On failure
  • EINVAL Invalid argument
  • ECANCELED No such memory
Examples:
vedma/dma.c.