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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #if defined(lint) || defined(DS_DDICT)
27 #include <sys/types.h>
28 #include <sys/param.h>
30 #include "assym.h" /* Determine value of CPU_THREAD */
31 #include <sys/asm_linkage.h>
35 #define uint8_t uchar_t
40 * Special support routines that can't be done with C
45 * uint8_t nsc_ldstub(uint8_t *cp)
47 * Store 0xFF at the specified location, and return its previous content.
50 #if defined(lint) || defined(DS_DDICT)
52 nsc_ldstub
(uint8_t
*cp
)
64 xchgb
%al
, (%rdi
) /* rdi = lock addr */
67 movl
4(%esp
), %ecx
/* ecx = lock addr */
68 movl $
0xff, %eax
/* eax = 0xff */
70 xchgb
%al
, (%ecx
) /* atomic swap eax <-> *ecx */
73 #error "port this routine"
79 * nsc_membar_stld(void)
81 * On SPARC this is a C callable interface to SPARC asm membar instruction.
82 * For x86 we brute force it with a #LOCK instruction.
85 #if defined(lint) || defined(DS_DDICT)
91 ENTRY
(nsc_membar_stld
)
100 #error "port this routine"
102 SET_SIZE
(nsc_membar_stld
)
104 #endif /* lint || DS_DDICT */
108 * if a() calls b() calls nsc_caller(),
109 * nsc_caller() returns return address in a().
112 #if defined(lint) || defined(DS_DDICT)
122 movq
8(%rbp
), %rax
/* b()'s return pc, in a() */
124 #elif defined(__i386)
125 movl
4(%ebp
), %eax
/* b()'s return pc, in a() */
128 #error "port this routine"
132 #endif /* lint || DS_DDICT */
136 * if a() calls nsc_callee(), nsc_callee() returns the
137 * return address in a();
140 #if defined(lint) || defined(DS_DDICT)
150 movq
(%rsp
), %rax
/* callee()'s return pc, in a() */
152 #elif defined(__i386)
153 movl
(%esp
), %eax
/* callee()'s return pc, in a() */
156 #error "port this routine"
160 #endif /* lint || DS_DDICT */
166 * C callable interface to get the current thread pointer.
169 #if defined(lint) || defined(DS_DDICT)
179 movq
%gs
:CPU_THREAD
, %rax
181 #elif defined(__i386)
182 movl
%gs
:CPU_THREAD
,%eax
185 #error "port this routine"
187 SET_SIZE
(nsc_threadp
)
189 #endif /* lint || DS_DDICT */