From: imp@bsdimp.com
To: qemu-devel@nongnu.org
Cc: kevans@freebsd.org,
Richard Henderson <richard.henderson@linaro.org>,
Warner Losh <imp@FreeBSD.org>, Warner Losh <imp@bsdimp.com>,
Stacey Son <sson@FreeBSD.org>
Subject: [PATCH v3 35/43] bsd-user: Add target_arch_reg to describe a target's register set
Date: Thu, 2 Sep 2021 17:47:21 -0600 [thread overview]
Message-ID: <20210902234729.76141-36-imp@bsdimp.com> (raw)
In-Reply-To: <20210902234729.76141-1-imp@bsdimp.com>
From: Warner Losh <imp@FreeBSD.org>
target_reg_t is the normal register. target_fpreg_t is the floating
point registers. target_copy_regs copies the registers out of CPU
context for things like core dumps.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/i386/target_arch_reg.h | 82 +++++++++++++++++++++++++++
bsd-user/x86_64/target_arch_reg.h | 92 +++++++++++++++++++++++++++++++
2 files changed, 174 insertions(+)
create mode 100644 bsd-user/i386/target_arch_reg.h
create mode 100644 bsd-user/x86_64/target_arch_reg.h
diff --git a/bsd-user/i386/target_arch_reg.h b/bsd-user/i386/target_arch_reg.h
new file mode 100644
index 0000000000..1fce1daf01
--- /dev/null
+++ b/bsd-user/i386/target_arch_reg.h
@@ -0,0 +1,82 @@
+/*
+ * FreeBSD i386 register structures
+ *
+ * Copyright (c) 2015 Stacey Son
+ * All rights reserved.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _TARGET_ARCH_REG_H_
+#define _TARGET_ARCH_REG_H_
+
+/* See sys/i386/include/reg.h */
+typedef struct target_reg {
+ uint32_t r_fs;
+ uint32_t r_es;
+ uint32_t r_ds;
+ uint32_t r_edi;
+ uint32_t r_esi;
+ uint32_t r_ebp;
+ uint32_t r_isp;
+ uint32_t r_ebx;
+ uint32_t r_edx;
+ uint32_t r_ecx;
+ uint32_t r_eax;
+ uint32_t r_trapno;
+ uint32_t r_err;
+ uint32_t r_eip;
+ uint32_t r_cs;
+ uint32_t r_eflags;
+ uint32_t r_esp;
+ uint32_t r_ss;
+ uint32_t r_gs;
+} target_reg_t;
+
+typedef struct target_fpreg {
+ uint32_t fpr_env[7];
+ uint8_t fpr_acc[8][10];
+ uint32_t fpr_ex_sw;
+ uint8_t fpr_pad[64];
+} target_fpreg_t;
+
+static inline void target_copy_regs(target_reg_t *regs, const CPUX86State *env)
+{
+
+ regs->r_fs = env->segs[R_FS].selector & 0xffff;
+ regs->r_es = env->segs[R_ES].selector & 0xffff;
+ regs->r_ds = env->segs[R_DS].selector & 0xffff;
+
+ regs->r_edi = env->regs[R_EDI];
+ regs->r_esi = env->regs[R_ESI];
+ regs->r_ebp = env->regs[R_EBP];
+ /* regs->r_isp = env->regs[R_ISP]; XXX */
+ regs->r_ebx = env->regs[R_EBX];
+ regs->r_edx = env->regs[R_EDX];
+ regs->r_ecx = env->regs[R_ECX];
+ regs->r_eax = env->regs[R_EAX];
+ /* regs->r_trapno = env->regs[R_TRAPNO]; XXX */
+ regs->r_err = env->error_code; /* XXX ? */
+ regs->r_eip = env->eip;
+
+ regs->r_cs = env->segs[R_CS].selector & 0xffff;
+
+ regs->r_eflags = env->eflags;
+ regs->r_esp = env->regs[R_ESP];
+
+ regs->r_ss = env->segs[R_SS].selector & 0xffff;
+ regs->r_gs = env->segs[R_GS].selector & 0xffff;
+}
+
+#endif /* !_TARGET_ARCH_REG_H_ */
diff --git a/bsd-user/x86_64/target_arch_reg.h b/bsd-user/x86_64/target_arch_reg.h
new file mode 100644
index 0000000000..00e9624517
--- /dev/null
+++ b/bsd-user/x86_64/target_arch_reg.h
@@ -0,0 +1,92 @@
+/*
+ * FreeBSD amd64 register structures
+ *
+ * Copyright (c) 2015 Stacey Son
+ * All rights reserved.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _TARGET_ARCH_REG_H_
+#define _TARGET_ARCH_REG_H_
+
+/* See sys/amd64/include/reg.h */
+typedef struct target_reg {
+ uint64_t r_r15;
+ uint64_t r_r14;
+ uint64_t r_r13;
+ uint64_t r_r12;
+ uint64_t r_r11;
+ uint64_t r_r10;
+ uint64_t r_r9;
+ uint64_t r_r8;
+ uint64_t r_rdi;
+ uint64_t r_rsi;
+ uint64_t r_rbp;
+ uint64_t r_rbx;
+ uint64_t r_rdx;
+ uint64_t r_rcx;
+ uint64_t r_rax;
+ uint32_t r_trapno;
+ uint16_t r_fs;
+ uint16_t r_gs;
+ uint32_t r_err;
+ uint16_t r_es;
+ uint16_t r_ds;
+ uint64_t r_rip;
+ uint64_t r_cs;
+ uint64_t r_rflags;
+ uint64_t r_rsp;
+ uint64_t r_ss;
+} target_reg_t;
+
+typedef struct target_fpreg {
+ uint64_t fpr_env[4];
+ uint8_t fpr_acc[8][16];
+ uint8_t fpr_xacc[16][16];
+ uint64_t fpr_spare[12];
+} target_fpreg_t;
+
+static inline void target_copy_regs(target_reg_t *regs, const CPUX86State *env)
+{
+
+ regs->r_r15 = env->regs[15];
+ regs->r_r14 = env->regs[14];
+ regs->r_r13 = env->regs[13];
+ regs->r_r12 = env->regs[12];
+ regs->r_r11 = env->regs[11];
+ regs->r_r10 = env->regs[10];
+ regs->r_r9 = env->regs[9];
+ regs->r_r8 = env->regs[8];
+ regs->r_rdi = env->regs[R_EDI];
+ regs->r_rsi = env->regs[R_ESI];
+ regs->r_rbp = env->regs[R_EBP];
+ regs->r_rbx = env->regs[R_EBX];
+ regs->r_rdx = env->regs[R_EDX];
+ regs->r_rcx = env->regs[R_ECX];
+ regs->r_rax = env->regs[R_EAX];
+ /* regs->r_trapno = env->regs[R_TRAPNO]; XXX */
+ regs->r_fs = env->segs[R_FS].selector & 0xffff;
+ regs->r_gs = env->segs[R_GS].selector & 0xffff;
+ regs->r_err = env->error_code; /* XXX ? */
+ regs->r_es = env->segs[R_ES].selector & 0xffff;
+ regs->r_ds = env->segs[R_DS].selector & 0xffff;
+ regs->r_rip = env->eip;
+ regs->r_cs = env->segs[R_CS].selector & 0xffff;
+ regs->r_rflags = env->eflags;
+ regs->r_rsp = env->regs[R_ESP];
+ regs->r_ss = env->segs[R_SS].selector & 0xffff;
+}
+
+#endif /* !_TARGET_ARCH_REG_H_ */
--
2.32.0
next prev parent reply other threads:[~2021-09-03 0:27 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-02 23:46 [PATCH v3 00/43] bsd-user updates to run hello world imp
2021-09-02 23:46 ` [PATCH v3 01/43] bsd-user: remove sparc and sparc64 imp
2021-09-02 23:46 ` [PATCH v3 02/43] bsd-user: add copyright header to elfload.c imp
2021-09-02 23:46 ` [PATCH v3 03/43] bsd-user: Add Stacey's copyright to main.c imp
2021-09-02 23:46 ` [PATCH v3 04/43] bsd-user: add license to bsdload.c imp
2021-09-02 23:46 ` [PATCH v3 05/43] bsd-user: style nits: bsdload.c whitespace to qemu standard imp
2021-09-02 23:46 ` [PATCH v3 06/43] bsd-user: Remove all non-x86 code from elfload.c imp
2021-09-02 23:46 ` [PATCH v3 07/43] bsd-user: move arch specific defines out of elfload.c imp
2021-09-02 23:46 ` [PATCH v3 08/43] bsd-user: pass the bsd_param into loader_exec imp
2021-09-02 23:46 ` [PATCH v3 09/43] bsd-user: Fix calculation of size to allocate imp
2021-09-02 23:46 ` [PATCH v3 10/43] bsd-user: implement path searching imp
2021-09-05 10:11 ` Richard Henderson
2021-09-02 23:46 ` [PATCH v3 11/43] bsd-user: Eliminate elf personality imp
2021-09-02 23:46 ` [PATCH v3 12/43] bsd-user: remove a.out support imp
2021-09-02 23:46 ` [PATCH v3 13/43] bsd-user: TARGET_NGROUPS unused in this file, remove imp
2021-09-02 23:47 ` [PATCH v3 14/43] bsd-user: elfload: simplify bswap a bit imp
2021-09-02 23:47 ` [PATCH v3 15/43] bsd-user: assume pthreads and support of __thread imp
2021-09-02 23:47 ` [PATCH v3 16/43] bsd-user: add host-os.h imp
2021-09-02 23:47 ` [PATCH v3 17/43] bsd-user: Include host-os.h from main imp
2021-09-02 23:47 ` [PATCH v3 18/43] bsd-user: save the path to the qemu emulator imp
2021-09-05 19:04 ` Kyle Evans
2021-09-02 23:47 ` [PATCH v3 19/43] bsd-user: start to move target CPU functions to target_arch* imp
2021-09-02 23:47 ` [PATCH v3 20/43] bsd-user: Move per-cpu code into target_arch_cpu.h imp
2021-09-05 10:13 ` Richard Henderson
2021-09-02 23:47 ` [PATCH v3 21/43] bsd-user: pull in target_arch_thread.h update target_arch_elf.h imp
2021-09-05 19:03 ` Kyle Evans
2021-09-02 23:47 ` [PATCH v3 22/43] bsd-user: Include more things in qemu.h imp
2021-09-05 10:14 ` Richard Henderson
2021-09-02 23:47 ` [PATCH v3 23/43] bsd-user: define max args in terms of pages imp
2021-09-02 23:47 ` [PATCH v3 24/43] bsd-user: Create target specific vmparam.h imp
2021-09-02 23:47 ` [PATCH v3 25/43] bsd-user: Add system independent stack, data and text limiting imp
2021-09-02 23:47 ` [PATCH v3 26/43] bsd-user: *BSD specific siginfo defintions imp
2021-09-05 19:01 ` Kyle Evans
2021-09-02 23:47 ` [PATCH v3 27/43] bsd-user: Implement --seed and initialize random state imp
2021-09-05 10:32 ` Richard Henderson
2021-09-05 14:34 ` Warner Losh
2021-09-02 23:47 ` [PATCH v3 28/43] bsd-user: Move stack initializtion into a per-os file imp
2021-09-02 23:47 ` [PATCH v3 29/43] bsd-user: Add architecture specific signal tramp code imp
2021-09-02 23:47 ` [PATCH v3 30/43] bsd-user: elf cleanup imp
2021-09-05 19:00 ` Kyle Evans
2021-09-02 23:47 ` [PATCH v3 31/43] bsd-user: Remove dead #ifdefs from elfload.c imp
2021-09-02 23:47 ` [PATCH v3 32/43] bsd-user: Rewrite target system call definintion glue imp
2021-09-05 10:33 ` Richard Henderson
2021-09-05 14:38 ` Warner Losh
2021-09-05 18:58 ` Kyle Evans
2021-09-02 23:47 ` [PATCH v3 33/43] bsd-user: Make cpu_model and cpu_type visible to all of main.c imp
2021-09-05 18:57 ` Kyle Evans
2021-09-05 22:44 ` Warner Losh
2021-09-02 23:47 ` [PATCH v3 34/43] bsd-user: update debugging in mmap.c imp
2021-09-05 18:53 ` Kyle Evans
2021-09-02 23:47 ` imp [this message]
2021-09-02 23:47 ` [PATCH v3 36/43] bsd-user: Add target_os_user.h to capture the user/kernel structures imp
2021-09-05 18:52 ` Kyle Evans
2021-09-02 23:47 ` [PATCH v3 37/43] bsd-user: add stubbed out core dump support imp
2021-09-05 10:34 ` Richard Henderson
2021-09-02 23:47 ` [PATCH v3 38/43] bsd-user: elfload.c style catch up patch imp
2021-09-02 23:47 ` [PATCH v3 39/43] bsd-user: Refactor load_elf_sections and is_target_elf_binary imp
2021-09-05 18:50 ` Kyle Evans
2021-09-02 23:47 ` [PATCH v3 40/43] bsd-user: move qemu_log to later in the file imp
2021-09-05 18:42 ` Kyle Evans
2021-09-02 23:47 ` [PATCH v3 41/43] bsd-user: Implement interlock for atomic operations imp
2021-09-02 23:47 ` [PATCH v3 42/43] bsd-user: Add '-0 argv0' option to bsd-user/main.c imp
2021-09-02 23:47 ` [PATCH v3 43/43] bsd-user: Update mapping to handle reserved and starting conditions imp
2021-09-05 18:39 ` Kyle Evans
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210902234729.76141-36-imp@bsdimp.com \
--to=imp@bsdimp.com \
--cc=imp@FreeBSD.org \
--cc=kevans@freebsd.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sson@FreeBSD.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).