1 /**
2 * \file
3 * \brief UTCB definitions for ARM64.
4 * \ingroup l4_utcb_api
5 */
6 /*
7 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8 * Alexander Warg <warg@os.inf.tu-dresden.de>
9 * economic rights: Technische Universität Dresden (Germany)
10 *
11 * This file is part of TUD:OS and distributed under the terms of the
12 * GNU General Public License 2.
13 * Please see the COPYING-GPL-2 file for details.
14 *
15 * As a special exception, you may use this file as part of a free software
16 * library without restriction. Specifically, if other files instantiate
17 * templates or use macros or inline functions from this file, or you compile
18 * this file and link it with other files to produce an executable, this
19 * file does not by itself cause the resulting executable to be covered by
20 * the GNU General Public License. This exception does not however
21 * invalidate any other reasons why the executable file might be covered by
22 * the GNU General Public License.
23 */
24 #ifndef __L4_SYS__INCLUDE__ARCH_ARM64__UTCB_H__
25 #define __L4_SYS__INCLUDE__ARCH_ARM64__UTCB_H__
26
27 #include <l4/sys/types.h>
28
29 /**
30 * \defgroup l4_utcb_api_arm64 ARM64 Virtual Registers (UTCB)
31 * \ingroup l4_utcb_api
32 */
33
34 /**
35 * \brief UTCB structure for exceptions.
36 * \ingroup l4_utcb_api_arm64
37 */
38 typedef struct l4_exc_regs_t
39 {
40 l4_umword_t eret_work;
41 l4_umword_t r[31];
42 l4_umword_t reserved;
43 l4_umword_t err;
44
45 l4_umword_t pfa;
46 l4_umword_t sp;
47 union { l4_umword_t ip; l4_umword_t pc; }; /* aliases for PC */
48 union { l4_umword_t flags; l4_umword_t pstate; }; /* aliases for PSTATE (PSR) */
49 l4_umword_t tpidruro;
50 } l4_exc_regs_t;
51
52 /**
53 * \brief UTCB constants for ARM64
54 * \ingroup l4_utcb_api_arm64
55 * \hideinitializer
56 */
57 enum L4_utcb_consts_arm64
58 {
59 L4_UTCB_EXCEPTION_REGS_SIZE = sizeof(l4_exc_regs_t) / sizeof(l4_umword_t),
60 L4_UTCB_GENERIC_DATA_SIZE = 63,
61 L4_UTCB_GENERIC_BUFFERS_SIZE = 58,
62
63 L4_UTCB_MSG_REGS_OFFSET = 0,
64 L4_UTCB_BUF_REGS_OFFSET = 64 * sizeof(l4_umword_t),
65 L4_UTCB_THREAD_REGS_OFFSET = 123 * sizeof(l4_umword_t),
66
67 L4_UTCB_INHERIT_FPU = 1UL << 24,
68
69 L4_UTCB_OFFSET = 1024,
70 };
71
72 #include_next <l4/sys/utcb.h>
73
74 /*
75 * ==================================================================
76 * Implementations.
77 */
78
79 #ifdef __GNUC__
l4_utcb_direct(void)80 L4_INLINE l4_utcb_t *l4_utcb_direct(void) L4_NOTHROW
81 {
82 l4_utcb_t *utcb;
83 __asm__ ("mrs %0, TPIDRRO_EL0" : "=r" (utcb));
84 return utcb;
85 }
86 #endif
87
l4_utcb_exc_pc(l4_exc_regs_t const * u)88 L4_INLINE l4_umword_t l4_utcb_exc_pc(l4_exc_regs_t const *u) L4_NOTHROW
89 {
90 return u->pc;
91 }
92
l4_utcb_exc_pc_set(l4_exc_regs_t * u,l4_addr_t pc)93 L4_INLINE void l4_utcb_exc_pc_set(l4_exc_regs_t *u, l4_addr_t pc) L4_NOTHROW
94 {
95 u->pc = pc;
96 }
97
l4_utcb_exc_typeval(l4_exc_regs_t const * u)98 L4_INLINE l4_umword_t l4_utcb_exc_typeval(l4_exc_regs_t const *u) L4_NOTHROW
99 {
100 return u->err >> 26;
101 }
102
l4_utcb_exc_is_pf(l4_exc_regs_t const * u)103 L4_INLINE int l4_utcb_exc_is_pf(l4_exc_regs_t const *u) L4_NOTHROW
104 {
105 return ((u->err >> 26) & 0x30) == 0x20;
106 }
107
l4_utcb_exc_pfa(l4_exc_regs_t const * u)108 L4_INLINE l4_addr_t l4_utcb_exc_pfa(l4_exc_regs_t const *u) L4_NOTHROW
109 {
110 return (u->pfa & ~7UL) | ((u->err >> 5) & 2);
111 }
112
l4_utcb_exc_is_ex_regs_exception(l4_exc_regs_t const * u)113 L4_INLINE int l4_utcb_exc_is_ex_regs_exception(l4_exc_regs_t const *u) L4_NOTHROW
114 {
115 return (u->err >> 26) == 0x3e;
116 }
117
118 #endif /* ! __L4_SYS__INCLUDE__ARCH_ARM64__UTCB_H__ */
119