xref: /qemu/bsd-user/arm/target_arch_reg.h (revision bcacf30808ee8cd5f2e1c7104bbbee9d64e7ca6c)
1*bcacf308SWarner Losh /*
2*bcacf308SWarner Losh  *  FreeBSD arm register structures
3*bcacf308SWarner Losh  *
4*bcacf308SWarner Losh  *  Copyright (c) 2015 Stacey Son
5*bcacf308SWarner Losh  *
6*bcacf308SWarner Losh  *  This program is free software; you can redistribute it and/or modify
7*bcacf308SWarner Losh  *  it under the terms of the GNU General Public License as published by
8*bcacf308SWarner Losh  *  the Free Software Foundation; either version 2 of the License, or
9*bcacf308SWarner Losh  *  (at your option) any later version.
10*bcacf308SWarner Losh  *
11*bcacf308SWarner Losh  *  This program is distributed in the hope that it will be useful,
12*bcacf308SWarner Losh  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13*bcacf308SWarner Losh  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*bcacf308SWarner Losh  *  GNU General Public License for more details.
15*bcacf308SWarner Losh  *
16*bcacf308SWarner Losh  *  You should have received a copy of the GNU General Public License
17*bcacf308SWarner Losh  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18*bcacf308SWarner Losh  */
19*bcacf308SWarner Losh 
20*bcacf308SWarner Losh #ifndef _TARGET_ARCH_REG_H_
21*bcacf308SWarner Losh #define _TARGET_ARCH_REG_H_
22*bcacf308SWarner Losh 
23*bcacf308SWarner Losh /* See sys/arm/include/reg.h */
24*bcacf308SWarner Losh typedef struct target_reg {
25*bcacf308SWarner Losh     uint32_t        r[13];
26*bcacf308SWarner Losh     uint32_t        r_sp;
27*bcacf308SWarner Losh     uint32_t        r_lr;
28*bcacf308SWarner Losh     uint32_t        r_pc;
29*bcacf308SWarner Losh     uint32_t        r_cpsr;
30*bcacf308SWarner Losh } target_reg_t;
31*bcacf308SWarner Losh 
32*bcacf308SWarner Losh typedef struct target_fp_reg {
33*bcacf308SWarner Losh     uint32_t        fp_exponent;
34*bcacf308SWarner Losh     uint32_t        fp_mantissa_hi;
35*bcacf308SWarner Losh     u_int32_t       fp_mantissa_lo;
36*bcacf308SWarner Losh } target_fp_reg_t;
37*bcacf308SWarner Losh 
38*bcacf308SWarner Losh typedef struct target_fpreg {
39*bcacf308SWarner Losh     uint32_t        fpr_fpsr;
40*bcacf308SWarner Losh     target_fp_reg_t fpr[8];
41*bcacf308SWarner Losh } target_fpreg_t;
42*bcacf308SWarner Losh 
43*bcacf308SWarner Losh #define tswapreg(ptr)   tswapal(ptr)
44*bcacf308SWarner Losh 
45*bcacf308SWarner Losh static inline void target_copy_regs(target_reg_t *regs, const CPUARMState *env)
46*bcacf308SWarner Losh {
47*bcacf308SWarner Losh     int i;
48*bcacf308SWarner Losh 
49*bcacf308SWarner Losh     for (i = 0; i < 13; i++) {
50*bcacf308SWarner Losh         regs->r[i] = tswapreg(env->regs[i + 1]);
51*bcacf308SWarner Losh     }
52*bcacf308SWarner Losh     regs->r_sp = tswapreg(env->regs[13]);
53*bcacf308SWarner Losh     regs->r_lr = tswapreg(env->regs[14]);
54*bcacf308SWarner Losh     regs->r_pc = tswapreg(env->regs[15]);
55*bcacf308SWarner Losh     regs->r_cpsr = tswapreg(cpsr_read((CPUARMState *)env));
56*bcacf308SWarner Losh }
57*bcacf308SWarner Losh 
58*bcacf308SWarner Losh #undef tswapreg
59*bcacf308SWarner Losh 
60*bcacf308SWarner Losh #endif /* !_TARGET_ARCH_REG_H_ */
61