[haiku-commits] haiku: hrev52162 - in headers: private/kernel/arch/arm64 posix/arch/arm64

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 2 Aug 2018 20:55:30 -0400 (EDT)

hrev52162 adds 5 changesets to branch 'master'
old head: 9a90ee3a38f7cf8ab7f06bf0062424d093560a29
new head: 3a72e3ebeeae13395c2172eb2ee9fd93c8509166
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=3a72e3ebeeae+%5E9a90ee3a38f7

----------------------------------------------------------------------------

fb4cc9847261: build: Add initial ARM64 target.
  
  It will probably be just stubs for the significant future, but,
  here it is anyway.
  
  Regarding the naming: Yes, the official name is "aarch64." However,
  Linux, FreeBSD, and Zircon all call it "arm64", and so we will do the same.
  
  I've configured it initially to be a Clang-only port, making no
  changes to GCC buildtools whatsoever here. We'll see if that sticks,
  however.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

5effe7f3ecfa: bootloader: Align boot volume structure to 8 bytes instead of 4.
  
  This alignment is preferred e.g. on ARM when using 64-bit values.
  
  Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>

                                   [ Jaroslaw Pelczar <jarek@xxxxxxxxxxxx> ]

25cd28e8c174: posix: Add initial ARM64 headers.
  
  Almost directly copied from jpelczar's work.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

0689d8ddb87c: BuildSetup: aarch64 -> arm64.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

3a72e3ebeeae: ARM64: Add initial kernel headers
  
  Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>
  aarch64 -> arm64 and coding style fixes by me.

                                   [ Jaroslaw Pelczar <jarek@xxxxxxxxxxxx> ]

----------------------------------------------------------------------------

21 files changed, 683 insertions(+), 9 deletions(-)
build/jam/BuildSetup                             |   2 +-
configure                                        |   5 +-
headers/config/HaikuConfig.h                     |   5 +
headers/os/kernel/elf.h                          |   3 +-
headers/posix/arch/arm64/fenv.h                  | 248 +++++++++++++++++++
headers/posix/arch/arm64/signal.h                |  29 +++
headers/private/kernel/arch/arm64/arch_atomic.h  |  32 +++
headers/private/kernel/arch/arm64/arch_cpu.h     | 158 ++++++++++++
headers/private/kernel/arch/arm64/arch_debug.h   |  17 ++
headers/private/kernel/arch/arm64/arch_int.h     |  15 ++
headers/private/kernel/arch/arm64/arch_kernel.h  |  27 ++
.../private/kernel/arch/arm64/arch_kernel_args.h |  19 ++
.../private/kernel/arch/arm64/arch_system_info.h |   9 +
headers/private/kernel/arch/arm64/arch_thread.h  |  34 +++
.../kernel/arch/arm64/arch_thread_types.h        |  30 +++
.../kernel/arch/arm64/arch_user_debugger.h       |  17 ++
headers/private/kernel/arch/arm64/arch_vm.h      |  12 +
.../kernel/arch/arm64/arch_vm_translation_map.h  |   9 +
.../private/kernel/arch/arm64/arch_vm_types.h    |   9 +
src/system/boot/loader/main.cpp                  |   8 +-
src/system/runtime_loader/runtime_loader.cpp     |   4 +-

############################################################################

Commit:      fb4cc9847261bd198062eb7194e6ef540b33a5e3
URL:         https://git.haiku-os.org/haiku/commit/?id=fb4cc9847261
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Aug  2 23:48:29 2018 UTC

build: Add initial ARM64 target.

It will probably be just stubs for the significant future, but,
here it is anyway.

Regarding the naming: Yes, the official name is "aarch64." However,
Linux, FreeBSD, and Zircon all call it "arm64", and so we will do the same.

I've configured it initially to be a Clang-only port, making no
changes to GCC buildtools whatsoever here. We'll see if that sticks,
however.

----------------------------------------------------------------------------

diff --git a/configure b/configure
index 602ddfda04..18b44d9ef5 100755
--- a/configure
+++ b/configure
@@ -32,7 +32,7 @@ options:
                               directory under "cross-tools". The HAIKU_* tools
                               variables will be set accordingly.
                               <arch> specifies the target architecture, either
