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 #include <sys/asm_linkage.h>
29 #include <sys/asm_misc.h>
30 #include <sys/regset.h>
31 #include <sys/psw.h>
32
33 #if defined(__lint)
34
35 #include <sys/types.h>
36 #include <sys/thread.h>
37 #include <sys/systm.h>
38 #include <sys/lgrp.h>
39
40 #else /* __lint */
41
42 #include <sys/pcb.h>
43 #include <sys/trap.h>
44 #include <sys/ftrace.h>
45 #include <sys/traptrace.h>
46 #include <sys/clock.h>
47 #include <sys/panic.h>
84 }
85
86 #else /* __lint */
87
88 /*
89 * XX64: We are assuming that libc continues to expect the 64-bit value being
90 * returned in %edx:%eax. We further assume that it is safe to leave
91 * the top 32-bit intact in %rax as they will be ignored by libc. In
92 * other words, if the 64-bit value is already in %rax, while we manually
93 * manufacture a 64-bit value in %edx:%eax by setting %edx to be the high
94 * 32 bits of %rax, we don't zero them out in %rax.
95 * The following amd64 versions will need to be changed if the above
96 * assumptions are not true.
97 */
98
99 #if defined(__amd64)
100
101 .globl gethrtimef
102 ENTRY_NP(get_hrtime)
103 FAST_INTR_PUSH
104 call *gethrtimef(%rip)
105 movq %rax, %rdx
106 shrq $32, %rdx /* high 32-bit in %edx */
107 FAST_INTR_POP
108 FAST_INTR_RETURN
109 SET_SIZE(get_hrtime)
110
111 #elif defined(__i386)
112
113 .globl gethrtimef
114 ENTRY_NP(get_hrtime)
115 FAST_INTR_PUSH
116 call *gethrtimef
117 FAST_INTR_POP
118 FAST_INTR_RETURN
119 SET_SIZE(get_hrtime)
120
121 #endif /* __i386 */
122
123 #if defined(__amd64)
124
125 .globl gethrestimef
126 ENTRY_NP(get_hrestime)
127 FAST_INTR_PUSH
128 subq $TIMESPEC_SIZE, %rsp
129 movq %rsp, %rdi
130 call *gethrestimef(%rip)
131 movl (%rsp), %eax
132 movl CLONGSIZE(%rsp), %edx
133 addq $TIMESPEC_SIZE, %rsp
134 FAST_INTR_POP
135 FAST_INTR_RETURN
136 SET_SIZE(get_hrestime)
137
138 #elif defined(__i386)
139
140 .globl gethrestimef
141 ENTRY_NP(get_hrestime)
142 FAST_INTR_PUSH
143 subl $TIMESPEC_SIZE, %esp
144 pushl %esp
145 call *gethrestimef
146 movl _CONST(4 + 0)(%esp), %eax
147 movl _CONST(4 + CLONGSIZE)(%esp), %edx
148 addl $_CONST(4 + TIMESPEC_SIZE), %esp
149 FAST_INTR_POP
150 FAST_INTR_RETURN
|
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 * Copyright 2019 Joyent, Inc.
25 */
26
27 #include <sys/asm_linkage.h>
28 #include <sys/asm_misc.h>
29 #include <sys/regset.h>
30 #include <sys/psw.h>
31
32 #if defined(__lint)
33
34 #include <sys/types.h>
35 #include <sys/thread.h>
36 #include <sys/systm.h>
37 #include <sys/lgrp.h>
38
39 #else /* __lint */
40
41 #include <sys/pcb.h>
42 #include <sys/trap.h>
43 #include <sys/ftrace.h>
44 #include <sys/traptrace.h>
45 #include <sys/clock.h>
46 #include <sys/panic.h>
83 }
84
85 #else /* __lint */
86
87 /*
88 * XX64: We are assuming that libc continues to expect the 64-bit value being
89 * returned in %edx:%eax. We further assume that it is safe to leave
90 * the top 32-bit intact in %rax as they will be ignored by libc. In
91 * other words, if the 64-bit value is already in %rax, while we manually
92 * manufacture a 64-bit value in %edx:%eax by setting %edx to be the high
93 * 32 bits of %rax, we don't zero them out in %rax.
94 * The following amd64 versions will need to be changed if the above
95 * assumptions are not true.
96 */
97
98 #if defined(__amd64)
99
100 .globl gethrtimef
101 ENTRY_NP(get_hrtime)
102 FAST_INTR_PUSH
103 movq gethrtimef(%rip), %rax
104 INDIRECT_CALL_REG(rax)
105 movq %rax, %rdx
106 shrq $32, %rdx /* high 32-bit in %edx */
107 FAST_INTR_POP
108 FAST_INTR_RETURN
109 SET_SIZE(get_hrtime)
110
111 #elif defined(__i386)
112
113 .globl gethrtimef
114 ENTRY_NP(get_hrtime)
115 FAST_INTR_PUSH
116 call *gethrtimef
117 FAST_INTR_POP
118 FAST_INTR_RETURN
119 SET_SIZE(get_hrtime)
120
121 #endif /* __i386 */
122
123 #if defined(__amd64)
124
125 .globl gethrestimef
126 ENTRY_NP(get_hrestime)
127 FAST_INTR_PUSH
128 subq $TIMESPEC_SIZE, %rsp
129 movq %rsp, %rdi
130 movq gethrestimef(%rip), %rax
131 INDIRECT_CALL_REG(rax)
132 movl (%rsp), %eax
133 movl CLONGSIZE(%rsp), %edx
134 addq $TIMESPEC_SIZE, %rsp
135 FAST_INTR_POP
136 FAST_INTR_RETURN
137 SET_SIZE(get_hrestime)
138
139 #elif defined(__i386)
140
141 .globl gethrestimef
142 ENTRY_NP(get_hrestime)
143 FAST_INTR_PUSH
144 subl $TIMESPEC_SIZE, %esp
145 pushl %esp
146 call *gethrestimef
147 movl _CONST(4 + 0)(%esp), %eax
148 movl _CONST(4 + CLONGSIZE)(%esp), %edx
149 addl $_CONST(4 + TIMESPEC_SIZE), %esp
150 FAST_INTR_POP
151 FAST_INTR_RETURN
|