1294227Sbr/*-
2294227Sbr * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
3294227Sbr * All rights reserved.
4294227Sbr *
5294227Sbr * Portions of this software were developed by SRI International and the
6294227Sbr * University of Cambridge Computer Laboratory under DARPA/AFRL contract
7294227Sbr * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
8294227Sbr *
9294227Sbr * Portions of this software were developed by the University of Cambridge
10294227Sbr * Computer Laboratory as part of the CTSRD Project, with support from the
11294227Sbr * UK Higher Education Innovation Fund (HEIF).
12294227Sbr *
13294227Sbr * Redistribution and use in source and binary forms, with or without
14294227Sbr * modification, are permitted provided that the following conditions
15294227Sbr * are met:
16294227Sbr * 1. Redistributions of source code must retain the above copyright
17294227Sbr *    notice, this list of conditions and the following disclaimer.
18294227Sbr * 2. Redistributions in binary form must reproduce the above copyright
19294227Sbr *    notice, this list of conditions and the following disclaimer in the
20294227Sbr *    documentation and/or other materials provided with the distribution.
21294227Sbr *
22294227Sbr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23294227Sbr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24294227Sbr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25294227Sbr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26294227Sbr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27294227Sbr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28294227Sbr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29294227Sbr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30294227Sbr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31294227Sbr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32294227Sbr * SUCH DAMAGE.
33294227Sbr */
34294227Sbr
35294227Sbr#include <sys/cdefs.h>
36294227Sbr__FBSDID("$FreeBSD: releng/11.0/lib/libc/riscv/gen/_set_tp.c 294227 2016-01-17 15:21:23Z br $");
37294227Sbr
38294227Sbr#include <string.h>
39294227Sbr#include <sys/types.h>
40294227Sbr
41294227Sbr#include <machine/sysarch.h>
42294227Sbr
43294227Sbr#include <stdlib.h>
44294227Sbr
45294227Sbrvoid
46294227Sbr_set_tp(void *tp)
47294227Sbr{
48294227Sbr
49294227Sbr	__asm __volatile("mv  tp, %0" :: "r"((char*)tp + 0x10));
50294227Sbr}
51