Add the risu_ppc.c file. It defines several functions used by risu.
Signed-off-by: John Arbuckle <programmingk...@gmail.com> --- risu_ppc.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 risu_ppc.c diff --git a/risu_ppc.c b/risu_ppc.c new file mode 100644 index 0000000..70a1cf7 --- /dev/null +++ b/risu_ppc.c @@ -0,0 +1,41 @@ +/***************************************************************** + * File: risu_ppc.c + * Date: 3-27-2017 + * Description: Implement advance_pc(), set_ucontext_paramreg(), + * get_reginfo_paramreg(), get_risuop() + *****************************************************************/ + +#include "risu.h" + +/* Advances the program counter register to the next instruction */ +void advance_pc(void *vuc) +{ + ucontext_t *uc = (ucontext_t*)vuc; + uc->uc_mcontext->ss.srr0 += 4; +} + +/* Sets register r0 to the address of a memory block. */ +void set_ucontext_paramreg(void *vuc, uint64_t value) +{ + ucontext_t *uc = vuc; + uc->uc_mcontext->ss.r0 = value; +} + +/* + * Returns the register that keeps track of a memory block address. + * Used for the load and store to memory instructions like LFD. + * Returns general purpose register r0. + */ +uint64_t get_reginfo_paramreg(struct reginfo *ri) +{ + return ri->gpr[0]; +} + +int get_risuop(struct reginfo *ri) +{ + uint32_t insn = ri->faulting_insn; + uint32_t op = insn & 0xf; + uint32_t key = insn & ~0xf; + uint32_t risukey = 0x00005af0; + return (key != risukey) ? -1 : op; +} -- 2.10.2