ITS/PS: Make file system configuration dynamic

Support not providing the following macros:
- ITS_FLASH_AREA_ADDR
- ITS_FLASH_AREA_SIZE
- PS_FLASH_AREA_ADDR
- PS_FLASH_AREA_SIZE
instead getting them from the platform HAL at runtime.

The intent here is that it will eventually be possible to use a single
TFM image on multiple boards, with the flash layout specified in
provisioning information.

Add platform HAL API functions to get the file system configuration.
Provide default implementations that just use the macros.

Add support for new macros, ITS_RAM_FS_SIZE and PS_RAM_FS_SIZE, for
use with ITS_RAM_FS and PS_RAM_FS.

Also add a validation function and perform the validation of fs
configuration that was previously done at compile-time at runtime.

There's a TODO in the new code - to move the flash_dev from struct
its_flash_info_t to struct flash_fs_info_t. Because the sector_size
and erase_val are both hard-coded in macros rather than being read
from the device driver using flash_dev->ARM_Flash_GetInfo(), this
would be a fairly major change in itself at this time.

Change-Id: I6ccb126999b0227e85dd8f6de2ea044e2a36c2e8
Signed-off-by: Chris Brand <chris.brand@cypress.com>
diff --git a/docs/reference/services/tfm_its_integration_guide.rst b/docs/reference/services/tfm_its_integration_guide.rst
index 230117e..7c0ca5b 100644
--- a/docs/reference/services/tfm_its_integration_guide.rst
+++ b/docs/reference/services/tfm_its_integration_guide.rst
@@ -197,10 +197,6 @@
 ============================================
 The ITS service requires the following platform definitions:
 
-- ``ITS_FLASH_AREA_ADDR`` - Defines the flash address where the internal trusted
-  storage area starts.
-- ``ITS_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area for
-  internal trusted storage in bytes.
 - ``ITS_SECTOR_SIZE`` - Defines the size of the flash sectors (the smallest
   erasable unit) in bytes.
 - ``ITS_SECTORS_PER_BLOCK`` - Defines the number of contiguous ITS_SECTOR_SIZE
@@ -234,6 +230,12 @@
 The following optional platform definitions may also be defined in
 ``flash_layout.h`` or set at build time in ``platform/ext/<TARGET_NAME>.cmake``:
 
+- ``ITS_FLASH_AREA_ADDR`` - Defines the flash address where the internal trusted
+  storage area starts.
+  If not defined, the platform must implement ``tfm_hal_its_fs_info()``.
+- ``ITS_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area for
+  internal trusted storage in bytes.
+  If not defined, the platform must implement ``tfm_hal_its_fs_info()``.
 - ``ITS_BUF_SIZE``- Defines the size of the partition's internal data transfer
   buffer. If not provided, then ``ITS_MAX_ASSET_SIZE`` is used to allow asset
   data to be copied between the client and the filesystem in one iteration.
@@ -282,6 +284,8 @@
   service. This flag is ``OFF`` by default. The ITS regression tests write/erase
   storage multiple time, so enabling this flag can increase the life of flash
   memory when testing.
+  If this flag is set to ``ON``, ITS_RAM_FS_SIZE must also be provided. This
+  specifies the size of the block of RAM to be used to simulate the flash.
 
   .. Note::
     If this flag is disabled when running the regression tests, then it is
diff --git a/docs/reference/services/tfm_ps_integration_guide.rst b/docs/reference/services/tfm_ps_integration_guide.rst
index 342011a..1bf35f5 100644
--- a/docs/reference/services/tfm_ps_integration_guide.rst
+++ b/docs/reference/services/tfm_ps_integration_guide.rst
@@ -211,10 +211,6 @@
 =====================================
 The PS service requires the following platform definitions:
 
-- ``PS_FLASH_AREA_ADDR`` - Defines the flash address where the protected storage
-  area starts.
-- ``PS_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area
-  for protected storage in bytes.
 - ``PS_SECTOR_SIZE`` - Defines the size of the flash sectors (the smallest
   erasable unit) in bytes.
 - ``PS_SECTORS_PER_BLOCK`` - Defines the number of contiguous PS_SECTOR_SIZE
@@ -249,6 +245,16 @@
 available in :doc:`platform readme </platform/ext/readme>` along with other
 platform information.
 
+The following optional platform definitions may also be defined in
+``flash_layout.h`` or set at build time in ``platform/ext/<TARGET_NAME>.cmake``:
+
+- ``PS_FLASH_AREA_ADDR`` - Defines the flash address where the protected storage
+  area starts.
+  If not defined, the platform must implement ``tfm_hal_ps_fs_info()``.
+- ``PS_FLASH_AREA_SIZE`` - Defines the size of the dedicated flash area
+  for protected storage in bytes.
+  If not defined, the platform must implement ``tfm_hal_ps_fs_info()``.
+
 TF-M NV Counter Interface
 =========================
 To have a platform independent way to access the NV counters, TF-M defines a
@@ -332,6 +338,8 @@
   service. This flag is ``OFF`` by default. The PS regression tests write/erase
   storage multiple time, so enabling this flag can increase the life of flash
   memory when testing.
+  If this flag is set to ``ON``, PS_RAM_FS_SIZE must also be provided. This
+  specifies the size of the block of RAM to be used to simulate the flash.
 
   .. Note::
     If this flag is disabled when running the regression tests, then it is
@@ -359,3 +367,4 @@
 --------------
 
 *Copyright (c) 2018-2020, Arm Limited. All rights reserved.*
+*Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.*
diff --git a/platform/ext/Mps2AN519.cmake b/platform/ext/Mps2AN519.cmake
index c18f482..3613f67 100644
--- a/platform/ext/Mps2AN519.cmake
+++ b/platform/ext/Mps2AN519.cmake
@@ -1,5 +1,6 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -146,6 +147,8 @@
   if (TFM_PARTITION_PLATFORM)
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/services/src/tfm_platform_system.c")
   endif()
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
   embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/Mps2AN521.cmake b/platform/ext/Mps2AN521.cmake
