1*4d12bfcdSjoerg/* $NetBSD: swapcontext.S,v 1.5 2013/09/12 15:36:16 joerg 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" 333fdac2b8Sthorpej 343fdac2b8Sthorpej#if defined(LIBC_SCCS) && !defined(lint) 35*4d12bfcdSjoerg RCSID("$NetBSD: swapcontext.S,v 1.5 2013/09/12 15:36:16 joerg Exp $") 363fdac2b8Sthorpej#endif /* LIBC_SCCS && !lint */ 373fdac2b8Sthorpej 383fdac2b8SthorpejENTRY(swapcontext) 393fdac2b8Sthorpej mov %o0, %o2 ! must save pointer 403fdac2b8Sthorpej mov %o1, %o3 ! must save pointer 413fdac2b8Sthorpej mov SYS_getcontext, %g1 423fdac2b8Sthorpej t ST_SYSCALL 433fdac2b8Sthorpej bcc,a 1f 443fdac2b8Sthorpej st %g0, [%o2 + 40 + 11 * 4] ! gr[_REG_O0] = 0 453fdac2b8Sthorpej ERROR() 463fdac2b8Sthorpej1: 473fdac2b8Sthorpej add %o7, 12, %o1 483fdac2b8Sthorpej st %o1, [%o2 + 40 + 2 * 4] ! gr[_REG_nPC] = retaddr + 4 493fdac2b8Sthorpej add %o7, 8, %o1 503fdac2b8Sthorpej st %o1, [%o2 + 40 + 1 * 4] ! gr[_REG_PC] = retaddr 513fdac2b8Sthorpej 52*4d12bfcdSjoerg#ifdef __PIC__ 53bba80928Smanu PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE 54bba80928Smanu set _C_LABEL(setcontext), %g2 55bba80928Smanu ld [%g1 + %g2], %g1 56bba80928Smanu jmp %g1 573fdac2b8Sthorpej mov %o3, %o0 58bba80928Smanu#else 59bba80928Smanu jmp _C_LABEL(setcontext) 60bba80928Smanu mov %o3, %o0 61bba80928Smanu#endif 62