1/* Copyright (C) 2005-2021 Free Software Foundation, Inc.
2   This file is part of the GNU C Library.
3
4   The GNU C Library is free software; you can redistribute it and/or
5   modify it under the terms of the GNU Lesser General Public
6   License as published by the Free Software Foundation; either
7   version 2.1 of the License, or (at your option) any later version.
8
9   In addition to the permissions in the GNU Lesser General Public
10   License, the Free Software Foundation gives you unlimited
11   permission to link the compiled version of this file with other
12   programs, and to distribute those programs without any restriction
13   coming from the use of this file. (The GNU Lesser General Public
14   License restrictions do apply in other respects; for example, they
15   cover modification of the file, and distribution when not linked
16   into another program.)
17
18   Note that people who make modified versions of this file are not
19   obligated to grant this special exception for their modified
20   versions; it is their choice whether to do so. The GNU Lesser
21   General Public License gives permission to release a modified
22   version without this exception; this exception also makes it
23   possible to release a modified version which carries forward this
24   exception.
25
26   The GNU C Library is distributed in the hope that it will be useful,
27   but WITHOUT ANY WARRANTY; without even the implied warranty of
28   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29   Lesser General Public License for more details.
30
31   You should have received a copy of the GNU Lesser General Public
32   License along with the GNU C Library.  If not, see
33   <https://www.gnu.org/licenses/>.  */
34
35#include <sysdep.h>
36
37/* GCC will emit calls to this routine under -mtp=soft.  Linux has an
38   equivalent helper function (which clobbers fewer registers than
39   a normal function call) in a high page of memory; tail call to the
40   helper.  */
41
42	.hidden __aeabi_read_tp
43ENTRY (__aeabi_read_tp)
44#ifdef ARCH_HAS_HARD_TP
45	mrc	p15, 0, r0, c13, c0, 3
46	bx	lr
47#elif defined(__thumb2__)
48	movw	r0, #0x0fe0
49	movt	r0, #0xffff
50	bx	r0
51#else
52	mov	r0, #0xffff0fff
53	sub	pc, r0, #31
54#endif
55END (__aeabi_read_tp)
56