SPM: Memory check interface update

The memory check API checks memory accessibility by comparing the
attribute of a Secure Partition to a memory attribute. These attributes
are platform-specific, while SPM processes FF-M defined attributes.
Involving platform-defined attributes (Privileged, S/NS, e.g) would
burden SPM logic that it always needs to perform a conversion between
these two types of attributes. And it brings source-level dependency on
platform headers, and these headers can be various.

Actually, the Secure Partition's access attribute is represented by its
boundary, and the data 'boundary' are actually encoded by the platform
through HAL API. If a memory check can be performed by a HAL API to the
platform, by telling the platform the boundary and a memory address,
it can avoid SPM processing those conversions to platform-specific attributes.

There may be still several conversions in HAL API implementation to
convert the READ/WRITE attributes to platform-specific ones. This is
much lighter than before. And it is still possible to be avoided by
platform defining several quick preprocessors to convert these
attributes with bit operations, but it is not included in this patch.

Updated the 'tfm_hal_memory_check' for SPM direct call, which simplifies
the legacy memory check much.

Signed-off-by: Summer Qin <summer.qin@arm.com>
Change-Id: Ifb57d07f04683152482de7c2f81598b6eb4554ad
diff --git a/platform/include/tfm_hal_isolation.h b/platform/include/tfm_hal_isolation.h
index 67cf1c2..835155a 100644
--- a/platform/include/tfm_hal_isolation.h
+++ b/platform/include/tfm_hal_isolation.h
@@ -26,6 +26,9 @@
 #define TFM_HAL_ACCESS_DEVICE           (1UL << 4)
 #define TFM_HAL_ACCESS_NS               (1UL << 5)
 
+#define TFM_HAL_ACCESS_READWRITE  \
+        (TFM_HAL_ACCESS_READABLE | TFM_HAL_ACCESS_WRITABLE)
+
 #ifdef TFM_FIH_PROFILE_ON
 #include "fih.h"
 /**
@@ -87,14 +90,16 @@
 #endif /* TFM_FIH_PROFILE_ON */
 
 /**
- * \brief  This API checks if the memory region defined by base and size
- *         matches the given attributes - attr.
- *         The attributes can include NSPE access, privileged mode, and
- *         read-write permissions.
+ * \brief  This API checks if a given range of memory can be accessed with
+ *         specified access types in boundary. The boundary belongs to
+ *         a partition which contains all asset info.
  *
- * \param[in]   base    The base address of the region.
- * \param[in]   size    The size of the region.
- * \param[in]   attr    The memory access attributes.
+ * \param[in]   boundary      The boundary that the given memory is to be
+ *                            checked with.
+ * \param[in]   base          The base address of the region.
+ * \param[in]   size          The size of the region.
+ * \param[in]   access_type   The memory access types to be checked between
+ *                            given memory and boundaries.
  *
  * \return TFM_HAL_SUCCESS - The memory region has the access permissions.
  *         TFM_HAL_ERROR_MEM_FAULT - The memory region has not the access
@@ -102,9 +107,8 @@
  *         TFM_HAL_ERROR_INVALID_INPUT - Invalid inputs.
  *         TFM_HAL_ERROR_GENERIC - An error occurred.
  */
-enum tfm_hal_status_t tfm_hal_memory_has_access(uintptr_t base,
-                                                size_t size,
-                                                uint32_t attr);
+enum tfm_hal_status_t tfm_hal_memory_check(uintptr_t boundary, uintptr_t base,
+                                           size_t size, uint32_t access_type);
 
 /**
  * \brief  This API binds partition boundaries with the platform. The platform