arm: Return whether a semihosting call was recognized/handled.
Otherwise there's no way to determine whether the return value was from the semihosting mechanism itself, or from one of the calls. There would also be no way to determine whether a call had actually happened. Change-Id: Ie2da812172fe2f9c1e2b5be95561863bd12920b1 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25949 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com>
This commit is contained in:
@@ -153,21 +153,21 @@ ArmSemihosting::ArmSemihosting(const ArmSemihostingParams *p)
|
||||
tickShift);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto it = calls.find(op);
|
||||
if (it == calls.end()) {
|
||||
unrecognizedCall<Abi64>(
|
||||
tc, "Unknown aarch64 semihosting call: op = 0x%x", op);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
const SemiCall &call = it->second;
|
||||
|
||||
@@ -175,23 +175,25 @@ ArmSemihosting::call64(ThreadContext *tc, bool gem5_ops)
|
||||
auto err = call.call64(this, tc);
|
||||
semiErrno = err.second;
|
||||
DPRINTF(Semihosting, "\t ->: 0x%x, %i\n", err.first, err.second);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto it = calls.find(op);
|
||||
if (it == calls.end()) {
|
||||
unrecognizedCall<Abi32>(
|
||||
tc, "Unknown aarch32 semihosting call: op = 0x%x", op);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
const SemiCall &call = it->second;
|
||||
|
||||
@@ -199,6 +201,8 @@ ArmSemihosting::call32(ThreadContext *tc, bool gem5_ops)
|
||||
auto err = call.call32(this, tc);
|
||||
semiErrno = err.second;
|
||||
DPRINTF(Semihosting, "\t ->: 0x%x, %i\n", err.first, err.second);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -214,9 +214,9 @@ class ArmSemihosting : public SimObject
|
||||
ArmSemihosting(const ArmSemihostingParams *p);
|
||||
|
||||
/** Perform an Arm Semihosting call from aarch64 code. */
|
||||
void call64(ThreadContext *tc, bool gem5_ops);
|
||||
bool call64(ThreadContext *tc, bool gem5_ops);
|
||||
/** Perform an Arm Semihosting call from aarch32 code. */
|
||||
void call32(ThreadContext *tc, bool gem5_ops);
|
||||
bool call32(ThreadContext *tc, bool gem5_ops);
|
||||
|
||||
public: // SimObject and related interfaces
|
||||
void serialize(CheckpointOut &cp) const override;
|
||||
|
||||
@@ -179,16 +179,16 @@ ArmSystem::haveSemihosting(ThreadContext *tc)
|
||||
return FullSystem && getArmSystem(tc)->haveSemihosting();
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ArmSystem::callSemihosting64(ThreadContext *tc, bool gem5_ops)
|
||||
{
|
||||
getArmSystem(tc)->semihosting->call64(tc, gem5_ops);
|
||||
return getArmSystem(tc)->semihosting->call64(tc, gem5_ops);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ArmSystem::callSemihosting32(ThreadContext *tc, bool gem5_ops)
|
||||
{
|
||||
getArmSystem(tc)->semihosting->call32(tc, gem5_ops);
|
||||
return getArmSystem(tc)->semihosting->call32(tc, gem5_ops);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -314,10 +314,10 @@ class ArmSystem : public System
|
||||
static bool haveSemihosting(ThreadContext *tc);
|
||||
|
||||
/** Make a Semihosting call from aarch64 */
|
||||
static void callSemihosting64(ThreadContext *tc, bool gem5_ops=false);
|
||||
static bool callSemihosting64(ThreadContext *tc, bool gem5_ops=false);
|
||||
|
||||
/** Make a Semihosting call from aarch32 */
|
||||
static void callSemihosting32(ThreadContext *tc, bool gem5_ops=false);
|
||||
static bool callSemihosting32(ThreadContext *tc, bool gem5_ops=false);
|
||||
|
||||
/** Make a call to notify the power controller of STANDBYWFI assertion */
|
||||
static void callSetStandByWfi(ThreadContext *tc);
|
||||
|
||||
Reference in New Issue
Block a user