1*7c478bd9Sstevel@tonic-gate/* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate/* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1988-1991 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" /* From SunOS 4.1 1.6 */ 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate#if defined(lint) 29*7c478bd9Sstevel@tonic-gate#include <sys/types.h> 30*7c478bd9Sstevel@tonic-gate#include <sys/regset.h> 31*7c478bd9Sstevel@tonic-gate#include <sys/privregs.h> 32*7c478bd9Sstevel@tonic-gate#endif /* lint */ 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h> 35*7c478bd9Sstevel@tonic-gate#include <sys/trap.h> 36*7c478bd9Sstevel@tonic-gate#include <sys/machtrap.h> 37*7c478bd9Sstevel@tonic-gate#include <sys/simulate.h> 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate/* 40*7c478bd9Sstevel@tonic-gate * C run time subroutines. 41*7c478bd9Sstevel@tonic-gate * 42*7c478bd9Sstevel@tonic-gate * Those beginning in `.' are not callable from C and hence do not 43*7c478bd9Sstevel@tonic-gate * get lint prototypes. 44*7c478bd9Sstevel@tonic-gate */ 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate#if !defined(lint) 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate/* 49*7c478bd9Sstevel@tonic-gate * Structure return 50*7c478bd9Sstevel@tonic-gate */ 51*7c478bd9Sstevel@tonic-gate#define UNIMP 0 52*7c478bd9Sstevel@tonic-gate#define MASK 0x00000fff 53*7c478bd9Sstevel@tonic-gate#define STRUCT_VAL_OFF (16*4) 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate RTENTRY(.stret4) 56*7c478bd9Sstevel@tonic-gate RTENTRY(.stret8) 57*7c478bd9Sstevel@tonic-gate ! 58*7c478bd9Sstevel@tonic-gate ! see if key matches: if not, structure value not expected, 59*7c478bd9Sstevel@tonic-gate ! so just return 60*7c478bd9Sstevel@tonic-gate ! 61*7c478bd9Sstevel@tonic-gate ld [%i7 + 8], %o3 62*7c478bd9Sstevel@tonic-gate and %o1, MASK, %o4 63*7c478bd9Sstevel@tonic-gate sethi %hi(UNIMP), %o5 64*7c478bd9Sstevel@tonic-gate or %o4, %o5, %o5 65*7c478bd9Sstevel@tonic-gate cmp %o5, %o3 66*7c478bd9Sstevel@tonic-gate be,a 0f 67*7c478bd9Sstevel@tonic-gate ld [%fp + STRUCT_VAL_OFF], %i0 ! set expected return value 68*7c478bd9Sstevel@tonic-gate ret 69*7c478bd9Sstevel@tonic-gate restore 70*7c478bd9Sstevel@tonic-gate0: ! copy the struct 71*7c478bd9Sstevel@tonic-gate subcc %o1, 4, %o1 72*7c478bd9Sstevel@tonic-gate ld [%o0 + %o1], %o4 73*7c478bd9Sstevel@tonic-gate bg 0b 74*7c478bd9Sstevel@tonic-gate st %o4, [%i0 + %o1] ! delay slot 75*7c478bd9Sstevel@tonic-gate add %i7, 0x4, %i7 ! bump return address 76*7c478bd9Sstevel@tonic-gate ret 77*7c478bd9Sstevel@tonic-gate restore 78*7c478bd9Sstevel@tonic-gate SET_SIZE(.stret4) 79*7c478bd9Sstevel@tonic-gate SET_SIZE(.stret8) 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate RTENTRY(.stret2) 82*7c478bd9Sstevel@tonic-gate ! 83*7c478bd9Sstevel@tonic-gate ! see if key matches: if not, structure value not expected, 84*7c478bd9Sstevel@tonic-gate ! so just return 85*7c478bd9Sstevel@tonic-gate ! 86*7c478bd9Sstevel@tonic-gate ld [%i7 + 8], %o3 87*7c478bd9Sstevel@tonic-gate and %o1, MASK, %o4 88*7c478bd9Sstevel@tonic-gate sethi %hi(UNIMP), %o5 89*7c478bd9Sstevel@tonic-gate or %o4, %o5, %o5 90*7c478bd9Sstevel@tonic-gate cmp %o5, %o3 91*7c478bd9Sstevel@tonic-gate be,a 0f 92*7c478bd9Sstevel@tonic-gate ld [%fp + STRUCT_VAL_OFF], %i0 ! set expected return value 93*7c478bd9Sstevel@tonic-gate ret 94*7c478bd9Sstevel@tonic-gate restore 95*7c478bd9Sstevel@tonic-gate0: ! copy the struct 96*7c478bd9Sstevel@tonic-gate subcc %o1, 2, %o1 97*7c478bd9Sstevel@tonic-gate lduh [%o0 + %o1], %o4 98*7c478bd9Sstevel@tonic-gate bg 0b 99*7c478bd9Sstevel@tonic-gate sth %o4, [%i0 + %o1] ! delay slot 100*7c478bd9Sstevel@tonic-gate add %i7, 0x4, %i7 ! bump return address 101*7c478bd9Sstevel@tonic-gate ret 102*7c478bd9Sstevel@tonic-gate restore 103*7c478bd9Sstevel@tonic-gate SET_SIZE(.stret2) 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate/* 106*7c478bd9Sstevel@tonic-gate * Convert 32-bit arg pairs in %o0:o1 and %o2:%o3 to 64-bit args in %o1 and %o2 107*7c478bd9Sstevel@tonic-gate */ 108*7c478bd9Sstevel@tonic-gate#define ARGS_TO_64 \ 109*7c478bd9Sstevel@tonic-gate sllx %o0, 32, %o0; \ 110*7c478bd9Sstevel@tonic-gate srl %o1, 0, %o1; \ 111*7c478bd9Sstevel@tonic-gate sllx %o2, 32, %o2; \ 112*7c478bd9Sstevel@tonic-gate srl %o3, 0, %o3; \ 113*7c478bd9Sstevel@tonic-gate or %o0, %o1, %o1; \ 114*7c478bd9Sstevel@tonic-gate or %o2, %o3, %o2 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate RTENTRY(__mul64) 117*7c478bd9Sstevel@tonic-gate ALTENTRY(__umul64) 118*7c478bd9Sstevel@tonic-gate ARGS_TO_64 119*7c478bd9Sstevel@tonic-gate sub %o1, %o2, %o0 ! %o0 = a - b 120*7c478bd9Sstevel@tonic-gate movrlz %o0, %g0, %o0 ! %o0 = (a < b) ? 0 : a - b 121*7c478bd9Sstevel@tonic-gate sub %o1, %o0, %o1 ! %o1 = (a < b) ? a : b = min(a, b) 122*7c478bd9Sstevel@tonic-gate add %o2, %o0, %o2 ! %o2 = (a < b) ? b : a = max(a, b) 123*7c478bd9Sstevel@tonic-gate mulx %o1, %o2, %o1 ! min(a, b) in "rs1" for early exit 124*7c478bd9Sstevel@tonic-gate retl 125*7c478bd9Sstevel@tonic-gate srax %o1, 32, %o0 126*7c478bd9Sstevel@tonic-gate SET_SIZE(__mul64) 127*7c478bd9Sstevel@tonic-gate SET_SIZE(__umul64) 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate RTENTRY(__div64) 130*7c478bd9Sstevel@tonic-gate ARGS_TO_64 131*7c478bd9Sstevel@tonic-gate sdivx %o1, %o2, %o1 132*7c478bd9Sstevel@tonic-gate retl 133*7c478bd9Sstevel@tonic-gate srax %o1, 32, %o0 134*7c478bd9Sstevel@tonic-gate SET_SIZE(__div64) 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate RTENTRY(__udiv64) 137*7c478bd9Sstevel@tonic-gate ARGS_TO_64 138*7c478bd9Sstevel@tonic-gate udivx %o1, %o2, %o1 139*7c478bd9Sstevel@tonic-gate retl 140*7c478bd9Sstevel@tonic-gate srax %o1, 32, %o0 141*7c478bd9Sstevel@tonic-gate SET_SIZE(__udiv64) 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate RTENTRY(__rem64) 144*7c478bd9Sstevel@tonic-gate ARGS_TO_64 145*7c478bd9Sstevel@tonic-gate sdivx %o1, %o2, %o3 146*7c478bd9Sstevel@tonic-gate mulx %o2, %o3, %o3 147*7c478bd9Sstevel@tonic-gate sub %o1, %o3, %o1 148*7c478bd9Sstevel@tonic-gate retl 149*7c478bd9Sstevel@tonic-gate srax %o1, 32, %o0 150*7c478bd9Sstevel@tonic-gate SET_SIZE(__rem64) 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate RTENTRY(__urem64) 153*7c478bd9Sstevel@tonic-gate ARGS_TO_64 154*7c478bd9Sstevel@tonic-gate udivx %o1, %o2, %o3 155*7c478bd9Sstevel@tonic-gate mulx %o2, %o3, %o3 156*7c478bd9Sstevel@tonic-gate sub %o1, %o3, %o1 157*7c478bd9Sstevel@tonic-gate retl 158*7c478bd9Sstevel@tonic-gate srax %o1, 32, %o0 159*7c478bd9Sstevel@tonic-gate SET_SIZE(__urem64) 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate#endif /* !lint */ 162