aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorJon Medhurst <tixy@linaro.org>2014-02-11 14:48:56 +0000
committerDan Handley <dan.handley@arm.com>2014-03-05 16:21:14 +0000
commitcf6eeb8a60bfb8c6b2e49c3839eed173d814f2ba (patch)
treed3b29a6ccd2e93a472bd9f8492a395b279694803 /arch
parenta4d9f26b009647db14fbf24479245227e712d35d (diff)
downloadarm-trusted-firmware-cf6eeb8a60bfb8c6b2e49c3839eed173d814f2ba.tar.gz
Fix implementation and users of gicd_set_ipriorityr()
Make gicd_set_ipriorityr() actually write to the priority register. Also correct callers of this function which want the highest priority to use the value zero as this is the highest priority value according to the ARM Generic Interrupt Controller Architecture Specification. To make this easier to get right, we introduce defines for the lowest and highest priorities for secure and non-secure interrupts. Fixes ARM-software/tf-issues#21 Signed-off-by: Jon Medhurst <tixy@linaro.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/system/gic/gic.h6
-rw-r--r--arch/system/gic/gic_v2.c25
2 files changed, 21 insertions, 10 deletions
diff --git a/arch/system/gic/gic.h b/arch/system/gic/gic.h
index 9e9fb73..3266043 100644
--- a/arch/system/gic/gic.h
+++ b/arch/system/gic/gic.h
@@ -37,7 +37,11 @@
#define GRP0 0
#define GRP1 1
-#define MAX_PRI_VAL 0xff
+#define GIC_PRI_MASK 0xff
+#define GIC_HIGHEST_SEC_PRIORITY 0
+#define GIC_LOWEST_SEC_PRIORITY 127
+#define GIC_HIGHEST_NS_PRIORITY 128
+#define GIC_LOWEST_NS_PRIORITY 254 /* 255 would disable an interrupt */
#define ENABLE_GRP0 (1 << 0)
#define ENABLE_GRP1 (1 << 1)
diff --git a/arch/system/gic/gic_v2.c b/arch/system/gic/gic_v2.c
index 220ca19..6af0378 100644
--- a/arch/system/gic/gic_v2.c
+++ b/arch/system/gic/gic_v2.c
@@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <assert.h>
#include <gic.h>
#include <mmio.h>
@@ -264,20 +265,26 @@ void gicd_set_icactiver(unsigned int base, unsigned int id)
*/
void gicd_set_ipriorityr(unsigned int base, unsigned int id, unsigned int pri)
{
- unsigned byte_off = id & ((1 << ICACTIVER_SHIFT) - 1);
- unsigned int reg_val = gicd_read_icactiver(base, id);
+ unsigned int reg = base + GICD_IPRIORITYR + (id & ~3);
+ unsigned int shift = (id & 3) << 3;
+ unsigned int reg_val = mmio_read_32(reg);
/*
* Enforce ARM recommendation to manage priority values such
* that group1 interrupts always have a lower priority than
- * group0 interrupts
+ * group0 interrupts.
+ * Note, lower numerical values are higher priorities so the comparison
+ * checks below are reversed from what might be expected.
*/
- if (gicd_get_igroupr(base, id) == GRP1)
- pri |= 1 << 7;
- else
- pri &= ~(1 << 7);
-
- gicd_write_icactiver(base, id, reg_val & ~(pri << (byte_off << 3)));
+ assert(gicd_get_igroupr(base, id) == GRP1 ?
+ pri >= GIC_HIGHEST_NS_PRIORITY &&
+ pri <= GIC_LOWEST_NS_PRIORITY :
+ pri >= GIC_HIGHEST_SEC_PRIORITY &&
+ pri <= GIC_LOWEST_SEC_PRIORITY);
+
+ reg_val &= ~(GIC_PRI_MASK << shift);
+ reg_val |= (pri & GIC_PRI_MASK) << shift;
+ mmio_write_32(reg, reg_val);
}
void gicd_set_itargetsr(unsigned int base, unsigned int id, unsigned int iface)