Software Drivers

xdmaps.h File Reference

#include "xparameters.h"
#include "xil_types.h"
#include "xil_assert.h"
#include "xstatus.h"
#include "xdmaps_hw.h"

Classes

struct  XDmaPs_Config
struct  XDmaPs_ChanCtrl
struct  XDmaPs_BD
struct  XDmaPs_Cmd
struct  XDmaPs_ProgBuf
struct  XDmaPs_ChannelData
struct  XDmaPs

Defines

#define XDMAPS_H
#define XDMAPS_MAX_CHAN_BUFS   2
#define XDMAPS_CHAN_BUF_LEN   128

Typedefs

typedef void(* XDmaPsDoneHandler )(unsigned int Channel, XDmaPs_Cmd *DmaCmd, void *CallbackRef)
typedef void(* XDmaPsFaultHandler )(unsigned int Channel, XDmaPs_Cmd *DmaCmd, void *CallbackRef)

Functions

int XDmaPs_CfgInitialize (XDmaPs *InstPtr, XDmaPs_Config *Config, u32 EffectiveAddr)
int XDmaPs_Start (XDmaPs *InstPtr, unsigned int Channel, XDmaPs_Cmd *Cmd, int HoldDmaProg)
int XDmaPs_IsActive (XDmaPs *InstPtr, unsigned int Channel)
int XDmaPs_GenDmaProg (XDmaPs *InstPtr, unsigned int Channel, XDmaPs_Cmd *Cmd)
int XDmaPs_FreeDmaProg (XDmaPs *InstPtr, unsigned int Channel, XDmaPs_Cmd *Cmd)
void XDmaPs_Print_DmaProg (XDmaPs_Cmd *Cmd)
int XDmaPs_ResetManager (XDmaPs *InstPtr)
int XDmaPs_ResetChannel (XDmaPs *InstPtr, unsigned int Channel)
int XDmaPs_SetDoneHandler (XDmaPs *InstPtr, unsigned Channel, XDmaPsDoneHandler DoneHandler, void *CallbackRef)
int XDmaPs_SetFaultHandler (XDmaPs *InstPtr, XDmaPsFaultHandler FaultHandler, void *CallbackRef)
void XDmaPs_DoneISR_0 (XDmaPs *InstPtr)
void XDmaPs_DoneISR_1 (XDmaPs *InstPtr)
void XDmaPs_DoneISR_2 (XDmaPs *InstPtr)
void XDmaPs_DoneISR_3 (XDmaPs *InstPtr)
void XDmaPs_DoneISR_4 (XDmaPs *InstPtr)
void XDmaPs_DoneISR_5 (XDmaPs *InstPtr)
void XDmaPs_DoneISR_6 (XDmaPs *InstPtr)
void XDmaPs_DoneISR_7 (XDmaPs *InstPtr)
void XDmaPs_FaultISR (XDmaPs *InstPtr)
XDmaPs_ConfigXDmaPs_LookupConfig (u16 DeviceId)
int XDmaPs_SelfTest (XDmaPs *InstPtr)

Detailed Description


Define Documentation

#define XDMAPS_CHAN_BUF_LEN   128
#define XDMAPS_H
#define XDMAPS_MAX_CHAN_BUFS   2

Typedef Documentation

typedef void(* XDmaPsDoneHandler)(unsigned int Channel, XDmaPs_Cmd *DmaCmd, void *CallbackRef)

It's the done handler a user can set for a channel

typedef void(* XDmaPsFaultHandler)(unsigned int Channel, XDmaPs_Cmd *DmaCmd, void *CallbackRef)

It's the fault handler a user can set for a channel


Function Documentation

int XDmaPs_CfgInitialize ( XDmaPs InstPtr,
XDmaPs_Config Config,
u32  EffectiveAddr 
)

Initializes a specific XDmaPs instance such that it is ready to be used. The data format of the device is setup for 8 data bits, 1 stop bit, and no parity by default. The baud rate is set to a default value specified by Config->DefaultBaudRate if set, otherwise it is set to 19.2K baud. The receive FIFO threshold is set for 8 bytes. The default operating mode of the driver is polled mode.

Parameters:
InstPtr is a pointer to the XDmaPs instance.
Config is a reference to a structure containing information about a specific XDmaPs driver.
EffectiveAddr is the device base address in the virtual memory address space. The caller is responsible for keeping the address mapping from EffectiveAddr to the device physical base address unchanged once this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called. If address translation is not used, pass in the physical address instead.
Returns:
  • XST_SUCCESS on initialization completion
Note:
None.
void XDmaPs_DoneISR_0 ( XDmaPs InstPtr  ) 

Driver done interrupt service routines for the channels. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC

Driver done interrupt service routine for channel 0. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC

Parameters:
InstPtr is the DMA instance.
Returns:
None.
Note:
None.
void XDmaPs_DoneISR_1 ( XDmaPs InstPtr  ) 

Driver done interrupt service routine for channel 1. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC

Parameters:
InstPtr is the DMA instance.
Returns:
None.
Note:
None.
void XDmaPs_DoneISR_2 ( XDmaPs InstPtr  ) 

Driver done interrupt service routine for channel 2. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC

Parameters:
InstPtr is the DMA instance.
Returns:
None.
Note:
None.
void XDmaPs_DoneISR_3 ( XDmaPs InstPtr  ) 

Driver done interrupt service routine for channel 3. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC

Parameters:
InstPtr is the DMA instance.
Returns:
None.
Note:
None.
void XDmaPs_DoneISR_4 ( XDmaPs InstPtr  ) 

