timex.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. /* Inline functions for clock register access. */
  13. static inline int set_clock(__u64 time)
  14. {
  15. int cc;
  16. asm volatile(
  17. " sck 0(%2)\n"
  18. " ipm %0\n"
  19. " srl %0,28\n"
  20. : "=d" (cc) : "m" (time), "a" (&time) : "cc");
  21. return cc;
  22. }
  23. static inline int store_clock(__u64 *time)
  24. {
  25. int cc;
  26. asm volatile(
  27. " stck 0(%2)\n"
  28. " ipm %0\n"
  29. " srl %0,28\n"
  30. : "=d" (cc), "=m" (*time) : "a" (time) : "cc");
  31. return cc;
  32. }
  33. static inline void set_clock_comparator(__u64 time)
  34. {
  35. asm volatile("sckc 0(%1)" : : "m" (time), "a" (&time));
  36. }
  37. static inline void store_clock_comparator(__u64 *time)
  38. {
  39. asm volatile("stckc 0(%1)" : "=m" (*time) : "a" (time));
  40. }
  41. #define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
  42. typedef unsigned long long cycles_t;
  43. static inline unsigned long long get_clock (void)
  44. {
  45. unsigned long long clk;
  46. #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
  47. asm volatile("stck %0" : "=Q" (clk) : : "cc");
  48. #else /* __GNUC__ */
  49. asm volatile("stck 0(%1)" : "=m" (clk) : "a" (&clk) : "cc");
  50. #endif /* __GNUC__ */
  51. return clk;
  52. }
  53. static inline unsigned long long get_clock_xt(void)
  54. {
  55. unsigned char clk[16];
  56. #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
  57. asm volatile("stcke %0" : "=Q" (clk) : : "cc");
  58. #else /* __GNUC__ */
  59. asm volatile("stcke 0(%1)" : "=m" (clk)
  60. : "a" (clk) : "cc");
  61. #endif /* __GNUC__ */
  62. return *((unsigned long long *)&clk[1]);
  63. }
  64. static inline cycles_t get_cycles(void)
  65. {
  66. return (cycles_t) get_clock() >> 2;
  67. }
  68. int get_sync_clock(unsigned long long *clock);
  69. void init_cpu_timer(void);
  70. unsigned long long monotonic_clock(void);
  71. #endif