1/*- 2 * Copyright (C) 2003 Jake Burkholder <jake@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Neither the name of the author nor the names of its contributors 11 * may be used to endorse or promote products derived from this software 12 * without specific prior written permission. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <machine/asm.h> 28__FBSDID("$FreeBSD$"); 29 30#include "assym.s" 31 32 .weak CNAME(_thr_getcontext) 33 .set CNAME(_thr_getcontext),CNAME(__thr_getcontext) 34ENTRY(__thr_getcontext) 35 add %o7, 8, %o1 36 add %o1, 4, %o2 37 stx %sp, [%o0 + MC_OUT + (6 * 8)] 38 stx %o1, [%o0 + MC_TPC] 39 stx %o2, [%o0 + MC_TNPC] 40 mov MC_VALID_FLAGS, %l0 /* Validate the context. */ 41 stx %l0, [%o0 + MC_FLAGS] 42 mov 1, %l0 43 stx %l0, [%o0 + MC_OUT + (0 * 8)] /* return 1 when resumed */ 44 retl 45 mov 0, %o0 /* return 0 */ 46END(__thr_getcontext) 47 48 .weak CNAME(_thr_setcontext) 49 .set CNAME(_thr_setcontext),CNAME(__thr_setcontext) 50ENTRY(__thr_setcontext) 51 save %sp, -CCFSZ, %sp 52 flushw 53 mov %i0, %l0 54 mov %i1, %l1 55 mov %i2, %l2 56 ldx [%l0 + MC_GLOBAL + (1 * 8)], %g1 57 ldx [%l0 + MC_GLOBAL + (2 * 8)], %g2 58 ldx [%l0 + MC_GLOBAL + (3 * 8)], %g3 59 ldx [%l0 + MC_GLOBAL + (4 * 8)], %g4 60 ldx [%l0 + MC_GLOBAL + (5 * 8)], %g5 61 ldx [%l0 + MC_GLOBAL + (6 * 8)], %g6 62 ldx [%l0 + MC_GLOBAL + (7 * 8)], %g7 63 ldx [%l0 + MC_OUT + (0 * 8)], %i0 64 ldx [%l0 + MC_OUT + (1 * 8)], %i1 65 ldx [%l0 + MC_OUT + (2 * 8)], %i2 66 ldx [%l0 + MC_OUT + (3 * 8)], %i3 67 ldx [%l0 + MC_OUT + (4 * 8)], %i4 68 ldx [%l0 + MC_OUT + (5 * 8)], %i5 69 ldx [%l0 + MC_OUT + (6 * 8)], %i6 70 ldx [%l0 + MC_OUT + (7 * 8)], %i7 71 ldx [%l0 + MC_TPC], %l4 72 ldx [%l0 + MC_TNPC], %l3 73 brz %l2, 1f 74 nop 75 stx %l1, [%l2] 761: jmpl %l3, %g0 77 return %l4 78END(__thr_setcontext) 79 80ENTRY(_sparc64_enter_uts) 81 save %sp, -CCFSZ, %sp 82 flushw 83 add %i2, %i3, %i2 84 sub %i2, SPOFF + CCFSZ, %sp 85 jmpl %i0, %g0 86 mov %i1, %o0 87END(_sparc64_enter_uts) 88