bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VERY RFC PATCH 2/2] Add basic public headers for AArch64


From: Sergey Bugaev
Subject: [VERY RFC PATCH 2/2] Add basic public headers for AArch64
Date: Tue, 2 Jan 2024 15:21:21 +0300

And just enough of buildsystem plumbing to install them.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---

This should not break anything if it is applied, but I don't expect it
to get applied as is. Rather, please review and discuss.

- exception.h lists some exception codes. Particularly, we can
  apparently distingiush reasons for float-point errors; and looks like
  with new enough Arm revisions, there are distinct ways for EL1 to get
  notified of PAC, BTI, and MTE failures (as opposed to PAC failure just
  producing an invalid pointer and expecting it to then crash the
  natural way, as it has been done in previous revisions, and described
  in many places all over the web), so we might as well expose those
  properly to userland.

  (But as always, I have no idea what I'm talking about, please correct
  me if you do.)

  The codes and their names are somewhat inspired by what XNU Mach has,
  but no compatibility with XNU is implied (for one thing, we're doing
  AArch64 as a separate architecture, and not as a 64-bit ARM flavor).

- mach_aarch64.defs currently only has an RPC to get hwcaps (and
  midr/revidr), using the HWCAP bits defined in the corresponding
  header, and matching Linux values (FreeBSD mostly uses the same values
  as well; we stick to Linux values when they differ). I imagine this is
  where we'd also have the RPCs to control PAC keys, and posibly more
  AArch64-specific things.

- syscall_sw.h defines the syscall ABI. We use the same ABI as Linux:
  the args are passed just like for a function call, and the trap
  number in x8; except we again require that no registers are clobbered.

- thread_status.h is too a bit inspired by the XNU version (see their
  struct arm_saved_state64), but different from that. I'm not at all
  sure how complete/reasonable my definitions are, so they should not by
  considered final / stable ABI/API - we can definitely tweak them (with
  matching changes in glibc).

