timex.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * include/asm-s390/timex.h
  3. *
  4. * S390 version
  5. * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
  6. *
  7. * Derived from "include/asm-i386/timex.h"
  8. * Copyright (C) 1992, Linus Torvalds
  9. */
  10. #ifndef _ASM_S390_TIMEX_H
  11. #define _ASM_S390_TIMEX_H
  12. /* The value of the TOD clock for 1.1.1970. */
  13. #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
  14. /* Inline functions for clock register access. */
  15. static inline int set_clock(__u64 time)
  16. {
  17. int cc;
  18. asm volatile(
  19. " sck 0(%2)\n"
  20. " ipm %0\n"
  21. " srl %0,28\n"
  22. : "=d" (cc) : "m" (time), "a" (&time) : "cc");
  23. return cc;
  24. }
  25. static inline int store_clock(__u64 *time)
  26. {
  27. int cc;
  28. asm volatile(
  29. " stck 0(%2)\n"
  30. " ipm %0\n"
  31. " srl %0,28\n"
  32. : "=d" (cc), "=m" (*time) : "a" (time) : "cc");
  33. return cc;
  34. }
  35. static inline void set_clock_comparator(__u64 time)
  36. {
  37. asm volatile("sckc 0(%1)" : : "m" (time), "a" (&time));
  38. }
  39. static inline void store_clock_comparator(__u64 *time)
  40. {
  41. asm volatile("stckc 0(%1)" : "=m" (*time) : "a" (time));
  42. }
  43. #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
  44. typedef unsigned long long cycles_t;
  45. static inline unsigned long long get_clock (void)
  46. {
  47. unsigned long long clk;
  48. #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
  49. asm volatile("stck %0" : "=Q" (clk) : : "cc");
  50. #else /* __GNUC__ */
  51. asm volatile("stck 0(%1)" : "=m" (clk) : "a" (&clk) : "cc");
  52. #endif /* __GNUC__ */
  53. return clk;
  54. }
  55. static inline unsigned long long get_clock_xt(void)
  56. {
  57. unsigned char clk[16];
  58. #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
  59. asm volatile("stcke %0" : "=Q" (clk) : : "cc");
  60. #else /* __GNUC__ */
  61. asm volatile("stcke 0(%1)" : "=m" (clk)
  62. : "a" (clk) : "cc");
  63. #endif /* __GNUC__ */
  64. return *((unsigned long long *)&clk[1]);
  65. }
  66. static inline cycles_t get_cycles(void)
  67. {
  68. return (cycles_t) get_clock() >> 2;
  69. }
  70. int get_sync_clock(unsigned long long *clock);
  71. void init_cpu_timer(void);
  72. unsigned long long monotonic_clock(void);
  73. extern u64 sched_clock_base_cc;
  74. #endif