protect header file and reformat/cleanup code
authorSam Sortais <sam.sortais@xilinx.com>
Fri, 27 Jan 2017 03:18:29 +0000 (19:18 -0800)
committerWendy Liang <jliang@xilinx.com>
Wed, 8 Feb 2017 00:21:32 +0000 (16:21 -0800)
protect rsc_table.h from multiple inclusion
add/rm comments and include files
rename funcs/var to match zynq/zynqmp code

Signed-off-by: Sam Sortais <sam.sortais@xilinx.com>
apps/system/generic/machine/zynq7/helper.c
apps/system/generic/machine/zynqmp_r5/helper.c
apps/system/linux/machine/generic/rsc_table.h

index 690ea5df5261e80d7f4529b69af3162ea26f90d3..eef12590224e780708e6303527048bf9cbe05cb9 100755 (executable)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2014, Mentor Graphics Corporation
  * All rights reserved.
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#include <string.h>
+
 #include "xparameters.h"
 #include "xil_exception.h"
 #include "xscugic.h"
 #include "xil_cache.h"
 #include "metal/sys.h"
+#include "metal/irq.h"
+#include "platform_info.h"
 
-#define INTC_DEVICE_ID         XPAR_SCUGIC_0_DEVICE_ID
-/** IPI IRQ ID */
-#define VRING0_IPI_VECT         15
-#define VRING1_IPI_VECT         14
 
-XScuGic InterruptController;
+#define INTC_DEVICE_ID         XPAR_SCUGIC_0_DEVICE_ID
 
-extern void metal_irq_isr(unsigned int irq);
+static XScuGic xInterruptController;
 
-int zynq_a9_gic_initialize()
+/* Interrupt Controller setup */
+static int app_gic_initialize(void)
 {
        u32 Status;
+       XScuGic_Config *IntcConfig;     /* The configuration parameters of the interrupt controller */
 
        Xil_ExceptionDisable();
 
-       XScuGic_Config *IntcConfig;     /* The configuration parameters of the interrupt controller */
-
        /*
         * Initialize the interrupt controller driver
         */
@@ -61,7 +58,7 @@ int zynq_a9_gic_initialize()
                return XST_FAILURE;
        }
 
-       Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
+       Status = XScuGic_CfgInitialize(&xInterruptController, IntcConfig,
                                       IntcConfig->CpuBaseAddress);
        if (Status != XST_SUCCESS) {
                return XST_FAILURE;
@@ -73,32 +70,42 @@ int zynq_a9_gic_initialize()
         */
        Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
                        (Xil_ExceptionHandler)XScuGic_InterruptHandler,
-                       &InterruptController);
+                       &xInterruptController);
 
        Xil_ExceptionEnable();
+
        /* Connect IPI0 Interrupt ID with ISR */
-       XScuGic_Connect(&InterruptController, VRING0_IPI_VECT,
-                          (Xil_ExceptionHandler)metal_irq_isr,
-                          (void *)VRING0_IPI_VECT);
+       XScuGic_Connect(&xInterruptController, VRING0_IPI_INTR_VECT,
+                       (Xil_ExceptionHandler)metal_irq_isr,
+                       (void *)VRING0_IPI_INTR_VECT);
 
        /* Connect IPI1 Interrupt ID with ISR */
-       XScuGic_Connect(&InterruptController, VRING1_IPI_VECT,
-                          (Xil_ExceptionHandler)metal_irq_isr,
-                          (void *)VRING1_IPI_VECT);
+       XScuGic_Connect(&xInterruptController, VRING1_IPI_INTR_VECT,
+                       (Xil_ExceptionHandler)metal_irq_isr,
+                       (void *)VRING1_IPI_INTR_VECT);
+
        return 0;
 }
 
-void init_system()
+/* Main hw machinery initialization entry point, called from main()*/
+/* return 0 on success */
+int init_system(void)
 {
        struct metal_init_params metal_param = METAL_INIT_DEFAULTS;
 
+       /* Low level abstraction layer for openamp initialization */
        metal_init(&metal_param);
-       zynq_a9_gic_initialize();
+
+       /* configure the global interrupt controller */
+       app_gic_initialize();
+
+       return 0;
 }
 
 void cleanup_system()
 {
        metal_finish();
+
        Xil_DCacheDisable();
        Xil_ICacheDisable();
        Xil_DCacheInvalidate();
index 066e666dc5d4cd1424a1dd44a7b287f25f0aba6f..a6d4fc60ab97f4fd2ad61430e8af29665039204e 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2014, Mentor Graphics Corporation
  * All rights reserved.
 #include "xil_cache.h"
 #include "metal/sys.h"
 #include "metal/irq.h"
-#include "metal/system/generic/irq.h"
-
+#include "platform_info.h"
 
 #define INTC_DEVICE_ID         XPAR_SCUGIC_0_DEVICE_ID
-/** IPI IRQ ID */
-#define IPI_IRQ_VECT_ID         65
-
-static XScuGic InterruptController;
 
+static XScuGic xInterruptController;
 
-static int zynqmp_r5_gic_initialize(void)
+/* Interrupt Controller setup */
+static int app_gic_initialize(void)
 {
        u32 Status;
        XScuGic_Config *IntcConfig;     /* The configuration parameters of the interrupt controller */
@@ -61,7 +57,7 @@ static int zynqmp_r5_gic_initialize(void)
                return XST_FAILURE;
        }
 
-       Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
+       Status = XScuGic_CfgInitialize(&xInterruptController, IntcConfig,
                                       IntcConfig->CpuBaseAddress);
        if (Status != XST_SUCCESS) {
                return XST_FAILURE;
@@ -73,24 +69,31 @@ static int zynqmp_r5_gic_initialize(void)
         */
        Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
                        (Xil_ExceptionHandler)XScuGic_InterruptHandler,
-                       &InterruptController);
+                       &xInterruptController);
 
        Xil_ExceptionEnable();
 
        /* Connect Interrupt ID with ISR */
-       XScuGic_Connect(&InterruptController, IPI_IRQ_VECT_ID,
-                          (Xil_ExceptionHandler)metal_irq_isr,
-                          (void *)IPI_IRQ_VECT_ID);
+       XScuGic_Connect(&xInterruptController, IPI_IRQ_VECT_ID,
+                       (Xil_ExceptionHandler)metal_irq_isr,
+                       (void *)IPI_IRQ_VECT_ID);
 
        return 0;
 }
 
-void init_system(void)
+/* Main hw machinery initialization entry point, called from main()*/
+/* return 0 on success */
+int init_system(void)
 {
        struct metal_init_params metal_param = METAL_INIT_DEFAULTS;
 
+       /* Low level abstraction layer for openamp initialization */
        metal_init(&metal_param);
-       zynqmp_r5_gic_initialize();
+
+       /* configure the global interrupt controller */
+       app_gic_initialize();
+
+       return 0;
 }
 
 void cleanup_system()
index 698a6f3b66b47fa7caab505e9973a4fad51605e2..1794d290be50ddf3b1de1dcb5fc6713dd72a8b20 100644 (file)
@@ -31,6 +31,9 @@
 /* This file populates resource table for BM remote
  * for use by the Linux Master */
 
+#ifndef RSC_TABLE_H_
+#define RSC_TABLE_H_
+
 #include <stddef.h>
 #include "openamp/open_amp.h"
 
@@ -47,3 +50,5 @@ struct remote_resource_table {
        struct fw_rsc_vdev_vring rpmsg_vring0;
        struct fw_rsc_vdev_vring rpmsg_vring1;
 };
+
+#endif /* RSC_TABLE_H_ */