Platform: Make manifest files common for all targets

And remove unnecessary sub-dir such as common/ and ipc/
This would make easy integration of FF tests with TFM.

Change-Id: I6eb903ae16136b9ce54430e03102524bc0afc83f
Signed-off-by: Jaykumar Pitambarbhai Patel <jaykumar.pitambarbhaipatel@arm.com>
diff --git a/api-tests/docs/porting_guide_ff.md b/api-tests/docs/porting_guide_ff.md
index 4e5f612..a224d5c 100644
--- a/api-tests/docs/porting_guide_ff.md
+++ b/api-tests/docs/porting_guide_ff.md
@@ -36,7 +36,7 @@
   1. Create a new directory in **platform/targets/<platform_name>**. For reference, see the existing platform tgt_ff_tfm_an521 directory.
   2. Execute `cp -rf platform/targets/tgt_ff_tfm_an521/ platform/targets/<platform_name>/`.
   3. Update **platform/targets/<platform_name>/target.cfg** with your target platform details. Refer to **val/common/val_target.h** for structure details.
-  4. Update the platform information available in manifest files located in  **platform/targets/<platform_name>/manifests/** directory with your platform information. The platform details must match the device details provided in the target.cfg file.
+  4. Update the platform information available in manifest files located in  **platform/manifests/** directory with your platform information. The platform details must match the device details provided in the target.cfg file.
   5. Update **platform/targets/<platform_name>/target.cmake** appropriately to select the correct instances of PAL files for compilation.
   6. Refer to the **List of PAL APIs** section to view the list of PAL APIs that must be ported for your target platform. These API definitions are available in **nspe/<suite_name>/pal_\*\_intf.c** and **spe/pal_\*\_intf.c** files. These APIs are written for **tgt_ff_tfm_an521** platform. You can reuse the code if it works for your platform. Otherwise, you must port them for your platform-specific peripherals.
 
@@ -71,4 +71,4 @@
 
 --------------
 
-*Copyright (c) 2018-2019, Arm Limited and Contributors. All rights reserved.*
+*Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved.*
diff --git a/api-tests/ff/README.md b/api-tests/ff/README.md
index deb09a8..75d1197 100644
--- a/api-tests/ff/README.md
+++ b/api-tests/ff/README.md
@@ -41,13 +41,15 @@
 
 1. Execute `cd api-tests`.
 
-2. Using your Secure partition build tool, parse the following test suite partition manifest files and generate manifest output files. The manifest parsing tool must be compliant with the manifest rules defined in the PSA FF specification.<br />
-   <br />The test suite manifests to be parsed are:<br />
-   - **platform/targets/<platform_name>/manifests/common/driver_partition_psa.json**
-   - **platform/targets/<platform_name>/manifests/ipc/client_partition_psa.json**
-   - **platform/targets/<platform_name>/manifests/ipc/server_partition_psa.json**
+2. Execute `python tools/scripts/manifest_update.py` to remove heap_size field from PSA test suite manifest files if your platform doesn't support the dynamic memory functions for the secure partition. Otherwise, skip this step.
 
-3. Compile the tests as shown below. <br />
+3. Using your Secure partition build tool, parse the following test suite partition manifest files and generate manifest output files. The manifest parsing tool must be compliant with the manifest rules defined in the PSA FF specification.<br />
+   <br />The test suite manifests to be parsed are:<br />
+   - **platform/manifests/driver_partition_psa.json**
+   - **platform/manifests/client_partition_psa.json**
+   - **platform/manifests/server_partition_psa.json**
+
+4. Compile the tests as shown below. <br />
 ```
     cd api-tests
     mkdir <build_dir>
@@ -131,4 +133,4 @@
 
 --------------
 
-*Copyright (c) 2018-2019, Arm Limited and Contributors. All rights reserved.*
+*Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved.*
diff --git a/api-tests/ff/partition/ipc/client_partition.c b/api-tests/ff/partition/client_partition.c
similarity index 100%
rename from api-tests/ff/partition/ipc/client_partition.c
rename to api-tests/ff/partition/client_partition.c
diff --git a/api-tests/ff/partition/ipc/client_partition.h b/api-tests/ff/partition/client_partition.h
similarity index 100%
rename from api-tests/ff/partition/ipc/client_partition.h
rename to api-tests/ff/partition/client_partition.h
diff --git a/api-tests/ff/partition/common/driver_partition.c b/api-tests/ff/partition/driver_partition.c
similarity index 100%
rename from api-tests/ff/partition/common/driver_partition.c
rename to api-tests/ff/partition/driver_partition.c
diff --git a/api-tests/ff/partition/ipc/server_partition.c b/api-tests/ff/partition/server_partition.c
similarity index 100%
rename from api-tests/ff/partition/ipc/server_partition.c
rename to api-tests/ff/partition/server_partition.c
diff --git a/api-tests/ff/partition/ipc/server_partition.h b/api-tests/ff/partition/server_partition.h
similarity index 100%
rename from api-tests/ff/partition/ipc/server_partition.h
rename to api-tests/ff/partition/server_partition.h
diff --git a/api-tests/platform/targets/tgt_ff_tfm_an521/manifests/ipc/client_partition_psa.json b/api-tests/platform/manifests/client_partition_psa.json
similarity index 100%
rename from api-tests/platform/targets/tgt_ff_tfm_an521/manifests/ipc/client_partition_psa.json
rename to api-tests/platform/manifests/client_partition_psa.json
diff --git a/api-tests/platform/targets/tgt_ff_tfm_an521/manifests/common/driver_partition_psa.json b/api-tests/platform/manifests/driver_partition_psa.json
similarity index 79%
rename from api-tests/platform/targets/tgt_ff_tfm_an521/manifests/common/driver_partition_psa.json
rename to api-tests/platform/manifests/driver_partition_psa.json
index 7bc6649..2fa4550 100644
--- a/api-tests/platform/targets/tgt_ff_tfm_an521/manifests/common/driver_partition_psa.json
+++ b/api-tests/platform/manifests/driver_partition_psa.json
@@ -38,27 +38,19 @@
   ],
   "mmio_regions" : [
     {
-      "name": "UART_REGION",
-      "base": "0x50202000",
-      "size": "0x1000",
+      "name": "TEST_UART_REGION",
       "permission": "READ-WRITE"
     },
     {
-      "name": "WATCHDOG_REGION",
-      "base": "0x50081000",
-      "size": "0x1000",
+      "name": "TEST_WATCHDOG_REGION",
       "permission": "READ-WRITE"
     },
     {
-      "name": "NVMEM_REGION",
-      "base": "0x102FFC00",
-      "size": "0x400",
+      "name": "TEST_NVMEM_REGION",
       "permission": "READ-WRITE"
     },
     {
-      "name": "DRIVER_PARTITION_MMIO",
-      "base": "0x10300F20",
-      "size": "0x20",
+      "name": "TEST_DRIVER_PARTITION_MMIO",
       "permission": "READ-WRITE"
     }
   ],
diff --git a/api-tests/platform/targets/tgt_ff_tfm_an521/manifests/ipc/server_partition_psa.json b/api-tests/platform/manifests/server_partition_psa.json
similarity index 94%
rename from api-tests/platform/targets/tgt_ff_tfm_an521/manifests/ipc/server_partition_psa.json
rename to api-tests/platform/manifests/server_partition_psa.json
index 907aaa2..0608200 100644
--- a/api-tests/platform/targets/tgt_ff_tfm_an521/manifests/ipc/server_partition_psa.json
+++ b/api-tests/platform/manifests/server_partition_psa.json
@@ -61,9 +61,7 @@
   ],
   "mmio_regions" : [
     {
-      "name": "SERVER_PARTITION_MMIO",
-      "base": "0x10300F00",
-      "size": "0x20",
+      "name": "TEST_SERVER_PARTITION_MMIO",
       "permission": "READ-WRITE"
     }
    ]
diff --git a/api-tests/platform/targets/tgt_ff_tfm_musca_a/manifests/common/driver_partition_psa.json b/api-tests/platform/targets/tgt_ff_tfm_musca_a/manifests/common/driver_partition_psa.json
deleted file mode 100644
index 6a8adf9..0000000
--- a/api-tests/platform/targets/tgt_ff_tfm_musca_a/manifests/common/driver_partition_psa.json
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-  "psa_framework_version": 1.0,
-  "name": "DRIVER_PARTITION",
-  "type": "PSA-ROT",
-  "priority": "NORMAL",
-  "description": "Implements device services such print, flash read/write,. etc.",
-  "entry_point": "driver_main",
-  "stack_size": "0x400",
-  "heap_size": "0x100",
-  "services": [{
-      "name": "DRIVER_UART",
-      "sid": "0x0000FC01",
-      "non_secure_clients": true,
-      "version": 1,
-      "version_policy": "RELAXED"
-    },
-    {
-      "name": "DRIVER_WATCHDOG",
-      "sid": "0x0000FC02",
-      "non_secure_clients": true,
-      "version": 1,
-      "version_policy": "RELAXED"
-    },
-    {
-      "name": "DRIVER_NVMEM",
-      "sid": "0x0000FC03",
-      "non_secure_clients": true,
-      "version": 1,
-      "version_policy": "RELAXED"
-    },
-    {
-      "name": "DRIVER_TEST",
-      "sid": "0x0000FC04",
-      "non_secure_clients": true,
-      "version": 1,
-      "version_policy": "RELAXED"
-    }
-  ],
-  "mmio_regions" : [
-    {
-      "name": "UART_REGION",
-      "base": "0x40102000",
-      "size": "0x1000",
-      "permission": "READ-WRITE"
-    },
-    {
-      "name": "WATCHDOG_REGION",
-      "base": "0x50081000",
-      "size": "0x1000",
-      "permission": "READ-WRITE"
-    },
-    {
-      "name": "NVMEM_REGION",
-      "base": "0x30017C00",
-      "size": "0x400",
-      "permission": "READ-WRITE"
-    },
-    {
-      "name": "DRIVER_PARTITION_MMIO",
-      "base": "0x10200F20",
-      "size": "0x20",
-      "permission": "READ-WRITE"
-    }
-  ],
-  "irqs": [
-    {
-       "description": "Using UART TX interrupt to test psa_wait and psa_eoi for irq_signal",
-       "signal": "DRIVER_UART_INTR_SIG",
-       "source": "UARTTX_IRQ"
-    }
-  ]
-}
diff --git a/api-tests/platform/targets/tgt_ff_tfm_musca_a/manifests/ipc/client_partition_psa.json b/api-tests/platform/targets/tgt_ff_tfm_musca_a/manifests/ipc/client_partition_psa.json
deleted file mode 100644
index c0fb05b..0000000
--- a/api-tests/platform/targets/tgt_ff_tfm_musca_a/manifests/ipc/client_partition_psa.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
-  "psa_framework_version": 1.0,
-  "name": "CLIENT_PARTITION",
-  "type": "APPLICATION-ROT",
-  "priority": "NORMAL",
-  "description": "Client partition executing client test func from SPE",
-  "entry_point": "client_main",
-  "stack_size": "0x400",
-  "services": [{
-      "name": "CLIENT_TEST_DISPATCHER",
-      "sid": "0x0000FA01",
-      "non_secure_clients": true,
-      "version": 1,
-      "version_policy": "RELAXED"
-    }
-  ],
-  "dependencies": [
-    "DRIVER_UART",
-    "DRIVER_NVMEM",
-    "DRIVER_TEST",
-    "SERVER_TEST_DISPATCHER",
-    "SERVER_UNSPECIFED_VERSION",
-    "SERVER_STRICT_VERSION",
-    "SERVER_RELAX_VERSION",
-    "SERVER_SECURE_CONNECT_ONLY",
-    "SERVER_CONNECTION_DROP"
-  ]
-}
diff --git a/api-tests/platform/targets/tgt_ff_tfm_musca_a/manifests/ipc/server_partition_psa.json b/api-tests/platform/targets/tgt_ff_tfm_musca_a/manifests/ipc/server_partition_psa.json
deleted file mode 100644
index 5a1955b..0000000
--- a/api-tests/platform/targets/tgt_ff_tfm_musca_a/manifests/ipc/server_partition_psa.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
-  "psa_framework_version": 1.0,
-  "name": "SERVER_PARTITION",
-  "type": "APPLICATION-ROT",
-  "priority": "NORMAL",
-  "description": "Server partition executing server test func",
-  "entry_point": "server_main",
-  "stack_size": "0x400",
-  "heap_size": "0x100",
-  "services": [{
-      "name": "SERVER_TEST_DISPATCHER",
-      "sid": "0x0000FB01",
-      "non_secure_clients": true,
-      "version": 1,
-      "version_policy": "RELAXED"
-    },
-    {
-      "name": "SERVER_SECURE_CONNECT_ONLY",
-      "sid": "0x0000FB02",
-      "non_secure_clients": false,
-      "version": 2,
-      "version_policy": "RELAXED"
-    },
-    {
-      "name": "SERVER_STRICT_VERSION",
-      "sid": "0x0000FB03",
-      "non_secure_clients": true,
-      "version": 2,
-      "version_policy": "STRICT"
-    },
-    {
-      "name": "SERVER_UNSPECIFED_VERSION",
-      "sid": "0x0000FB04",
-      "non_secure_clients": true
-    },
-    {
-      "name": "SERVER_RELAX_VERSION",
-      "sid": "0x0000FB05",
-      "non_secure_clients": true,
-      "version": 2,
-      "version_policy": "RELAXED"
-    },
-    {
-      "name": "SERVER_UNEXTERN",
-      "sid": "0x0000FB06",
-      "non_secure_clients": true,
-      "version": 2,
-      "version_policy": "RELAXED"
-    },
-    {
-      "name": "SERVER_CONNECTION_DROP",
-      "sid": "0x0000FB07",
-      "non_secure_clients": true,
-      "version": 2,
-      "version_policy": "RELAXED"
-    }
-  ],
-  "mmio_regions" : [
-    {
-      "name": "SERVER_PARTITION_MMIO",
-      "base": "0x10200F00",
-      "size": "0x20",
-      "permission": "READ-WRITE"
-    }
-   ],
-  "dependencies": [
-    "DRIVER_UART",
-    "DRIVER_NVMEM"
-  ]
-}
diff --git a/api-tests/tools/scripts/manifest_update.py b/api-tests/tools/scripts/manifest_update.py
index 65c693e..21447ae 100644
--- a/api-tests/tools/scripts/manifest_update.py
+++ b/api-tests/tools/scripts/manifest_update.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #/** @file
-# * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved.
+# * Copyright (c) 2019-2020, Arm Limited or its affiliates. All rights reserved.
 # * SPDX-License-Identifier : Apache-2.0
 # *
 # * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,64 +21,22 @@
 import shutil
 from argparse import ArgumentParser
 
-driver_linker_pattern = \
-'   ],\n'\
-'   "linker_pattern": {\n'\
-'     "library_list": [\n'\
-'     "*driver_partition.a"\n'\
-'   ]\n'\
-' }\n'
-client_linker_pattern = \
-'   ],\n'\
-'   "linker_pattern": {\n'\
-'     "library_list": [\n'\
-'     "*client_partition.a"\n'\
-'   ]\n'\
-' }\n'
-server_linker_pattern = \
-'   ],\n'\
-'   "linker_pattern": {\n'\
-'     "library_list": [\n'\
-'     "*server_partition.a"\n'\
-'   ]\n'\
-' }\n'
-
-def update_manifest_file(manifest_dir_path, sp_heap_mem_supp, add_linker_pattern):
+def update_manifest_file(manifest_dir_path):
 	"""
 	- Remove heap_size field from manifest if dynamic memory function is not supported.
-	- TFM needs special linker pattern field(other than PSA FF defined field)
-	  in manifest to place partition code/data at appropriate places in the memory.
-	  This routine appends these linker pattern to the available manifest files.
 	"""
-	linker_pattern_present = 0
-	driver_partition_manifest = manifest_dir_path+"/common/driver_partition_psa.json"
-	client_partition_manifest = manifest_dir_path+"/ipc/client_partition_psa.json"
-	server_partition_manifest = manifest_dir_path+"/ipc/server_partition_psa.json"
-	file_pattern_dict = {driver_partition_manifest:driver_linker_pattern,
-						 client_partition_manifest:client_linker_pattern,
-						 server_partition_manifest:server_linker_pattern}
+	file_list =	[manifest_dir_path+"/driver_partition_psa.json",
+				manifest_dir_path+"/client_partition_psa.json",
+				manifest_dir_path+"/server_partition_psa.json"]
 
-	for file,pattern in file_pattern_dict.items():
+	for file in file_list:
 		print("Updating "+file+" manifest file")
 		f_i = open(file, 'r')
 		f_o = open(file+".update", 'w')
 		f1 = f_i.readlines()
 		for line in f1:
-				if (add_linker_pattern == "1"):
-					if (linker_pattern_present == 1):
-						f_o.write(line)
-						continue
-					if (re.findall('linker_pattern', line)):
-						linker_pattern_present = 1
-						f_o.write(line)
-						continue
-					if (re.findall(']$', line)):
-						f_o.write(pattern)
-						continue
-
-				if (sp_heap_mem_supp == "0"):
-					if (re.findall('heap_size', line)):
-						continue
+				if (re.findall('heap_size', line)):
+					continue
 				f_o.write(line)
 		shutil.move(file+".update", file)
 
@@ -86,26 +44,15 @@
 	"""
 	Parse the command line argument
 	"""
-	parser = ArgumentParser(description='Utility to update manifest files')
-	parser.add_argument('--manifest_dir_path', help="Absolute path for manifest directory",
-                        type=str, action="store", dest='manifest_dir_path')
-	parser.add_argument('--sp_heap_mem_supp',
-						help="Pass 1 if platform supports dynamic memory functions \
-						for secure partition otherwise 0. Default is 1. Passing 0 \
-						will remove the heap_size field from the manifest",
-                        type=str, action="store", dest='sp_heap_mem_supp')
-	parser.add_argument('--add_linker_pattern', help="Pass 1 if platform is Trusted Firmware-M otherwise 0.\
-						This updates the manifest files with TFM required linker pattern",
-                        type=str, action="store", dest='add_linker_pattern')
+	parser = ArgumentParser(description='Utility to remove heap_size field from manifest files. \
+							Heap_size field is optional feature and use this script to remove it\
+							when dynamic memory function are not available to secure partition.')
 	options = parser.parse_args()
 
-	if (len(sys.argv) != 4):
-		print("\n Invaild number of arguments. Refer help message.")
-		sys.exit(1)
-
 	return options
 
 #main code starts here
 if __name__ == "__main__":
+	manifest_dir_path =	"platform/manifests"
 	options = argparse()
-	update_manifest_file(options.manifest_dir_path, options.sp_heap_mem_supp, options.add_linker_pattern)
+	update_manifest_file(manifest_dir_path)
diff --git a/api-tests/val/val_spe.cmake b/api-tests/val/val_spe.cmake
index c921d8a..be1e550 100644
--- a/api-tests/val/val_spe.cmake
+++ b/api-tests/val/val_spe.cmake
@@ -1,5 +1,5 @@
 #/** @file
-# * Copyright (c) 2019, Arm Limited or its affiliates. All rights reserved.
+# * Copyright (c) 2019-2020, Arm Limited or its affiliates. All rights reserved.
 # * SPDX-License-Identifier : Apache-2.0
 # *
 # * Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,16 +22,16 @@
 
 # Listing common sources from partition
 list(APPEND PARTITION_COMMON_SRC_C_SPE
-	${PSA_ROOT_DIR}/ff/partition/common/driver_partition.c
+	${PSA_ROOT_DIR}/ff/partition/driver_partition.c
 )
 
 # Listing sources from partition for client
 list(APPEND PARTITION_IPC_CLIENT_SRC_C_SPE
-	${PSA_ROOT_DIR}/ff/partition/ipc/client_partition.c
+	${PSA_ROOT_DIR}/ff/partition/client_partition.c
 )
 # Listing sources from partition for server
 list(APPEND PARTITION_IPC_SERVER_SRC_C_SPE
-	${PSA_ROOT_DIR}/ff/partition/ipc/server_partition.c
+	${PSA_ROOT_DIR}/ff/partition/server_partition.c
 )
 
 foreach(src_file ${SUITE_CC_SOURCE_SPE})
@@ -57,7 +57,7 @@
 	${CMAKE_CURRENT_BINARY_DIR}
 	${PSA_ROOT_DIR}/val/common
 	${PSA_ROOT_DIR}/val/spe
-	${PSA_ROOT_DIR}/ff/partition/common
+	${PSA_ROOT_DIR}/ff/partition
 	${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/common
 	${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/crypto
 )
@@ -74,7 +74,7 @@
 	${PSA_ROOT_DIR}/val/spe
 	${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/common
 	${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/crypto
-	${PSA_ROOT_DIR}/ff/partition/ipc
+	${PSA_ROOT_DIR}/ff/partition
 )
 target_include_directories(${PSA_TARGET_SERVER_PARTITION_LIB} PRIVATE
 	${CMAKE_CURRENT_BINARY_DIR}
@@ -82,7 +82,7 @@
 	${PSA_ROOT_DIR}/val/spe
 	${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/common
 	${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/crypto
-	${PSA_ROOT_DIR}/ff/partition/ipc
+	${PSA_ROOT_DIR}/ff/partition
 )
 
 # PSA Include directories