scugic
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Macros Groups Pages
xscugic_low_level_example.c File Reference

Overview

This file contains a design example using the low level driver, interface of the Interrupt Controller driver.

This example shows the use of the Interrupt Controller with the ARM processor.

MODIFICATION HISTORY:
Ver   Who  Date     Changes


1.00a drg 01/30/10 First release 3.10 mus 09/19/18 Update prototype of LowInterruptHandler to fix the GCC warning 4.0 mus 01/28/19 Updated to support Cortexa72 GIC (GIC500). 5.0 adk 04/18/22 Replace infinite while loop with Xil_WaitForEventSet() API. adk 20/07/22 Update the Xil_WaitForEventSet() API arguments as per latest API. 5.1 mus 02/15/23 Added support for VERSAL_NET. 5.2 dp 06/20/23 Make interrupt as Group1 interrupt for Cortex-R52. 5.5 ml 12/20/24 Fixed GCC warnings 5.6 ml 07/21/25 Fixed GCC warnings

#include <stdio.h>
#include "xparameters.h"
#include "xil_exception.h"
#include "xscugic_hw.h"
#include "xil_printf.h"
#include "xstatus.h"
#include "xscugic.h"
#include "xil_util.h"

Macros

#define XSCUGIC_DIST_BASEADDR   XPAR_XSCUGIC_0_BASEADDR
 Base address of the GIC distributor. More...
 
#define GIC_DEVICE_INT_MASK   0x02010003
 Bits [25:24]: target-list filter; [23:16]: CPU target; [3:0]: SGI ID. More...
 
#define XSCUGIC_SW_TIMEOUT_VAL   10000000U
 Software timeout value in clock cycles. More...
 
#define DEFAULT_PRIORITY   0xa0a0a0a0UL
 Default priority value for all interrupt lines. More...
 
#define DEFAULT_TARGET   0x01010101UL
 Default target CPU mask. More...
 

Functions

void SetupInterruptSystem (void)
 This function connects the interrupt handler of the interrupt controller to the processor. More...
 
void LowInterruptHandler (void *CallbackRef)
 Simulates a device driver interrupt handler for the example. More...
 
int main (void)
 This is the main function for the Interrupt Controller Low Level example. More...
 

Macro Definition Documentation

#define DEFAULT_PRIORITY   0xa0a0a0a0UL

Default priority value for all interrupt lines.

#define DEFAULT_TARGET   0x01010101UL

Default target CPU mask.

#define GIC_DEVICE_INT_MASK   0x02010003

Bits [25:24]: target-list filter; [23:16]: CPU target; [3:0]: SGI ID.

#define XSCUGIC_DIST_BASEADDR   XPAR_XSCUGIC_0_BASEADDR

Base address of the GIC distributor.

#define XSCUGIC_SW_TIMEOUT_VAL   10000000U

Software timeout value in clock cycles.

Function Documentation

void LowInterruptHandler ( void *  CallbackRef)

Simulates a device driver interrupt handler for the example.

This is typically a 2nd level handler that is called from the interrupt controller interrupt handler. This handler would typically perform device specific processing such as reading and writing the registers of the device to clear the interrupt condition and pass any data to an application using the device driver.

Parameters
[in]CallbackRefis passed back to the device driver's interrupt handler by the XScuGic driver. It was given to the XScuGic driver in the XScuGic_Connect() function call. It is typically a pointer to the device driver instance variable if using the Xilinx Level 1 device drivers. In this example, we are passing it as scugic cpu interface base address to access ack and EOI registers.

References XSCUGIC_ACK_INTID_MASK, XSCUGIC_EOI_OFFSET, XSCUGIC_INT_ACK_OFFSET, XSCUGIC_MAX_NUM_INTR_INPUTS, XScuGic_ReadReg, and XScuGic_WriteReg.

Referenced by SetupInterruptSystem().

int main ( void  )

This is the main function for the Interrupt Controller Low Level example.

Returns
XST_SUCCESS to indicate success, otherwise XST_FAILURE.
void SetupInterruptSystem ( void  )

This function connects the interrupt handler of the interrupt controller to the processor.

This function is separate to allow it to be customized for each application. Each processor or RTOS may require unique processing to connect the interrupt handler.

References XScuGic_Config::CpuBaseAddress, and LowInterruptHandler().