configs: Enable Semihosting for baremetal.py
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 20 Mar 2020 19:22:58 +0000 (19:22 +0000)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 25 Mar 2020 09:37:26 +0000 (09:37 +0000)
This is enabled via the --semihosting option

Change-Id: If6961cba8ec4a3aa22e788db6fe0ae54e169bb9c
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26993
Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>

configs/example/arm/baremetal.py

index c691a7d82e7589a45415ba214bf698c5c9f9f0d5..85ded9c5a4147f9456de5709f108dba78294c815 100644 (file)
@@ -104,6 +104,14 @@ def create(args):
 
     MemConfig.config_mem(args, system)
 
+    if args.semi_enable:
+        system.semihosting = ArmSemihosting(
+            stdin=args.semi_stdin,
+            stdout=args.semi_stdout,
+            stderr=args.semi_stderr,
+            cmd_line = " ".join([ args.kernel ] + args.args)
+        )
+
     # Add the PCI devices we need for this system. The base system
     # doesn't have any PCI devices by default since they are assumed
     # to be added by the configurastion scripts needin them.
@@ -203,7 +211,19 @@ def main():
     parser.add_argument("--restore", type=str, default=None)
     parser.add_argument("--dtb-gen", action="store_true",
                         help="Doesn't run simulation, it generates a DTB only")
-
+    parser.add_argument("--semi-enable", action="store_true",
+                        help="Enable semihosting support")
+    parser.add_argument("--semi-stdin", type=str, default="stdin",
+                        help="Standard input for semihosting " \
+                        "(default: gem5's stdin)")
+    parser.add_argument("--semi-stdout", type=str, default="stdout",
+                        help="Standard output for semihosting " \
+                        "(default: gem5's stdout)")
+    parser.add_argument("--semi-stderr", type=str, default="stderr",
+                        help="Standard error for semihosting " \
+                        "(default: gem5's stderr)")
+    parser.add_argument("args", default=[], nargs="*",
+                        help="Semihosting arguments to pass to benchmark")
 
     args = parser.parse_args()