#include "arch/arm/isa.hh"
#include "arch/arm/isa_traits.hh"
#include "arch/arm/pauth_helpers.hh"
+#include "arch/arm/semihosting.hh"
#include "arch/arm/utility.hh"
#include "arch/generic/memhelpers.hh"
#include "base/condcodes.hh"
svcCode = '''
ThreadContext *tc = xc->tcBase();
- const auto semihost_imm = Thumb? 0xAB : 0x123456;
-
- if (ArmSystem::haveSemihosting(tc) && imm == semihost_imm) {
+ bool have_semi = ArmSystem::haveSemihosting(tc);
+ if (have_semi && Thumb && imm == ArmSemihosting::T32Imm) {
+ // Enable gem5 extensions since we can't distinguish in thumb.
+ ArmSystem::callSemihosting32(tc, true);
+ } else if (have_semi && imm == ArmSemihosting::A32Imm) {
ArmSystem::callSemihosting32(tc);
+ } else if (have_semi && imm == ArmSemihosting::Gem5Imm) {
+ ArmSystem::callSemihosting32(tc, true);
} else {
fault = std::make_shared<SupervisorCall>(machInst, imm);
}
hltCode = '''
ThreadContext *tc = xc->tcBase();
- if (ArmSystem::haveSemihosting(tc) && imm == 0xF000) {
+ bool have_semi = ArmSystem::haveSemihosting(tc);
+ if (imm == ArmSemihosting::A64Imm && have_semi) {
ArmSystem::callSemihosting64(tc);
+ } else if (imm == ArmSemihosting::Gem5Imm && have_semi) {
+ ArmSystem::callSemihosting64(tc, true);
} else {
// HLT instructions aren't implemented, so treat them as undefined
// instructions.
{
public:
+ enum {
+ // Standard ARM immediate values which trigger semihosting.
+ T32Imm = 0xAB,
+ A32Imm = 0x123456,
+ A64Imm = 0xF000,
+
+ // The immediate value which enables gem5 semihosting calls. Use the
+ // standard value for thumb.
+ Gem5Imm = 0x5D57
+ };
+
static PortProxy &portProxy(ThreadContext *tc);
struct AbiBase