diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2021-04-05 03:30:35 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2021-04-23 11:14:07 +0000 |
commit | 41331ef7f618e15732b84f960cc236e70e38e253 (patch) | |
tree | dd9234fd0a1dd20fc835a548553304749a2c5f11 /lib/libc/arm/gen | |
parent | 4bcc2e90a09330711bcc32f1f6d100c5d7989152 (diff) |
libc: add _get_tp() private function
(cherry picked from commit 06d8a116bd6b6f70b8aedc6a6a2c4085c53f63ac)
Diffstat (limited to 'lib/libc/arm/gen')
-rw-r--r-- | lib/libc/arm/gen/Makefile.inc | 1 | ||||
-rw-r--r-- | lib/libc/arm/gen/_get_tp.c | 51 |
2 files changed, 52 insertions, 0 deletions
diff --git a/lib/libc/arm/gen/Makefile.inc b/lib/libc/arm/gen/Makefile.inc index 6cc9b69d2b0e..35aa465e4904 100644 --- a/lib/libc/arm/gen/Makefile.inc +++ b/lib/libc/arm/gen/Makefile.inc @@ -4,6 +4,7 @@ SRCS+= \ __aeabi_read_tp.S \ _ctx_start.S \ + _get_tp.c \ _set_tp.c \ _setjmp.S \ alloca.S \ diff --git a/lib/libc/arm/gen/_get_tp.c b/lib/libc/arm/gen/_get_tp.c new file mode 100644 index 000000000000..7e0285f7d6f2 --- /dev/null +++ b/lib/libc/arm/gen/_get_tp.c @@ -0,0 +1,51 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <string.h> +#include <stdint.h> +#include <machine/sysarch.h> +#include "libc_private.h" + +void * +_get_tp(void) +{ + void *res; + +#ifdef ARM_TP_ADDRESS + res = (void *)ARM_TP_ADDRESS +#else + __asm __volatile("mrc p15, 0, %0, c13, c0, 3" : "=r" (res)); +#endif + return (res); +} |