From 4ddeceba96c5e066d79138709091a6dffec17372 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 2 Jun 2010 12:58:00 -0500 Subject: [PATCH] ARM: Allow ARM processes to start in Thumb mode. --- src/arch/arm/linux/process.cc | 4 ++-- src/arch/arm/linux/process.hh | 3 ++- src/arch/arm/process.cc | 7 +++++-- src/arch/arm/process.hh | 5 ++++- src/sim/process.cc | 5 +---- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/arch/arm/linux/process.cc b/src/arch/arm/linux/process.cc index f909d871a..7a5e9da56 100644 --- a/src/arch/arm/linux/process.cc +++ b/src/arch/arm/linux/process.cc @@ -435,8 +435,8 @@ SyscallDesc ArmLinuxProcess::privSyscallDescs[] = { }; ArmLinuxProcess::ArmLinuxProcess(LiveProcessParams * params, - ObjectFile *objFile) - : ArmLiveProcess(params, objFile), + ObjectFile *objFile, ObjectFile::Arch _arch) + : ArmLiveProcess(params, objFile, _arch), Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc)), Num_Priv_Syscall_Descs(sizeof(privSyscallDescs) / sizeof(SyscallDesc)) { } diff --git a/src/arch/arm/linux/process.hh b/src/arch/arm/linux/process.hh index ab836fab2..7b9e5789e 100644 --- a/src/arch/arm/linux/process.hh +++ b/src/arch/arm/linux/process.hh @@ -38,7 +38,8 @@ class ArmLinuxProcess : public ArmLiveProcess { public: - ArmLinuxProcess(LiveProcessParams * params, ObjectFile *objFile); + ArmLinuxProcess(LiveProcessParams * params, ObjectFile *objFile, + ObjectFile::Arch _arch); virtual SyscallDesc* getDesc(int callnum); diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc index 702922a43..3c51c80a7 100644 --- a/src/arch/arm/process.cc +++ b/src/arch/arm/process.cc @@ -43,8 +43,9 @@ using namespace std; using namespace ArmISA; -ArmLiveProcess::ArmLiveProcess(LiveProcessParams *params, ObjectFile *objFile) - : LiveProcess(params, objFile) +ArmLiveProcess::ArmLiveProcess(LiveProcessParams *params, ObjectFile *objFile, + ObjectFile::Arch _arch) + : LiveProcess(params, objFile), arch(_arch) { stack_base = 0xbf000000L; @@ -316,6 +317,8 @@ ArmLiveProcess::argsInit(int intSize, int pageSize) } Addr prog_entry = objFile->entryPoint(); + if (arch == ObjectFile::Thumb) + prog_entry = (prog_entry & ~mask(1)) | (ULL(1) << PcTBitShift); tc->setPC(prog_entry); tc->setNextPC(prog_entry + sizeof(MachInst)); diff --git a/src/arch/arm/process.hh b/src/arch/arm/process.hh index f793892d0..a4dd5e842 100644 --- a/src/arch/arm/process.hh +++ b/src/arch/arm/process.hh @@ -33,6 +33,7 @@ #include #include +#include "base/loader/object_file.hh" #include "sim/process.hh" class LiveProcess; @@ -42,7 +43,9 @@ class System; class ArmLiveProcess : public LiveProcess { protected: - ArmLiveProcess(LiveProcessParams * params, ObjectFile *objFile); + ObjectFile::Arch arch; + ArmLiveProcess(LiveProcessParams * params, ObjectFile *objFile, + ObjectFile::Arch _arch); void startup(); diff --git a/src/sim/process.cc b/src/sim/process.cc index 18f33abdc..ba4a3905b 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -763,10 +763,7 @@ LiveProcess::create(LiveProcessParams * params) warn("Unknown operating system; assuming Linux."); // fall through case ObjectFile::Linux: - if (objFile->getArch() == ObjectFile::Thumb) - panic("Thumb processes not yet supported.\n"); - else - process = new ArmLinuxProcess(params, objFile); + process = new ArmLinuxProcess(params, objFile, objFile->getArch()); break; case ObjectFile::LinuxArmOABI: fatal("M5 does not support ARM OABI binaries. Please recompile with an" -- 2.30.2