xref: /openbsd-src/sys/arch/hppa/include/tcb.h (revision 5121d428d9536017610dd126bc74e8f8c87cad0b)
1 /*	$OpenBSD: tcb.h,v 1.2 2011/11/08 15:39:50 kettenis Exp $	*/
2 
3 /*
4  * Copyright (c) 2011 Philip Guenther <guenther@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef _MACHINE_TCB_H_
20 #define _MACHINE_TCB_H_
21 
22 #ifdef _KERNEL
23 
24 #define TCB_GET(p)		\
25 	((void *)(p)->p_md.md_regs->tf_cr27)
26 #define TCB_SET(p, addr)	\
27 	((p)->p_md.md_regs->tf_cr27 = (unsigned)(addr))
28 
29 #else /* _KERNEL */
30 
31 /* ELF TLS ABI calls for small TCB, with static TLS data after it */
32 #define TLS_VARIANT	1
33 
34 /* Get a pointer to the TCB itself */
35 static inline void *
__hppa_get_tcb(void)36 __hppa_get_tcb(void)
37 {
38 	void *val;
39 	__asm__ ("mfctl %%cr27, %0" : "=r" (val));
40 	return val;
41 }
42 #define TCB_GET()		__hppa_get_tcb()
43 
44 #endif /* _KERNEL */
45 
46 #endif /* _MACHINE_TCB_H_ */
47