feat(manifest): check interrupt IDs are unique

Add a checks to prevent two endpoints from declaring the same
interrupt ID resource for a device peripheral.

Also add macros used to access the bitmask that tracks
interrupts.

Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I5074e8d4209588a6c8f62ee06e0eb05b20cac387
diff --git a/inc/hf/interrupt_desc.h b/inc/hf/interrupt_desc.h
index 94943ed..1f78e48 100644
--- a/inc/hf/interrupt_desc.h
+++ b/inc/hf/interrupt_desc.h
@@ -15,6 +15,15 @@
 #include "vmapi/hf/ffa.h"
 
 /**
+ * Macros for accessing the bitmap tracking interrupts.
+ */
+/* The number of bits in each element of the interrupt bitfields. */
+#define INTERRUPT_REGISTER_BITS 32
+
+#define INTID_INDEX(intid) (intid / INTERRUPT_REGISTER_BITS)
+#define INTID_MASK(v, intid) (v << (intid % INTERRUPT_REGISTER_BITS))
+
+/**
  * Attributes encoding in the manifest:
 
  * Field		Bit(s)
diff --git a/inc/hf/manifest.h b/inc/hf/manifest.h
index 69955e2..91da3f7 100644
--- a/inc/hf/manifest.h
+++ b/inc/hf/manifest.h
@@ -226,12 +226,14 @@
 	MANIFEST_ERROR_DEVICE_REGION_NODE_EMPTY,
 	MANIFEST_ERROR_RXTX_SIZE_MISMATCH,
 	MANIFEST_ERROR_INVALID_MEM_PERM,
+	MANIFEST_ERROR_INTERRUPT_ID_REPEATED,
 };
 
 enum manifest_return_code manifest_init(struct mm_stage1_locked stage1_locked,
 					struct manifest *manifest,
 					struct memiter *manifest_fdt,
 					struct mpool *ppool);
+void manifest_deinit(struct mpool *ppool);
 
 enum manifest_return_code parse_ffa_manifest(struct fdt *fdt,
 					     struct manifest_vm *vm,
diff --git a/inc/hf/vcpu.h b/inc/hf/vcpu.h
index 2a0636b..47f9ed6 100644
--- a/inc/hf/vcpu.h
+++ b/inc/hf/vcpu.h
@@ -9,13 +9,11 @@
 #pragma once
 
 #include "hf/addr.h"
+#include "hf/interrupt_desc.h"
 #include "hf/spinlock.h"
 
 #include "vmapi/hf/ffa.h"
 
-/** The number of bits in each element of the interrupt bitfields. */
-#define INTERRUPT_REGISTER_BITS 32
-
 enum vcpu_state {
 	/** The vCPU is switched off. */
 	VCPU_STATE_OFF,