Home | History | Annotate | Download | only in arm
      1 /*
      2  * This file is part of ltrace.
      3  * Copyright (C) 2013 Petr Machata, Red Hat Inc.
      4  *
      5  * This program is free software; you can redistribute it and/or
      6  * modify it under the terms of the GNU General Public License as
      7  * published by the Free Software Foundation; either version 2 of the
      8  * License, or (at your option) any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful, but
     11  * WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13  * General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License
     16  * along with this program; if not, write to the Free Software
     17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
     18  * 02110-1301 USA
     19  */
     20 
     21 #define SUBMASK(x) ((1L << ((x) + 1)) - 1)
     22 #define BIT(obj,st) (((obj) >> (st)) & 1)
     23 #define BITS(obj,st,fn) (((obj) >> (st)) & SUBMASK((fn) - (st)))
     24 #define SBITS(obj,st,fn) \
     25 	((long) (BITS(obj,st,fn) | ((long) BIT(obj,fn) * ~ SUBMASK(fn - st))))
     26 
     27 enum arm_register {
     28 	ARM_REG_R7 = 7,
     29 	ARM_REG_IP = 12,
     30 	ARM_REG_SP = 13,
     31 	ARM_REG_LR = 14,
     32 	ARM_REG_PC = 15,
     33 	ARM_REG_CPSR = 16,
     34 };
     35 
     36 /* Write value of register REG to *LP.  Return 0 on success or a
     37  * negative value on failure.  */
     38 int arm_get_register(struct process *proc, enum arm_register reg, uint32_t *lp);
     39 
     40 /* Same as above, but if REG==ARM_REG_PC, it returns the value +8.  */
     41 int arm_get_register_offpc(struct process *proc, enum arm_register reg,
     42 			   uint32_t *lp);
     43 
     44 /* Same as arm_get_register, but shift is performed depending on
     45  * instruction INST.  */
     46 int arm_get_shifted_register(struct process *proc, uint32_t inst, int carry,
     47 			     arch_addr_t pc, uint32_t *lp);
     48