| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: tsc.9,v 1.5 2013/11/20 18:13:16 jruoho Exp $ | | 1 | .\" $NetBSD: tsc.9,v 1.6 2015/05/04 08:15:21 pgoyette Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 2011 The NetBSD Foundation, Inc. | | 3 | .\" Copyright (c) 2011 The NetBSD Foundation, Inc. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | | 6 | .\" This code is derived from software contributed to The NetBSD Foundation |
7 | .\" by Jukka Ruohonen. | | 7 | .\" by Jukka Ruohonen. |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | .\" | | 17 | .\" |
18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | .\" POSSIBILITY OF SUCH DAMAGE. | | 28 | .\" POSSIBILITY OF SUCH DAMAGE. |
29 | .\" | | 29 | .\" |
30 | .Dd November 20, 2013 | | 30 | .Dd April 4, 2015 |
31 | .Dt TSC 9 x86 | | 31 | .Dt TSC 9 x86 |
32 | .Os | | 32 | .Os |
33 | .Sh NAME | | 33 | .Sh NAME |
34 | .Nm tsc | | 34 | .Nm tsc |
35 | .Nd Time Stamp Counter | | 35 | .Nd Time Stamp Counter |
36 | .Sh SYNOPSIS | | 36 | .Sh SYNOPSIS |
37 | .In x86/x86/tsc.h | | 37 | .In x86/x86/tsc.h |
38 | .Ft uint64_t | | 38 | .Ft uint64_t |
39 | .Fn rdtsc "void" | | 39 | .Fn rdtsc "void" |
40 | .Ft void | | 40 | .Ft void |
41 | .Fn tsc_tc_init "void" | | 41 | .Fn tsc_tc_init "void" |
42 | .Ft void | | 42 | .Ft void |
43 | .Fn tsc_sync_ap "struct cpu_info *ci" | | 43 | .Fn tsc_sync_ap "struct cpu_info *ci" |
| @@ -83,44 +83,44 @@ Care should be however taken in implemen | | | @@ -83,44 +83,44 @@ Care should be however taken in implemen |
83 | .It Fn rdtsc "" | | 83 | .It Fn rdtsc "" |
84 | The | | 84 | The |
85 | .Fn rdtsc | | 85 | .Fn rdtsc |
86 | function returns the value read from | | 86 | function returns the value read from |
87 | .Dv RDTSC . | | 87 | .Dv RDTSC . |
88 | .It Fn tsc_tc_init "" | | 88 | .It Fn tsc_tc_init "" |
89 | The | | 89 | The |
90 | .Fn tsc_tc_init | | 90 | .Fn tsc_tc_init |
91 | function initializes the | | 91 | function initializes the |
92 | .Tn TSC | | 92 | .Tn TSC |
93 | as a | | 93 | as a |
94 | .Xr timecounter 9 . | | 94 | .Xr timecounter 9 . |
95 | The function is called early in the boot process when the processors attach. | | 95 | The function is called early in the boot process when the processors attach. |
96 | .It Fn tsc_sync_ap "ci" | | 96 | .It Fn tsc_sync_bp "ci" |
97 | The | | 97 | The |
98 | .Fn tsc_sync_ap | | 98 | .Fn tsc_sync_bp |
99 | function synchronizes the counter for the boot processor | | 99 | function synchronizes the counter for the boot processor |
100 | .Pq Tn BP . | | 100 | .Pq Tn BP . |
101 | The supplied | | 101 | The supplied |
102 | .Fa ci | | 102 | .Fa ci |
103 | must refer to the | | 103 | must refer to the |
104 | .Tn BP | | 104 | .Tn BP |
105 | itself. | | 105 | itself. |
106 | The | | 106 | The |
107 | .Nm | | 107 | .Nm |
108 | interface takes internally care of such issues as out-of-order execution, | | 108 | interface takes internally care of such issues as out-of-order execution, |
109 | where instructions are not necessarily performed in the order of execution, | | 109 | where instructions are not necessarily performed in the order of execution, |
110 | possibly causing a misleading cycle count. | | 110 | possibly causing a misleading cycle count. |
111 | .It Fn tsc_sync_bp "ci" | | 111 | .It Fn tsc_sync_ap "ci" |
112 | The | | 112 | The |
113 | .Fn tsc_sync_bp | | 113 | .Fn tsc_sync_ap |
114 | function synchronize the counter for the application processor | | 114 | function synchronize the counter for the application processor |
115 | .Fa ci . | | 115 | .Fa ci . |
116 | Interrupts must be off at machine-level when the function is called. | | 116 | Interrupts must be off at machine-level when the function is called. |
117 | .Pp | | 117 | .Pp |
118 | It is necessary to call both | | 118 | It is necessary to call both |
119 | .Fn tsc_sync_ap | | 119 | .Fn tsc_sync_ap |
120 | and | | 120 | and |
121 | .Fn tsc_sync_bp | | 121 | .Fn tsc_sync_bp |
122 | during the boot, but additional synchronization | | 122 | during the boot, but additional synchronization |
123 | may be required also during runtime. | | 123 | may be required also during runtime. |
124 | As an example, the | | 124 | As an example, the |
125 | .Tn TSC | | 125 | .Tn TSC |
126 | needs to be synchronized for all processors when the system resumes from an | | 126 | needs to be synchronized for all processors when the system resumes from an |