Re: [PATCH 10/24] bsd-user/arm/target_arch_reg.h: Implement core dump register copying

2021-10-28 Thread Richard Henderson

On 10/19/21 9:44 AM, Warner Losh wrote:

Implement the register copying routines to extract registers from the
cpu for core dump generation.

Signed-off-by: Stacey Son 
Signed-off-by: Warner Losh 


Reviewed-by: Richard Henderson 


+static inline void target_copy_regs(target_reg_t *regs, const CPUARMState *env)
+{
+int i;
+
+for (i = 0; i < 13; i++) {
+regs->r[i] = tswapreg(env->regs[i + 1]);
+}
+regs->r_sp = tswapreg(env->regs[13]);
+regs->r_lr = tswapreg(env->regs[14]);
+regs->r_pc = tswapreg(env->regs[15]);
+regs->r_cpsr = tswapreg(cpsr_read((CPUARMState *)env));


I guess we could do with a bit of const-ification in target/arm/...


r~



Re: [PATCH 10/24] bsd-user/arm/target_arch_reg.h: Implement core dump register copying

2021-10-25 Thread Kyle Evans
On Tue, Oct 19, 2021 at 11:45 AM Warner Losh  wrote:
>
> Implement the register copying routines to extract registers from the
> cpu for core dump generation.
>
> Signed-off-by: Stacey Son 
> Signed-off-by: Warner Losh 
> ---
>  bsd-user/arm/target_arch_reg.h | 60 ++
>  1 file changed, 60 insertions(+)
>  create mode 100644 bsd-user/arm/target_arch_reg.h
>
> diff --git a/bsd-user/arm/target_arch_reg.h b/bsd-user/arm/target_arch_reg.h
> new file mode 100644
> index 00..ef5ed5154f
> --- /dev/null
> +++ b/bsd-user/arm/target_arch_reg.h
> @@ -0,0 +1,60 @@
> +/*
> + *  FreeBSD arm register structures
> + *
> + *  Copyright (c) 2015 Stacey Son
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, see .
> + */
> +
> +#ifndef _TARGET_ARCH_REG_H_
> +#define _TARGET_ARCH_REG_H_
> +
> +/* See sys/arm/include/reg.h */
> +typedef struct target_reg {
> +uint32_tr[13];
> +uint32_tr_sp;
> +uint32_tr_lr;
> +uint32_tr_pc;
> +uint32_tr_cpsr;
> +} target_reg_t;
> +
> +typedef struct target_fp_reg {
> +uint32_tfp_exponent;
> +uint32_tfp_mantissa_hi;
> +u_int32_t   fp_mantissa_lo;
> +} target_fp_reg_t;
> +
> +typedef struct target_fpreg {
> +uint32_tfpr_fpsr;
> +target_fp_reg_t fpr[8];
> +} target_fpreg_t;
> +
> +#define tswapreg(ptr)   tswapal(ptr)
> +
> +static inline void target_copy_regs(target_reg_t *regs, const CPUARMState 
> *env)
> +{
> +int i;
> +
> +for (i = 0; i < 13; i++) {
> +regs->r[i] = tswapreg(env->regs[i + 1]);
> +}
> +regs->r_sp = tswapreg(env->regs[13]);
> +regs->r_lr = tswapreg(env->regs[14]);
> +regs->r_pc = tswapreg(env->regs[15]);
> +regs->r_cpsr = tswapreg(cpsr_read((CPUARMState *)env));
> +}
> +
> +#undef tswapreg
> +
> +#endif /* !_TARGET_ARCH_REG_H_ */
> --
> 2.32.0
>

Reviewed-by: Kyle Evans 



[PATCH 10/24] bsd-user/arm/target_arch_reg.h: Implement core dump register copying

2021-10-19 Thread Warner Losh
Implement the register copying routines to extract registers from the
cpu for core dump generation.

Signed-off-by: Stacey Son 
Signed-off-by: Warner Losh 
---
 bsd-user/arm/target_arch_reg.h | 60 ++
 1 file changed, 60 insertions(+)
 create mode 100644 bsd-user/arm/target_arch_reg.h

diff --git a/bsd-user/arm/target_arch_reg.h b/bsd-user/arm/target_arch_reg.h
new file mode 100644
index 00..ef5ed5154f
--- /dev/null
+++ b/bsd-user/arm/target_arch_reg.h
@@ -0,0 +1,60 @@
+/*
+ *  FreeBSD arm register structures
+ *
+ *  Copyright (c) 2015 Stacey Son
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see .
+ */
+
+#ifndef _TARGET_ARCH_REG_H_
+#define _TARGET_ARCH_REG_H_
+
+/* See sys/arm/include/reg.h */
+typedef struct target_reg {
+uint32_tr[13];
+uint32_tr_sp;
+uint32_tr_lr;
+uint32_tr_pc;
+uint32_tr_cpsr;
+} target_reg_t;
+
+typedef struct target_fp_reg {
+uint32_tfp_exponent;
+uint32_tfp_mantissa_hi;
+u_int32_t   fp_mantissa_lo;
+} target_fp_reg_t;
+
+typedef struct target_fpreg {
+uint32_tfpr_fpsr;
+target_fp_reg_t fpr[8];
+} target_fpreg_t;
+
+#define tswapreg(ptr)   tswapal(ptr)
+
+static inline void target_copy_regs(target_reg_t *regs, const CPUARMState *env)
+{
+int i;
+
+for (i = 0; i < 13; i++) {
+regs->r[i] = tswapreg(env->regs[i + 1]);
+}
+regs->r_sp = tswapreg(env->regs[13]);
+regs->r_lr = tswapreg(env->regs[14]);
+regs->r_pc = tswapreg(env->regs[15]);
+regs->r_cpsr = tswapreg(cpsr_read((CPUARMState *)env));
+}
+
+#undef tswapreg
+
+#endif /* !_TARGET_ARCH_REG_H_ */
-- 
2.32.0