1
2
3
4
5
6
7
8
9 #include <asm/processor.h>
10 #include <asm/ppc_asm.h>
11 #include <asm/vdso.h>
12 #include <asm/asm-offsets.h>
13 #include <asm/unistd.h>
14
15 .text
16
17
18
19
20
21
22 V_FUNCTION_BEGIN(__kernel_gettimeofday)
23 .cfi_startproc
24 mflr r12
25 .cfi_register lr,r12
26
27 mr r11,r3
28 mr r10,r4
29 bl V_LOCAL_FUNC(__get_datapage)
30 cmpldi r11,0
31 beq 2f
32 lis r7,1000000@ha
33 addi r7,r7,1000000@l
34 bl V_LOCAL_FUNC(__do_get_tspec)
35 std r4,TVAL64_TV_SEC(r11)
36 std r5,TVAL64_TV_USEC(r11)
37 2: cmpldi r10,0
38 beq 1f
39 lwz r4,CFG_TZ_MINUTEWEST(r3)
40 lwz r5,CFG_TZ_DSTTIME(r3)
41 stw r4,TZONE_TZ_MINWEST(r10)
42 stw r5,TZONE_TZ_DSTTIME(r10)
43 1: mtlr r12
44 crclr cr0*4+so
45 li r3,0
46 blr
47 .cfi_endproc
48 V_FUNCTION_END(__kernel_gettimeofday)
49
50
51
52
53
54
55
56
57 V_FUNCTION_BEGIN(__kernel_clock_gettime)
58 .cfi_startproc
59
60 cmpwi cr0,r3,CLOCK_REALTIME
61 cmpwi cr1,r3,CLOCK_MONOTONIC
62 cror cr0*4+eq,cr0*4+eq,cr1*4+eq
63
64 cmpwi cr5,r3,CLOCK_REALTIME_COARSE
65 cmpwi cr6,r3,CLOCK_MONOTONIC_COARSE
66 cror cr5*4+eq,cr5*4+eq,cr6*4+eq
67
68 cror cr0*4+eq,cr0*4+eq,cr5*4+eq
69 bne cr0,99f
70
71 mflr r12
72 .cfi_register lr,r12
73 mr r11,r4
74 bl V_LOCAL_FUNC(__get_datapage)
75 lis r7,NSEC_PER_SEC@h
76 ori r7,r7,NSEC_PER_SEC@l
77 beq cr5,70f
78 50: bl V_LOCAL_FUNC(__do_get_tspec)
79 bne cr1,80f
80
81
82
83
84
85
86
87
88
89
90
91 ld r6,WTOM_CLOCK_SEC(r3)
92 lwa r9,WTOM_CLOCK_NSEC(r3)
93
94
95
96
97 or r0,r6,r9
98 xor r0,r0,r0
99 add r3,r3,r0
100 ld r0,CFG_TB_UPDATE_COUNT(r3)
101 cmpld cr0,r0,r8
102 bne- 50b
103 b 78f
104
105
106
107
108
109
110 70: ld r8,CFG_TB_UPDATE_COUNT(r3)
111 andi. r0,r8,1
112 bne- 70b
113 add r3,r3,r0
114
115
116
117
118
119 ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
120 ld r5,STAMP_XTIME+TSPC64_TV_NSEC(r3)
121 bne cr6,75f
122
123
124 ld r6,WTOM_CLOCK_SEC(r3)
125 lwa r9,WTOM_CLOCK_NSEC(r3)
126
127
128 or r0,r6,r9
129 75: or r0,r0,r4
130 or r0,r0,r5
131 xor r0,r0,r0
132 add r3,r3,r0
133 ld r0,CFG_TB_UPDATE_COUNT(r3)
134 cmpld cr0,r0,r8
135 bne- 70b
136
137
138
139
140
141 bne cr6,80f
142
143
144 78: add r4,r4,r6
145 add r5,r5,r9
146 cmpd cr0,r5,r7
147 cmpdi cr1,r5,0
148 blt 79f
149 subf r5,r7,r5
150 addi r4,r4,1
151 79: bge cr1,80f
152 addi r4,r4,-1
153 add r5,r5,r7
154
155 80: std r4,TSPC64_TV_SEC(r11)
156 std r5,TSPC64_TV_NSEC(r11)
157
158 mtlr r12
159 crclr cr0*4+so
160 li r3,0
161 blr
162
163
164
165
166 99:
167 li r0,__NR_clock_gettime
168 .cfi_restore lr
169 sc
170 blr
171 .cfi_endproc
172 V_FUNCTION_END(__kernel_clock_gettime)
173
174
175
176
177
178
179
180
181 V_FUNCTION_BEGIN(__kernel_clock_getres)
182 .cfi_startproc
183
184 cmpwi cr0,r3,CLOCK_REALTIME
185 cmpwi cr1,r3,CLOCK_MONOTONIC
186 cror cr0*4+eq,cr0*4+eq,cr1*4+eq
187 bne cr0,99f
188
189 mflr r12
190 .cfi_register lr,r12
191 bl V_LOCAL_FUNC(__get_datapage)
192 lwz r5, CLOCK_HRTIMER_RES(r3)
193 mtlr r12
194 li r3,0
195 cmpldi cr0,r4,0
196 crclr cr0*4+so
197 beqlr
198 std r3,TSPC64_TV_SEC(r4)
199 std r5,TSPC64_TV_NSEC(r4)
200 blr
201
202
203
204
205 99:
206 li r0,__NR_clock_getres
207 sc
208 blr
209 .cfi_endproc
210 V_FUNCTION_END(__kernel_clock_getres)
211
212
213
214
215
216
217
218 V_FUNCTION_BEGIN(__kernel_time)
219 .cfi_startproc
220 mflr r12
221 .cfi_register lr,r12
222
223 mr r11,r3
224 bl V_LOCAL_FUNC(__get_datapage)
225
226 ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
227
228 cmpldi r11,0
229 beq 2f
230 std r4,0(r11)
231 2: mtlr r12
232 crclr cr0*4+so
233 mr r3,r4
234 blr
235 .cfi_endproc
236 V_FUNCTION_END(__kernel_time)
237
238
239
240
241
242
243
244
245
246
247
248
249 V_FUNCTION_BEGIN(__do_get_tspec)
250 .cfi_startproc
251
252 1: ld r8,CFG_TB_UPDATE_COUNT(r3)
253 andi. r0,r8,1
254 bne- 1b
255 xor r0,r8,r8
256 add r3,r3,r0
257
258
259
260
261 MFTB(r6)
262 ld r9,CFG_TB_ORIG_STAMP(r3)
263 subf r6,r9,r6
264
265
266 ld r5,CFG_TB_TO_XS(r3)
267 sldi r6,r6,12
268 mulhdu r6,r6,r5
269
270
271 ld r4,STAMP_XTIME+TSPC64_TV_SEC(r3)
272 lwz r5,STAMP_SEC_FRAC(r3)
273 or r0,r4,r5
274 or r0,r0,r6
275 xor r0,r0,r0
276 add r3,r3,r0
277 ld r0,CFG_TB_UPDATE_COUNT(r3)
278 cmpld r0,r8
279 bne- 1b
280
281
282 add r6,r6,r5
283 mulhwu r5,r6,r7
284 srdi r6,r6,32
285 clrldi r5,r5,32
286 add r4,r4,r6
287 blr
288 .cfi_endproc
289 V_FUNCTION_END(__do_get_tspec)