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_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.*