[PATCH 17/22] bsd-user: introduce target.h

Warner Losh posted 22 patches 4 years ago
Maintainers: Kyle Evans <kevans@freebsd.org>, Warner Losh <imp@bsdimp.com>, Brad Smith <brad@comstyle.com>
There is a newer version of this series
[PATCH 17/22] bsd-user: introduce target.h
Posted by Warner Losh 4 years ago
Create target.h. This file is intended to be simple and describe basic
things about the architecture. If something is a basic feature of the
architecture, it belongs here. Should we need something that's per-BSD
there will be a target-os.h that will live in the per-bsd directories.

Define regpairs_aligned to reflect whether or not registers are 'paired'
for 64-bit arguments or not. This will be false for all 64-bit targets,
and will be true on those architectures that pair (currently just armv7
and powerpc on FreeBSD 14.x).

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/arm/target.h    | 21 +++++++++++++++++++++
 bsd-user/i386/target.h   | 21 +++++++++++++++++++++
 bsd-user/qemu.h          |  1 +
 bsd-user/x86_64/target.h | 21 +++++++++++++++++++++
 4 files changed, 64 insertions(+)
 create mode 100644 bsd-user/arm/target.h
 create mode 100644 bsd-user/i386/target.h
 create mode 100644 bsd-user/x86_64/target.h

diff --git a/bsd-user/arm/target.h b/bsd-user/arm/target.h
new file mode 100644
index 00000000000..1f7ee49bfb4
--- /dev/null
+++ b/bsd-user/arm/target.h
@@ -0,0 +1,21 @@
+/*
+ * Intel general target stuff that's common to all i386 details
+ *
+ * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TARGET_H
+#define TARGET_H
+
+/*
+ * arm EABI 'lumps' the registers for 64-bit args.
+ */
+static inline int regpairs_aligned(void *cpu_env)
+{
+    return 1;
+}
+
+#endif /* ! TARGET_H */
+
diff --git a/bsd-user/i386/target.h b/bsd-user/i386/target.h
new file mode 100644
index 00000000000..b0ab477d683
--- /dev/null
+++ b/bsd-user/i386/target.h
@@ -0,0 +1,21 @@
+/*
+ * Intel general target stuff that's common to all i386 details
+ *
+ * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TARGET_ARCH_H
+#define TARGET_ARCH_H
+
+/*
+ * i386 doesn't 'lump' the registers for 64-bit args.
+ */
+static inline int regpairs_aligned(void *cpu_env)
+{
+    return 0;
+}
+
+#endif /* ! TARGET_ARCH_H */
+
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 56042ddbc5d..a9efa807b78 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -35,6 +35,7 @@ extern char **environ;
 #include "target_syscall.h"
 #include "target_os_vmparam.h"
 #include "target_os_signal.h"
+#include "target.h"
 #include "exec/gdbstub.h"
 
 /*
diff --git a/bsd-user/x86_64/target.h b/bsd-user/x86_64/target.h
new file mode 100644
index 00000000000..6d3aef8fc49
--- /dev/null
+++ b/bsd-user/x86_64/target.h
@@ -0,0 +1,21 @@
+/*
+ * Intel general target stuff that's common to all x86_64 details
+ *
+ * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TARGET_H
+#define TARGET_H
+
+/*
+ * x86 doesn't 'lump' the registers for 64-bit args, all args are 64 bits.
+ */
+static inline int regpairs_aligned(void *cpu_env)
+{
+    return 0;
+}
+
+#endif /* ! TARGET_H */
+
-- 
2.33.1


Re: [PATCH 17/22] bsd-user: introduce target.h
Posted by Kyle Evans 4 years ago
On Tue, Feb 1, 2022 at 5:15 AM Warner Losh <imp@bsdimp.com> wrote:
>
> Create target.h. This file is intended to be simple and describe basic
> things about the architecture. If something is a basic feature of the
> architecture, it belongs here. Should we need something that's per-BSD
> there will be a target-os.h that will live in the per-bsd directories.
>
> Define regpairs_aligned to reflect whether or not registers are 'paired'
> for 64-bit arguments or not. This will be false for all 64-bit targets,
> and will be true on those architectures that pair (currently just armv7
> and powerpc on FreeBSD 14.x).
>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>  bsd-user/arm/target.h    | 21 +++++++++++++++++++++
>  bsd-user/i386/target.h   | 21 +++++++++++++++++++++
>  bsd-user/qemu.h          |  1 +
>  bsd-user/x86_64/target.h | 21 +++++++++++++++++++++
>  4 files changed, 64 insertions(+)
>  create mode 100644 bsd-user/arm/target.h
>  create mode 100644 bsd-user/i386/target.h
>  create mode 100644 bsd-user/x86_64/target.h
>

