Add support for SMMUv3 driver to perform stage 2 translation

This patch adds support for SMMUv3 driver at (S)EL-2 in Hafnium to
perform stage 2 translation, protection and isolation of upstream
peripheral device's DMA transactions.

Change-Id: Ib16389981d0b30053ecd6f20e752d73c38d12f3d
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
diff --git a/inc/hf/manifest.h b/inc/hf/manifest.h
index dc58b58..8a01883 100644
--- a/inc/hf/manifest.h
+++ b/inc/hf/manifest.h
@@ -15,6 +15,7 @@
 #include "hf/vm.h"
 
 #define MANIFEST_INVALID_ADDRESS UINT64_MAX
+#define MANIFEST_INVALID_ID UINT32_MAX
 
 #define SP_PKG_HEADER_MAGIC (0x474b5053)
 #define SP_PKG_HEADER_VERSION (0x1)
@@ -88,6 +89,8 @@
 	struct interrupt interrupts[SP_MAX_INTERRUPTS_PER_DEVICE];
 	/** SMMU ID - optional */
 	uint32_t smmu_id;
+	/** Count of Stream IDs assigned to device - optional */
+	uint8_t stream_count;
 	/** List of Stream IDs assigned to device - optional */
 	uint32_t stream_ids[SP_MAX_STREAMS_PER_DEVICE];
 	/** Exclusive access to an endpoint - optional */
diff --git a/inc/hf/plat/iommu.h b/inc/hf/plat/iommu.h
index c6fb171..a144622 100644
--- a/inc/hf/plat/iommu.h
+++ b/inc/hf/plat/iommu.h
@@ -10,6 +10,7 @@
 
 #include "hf/addr.h"
 #include "hf/fdt.h"
+#include "hf/manifest.h"
 #include "hf/vm.h"
 
 /**
@@ -44,3 +45,26 @@
  */
 void plat_iommu_identity_map(struct vm_locked vm_locked, paddr_t begin,
 			     paddr_t end, uint32_t mode);
+
+/**
+ * Configure IOMMU to perform address translation of memory transactions on the
+ * bus generated by each upstream peripheral device associated with a VM.
+
+ * mm_stage1_locked and mpool structure are provided so that the driver can
+ * allocate memory dynamically if needed (such as for configuring IOMMU using
+ * in-memory data structures.
+
+ * vm_locked is needed for retrieving information related to the translation
+ * settings of the VM associated with a peripheral.
+
+ * manifest_vm serves as a descriptor of various upstream peripherals that are
+ * associated with a VM.
+
+ * Note: Not all these arguments may be needed for a certain implementation.
+ * This interface is designed to be agnostic of any particular implementation
+ * of IOMMU driver.
+ */
+bool plat_iommu_attach_peripheral(struct mm_stage1_locked stage1_locked,
+				  struct vm_locked vm_locked,
+				  const struct manifest_vm *manifest_vm,
+				  struct mpool *ppool);