Adding Corstone-Polaris target

Corstone-Polaris is the upcoming Corstone-3xx platform featuring
the Cortex-Olympus CPU.

Change-Id: I17b56b6e94f040e7f9a39dddad2e98309c82b294
diff --git a/scripts/run_ctest.py b/scripts/run_ctest.py
index 3e7abfc..cc02226 100755
--- a/scripts/run_ctest.py
+++ b/scripts/run_ctest.py
@@ -44,6 +44,23 @@
     __print_arguments(args)
     return subprocess.check_output(args, **kwargs)
 
+def run_fvp(cmd):
+    # Run FVP and tee output to console while scanning for exit tag
+    ret = 1
+    proc = Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    while True:
+        line = proc.stdout.readline().decode()
+        if not line:
+                break
+
+        if 'Application exit code: 0.' in line:
+            ret = 0
+
+        sys.stdout.write(line)
+        sys.stdout.flush()
+
+    return ret
+
 def run_corstone_300(args):
     if not args.arch or args.arch == 'ethos-u55':
         fvp = 'FVP_Corstone_SSE-300_Ethos-U55'
@@ -74,25 +91,42 @@
 
     cmd += args.args
 
-    # Run FVP and tee output to console while scanning for exit tag
-    ret = 1
-    proc = Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-    while True:
-        line = proc.stdout.readline().decode()
-        if not line:
-                break
+    return run_fvp(cmd)
 
-        if 'Application exit code: 0.' in line:
-            ret = 0
+def run_corstone_polaris(args):
+    # Verify supported FVP version
+    version = subprocess.check_output(['FVP_Corstone-Polaris', '--version']).decode()
+    supported_version = ['11.16']
 
-        sys.stdout.write(line)
-        sys.stdout.flush()
+    if not [s for s in supported_version if s in version]:
+        raise Exception("Incorrect FVP version. Supported versions are '{}'.".format(supported_version))
 
-    return ret
+    # FVP executable
+    cmd = ['FVP_Corstone-Polaris']
+
+    # NPU configuration
+    cmd += ['-C', 'ethosu.num_macs=' + str(args.macs)]
+
+    # 32kB ITCM, 32kB DTCM, 2MB SRAM
+    cmd += ['-C', 'cpu0.CFGITCMSZ=6',
+            '-C', 'cpu0.CFGDTCMSZ=6',
+            '-C', 'mps3_board.sse300.NUMVMBANK=1',
+            '-C', 'mps3_board.sse300.VM_BANK_SIZE=2048']
+
+    # Output parameters
+    cmd += ['-C', 'mps3_board.visualisation.disable-visualisation=1',
+            '-C', 'mps3_board.telnetterminal0.start_telnet=0',
+            '-C', 'mps3_board.uart0.out_file="-"',
+            '-C', 'mps3_board.uart0.unbuffered_output=1',
+            '-C', 'mps3_board.uart0.shutdown_on_eot=1']
+
+    cmd += args.args
+
+    return run_fvp(cmd)
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description='Run a test with given test command and test binary.')
-    parser.add_argument('-t', '--target', choices=['corstone-300'], required=True, help='FVP target.')
+    parser.add_argument('-t', '--target', choices=['corstone-300', 'corstone-polaris'], required=True, help='FVP target.')
     parser.add_argument('-a', '--arch', choices=['ethos-u55', 'ethos-u65'], help='NPU architecture.')
     parser.add_argument('-m', '--macs', type=int, choices=[32, 64, 128, 256], default=128, help='NPU number of MACs.')
     parser.add_argument('args', nargs='+', help='Arguments.')
@@ -100,3 +134,5 @@
 
     if args.target == 'corstone-300':
         sys.exit(run_corstone_300(args))
+    elif args.target == 'corstone-polaris':
+        sys.exit(run_corstone_polaris(args))