regs.h revision d4a5447503b7bddfb6d7667747ee1eedd20ae491
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
25enum arm_register {
26	ARM_REG_SP = 13,
27	ARM_REG_PC = 15,
28	ARM_REG_CPSR = 16,
29};
30
31/* Write value of register REG to *LP.  Return 0 on success or a
32 * negative value on failure.  */
33int arm_get_register(struct process *proc, enum arm_register reg, uint32_t *lp);
34
35/* Same as above, but if REG==ARM_REG_PC, it returns the value +8.  */
36int arm_get_register_offpc(struct process *proc, enum arm_register reg,
37			   uint32_t *lp);
38
39/* Same as arm_get_register, but shift is performed depending on
40 * instruction INST.  */
41int arm_get_shifted_register(struct process *proc, uint32_t inst, int carry,
42			     arch_addr_t pc, uint32_t *lp);
43