-                              "x86_gcc2", "x86", "x86_64", "ppc", "m68k", "arm"
+                              "x86_gcc2", "x86", "x86_64", "ppc", "m68k", 
"arm", "arm64"
                               This option and --cross-tools-prefix can be
                               specified multiple times. The first cross tools
                               specify the primary tools, the subsequent ones 
the
@@ -254,6 +254,7 @@ standard_gcc_settings()
        # determine architecture from machine triple
        case $gccMachine in
                arm-*)          targetCpu=arm;;
+               arm64-*)        targetCpu=arm64;;
                i?86-*)         targetCpu=x86;;
                m68k-*)         targetCpu=m68k;;
                powerpc-*)      targetCpu=ppc;;
@@ -599,6 +600,7 @@ export haikuRequiredLegacyGCCVersion
        # version of legacy gcc required to build haiku
 supportedTargetArchs="
        arm
+       arm64
        m68k
        ppc
        x86
@@ -706,6 +708,7 @@ while [ $# -gt 0 ] ; do
                                x86_64)         
targetMachine=x86_64-unknown-haiku;;
                                ppc)            
targetMachine=powerpc-apple-haiku;;
                                arm)            
targetMachine=arm-unknown-haiku;;
+                               arm64)          
targetMachine=arm64-unknown-haiku;;
                                *)
                                        echo "Unsupported target architecture: 
$2" >&2
                                        exit 1
diff --git a/headers/config/HaikuConfig.h b/headers/config/HaikuConfig.h
index d99a23285b..f28e193f9e 100644
--- a/headers/config/HaikuConfig.h
+++ b/headers/config/HaikuConfig.h
@@ -56,6 +56,11 @@
 #      define __HAIKU_ARCH_ABI                         "armeb"
 #      define __HAIKU_ARCH_ARM                         1
 #      define __HAIKU_BIG_ENDIAN                       1
+#elif defined(__arm64__)
+#      define __HAIKU_ARCH                                     arm64
+#      define __HAIKU_ARCH_ABI                         "arm64"
+#      define __HAIKU_ARCH_ARM64                       1
+#      define __HAIKU_ARCH_BITS                        64
 #else
 #      error Unsupported architecture!
 #endif