index 6a6d64d..215ab04 100644
--- a/platform/ext/Mps2AN521.cmake
+++ b/platform/ext/Mps2AN521.cmake
@@ -1,5 +1,6 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -147,6 +148,8 @@
   if (TFM_PARTITION_PLATFORM)
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an521/services/src/tfm_platform_system.c")
   endif()
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
   embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/Mps2AN539.cmake b/platform/ext/Mps2AN539.cmake
index a806e50..f0b572e 100644
--- a/platform/ext/Mps2AN539.cmake
+++ b/platform/ext/Mps2AN539.cmake
@@ -1,5 +1,6 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -143,6 +144,8 @@
   if (TFM_PARTITION_PLATFORM)
     list(APPEND ALL_SRC_C_S "${AN539_DIR}/services/src/tfm_platform_system.c")
   endif()
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
   embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/Mps3AN524.cmake b/platform/ext/Mps3AN524.cmake
index 6ab58f4..557c19d 100644
--- a/platform/ext/Mps3AN524.cmake
+++ b/platform/ext/Mps3AN524.cmake
@@ -1,5 +1,6 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -153,6 +154,8 @@
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c")
   list(APPEND ALL_SRC_C_S "${AN524_DIR}/native_drivers/mpu_armv8m_drv.c")
   list(APPEND ALL_SRC_C_S "${AN524_DIR}/services/src/tfm_platform_system.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
   embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/SSE-200_AWS.cmake b/platform/ext/SSE-200_AWS.cmake
index 4c9500f..c56f3b8 100644
--- a/platform/ext/SSE-200_AWS.cmake
+++ b/platform/ext/SSE-200_AWS.cmake
@@ -1,5 +1,6 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -149,6 +150,8 @@
   if (TFM_PARTITION_PLATFORM)
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/sse-200_aws/services/src/tfm_platform_system.c")
   endif()
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
   embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/common/tfm_hal_its.c b/platform/ext/common/tfm_hal_its.c
new file mode 100644
index 0000000..ed7b6ad
--- /dev/null
+++ b/platform/ext/common/tfm_hal_its.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "cmsis_compiler.h"
+#include "flash_layout.h"
+#include "tfm_hal_its.h"
+
+__WEAK void tfm_hal_its_fs_info(uint32_t *flash_area_addr, uint32_t *flash_area_size)
+{
+    if (!flash_area_addr || !flash_area_size) {
+        return;
+    }
+
+    *flash_area_addr = ITS_FLASH_AREA_ADDR;
+    *flash_area_size = ITS_FLASH_AREA_SIZE;
+}
diff --git a/platform/ext/common/tfm_hal_ps.c b/platform/ext/common/tfm_hal_ps.c
new file mode 100644
index 0000000..df88292
--- /dev/null
+++ b/platform/ext/common/tfm_hal_ps.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "cmsis_compiler.h"
+#include "flash_layout.h"
+#include "tfm_hal_ps.h"
+
+__WEAK void tfm_hal_ps_fs_info(uint32_t *flash_area_addr, uint32_t *flash_area_size)
+{
+    if (!flash_area_addr || !flash_area_size) {
+        return;
+    }
+
+    *flash_area_addr = PS_FLASH_AREA_ADDR;
+    *flash_area_size = PS_FLASH_AREA_SIZE;
+}
diff --git a/platform/ext/fvp_sse300_mps2.cmake b/platform/ext/fvp_sse300_mps2.cmake
index 9a9030e..6117b71 100644
--- a/platform/ext/fvp_sse300_mps2.cmake
+++ b/platform/ext/fvp_sse300_mps2.cmake
@@ -1,5 +1,6 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -137,6 +138,8 @@
   if (TFM_PARTITION_PLATFORM)
     list(APPEND ALL_SRC_C_S "${FVP_SSE300_DIR}/services/src/tfm_platform_system.c")
   endif()
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
   embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/lpc55s69.cmake b/platform/ext/lpc55s69.cmake
index 66f72f4..be11318 100644
--- a/platform/ext/lpc55s69.cmake
+++ b/platform/ext/lpc55s69.cmake
@@ -1,6 +1,7 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2018-2020, Arm Limited. All rights reserved.
 # Copyright (c) 2020, Linaro. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -174,6 +175,8 @@
   if (TFM_PARTITION_PLATFORM)
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/services/src/tfm_platform_system.c")
   endif()
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
   embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/musca_a.cmake b/platform/ext/musca_a.cmake
index 3af796f..e76f751 100644
--- a/platform/ext/musca_a.cmake
+++ b/platform/ext/musca_a.cmake
@@ -1,5 +1,6 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -138,6 +139,8 @@
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/spm_hal.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/Native_Driver/mpu_armv8m_drv.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
   if (TFM_PARTITION_PLATFORM)
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/services/src/tfm_platform_system.c")
diff --git a/platform/ext/musca_b1.cmake b/platform/ext/musca_b1.cmake
index b25cd82..32c3176 100644
--- a/platform/ext/musca_b1.cmake
+++ b/platform/ext/musca_b1.cmake
@@ -1,5 +1,6 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -148,6 +149,8 @@
         list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_b1/services/src/tfm_platform_system.c")
         list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_b1/services/src/tfm_ioctl_s_api.c")
     endif()
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
     embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/musca_s1.cmake b/platform/ext/musca_s1.cmake
index 0815c3b..c8acee1 100644
--- a/platform/ext/musca_s1.cmake
+++ b/platform/ext/musca_s1.cmake
@@ -1,5 +1,6 @@
 #-------------------------------------------------------------------------------
 # Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -146,6 +147,8 @@
         list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/services/src/tfm_platform_system.c")
         list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/services/src/tfm_ioctl_s_api.c")
     endif()
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
     embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/psoc64.cmake b/platform/ext/psoc64.cmake
index db48300..c47dea3 100644
--- a/platform/ext/psoc64.cmake
+++ b/platform/ext/psoc64.cmake
@@ -202,6 +202,8 @@
   if (TFM_PARTITION_PLATFORM)
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/services/src/tfm_platform_system.c")
   endif()
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+  list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
   embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
 endif()
diff --git a/platform/ext/readme.rst b/platform/ext/readme.rst
index 1d877d4..52e14da 100644
--- a/platform/ext/readme.rst
+++ b/platform/ext/readme.rst
@@ -226,6 +226,8 @@
 .. Note::
 
     The sectors must be consecutive.
+    The platform may implement ``tfm_hal_ps_fs_info()`` as an alternative
+    to defining ``PS_FLASH_AREA_ADDR`` and ``PS_FLASH_AREA_SIZE``.
 
 Internal Trusted Storage (ITS) Service definitions
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -251,6 +253,8 @@
 .. Note::
 
     The sectors must be consecutive.
+    The platform may implement ``tfm_hal_its_fs_info()`` as an alternative
+    to defining ``ITS_FLASH_AREA_ADDR`` and ``ITS_FLASH_AREA_SIZE``.
 
 ***************************************
 Expose target support for HW components
@@ -266,3 +270,4 @@
 --------------
 
 *Copyright (c) 2017-2020, Arm Limited. All rights reserved.*
+*Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.*
diff --git a/platform/ext/target/cypress/psoc64/partition/flash_layout.h b/platform/ext/target/cypress/psoc64/partition/flash_layout.h
index 36bdeeb..1f30233 100644
--- a/platform/ext/target/cypress/psoc64/partition/flash_layout.h
+++ b/platform/ext/target/cypress/psoc64/partition/flash_layout.h
@@ -132,6 +132,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
 #define PS_SECTORS_PER_BLOCK   0x8
@@ -156,6 +157,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
 #define ITS_SECTORS_PER_BLOCK   (0x8)
diff --git a/platform/ext/target/mps2/an519/partition/flash_layout.h b/platform/ext/target/mps2/an519/partition/flash_layout.h
index e6eb047..098e1c9 100644
--- a/platform/ext/target/mps2/an519/partition/flash_layout.h
+++ b/platform/ext/target/mps2/an519/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2020 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -178,6 +179,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
 #define PS_SECTORS_PER_BLOCK   (0x1)
@@ -202,6 +204,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
 #define ITS_SECTORS_PER_BLOCK   (0x1)
diff --git a/platform/ext/target/mps2/an521/partition/flash_layout.h b/platform/ext/target/mps2/an521/partition/flash_layout.h
index cb661ea..5e87781 100644
--- a/platform/ext/target/mps2/an521/partition/flash_layout.h
+++ b/platform/ext/target/mps2/an521/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2020 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -178,6 +179,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
 #define PS_SECTORS_PER_BLOCK   (0x1)
@@ -202,6 +204,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
 #define ITS_SECTORS_PER_BLOCK   (0x1)
diff --git a/platform/ext/target/mps2/an539/partition/flash_layout.h b/platform/ext/target/mps2/an539/partition/flash_layout.h
index 092e83b..6cd45c3 100644
--- a/platform/ext/target/mps2/an539/partition/flash_layout.h
+++ b/platform/ext/target/mps2/an539/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2020 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -177,6 +178,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
 #define PS_SECTORS_PER_BLOCK   (0x1)
@@ -201,6 +203,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
 #define ITS_SECTORS_PER_BLOCK   (0x1)
diff --git a/platform/ext/target/mps2/fvp_sse300/partition/flash_layout.h b/platform/ext/target/mps2/fvp_sse300/partition/flash_layout.h
index 39461c5..f188add 100644
--- a/platform/ext/target/mps2/fvp_sse300/partition/flash_layout.h
+++ b/platform/ext/target/mps2/fvp_sse300/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2020 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -181,6 +182,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
 #define PS_SECTORS_PER_BLOCK   (0x1)
@@ -205,6 +207,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
 #define ITS_SECTORS_PER_BLOCK   (0x1)
diff --git a/platform/ext/target/mps3/an524/partition/flash_layout.h b/platform/ext/target/mps3/an524/partition/flash_layout.h
index 191445a..8dcab0c 100644
--- a/platform/ext/target/mps3/an524/partition/flash_layout.h
+++ b/platform/ext/target/mps3/an524/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2020 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -165,6 +166,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 /* Sector size of the flash hardware; same as FLASH0_SECTOR_SIZE */
 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
@@ -190,6 +192,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 /* Sector size of the flash hardware; same as FLASH0_SECTOR_SIZE */
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
diff --git a/platform/ext/target/musca_a/partition/flash_layout.h b/platform/ext/target/musca_a/partition/flash_layout.h
index 126f173..6e311df 100644
--- a/platform/ext/target/musca_a/partition/flash_layout.h
+++ b/platform/ext/target/musca_a/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2018-2020 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -185,6 +186,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
 #define PS_SECTORS_PER_BLOCK   (0x1)
@@ -209,6 +211,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
 #define ITS_SECTORS_PER_BLOCK   (0x1)
diff --git a/platform/ext/target/musca_b1/partition/flash_layout.h b/platform/ext/target/musca_b1/partition/flash_layout.h
index 1ccb5e8..4738e68 100644
--- a/platform/ext/target/musca_b1/partition/flash_layout.h
+++ b/platform/ext/target/musca_b1/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2018-2020 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -184,6 +185,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 #define PS_SECTOR_SIZE         QSPI_FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
 #define PS_SECTORS_PER_BLOCK   (0x1)
@@ -208,6 +210,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
 #define ITS_SECTORS_PER_BLOCK   (0x1)
diff --git a/platform/ext/target/musca_s1/partition/flash_layout.h b/platform/ext/target/musca_s1/partition/flash_layout.h
index 72b4810..70281e0 100644
--- a/platform/ext/target/musca_s1/partition/flash_layout.h
+++ b/platform/ext/target/musca_s1/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2018-2020 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -187,6 +188,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
 #define PS_SECTORS_PER_BLOCK   (0x1)
@@ -211,6 +213,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
 #define ITS_SECTORS_PER_BLOCK   (0x1)
diff --git a/platform/ext/target/nxp/lpcxpresso55s69/partition/flash_layout.h b/platform/ext/target/nxp/lpcxpresso55s69/partition/flash_layout.h
index acee769..74794c5 100755
--- a/platform/ext/target/nxp/lpcxpresso55s69/partition/flash_layout.h
+++ b/platform/ext/target/nxp/lpcxpresso55s69/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*

  * Copyright (c) 2018-2020 Arm Limited. All rights reserved.

+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.

  *

  * Licensed under the Apache License, Version 2.0 (the "License");

  * you may not use this file except in compliance with the License.

@@ -176,6 +177,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET

 /* Dedicated flash area for PS */

 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE

+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE

 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE

 /* Number of PS_SECTOR_SIZE per block */

 #define PS_SECTORS_PER_BLOCK   (0x8)

@@ -201,6 +203,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET

 /* Dedicated flash area for ITS */

 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE

+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE

 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE

 /* Number of ITS_SECTOR_SIZE per block */

 #define ITS_SECTORS_PER_BLOCK   (0x2)

diff --git a/platform/ext/target/sse-200_aws/partition/flash_layout.h b/platform/ext/target/sse-200_aws/partition/flash_layout.h
index d2fb3a4..699180e 100644
--- a/platform/ext/target/sse-200_aws/partition/flash_layout.h
+++ b/platform/ext/target/sse-200_aws/partition/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2020 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -178,6 +179,7 @@
 #define PS_FLASH_AREA_ADDR     FLASH_PS_AREA_OFFSET
 /* Dedicated flash area for PS */
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 #define PS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of PS_SECTOR_SIZE per block */
 #define PS_SECTORS_PER_BLOCK   (0x1)
@@ -202,6 +204,7 @@
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 /* Dedicated flash area for ITS */
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* Number of ITS_SECTOR_SIZE per block */
 #define ITS_SECTORS_PER_BLOCK   (0x1)
diff --git a/platform/ext/target/stm/stm32l5xx/boards/nucleo_l552ze_q/flash_layout.h b/platform/ext/target/stm/stm32l5xx/boards/nucleo_l552ze_q/flash_layout.h
index e0d0e1c..3339731 100644
--- a/platform/ext/target/stm/stm32l5xx/boards/nucleo_l552ze_q/flash_layout.h
+++ b/platform/ext/target/stm/stm32l5xx/boards/nucleo_l552ze_q/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2018 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -171,6 +172,7 @@
 #define PS_SECTOR_SIZE      FLASH_AREA_IMAGE_SECTOR_SIZE
 #define PS_SECTORS_PER_BLOCK   (0x1)
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 
 /* The sectors must be in consecutive memory location */
 #define PS_NBR_OF_SECTORS  (FLASH_PS_AREA_SIZE / PS_SECTOR_SIZE)
@@ -185,6 +187,7 @@
 
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* The sectors must be in consecutive memory location */
diff --git a/platform/ext/target/stm/stm32l5xx/boards/stm32l562e_dk/flash_layout.h b/platform/ext/target/stm/stm32l5xx/boards/stm32l562e_dk/flash_layout.h
index fe33fc9..4826bd2 100644
--- a/platform/ext/target/stm/stm32l5xx/boards/stm32l562e_dk/flash_layout.h
+++ b/platform/ext/target/stm/stm32l5xx/boards/stm32l562e_dk/flash_layout.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2018 Arm Limited. All rights reserved.
+ * Copyright (c) 2020 Cypress Semiconductor Corporation. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -175,6 +176,7 @@
 #define PS_SECTOR_SIZE      FLASH_AREA_IMAGE_SECTOR_SIZE
 #define PS_SECTORS_PER_BLOCK   (0x1)
 #define PS_FLASH_AREA_SIZE     FLASH_PS_AREA_SIZE
+#define PS_RAM_FS_SIZE         PS_FLASH_AREA_SIZE
 
 /* The sectors must be in consecutive memory location */
 #define PS_NBR_OF_SECTORS  (FLASH_PS_AREA_SIZE / PS_SECTOR_SIZE)
@@ -190,6 +192,7 @@
 
 #define ITS_FLASH_AREA_ADDR     FLASH_ITS_AREA_OFFSET
 #define ITS_FLASH_AREA_SIZE     FLASH_ITS_AREA_SIZE
+#define ITS_RAM_FS_SIZE         ITS_FLASH_AREA_SIZE
 
 #define ITS_SECTOR_SIZE         FLASH_AREA_IMAGE_SECTOR_SIZE
 /* The sectors must be in consecutive memory location */
diff --git a/platform/ext/target/stm/stm32l5xx/stm32l5xx.cmake b/platform/ext/target/stm/stm32l5xx/stm32l5xx.cmake
index 4e7449c..d8d6914 100644
--- a/platform/ext/target/stm/stm32l5xx/stm32l5xx.cmake
+++ b/platform/ext/target/stm/stm32l5xx/stm32l5xx.cmake
@@ -1,4 +1,5 @@
 # Copyright (c) 2018, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -78,6 +79,8 @@
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/stm/stm32l5xx/secure/system_stm32l5xx.c")
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c")
     list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/stm/stm32l5xx/secure/tfm_platform_system.c")
+    list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
+    list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
   embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
   embedded_include_directories(PATH "${PLATFORM_DIR}/target/stm/stm32l5xx/Native_Driver" ABSOLUTE)
 endif()
diff --git a/platform/include/tfm_hal_its.h b/platform/include/tfm_hal_its.h
new file mode 100644
index 0000000..843eb71
--- /dev/null
+++ b/platform/include/tfm_hal_its.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_HAL_ITS_H__
+#define __TFM_HAL_ITS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Retrieve the filesystem config for ITS.
+ *
+ * Note that this function should ensure that the values returned do
+ * not result in a security compromise.
+ *
+ * \param [out] flash_area_addr  Location of the block of flash to use for ITS
+ * \param [out] flash_area_size  Number of bytes of flash to use for ITS
+ *
+ * \return void
+ * If an error is detected within this function, is should leave the
+ * content of the parameters unchanged.
+ */
+void tfm_hal_its_fs_info(uint32_t *flash_area_addr, uint32_t *flash_area_size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TFM_HAL_ITS_H__ */
diff --git a/platform/include/tfm_hal_ps.h b/platform/include/tfm_hal_ps.h
new file mode 100644
index 0000000..e372883
--- /dev/null
+++ b/platform/include/tfm_hal_ps.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_HAL_PS_H__
+#define __TFM_HAL_PS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Retrieve the filesystem config for PS.
+ *
+ * Note that this function should ensure that the values returned do
+ * not result in a security compromise.
+ *
+ * \param [out] flash_area_addr  Location of the block of flash to use for PS
+ * \param [out] flash_area_size  Number of bytes of flash to use for PS
+ *
+ * \return void
+ * If an error is detected within this function, is should leave the
+ * content of the parameters unchanged.
+ */
+void tfm_hal_ps_fs_info(uint32_t *flash_area_addr, uint32_t *flash_area_size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TFM_HAL_PS_H__ */
diff --git a/secure_fw/partitions/internal_trusted_storage/flash/its_flash.c b/secure_fw/partitions/internal_trusted_storage/flash/its_flash.c
index f5cb605..65a18ea 100644
--- a/secure_fw/partitions/internal_trusted_storage/flash/its_flash.c
+++ b/secure_fw/partitions/internal_trusted_storage/flash/its_flash.c
@@ -8,21 +8,49 @@
 
 #include "its_flash.h"
 
+#include "flash_fs/its_flash_fs.h"
+#include "tfm_hal_its.h"
+#include "tfm_hal_ps.h"
+
 #ifndef ITS_MAX_BLOCK_DATA_COPY
 #define ITS_MAX_BLOCK_DATA_COPY 256
 #endif
 
-extern const struct its_flash_info_t its_flash_info_internal;
-extern const struct its_flash_info_t its_flash_info_external;
+extern struct its_flash_info_t its_flash_info_internal;
+extern struct its_flash_info_t its_flash_info_external;
 
-static const struct its_flash_info_t *const flash_infos[] = {
+static struct its_flash_info_t *const flash_infos[] = {
     [ITS_FLASH_ID_INTERNAL] = &its_flash_info_internal,
     [ITS_FLASH_ID_EXTERNAL] = &its_flash_info_external,
 };
 
 const struct its_flash_info_t *its_flash_get_info(enum its_flash_id_t id)
 {
-    return flash_infos[id];
+    struct its_flash_info_t *ret = flash_infos[id];
+
+    /* Ask the platform for the filesystem config */
+    switch (id) {
+    case ITS_FLASH_ID_INTERNAL:
+        tfm_hal_its_fs_info(&ret->fs_info.flash_area_addr, &ret->fs_info.flash_area_size);
+        break;
+
+    case ITS_FLASH_ID_EXTERNAL:
+        tfm_hal_ps_fs_info(&ret->fs_info.flash_area_addr, &ret->fs_info.flash_area_size);
+        break;
+
+    default:
+        return NULL;
+    }
+
+    /* Derive num_blocks */
+    ret->num_blocks = ret->fs_info.flash_area_size / ret->block_size;
+
+    /* Check that the parameters are compatible */
+    if (its_flash_fs_validate_params(ret) != PSA_SUCCESS) {
+        ret = NULL;
+    }
+
+    return ret;
 }
 
 psa_status_t its_flash_block_to_block_move(const struct its_flash_info_t *info,
diff --git a/secure_fw/partitions/internal_trusted_storage/flash/its_flash.h b/secure_fw/partitions/internal_trusted_storage/flash/its_flash.h
index 6ee1740..b242082 100644
--- a/secure_fw/partitions/internal_trusted_storage/flash/its_flash.h
+++ b/secure_fw/partitions/internal_trusted_storage/flash/its_flash.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -54,6 +55,16 @@
 };
 
 /**
+ * \brief flash filesystem configuration structure
+ *
+ */
+struct flash_fs_info_t {
+    /* TODO - move flash_dev here from struct its_flash_info_t */
+    uint32_t flash_area_addr; /**< base address of the flash region */
+    uint32_t flash_area_size; /**< size in bytes of the flash region */
+};
+
+/**
  * \struct its_flash_info_t
  *
  * \brief Structure containing the required information about a flash device to
@@ -141,19 +152,22 @@
     psa_status_t (*erase)(const struct its_flash_info_t *info,
                           uint32_t block_id);
 
-    void *flash_dev;          /**< Pointer to the flash device */
-    uint32_t flash_area_addr; /**< Start address of the flash area */
-    uint16_t sector_size;     /**< Size of the flash device's physical erase
-                               *   unit
-                               */
-    uint16_t block_size;      /**< Size of a logical erase unit presented by the
-                               *   flash interface, a multiple of sector_size.
-                               */
-    uint16_t num_blocks;      /**< Number of logical erase blocks */
-    uint16_t program_unit;    /**< Minimum size of a program operation */
-    uint16_t max_file_size;   /**< Maximum file size */
-    uint16_t max_num_files;   /**< Maximum number of files */
-    uint8_t erase_val;        /**< Value of a byte after erase (usually 0xFF) */
+    void *flash_dev;                /**< Pointer to the flash device */
+    struct flash_fs_info_t fs_info; /**< Filesystem configuration */
+    uint16_t sector_size;           /**< Size of the flash device's physical
+                                     *   erase unit
+                                     */
+    uint16_t block_size;            /**< Size of a logical erase unit presented
+                                     *   by the flash interface, a multiple of
+                                     *   sector_size.
+                                     */
+    uint16_t num_blocks;            /**< Number of logical erase blocks */
+    uint16_t program_unit;          /**< Minimum size of a program operation */
+    uint16_t max_file_size;         /**< Maximum file size */
+    uint16_t max_num_files;         /**< Maximum number of files */
+    uint8_t erase_val;              /**< Value of a byte after erase
+                                     * (usually 0xFF)
+                                     */
 };
 
 /**
diff --git a/secure_fw/partitions/internal_trusted_storage/flash/its_flash_info_external.c b/secure_fw/partitions/internal_trusted_storage/flash/its_flash_info_external.c
index 6b083c3..fdcfd77 100644
--- a/secure_fw/partitions/internal_trusted_storage/flash/its_flash_info_external.c
+++ b/secure_fw/partitions/internal_trusted_storage/flash/its_flash_info_external.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -16,15 +17,6 @@
 #error "PS_FLASH_DEV_NAME must be defined by the target in flash_layout.h"
 #endif
 
-#ifndef PS_FLASH_AREA_ADDR
-#error "PS_FLASH_AREA_ADDR must be defined by the target in flash_layout.h"
-#endif
-
-/* Adjust to a size that will allow all assets to fit */
-#ifndef PS_FLASH_AREA_SIZE
-#error "PS_FLASH_AREA_SIZE must be defined by the target in flash_layout.h"
-#endif
-
 /* Adjust to match the size of the flash device's physical erase unit */
 #ifndef PS_SECTOR_SIZE
 #error "PS_SECTOR_SIZE must be defined by the target in flash_layout.h"
@@ -47,6 +39,9 @@
 /* Include the correct flash interface implementation */
 #ifdef PS_RAM_FS
 #include "its_flash_ram.h"
+#ifndef PS_RAM_FS_SIZE
+#error "PS_RAM_FS_SIZE must be defined by the target in flash_layout.h"
+#endif
 #define FLASH_INFO_INIT its_flash_ram_init
 #define FLASH_INFO_READ its_flash_ram_read
 #define FLASH_INFO_WRITE its_flash_ram_write
@@ -80,7 +75,6 @@
 
 /* Calculate the block layout */
 #define FLASH_INFO_BLOCK_SIZE (PS_SECTOR_SIZE * PS_SECTORS_PER_BLOCK)
-#define FLASH_INFO_NUM_BLOCKS (PS_FLASH_AREA_SIZE / FLASH_INFO_BLOCK_SIZE)
 
 /* Maximum file size */
 #define FLASH_INFO_MAX_FILE_SIZE ITS_UTILS_ALIGN(PS_MAX_OBJECT_SIZE, \
@@ -94,7 +88,7 @@
 
 #ifdef PS_RAM_FS
 /* Allocate a static buffer to emulate storage in RAM */
-static uint8_t ps_block_data[FLASH_INFO_BLOCK_SIZE * FLASH_INFO_NUM_BLOCKS];
+static uint8_t ps_block_data[PS_RAM_FS_SIZE];
 #define FLASH_INFO_DEV ps_block_data
 #else
 /* Import the CMSIS flash device driver */
@@ -102,23 +96,19 @@
 #define FLASH_INFO_DEV &PS_FLASH_DEV_NAME
 #endif
 
-const struct its_flash_info_t its_flash_info_external = {
+struct its_flash_info_t its_flash_info_external = {
     .init = FLASH_INFO_INIT,
     .read = FLASH_INFO_READ,
     .write = FLASH_INFO_WRITE,
     .flush = FLASH_INFO_FLUSH,
     .erase = FLASH_INFO_ERASE,
     .flash_dev = (void *)FLASH_INFO_DEV,
-    .flash_area_addr = PS_FLASH_AREA_ADDR,
+    .fs_info = {0, 0}, /* Filled by its_flash_get_info() */
     .sector_size = PS_SECTOR_SIZE,
     .block_size = FLASH_INFO_BLOCK_SIZE,
-    .num_blocks = FLASH_INFO_NUM_BLOCKS,
+    .num_blocks = 0, /* Filled by its_flash_get_info() */
     .program_unit = PS_FLASH_ALIGNMENT,
     .max_file_size = FLASH_INFO_MAX_FILE_SIZE,
     .max_num_files = FLASH_INFO_MAX_NUM_FILES,
     .erase_val = FLASH_INFO_ERASE_VAL,
 };
-
-/* Checks at compile time that the flash device configuration is valid */
-#include \
-"secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs_check_info.h"
diff --git a/secure_fw/partitions/internal_trusted_storage/flash/its_flash_info_internal.c b/secure_fw/partitions/internal_trusted_storage/flash/its_flash_info_internal.c
index 133f540..d8705aa 100644
--- a/secure_fw/partitions/internal_trusted_storage/flash/its_flash_info_internal.c
+++ b/secure_fw/partitions/internal_trusted_storage/flash/its_flash_info_internal.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -15,15 +16,6 @@
 #error "ITS_FLASH_DEV_NAME must be defined by the target in flash_layout.h"
 #endif
 
-#ifndef ITS_FLASH_AREA_ADDR
-#error "ITS_FLASH_AREA_ADDR must be defined by the target in flash_layout.h"
-#endif
-
-/* Adjust to a size that will allow all assets to fit */
-#ifndef ITS_FLASH_AREA_SIZE
-#error "ITS_FLASH_AREA_SIZE must be defined by the target in flash_layout.h"
-#endif
-
 /* Adjust to match the size of the flash device's physical erase unit */
 #ifndef ITS_SECTOR_SIZE
 #error "ITS_SECTOR_SIZE must be defined by the target in flash_layout.h"
@@ -46,6 +38,9 @@
 /* Include the correct flash interface implementation */
 #ifdef ITS_RAM_FS
 #include "its_flash_ram.h"
+#ifndef ITS_RAM_FS_SIZE
+#error "ITS_RAM_FS_SIZE must be defined by the target in flash_layout.h"
+#endif
 #define FLASH_INFO_INIT its_flash_ram_init
 #define FLASH_INFO_READ its_flash_ram_read
 #define FLASH_INFO_WRITE its_flash_ram_write
@@ -79,7 +74,6 @@
 
 /* Calculate the block layout */
 #define FLASH_INFO_BLOCK_SIZE (ITS_SECTOR_SIZE * ITS_SECTORS_PER_BLOCK)
-#define FLASH_INFO_NUM_BLOCKS (ITS_FLASH_AREA_SIZE / FLASH_INFO_BLOCK_SIZE)
 
 /* Maximum file size */
 #define FLASH_INFO_MAX_FILE_SIZE ITS_UTILS_ALIGN(ITS_MAX_ASSET_SIZE, \
@@ -93,7 +87,7 @@
 
 #ifdef ITS_RAM_FS
 /* Allocate a static buffer to emulate storage in RAM */
-static uint8_t its_block_data[FLASH_INFO_BLOCK_SIZE * FLASH_INFO_NUM_BLOCKS];
+static uint8_t its_block_data[ITS_RAM_FS_SIZE];
 #define FLASH_INFO_DEV its_block_data
 #else
 /* Import the CMSIS flash device driver */
@@ -101,22 +95,19 @@
 #define FLASH_INFO_DEV &ITS_FLASH_DEV_NAME
 #endif
 
-const struct its_flash_info_t its_flash_info_internal = {
+struct its_flash_info_t its_flash_info_internal = {
     .init = FLASH_INFO_INIT,
     .read = FLASH_INFO_READ,
     .write = FLASH_INFO_WRITE,
     .flush = FLASH_INFO_FLUSH,
     .erase = FLASH_INFO_ERASE,
     .flash_dev = (void *)FLASH_INFO_DEV,
-    .flash_area_addr = ITS_FLASH_AREA_ADDR,
+    .fs_info = {0, 0}, /* Filled by its_flash_get_info() */
     .sector_size = ITS_SECTOR_SIZE,
     .block_size = FLASH_INFO_BLOCK_SIZE,
-    .num_blocks = FLASH_INFO_NUM_BLOCKS,
+    .num_blocks = 0, /* Filled by its_flash_get_info() */
     .program_unit = ITS_FLASH_ALIGNMENT,
     .max_file_size = FLASH_INFO_MAX_FILE_SIZE,
     .max_num_files = FLASH_INFO_MAX_NUM_FILES,
     .erase_val = FLASH_INFO_ERASE_VAL,
 };
-
-/* Checks at compile time that the flash device configuration is valid */
-#include "flash_fs/its_flash_fs_check_info.h"
diff --git a/secure_fw/partitions/internal_trusted_storage/flash/its_flash_nand.c b/secure_fw/partitions/internal_trusted_storage/flash/its_flash_nand.c
index cd3a802..f6e86d0 100644
--- a/secure_fw/partitions/internal_trusted_storage/flash/its_flash_nand.c
+++ b/secure_fw/partitions/internal_trusted_storage/flash/its_flash_nand.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -25,7 +26,8 @@
 static uint32_t get_phys_address(const struct its_flash_info_t *info,
                                  uint32_t block_id, size_t offset)
 {
-    return info->flash_area_addr + (block_id * info->block_size) + offset;
+    return info->fs_info.flash_area_addr + (block_id * info->block_size)
+            + offset;
 }
 
 psa_status_t its_flash_nand_init(const struct its_flash_info_t *info)
diff --git a/secure_fw/partitions/internal_trusted_storage/flash/its_flash_nor.c b/secure_fw/partitions/internal_trusted_storage/flash/its_flash_nor.c
index 23d1e30..6d9ac10 100644
--- a/secure_fw/partitions/internal_trusted_storage/flash/its_flash_nor.c
+++ b/secure_fw/partitions/internal_trusted_storage/flash/its_flash_nor.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -20,7 +21,8 @@
 static uint32_t get_phys_address(const struct its_flash_info_t *info,
                                  uint32_t block_id, size_t offset)
 {
-    return info->flash_area_addr + (block_id * info->block_size) + offset;
+    return info->fs_info.flash_area_addr + (block_id * info->block_size)
+            + offset;
 }
 
 psa_status_t its_flash_nor_init(const struct its_flash_info_t *info)
diff --git a/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs.c b/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs.c
index 7d6ef1c..c202798 100644
--- a/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs.c
+++ b/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -60,6 +61,11 @@
     psa_status_t err;
     uint32_t idx;
 
+    /* Check for valid flash_info */
+    if (!flash_info) {
+        return PSA_ERROR_STORAGE_FAILURE;
+    }
+
     /* Associate the flash device info with the context */
     fs_ctx->flash_info = flash_info;
 
@@ -502,3 +508,72 @@
 
     return PSA_SUCCESS;
 }
+
+/* TODO This is very similar to (static) its_num_active_dblocks() */
+static uint32_t its_flash_fs_num_active_dblocks(const struct its_flash_info_t *info)
+{
+    /* Total number of datablocks is the number of dedicated datablocks plus
+     * logical datablock 0 stored in the metadata block.
+     */
+    if (info->num_blocks == 2) {
+        /* Metadata and data are stored in the same physical block, and the other
+         * block is required for power failure safe operation.
+         */
+        /* There are no dedicated data blocks when only two blocks are available */
+        return 1;
+    }
+    else {
+        /* One metadata block and two scratch blocks are reserved. One scratch block
+         * for metadata operations and the other for files data operations.
+         */
+        return info->num_blocks - 2;
+    }
+}
+
+static size_t its_flash_fs_all_metadata_size(const struct its_flash_info_t *info)
+{
+    return (sizeof(struct its_metadata_block_header_t)
+            + (its_flash_fs_num_active_dblocks(info)
+                * sizeof(struct its_block_meta_t))
+            + (info->max_num_files * sizeof(struct its_file_meta_t)));
+}
+
+psa_status_t its_flash_fs_validate_params(const struct its_flash_info_t *info)
+{
+    psa_status_t ret = PSA_SUCCESS;
+
+    /* The minimum number of blocks is 2. In this case, metadata and data are
+      * stored in the same physical block, and the other block is required for
+      * power failure safe operation.
+      * If at least 1 data block is available, 1 data scratch block is required for
+      * power failure safe operation. So, in this case, the minimum number of
+      * blocks is 4 (2 metadata block + 2 data blocks).
+      */
+    if ((info->num_blocks < 2) || (info->num_blocks == 3)) {
+        ret = PSA_ERROR_STORAGE_FAILURE;
+    }
+
+    if (info->num_blocks == 2) {
+        /* Metadata and data are stored in the same physical block */
+        if (info->max_file_size > info->block_size
+                                   - its_flash_fs_all_metadata_size(info)) {
+            ret = PSA_ERROR_STORAGE_FAILURE;
+        }
+    }
+
+    /* It is not required that all files fit in ITS flash area at the same time.
+     * So, it is possible that a create action fails because flash is full.
+     * However, the larger file must have enough space in the ITS flash area to be
+     * created, at least, when the ITS flash area is empty.
+     */
+    if (info->max_file_size > info->block_size) {
+        ret = PSA_ERROR_STORAGE_FAILURE;
+    }
+
+    /* Metadata must fit in a flash block */
+    if (its_flash_fs_all_metadata_size(info) > info->block_size) {
+        ret = PSA_ERROR_STORAGE_FAILURE;
+    }
+
+    return ret;
+}
diff --git a/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs.h b/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs.h
index f051786..57431dc 100644
--- a/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs.h
+++ b/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -164,6 +165,18 @@
 psa_status_t its_flash_fs_file_delete(its_flash_fs_ctx_t *fs_ctx,
                                       const uint8_t *fid);
 
+/**
+ * \brief Validates the configuration of the flash filesystem.
+ *
+ * This function checks that the flash block provided is compatible with the
+ * flash_fs described by the info parameter
+ *
+ * \param[in] info        Filesystem information
+ *
+ * \return Returns error code as specified in \ref psa_status_t
+ */
+psa_status_t its_flash_fs_validate_params(const struct its_flash_info_t *info);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs_check_info.h b/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs_check_info.h
deleted file mode 100644
index ac39b63..0000000
--- a/secure_fw/partitions/internal_trusted_storage/flash_fs/its_flash_fs_check_info.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-/**
- * \file its_flash_fs_check_info.h
- *
- * \brief Checks at compile time that the flash device configuration is valid.
- *        Should be included after defining the flash info parameters for a
- *        flash device.
- */
-
-#ifndef __ITS_FLASH_FS_CHECK_INFO_H__
-#define __ITS_FLASH_FS_CHECK_INFO_H__
-
-#include "its_flash_fs_mblock.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ITS_BLOCK_META_HEADER_SIZE  sizeof(struct its_metadata_block_header_t)
-#define ITS_BLOCK_METADATA_SIZE     sizeof(struct its_block_meta_t)
-#define ITS_FILE_METADATA_SIZE      sizeof(struct its_file_meta_t)
-
-#if ((FLASH_INFO_NUM_BLOCKS < 2) || (FLASH_INFO_NUM_BLOCKS == 3))
-  /* The minimum number of blocks is 2. In this case, metadata and data are
-   * stored in the same physical block, and the other block is required for
-   * power failure safe operation.
-   * If at least 1 data block is available, 1 data scratch block is required for
-   * power failure safe operation. So, in this case, the minimum number of
-   * blocks is 4 (2 metadata block + 2 data blocks).
-   */
-  #error "Total number of blocks should be 2 or bigger than 3"
-#endif
-
-/* The numbers in the defines are physical block indexes, starting from 0,
- * except for ITS_NUM_DEDICATED_DBLOCKS.
- */
-#if (FLASH_INFO_NUM_BLOCKS == 2)
-  /* Metadata and data are stored in the same physical block, and the other
-   * block is required for power failure safe operation.
-   */
-
-  /* Initial position of scratch block is the scratch metadata block */
-  #define ITS_INIT_SCRATCH_DBLOCK 1
-
-  /* Metadata and data are stored in the same block */
-  #define ITS_INIT_DBLOCK_START 0
-
-  /* There are no dedicated data blocks when only two blocks are available */
-  #define ITS_NUM_DEDICATED_DBLOCKS 0
-
-#else
-
-  /* Initial position of scratch block is immediately after metadata blocks */
-  #define ITS_INIT_SCRATCH_DBLOCK 2
-
-  /* One metadata block and two scratch blocks are reserved. One scratch block
-   * for metadata operations and the other for files data operations.
-   */
-  #define ITS_INIT_DBLOCK_START 3
-
-  /* Number of blocks dedicated just for data is the number of blocks available
-   * beyond the initial datablock start index.
-   */
-  #define ITS_NUM_DEDICATED_DBLOCKS (FLASH_INFO_NUM_BLOCKS - \
-                                     ITS_INIT_DBLOCK_START)
-#endif /* FLASH_INFO_NUM_BLOCKS == 2 */
-
-/* Total number of datablocks is the number of dedicated datablocks plus
- * logical datablock 0 stored in the metadata block.
- */
-#define ITS_NUM_ACTIVE_DBLOCKS (ITS_NUM_DEDICATED_DBLOCKS + 1)
-
-#define ITS_ALL_METADATA_SIZE \
-    (ITS_BLOCK_META_HEADER_SIZE \
-     + (ITS_NUM_ACTIVE_DBLOCKS * ITS_BLOCK_METADATA_SIZE) \
-     + (FLASH_INFO_MAX_NUM_FILES * ITS_FILE_METADATA_SIZE))
-
-/* It is not required that all files fit in ITS flash area at the same time.
- * So, it is possible that a create action fails because flash is full.
- * However, the larger file must have enough space in the ITS flash area to be
- * created, at least, when the ITS flash area is empty.
- */
-/* Checks at compile time if the largest file fits in the data area */
-ITS_UTILS_BOUND_CHECK(LARGEST_ITS_FILE_NOT_FIT_IN_DATA_BLOCK,
-                      FLASH_INFO_MAX_FILE_SIZE, FLASH_INFO_BLOCK_SIZE);
-
-#if (FLASH_INFO_NUM_BLOCKS == 2)
-ITS_UTILS_BOUND_CHECK(ITS_FILE_NOT_FIT_IN_DATA_AREA, FLASH_INFO_MAX_FILE_SIZE,
-                      (FLASH_INFO_BLOCK_SIZE - ITS_ALL_METADATA_SIZE));
-#endif
-
-/* Checks at compile time if the metadata fits in a flash block */
-ITS_UTILS_BOUND_CHECK(ITS_METADATA_NOT_FIT_IN_METADATA_BLOCK,
-                      ITS_ALL_METADATA_SIZE, FLASH_INFO_BLOCK_SIZE);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __ITS_FLASH_FS_CHECK_INFO_H__ */