Configuring the XMPU_PL in the PMU Scheduler

Memory and Peripheral Protection Unit for PL Isolation in Zynq UltraScale+ Devices (XAPP1353)

Document ID
Release Date
v1.1 English

The PMU scheduler is used to periodically call a task. In this example, a scheduler task is used to initialize and configure the XMPU_PL. While it only needs to be initialized once, the task needs to wait until PL configuration and start up are complete. A flag indicates whether the XMPU_PL has already been initialized.

The xpfw_pl_xmpu.h header file provides API declarations for the following functions:

void XMpuPl_PmuTaskInit(const XPfw_Module_t*SchModPtr);

Task initialization function registers the Task function in the scheduler.

void XMpuPl_PmuTask(void);

The Task function is periodically called by the scheduler at a defined interval.

void XmpuPl_Interrupt_Handler(u8 ErrorId);

The interrupt handler for the XMPU_PL is called by the PMU Error Manager.

To schedule the task, a function call to XMpuPl_PmuTaskInit is added to the SchCfgInit function in xpfw_mod_sched.c, shown in the following figure.

Figure 1. Scheduler Task Initialization in xpfw_mod_sched.c

The source file xpfw_pl_xmpu.c and header file xpfw_pl_xmpu.h are not a part of the standard PMU source nor is it from the zupl_xmpu SW driver set. These are examples of user-created files, created specifically for this demonstration.

The following figure shows the XMpuPl_PmuTaskInit function. The XPfw_CoreScheduleTask API function schedules the XMpuPl_PmuTask task as a callback function in the scheduler. The XMPUPL_TASK_INTERVAL sets a callback period of 25 ms.

Figure 2. XMpuPl_PmuTaskInit Function in xpfw_pl_xmpu.c

The xpfw_pl_xmpu.c file defines two static variables:

static u8 XMpuPl_Initialized = {0U};
        Flag to indicate XMPU_PL initialization status.

        static XmpuPl XmpuInst;
        XMPU_PL instance.

The XMpuPl_PmuTask function is shown in the following figure. First, it checks the XMpuPl_Initialized flag to see if the XMPU_PL needs to be initialized. Next, it checks the PCAP Status to see if the PL configuration is DONE and has reached the end of start up (EOS). Then it calls the configureXMPU function. If the configureXMPU function completes successfully, then the XMpuPl_Initialized flag is set.

Figure 3. XMpuPl_PmuTask function in xpfw_pl_xmpu.c
Tip: Though it is not necessary to do so, once the XMPU_PL has been configured, the XMpuPl_PmuTask function can be removed from the scheduler, using the XPfw_CoreRemoveTask, to avoid continuing to unnecessarily task the PMU. This is left as an exercise for the reader.

The configureXMPU function, shown in the previous figure, first initializes the XmpuPl instance, and then configures the XMPU_PL core. Only one instance is needed for this demonstration design, however, the Simple XMPU_PL (RPU) Example demonstrates initialization for any number of instances.

The SW Driver functions that configures the XMPU_PL are shown in Appendix B: SW Driver Library. See thexpfw_pl_xmpu.h header file for the macro definitions of the constants used in the configureXMPU function.

Figure 4. configureXMPU Function in xpfw_pl_xmpu.c