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 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <sys/asm_linkage.h>
29 #include <sys/asm_misc.h>
30 #include <sys/regset.h>
35 #include <sys/types.h>
36 #include <sys/thread.h>
37 #include <sys/systm.h>
44 #include <sys/ftrace.h>
45 #include <sys/traptrace.h>
46 #include <sys/clock.h>
47 #include <sys/panic.h>
48 #include <sys/privregs.h>
66 gethrestime
((timespec_t
*)&ts
);
73 klwp_t
*lwp
= ttolwp
(curthread
);
74 struct mstate
*ms
= &lwp-
>lwp_mstate;
76 return
(gethrtime
() - ms-
>ms_state_start
+ ms-
>ms_acct
[LMS_USER
]);
82 return
(((uint64_t
)(curthread-
>t_lpl-
>lpl_lgrpid
) << 32) |
83 curthread-
>t_cpu-
>cpu_id
);
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.
104 call
*gethrtimef
(%rip
)
106 shrq $
32, %rdx
/* high 32-bit in %edx */
111 #elif defined(__i386)
126 ENTRY_NP
(get_hrestime
)
128 subq $TIMESPEC_SIZE
, %rsp
130 call
*gethrestimef
(%rip
)
132 movl CLONGSIZE
(%rsp
), %edx
133 addq $TIMESPEC_SIZE
, %rsp
136 SET_SIZE
(get_hrestime
)
138 #elif defined(__i386)
141 ENTRY_NP
(get_hrestime
)
143 subl $TIMESPEC_SIZE
, %esp
146 movl _CONST
(4 + 0)(%esp
), %eax
147 movl _CONST
(4 + CLONGSIZE
)(%esp
), %edx
148 addl $_CONST
(4 + TIMESPEC_SIZE
), %esp
151 SET_SIZE
(get_hrestime
)
159 call gethrtime_unscaled
/* get time since boot */
160 movq
%gs
:CPU_LWP
, %rcx
/* current lwp */
161 subq LWP_MS_STATE_START
(%rcx
), %rax
/* - ms->ms_state_start */
162 addq LWP_ACCT_USER
(%rcx
), %rax
/* add ms->ms_acct[LMS_USER] */
170 shrq $
32, %rdx
/* high 32-bit in %rdx */
175 #elif defined(__i386)
179 call gethrtime_unscaled
/* get time since boot */
180 movl
%gs
:CPU_LWP
, %ecx
/* current lwp */
181 subl LWP_MS_STATE_START
(%ecx
), %eax
/* - ms->ms_state_start */
182 sbbl LWP_MS_STATE_START+
4(%ecx
), %edx
183 addl LWP_ACCT_USER
(%ecx
), %eax
/* add ms->ms_acct[LMS_USER] */
184 adcl LWP_ACCT_USER+
4(%ecx
), %edx
205 movq
%gs
:CPU_THREAD
, %rcx
206 movq T_LPL
(%rcx
), %rcx
207 movl LPL_LGRPID
(%rcx
), %edx
208 movl
%gs
:CPU_ID
, %eax
213 #elif defined(__i386)
217 movl
%gs
:CPU_THREAD
, %ecx
218 movl T_LPL
(%ecx
), %ecx
219 movl LPL_LGRPID
(%ecx
), %edx
220 movl
%gs
:CPU_ID
, %eax