1*ce099b40Smartin/* $NetBSD: getcontext.S,v 1.2 2008/04/28 20:22:57 martin Exp $ */ 213a5336cSkleink 313a5336cSkleink/*- 413a5336cSkleink * Copyright (c) 2001 The NetBSD Foundation, Inc. 513a5336cSkleink * All rights reserved. 613a5336cSkleink * 713a5336cSkleink * This code is derived from software contributed to The NetBSD Foundation 813a5336cSkleink * by Klaus Klein. 913a5336cSkleink * 1013a5336cSkleink * Redistribution and use in source and binary forms, with or without 1113a5336cSkleink * modification, are permitted provided that the following conditions 1213a5336cSkleink * are met: 1313a5336cSkleink * 1. Redistributions of source code must retain the above copyright 1413a5336cSkleink * notice, this list of conditions and the following disclaimer. 1513a5336cSkleink * 2. Redistributions in binary form must reproduce the above copyright 1613a5336cSkleink * notice, this list of conditions and the following disclaimer in the 1713a5336cSkleink * documentation and/or other materials provided with the distribution. 1813a5336cSkleink * 1913a5336cSkleink * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2013a5336cSkleink * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2113a5336cSkleink * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2213a5336cSkleink * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2313a5336cSkleink * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2413a5336cSkleink * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2513a5336cSkleink * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2613a5336cSkleink * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2713a5336cSkleink * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2813a5336cSkleink * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2913a5336cSkleink * POSSIBILITY OF SUCH DAMAGE. 3013a5336cSkleink */ 3113a5336cSkleink 3213a5336cSkleink#include "SYS.h" 3313a5336cSkleink 3413a5336cSkleink#if defined(SYSLIBC_SCCS) && !defined(lint) 35*ce099b40Smartin RCSID("$NetBSD: getcontext.S,v 1.2 2008/04/28 20:22:57 martin Exp $") 3613a5336cSkleink#endif /* SYSLIBC_SCCS && !lint */ 3713a5336cSkleink 3813a5336cSkleink#ifdef WEAK_ALIAS 3913a5336cSkleinkWEAK_ALIAS(getcontext, _getcontext) 4013a5336cSkleink#endif 4113a5336cSkleink 4213a5336cSkleinkENTRY(_getcontext) 4313a5336cSkleink mov %o0, %o2 ! must save pointer 4413a5336cSkleink mov SYS_getcontext, %g1 4513a5336cSkleink t ST_SYSCALL 4613a5336cSkleink bcc,a 1f 4713a5336cSkleink clr [%o2 + 40 + 11 * 4] ! gr[_REG_O0] = 0 4813a5336cSkleink ERROR() 4913a5336cSkleink1: 5013a5336cSkleink add %o7, 8, %o1 5113a5336cSkleink st %o1, [%o2 + 40 + 1 * 4] ! gr[_REG_PC] = retaddr 5213a5336cSkleink add %o7, 12, %o1 5313a5336cSkleink retl 5413a5336cSkleink st %o1, [%o2 + 40 + 2 * 4] ! gr[_REG_nPC] = retaddr + 4 55