11.5Smatt/* $NetBSD: __aeabi_read_tp.S,v 1.5 2013/08/19 22:10:51 matt Exp $ */
21.3Smatt
31.5Smatt#undef __thumb__
41.1Sjoerg#include "SYS.h"
51.1Sjoerg
61.3Smatt/*
71.3Smatt * Implementations of this function should corrupt only the result register
81.3Smatt * (r0) and the non-parameter integer core registers allowed to be corrupted
91.3Smatt * by the [AAPCS] (ip, lr, and CPSR).
101.3Smatt */
111.5SmattARM_ENTRY(__aeabi_read_tp)
121.3Smatt	mrc	p15, 0, r0, c13, c0, 3
131.2Smatt#ifndef _ARM_ARCH_6
141.3Smatt	cmp	r0, #0			/* was it zero? */
151.2Smatt	RETc(ne)			/* return it's not zero */
161.3Smatt	mov	ip, r1			/* syscall zeroes r1 */
171.2Smatt	SYSTRAP(_lwp_getprivate)	/* can't fail */
181.3Smatt	mov	r1, ip			/* restore r1 */
191.2Smatt#endif
201.1Sjoerg	RET
211.4SmattEND(__aeabi_read_tp)
22