Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/25947 )

Change subject: arm: Optionally enable gem5 extended semihosting calls.
......................................................................

arm: Optionally enable gem5 extended semihosting calls.

ARM's semihosting interface defines call numbers up to 0xff to be
for standardized use, and says that custom calls should go above this
number.

This new mechanism will let the caller decide whether it wants to
enable these extended calls, or if they should be ignored and only
standard calls should be recognized.

Change-Id: I34b01a4439c8a88242971ac486e34d810b054baf
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25947
Reviewed-by: Giacomo Travaglini <giacomo.travagl...@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/arch/arm/semihosting.cc
M src/arch/arm/semihosting.hh
M src/arch/arm/system.cc
M src/arch/arm/system.hh
4 files changed, 20 insertions(+), 10 deletions(-)

Approvals:
  Giacomo Travaglini: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/arch/arm/semihosting.cc b/src/arch/arm/semihosting.cc
index 5ea894a..b6db38a 100644
--- a/src/arch/arm/semihosting.cc
+++ b/src/arch/arm/semihosting.cc
@@ -154,9 +154,14 @@
 }

 void
-ArmSemihosting::call64(ThreadContext *tc)
+ArmSemihosting::call64(ThreadContext *tc, bool gem5_ops)
 {
     RegVal op = tc->readIntReg(ArmISA::INTREG_X0 & mask(32));
+    if (op > MaxStandardOp && !gem5_ops) {
+        unrecognizedCall<Abi64>(
+                tc, "Gem5 semihosting op (0x%x) disabled from here.", op);
+        return;
+    }

     auto it = calls.find(op);
     if (it == calls.end()) {
@@ -173,9 +178,14 @@
 }

 void
-ArmSemihosting::call32(ThreadContext *tc)
+ArmSemihosting::call32(ThreadContext *tc, bool gem5_ops)
 {
     RegVal op = tc->readIntReg(ArmISA::INTREG_R0);
+    if (op > MaxStandardOp && !gem5_ops) {
+        unrecognizedCall<Abi32>(
+                tc, "Gem5 semihosting op (0x%x) disabled from here.", op);
+        return;
+    }

     auto it = calls.find(op);
     if (it == calls.end()) {
diff --git a/src/arch/arm/semihosting.hh b/src/arch/arm/semihosting.hh
index 4a8aa2b..9aa5b41 100644
--- a/src/arch/arm/semihosting.hh
+++ b/src/arch/arm/semihosting.hh
@@ -214,9 +214,9 @@
     ArmSemihosting(const ArmSemihostingParams *p);

     /** Perform an Arm Semihosting call from aarch64 code. */
-    void call64(ThreadContext *tc);
+    void call64(ThreadContext *tc, bool gem5_ops);
     /** Perform an Arm Semihosting call from aarch32 code. */
-    void call32(ThreadContext *tc);
+    void call32(ThreadContext *tc, bool gem5_ops);

   public: // SimObject and related interfaces
     void serialize(CheckpointOut &cp) const override;
diff --git a/src/arch/arm/system.cc b/src/arch/arm/system.cc
index 906cc9e..e61402a 100644
--- a/src/arch/arm/system.cc
+++ b/src/arch/arm/system.cc
@@ -180,15 +180,15 @@
 }

 void
-ArmSystem::callSemihosting64(ThreadContext *tc)
+ArmSystem::callSemihosting64(ThreadContext *tc, bool gem5_ops)
 {
-    getArmSystem(tc)->semihosting->call64(tc);
+    getArmSystem(tc)->semihosting->call64(tc, gem5_ops);
 }

 void
-ArmSystem::callSemihosting32(ThreadContext *tc)
+ArmSystem::callSemihosting32(ThreadContext *tc, bool gem5_ops)
 {
-    getArmSystem(tc)->semihosting->call32(tc);
+    getArmSystem(tc)->semihosting->call32(tc, gem5_ops);
 }

 void
diff --git a/src/arch/arm/system.hh b/src/arch/arm/system.hh
index ae83da0..fc32d0f 100644
--- a/src/arch/arm/system.hh
+++ b/src/arch/arm/system.hh
@@ -314,10 +314,10 @@
     static bool haveSemihosting(ThreadContext *tc);

     /** Make a Semihosting call from aarch64 */
-    static void callSemihosting64(ThreadContext *tc);
+    static void callSemihosting64(ThreadContext *tc, bool gem5_ops=false);

     /** Make a Semihosting call from aarch32 */
-    static void callSemihosting32(ThreadContext *tc);
+    static void callSemihosting32(ThreadContext *tc, bool gem5_ops=false);

/** Make a call to notify the power controller of STANDBYWFI assertion */
     static void callSetStandByWfi(ThreadContext *tc);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/25947
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I34b01a4439c8a88242971ac486e34d810b054baf
Gerrit-Change-Number: 25947
Gerrit-PatchSet: 14
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Chun-Chen TK Hsu <chunchen...@google.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to