From c45ce87c6c343884c5cc7d2527f2ec06f750954d Mon Sep 17 00:00:00 2001 From: Jason Hiser <jdhiser@gmail.com> Date: Wed, 19 Dec 2018 12:42:40 -0500 Subject: [PATCH] refactoring for separate arm/x86 pinners --- include/arch/archARM64.hpp | 6 ++++++ include/arch/archX86.hpp | 4 ++++ include/arch/archbase.hpp | 1 + include/pinner/pinnerARM64.hpp | 11 +++++++++++ include/pinner/pinnerX86.hpp | 12 ++++++++++++ include/pinner/pinner_base.hpp | 12 ++++++++++++ include/zipr_all.h | 1 + 7 files changed, 47 insertions(+) create mode 100644 include/pinner/pinnerARM64.hpp create mode 100644 include/pinner/pinnerX86.hpp create mode 100644 include/pinner/pinner_base.hpp diff --git a/include/arch/archARM64.hpp b/include/arch/archARM64.hpp index 33d9139..52ae2b5 100644 --- a/include/arch/archARM64.hpp +++ b/include/arch/archARM64.hpp @@ -11,5 +11,11 @@ class ZiprArchitectureHelperARM64_t : public ZiprArchitectureHelperBase_t // it includes a 26-bit immediate, which is +/- 128MB, which should be a good enough "jump anywhere" // for now. } + virtual libIRDB::Instruction_t* createNewHaltInstruction(libIRDB::FileIR_t *p_firp, libIRDB::Instruction_t* p_existing) override + { + return IRDBUtility::addNewDatabits(p_firp, p_existing, "\xd4\x40\x00\x00"); + // A halt unconditional, in binary is: + // 1101 0100 0100 0000 0000 0000 0000 0000 + } }; #endif diff --git a/include/arch/archX86.hpp b/include/arch/archX86.hpp index 63385e0..0ebfb00 100644 --- a/include/arch/archX86.hpp +++ b/include/arch/archX86.hpp @@ -9,5 +9,9 @@ class ZiprArchitectureHelperX86_t : public ZiprArchitectureHelperBase_t { return IRDBUtility::addNewAssembly(p_firp, p_existing, "jmp 0"); } + virtual libIRDB::Instruction_t* createNewHaltInstruction(libIRDB::FileIR_t *p_firp, libIRDB::Instruction_t* p_existing) override + { + return IRDBUtility::addNewAssembly(p_firp, p_existing, "hlt"); + } }; #endif diff --git a/include/arch/archbase.hpp b/include/arch/archbase.hpp index 53a4fb7..703ada9 100644 --- a/include/arch/archbase.hpp +++ b/include/arch/archbase.hpp @@ -6,6 +6,7 @@ class ZiprArchitectureHelperBase_t { public: virtual libIRDB::Instruction_t* createNewJumpInstruction(libIRDB::FileIR_t *p_firp, libIRDB::Instruction_t* p_existing)=0; + virtual libIRDB::Instruction_t* createNewHaltInstruction(libIRDB::FileIR_t *p_firp, libIRDB::Instruction_t* p_existing)=0; static std::unique_ptr<ZiprArchitectureHelperBase_t> factory(libIRDB::FileIR_t* p_firp); }; diff --git a/include/pinner/pinnerARM64.hpp b/include/pinner/pinnerARM64.hpp new file mode 100644 index 0000000..4082beb --- /dev/null +++ b/include/pinner/pinnerARM64.hpp @@ -0,0 +1,11 @@ +#ifndef ZIPR_PINNER +#define ZIPR_PINNER + +class ZiprPinner_t +{ + public: + virtual void doPinning(); +}; + + +#endif diff --git a/include/pinner/pinnerX86.hpp b/include/pinner/pinnerX86.hpp new file mode 100644 index 0000000..bcefa97 --- /dev/null +++ b/include/pinner/pinnerX86.hpp @@ -0,0 +1,12 @@ +#ifndef ZIPR_PINNER +#define ZIPR_PINNER + +class ZiprPinner_t +{ + public: + virtual void doPinning()=0; + static unique_ptr<ZiprPinner_t> factory(Zipr_SDK::Zipr_t* parent); +}; + + +#endif diff --git a/include/pinner/pinner_base.hpp b/include/pinner/pinner_base.hpp new file mode 100644 index 0000000..bcefa97 --- /dev/null +++ b/include/pinner/pinner_base.hpp @@ -0,0 +1,12 @@ +#ifndef ZIPR_PINNER +#define ZIPR_PINNER + +class ZiprPinner_t +{ + public: + virtual void doPinning()=0; + static unique_ptr<ZiprPinner_t> factory(Zipr_SDK::Zipr_t* parent); +}; + + +#endif diff --git a/include/zipr_all.h b/include/zipr_all.h index c4c1b41..d6e169f 100644 --- a/include/zipr_all.h +++ b/include/zipr_all.h @@ -59,6 +59,7 @@ using namespace Zipr_SDK; #include <zipr_dollop_man.h> #include <zipr_utils.h> #include <arch/archbase.hpp> +#include <pinner/pinner_base.h> #include <zipr_impl.h> #include <zipr_optimizations.h> #include <zipr_stats.h> -- GitLab