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