xref: /freebsd/sys/arm64/include/tls.h (revision d5d97bed4ab6bb63e97c8ff67b5b94ae37cd24fc)
11a62e9bcSJohn Baldwin /*-
21a62e9bcSJohn Baldwin  * Copyright (c) 2005 David Xu <davidxu@freebsd.org>.
31a62e9bcSJohn Baldwin  * Copyright (c) 2014 the FreeBSD Foundation
41a62e9bcSJohn Baldwin  * All rights reserved.
51a62e9bcSJohn Baldwin  *
61a62e9bcSJohn Baldwin  * Portions of this software were developed by Andrew Turner
71a62e9bcSJohn Baldwin  * under sponsorship from the FreeBSD Foundation
81a62e9bcSJohn Baldwin  *
91a62e9bcSJohn Baldwin  * Redistribution and use in source and binary forms, with or without
101a62e9bcSJohn Baldwin  * modification, are permitted provided that the following conditions
111a62e9bcSJohn Baldwin  * are met:
121a62e9bcSJohn Baldwin  *
131a62e9bcSJohn Baldwin  * 1. Redistributions of source code must retain the above copyright
141a62e9bcSJohn Baldwin  *    notice, this list of conditions and the following disclaimer.
151a62e9bcSJohn Baldwin  * 2. Redistributions in binary form must reproduce the above copyright
161a62e9bcSJohn Baldwin  *    notice, this list of conditions and the following disclaimer in the
171a62e9bcSJohn Baldwin  *    documentation and/or other materials provided with the distribution.
181a62e9bcSJohn Baldwin  *
191a62e9bcSJohn Baldwin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
201a62e9bcSJohn Baldwin  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
211a62e9bcSJohn Baldwin  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
221a62e9bcSJohn Baldwin  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
231a62e9bcSJohn Baldwin  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
241a62e9bcSJohn Baldwin  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
251a62e9bcSJohn Baldwin  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
261a62e9bcSJohn Baldwin  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
271a62e9bcSJohn Baldwin  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
281a62e9bcSJohn Baldwin  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
291a62e9bcSJohn Baldwin  */
301a62e9bcSJohn Baldwin 
31*d5d97bedSMike Karels #ifdef __arm__
32*d5d97bedSMike Karels #include <arm/tls.h>
33*d5d97bedSMike Karels #else /* !__arm__ */
34*d5d97bedSMike Karels 
351a62e9bcSJohn Baldwin #ifndef _MACHINE_TLS_H_
361a62e9bcSJohn Baldwin #define	_MACHINE_TLS_H_
371a62e9bcSJohn Baldwin 
381a62e9bcSJohn Baldwin #include <sys/_tls_variant_i.h>
391a62e9bcSJohn Baldwin 
401a62e9bcSJohn Baldwin #define	TLS_DTV_OFFSET	0
411a62e9bcSJohn Baldwin #define	TLS_TCB_ALIGN	16
421a62e9bcSJohn Baldwin #define	TLS_TP_OFFSET	0
431a62e9bcSJohn Baldwin 
441a62e9bcSJohn Baldwin static __inline void
_tcb_set(struct tcb * tcb)451a62e9bcSJohn Baldwin _tcb_set(struct tcb *tcb)
461a62e9bcSJohn Baldwin {
471a62e9bcSJohn Baldwin 	__asm __volatile("msr	tpidr_el0, %x0" :: "r" (tcb));
481a62e9bcSJohn Baldwin }
491a62e9bcSJohn Baldwin 
501a62e9bcSJohn Baldwin static __inline struct tcb *
_tcb_get(void)511a62e9bcSJohn Baldwin _tcb_get(void)
521a62e9bcSJohn Baldwin {
531a62e9bcSJohn Baldwin 	struct tcb *tcb;
541a62e9bcSJohn Baldwin 
551a62e9bcSJohn Baldwin 	__asm __volatile("mrs	%x0, tpidr_el0" : "=r" (tcb));
561a62e9bcSJohn Baldwin 	return (tcb);
571a62e9bcSJohn Baldwin }
581a62e9bcSJohn Baldwin 
591a62e9bcSJohn Baldwin #endif /* !_MACHINE_TLS_H_ */
60*d5d97bedSMike Karels 
61*d5d97bedSMike Karels #endif /* !__arm__ */
62