TEMU  4.4
The Terma Emulator
Instrumenter.h
Go to the documentation of this file.
1 //===--------------------------------------------------------------*- C -*-===//
2 //
3 // TEMU: The Terma Emulator
4 // (c) Terma 2018, 2019
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef TEMU_INSTRUMENTER_H
10 #define TEMU_INSTRUMENTER_H
11 #include "temu-c/Support/Objsys.h"
12 #include <stdint.h>
13 
14 /*!
15  Instruction classification flags
16  */
17 typedef enum {
18  teIF_Branch = 1 << 0, //!< Instruction is a branch
19  teIF_IndirectBranch = 1 << 1, //!< Instruction is an indirect branch
20  teIF_Load = 1 << 2, //!< Instruction is a load
21  teIF_Store = 1 << 3, //!< Instruction is a store
22  teIF_Integer = 1 << 4, //!< Integer instruction
23  teIF_Float = 1 << 5, //!< Floating point instruction
24  teIF_Arithmetic = 1 << 6, //!< Arithmetic instruction
25  teIF_Annulled = 1 << 7, //!< Annulled branch
26  teIF_UnconditionalTaken = 1 << 8, //!< Unconditional taken branch
27  teIF_UnconditionalNotTaken = 1 << 9, //!< Unconditional not-taken branch
28  teIF_OnPage = 1 << 10, //!< On page branch
29  teIF_ModeSwitch = 1 << 11, //!< Privilege mode switching instruction
30  teIF_Call = 1 << 12, //!< Call instruction
31  teIF_Unimplemented = 1 << 13, //!< Permanently unimplemented
32 } temu_InstructionFlags;
33 
34 /*!
35  Binary translation instrumentation interface
36  */
37 typedef struct {
38  //! Called on start of a block
39  int (*beginBlock)(void *Obj, uint64_t VA, uint64_t PA);
40  //! Called at the end of a block
41  int (*endBlock)(void *Obj, uint64_t VA, uint64_t PA);
42  //! Called when instruction is started
43  int (*beginInstr)(void *Obj, uint64_t VA, uint64_t PA, uint32_t Instr,
44  uint32_t Flags);
45 
46  //! Called when instruction is finished.
47  //! Arm: 0 = normal / not taken branch.
48  //! 1 = taken conditional instruction.
49  int (*endInstr)(void *Obj, uint64_t VA, uint64_t PA, uint32_t Instr,
50  uint32_t Flags, int Arm);
51 } temu_InstrumenterIface;
52 
53 #define TEMU_INSTRUMENTER_IFACE_TYPE "temu::InstrumenterIface"
54 TEMU_IFACE_REFERENCE_TYPE(temu_Instrumenter);
55 
56 #endif // ! TEMU_INSTRUMENTER_H
teIF_OnPage
@ teIF_OnPage
On page branch.
Definition: Instrumenter.h:28
temu_InstrumenterIface::beginInstr
int(* beginInstr)(void *Obj, uint64_t VA, uint64_t PA, uint32_t Instr, uint32_t Flags)
Called when instruction is started.
Definition: Instrumenter.h:43
teIF_Load
@ teIF_Load
Instruction is a load.
Definition: Instrumenter.h:20
teIF_UnconditionalNotTaken
@ teIF_UnconditionalNotTaken
Unconditional not-taken branch.
Definition: Instrumenter.h:27
temu_InstrumenterIface::beginBlock
int(* beginBlock)(void *Obj, uint64_t VA, uint64_t PA)
Called on start of a block.
Definition: Instrumenter.h:39
teIF_ModeSwitch
@ teIF_ModeSwitch
Privilege mode switching instruction.
Definition: Instrumenter.h:29
teIF_Call
@ teIF_Call
Call instruction.
Definition: Instrumenter.h:30
teIF_IndirectBranch
@ teIF_IndirectBranch
Instruction is an indirect branch.
Definition: Instrumenter.h:19
teIF_UnconditionalTaken
@ teIF_UnconditionalTaken
Unconditional taken branch.
Definition: Instrumenter.h:26
teIF_Unimplemented
@ teIF_Unimplemented
Permanently unimplemented.
Definition: Instrumenter.h:31
teIF_Float
@ teIF_Float
Floating point instruction.
Definition: Instrumenter.h:23
teIF_Store
@ teIF_Store
Instruction is a store.
Definition: Instrumenter.h:21
temu_InstrumenterIface::endBlock
int(* endBlock)(void *Obj, uint64_t VA, uint64_t PA)
Called at the end of a block.
Definition: Instrumenter.h:41
teIF_Integer
@ teIF_Integer
Integer instruction.
Definition: Instrumenter.h:22
teIF_Annulled
@ teIF_Annulled
Annulled branch.
Definition: Instrumenter.h:25
teIF_Branch
@ teIF_Branch
Instruction is a branch.
Definition: Instrumenter.h:18
teIF_Arithmetic
@ teIF_Arithmetic
Arithmetic instruction.
Definition: Instrumenter.h:24
temu_InstrumenterIface::endInstr
int(* endInstr)(void *Obj, uint64_t VA, uint64_t PA, uint32_t Instr, uint32_t Flags, int Arm)
Definition: Instrumenter.h:49