~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/include/asm/timex.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/s390/include/asm/timex.h (Architecture sparc) and /arch/alpha/include/asm-alpha/timex.h (Architecture alpha)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 /*                                                
  3  *  S390 version                                  
  4  *    Copyright IBM Corp. 1999                    
  5  *                                                
  6  *  Derived from "include/asm-i386/timex.h"       
  7  *    Copyright (C) 1992, Linus Torvalds          
  8  */                                               
  9                                                   
 10 #ifndef _ASM_S390_TIMEX_H                         
 11 #define _ASM_S390_TIMEX_H                         
 12                                                   
 13 #include <linux/preempt.h>                        
 14 #include <linux/time64.h>                         
 15 #include <asm/lowcore.h>                          
 16                                                   
 17 /* The value of the TOD clock for 1.1.1970. */    
 18 #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL      
 19                                                   
 20 extern u64 clock_comparator_max;                  
 21                                                   
 22 union tod_clock {                                 
 23         __uint128_t val;                          
 24         struct {                                  
 25                 __uint128_t ei  :  8; /* epoch    
 26                 __uint128_t tod : 64; /* bits     
 27                 __uint128_t     : 40;             
 28                 __uint128_t pf  : 16; /* progr    
 29         };                                        
 30         struct {                                  
 31                 __uint128_t eitod : 72; /* epo    
 32                 __uint128_t       : 56;           
 33         };                                        
 34         struct {                                  
 35                 __uint128_t us  : 60; /* micro    
 36                 __uint128_t sus : 12; /* sub-m    
 37                 __uint128_t     : 56;             
 38         };                                        
 39 } __packed;                                       
 40                                                   
 41 /* Inline functions for clock register access.    
 42 static inline int set_tod_clock(__u64 time)       
 43 {                                                 
 44         int cc;                                   
 45                                                   
 46         asm volatile(                             
 47                 "   sck   %1\n"                   
 48                 "   ipm   %0\n"                   
 49                 "   srl   %0,28\n"                
 50                 : "=d" (cc) : "Q" (time) : "cc    
 51         return cc;                                
 52 }                                                 
 53                                                   
 54 static inline int store_tod_clock_ext_cc(union    
 55 {                                                 
 56         int cc;                                   
 57                                                   
 58         asm volatile(                             
 59                 "   stcke  %1\n"                  
 60                 "   ipm   %0\n"                   
 61                 "   srl   %0,28\n"                
 62                 : "=d" (cc), "=Q" (*clk) : : "    
 63         return cc;                                
 64 }                                                 
 65                                                   
 66 static __always_inline void store_tod_clock_ex    
 67 {                                                 
 68         asm volatile("stcke %0" : "=Q" (*tod)     
 69 }                                                 
 70                                                   
 71 static inline void set_clock_comparator(__u64     
 72 {                                                 
 73         asm volatile("sckc %0" : : "Q" (time))    
 74 }                                                 
 75                                                   
 76 static inline void set_tod_programmable_field(    
 77 {                                                 
 78         asm volatile(                             
 79                 "       lgr     0,%[val]\n"       
 80                 "       sckpf\n"                  
 81                 :                                 
 82                 : [val] "d" ((unsigned long)va    
 83                 : "");                            
 84 }                                                 
 85                                                   
 86 void clock_comparator_work(void);                 
 87                                                   
 88 void __init time_early_init(void);                
 89                                                   
 90 extern unsigned char ptff_function_mask[16];      
 91                                                   
 92 /* Function codes for the ptff instruction. */    
 93 #define PTFF_QAF        0x00    /* query avail    
 94 #define PTFF_QTO        0x01    /* query tod o    
 95 #define PTFF_QSI        0x02    /* query steer    
 96 #define PTFF_QUI        0x04    /* query UTC i    
 97 #define PTFF_ATO        0x40    /* adjust tod     
 98 #define PTFF_STO        0x41    /* set tod off    
 99 #define PTFF_SFS        0x42    /* set fine st    
100 #define PTFF_SGS        0x43    /* set gross s    
101                                                   
102 /* Query TOD offset result */                     
103 struct ptff_qto {                                 
104         unsigned long physical_clock;             
105         unsigned long tod_offset;                 
106         unsigned long logical_tod_offset;         
107         unsigned long tod_epoch_difference;       
108 } __packed;                                       
109                                                   
110 static inline int ptff_query(unsigned int nr)     
111 {                                                 
112         unsigned char *ptr;                       
113                                                   
114         ptr = ptff_function_mask + (nr >> 3);     
115         return (*ptr & (0x80 >> (nr & 7))) !=     
116 }                                                 
117                                                   
118 /* Query UTC information result */                
119 struct ptff_qui {                                 
120         unsigned int tm : 2;                      
121         unsigned int ts : 2;                      
122         unsigned int : 28;                        
123         unsigned int pad_0x04;                    
124         unsigned long leap_event;                 
125         short old_leap;                           
126         short new_leap;                           
127         unsigned int pad_0x14;                    
128         unsigned long prt[5];                     
129         unsigned long cst[3];                     
130         unsigned int skew;                        
131         unsigned int pad_0x5c[41];                
132 } __packed;                                       
133                                                   
134 /*                                                
135  * ptff - Perform timing facility function        
136  * @ptff_block: Pointer to ptff parameter bloc    
137  * @len: Length of parameter block                
138  * @func: Function code                           
139  * Returns: Condition code (0 on success)         
140  */                                               
141 #define ptff(ptff_block, len, func)               
142 ({                                                
143         struct addrtype { char _[len]; };         
144         unsigned int reg0 = func;                 
145         unsigned long reg1 = (unsigned long)(p    
146         int rc;                                   
147                                                   
148         asm volatile(                             
149                 "       lgr     0,%[reg0]\n"      
150                 "       lgr     1,%[reg1]\n"      
151                 "       ptff\n"                   
152                 "       ipm     %[rc]\n"          
153                 "       srl     %[rc],28\n"       
154                 : [rc] "=&d" (rc), "+m" (*(str    
155                 : [reg0] "d" (reg0), [reg1] "d    
156                 : "cc", "", "1");                 
157         rc;                                       
158 })                                                
159                                                   
160 static inline unsigned long local_tick_disable    
161 {                                                 
162         unsigned long old;                        
163                                                   
164         old = get_lowcore()->clock_comparator;    
165         get_lowcore()->clock_comparator = cloc    
166         set_clock_comparator(get_lowcore()->cl    
167         return old;                               
168 }                                                 
169                                                   
170 static inline void local_tick_enable(unsigned     
171 {                                                 
172         get_lowcore()->clock_comparator = comp    
173         set_clock_comparator(get_lowcore()->cl    
174 }                                                 
175                                                   
176 #define CLOCK_TICK_RATE         1193180 /* Und    
177                                                   
178 typedef unsigned long cycles_t;                   
179                                                   
180 static __always_inline unsigned long get_tod_c    
181 {                                                 
182         union tod_clock clk;                      
183                                                   
184         store_tod_clock_ext(&clk);                
185         return clk.tod;                           
186 }                                                 
187                                                   
188 static inline unsigned long get_tod_clock_fast    
189 {                                                 
190         unsigned long clk;                        
191                                                   
192         asm volatile("stckf %0" : "=Q" (clk) :    
193         return clk;                               
194 }                                                 
195                                                   
196 static inline cycles_t get_cycles(void)           
197 {                                                 
198         return (cycles_t) get_tod_clock() >> 2    
199 }                                                 
200 #define get_cycles get_cycles                     
201                                                   
202 int get_phys_clock(unsigned long *clock);         
203 void init_cpu_timer(void);                        
204                                                   
205 extern union tod_clock tod_clock_base;            
206                                                   
207 static __always_inline unsigned long __get_tod    
208 {                                                 
209         return get_tod_clock() - tod_clock_bas    
210 }                                                 
211                                                   
212 /**                                               
213  * get_clock_monotonic - returns current time     
214  *                                                
215  * The clock and tod_clock_base get changed vi    
216  * Therefore preemption must be disabled, othe    
217  * value is not guaranteed to be monotonic.       
218  */                                               
219 static inline unsigned long get_tod_clock_mono    
220 {                                                 
221         unsigned long tod;                        
222                                                   
223         preempt_disable_notrace();                
224         tod = __get_tod_clock_monotonic();        
225         preempt_enable_notrace();                 
226         return tod;                               
227 }                                                 
228                                                   
229 /**                                               
230  * tod_to_ns - convert a TOD format value to n    
231  * @todval: to be converted TOD format value      
232  * Returns: number of nanoseconds that corresp    
233  *                                                
234  * Converting a 64 Bit TOD format value to nan    
235  * must be divided by 4.096. In order to achie    
236  * and divide by 512:                             
237  *                                                
238  *    ns = (todval * 125) >> 9;                   
239  *                                                
240  * In order to avoid an overflow with the mult    
241  * With a split todval == 2^9 * th + tl (th up    
242  * we end up with                                 
243  *                                                
244  *    ns = ((2^9 * th + tl) * 125 ) >> 9;         
245  * -> ns = (th * 125) + ((tl * 125) >> 9);        
246  *                                                
247  */                                               
248 static __always_inline unsigned long tod_to_ns    
249 {                                                 
250         return ((todval >> 9) * 125) + (((todv    
251 }                                                 
252                                                   
253 /**                                               
254  * tod_after - compare two 64 bit TOD values      
255  * @a: first 64 bit TOD timestamp                 
256  * @b: second 64 bit TOD timestamp                
257  *                                                
258  * Returns: true if a is later than b             
259  */                                               
260 static inline int tod_after(unsigned long a, u    
261 {                                                 
262         if (MACHINE_HAS_SCC)                      
263                 return (long) a > (long) b;       
264         return a > b;                             
265 }                                                 
266                                                   
267 /**                                               
268  * tod_after_eq - compare two 64 bit TOD value    
269  * @a: first 64 bit TOD timestamp                 
270  * @b: second 64 bit TOD timestamp                
271  *                                                
272  * Returns: true if a is later than b             
273  */                                               
274 static inline int tod_after_eq(unsigned long a    
275 {                                                 
276         if (MACHINE_HAS_SCC)                      
277                 return (long) a >= (long) b;      
278         return a >= b;                            
279 }                                                 
280                                                   
281 #endif                                            
282                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php