190075Sobrien/*-
290075Sobrien * SPDX-License-Identifier: BSD-2-Clause
3132718Skan *
490075Sobrien * Copyright (c) 2005 David Xu <davidxu@freebsd.org>.
590075Sobrien * All rights reserved.
690075Sobrien *
790075Sobrien * Redistribution and use in source and binary forms, with or without
890075Sobrien * modification, are permitted provided that the following conditions
990075Sobrien * are met:
1090075Sobrien *
1190075Sobrien * 1. Redistributions of source code must retain the above copyright
1290075Sobrien *    notice, this list of conditions and the following disclaimer.
1390075Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1490075Sobrien *    notice, this list of conditions and the following disclaimer in the
1590075Sobrien *    documentation and/or other materials provided with the distribution.
1690075Sobrien *
1790075Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1890075Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1990075Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2090075Sobrien * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21169689Skan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22169689Skan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2390075Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2490075Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2590075Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26132718Skan * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27132718Skan */
2890075Sobrien
2990075Sobrien#ifndef _MACHINE_TLS_H_
3090075Sobrien#define	_MACHINE_TLS_H_
3190075Sobrien
3290075Sobrien#include <sys/_tls_variant_i.h>
3390075Sobrien#include <machine/sysarch.h>
3490075Sobrien
3590075Sobrien#define	TLS_DTV_OFFSET	0
3690075Sobrien#define	TLS_TCB_ALIGN	8
3790075Sobrien#define	TLS_TP_OFFSET	0
3890075Sobrien
3990075Sobrienstatic __inline void
4090075Sobrien_tcb_set(struct tcb *tcb)
41132718Skan{
4290075Sobrien	sysarch(ARM_SET_TP, tcb);
43132718Skan}
44169689Skan
4590075Sobrienstatic __inline struct tcb *
4690075Sobrien_tcb_get(void)
4790075Sobrien{
4890075Sobrien	struct tcb *tcb;
49169689Skan
50169689Skan	__asm __volatile("mrc  p15, 0, %0, c13, c0, 3"		\
51169689Skan	   		 : "=r" (tcb));
52169689Skan	return (tcb);
53169689Skan}
54169689Skan
55169689Skan#endif /* !_MACHINE_TLS_H_ */
56169689Skan