Driver done interrupt service routine for channel 4. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC

Parameters:
InstPtr is the DMA instance.
Returns:
None.
Note:
None.
void XDmaPs_DoneISR_5 ( XDmaPs InstPtr  ) 

Driver done interrupt service routine for channel 5. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC

Parameters:
InstPtr is the DMA instance.
Returns:
None.
Note:
None.
void XDmaPs_DoneISR_6 ( XDmaPs InstPtr  ) 

Driver done interrupt service routine for channel 6. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC

Parameters:
InstPtr is the DMA instance.
Returns:
None.
Note:
None.
void XDmaPs_DoneISR_7 ( XDmaPs InstPtr  ) 

Driver done interrupt service routine for channel 7. We need this done ISR mainly because the driver needs to release the DMA program buffer. This is the one that connects the GIC

Parameters:
InstPtr is the DMA instance.
Returns:
None.
Note:
None.
void XDmaPs_FaultISR ( XDmaPs InstPtr  ) 

Driver fault interrupt service routine

Driver fault interrupt service routine This is the one that connects the GIC

Parameters:
InstPtr is the DMA instance.
Returns:
None.
Note:
None.
int XDmaPs_FreeDmaProg ( XDmaPs InstPtr,
unsigned int  Channel,
XDmaPs_Cmd Cmd 
)

Free the DMA program buffer that is pointed by the GeneratedDmaProg field of the command.

Parameters:
InstPtr is then DMA instance.
Channel is the DMA channel number.
Cmd is the DMA command.
Returns:
XST_SUCCESS on success. XST_FAILURE if there is any error.
Note:
None.
int XDmaPs_GenDmaProg ( XDmaPs InstPtr,
unsigned int  Channel,
XDmaPs_Cmd Cmd 
)

Generate a DMA program based for the DMA command, the buffer will be pointed by the GeneratedDmaProg field of the command.

Parameters:
InstPtr is then DMA instance.
Channel is the DMA channel number.
Cmd is the DMA command.
Returns:
- XST_SUCCESS on success.
  • XST_FAILURE if it fails
Note:
None.
int XDmaPs_IsActive ( XDmaPs InstPtr,
unsigned int  Channel 
)

Checks whether the DMA channel is active or idle.

Parameters:
InstPtr is the DMA instance.
Channel is the DMA channel number.
Returns:
0: if the channel is idle 1: otherwise
Note:
None.
XDmaPs_Config* XDmaPs_LookupConfig ( u16  DeviceId  ) 

Looks up the device configuration based on the unique device ID. The table contains the configuration info for each device in the system.

Parameters:
DeviceId contains the ID of the device
Returns:

A pointer to the configuration structure or NULL if the specified device is not in the system.

Note:

None.

void XDmaPs_Print_DmaProg ( XDmaPs_Cmd Cmd  ) 

Print the Dma Prog Contents.

Parameters:
Cmd is the command buffer.
Returns:
None.
Note:
None.
int XDmaPs_ResetChannel ( XDmaPs InstPtr,
unsigned int  Channel 
)

Reset the specified DMA Channel.

Parameters:
InstPtr is the DMA instance.
Channel is the channel to be reset.
Returns:
0 on success, -1 on time out
Note:
None.
int XDmaPs_ResetManager ( XDmaPs InstPtr  ) 

Reset the DMA Manager.

Parameters:
InstPtr is the DMA instance.
Returns:
0 on success, -1 on time out
Note:
None.
int XDmaPs_SelfTest ( XDmaPs InstPtr  ) 

This function runs a self-test on the driver and hardware device. This self test performs a local loopback and verifies data can be sent and received.

The time for this test is proportional to the baud rate that has been set prior to calling this function.

The mode and control registers are restored before return.

Parameters:
InstPtr is a pointer to the XDmaPs instance
Returns:
  • XST_SUCCESS if the test was successful
  • XST_FAILURE if the test failed
Note:

This function can hang if the hardware is not functioning properly.

int XDmaPs_SetDoneHandler ( XDmaPs InstPtr,
unsigned  Channel,
XDmaPsDoneHandler  DoneHandler,
void *  CallbackRef 
)

Set the done handler for a channel.

Parameters:
InstPtr is the DMA instance.
Channel is the channel number.
DoneHandler is the done interrupt handler.
CallbackRef is the callback reference data.
Returns:
None.
Note:
None.
int XDmaPs_SetFaultHandler ( XDmaPs InstPtr,
XDmaPsFaultHandler  FaultHandler,
void *  CallbackRef 
)

Set the fault handler for a channel.

Parameters:
InstPtr is the DMA instance.
FaultHandler is the fault interrupt handler.
CallbackRef is the callback reference data.
Returns:
None.
Note:
None.
int XDmaPs_Start ( XDmaPs InstPtr,
unsigned int  Channel,
XDmaPs_Cmd Cmd,
int  HoldDmaProg 
)

Start a DMA command. The command can only be invoked when the channel is idle. The driver takes the command, generates DMA program if needed, then pass the program to DMAC to execute.

Parameters:
InstPtr is then DMA instance.
Channel is the DMA channel number.
Cmd is the DMA command.
HoldDmaProg is tag indicating whether the driver can release the allocated DMA buffer or not. If a user wants to examine the generated DMA program, the flag should be set to 1. After the DMA program is finished, a user needs to explicity free the buffer.
Returns:
  • XST_SUCCESS on success
  • XST_DEVICE_BUSY if DMA is busy
  • XST_FAILURE on other failures
Note:
None.