17c478bd9Sstevel@tonic-gate/* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57257d1b4Sraf * Common Development and Distribution License (the "License"). 67257d1b4Sraf * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate 227c478bd9Sstevel@tonic-gate/* 237257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277257d1b4Sraf/* Copyright (c) 1988 AT&T */ 287257d1b4Sraf/* All Rights Reserved */ 297257d1b4Sraf 307c478bd9Sstevel@tonic-gate/* 317c478bd9Sstevel@tonic-gate * C library -- int syscall(int sysnum, ...); 327c478bd9Sstevel@tonic-gate * C library -- int __systemcall(sysret_t *, int sysnum, ...); 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate * Interpret a given system call 357c478bd9Sstevel@tonic-gate * 367c478bd9Sstevel@tonic-gate * This version handles up to 8 'long' arguments to a system call. 377c478bd9Sstevel@tonic-gate * 387c478bd9Sstevel@tonic-gate * Even though indirect system call support exists in the SPARC 397c478bd9Sstevel@tonic-gate * 32-bit kernel, we want to eliminate it in a future release, 407c478bd9Sstevel@tonic-gate * so the real trap for the desired system call is issued right here. 417c478bd9Sstevel@tonic-gate * 427c478bd9Sstevel@tonic-gate * Even though %g5 can be used as a scratch register for sparcv9, we don't 437c478bd9Sstevel@tonic-gate * use it here because this code is shared between sparcv8 and sparcv9. 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate 46*9a70fc3bSMark J. Nelson .file "syscall.s" 477c478bd9Sstevel@tonic-gate 487257d1b4Sraf#include "SYS.h" 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK(syscall,function) 517c478bd9Sstevel@tonic-gate 527257d1b4Sraf ENTRY(syscall) 537c478bd9Sstevel@tonic-gate save %sp, -SA(MINFRAME + 2*CLONGSIZE), %sp 547c478bd9Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME], %o5 ! arg 5 557c478bd9Sstevel@tonic-gate mov %i3, %o2 ! arg 2 567c478bd9Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + CLONGSIZE], %g1 577c478bd9Sstevel@tonic-gate mov %i4, %o3 ! arg 3 587c478bd9Sstevel@tonic-gate stn %g1, [%sp + STACK_BIAS + MINFRAME] ! arg 6 597c478bd9Sstevel@tonic-gate mov %i5, %o4 ! arg 4 607c478bd9Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + 2*CLONGSIZE], %g1 617c478bd9Sstevel@tonic-gate mov %i1, %o0 ! arg 0 627c478bd9Sstevel@tonic-gate stn %g1, [%sp + STACK_BIAS + MINFRAME + CLONGSIZE] ! arg 7 637c478bd9Sstevel@tonic-gate mov %i2, %o1 ! arg 1 647c478bd9Sstevel@tonic-gate mov %i0, %g1 ! sysnum 657c478bd9Sstevel@tonic-gate ta SYSCALL_TRAPNUM 667c478bd9Sstevel@tonic-gate bcc,a,pt %icc, 1f 677c478bd9Sstevel@tonic-gate sra %o0, 0, %i0 ! (int) cast 687c478bd9Sstevel@tonic-gate restore %o0, 0, %o0 697c478bd9Sstevel@tonic-gate ba __cerror 707c478bd9Sstevel@tonic-gate nop 717c478bd9Sstevel@tonic-gate1: 727c478bd9Sstevel@tonic-gate ret 737c478bd9Sstevel@tonic-gate restore 747257d1b4Sraf SET_SIZE(syscall) 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate/* 777c478bd9Sstevel@tonic-gate * Same as _syscall(), but restricted to 6 syscall arguments 787c478bd9Sstevel@tonic-gate * so it doesn't need to incur the overhead of a register window. 797c478bd9Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported. 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate ENTRY(_syscall6) 827c478bd9Sstevel@tonic-gate mov %o0, %g1 /* sysnum */ 837c478bd9Sstevel@tonic-gate mov %o1, %o0 /* syscall args */ 847c478bd9Sstevel@tonic-gate mov %o2, %o1 857c478bd9Sstevel@tonic-gate mov %o3, %o2 867c478bd9Sstevel@tonic-gate mov %o4, %o3 877c478bd9Sstevel@tonic-gate mov %o5, %o4 887c478bd9Sstevel@tonic-gate ldn [%sp + STACK_BIAS + MINFRAME], %o5 897c478bd9Sstevel@tonic-gate ta SYSCALL_TRAPNUM 907c478bd9Sstevel@tonic-gate SYSCERROR 917c478bd9Sstevel@tonic-gate retl 927c478bd9Sstevel@tonic-gate sra %o0, 0, %o0 /* (int) cast */ 937c478bd9Sstevel@tonic-gate SET_SIZE(_syscall6) 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate ENTRY(__systemcall) 967c478bd9Sstevel@tonic-gate save %sp, -SA(MINFRAME + 2*CLONGSIZE), %sp 977c478bd9Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME], %o4 ! arg 4 987c478bd9Sstevel@tonic-gate mov %i3, %o1 ! arg 1 997c478bd9Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + CLONGSIZE], %o5 ! arg5 1007c478bd9Sstevel@tonic-gate mov %i4, %o2 ! arg 2 1017c478bd9Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + 2*CLONGSIZE], %g1 1027c478bd9Sstevel@tonic-gate mov %i5, %o3 ! arg 3 1037c478bd9Sstevel@tonic-gate stn %g1, [%sp + STACK_BIAS + MINFRAME] ! arg 6 1047c478bd9Sstevel@tonic-gate mov %i2, %o0 ! arg 0 1057c478bd9Sstevel@tonic-gate ldn [%fp + STACK_BIAS + MINFRAME + 3*CLONGSIZE], %g1 1067c478bd9Sstevel@tonic-gate stn %g1, [%sp + STACK_BIAS + MINFRAME + CLONGSIZE] ! arg7 1077c478bd9Sstevel@tonic-gate mov %i1, %g1 ! sysnum 1087c478bd9Sstevel@tonic-gate ta SYSCALL_TRAPNUM 1097c478bd9Sstevel@tonic-gate bcc,pt %icc, 1f 1107c478bd9Sstevel@tonic-gate mov -1, %g1 1117c478bd9Sstevel@tonic-gate stn %g1, [%i0] /* error */ 1127c478bd9Sstevel@tonic-gate ba 2f 1137c478bd9Sstevel@tonic-gate stn %g1, [%i0 + CLONGSIZE] 1147c478bd9Sstevel@tonic-gate1: 1157c478bd9Sstevel@tonic-gate stn %o0, [%i0] /* no error */ 1167c478bd9Sstevel@tonic-gate clr %o0 1177c478bd9Sstevel@tonic-gate stn %o1, [%i0 + CLONGSIZE] 1187c478bd9Sstevel@tonic-gate2: 1197c478bd9Sstevel@tonic-gate ret 1207c478bd9Sstevel@tonic-gate restore %o0, 0, %o0 1217c478bd9Sstevel@tonic-gate SET_SIZE(__systemcall) 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate/* 1247c478bd9Sstevel@tonic-gate * Same as __systemcall(), but restricted to 6 syscall arguments 1257c478bd9Sstevel@tonic-gate * so it doesn't need to incur the overhead of a register window. 1267c478bd9Sstevel@tonic-gate * Implemented for use only within libc; symbol is not exported. 1277c478bd9Sstevel@tonic-gate */ 1287c478bd9Sstevel@tonic-gate ENTRY(__systemcall6) 1297c478bd9Sstevel@tonic-gate stn %o0, [%sp + SAVE_OFFSET] /* sysret address */ 1307c478bd9Sstevel@tonic-gate mov %o1, %g1 /* sysnum */ 1317c478bd9Sstevel@tonic-gate mov %o2, %o0 /* syscall args */ 1327c478bd9Sstevel@tonic-gate mov %o3, %o1 1337c478bd9Sstevel@tonic-gate mov %o4, %o2 1347c478bd9Sstevel@tonic-gate mov %o5, %o3 1357c478bd9Sstevel@tonic-gate ldn [%sp + STACK_BIAS + MINFRAME], %o4 1367c478bd9Sstevel@tonic-gate ldn [%sp + STACK_BIAS + MINFRAME + CLONGSIZE], %o5 1377c478bd9Sstevel@tonic-gate ta SYSCALL_TRAPNUM 1387c478bd9Sstevel@tonic-gate bcs,pn %icc, 1f 1397c478bd9Sstevel@tonic-gate ldn [%sp + SAVE_OFFSET], %g1 1407c478bd9Sstevel@tonic-gate stn %o0, [%g1] /* no error */ 1417c478bd9Sstevel@tonic-gate stn %o1, [%g1 + CLONGSIZE] 1427c478bd9Sstevel@tonic-gate retl 1437c478bd9Sstevel@tonic-gate clr %o0 1447c478bd9Sstevel@tonic-gate1: 1457c478bd9Sstevel@tonic-gate mov -1, %o1 /* error */ 1467c478bd9Sstevel@tonic-gate stn %o1, [%g1] 1477c478bd9Sstevel@tonic-gate retl 1487c478bd9Sstevel@tonic-gate stn %o1, [%g1 + CLONGSIZE] 1497c478bd9Sstevel@tonic-gate SET_SIZE(__systemcall6) 150