Reviewed-by: Kyle Evans <kevans@FreeBSD.org>

> diff --git a/bsd-user/arm/target.h b/bsd-user/arm/target.h
> new file mode 100644
> index 00000000000..1f7ee49bfb4
> --- /dev/null
> +++ b/bsd-user/arm/target.h
> @@ -0,0 +1,21 @@
> +/*
> + * Intel general target stuff that's common to all i386 details
> + *
> + * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef TARGET_H
> +#define TARGET_H
> +
> +/*
> + * arm EABI 'lumps' the registers for 64-bit args.
> + */
> +static inline int regpairs_aligned(void *cpu_env)
> +{
> +    return 1;
> +}
> +
> +#endif /* ! TARGET_H */
> +
> diff --git a/bsd-user/i386/target.h b/bsd-user/i386/target.h
> new file mode 100644
> index 00000000000..b0ab477d683
> --- /dev/null
> +++ b/bsd-user/i386/target.h
> @@ -0,0 +1,21 @@
> +/*
> + * Intel general target stuff that's common to all i386 details
> + *
> + * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef TARGET_ARCH_H
> +#define TARGET_ARCH_H
> +
> +/*
> + * i386 doesn't 'lump' the registers for 64-bit args.
> + */
> +static inline int regpairs_aligned(void *cpu_env)
> +{
> +    return 0;
> +}
> +
> +#endif /* ! TARGET_ARCH_H */
> +
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index 56042ddbc5d..a9efa807b78 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -35,6 +35,7 @@ extern char **environ;
>  #include "target_syscall.h"
>  #include "target_os_vmparam.h"
>  #include "target_os_signal.h"
> +#include "target.h"
>  #include "exec/gdbstub.h"
>
>  /*
> diff --git a/bsd-user/x86_64/target.h b/bsd-user/x86_64/target.h
> new file mode 100644
> index 00000000000..6d3aef8fc49
> --- /dev/null
> +++ b/bsd-user/x86_64/target.h
> @@ -0,0 +1,21 @@
> +/*
> + * Intel general target stuff that's common to all x86_64 details
> + *
> + * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef TARGET_H
> +#define TARGET_H
> +
> +/*
> + * x86 doesn't 'lump' the registers for 64-bit args, all args are 64 bits.
> + */
> +static inline int regpairs_aligned(void *cpu_env)
> +{
> +    return 0;
> +}
> +
> +#endif /* ! TARGET_H */
> +
> --
> 2.33.1
>

Re: [PATCH 17/22] bsd-user: introduce target.h
Posted by Richard Henderson 4 years ago
On 2/1/22 22:14, Warner Losh wrote:
> Create target.h. This file is intended to be simple and describe basic
> things about the architecture. If something is a basic feature of the
> architecture, it belongs here. Should we need something that's per-BSD
> there will be a target-os.h that will live in the per-bsd directories.
> 
> Define regpairs_aligned to reflect whether or not registers are 'paired'
> for 64-bit arguments or not. This will be false for all 64-bit targets,
> and will be true on those architectures that pair (currently just armv7
> and powerpc on FreeBSD 14.x).
> 
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>   bsd-user/arm/target.h    | 21 +++++++++++++++++++++
>   bsd-user/i386/target.h   | 21 +++++++++++++++++++++
>   bsd-user/qemu.h          |  1 +
>   bsd-user/x86_64/target.h | 21 +++++++++++++++++++++
>   4 files changed, 64 insertions(+)
>   create mode 100644 bsd-user/arm/target.h
>   create mode 100644 bsd-user/i386/target.h
>   create mode 100644 bsd-user/x86_64/target.h
> 
> diff --git a/bsd-user/arm/target.h b/bsd-user/arm/target.h
> new file mode 100644
> index 00000000000..1f7ee49bfb4
> --- /dev/null
> +++ b/bsd-user/arm/target.h
> @@ -0,0 +1,21 @@
> +/*
> + * Intel general target stuff that's common to all i386 details
> + *
> + * Copyright (c) 2022 M. Warner Losh <imp@bsdimp.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef TARGET_H
> +#define TARGET_H
> +
> +/*
> + * arm EABI 'lumps' the registers for 64-bit args.
> + */
> +static inline int regpairs_aligned(void *cpu_env)

Nit: could use bool.  Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~