Emit warnings when using deprecated GIC init

Emit runtime warnings when intializing the GIC drivers using the
deprecated method of defining integer interrupt arrays in the GIC driver
data structures; interrupt_prop_t arrays should be used instead. This
helps platforms detect that they have migration work to do. Previously,
no warning was emitted in this case. This affects both the GICv2 and GICv3
drivers.

Also use the __deprecated attribute to emit a build time warning if these
deprecated fields are used. These warnings are suppressed in the GIC
driver compatibility functions but will be visible if platforms use them.

Change-Id: I6b6b8f6c3b4920c448b6dcb82fc18442cfdf6c7a
Signed-off-by: Dan Handley <dan.handley@arm.com>
diff --git a/drivers/arm/gic/v2/gicv2_main.c b/drivers/arm/gic/v2/gicv2_main.c
index c65f972..7e2c7a7 100644
--- a/drivers/arm/gic/v2/gicv2_main.c
+++ b/drivers/arm/gic/v2/gicv2_main.c
@@ -85,10 +85,17 @@
 				driver_data->interrupt_props_num);
 #if !ERROR_DEPRECATED
 	} else {
+		/*
+		 * Suppress deprecated declaration warnings in compatibility
+		 * function
+		 */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 		assert(driver_data->g0_interrupt_array);
 		gicv2_secure_ppi_sgi_setup(driver_data->gicd_base,
 				driver_data->g0_interrupt_num,
 				driver_data->g0_interrupt_array);
+#pragma GCC diagnostic pop
 	}
 #endif
 
@@ -128,12 +135,20 @@
 				driver_data->interrupt_props_num);
 #if !ERROR_DEPRECATED
 	} else {
+		/*
+		 * Suppress deprecated declaration warnings in compatibility
+		 * function
+		 */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 		assert(driver_data->g0_interrupt_array);
 
 		/* Configure the G0 SPIs */
 		gicv2_secure_spis_configure(driver_data->gicd_base,
 				driver_data->g0_interrupt_num,
 				driver_data->g0_interrupt_array);
+#pragma GCC diagnostic pop
 	}
 #endif
 
@@ -156,6 +171,13 @@
 		/* Interrupt properties array size must be 0 */
 		assert(plat_driver_data->interrupt_props_num == 0);
 
+		/*
+		 * Suppress deprecated declaration warnings in compatibility
+		 * function
+		 */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 		/* The platform should provide a list of secure interrupts */
 		assert(plat_driver_data->g0_interrupt_array);
 
@@ -166,6 +188,11 @@
 		assert(plat_driver_data->g0_interrupt_array ?
 				plat_driver_data->g0_interrupt_num :
 				plat_driver_data->g0_interrupt_num == 0);
+#pragma GCC diagnostic pop
+
+		WARN("Using deprecated integer interrupt array in "
+		     "gicv2_driver_data_t\n");
+		WARN("Please migrate to using an interrupt_prop_t array\n");
 	}
 #else
 	assert(plat_driver_data->interrupt_props != NULL);
diff --git a/drivers/arm/gic/v3/gicv3_main.c b/drivers/arm/gic/v3/gicv3_main.c
index 45a2e5b..f4a3ef8 100644
--- a/drivers/arm/gic/v3/gicv3_main.c
+++ b/drivers/arm/gic/v3/gicv3_main.c
@@ -73,6 +73,13 @@
 		assert(plat_driver_data->interrupt_props_num == 0);
 
 		/*
+		 * Suppress deprecated declaration warnings in compatibility
+		 * function
+		 */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
+		/*
 		 * The platform should provide a list of at least one type of
 		 * interrupt.
 		 */
@@ -89,6 +96,11 @@
 		assert(plat_driver_data->g1s_interrupt_array ?
 				plat_driver_data->g1s_interrupt_num :
 				plat_driver_data->g1s_interrupt_num == 0);
+#pragma GCC diagnostic pop
+
+		WARN("Using deprecated integer interrupt arrays in "
+		     "gicv3_driver_data_t\n");
+		WARN("Please migrate to using interrupt_prop_t arrays\n");
 	}
 #else
 	assert(plat_driver_data->interrupt_props != NULL);
@@ -189,6 +201,13 @@
 				gicv3_driver_data->interrupt_props_num);
 #if !ERROR_DEPRECATED
 	} else {
+		/*
+		 * Suppress deprecated declaration warnings in compatibility
+		 * function
+		 */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 		assert(gicv3_driver_data->g1s_interrupt_array ||
 				gicv3_driver_data->g0_interrupt_array);
 
@@ -209,6 +228,7 @@
 					INTR_GROUP0);
 			bitmap |= CTLR_ENABLE_G0_BIT;
 		}
+#pragma GCC diagnostic pop
 	}
 #endif
 
@@ -253,6 +273,13 @@
 				gicv3_driver_data->interrupt_props_num);
 #if !ERROR_DEPRECATED
 	} else {
+		/*
+		 * Suppress deprecated declaration warnings in compatibility
+		 * function
+		 */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 		assert(gicv3_driver_data->g1s_interrupt_array ||
 		       gicv3_driver_data->g0_interrupt_array);
 
@@ -273,6 +300,7 @@
 					INTR_GROUP0);
 			bitmap |= CTLR_ENABLE_G0_BIT;
 		}
+#pragma GCC diagnostic pop
 	}
 #endif
 
diff --git a/include/drivers/arm/gicv2.h b/include/drivers/arm/gicv2.h
index 6e8322e..39c7302 100644
--- a/include/drivers/arm/gicv2.h
+++ b/include/drivers/arm/gicv2.h
@@ -155,8 +155,8 @@
 	uintptr_t gicd_base;
 	uintptr_t gicc_base;
 #if !ERROR_DEPRECATED
-	unsigned int g0_interrupt_num;
-	const unsigned int *g0_interrupt_array;
+	unsigned int g0_interrupt_num __deprecated;
+	const unsigned int *g0_interrupt_array __deprecated;
 #endif
 	unsigned int *target_masks;
 	unsigned int target_masks_num;
diff --git a/include/drivers/arm/gicv3.h b/include/drivers/arm/gicv3.h
index 5f265c6..37c92e4 100644
--- a/include/drivers/arm/gicv3.h
+++ b/include/drivers/arm/gicv3.h
@@ -310,10 +310,10 @@
 	uintptr_t gicd_base;
 	uintptr_t gicr_base;
 #if !ERROR_DEPRECATED
-	unsigned int g0_interrupt_num;
-	unsigned int g1s_interrupt_num;
-	const unsigned int *g0_interrupt_array;
-	const unsigned int *g1s_interrupt_array;
+	unsigned int g0_interrupt_num __deprecated;
+	unsigned int g1s_interrupt_num __deprecated;
+	const unsigned int *g0_interrupt_array __deprecated;
+	const unsigned int *g1s_interrupt_array __deprecated;
 #endif
 	const interrupt_prop_t *interrupt_props;
 	unsigned int interrupt_props_num;