18238b87bSPeter Grehan/*- 28238b87bSPeter Grehan * Copyright (c) 2002 Peter Grehan. 38238b87bSPeter Grehan * All rights reserved. 48238b87bSPeter Grehan * 58238b87bSPeter Grehan * Redistribution and use in source and binary forms, with or without 68238b87bSPeter Grehan * modification, are permitted provided that the following conditions 78238b87bSPeter Grehan * are met: 88238b87bSPeter Grehan * 1. Redistributions of source code must retain the above copyright 98238b87bSPeter Grehan * notice, this list of conditions and the following disclaimer. 108238b87bSPeter Grehan * 2. Redistributions in binary form must reproduce the above copyright 118238b87bSPeter Grehan * notice, this list of conditions and the following disclaimer in the 128238b87bSPeter Grehan * documentation and/or other materials provided with the distribution. 138238b87bSPeter Grehan * 148238b87bSPeter Grehan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 158238b87bSPeter Grehan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 168238b87bSPeter Grehan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 178238b87bSPeter Grehan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 188238b87bSPeter Grehan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 198238b87bSPeter Grehan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 208238b87bSPeter Grehan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 218238b87bSPeter Grehan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 228238b87bSPeter Grehan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 238238b87bSPeter Grehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 248238b87bSPeter Grehan * SUCH DAMAGE. 258238b87bSPeter Grehan */ 268238b87bSPeter Grehan/* $NetBSD: _setjmp.S,v 1.1 1997/03/29 20:55:53 thorpej Exp $ */ 278238b87bSPeter Grehan 288238b87bSPeter Grehan#include <machine/asm.h> 298238b87bSPeter Grehan__FBSDID("$FreeBSD$"); 308238b87bSPeter Grehan 318238b87bSPeter Grehan/* 328238b87bSPeter Grehan * C library -- _setjmp, _longjmp 338238b87bSPeter Grehan * 348238b87bSPeter Grehan * _longjmp(a,v) 358238b87bSPeter Grehan * will generate a "return(v?v:1)" from the last call to 368238b87bSPeter Grehan * _setjmp(a) 378238b87bSPeter Grehan * by restoring registers from the stack. 388238b87bSPeter Grehan * The previous signal state is NOT restored. 398238b87bSPeter Grehan * 408238b87bSPeter Grehan * jmpbuf layout: 418238b87bSPeter Grehan * +------------+ 428238b87bSPeter Grehan * | unused | 438238b87bSPeter Grehan * +------------+ 448238b87bSPeter Grehan * | unused | 458238b87bSPeter Grehan * | | 468238b87bSPeter Grehan * | (4 words) | 478238b87bSPeter Grehan * | | 488238b87bSPeter Grehan * +------------+ 498238b87bSPeter Grehan * | saved regs | 508238b87bSPeter Grehan * | ... | 518238b87bSPeter Grehan */ 528238b87bSPeter Grehan 538238b87bSPeter GrehanENTRY(_setjmp) 548238b87bSPeter Grehan mflr %r11 558238b87bSPeter Grehan mfcr %r12 568238b87bSPeter Grehan mr %r10,%r1 578238b87bSPeter Grehan mr %r9,%r2 588238b87bSPeter Grehan stmw %r9,20(%r3) 598238b87bSPeter Grehan li %r3,0 608238b87bSPeter Grehan blr 618238b87bSPeter Grehan 628238b87bSPeter GrehanENTRY(_longjmp) 638238b87bSPeter Grehan lmw %r9,20(%r3) 648238b87bSPeter Grehan mtlr %r11 658238b87bSPeter Grehan mtcr %r12 668238b87bSPeter Grehan mr %r2,%r9 678238b87bSPeter Grehan mr %r1,%r10 688238b87bSPeter Grehan or. %r3,%r4,%r4 698238b87bSPeter Grehan bnelr 708238b87bSPeter Grehan li %r3,1 718238b87bSPeter Grehan blr 72*8f861da9SKonstantin Belousov 73*8f861da9SKonstantin Belousov .section .note.GNU-stack,"",%progbits 74