DE10-Advanced revC demo: PCI Express Library API

From Terasic Wiki

(Difference between revisions)
Jump to: navigation, search
Line 2: Line 2:
<div style="color:#404040;">Note: the Linux library terasic_pcie_qsys.so also use the same API and header file.</div>
<div style="color:#404040;">Note: the Linux library terasic_pcie_qsys.so also use the same API and header file.</div>
-
* <div style="margin-left:0cm;margin-right:0cm;">'''PCIE_Open'''</div>
 
 +
 +
<div style="margin-left:0cm;margin-right:0cm;"></div>* '''PCIE_Open'''
{| style="border-spacing:0;width:15.251cm;"
{| style="border-spacing:0;width:15.251cm;"
Line 44: Line 45:
|-
|-
|}
|}
 +
<div style="margin-left:0cm;margin-right:0cm;"></div>* '''PCIE_Close'''
<div style="margin-left:0cm;margin-right:0cm;"></div>* '''PCIE_Close'''
-
 
-
 
Line 54: Line 54:
|| '''Function:'''
|| '''Function:'''
-
Close a handle associated to the PCIe card.
+
:Close a handle associated to the PCIe card.
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|| '''Prototype:'''
|| '''Prototype:'''
Line 60: Line 60:
void PCIE_Close(
void PCIE_Close(
-
PCIE_HANDLE hPCIE);
+
:PCIE_HANDLE hPCIE);
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|| '''Parameters:'''
|| '''Parameters:'''
-
hPCIE:  
+
:hPCIE:  
-
A PCIe handle return by PCIE_Open function.
+
::A PCIe handle return by PCIE_Open function.
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|| '''Return Value:'''
|| '''Return Value:'''
-
None.
+
:None.
|-
|-
|}
|}
Line 83: Line 83:
|| '''Function:'''
|| '''Function:'''
-
Read a 32-bit data from the FPGA board.
+
:Read a 32-bit data from the FPGA board.
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|| '''Prototype:'''
|| '''Prototype:'''
-
bool PCIE_Read32(
+
:bool PCIE_Read32(
-
PCIE_HANDLE hPCIE,
+
::PCIE_HANDLE hPCIE,
-
PCIE_BAR PcieBar,  
+
::PCIE_BAR PcieBar,  
-
PCIE_ADDRESS PcieAddress,  
+
::PCIE_ADDRESS PcieAddress,  
-
uint32_t *pdwData);
+
::uint32_t *pdwData);
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|| '''Parameters:'''
|| '''Parameters:'''
-
hPCIE:  
+
:hPCIE:  
-
A PCIe handle return by PCIE_Open function.
+
::A PCIe handle return by PCIE_Open function.
-
PcieBar:  
+
:PcieBar:  
-
Specify the target BAR.
+
::Specify the target BAR.
-
PcieAddress:  
+
:PcieAddress:  
-
Specify the target address in FPGA.
+
::Specify the target address in FPGA.
-
pdwData:  
+
:pdwData:  
-
A buffer to retrieve the 32-bit data.
+
::A buffer to retrieve the 32-bit data.
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|- style="background-color:#e6e6e6;border:0.5pt solid #00000a;padding:0cm;"
|| '''Return Value:'''
|| '''Return Value:'''
-
Return '''true''' if read data is successful; otherwise '''false''' is returned.
+
:Return '''true''' if read data is successful; otherwise '''false''' is returned.
|-
|-
|}
|}

Revision as of 15:47, 27 August 2018

Below shows the exported API in the TERASIC_PCIE_AVMM.dll. The API prototype is defined in the TERASIC_PCIE_AVMM.h.
Note: the Linux library terasic_pcie_qsys.so also use the same API and header file.


* PCIE_Open
Function:
Open a specified PCIe card with vendor ID, device ID, and matched card index.
Prototype:
PCIE_HANDLE PCIE_Open(
uint8_t wVendorID,
uint8_t wDeviceID,
uint8_t wCardIndex);
Parameters:
wVendorID:
Specify the desired vendor ID. A zero value means to ignore the vendor ID.
wDeviceID:
Specify the desired device ID. A zero value means to ignore the device ID.
wCardIndex:
Specify the matched card index, a zero based index, based on the matched vendor ID and device ID.
Return Value:
Return a handle to presents specified PCIe card. A positive value is return if the PCIe card is opened successfully. A value zero means failed to connect the target PCIe card.
This handle value is used as a parameter for other functions, e.g. PCIE_Read32.
Users need to call PCIE_Close to release handle once the handle is no more used.


* PCIE_Close


Function:
Close a handle associated to the PCIe card.
Prototype:

