1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26#pragma ident "%Z%%M% %I% %E% SMI" 27 28 .file "%M%" 29 30#include <sys/asm_linkage.h> 31 32 /* 33 * weak aliases for public interfaces 34 */ 35 ANSI_PRAGMA_WEAK(_door_bind,function) 36 ANSI_PRAGMA_WEAK(_door_call,function) 37 ANSI_PRAGMA_WEAK(_door_getparam,function) 38 ANSI_PRAGMA_WEAK(_door_info,function) 39 ANSI_PRAGMA_WEAK(_door_revoke,function) 40 ANSI_PRAGMA_WEAK(_door_setparam,function) 41 ANSI_PRAGMA_WEAK(_door_unbind,function) 42 43 ANSI_PRAGMA_WEAK(door_bind,function) 44 ANSI_PRAGMA_WEAK(door_call,function) 45 ANSI_PRAGMA_WEAK(door_getparam,function) 46 ANSI_PRAGMA_WEAK(door_info,function) 47 ANSI_PRAGMA_WEAK(door_revoke,function) 48 ANSI_PRAGMA_WEAK(door_setparam,function) 49 ANSI_PRAGMA_WEAK(door_unbind,function) 50 51#include <sys/door.h> 52#include "SYS.h" 53 54/* 55 * Offsets within struct door_results 56 */ 57#define DOOR_COOKIE (SA(MINFRAME) + STACK_BIAS + 0*CLONGSIZE) 58#define DOOR_DATA_PTR (SA(MINFRAME) + STACK_BIAS + 1*CLONGSIZE) 59#define DOOR_DATA_SIZE (SA(MINFRAME) + STACK_BIAS + 2*CLONGSIZE) 60#define DOOR_DESC_PTR (SA(MINFRAME) + STACK_BIAS + 3*CLONGSIZE) 61#define DOOR_DESC_SIZE (SA(MINFRAME) + STACK_BIAS + 4*CLONGSIZE) 62#define DOOR_PC (SA(MINFRAME) + STACK_BIAS + 5*CLONGSIZE) 63#define DOOR_SERVERS (SA(MINFRAME) + STACK_BIAS + 6*CLONGSIZE) 64#define DOOR_INFO_PTR (SA(MINFRAME) + STACK_BIAS + 7*CLONGSIZE) 65 66/* 67 * All of the syscalls except door_return() follow the same pattern. The 68 * subcode goes in %o5, after all of the other arguments. 69 */ 70#define DOOR_SYSCALL(name, code) \ 71 ENTRY(name); \ 72 mov code, %o5; /* subcode */ \ 73 SYSTRAP_RVAL1(door); \ 74 SYSCERROR; \ 75 RET; \ 76 SET_SIZE(name) 77 78 DOOR_SYSCALL(__door_bind, DOOR_BIND) 79 DOOR_SYSCALL(__door_call, DOOR_CALL) 80 DOOR_SYSCALL(__door_create, DOOR_CREATE) 81 DOOR_SYSCALL(__door_getparam, DOOR_GETPARAM) 82 DOOR_SYSCALL(__door_info, DOOR_INFO) 83 DOOR_SYSCALL(__door_revoke, DOOR_REVOKE) 84 DOOR_SYSCALL(__door_setparam, DOOR_SETPARAM) 85 DOOR_SYSCALL(__door_ucred, DOOR_UCRED) 86 DOOR_SYSCALL(__door_unbind, DOOR_UNBIND) 87 DOOR_SYSCALL(__door_unref, DOOR_UNREFSYS) 88 89/* 90 * int 91 * __door_return( 92 * void *data_ptr, 93 * size_t data_size, (in bytes) 94 * door_return_desc_t *door_ptr, (holds returned desc info) 95 * caddr_t stack_base, 96 * size_t stack_size) 97 */ 98 ENTRY(__door_return) 99door_restart: 100 mov DOOR_RETURN, %o5 /* subcode */ 101 SYSTRAP_RVAL1(door) 102 bcs,pn %icc, 3f /* errno is set */ 103 ld [%sp + DOOR_SERVERS], %g1 /* (delay) load nservers */ 104 /* 105 * On return, we're serving a door_call. Our stack looks like this: 106 * 107 * descriptors (if any) 108 * data (if any) 109 * struct door_results 110 * MINFRAME 111 * sp -> 112 */ 113 tst %g1 /* test nservers */ 114 bg 1f /* everything looks o.k. */ 115 ldn [%sp + DOOR_COOKIE], %o0 /* (delay) load cookie */ 116 /* 117 * this is the last server thread - call creation func for more 118 */ 119 save %sp, -SA(MINFRAME), %sp 120 PIC_SETUP(g1) 121#ifdef __sparcv9 122 sethi %hi(door_server_func), %g5 123 or %g5, %lo(door_server_func), %g5 124 ldn [%g5 + %g1], %g1 125#else 126 ldn [%g1 + door_server_func], %g1 127#endif 128 ldn [%g1], %g1 129 jmpl %g1, %o7 /* call create function */ 130 ldn [%fp + DOOR_INFO_PTR], %o0 /* (delay) load door_info ptr */ 131 restore 1321: 133 /* Call the door server function now */ 134 ldn [%sp + DOOR_DATA_PTR], %o1 135 ldn [%sp + DOOR_DATA_SIZE], %o2 136 ldn [%sp + DOOR_DESC_PTR], %o3 137 ldn [%sp + DOOR_PC], %g1 138 jmpl %g1, %o7 139 ldn [%sp + DOOR_DESC_SIZE], %o4 140 1412: 142 /* Exit the thread if we return here */ 143 call _thr_terminate 144 mov %g0, %o0 145 /* NOTREACHED */ 146 1473: 148 /* 149 * Error during door_return call. Repark the thread in the kernel if 150 * the error code is EINTR (or ERESTART) and this lwp is still part 151 * of the same process. If error is EEXIST then we don't need 152 * this server thread. 153 */ 154 cmp %o0, EEXIST 155 be 2b 156 nop 157 cmp %o0, ERESTART /* ERESTART is same as EINTR */ 158 be,a 4f 159 mov EINTR, %o0 160 1614: 162 cmp %o0, EINTR /* interrupted while waiting? */ 163 bne __cerror /* if not, return the error */ 164 nop 165 166 save %sp, -SA(MINFRAME), %sp 167 call _private_getpid /* get current process id */ 168 nop 169 PIC_SETUP(g1) 170#ifdef __sparcv9 171 sethi %hi(door_create_pid), %g5 172 or %g5, %lo(door_create_pid), %g5 173 ldn [%g1 + %g5], %g1 174#else 175 ldn [%g1 + door_create_pid], %g1 176#endif 177 ld [%g1], %g1 178 cmp %o0, %g1 /* same process? */ 179 mov EINTR, %o0 /* if no, return EINTR (child of forkall) */ 180 bne __cerror 181 restore 182 183 clr %o0 /* clear arguments and restart */ 184 clr %o1 185 ba door_restart 186 clr %o2 187 SET_SIZE(__door_return) 188