Index: uspace/lib/c/arch/arm64/Makefile.common
===================================================================
--- uspace/lib/c/arch/arm64/Makefile.common	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/Makefile.common	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2015 Petr Pavlu
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+COMMON_CFLAGS += -fno-omit-frame-pointer
+
+LDFLAGS += -Wl,--gc-sections
+
+ENDIANESS = LE
+
+BFD_NAME = elf64-littleaarch64
+BFD_ARCH = aarch64
Index: uspace/lib/c/arch/arm64/Makefile.inc
===================================================================
--- uspace/lib/c/arch/arm64/Makefile.inc	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/Makefile.inc	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2015 Petr Pavlu
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES = \
+	arch/$(UARCH)/src/entryjmp.S \
+	arch/$(UARCH)/src/fibril.S \
+	arch/$(UARCH)/src/stacktrace.c \
+	arch/$(UARCH)/src/stacktrace_asm.S \
+	arch/$(UARCH)/src/syscall.c \
+	arch/$(UARCH)/src/tls.c \
+	arch/$(UARCH)/src/thread_entry.S
+
+ARCH_AUTOCHECK_HEADERS = \
+	arch/$(UARCH)/include/libarch/fibril_context.h
Index: uspace/lib/c/arch/arm64/include/libarch/config.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/config.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/config.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file
+ * @brief Configuration constants.
+ */
+
+#ifndef _LIBC_arm64_CONFIG_H_
+#define _LIBC_arm64_CONFIG_H_
+
+#define PAGE_WIDTH  12
+#define PAGE_SIZE   (1 << PAGE_WIDTH)
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/include/libarch/ddi.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/ddi.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/ddi.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file
+ * @brief
+ */
+
+#ifndef _LIBC_arm64_DDI_H_
+#define _LIBC_arm64_DDI_H_
+
+#include <ddi.h>
+
+static inline void arch_pio_write_8(ioport8_t *port, uint8_t v)
+{
+	*port = v;
+}
+
+static inline void arch_pio_write_16(ioport16_t *port, uint16_t v)
+{
+	*port = v;
+}
+
+static inline void arch_pio_write_32(ioport32_t *port, uint32_t v)
+{
+	*port = v;
+}
+
+static inline void arch_pio_write_64(ioport64_t *port, uint64_t v)
+{
+	*port = v;
+}
+
+static inline uint8_t arch_pio_read_8(const ioport8_t *port)
+{
+	return *port;
+}
+
+static inline uint16_t arch_pio_read_16(const ioport16_t *port)
+{
+	return *port;
+}
+
+static inline uint32_t arch_pio_read_32(const ioport32_t *port)
+{
+	return *port;
+}
+
+static inline uint64_t arch_pio_read_64(const ioport64_t *port)
+{
+	return *port;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/include/libarch/elf_linux.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/elf_linux.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/elf_linux.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file Definitions needed to write core files in Linux-ELF format.
+ */
+
+#ifndef _LIBC_arm64_ELF_LINUX_H_
+#define _LIBC_arm64_ELF_LINUX_H_
+
+#include <libarch/istate.h>
+#include <stdint.h>
+
+/** Linux kernel struct pt_regs structure.
+ *
+ * We need this to save register state to a core file in Linux format
+ * (readable by GDB configured for Linux target).
+ */
+typedef struct {
+	uint64_t x0;
+	uint64_t x1;
+	uint64_t x2;
+	uint64_t x3;
+	uint64_t x4;
+	uint64_t x5;
+	uint64_t x6;
+	uint64_t x7;
+	uint64_t x8;
+	uint64_t x9;
+	uint64_t x10;
+	uint64_t x11;
+	uint64_t x12;
+	uint64_t x13;
+	uint64_t x14;
+	uint64_t x15;
+	uint64_t x16;
+	uint64_t x17;
+	uint64_t x18;
+	uint64_t x19;
+	uint64_t x20;
+	uint64_t x21;
+	uint64_t x22;
+	uint64_t x23;
+	uint64_t x24;
+	uint64_t x25;
+	uint64_t x26;
+	uint64_t x27;
+	uint64_t x28;
+	uint64_t x29;
+	uint64_t x30;
+
+	uint64_t sp;
+	uint64_t pc;
+	uint64_t pstate;
+
+	uint64_t orig_x0;
+	uint64_t syscallno;
+} elf_regs_t;
+
+/** Convert istate_t to elf_regs_t. */
+static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs)
+{
+	elf_regs->x0 = istate->x0;
+	elf_regs->x1 = istate->x1;
+	elf_regs->x2 = istate->x2;
+	elf_regs->x3 = istate->x3;
+	elf_regs->x4 = istate->x4;
+	elf_regs->x5 = istate->x5;
+	elf_regs->x6 = istate->x6;
+	elf_regs->x7 = istate->x7;
+	elf_regs->x8 = istate->x8;
+	elf_regs->x9 = istate->x9;
+	elf_regs->x10 = istate->x10;
+	elf_regs->x11 = istate->x11;
+	elf_regs->x12 = istate->x12;
+	elf_regs->x13 = istate->x13;
+	elf_regs->x14 = istate->x14;
+	elf_regs->x15 = istate->x15;
+	elf_regs->x16 = istate->x16;
+	elf_regs->x17 = istate->x17;
+	elf_regs->x18 = istate->x18;
+	elf_regs->x19 = istate->x19;
+	elf_regs->x20 = istate->x20;
+	elf_regs->x21 = istate->x21;
+	elf_regs->x22 = istate->x22;
+	elf_regs->x23 = istate->x23;
+	elf_regs->x24 = istate->x24;
+	elf_regs->x25 = istate->x25;
+	elf_regs->x26 = istate->x26;
+	elf_regs->x27 = istate->x27;
+	elf_regs->x28 = istate->x28;
+	elf_regs->x29 = istate->x29;
+	elf_regs->x30 = istate->x30;
+
+	elf_regs->sp = istate->sp;
+	elf_regs->pc = istate->pc;
+	elf_regs->pstate = istate->spsr;
+
+	elf_regs->orig_x0 = 0;
+	elf_regs->syscallno = 0;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/include/libarch/faddr.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/faddr.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/faddr.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file
+ * @brief Function address conversion.
+ */
+
+#ifndef _LIBC_arm64_FADDR_H_
+#define _LIBC_arm64_FADDR_H_
+
+#include <types/common.h>
+
+/** Calculate absolute address of function referenced by fptr pointer.
+ *
+ * @param f Function pointer.
+ */
+#define FADDR(f)  ((uintptr_t) (f))
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/include/libarch/fibril.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/fibril.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/fibril.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file
+ * @brief Fibrils related declarations.
+ */
+
+#ifndef _LIBC_arm64_FIBRIL_H_
+#define _LIBC_arm64_FIBRIL_H_
+
+#include <types/common.h>
+#include <align.h>
+#include <libarch/fibril_context.h>
+
+/** Size of a stack item. */
+#define STACK_ITEM_SIZE	 8
+
+/** Required stack alignment. */
+#define STACK_ALIGNMENT	 16
+
+#define SP_DELTA  (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
+
+/** Sets data to the context.
+ *
+ * @param c Context (#context_t).
+ * @param _pc Program counter.
+ * @param stack Stack address.
+ * @param size Stack size.
+ * @param ptls Pointer to the TCB.
+ */
+#define context_set(c, _pc, stack, size, ptls) \
+	do { \
+		(c)->pc = (uint64_t) (_pc); \
+		(c)->sp = ((uint64_t) (stack)) + (size) - SP_DELTA; \
+		(c)->tls = ((uint64_t) (ptls)) + ARCH_TP_OFFSET; \
+		/* Set frame pointer too. */ \
+		(c)->x29 = 0; \
+	} while (0)
+
+static inline uintptr_t _context_get_fp(context_t *ctx)
+{
+	return ctx->x29;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/include/libarch/fibril_context.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/fibril_context.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/fibril_context.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+#ifndef _LIBC_ARCH_FIBRIL_CONTEXT_H_
+#define _LIBC_ARCH_FIBRIL_CONTEXT_H_
+
+#define __CONTEXT_OFFSET_SP     0x00
+#define __CONTEXT_OFFSET_PC     0x08
+#define __CONTEXT_OFFSET_X19    0x10
+#define __CONTEXT_OFFSET_X20    0x18
+#define __CONTEXT_OFFSET_X21    0x20
+#define __CONTEXT_OFFSET_X22    0x28
+#define __CONTEXT_OFFSET_X23    0x30
+#define __CONTEXT_OFFSET_X24    0x38
+#define __CONTEXT_OFFSET_X25    0x40
+#define __CONTEXT_OFFSET_X26    0x48
+#define __CONTEXT_OFFSET_X27    0x50
+#define __CONTEXT_OFFSET_X28    0x58
+#define __CONTEXT_OFFSET_X29    0x60
+#define __CONTEXT_OFFSET_TLS    0x68
+#define __CONTEXT_OFFSET_VREGS  0x70
+#define __CONTEXT_SIZE          0xb0
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+typedef struct __context {
+	uint64_t sp;
+	uint64_t pc;
+	uint64_t x19;
+	uint64_t x20;
+	uint64_t x21;
+	uint64_t x22;
+	uint64_t x23;
+	uint64_t x24;
+	uint64_t x25;
+	uint64_t x26;
+	uint64_t x27;
+	uint64_t x28;
+	uint64_t x29;
+	uint64_t tls;
+	/* v8-v15, low 64 bits only. */
+	uint64_t vregs[8];
+} __context_t;
+
+#endif
+#endif
Index: uspace/lib/c/arch/arm64/include/libarch/istate.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/istate.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/istate.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/arm64/include/arch/istate.h
Index: uspace/lib/c/arch/arm64/include/libarch/istate_struct.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/istate_struct.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/istate_struct.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/arm64/include/arch/istate_struct.h
Index: uspace/lib/c/arch/arm64/include/libarch/regutils.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/regutils.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/regutils.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,1 @@
+../../../../../../../kernel/arch/arm64/include/arch/regutils.h
Index: uspace/lib/c/arch/arm64/include/libarch/syscall.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/syscall.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/syscall.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file
+ * @brief
+ */
+
+#ifndef _LIBC_arm64_SYSCALL_H_
+#define _LIBC_arm64_SYSCALL_H_
+
+#define LIBARCH_SYSCALL_GENERIC
+
+#include <syscall.h>
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/include/libarch/thread.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/thread.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/thread.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBC_arm64_THREAD_H_
+#define _LIBC_arm64_THREAD_H_
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/include/libarch/tls.h
===================================================================
--- uspace/lib/c/arch/arm64/include/libarch/tls.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/include/libarch/tls.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file
+ * @brief Thread-local storage.
+ */
+
+#ifndef _LIBC_arm64_TLS_H_
+#define _LIBC_arm64_TLS_H_
+
+#define CONFIG_TLS_VARIANT_1
+
+/** Offsets for accessing thread-local variables are shifted 16 bytes higher. */
+#define ARCH_TP_OFFSET  (sizeof(tcb_t) - 16)
+
+/** TCB (Thread Control Block) struct.
+ *
+ * TLS starts just after this struct.
+ */
+typedef struct {
+	/** Fibril data. */
+	void *fibril_data;
+} tcb_t;
+
+static inline void __tcb_raw_set(void *tls)
+{
+	asm volatile ("msr tpidr_el0, %[tls]" : : [tls] "r" (tls));
+}
+
+static inline void *__tcb_raw_get(void)
+{
+	void *retval;
+	asm volatile ("mrs %[tls], tpidr_el0" : [tls] "=r" (retval));
+	return retval;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/src/entry.S
===================================================================
--- uspace/lib/c/arch/arm64/src/entry.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/src/entry.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,48 @@
+#
+# Copyright (c) 2015 Petr Pavlu
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <abi/asmtool.h>
+
+.text
+
+.org 0
+
+## User-space task entry point
+#
+# x0 contains the PCB pointer
+#
+SYMBOL(_start)
+	#
+	# Create the first stack frame.
+	#
+	mov x29, #0
+	stp x29, x30, [sp, #-16]!
+	mov x29, sp
+
+	# Pass pcb_ptr to __c_start as the first argument (in x0)
+	bl __c_start
Index: uspace/lib/c/arch/arm64/src/entryjmp.S
===================================================================
--- uspace/lib/c/arch/arm64/src/entryjmp.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/src/entryjmp.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2015 Petr Pavlu
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <abi/asmtool.h>
+
+## void entry_point_jmp(void *entry_point, void *pcb);
+#
+# x0	contains entry_point
+# x1	contains pcb
+#
+# Jump to program entry point
+SYMBOL(entry_point_jmp)
+	# Pass PCB in x0 to the entry point and jump to it.
+	mov x2, x0
+	mov x0, x1
+	br x2
Index: uspace/lib/c/arch/arm64/src/fibril.S
===================================================================
--- uspace/lib/c/arch/arm64/src/fibril.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/src/fibril.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+#include <abi/asmtool.h>
+#include <libarch/fibril_context.h>
+
+.text
+
+/* Static checks for the context_t save/load. */
+#if __CONTEXT_OFFSET_SP + 8 != __CONTEXT_OFFSET_PC
+#error sp and pc are not successive in context_t
+#endif
+#if __CONTEXT_OFFSET_X19 + 8 != __CONTEXT_OFFSET_X20
+#error x19 and x20 are not successive in context_t
+#endif
+#if __CONTEXT_OFFSET_X21 + 8 != __CONTEXT_OFFSET_X22
+#error x21 and x22 are not successive in context_t
+#endif
+#if __CONTEXT_OFFSET_X23 + 8 != __CONTEXT_OFFSET_X24
+#error x23 and x24 are not successive in context_t
+#endif
+#if __CONTEXT_OFFSET_X25 + 8 != __CONTEXT_OFFSET_X26
+#error x25 and x26 are not successive in context_t
+#endif
+#if __CONTEXT_OFFSET_X27 + 8 != __CONTEXT_OFFSET_X28
+#error x27 and x28 are not successive in context_t
+#endif
+#if __CONTEXT_OFFSET_X29 + 8 != __CONTEXT_OFFSET_TLS
+#error x29 and tls are not successive in context_t
+#endif
+
+FUNCTION_BEGIN(__context_save)
+	/* Save callee-saved registers into context_t pointed by x0. */
+	mov x1, sp
+	stp x1, x30, [x0, #__CONTEXT_OFFSET_SP]
+	stp x19, x20, [x0, #__CONTEXT_OFFSET_X19]
+	stp x21, x22, [x0, #__CONTEXT_OFFSET_X21]
+	stp x23, x24, [x0, #__CONTEXT_OFFSET_X23]
+	stp x25, x26, [x0, #__CONTEXT_OFFSET_X25]
+	stp x27, x28, [x0, #__CONTEXT_OFFSET_X27]
+	/* Save the last general-purpose register and TLS. */
+	mrs x1, tpidr_el0
+	stp x29, x1, [x0, #__CONTEXT_OFFSET_X29]
+	/* Save low 64 bits of v8-v15. */
+	stp d8, d9, [x0, #__CONTEXT_OFFSET_VREGS + 8 * 0]
+	stp d10, d11, [x0, #__CONTEXT_OFFSET_VREGS + 8 * 2]
+	stp d12, d13, [x0, #__CONTEXT_OFFSET_VREGS + 8 * 4]
+	stp d14, d15, [x0, #__CONTEXT_OFFSET_VREGS + 8 * 6]
+
+	/* Return 0. */
+	mov x0, #0
+	ret
+FUNCTION_END(__context_save)
+
+FUNCTION_BEGIN(__context_restore)
+	/* Restore callee-saved registers from context_t pointed by x0. */
+	ldp x2, x30, [x0, #__CONTEXT_OFFSET_SP]
+	mov sp, x2
+	ldp x19, x20, [x0, #__CONTEXT_OFFSET_X19]
+	ldp x21, x22, [x0, #__CONTEXT_OFFSET_X21]
+	ldp x23, x24, [x0, #__CONTEXT_OFFSET_X23]
+	ldp x25, x26, [x0, #__CONTEXT_OFFSET_X25]
+	ldp x27, x28, [x0, #__CONTEXT_OFFSET_X27]
+	/* Restore the last general-purpose register and TLS. */
+	ldp x29, x2, [x0, #__CONTEXT_OFFSET_X29]
+	msr tpidr_el0, x2
+	/* Restore low 64 bits of v8-v15. */
+	ldp d8, d9, [x0, #__CONTEXT_OFFSET_VREGS + 8 * 0]
+	ldp d10, d11, [x0, #__CONTEXT_OFFSET_VREGS + 8 * 2]
+	ldp d12, d13, [x0, #__CONTEXT_OFFSET_VREGS + 8 * 4]
+	ldp d14, d15, [x0, #__CONTEXT_OFFSET_VREGS + 8 * 6]
+
+	/* Return the second argument. */
+	mov x0, x1
+	ret
+FUNCTION_END(__context_restore)
Index: uspace/lib/c/arch/arm64/src/stacktrace.c
===================================================================
--- uspace/lib/c/arch/arm64/src/stacktrace.c	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/src/stacktrace.c	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file
+ * @brief
+ */
+
+#include <stacktrace.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#define FRAME_OFFSET_FP_PREV  0
+#define FRAME_OFFSET_RA       8
+
+bool stacktrace_fp_valid(stacktrace_t *st __attribute__((unused)),
+    uintptr_t fp)
+{
+	return fp != 0;
+}
+
+errno_t stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
+{
+	return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV,
+	    prev);
+}
+
+errno_t stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
+{
+	return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
+}
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/src/stacktrace_asm.S
===================================================================
--- uspace/lib/c/arch/arm64/src/stacktrace_asm.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/src/stacktrace_asm.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,45 @@
+#
+# Copyright (c) 2015 Petr Pavlu
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <abi/asmtool.h>
+
+.text
+
+FUNCTION_BEGIN(stacktrace_prepare)
+	ret
+FUNCTION_END(stacktrace_prepare)
+
+FUNCTION_BEGIN(stacktrace_fp_get)
+	mov x0, x29
+	ret
+FUNCTION_END(stacktrace_fp_get)
+
+FUNCTION_BEGIN(stacktrace_pc_get)
+	mov x0, x30
+	ret
+FUNCTION_END(stacktrace_pc_get)
Index: uspace/lib/c/arch/arm64/src/syscall.c
===================================================================
--- uspace/lib/c/arch/arm64/src/syscall.c	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/src/syscall.c	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ * @{
+ */
+/** @file
+ * @brief Syscall routine.
+ */
+
+#include <libc.h>
+
+/** Syscall routine.
+ *
+ * Stores p1-p6, id to r0-r6 registers and calls <code>svc</code> instruction.
+ * Returned value is read from r0 register.
+ *
+ * @param p1 Parameter 1.
+ * @param p2 Parameter 2.
+ * @param p3 Parameter 3.
+ * @param p4 Parameter 4.
+ * @param p5 Parameter 5.
+ * @param p6 Parameter 6.
+ * @param id Number of syscall.
+ *
+ * @return Syscall return value.
+ */
+sysarg_t __syscall(const sysarg_t p1, const sysarg_t p2, const sysarg_t p3,
+    const sysarg_t p4, const sysarg_t p5, const sysarg_t p6,
+    const syscall_t id)
+{
+	register sysarg_t __arm_reg_x0 asm("x0") = p1;
+	register sysarg_t __arm_reg_x1 asm("x1") = p2;
+	register sysarg_t __arm_reg_x2 asm("x2") = p3;
+	register sysarg_t __arm_reg_x3 asm("x3") = p4;
+	register sysarg_t __arm_reg_x4 asm("x4") = p5;
+	register sysarg_t __arm_reg_x5 asm("x5") = p6;
+	register sysarg_t __arm_reg_x6 asm("x6") = id;
+
+	asm volatile (
+	    "svc #0"
+	    : "=r" (__arm_reg_x0)
+	    : "r" (__arm_reg_x0),
+	      "r" (__arm_reg_x1),
+	      "r" (__arm_reg_x2),
+	      "r" (__arm_reg_x3),
+	      "r" (__arm_reg_x4),
+	      "r" (__arm_reg_x5),
+	      "r" (__arm_reg_x6)
+	    :
+	      /*
+	       * Clobber memory too as some arguments might be actually
+	       * pointers.
+	       */
+	      "memory"
+	);
+
+	return __arm_reg_x0;
+}
+
+/** @}
+ */
Index: uspace/lib/c/arch/arm64/src/thread_entry.S
===================================================================
--- uspace/lib/c/arch/arm64/src/thread_entry.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/src/thread_entry.S	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 2015 Petr Pavlu
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <abi/asmtool.h>
+
+.text
+
+## User-space thread entry point for all but the first thread.
+#
+#
+SYMBOL(__thread_entry)
+	#
+	# Create the first stack frame.
+	#
+	mov x29, #0
+	stp x29, x30, [sp, #-16]!
+	mov x29, sp
+
+	b __thread_main
Index: uspace/lib/c/arch/arm64/src/tls.c
===================================================================
--- uspace/lib/c/arch/arm64/src/tls.c	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
+++ uspace/lib/c/arch/arm64/src/tls.c	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 Petr Pavlu
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libcarm64
+ */
+/** @file
+ * @brief Thread-local storage.
+ */
+
+#include <tls.h>
+#include <stddef.h>
+
+tcb_t *tls_alloc_arch(size_t size, size_t align)
+{
+	return tls_alloc_variant_1(size, align);
+}
+
+void tls_free_arch(tcb_t *tcb, size_t size, size_t align)
+{
+	tls_free_variant_1(tcb, size, align);
+}
+
+/** @}
+ */
Index: uspace/lib/c/doc/doxygroups.h
===================================================================
--- uspace/lib/c/doc/doxygroups.h	(revision b58728fdc037c108b8477d42b1a79dc3748c5e4d)
+++ uspace/lib/c/doc/doxygroups.h	(revision b63f4e8923acb50eeb87d363e82f2908a460b2a9)
@@ -17,4 +17,9 @@
 /**
  * @addtogroup libcarm32 arm32
+ * @ingroup libc
+ */
+
+/**
+ * @addtogroup libcarm64 arm64
  * @ingroup libc
  */