- PAGE_SHIFT in vm_param.h is set to a placeholder value. While it may
  be reasonable to build Mach itself with a compile-time fixed page size
  (or maybe we do want to make it runtime-adjustable with a kernel
  cmdline option?), this definition there not only impacts Mach itself,
  but is exported to userspace, and currently <mach/vm_param.h> insists
  that <mach/machine/vm_param.h> must define PAGE_SHIFT, and defines
  PAGE_SIZE based on that. We should make it so that there are internal
  (unexported) PAGE_SIZE and PAGE_SHIFT definitions, but they are only
  publicly exported if the machine/port wants them to be (i386 will,
  aarch64 won't).

 Makefrag.am                                   |   3 +
 aarch64/Makefrag.am                           |  37 ++++++
 aarch64/aarch64/mach_aarch64.srv              |  23 ++++
 aarch64/configfrag.ac                         |   3 +
 aarch64/include/mach/aarch64/asm.h            |  33 +++++
 aarch64/include/mach/aarch64/boolean.h        |  24 ++++
 aarch64/include/mach/aarch64/exception.h      |  67 ++++++++++
 aarch64/include/mach/aarch64/fp_reg.h         |   1 +
 aarch64/include/mach/aarch64/kern_return.h    |  25 ++++
 .../include/mach/aarch64/mach_aarch64.defs    |  52 ++++++++
 .../include/mach/aarch64/mach_aarch64_types.h | 117 ++++++++++++++++
 .../include/mach/aarch64/machine_types.defs   |  92 +++++++++++++
 aarch64/include/mach/aarch64/syscall_sw.h     |  31 +++++
 aarch64/include/mach/aarch64/thread_status.h  |  41 ++++++
 aarch64/include/mach/aarch64/vm_param.h       |  32 +++++
 aarch64/include/mach/aarch64/vm_types.h       | 125 ++++++++++++++++++
 configure.ac                                  |   7 +-
 17 files changed, 712 insertions(+), 1 deletion(-)
 create mode 100644 aarch64/Makefrag.am
 create mode 100644 aarch64/aarch64/mach_aarch64.srv
 create mode 100644 aarch64/configfrag.ac
 create mode 100644 aarch64/include/mach/aarch64/asm.h
 create mode 100644 aarch64/include/mach/aarch64/boolean.h
 create mode 100644 aarch64/include/mach/aarch64/exception.h
 create mode 100644 aarch64/include/mach/aarch64/fp_reg.h
 create mode 100644 aarch64/include/mach/aarch64/kern_return.h
 create mode 100644 aarch64/include/mach/aarch64/mach_aarch64.defs
 create mode 100644 aarch64/include/mach/aarch64/mach_aarch64_types.h
 create mode 100644 aarch64/include/mach/aarch64/machine_types.defs
 create mode 100644 aarch64/include/mach/aarch64/syscall_sw.h
 create mode 100644 aarch64/include/mach/aarch64/thread_status.h
 create mode 100644 aarch64/include/mach/aarch64/vm_param.h
 create mode 100644 aarch64/include/mach/aarch64/vm_types.h

diff --git a/Makefrag.am b/Makefrag.am
index 5b61a1d6..c5c2ac09 100644
--- a/Makefrag.am
+++ b/Makefrag.am
@@ -609,3 +609,6 @@ include i386/Makefrag.am
 
 # x86_64.
 include x86_64/Makefrag.am
+
+# aarch64.
+include aarch64/Makefrag.am
diff --git a/aarch64/Makefrag.am b/aarch64/Makefrag.am
new file mode 100644
index 00000000..d594208c
--- /dev/null
+++ b/aarch64/Makefrag.am
@@ -0,0 +1,37 @@
+# Makefile fragment for aarch64.
+
+# Copyright (C) 2023-2024 Free Software Foundation, Inc.
+
+# Permission to use, copy, modify and distribute this software and its
+# documentation is hereby granted, provided that both the copyright
+# notice and this permission notice appear in all copies of the
+# software, derivative works or modified versions, and any portions
+# thereof, and that both notices appear in supporting documentation.
+#
+# THE FREE SOFTWARE FOUNDATION ALLOWS FREE USE OF THIS SOFTWARE IN ITS
+# "AS IS" CONDITION.  THE FREE SOFTWARE FOUNDATION DISCLAIMS ANY
+# LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
+# USE OF THIS SOFTWARE.
+
+EXTRA_DIST += \
+       aarch64/aarch64/mach_aarch64.srv \
+       aarch64/include/mach/aarch64
+
+#
+# Installation.
+#
+
+include_mach_aarch64dir = $(includedir)/mach/aarch64
+include_mach_aarch64_HEADERS = \
+       aarch64/include/mach/aarch64/asm.h \
+       aarch64/include/mach/aarch64/boolean.h \
+       aarch64/include/mach/aarch64/exception.h \
+       aarch64/include/mach/aarch64/fp_reg.h \
+       aarch64/include/mach/aarch64/kern_return.h \
+       aarch64/include/mach/aarch64/mach_aarch64.defs \
+       aarch64/include/mach/aarch64/mach_aarch64_types.h \
+       aarch64/include/mach/aarch64/machine_types.defs \
+       aarch64/include/mach/aarch64/syscall_sw.h \
+       aarch64/include/mach/aarch64/thread_status.h \
+       aarch64/include/mach/aarch64/vm_param.h \
+       aarch64/include/mach/aarch64/vm_types.h
diff --git a/aarch64/aarch64/mach_aarch64.srv b/aarch64/aarch64/mach_aarch64.srv
new file mode 100644
index 00000000..19b6c04c
--- /dev/null
+++ b/aarch64/aarch64/mach_aarch64.srv
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/* This is a server presentation file.  */
+
+#define KERNEL_SERVER 1
+
+#include <mach/aarch64/mach_aarch64.defs>
diff --git a/aarch64/configfrag.ac b/aarch64/configfrag.ac
new file mode 100644
index 00000000..d3468da5
--- /dev/null
+++ b/aarch64/configfrag.ac
@@ -0,0 +1,3 @@
+dnl Configure fragment for aarch64.
+
+# Nothing here at the moment.
diff --git a/aarch64/include/mach/aarch64/asm.h 
b/aarch64/include/mach/aarch64/asm.h
new file mode 100644
index 00000000..9d27f46d
--- /dev/null
+++ b/aarch64/include/mach/aarch64/asm.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _MACH_AARCH64_ASM_H_
+#define _MACH_AARCH64_ASM_H_
+
+#define EXT(x)         x
+#define LEXT(x)                x ## :
+#define SEXT(x)                #x
+
+#define TEXT_ALIGN     4
+#define DATA_ALIGN     4
+
+#define SVC            svc # (0)
+#define ENTRY(x)       .globl EXT(x); .type EXT(x), @function; .p2align 
TEXT_ALIGN; LEXT(x)
+#define END(x)         .size x,.-x
+
+#endif /* _MACH_AARCH64_ASM_H_ */
diff --git a/aarch64/include/mach/aarch64/boolean.h 
b/aarch64/include/mach/aarch64/boolean.h
new file mode 100644
index 00000000..da61ea7e
--- /dev/null
+++ b/aarch64/include/mach/aarch64/boolean.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _MACH_AARCH64_BOOLEAN_H_
+#define _MACH_AARCH64_BOOLEAN_H_
+
+typedef int boolean_t;
+
+#endif  /* _MACH_AARCH64_BOOLEAN_H_ */
diff --git a/aarch64/include/mach/aarch64/exception.h 
b/aarch64/include/mach/aarch64/exception.h
new file mode 100644
index 00000000..b1e71fcc
--- /dev/null
+++ b/aarch64/include/mach/aarch64/exception.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ *     Codes and subcodes for AArch64 exceptions.
+ */
+#ifndef        _MACH_AARCH64_EXCEPTION_H_
+#define _MACH_AARCH64_EXCEPTION_H_
+
+
+/*
+ *     EXC_BAD_INSTRUCTION
+ */
+
+
+/*
+ *     EXC_ARITHMETIC
+ */
+
+#define EXC_AARCH64_FP_ID              1       /* input denormal, IDF bit */
+#define EXC_AARCH64_FP_IX              2       /* inexact, IXF bit */
+#define EXC_AARCH64_FP_UF              3       /* underflow, UFF bit */
+#define EXC_AARCH64_FP_OF              4       /* overflow, OFF bit */
+#define EXC_AARCH64_FP_DZ              5       /* divide by zero, DZF bit */
+#define EXC_AARCH64_FP_IO              6       /* invalid operation, IOF bit */
+
+/*
+ *     EXC_SOFTWARE
+ */
+
+/*
+ *     EXC_BAD_ACCESS
+ *
+ *     Exception code normally holds a kern_return_t value (such as
+ *     KERN_INVALID_ADDRESS), but for AArch64-specific exceptions these
+ *     values can be used as exception code instead; they must not conflict
+ *     with kern_return_t values.
+ */
+#define EXC_AARCH64_AL_FAULT           100     /* alignment fault */
+#define EXC_AARCH64_AL_PC              101     /* misaligned pc */
+#define EXC_AARCH64_AL_SP              102     /* misaligned sp */
+#define EXC_AARCH64_PAC                        103     /* PAC failure */
+#define EXC_AARCH64_MTE                        104     /* MTE failure */
+#define EXC_AARCH64_BTI                        105     /* BTI failure */
+
+/*
+ *     EXC_BREAKPOINT
+ */
+
+#define EXC_AARCH64_BRK                        1       /* BKPT, BRK */
+
+#endif /* _MACH_AARCH64_EXCEPTION_H_ */
diff --git a/aarch64/include/mach/aarch64/fp_reg.h 
b/aarch64/include/mach/aarch64/fp_reg.h
new file mode 100644
index 00000000..b97352f9
--- /dev/null
+++ b/aarch64/include/mach/aarch64/fp_reg.h
@@ -0,0 +1 @@
+/* Nothing here yet.  */
diff --git a/aarch64/include/mach/aarch64/kern_return.h 
b/aarch64/include/mach/aarch64/kern_return.h
new file mode 100644
index 00000000..43107046
--- /dev/null
+++ b/aarch64/include/mach/aarch64/kern_return.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _MACH_AARCH64_KERN_RETURN_H_
+#define _MACH_AARCH64_KERN_RETURN_H_
+
+#ifndef __ASSEMBLER__
+typedef int kern_return_t;
+#endif  /* __ASSEMBLER__ */
+#endif  /* _MACH_AARCH64_KERN_RETURN_H_ */
diff --git a/aarch64/include/mach/aarch64/mach_aarch64.defs 
b/aarch64/include/mach/aarch64/mach_aarch64.defs
new file mode 100644
index 00000000..e82ee459
--- /dev/null
+++ b/aarch64/include/mach/aarch64/mach_aarch64.defs
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * Special functions for aarch64.
+ */
+
+subsystem
+#if    KERNEL_SERVER
+         KernelServer
+#endif /* KERNEL_SERVER */
+                      mach_aarch64 4500;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+#ifdef MACH_AARCH64_IMPORTS
+MACH_AARCH64_IMPORTS
+#endif
+
+import <mach/aarch64/mach_aarch64_types.h>;
+
+/*
+ *     An array containing bitmasks; the meaning of individual
+ *     bits is defined by the HWCAP_* and HWCAP2_* constants
+ *     from the mach_aarch64_types.h header. In this version
+ *     of Mach, the array will contain two items, but future
+ *     versions can add more items and more bits (HWCAP3_* and
+ *     so forth).
+ */
+type   hwcaps_t        =       array[*:16] of uint32_t;
+
+routine aarch64_get_hwcaps(
+               host            : host_t;
+       out     hwcaps          : hwcaps_t, CountInOut;
+       out     midr_el1        : uint64_t;
+       out     revidr_el1      : uint64_t);
diff --git a/aarch64/include/mach/aarch64/mach_aarch64_types.h 
b/aarch64/include/mach/aarch64/mach_aarch64_types.h
new file mode 100644
index 00000000..21039dc3
--- /dev/null
+++ b/aarch64/include/mach/aarch64/mach_aarch64_types.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _MACH_MACH_AARCH64_TYPES_H_
+#define _MACH_MACH_AARCH64_TYPES_H_
+
+/* The currently defined number of hwcap values.
+   More ones could be added in future versions.  */
+#define HWCAPS_COUNT   2
+
+#ifndef __ASSEMBLER__
+typedef uint32_t *hwcaps_t;
+#endif
+
+/* These definitions are meant to match those in
+   linux:arch/arm64/include/uapi/asm/hwcap.h and
+   glibc:sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h,
+   but this is not strictly required for anything.  */
+
+#define HWCAP_FP               (1 << 0)
+#define HWCAP_ASIMD            (1 << 1)
+#define HWCAP_EVTSTRM          (1 << 2)
+#define HWCAP_AES              (1 << 3)
+#define HWCAP_PMULL            (1 << 4)
+#define HWCAP_SHA1             (1 << 5)
+#define HWCAP_SHA2             (1 << 6)
+#define HWCAP_CRC32            (1 << 7)
+#define HWCAP_ATOMICS          (1 << 8)
+#define HWCAP_FPHP             (1 << 9)
+#define HWCAP_ASIMDHP          (1 << 10)
+#define HWCAP_CPUID            (1 << 11)
+#define HWCAP_ASIMDRDM         (1 << 12)
+#define HWCAP_JSCVT            (1 << 13)
+#define HWCAP_FCMA             (1 << 14)
+#define HWCAP_LRCPC            (1 << 15)
+#define HWCAP_DCPOP            (1 << 16)
+#define HWCAP_SHA3             (1 << 17)
+#define HWCAP_SM3              (1 << 18)
+#define HWCAP_SM4              (1 << 19)
+#define HWCAP_ASIMDDP          (1 << 20)
+#define HWCAP_SHA512           (1 << 21)
+#define HWCAP_SVE              (1 << 22)
+#define HWCAP_ASIMDFHM         (1 << 23)
+#define HWCAP_DIT              (1 << 24)
+#define HWCAP_USCAT            (1 << 25)
+#define HWCAP_ILRCPC           (1 << 26)
+#define HWCAP_FLAGM            (1 << 27)
+#define HWCAP_SSBS             (1 << 28)
+#define HWCAP_SB               (1 << 29)
+#define HWCAP_PACA             (1 << 30)
+#define HWCAP_PACG             (1UL << 31)
+
+#define HWCAP2_DCPODP          (1 << 0)
+#define HWCAP2_SVE2            (1 << 1)
+#define HWCAP2_SVEAES          (1 << 2)
+#define HWCAP2_SVEPMULL                (1 << 3)
+#define HWCAP2_SVEBITPERM      (1 << 4)
+#define HWCAP2_SVESHA3         (1 << 5)
+#define HWCAP2_SVESM4          (1 << 6)
+#define HWCAP2_FLAGM2          (1 << 7)
+#define HWCAP2_FRINT           (1 << 8)
+#define HWCAP2_SVEI8MM         (1 << 9)
+#define HWCAP2_SVEF32MM                (1 << 10)
+#define HWCAP2_SVEF64MM                (1 << 11)
+#define HWCAP2_SVEBF16         (1 << 12)
+#define HWCAP2_I8MM            (1 << 13)
+#define HWCAP2_BF16            (1 << 14)
+#define HWCAP2_DGH             (1 << 15)
+#define HWCAP2_RNG             (1 << 16)
+#define HWCAP2_BTI             (1 << 17)
+#define HWCAP2_MTE             (1 << 18)
+#define HWCAP2_ECV             (1 << 19)
+#define HWCAP2_AFP             (1 << 20)
+#define HWCAP2_RPRES           (1 << 21)
+#define HWCAP2_MTE3            (1 << 22)
+#define HWCAP2_SME             (1 << 23)
+#define HWCAP2_SME_I16I64      (1 << 24)
+#define HWCAP2_SME_F64F64      (1 << 25)
+#define HWCAP2_SME_I8I32       (1 << 26)
+#define HWCAP2_SME_F16F32      (1 << 27)
+#define HWCAP2_SME_B16F32      (1 << 28)
+#define HWCAP2_SME_F32F32      (1 << 29)
+#define HWCAP2_SME_FA64                (1 << 30)
+#define HWCAP2_WFXT            (1UL << 31)
+#define HWCAP2_EBF16           (1UL << 32)
+#define HWCAP2_SVE_EBF16       (1UL << 33)
+#define HWCAP2_CSSC            (1UL << 34)
+#define HWCAP2_RPRFM           (1UL << 35)
+#define HWCAP2_SVE2P1          (1UL << 36)
+#define HWCAP2_SME2            (1UL << 37)
+#define HWCAP2_SME2P1          (1UL << 38)
+#define HWCAP2_SME_I16I32      (1UL << 39)
+#define HWCAP2_SME_BI32I32     (1UL << 40)
+#define HWCAP2_SME_B16B16      (1UL << 41)
+#define HWCAP2_SME_F16F16      (1UL << 42)
+#define HWCAP2_MOPS            (1UL << 43)
+#define HWCAP2_HBC             (1UL << 44)
+#define HWCAP2_SVE_B16B16      (1UL << 45)
+#define HWCAP2_LRCPC3          (1UL << 46)
+#define HWCAP2_LSE128          (1UL << 47)
+
+#endif
diff --git a/aarch64/include/mach/aarch64/machine_types.defs 
b/aarch64/include/mach/aarch64/machine_types.defs
new file mode 100644
index 00000000..02cf0810
--- /dev/null
+++ b/aarch64/include/mach/aarch64/machine_types.defs
@@ -0,0 +1,92 @@
+/* 
+ * Mach Operating System
+ * Copyright (c) 1992 Carnegie Mellon University
+ * All Rights Reserved.
+ * 
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ * 
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ * 
+ * Carnegie Mellon requests users of this software to return to
+ * 
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ * 
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ *     File:   mach/machine/machine_types.defs
+ *     Author: Alessandro Forin
+ *     Date:   7/92
+ *
+ *     Header file for the basic, machine-dependent data types.
+ *     Version for 32 bit architectures.
+ *
+ */
+
+#ifndef        _MACHINE_MACHINE_TYPES_DEFS_
+#define        _MACHINE_MACHINE_TYPES_DEFS_    1
+
+/*
+ * A natural_t is the type for the native
+ * unsigned integer type, usually 32 bits. It is suitable for
+ * most counters with a small chance of overflow.
+ * While historically natural_t was meant to be the same
+ * as a pointer, that is not the case here.
+ */
+type natural_t = uint32_t;
+
+/*
+ * An integer_t is the signed counterpart
+ * of the natural_t type. Both types are
+ * only supposed to be used to define
+ * other types in a machine-independent
+ * way.
+ */
+type integer_t = int32_t;
+
+type rpc_long_natural_t = uint64_t;
+type rpc_long_integer_t = int64_t;
+
+/*
+ * A long_natural_t is a possibly larger unsigned integer type than natural_t.
+ * Should be used instead of natural_t when we want the data to be less subject
+ * to overflows.
+ */
+type long_natural_t = rpc_long_natural_t
+#if defined(KERNEL_SERVER)
+    intran: long_natural_t convert_long_natural_from_user(rpc_long_natural_t)
+    outtran: rpc_long_natural_t convert_long_natural_to_user(long_natural_t)
+#elif defined(KERNEL_USER)
+    ctype: rpc_long_natural_t
+#endif
+    ;
+
+/*
+ * Larger version of integer_t. Only used when we want to hold possibly larger
+ * values than what is possible with integer_t.
+ */
+type long_integer_t = rpc_long_integer_t
+#if defined(KERNEL_SERVER)
+    intran: long_integer_t convert_long_integer_from_user(rpc_long_integer_t)
+    outtran: rpc_long_integer_t convert_long_integer_to_user(long_integer_t)
+#elif defined(KERNEL_USER)
+    ctype: rpc_long_integer_t
+#endif
+    ;
+
+/*
+ * Physical address size
+ */
+type rpc_phys_addr_t = uint64_t;
+
+#endif /* _MACHINE_MACHINE_TYPES_DEFS_ */
diff --git a/aarch64/include/mach/aarch64/syscall_sw.h 
b/aarch64/include/mach/aarch64/syscall_sw.h
new file mode 100644
index 00000000..f520189a
--- /dev/null
+++ b/aarch64/include/mach/aarch64/syscall_sw.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef        _MACH_AARCH64_SYSCALL_SW_H_
+#define _MACH_AARCH64_SYSCALL_SW_H_
+
+#include <mach/machine/asm.h>
+
+#define kernel_trap(trap_name,trap_number,number_args)  \
+ENTRY(trap_name)  \
+       mov w8, #(trap_number);  \
+       SVC;  \
+       ret;  \
+END(trap_name)
+
+#endif /* _MACH_AARCH64_SYSCALL_SW_H_ */
diff --git a/aarch64/include/mach/aarch64/thread_status.h 
b/aarch64/include/mach/aarch64/thread_status.h
new file mode 100644
index 00000000..5784994f
--- /dev/null
+++ b/aarch64/include/mach/aarch64/thread_status.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef        _MACH_AARCH64_THREAD_STATUS_H_
+#define _MACH_AARCH64_THREAD_STATUS_H_
+
+#define AARCH64_THREAD_STATE   1
+#define AARCH64_FLOAT_STATE    2
+
+struct aarch64_thread_state {
+       uint64_t x[31];
+       uint64_t sp;
+       uint64_t pc;
+       uint64_t tpidr_el0;
+       uint32_t cpsr;
+};
+#define AARCH64_THREAD_STATE_COUNT     (sizeof (struct aarch64_thread_state) / 
sizeof(unsigned int))
+
+struct aarch64_float_state {
+       __int128 v[32];
+       uint32_t fpsr;
+       uint32_t fpcr;
+};
+#define AARCH64_FLOAT_STATE_COUNT      (sizeof (struct aarch64_float_state) / 
sizeof(unsigned int))
+
+#endif /* _MACH_AARHC64_THREAD_STATUS_H_ */
diff --git a/aarch64/include/mach/aarch64/vm_param.h 
b/aarch64/include/mach/aarch64/vm_param.h
new file mode 100644
index 00000000..1676d7a7
--- /dev/null
+++ b/aarch64/include/mach/aarch64/vm_param.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2023-2024 Free Software Foundation.
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef        _MACH_AARCH64_VM_PARAM_H_
+#define _MACH_AARCH64_VM_PARAM_H_
+
+#include <mach/machine/vm_types.h>
+
+#define BYTE_SIZE      8       /* byte size in bits */
+
+#define VM_MIN_ADDRESS         (0ULL)
+#define VM_MAX_ADDRESS         (0x800000000000ULL)
+
+/* FIXME this is intentionally wrong */
+#define PAGE_SHIFT             123456
+
+#endif /* _MACH_AARCH64_VM_PARAM_H_ */
diff --git a/aarch64/include/mach/aarch64/vm_types.h 
b/aarch64/include/mach/aarch64/vm_types.h
new file mode 100644
index 00000000..0ec84bc1
--- /dev/null
+++ b/aarch64/include/mach/aarch64/vm_types.h
@@ -0,0 +1,125 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1992,1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
+ *  School of Computer Science
+ *  Carnegie Mellon University
+ *  Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef        _MACHINE_VM_TYPES_H_
+#define _MACHINE_VM_TYPES_H_   1
+
+#ifdef __ASSEMBLER__
+#else  /* __ASSEMBLER__ */
+
+#include <stdint.h>
+
+#ifdef MACH_KERNEL
+#include <kern/assert.h>
+#endif
+
+/*
+ * A natural_t is the type for the native
+ * unsigned integer type, usually 32 bits. It is suitable for
+ * most counters with a small chance of overflow.
+ * While historically natural_t was meant to be the same
+ * as a pointer, that is not the case here.
+ */
+typedef unsigned int   natural_t;
+
+/*
+ * An integer_t is the signed counterpart
+ * of the natural_t type. Both types are
+ * only supposed to be used to define
+ * other types in a machine-independent
+ * way.
+ */
+typedef int            integer_t;
+
+/*
+ * A long_natural_t is a possibly larger unsigned integer type than natural_t.
+ * Should be used instead of natural_t when we want the data to be less subject
+ * to overflows.
+ */
+typedef unsigned long long_natural_t;
+
+/*
+ * Larger version of integer_t. Only used when we want to hold possibly larger
+ * values than what is possible with integer_t.
+ */
+typedef long long_integer_t;
+
+/*
+ * A vm_offset_t is a type-neutral pointer,
+ * e.g. an offset into a virtual memory space.
+ */
+typedef        uintptr_t       vm_offset_t;
+typedef        vm_offset_t *   vm_offset_array_t;
+
+/*
+ * A type for physical addresses.
+ */
+typedef unsigned long phys_addr_t;
+typedef unsigned long rpc_phys_addr_t;
+
+/*
+ * A vm_size_t is the proper type for e.g.
+ * expressing the difference between two
+ * vm_offset_t entities.
+ */
+typedef uintptr_t vm_size_t;
+typedef        vm_size_t *     vm_size_array_t;
+
+/*
+ * rpc_types are for user/kernel interfaces. On kernel side they may differ 
from
+ * the native types, while on user space they shall be the same.
+ * These three types are always of the same size, so we can reuse the 
conversion
+ * functions.
+ */
+typedef uintptr_t      rpc_uintptr_t;
+typedef vm_offset_t    rpc_vm_address_t;
+typedef vm_offset_t    rpc_vm_offset_t;
+typedef vm_size_t      rpc_vm_size_t;
+
+#define convert_vm_to_user null_conversion
+#define convert_vm_from_user null_conversion
+
+typedef long_natural_t rpc_long_natural_t;
+typedef long_integer_t rpc_long_integer_t;
+
+#define convert_long_integer_to_user null_conversion
+#define convert_long_integer_from_user null_conversion
+
+#define convert_long_natural_to_user convert_vm_to_user
+#define convert_long_natural_from_user convert_vm_from_user
+
+typedef        rpc_vm_size_t * rpc_vm_size_array_t;
+typedef        rpc_vm_offset_t *       rpc_vm_offset_array_t;
+
+#endif /* __ASSEMBLER__ */
+
+/*
+ * If composing messages by hand (please dont)
+ */
+
+#define        MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32
+
+#endif /* _MACHINE_VM_TYPES_H_ */
diff --git a/configure.ac b/configure.ac
index cadc33b6..88b2533a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,8 +66,10 @@ case $host_platform:$host_cpu in
     [host_platform=at;;
   at:i?86 | xen:i?86 | at:x86_64 | xen:x86_64)
     :;;
+  *:aarch64)
+    ;;
   *)]
-    AC_MSG_ERROR([unsupported combination of cpu type `$host_cpu' and platform
+    AC_MSG_ERROR([unsupported combination of cpu type `$host_cpu' and platform 
\
       `$host_platform'.])[;;
 esac]
 AC_SUBST([host_platform])
@@ -176,6 +178,9 @@ m4_include([i386/configfrag.ac])
 # x86_64
 m4_include([x86_64/configfrag.ac])
 
+# aarch64
+m4_include([aarch64/configfrag.ac])
+
 # General options.
 m4_include([configfrag.ac])
 
-- 
2.43.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]