diff --git a/headers/os/kernel/elf.h b/headers/os/kernel/elf.h
index 0449cb47c5..45a8212a74 100644
--- a/headers/os/kernel/elf.h
+++ b/headers/os/kernel/elf.h
@@ -186,7 +186,8 @@ typedef struct {
 #define EM_BLACKFIN            106 /* Analog Devices Blackfin (DSP) processor 
*/
 #define EM_ARCA                        109 /* Arca RISC Microprocessor */
 #define EM_VIDCORE3            137 /* Broadcom VideoCore III */
-#define EM_AARCH64             183 /* ARM 64 bit */
+#define EM_ARM64               183 /* ARM 64 bit */
+#define EM_AARCH64             EM_ARM64
 #define EM_AVR32               185 /* AVR-32 */
 #define EM_STM8                        186 /* ST STM8S */
 #define EM_CUDA                        190 /* Nvidia CUDA */
diff --git a/src/system/runtime_loader/runtime_loader.cpp 
b/src/system/runtime_loader/runtime_loader.cpp
index e632895e92..b92f01eb1e 100644
--- a/src/system/runtime_loader/runtime_loader.cpp
+++ b/src/system/runtime_loader/runtime_loader.cpp
@@ -667,8 +667,8 @@ get_executable_architecture(int fd, const char** 
_architecture)
                case EM_ARM:
                        architecture = "arm";
                        break;
-               case EM_AARCH64:
-                       architecture = "aarch64";
+               case EM_ARM64:
+                       architecture = "arm64";
                        break;
                case EM_X86_64:
                        architecture = "x86_64";

############################################################################

Commit:      5effe7f3ecfad3e75c84ce604da8ab84ef7ddce4
URL:         https://git.haiku-os.org/haiku/commit/?id=5effe7f3ecfa
Author:      Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
Date:        Fri Mar  9 20:47:54 2018 UTC
Committer:   Augustin Cavalier <waddlesplash@xxxxxxxxx>
Commit-Date: Thu Aug  2 23:51:53 2018 UTC

bootloader: Align boot volume structure to 8 bytes instead of 4.

This alignment is preferred e.g. on ARM when using 64-bit values.

Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/system/boot/loader/main.cpp b/src/system/boot/loader/main.cpp
index bb7a063ccc..e6b081e874 100644
--- a/src/system/boot/loader/main.cpp
+++ b/src/system/boot/loader/main.cpp
@@ -132,15 +132,15 @@ main(stage2_args *args)
                        gKernelArgs.version = CURRENT_KERNEL_ARGS_VERSION;
 
                        // clone the boot_volume KMessage into kernel 
accessible memory
-                       // note, that we need to 4 byte align the buffer and 
thus allocate
-                       // 3 more bytes
-                       void* buffer = 
kernel_args_malloc(gBootVolume.ContentSize() + 3);
+                       // note, that we need to 8-byte align the buffer and 
thus allocate
+                       // 7 more bytes
+                       void* buffer = 
kernel_args_malloc(gBootVolume.ContentSize() + 7);
                        if (!buffer) {
                                panic("Could not allocate memory for the boot 
volume kernel "
                                        "arguments");
                        }
 
-                       buffer = (void*)(((addr_t)buffer + 3) & ~(addr_t)0x3);
+                       buffer = (void*)(((addr_t)buffer + 7) & ~(addr_t)0x7);
                        memcpy(buffer, gBootVolume.Buffer(), 
gBootVolume.ContentSize());
                        gKernelArgs.boot_volume = buffer;
                        gKernelArgs.boot_volume_size = 
gBootVolume.ContentSize();

############################################################################

Commit:      25cd28e8c17473039735b01fdd5e06a7c8bf7825
URL:         https://git.haiku-os.org/haiku/commit/?id=25cd28e8c174
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Aug  2 23:59:30 2018 UTC

posix: Add initial ARM64 headers.

Almost directly copied from jpelczar's work.

----------------------------------------------------------------------------

diff --git a/headers/posix/arch/arm64/fenv.h b/headers/posix/arch/arm64/fenv.h
new file mode 100644
index 0000000000..1d197f0b01
--- /dev/null
+++ b/headers/posix/arch/arm64/fenv.h
@@ -0,0 +1,248 @@
+/*-
+ * Copyright (c) 2004-2005 David Schultz <das@xxxxxxxxxxx>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef        _FENV_H_
+#define        _FENV_H_
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#ifndef        __fenv_static
+#define        __fenv_static   static
+#endif
+
+typedef        uint64_t        fenv_t;
+typedef        uint64_t        fexcept_t;
+
+/* Exception flags */
+#define        FE_INVALID      0x00000001
+#define        FE_DIVBYZERO    0x00000002
+#define        FE_OVERFLOW     0x00000004
+#define        FE_UNDERFLOW    0x00000008
+#define        FE_INEXACT      0x00000010
+#define        FE_ALL_EXCEPT   (FE_DIVBYZERO | FE_INEXACT | \
+                        FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+
+/*
+ * Rounding modes
+ *
+ * We can't just use the hardware bit values here, because that would
+ * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed.
+ */
+#define        FE_TONEAREST    0x0
+#define        FE_UPWARD       0x1
+#define        FE_DOWNWARD     0x2
+#define        FE_TOWARDZERO   0x3
+#define        _ROUND_MASK     (FE_TONEAREST | FE_DOWNWARD | \
+                        FE_UPWARD | FE_TOWARDZERO)
+#define        _ROUND_SHIFT    22
+
+__BEGIN_DECLS
+
+/* Default floating-point environment */
+extern const fenv_t    __fe_dfl_env;
+#define        FE_DFL_ENV      (&__fe_dfl_env)
+
+/* We need to be able to map status flag positions to mask flag positions */
+#define _FPUSW_SHIFT   8
+#define        _ENABLE_MASK    (FE_ALL_EXCEPT << _FPUSW_SHIFT)
+
+#define        __mrs_fpcr(__r) __asm __volatile("mrs %0, fpcr" : "=r" (__r))
+#define        __msr_fpcr(__r) __asm __volatile("msr fpcr, %0" : : "r" (__r))
+
+#define        __mrs_fpsr(__r) __asm __volatile("mrs %0, fpsr" : "=r" (__r))
+#define        __msr_fpsr(__r) __asm __volatile("msr fpsr, %0" : : "r" (__r))
+
+__fenv_static __inline int
+feclearexcept(int __excepts)
+{
+       fexcept_t __r;
+
+       __mrs_fpsr(__r);
+       __r &= ~__excepts;
+       __msr_fpsr(__r);
+       return (0);
+}
+
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+       fexcept_t __r;
+
+       __mrs_fpsr(__r);
+       *__flagp = __r & __excepts;
+       return (0);
+}
+
+__fenv_static inline int
+fesetexceptflag(const fexcept_t *__flagp, int __excepts)
+{
+       fexcept_t __r;
+
+       __mrs_fpsr(__r);
+       __r &= ~__excepts;
+       __r |= *__flagp & __excepts;
+       __msr_fpsr(__r);
+       return (0);
+}
+
+__fenv_static inline int
+feraiseexcept(int __excepts)
+{
+       fexcept_t __r;
+
+       __mrs_fpsr(__r);
+       __r |= __excepts;
+       __msr_fpsr(__r);
+       return (0);
+}
+
+__fenv_static inline int
+fetestexcept(int __excepts)
+{
+       fexcept_t __r;
+
+       __mrs_fpsr(__r);
+       return (__r & __excepts);
+}
+
+__fenv_static inline int
+fegetround(void)
+{
+       fenv_t __r;
+
+       __mrs_fpcr(__r);
+       return ((__r >> _ROUND_SHIFT) & _ROUND_MASK);
+}
+
+__fenv_static inline int
+fesetround(int __round)
+{
+       fenv_t __r;
+
+       if (__round & ~_ROUND_MASK)
+               return (-1);
+       __mrs_fpcr(__r);
+       __r &= ~(_ROUND_MASK << _ROUND_SHIFT);
+       __r |= __round << _ROUND_SHIFT;
+       __msr_fpcr(__r);
+       return (0);
+}
+
+__fenv_static inline int
+fegetenv(fenv_t *__envp)
+{
+       fenv_t __r;
+
+       __mrs_fpcr(__r);
+       *__envp = __r & _ENABLE_MASK;
+
+       __mrs_fpsr(__r);
+       *__envp |= __r & (FE_ALL_EXCEPT | (_ROUND_MASK << _ROUND_SHIFT));
+
+       return (0);
+}
+
+__fenv_static inline int
+feholdexcept(fenv_t *__envp)
+{
+       fenv_t __r;
+
+       __mrs_fpcr(__r);
+       *__envp = __r & _ENABLE_MASK;
+       __r &= ~(_ENABLE_MASK);
+       __msr_fpcr(__r);
+
+       __mrs_fpsr(__r);
+       *__envp |= __r & (FE_ALL_EXCEPT | (_ROUND_MASK << _ROUND_SHIFT));
+       __r &= ~(_ENABLE_MASK);
+       __msr_fpsr(__r);
+       return (0);
+}
+
+__fenv_static inline int
+fesetenv(const fenv_t *__envp)
+{
+
+       __msr_fpcr((*__envp) & _ENABLE_MASK);
+       __msr_fpsr((*__envp) & (FE_ALL_EXCEPT | (_ROUND_MASK << _ROUND_SHIFT)));
+       return (0);
+}
+
+__fenv_static inline int
+feupdateenv(const fenv_t *__envp)
+{
+       fexcept_t __r;
+
+       __mrs_fpsr(__r);
+       fesetenv(__envp);
+       feraiseexcept(__r & FE_ALL_EXCEPT);
+       return (0);
+}
+
+#if __BSD_VISIBLE
+
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
+feenableexcept(int __mask)
+{
+       fenv_t __old_r, __new_r;
+
+       __mrs_fpcr(__old_r);
+       __new_r = __old_r | ((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
+       __msr_fpcr(__new_r);
+       return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static inline int
+fedisableexcept(int __mask)
+{
+       fenv_t __old_r, __new_r;
+
+       __mrs_fpcr(__old_r);
+       __new_r = __old_r & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
+       __msr_fpcr(__new_r);
+       return ((__old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+}
+
+static inline int
+fegetexcept(void)
+{
+       fenv_t __r;
+
+       __mrs_fpcr(__r);
+       return ((__r & _ENABLE_MASK) >> _FPUSW_SHIFT);
+}
+
+#endif /* __BSD_VISIBLE */
+
+__END_DECLS
+
+#endif /* !_FENV_H_ */
diff --git a/headers/posix/arch/arm64/signal.h 
b/headers/posix/arch/arm64/signal.h
new file mode 100644
index 0000000000..96bfc51d59
--- /dev/null
+++ b/headers/posix/arch/arm64/signal.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+
+#ifndef _ARCH_SIGNAL_H_
+#define _ARCH_SIGNAL_H_
+
+
+/*
+ * Architecture-specific structure passed to signal handlers
+ */
+
+#if defined(__arm64__)
+struct vregs
+{
+       ulong           x[30];
+       ulong           lr;
+       ulong           sp;
+       ulong           elr;
+       ulong           spsr;
+       __uint128_t     fp_q[32];
+       u_int           fpsr;
+       u_int           fpcr;
+};
+#endif /* defined(__arm64__) */
+
+
+#endif /* _ARCH_SIGNAL_H_ */

############################################################################

Commit:      0689d8ddb87cb3f564c792c6e53c650dfd83b5e9
URL:         https://git.haiku-os.org/haiku/commit/?id=0689d8ddb87c
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Fri Aug  3 00:04:19 2018 UTC

BuildSetup: aarch64 -> arm64.

----------------------------------------------------------------------------

diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup
index a274c48a99..4806ec6a33 100644
--- a/build/jam/BuildSetup
+++ b/build/jam/BuildSetup
@@ -175,7 +175,7 @@ switch $(HOST_GCC_MACHINE) {
        case armv7l-*   : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
        case armv7hl-*  : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
        case armv7b-*   : HAIKU_HOST_IS_BIG_ENDIAN = 1 ;
-       case aarch64-*  : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
+       case arm64-*    : HAIKU_HOST_IS_BIG_ENDIAN = 0 ;
        case m68k-*             : HAIKU_HOST_IS_BIG_ENDIAN = 1 ;
        case *                  : Exit "Unsupported gcc host machine:" 
$(HOST_GCC_MACHINE) ;
 }

############################################################################

Revision:    hrev52162
Commit:      3a72e3ebeeae13395c2172eb2ee9fd93c8509166
URL:         https://git.haiku-os.org/haiku/commit/?id=3a72e3ebeeae
Author:      Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
Date:        Sat Mar 10 12:29:35 2018 UTC
Committer:   Augustin Cavalier <waddlesplash@xxxxxxxxx>
Commit-Date: Fri Aug  3 00:10:13 2018 UTC

ARM64: Add initial kernel headers

Signed-off-by: Augustin Cavalier <waddlesplash@xxxxxxxxx>
aarch64 -> arm64 and coding style fixes by me.

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/arch/arm64/arch_atomic.h 
b/headers/private/kernel/arch/arm64/arch_atomic.h
new file mode 100644
index 0000000000..87132086d1
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_atomic.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_ATOMIC_H_
+#define _KERNEL_ARCH_ARM64_ARCH_ATOMIC_H_
+
+
+static inline void memory_read_barrier_inline(void)
+{
+       __asm__ __volatile__("dmb ishld");
+}
+
+
+static inline void memory_write_barrier_inline(void)
+{
+       __asm__ __volatile__("dsb ishst");
+}
+
+
+static inline void memory_full_barrier_inline(void)
+{
+       __asm__ __volatile__("dsb sy");
+}
+
+
+#define memory_read_barrier memory_read_barrier_inline
+#define memory_write_barrier memory_write_barrier_inline
+#define memory_full_barrier memory_full_barrier_inline
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_ATOMIC_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_cpu.h 
b/headers/private/kernel/arch/arm64/arch_cpu.h
new file mode 100644
index 0000000000..970251c6ba
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_cpu.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_CPU_H_
+#define _KERNEL_ARCH_ARM64_ARCH_CPU_H_
+
+
+#define CPU_MAX_CACHE_LEVEL    8
+#define CACHE_LINE_SIZE                64
+
+#define set_ac()
+#define clear_ac()
+
+#include <kernel/arch/arm64/armreg.h>
+
+#ifndef _ASSEMBLER
+
+#include <arch/arm64/arch_thread_types.h>
+#include <kernel.h>
+
+#define arm64_sev()            __asm__ __volatile__("sev" : : : "memory")
+#define arm64_wfe()            __asm__ __volatile__("wfe" : : : "memory")
+#define arm64_dsb()            __asm__ __volatile__("dsb" : : : "memory")
+#define arm64_dmb()            __asm__ __volatile__("dmb" : : : "memory")
+#define arm64_isb()            __asm__ __volatile__("isb" : : : "memory")
+#define arm64_nop()            __asm__ __volatile__("nop" : : : "memory")
+#define arm64_yield()  __asm__ __volatile__("yield" : : : "memory")
+
+/* Extract CPU affinity levels 0-3 */
+#define        CPU_AFF0(mpidr) (u_int)(((mpidr) >> 0) & 0xff)
+#define        CPU_AFF1(mpidr) (u_int)(((mpidr) >> 8) & 0xff)
+#define        CPU_AFF2(mpidr) (u_int)(((mpidr) >> 16) & 0xff)
+#define        CPU_AFF3(mpidr) (u_int)(((mpidr) >> 32) & 0xff)
+#define        CPU_AFF0_MASK   0xffUL
+#define        CPU_AFF1_MASK   0xff00UL
+#define        CPU_AFF2_MASK   0xff0000UL
+#define        CPU_AFF3_MASK   0xff00000000UL
+#define        CPU_AFF_MASK    (CPU_AFF0_MASK | CPU_AFF1_MASK | \
+    CPU_AFF2_MASK| CPU_AFF3_MASK)      /* Mask affinity fields in MPIDR_EL1 */
+
+
+#define        CPU_IMPL_ARM            0x41
+#define        CPU_IMPL_BROADCOM       0x42
+#define        CPU_IMPL_CAVIUM         0x43
+#define        CPU_IMPL_DEC            0x44
+#define        CPU_IMPL_INFINEON       0x49
+#define        CPU_IMPL_FREESCALE      0x4D
+#define        CPU_IMPL_NVIDIA         0x4E
+#define        CPU_IMPL_APM            0x50
+#define        CPU_IMPL_QUALCOMM       0x51
+#define        CPU_IMPL_MARVELL        0x56
+#define        CPU_IMPL_INTEL          0x69
+
+#define        CPU_PART_THUNDER        0x0A1
+#define        CPU_PART_FOUNDATION     0xD00
+#define        CPU_PART_CORTEX_A35     0xD04
+#define        CPU_PART_CORTEX_A53     0xD03
+#define        CPU_PART_CORTEX_A55     0xD05
+#define        CPU_PART_CORTEX_A57     0xD07
+#define        CPU_PART_CORTEX_A72     0xD08
+#define        CPU_PART_CORTEX_A73     0xD09
+#define        CPU_PART_CORTEX_A75     0xD0A
+
+#define        CPU_REV_THUNDER_1_0     0x00
+#define        CPU_REV_THUNDER_1_1     0x01
+
+#define        CPU_IMPL(midr)  (((midr) >> 24) & 0xff)
+#define        CPU_PART(midr)  (((midr) >> 4) & 0xfff)
+#define        CPU_VAR(midr)   (((midr) >> 20) & 0xf)
+#define        CPU_REV(midr)   (((midr) >> 0) & 0xf)
+
+#define        CPU_IMPL_TO_MIDR(val)   (((val) & 0xff) << 24)
+#define        CPU_PART_TO_MIDR(val)   (((val) & 0xfff) << 4)
+#define        CPU_VAR_TO_MIDR(val)    (((val) & 0xf) << 20)
+#define        CPU_REV_TO_MIDR(val)    (((val) & 0xf) << 0)
+
+#define        CPU_IMPL_MASK   (0xff << 24)
+#define        CPU_PART_MASK   (0xfff << 4)
+#define        CPU_VAR_MASK    (0xf << 20)
+#define        CPU_REV_MASK    (0xf << 0)
+
+#define        CPU_ID_RAW(impl, part, var, rev)                \
+    (CPU_IMPL_TO_MIDR((impl)) |                                \
+    CPU_PART_TO_MIDR((part)) | CPU_VAR_TO_MIDR((var)) |        \
+    CPU_REV_TO_MIDR((rev)))
+
+#define        CPU_MATCH(mask, impl, part, var, rev)           \
+    (((mask) & PCPU_GET(midr)) ==                      \
+    ((mask) & CPU_ID_RAW((impl), (part), (var), (rev))))
+
+#define        CPU_MATCH_RAW(mask, devid)                      \
+    (((mask) & PCPU_GET(midr)) == ((mask) & (devid)))
+
+static inline uint64 arm64_get_cyclecount(void)
+{
+       return READ_SPECIALREG(cntvct_el0);
+}
+
+#define        ADDRESS_TRANSLATE_FUNC(stage)                                   
\
+static inline uint64                                                           
        \
+arm64_address_translate_ ##stage (uint64 addr)         \
+{                                                                              
                                \
+       uint64 ret;                                                             
                        \
+                                                                               
                                \
+       __asm __volatile(                                                       
                \
+           "at " __STRING(stage) ", %1 \n"                                     
\
+           "mrs %0, par_el1" : "=r"(ret) : "r"(addr));         \
+                                                                               
                                \
+       return (ret);                                                           
                \
+}
+
+ADDRESS_TRANSLATE_FUNC(s1e0r)
+ADDRESS_TRANSLATE_FUNC(s1e0w)
+ADDRESS_TRANSLATE_FUNC(s1e1r)
+ADDRESS_TRANSLATE_FUNC(s1e1w)
+
+/* raw exception frames */
+struct iframe {
+       uint64                  sp;
+       uint64                  lr;
+       uint64                  elr;
+       uint32                  spsr;
+       uint32                  esr;
+       uint64                  x[30];
+};
+
+namespace BKernel {
+       struct Thread;
+}  // namespace BKernel
+
+typedef struct arch_cpu_info {
+       uint32                                          mpidr;
+       BKernel::Thread*                        last_vfp_user;
+} arch_cpu_info;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline void arch_cpu_pause(void)
+{
+       arm64_yield();
+}
+
+static inline void arch_cpu_idle(void)
+{
+       arm64_yield();
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_CPU_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_debug.h 
b/headers/private/kernel/arch/arm64/arch_debug.h
new file mode 100644
index 0000000000..db81a7d7a9
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_debug.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_DEBUG_H_
+#define _KERNEL_ARCH_ARM64_ARCH_DEBUG_H_
+
+
+#include <SupportDefs.h>
+
+
+struct arch_debug_registers {
+
+};
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_DEBUG_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_int.h 
b/headers/private/kernel/arch/arm64/arch_int.h
new file mode 100644
index 0000000000..55e1afafd6
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_int.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_INT_H_
+#define _KERNEL_ARCH_ARM64_ARCH_INT_H_
+
+
+#include <SupportDefs.h>
+
+
+#define NUM_IO_VECTORS                 1024
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_INT_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_kernel.h 
b/headers/private/kernel/arch/arm64/arch_kernel.h
new file mode 100644
index 0000000000..9b837f4291
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_kernel.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_KERNEL_H_
+#define _KERNEL_ARCH_ARM64_ARCH_KERNEL_H_
+
+
+#include <kernel/arch/cpu.h>
+
+
+// memory layout
+#define KERNEL_BASE            0xffff000000000000
+#define KERNEL_SIZE            0x8000000000
+#define KERNEL_TOP             (KERNEL_BASE + (KERNEL_SIZE - 1))
+
+#define USER_BASE              0x1000
+#define USER_BASE_ANY  USER_BASE
+#define USER_SIZE              (0x0001000000000000UL - USER_BASE)
+#define USER_TOP               (0x0001000000000000UL - 1)
+
+#define KERNEL_USER_DATA_BASE  0x60000000
+#define USER_STACK_REGION              0x70000000
+#define USER_STACK_REGION_SIZE ((USER_TOP - USER_STACK_REGION) + 1)
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_KERNEL_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_kernel_args.h 
b/headers/private/kernel/arch/arm64/arch_kernel_args.h
new file mode 100644
index 0000000000..66c844465e
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_kernel_args.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_KERNEL_ARGS_H_
+#define _KERNEL_ARCH_ARM64_ARCH_KERNEL_ARGS_H_
+
+
+#ifndef KERNEL_BOOT_KERNEL_ARGS_H
+#      error This file is included from <boot/kernel_args.h> only
+#endif
+
+
+typedef struct {
+       int                     nothing_yet;
+} arch_kernel_args;
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_KERNEL_ARGS_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_system_info.h 
b/headers/private/kernel/arch/arm64/arch_system_info.h
new file mode 100644
index 0000000000..eae77d6429
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_system_info.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_SYSTEM_INFO_H_
+#define _KERNEL_ARCH_ARM64_ARCH_SYSTEM_INFO_H_
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_SYSTEM_INFO_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_thread.h 
b/headers/private/kernel/arch/arm64/arch_thread.h
new file mode 100644
index 0000000000..9022e82599
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_thread.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_THREAD_H_
+#define _KERNEL_ARCH_ARM64_ARCH_THREAD_H_
+
+
+#include <arch/cpu.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+static inline Thread * arch_thread_get_current_thread(void)
+{
+       return (Thread *)READ_SPECIALREG(tpidr_el1);
+}
+
+
+static inline void arch_thread_set_current_thread(Thread *t)
+{
+       WRITE_SPECIALREG(tpidr_el1, t);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_THREAD_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_thread_types.h 
b/headers/private/kernel/arch/arm64/arch_thread_types.h
new file mode 100644
index 0000000000..55785dfd4e
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_thread_types.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_THREAD_TYPES_H_
+#define _KERNEL_ARCH_ARM64_ARCH_THREAD_TYPES_H_
+
+
+#include <kernel.h>
+
+
+struct arch_thread {
+       uint64                  x[31];
+       uint64                  pc;
+       uint64                  sp;
+       uint64                  tpidr_el0;
+       uint64                  tpidrro_el0;
+       int                             last_vfp_cpu;
+};
+
+struct arch_team {
+       int                     dummy;
+};
+
+struct arch_fork_arg {
+       int                     dummy;
+};
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_THREAD_TYPES_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_user_debugger.h 
b/headers/private/kernel/arch/arm64/arch_user_debugger.h
new file mode 100644
index 0000000000..99ce0c6e07
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_user_debugger.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_USER_DEBUGGER_H_
+#define _KERNEL_ARCH_ARM64_ARCH_USER_DEBUGGER_H_
+
+
+struct arch_team_debug_info {
+};
+
+
+struct arch_thread_debug_info {
+};
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_USER_DEBUGGER_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_vm.h 
b/headers/private/kernel/arch/arm64/arch_vm.h
new file mode 100644
index 0000000000..aa0ff1735a
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_vm.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_VM_H_
+#define _KERNEL_ARCH_ARM64_ARCH_VM_H_
+
+
+#define PAGE_SHIFT             12
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_VM_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_vm_translation_map.h 
b/headers/private/kernel/arch/arm64/arch_vm_translation_map.h
new file mode 100644
index 0000000000..7f002eeb8f
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_vm_translation_map.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_VM_TRANSLATION_MAP_H_
+#define _KERNEL_ARCH_ARM64_ARCH_VM_TRANSLATION_MAP_H_
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_VM_TRANSLATION_MAP_H_ */
diff --git a/headers/private/kernel/arch/arm64/arch_vm_types.h 
b/headers/private/kernel/arch/arm64/arch_vm_types.h
new file mode 100644
index 0000000000..c2e3c9e071
--- /dev/null
+++ b/headers/private/kernel/arch/arm64/arch_vm_types.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright 2018, Jaroslaw Pelczar <jarek@xxxxxxxxxxxx>
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _KERNEL_ARCH_ARM64_ARCH_VM_TYPES_H_
+#define _KERNEL_ARCH_ARM64_ARCH_VM_TYPES_H_
+
+
+#endif /* _KERNEL_ARCH_ARM64_ARCH_VM_TYPES_H_ */


Other related posts:

  • » [haiku-commits] haiku: hrev52162 - in headers: private/kernel/arch/arm64 posix/arch/arm64 - waddlesplash