xref: /netbsd-src/lib/libc/arch/arm/sys/getcontext.S (revision 2a674d4fc64728ced9f1642054ee5ad19aad86e5)
1*2a674d4fSmatt/*	$NetBSD: getcontext.S,v 1.10 2013/09/03 00:30:19 matt Exp $	*/
23fdac2b8Sthorpej
33fdac2b8Sthorpej/*-
43fdac2b8Sthorpej * Copyright (c) 2001 The NetBSD Foundation, Inc.
53fdac2b8Sthorpej * All rights reserved.
63fdac2b8Sthorpej *
73fdac2b8Sthorpej * This code is derived from software contributed to The NetBSD Foundation
83fdac2b8Sthorpej * by Klaus Klein.
93fdac2b8Sthorpej *
103fdac2b8Sthorpej * Redistribution and use in source and binary forms, with or without
113fdac2b8Sthorpej * modification, are permitted provided that the following conditions
123fdac2b8Sthorpej * are met:
133fdac2b8Sthorpej * 1. Redistributions of source code must retain the above copyright
143fdac2b8Sthorpej *    notice, this list of conditions and the following disclaimer.
153fdac2b8Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
163fdac2b8Sthorpej *    notice, this list of conditions and the following disclaimer in the
173fdac2b8Sthorpej *    documentation and/or other materials provided with the distribution.
183fdac2b8Sthorpej *
193fdac2b8Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
203fdac2b8Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
213fdac2b8Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
223fdac2b8Sthorpej * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
233fdac2b8Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
243fdac2b8Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
253fdac2b8Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
263fdac2b8Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
273fdac2b8Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
283fdac2b8Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
293fdac2b8Sthorpej * POSSIBILITY OF SUCH DAMAGE.
303fdac2b8Sthorpej */
313fdac2b8Sthorpej
323fdac2b8Sthorpej#include "SYS.h"
33361e2d0bSskrll#include "assym.h"
343fdac2b8Sthorpej
353fdac2b8Sthorpej#if defined(SYSLIBC_SCCS) && !defined(lint)
36*2a674d4fSmatt	RCSID("$NetBSD: getcontext.S,v 1.10 2013/09/03 00:30:19 matt Exp $")
373fdac2b8Sthorpej#endif /* SYSLIBC_SCCS && !lint */
383fdac2b8Sthorpej
393fdac2b8Sthorpej#ifdef WEAK_ALIAS
403fdac2b8SthorpejWEAK_ALIAS(getcontext, _getcontext)
413fdac2b8Sthorpej#endif
423fdac2b8Sthorpej
433fdac2b8SthorpejENTRY(_getcontext)
443fdac2b8Sthorpej	mov	r2, r0			/* Must save argument pointer. */
45c82cfbf5Schris	SYSTRAP (getcontext)
46*2a674d4fSmatt	_INVOKE_CERROR()
47*2a674d4fSmatt#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
483e638bdcSskrll	str	lr, [r2, #_UC_REGS_PC]	/* Adjust PC. */
49*2a674d4fSmatt#else
50*2a674d4fSmatt	mov	r3, lr
51*2a674d4fSmatt	str	r3, [r2, #_UC_REGS_PC]	/* Adjust PC. */
52*2a674d4fSmatt#endif
533fdac2b8Sthorpej#ifdef SOFTFLOAT
543fdac2b8Sthorpej	/* Ahem. */
553fdac2b8Sthorpej	/* Judging from the softfloat code we should at least save
563fdac2b8Sthorpej	   the exception codes and rounding mode here. */
573fdac2b8Sthorpej#endif
58*2a674d4fSmatt	movs	r0, #0
593e638bdcSskrll	str	r0, [r2, #_UC_REGS_R0]	/* Return 0. */
60ed6e0e9eSrearnsha	RET
61*2a674d4fSmattEND(_getcontext)
62