xilsem
Vitis Drivers API Documentation
xsem_npi_example_pl_mb.c File Reference

Overview

This file demonstrates on how to use XilSEM NPI client interface on PL Microblaze to send commands to PLM firmware and read responses from PLM.

Note
The default linker settings places a software stack, heap and data in PL MB memory. For this example to work, any data shared between client running on PL and server running on PMC, should be placed in area which is accessible to both client and server.

Following is the procedure to provide shared memory region which can be accessed by server

In linker script(lscript.ld) user can add new memory section in source tab as shown below

            .sem_decdata : {
                    KEEP (*(.sem_decdata))
            } > axi_noc_0_C0_DDR_LOW0
MODIFICATION HISTORY:
Ver   Who       Date        Changes


0.1 gupta 11/16/2022 Initial Creation 0.2 anv 10/18/2023 Added macro to Enable Error Injection Feature usage and Updated Xilsem prints to get Npi status information and Added Test print summary 0.3 gam 01/02/2023 Fixed IPI interrupt ID for PL MB Versal Net, Removed false else condition in main function for XSem_CmdNpiGetStatus API as this is not a valid case for deferred start-up.

Macros

#define INTC_DEVICE_IPI_INT_ID   XPAR_AXI_INTC_0_VERSAL_CIPS_0_PSPMC_0_PS_PL_IRQ_LPD_IPI_IPI1_INTR
 Interrupt Number of IPI whose interrupt output is connected to the input of the Interrupt Controller. More...
 

Functions

XStatus XSem_ApiCheckScanCount (XSemNpiStatus *NpiStatus)
 
XStatus XSem_ApiCheckHbtCount (XSemNpiStatus *NpiStatus)
 
int XSem_NpiEventRegisterNotifier (u32 Enable)
 
int SetUpInterruptSystem (XIntc *XIntcInstancePtr)
 This function connects the IPI interrupts to the interrupt controller and to the processor. More...
 
int IntcAndIpiInit (void)
 This function initializes Interrupt Controller and IPI drivers. More...
 
int main (void)
 The purpose of this function is to illustrate the usage of client APIs for NPI scan over IPI. More...
 

Macro Definition Documentation

#define INTC_DEVICE_IPI_INT_ID   XPAR_AXI_INTC_0_VERSAL_CIPS_0_PSPMC_0_PS_PL_IRQ_LPD_IPI_IPI1_INTR

Interrupt Number of IPI whose interrupt output is connected to the input of the Interrupt Controller.

Referenced by SetUpInterruptSystem().

Function Documentation

int IntcAndIpiInit ( void  )

This function initializes Interrupt Controller and IPI drivers.

Returns
XST_SUCCESS to indicate success, otherwise XST_FAILURE.

Initialize the interrupt controller driver so that it is ready to use.

Perform a self-test to ensure that the hardware was built correctly.

References SetUpInterruptSystem().

int main ( void  )

The purpose of this function is to illustrate the usage of client APIs for NPI scan over IPI.

Returns
  • XST_SUCCESS - on successful execution of injection and detection of error
  • XST_FAILURE - on failure
Note
Npi example always injects error in the golden SHA of the first descriptor. The injected SHA error can be corrected by executing the error injection sequence again. Real SHA errors are uncorrectable.

Disable cache to get the shared buffer data from physical memory which is updated by PLM in response to NPI commands

Initialize IPI Driver This initialization is required to get XilSEM event notifications from PLM

The following sequence demonstrates how to inject errors in NPI

  1. Stop NPI scan
  2. Read current Golden SHA from descriptors
  3. Inject error
  4. Start NPI scan
  5. Read for Golden SHA mismatch error
  6. Read current Golden SHA from descriptors Note: Execute the sequence again to correct the injected error, but the error status will remain till POR. Note: For Error injection feature check enable XILSEM_ERRINJ_ENABLE macro

References CMD_ACK_NPI_ERRINJECT, CMD_ACK_NPI_GET_GLDN_SHA, CMD_ACK_NPI_STARTSCAN, CMD_ACK_NPI_STOPSCAN, XSem_DescriptorData::DescriptorCount, XSemNpiStatus::ErrInfo, XSemNpiStatus::HbCnt, IntcAndIpiInit(), MAX_NPI_ERR_INFO_CNT, MAX_NPI_SLV_SKIP_CNT, XSemIpiResp::RespMsg1, XSemIpiResp::RespMsg2, XSemNpiStatus::ScanCnt, XSemNpiStatus::SlvSkipCnt, XSemNpiStatus::Status, XSem_ApiCheckScanCount(), XSem_CmdNpiGetGldnSha(), XSem_CmdNpiGetStatus(), XSem_CmdNpiInjectError(), XSem_CmdNpiStartScan(), XSem_CmdNpiStopScan(), and XSem_NpiEventRegisterNotifier().

int SetUpInterruptSystem ( XIntc *  XIntcInstancePtr)

This function connects the IPI interrupts to the interrupt controller and to the processor.

Parameters
Intcinstance pointer.
Returns
Status : Success or Failure

Connect IPI interrupt handler that will be called when an interrupt for the IPI occurs, the IPI interrupt handler performs the specific interrupt processing for IPI.

Start the interrupt controller such that interrupts are enabled for all devices that cause interrupts.

References INTC_DEVICE_IPI_INT_ID.

XStatus XSem_ApiCheckHbtCount ( XSemNpiStatus NpiStatus)

Small delay to ensure NPI scan progresses before second read. The delay value assumes 100ms as NPI scan interval

References XSemNpiStatus::HbCnt, and XSem_CmdNpiGetStatus().

XStatus XSem_ApiCheckScanCount ( XSemNpiStatus NpiStatus)

Small delay to ensure NPI scan progresses before second read. The delay value assumes 100ms as NPI scan interval

References XSemNpiStatus::ScanCnt, and XSem_CmdNpiGetStatus().

Referenced by main().

int XSem_NpiEventRegisterNotifier ( u32  Enable)

In this example all NPI events are enabled If you want to enable particular event set the Event member in Notifier structure with corresponding event.

References XSem_Notifier::Flag, and XSem_RegisterEvent().

Referenced by main().