void PCIE_Close(

PCIE_HANDLE hPCIE);
Parameters:
hPCIE:
A PCIe handle return by PCIE_Open function.
Return Value:
None.
  • PCIE_Read32



Function:
Read a 32-bit data from the FPGA board.
Prototype:
bool PCIE_Read32(
PCIE_HANDLE hPCIE,
PCIE_BAR PcieBar,
PCIE_ADDRESS PcieAddress,
uint32_t *pdwData);
Parameters:
hPCIE:
A PCIe handle return by PCIE_Open function.
PcieBar:
Specify the target BAR.
PcieAddress:
Specify the target address in FPGA.
pdwData:
A buffer to retrieve the 32-bit data.
Return Value:
Return true if read data is successful; otherwise false is returned.
  • PCIE_Write32



Function:

Write a 32-bit data to the FPGA Board.

Prototype:

bool PCIE_Write32(

PCIE_HANDLE hPCIE,

PCIE_BAR PcieBar,

PCIE_ADDRESS PcieAddress,

uint32_t dwData);

Parameters:

hPCIE:

A PCIe handle return by PCIE_Open function.

PcieBar:

Specify the target BAR.

PcieAddress:

Specify the target address in FPGA.

dwData:

Specify a 32-bit data which will be written to FPGA board.

Return Value:

Return true if write data is successful; otherwise false is returned.

1

  • PCIE_Read8



Function:

Read an 8-bit data from the FPGA board.

Prototype:

bool PCIE_Read8(

PCIE_HANDLE hPCIE,

PCIE_BAR PcieBar,

PCIE_ADDRESS PcieAddress,

uint8_t *pByte);

Parameters:

hPCIE:

A PCIe handle return by PCIE_Open function.

PcieBar:

Specify the target BAR.

PcieAddress:

Specify the target address in FPGA.

pByte:

A buffer to retrieve the 8-bit data.

Return Value:

Return true if read data is successful; otherwise false is returned.

  • PCIE_Write8



Function:

Write an 8-bit data to the FPGA Board.

Prototype:

bool PCIE_Write8(

PCIE_HANDLE hPCIE,

PCIE_BAR PcieBar,

PCIE_ADDRESS PcieAddress,

uint8_t Byte);

Parameters:

hPCIE:

A PCIe handle return by PCIE_Open function.

PcieBar:

Specify the target BAR.

PcieAddress:

Specify the target address in FPGA.

Byte:

Specify an 8-bit data which will be written to FPGA board.

Return Value:

Return true if write data is successful; otherwise false is returned.

  • PCIE_DmaRead



Function:

Read data from the memory-mapped memory of FPGA board in DMA.

Maximal read size is (4GB-1) bytes.

Prototype:

bool PCIE_DmaRead(

PCIE_HANDLE hPCIE,

PCIE_LOCAL_ADDRESS LocalAddress,

void *pBuffer,

uint32_t dwBufSize

);

Parameters:

hPCIE:

A PCIe handle return by PCIE_Open function.

LocalAddress:

Specify the target memory-mapped address in FPGA.

pBuffer:

A pointer to a memory buffer to retrieved the data from FPGA. The size of buffer should be equal or larger the dwBufSize.

dwBufSize:

Specify the byte number of data retrieved from FPGA.

Return Value:

Return true if read data is successful; otherwise false is returned.

  • PCIE_DmaWrite



Function:

Write data to the memory-mapped memory of FPGA board in DMA.

Prototype:

bool PCIE_DmaWrite(

PCIE_HANDLE hPCIE,

PCIE_LOCAL_ADDRESS LocalAddress,

void *pData,

uint32_t dwDataSize

);

Parameters:

hPCIE:

A PCIe handle return by PCIE_Open function.

LocalAddress:

Specify the target memory mapped address in FPGA.

pData:

A pointer to a memory buffer to store the data which will be written to FPGA.

dwDataSize:

Specify the byte number of data which will be written to FPGA.

Return Value:

Return true if write data is successful; otherwise false is returned.

  • PCIE_ConfigRead32



Function:

Read PCIe Configuration Table. Read a 32-bit data by given a byte offset.

Prototype:

bool PCIE_ConfigRead32 (

PCIE_HANDLE hPCIE,

uint32_t Offset,

uint32_t *pdwData

);

Parameters:

hPCIE:

A PCIe handle return by PCIE_Open function.

Offset:

Specify the target byte of offset in PCIe configuration table.

pdwData:

A 4-bytes buffer to retrieve the 32-bit data.

Return Value:

Return true if read data is successful; otherwise false is returned.