summaryrefslogtreecommitdiff
path: root/src/sim/syscall_emul.hh
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2019-01-09 14:50:27 +0000
committerAndreas Sandberg <andreas.sandberg@arm.com>2019-01-10 17:55:42 +0000
commit0a36956261c67d61def90e1aefeb6c46568ff167 (patch)
tree5f6d72f83185698d45e1f4b3eba1537f1c370167 /src/sim/syscall_emul.hh
parent13daa2e0620e71a1c11f94d1f8a864f73a52b94d (diff)
downloadgem5-0a36956261c67d61def90e1aefeb6c46568ff167.tar.xz
sim-se: Refactor clone to avoid most ifdefs
Some parts of clone are architecture dependent. In some cases, we are able to use architecture-specific helper functions or register aliases. However, there is still some architecture-specific that is protected by ifdefs in the common clone implementation. Move these architecture-specific bits to the architecture-specific OS class instead to avoid these ifdefs and make the code a bit more readable. Change-Id: Ia0903d738d0ba890863bddfa77e3b717db7f45de Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Cc: Giacomo Travaglini <giacomo.travaglini@arm.com> Cc: Javier Setoain <javier.setoain@arm.com> Cc: Brandon Potter <Brandon.Potter@amd.com> Reviewed-on: https://gem5-review.googlesource.com/c/15435 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Brandon Potter <Brandon.Potter@amd.com>
Diffstat (limited to 'src/sim/syscall_emul.hh')
-rw-r--r--src/sim/syscall_emul.hh32
1 files changed, 3 insertions, 29 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 8480c7e94..343fb2731 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -1279,11 +1279,11 @@ cloneFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
* The flag defines the list of clone() arguments in the following
* order: flags -> newStack -> ptidPtr -> tlsPtr -> ctidPtr
*/
- Addr tlsPtr M5_VAR_USED = p->getSyscallArg(tc, index);
+ Addr tlsPtr = p->getSyscallArg(tc, index);
Addr ctidPtr = p->getSyscallArg(tc, index);
#else
Addr ctidPtr = p->getSyscallArg(tc, index);
- Addr tlsPtr M5_VAR_USED = p->getSyscallArg(tc, index);
+ Addr tlsPtr = p->getSyscallArg(tc, index);
#endif
if (((flags & OS::TGT_CLONE_SIGHAND)&& !(flags & OS::TGT_CLONE_VM)) ||
@@ -1365,33 +1365,7 @@ cloneFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
ctc->clearArchRegs();
-#if THE_ISA == ALPHA_ISA
- TheISA::copyMiscRegs(tc, ctc);
-#elif THE_ISA == SPARC_ISA
- TheISA::copyRegs(tc, ctc);
- ctc->setIntReg(TheISA::NumIntArchRegs + 6, 0);
- ctc->setIntReg(TheISA::NumIntArchRegs + 4, 0);
- ctc->setIntReg(TheISA::NumIntArchRegs + 3, TheISA::NWindows - 2);
- ctc->setIntReg(TheISA::NumIntArchRegs + 5, TheISA::NWindows);
- ctc->setMiscReg(TheISA::MISCREG_CWP, 0);
- ctc->setIntReg(TheISA::NumIntArchRegs + 7, 0);
- ctc->setMiscRegNoEffect(TheISA::MISCREG_TL, 0);
- ctc->setMiscReg(TheISA::MISCREG_ASI, TheISA::ASI_PRIMARY);
- for (int y = 8; y < 32; y++)
- ctc->setIntReg(y, tc->readIntReg(y));
-#elif THE_ISA == ARM_ISA or THE_ISA == X86_ISA or THE_ISA == RISCV_ISA
- TheISA::copyRegs(tc, ctc);
-#endif
-
-#if THE_ISA == X86_ISA
- if (flags & OS::TGT_CLONE_SETTLS) {
- ctc->setMiscRegNoEffect(TheISA::MISCREG_FS_BASE, tlsPtr);
- ctc->setMiscRegNoEffect(TheISA::MISCREG_FS_EFF_BASE, tlsPtr);
- }
-#endif
-
- if (newStack)
- ctc->setIntReg(TheISA::StackPointerReg, newStack);
+ OS::archClone(flags, p, cp, tc, ctc, newStack, tlsPtr);
cp->setSyscallReturn(ctc, 0);