From 0a36956261c67d61def90e1aefeb6c46568ff167 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Wed, 9 Jan 2019 14:50:27 +0000 Subject: 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 Cc: Giacomo Travaglini Cc: Javier Setoain Cc: Brandon Potter Reviewed-on: https://gem5-review.googlesource.com/c/15435 Reviewed-by: Jason Lowe-Power Maintainer: Brandon Potter --- src/arch/sparc/linux/linux.hh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/arch/sparc') diff --git a/src/arch/sparc/linux/linux.hh b/src/arch/sparc/linux/linux.hh index 69d373b67..1de949d10 100644 --- a/src/arch/sparc/linux/linux.hh +++ b/src/arch/sparc/linux/linux.hh @@ -31,6 +31,7 @@ #ifndef __ARCH_SPARC_LINUX_LINUX_HH__ #define __ARCH_SPARC_LINUX_LINUX_HH__ +#include "arch/sparc/utility.hh" #include "kern/linux/linux.hh" class SparcLinux : public Linux @@ -182,6 +183,28 @@ class SparcLinux : public Linux return false; } } + + static void + archClone(uint64_t flags, + Process *pp, Process *cp, + ThreadContext *ptc, ThreadContext *ctc, + uint64_t stack, uint64_t tls) + { + SparcISA::copyRegs(ptc, ctc); + ctc->setIntReg(SparcISA::NumIntArchRegs + 6, 0); + ctc->setIntReg(SparcISA::NumIntArchRegs + 4, 0); + ctc->setIntReg(SparcISA::NumIntArchRegs + 3, SparcISA::NWindows - 2); + ctc->setIntReg(SparcISA::NumIntArchRegs + 5, SparcISA::NWindows); + ctc->setMiscReg(SparcISA::MISCREG_CWP, 0); + ctc->setIntReg(SparcISA::NumIntArchRegs + 7, 0); + ctc->setMiscRegNoEffect(SparcISA::MISCREG_TL, 0); + ctc->setMiscReg(SparcISA::MISCREG_ASI, SparcISA::ASI_PRIMARY); + for (int y = 8; y < 32; y++) + ctc->setIntReg(y, ptc->readIntReg(y)); + + if (stack) + ctc->setIntReg(SparcISA::StackPointerReg, stack); + } }; class Sparc32Linux : public SparcLinux -- cgit v1.2.3