diff options
author | Ruslan Bukin <br@bsdpad.com> | 2015-04-29 22:35:23 -0500 |
---|---|---|
committer | Ruslan Bukin <br@bsdpad.com> | 2015-04-29 22:35:23 -0500 |
commit | 81f3211149c051e4f70b0b12eb3709dfc6e0395c (patch) | |
tree | 9b9d276586b948252ec6a39a2748dbca43fe92d3 /src/arch/arm/process.cc | |
parent | 52a3bc5e5c3cc694b3f8b29f38b0dd296b91350f (diff) | |
download | gem5-81f3211149c051e4f70b0b12eb3709dfc6e0395c.tar.xz |
arch, base, dev, kern, sym: FreeBSD support
This adds support for FreeBSD/aarch64 FS and SE mode (basic set of syscalls only)
Committed by: Nilay Vaish <nilay@cs.wisc.edu>
Diffstat (limited to 'src/arch/arm/process.cc')
-rw-r--r-- | src/arch/arm/process.cc | 91 |
1 files changed, 57 insertions, 34 deletions
diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc index a08e6ee45..ba56f0cdc 100644 --- a/src/arch/arm/process.cc +++ b/src/arch/arm/process.cc @@ -181,31 +181,43 @@ ArmLiveProcess::argsInit(int pageSize, IntRegIndex spIndex) //Auxilliary vectors are loaded only for elf formatted executables. ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile); if (elfObject) { - IntType features = - Arm_Swp | - Arm_Half | - Arm_Thumb | -// Arm_26Bit | - Arm_FastMult | -// Arm_Fpa | - Arm_Vfp | - Arm_Edsp | -// Arm_Java | -// Arm_Iwmmxt | -// Arm_Crunch | - Arm_ThumbEE | - Arm_Neon | - Arm_Vfpv3 | - Arm_Vfpv3d16 | - 0; - - //Bits which describe the system hardware capabilities - //XXX Figure out what these should be - auxv.push_back(auxv_t(M5_AT_HWCAP, features)); + + if (objFile->getOpSys() == ObjectFile::Linux) { + IntType features = + Arm_Swp | + Arm_Half | + Arm_Thumb | +// Arm_26Bit | + Arm_FastMult | +// Arm_Fpa | + Arm_Vfp | + Arm_Edsp | +// Arm_Java | +// Arm_Iwmmxt | +// Arm_Crunch | + Arm_ThumbEE | + Arm_Neon | + Arm_Vfpv3 | + Arm_Vfpv3d16 | + 0; + + //Bits which describe the system hardware capabilities + //XXX Figure out what these should be + auxv.push_back(auxv_t(M5_AT_HWCAP, features)); + //Frequency at which times() increments + auxv.push_back(auxv_t(M5_AT_CLKTCK, 0x64)); + //Whether to enable "secure mode" in the executable + auxv.push_back(auxv_t(M5_AT_SECURE, 0)); + // Pointer to 16 bytes of random data + auxv.push_back(auxv_t(M5_AT_RANDOM, 0)); + //The filename of the program + auxv.push_back(auxv_t(M5_AT_EXECFN, 0)); + //The string "v71" -- ARM v7 architecture + auxv.push_back(auxv_t(M5_AT_PLATFORM, 0)); + } + //The system page size auxv.push_back(auxv_t(M5_AT_PAGESZ, ArmISA::PageBytes)); - //Frequency at which times() increments - auxv.push_back(auxv_t(M5_AT_CLKTCK, 0x64)); // For statically linked executables, this is the virtual address of the // program header tables if they appear in the executable image auxv.push_back(auxv_t(M5_AT_PHDR, elfObject->programHeaderTable())); @@ -217,7 +229,6 @@ ArmLiveProcess::argsInit(int pageSize, IntRegIndex spIndex) //to 0 for regular executables. It should be something else //(not sure what) for dynamic libraries. auxv.push_back(auxv_t(M5_AT_BASE, 0)); - //XXX Figure out what this should be. auxv.push_back(auxv_t(M5_AT_FLAGS, 0)); //The entry point to the program @@ -227,16 +238,6 @@ ArmLiveProcess::argsInit(int pageSize, IntRegIndex spIndex) auxv.push_back(auxv_t(M5_AT_EUID, euid())); auxv.push_back(auxv_t(M5_AT_GID, gid())); auxv.push_back(auxv_t(M5_AT_EGID, egid())); - //Whether to enable "secure mode" in the executable - auxv.push_back(auxv_t(M5_AT_SECURE, 0)); - - // Pointer to 16 bytes of random data - auxv.push_back(auxv_t(M5_AT_RANDOM, 0)); - - //The filename of the program - auxv.push_back(auxv_t(M5_AT_EXECFN, 0)); - //The string "v71" -- ARM v7 architecture - auxv.push_back(auxv_t(M5_AT_PLATFORM, 0)); } //Figure out how big the initial stack nedes to be @@ -456,11 +457,33 @@ ArmLiveProcess64::setSyscallArg(ThreadContext *tc, void ArmLiveProcess32::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret) { + + if (objFile->getOpSys() == ObjectFile::FreeBSD) { + // Decode return value + if (sysret.encodedValue() >= 0) + // FreeBSD checks the carry bit to determine if syscall is succeeded + tc->setCCReg(CCREG_C, 0); + else { + sysret = -sysret.encodedValue(); + } + } + tc->setIntReg(ReturnValueReg, sysret.encodedValue()); } void ArmLiveProcess64::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret) { + + if (objFile->getOpSys() == ObjectFile::FreeBSD) { + // Decode return value + if (sysret.encodedValue() >= 0) + // FreeBSD checks the carry bit to determine if syscall is succeeded + tc->setCCReg(CCREG_C, 0); + else { + sysret = -sysret.encodedValue(); + } + } + tc->setIntReg(ReturnValueReg, sysret.encodedValue()); } |