11a62e9bcSJohn Baldwin /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
31a62e9bcSJohn Baldwin *
41a62e9bcSJohn Baldwin * Copyright (c) 2005 David Xu <davidxu@freebsd.org>.
51a62e9bcSJohn Baldwin * All rights reserved.
61a62e9bcSJohn Baldwin *
71a62e9bcSJohn Baldwin * Redistribution and use in source and binary forms, with or without
81a62e9bcSJohn Baldwin * modification, are permitted provided that the following conditions
91a62e9bcSJohn Baldwin * are met:
101a62e9bcSJohn Baldwin *
111a62e9bcSJohn Baldwin * 1. Redistributions of source code must retain the above copyright
121a62e9bcSJohn Baldwin * notice, this list of conditions and the following disclaimer.
131a62e9bcSJohn Baldwin * 2. Redistributions in binary form must reproduce the above copyright
141a62e9bcSJohn Baldwin * notice, this list of conditions and the following disclaimer in the
151a62e9bcSJohn Baldwin * documentation and/or other materials provided with the distribution.
161a62e9bcSJohn Baldwin *
171a62e9bcSJohn Baldwin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
181a62e9bcSJohn Baldwin * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
191a62e9bcSJohn Baldwin * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
201a62e9bcSJohn Baldwin * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
211a62e9bcSJohn Baldwin * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
221a62e9bcSJohn Baldwin * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231a62e9bcSJohn Baldwin * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241a62e9bcSJohn Baldwin * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251a62e9bcSJohn Baldwin * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
261a62e9bcSJohn Baldwin * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271a62e9bcSJohn Baldwin */
281a62e9bcSJohn Baldwin
291a62e9bcSJohn Baldwin #ifndef _MACHINE_TLS_H_
301a62e9bcSJohn Baldwin #define _MACHINE_TLS_H_
311a62e9bcSJohn Baldwin
321a62e9bcSJohn Baldwin #include <sys/_tls_variant_i.h>
331a62e9bcSJohn Baldwin #include <machine/sysarch.h>
341a62e9bcSJohn Baldwin
351a62e9bcSJohn Baldwin #define TLS_DTV_OFFSET 0
361a62e9bcSJohn Baldwin #define TLS_TCB_ALIGN 8
371a62e9bcSJohn Baldwin #define TLS_TP_OFFSET 0
381a62e9bcSJohn Baldwin
391a62e9bcSJohn Baldwin static __inline void
_tcb_set(struct tcb * tcb)401a62e9bcSJohn Baldwin _tcb_set(struct tcb *tcb)
411a62e9bcSJohn Baldwin {
421a62e9bcSJohn Baldwin sysarch(ARM_SET_TP, tcb);
431a62e9bcSJohn Baldwin }
441a62e9bcSJohn Baldwin
451a62e9bcSJohn Baldwin static __inline struct tcb *
_tcb_get(void)461a62e9bcSJohn Baldwin _tcb_get(void)
471a62e9bcSJohn Baldwin {
481a62e9bcSJohn Baldwin struct tcb *tcb;
491a62e9bcSJohn Baldwin
501a62e9bcSJohn Baldwin __asm __volatile("mrc p15, 0, %0, c13, c0, 3" \
511a62e9bcSJohn Baldwin : "=r" (tcb));
521a62e9bcSJohn Baldwin return (tcb);
531a62e9bcSJohn Baldwin }
541a62e9bcSJohn Baldwin
551a62e9bcSJohn Baldwin #endif /* !_MACHINE_TLS_H_ */
56