gettimeofday.S 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Userland implementation of gettimeofday() for 32 bits processes in a
  3. * s390 kernel for use in the vDSO
  4. *
  5. * Copyright IBM Corp. 2008
  6. * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License (version 2 only)
  10. * as published by the Free Software Foundation.
  11. */
  12. #include <asm/vdso.h>
  13. #include <asm/asm-offsets.h>
  14. #include <asm/unistd.h>
  15. .text
  16. .align 4
  17. .globl __kernel_gettimeofday
  18. .type __kernel_gettimeofday,@function
  19. __kernel_gettimeofday:
  20. .cfi_startproc
  21. ahi %r15,-16
  22. basr %r5,0
  23. 0: al %r5,13f-0b(%r5) /* get &_vdso_data */
  24. 1: ltr %r3,%r3 /* check if tz is NULL */
  25. je 2f
  26. mvc 0(8,%r3),__VDSO_TIMEZONE(%r5)
  27. 2: ltr %r2,%r2 /* check if tv is NULL */
  28. je 10f
  29. l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
  30. tml %r4,0x0001 /* pending update ? loop */
  31. jnz 1b
  32. stcke 0(%r15) /* Store TOD clock */
  33. lm %r0,%r1,1(%r15)
  34. s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
  35. sl %r1,__VDSO_XTIME_STAMP+4(%r5)
  36. brc 3,3f
  37. ahi %r0,-1
  38. 3: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
  39. st %r0,0(%r15)
  40. l %r0,__VDSO_TK_MULT(%r5)
  41. ltr %r1,%r1
  42. mr %r0,%r0
  43. jnm 4f
  44. a %r0,__VDSO_TK_MULT(%r5)
  45. 4: al %r0,0(%r15)
  46. al %r0,__VDSO_XTIME_NSEC(%r5) /* + xtime */
  47. al %r1,__VDSO_XTIME_NSEC+4(%r5)
  48. brc 12,5f
  49. ahi %r0,1
  50. 5: mvc 0(4,%r15),__VDSO_XTIME_SEC+4(%r5)
  51. cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
  52. jne 1b
  53. l %r4,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
  54. srdl %r0,0(%r4) /* >> tk->shift */
  55. l %r4,0(%r15) /* get tv_sec from stack */
  56. basr %r5,0
  57. 6: ltr %r0,%r0
  58. jnz 7f
  59. cl %r1,11f-6b(%r5)
  60. jl 8f
  61. 7: ahi %r4,1
  62. sl %r1,11f-6b(%r5)
  63. brc 3,6b
  64. ahi %r0,-1
  65. j 6b
  66. 8: st %r4,0(%r2) /* store tv->tv_sec */
  67. ltr %r1,%r1
  68. m %r0,12f-6b(%r5)
  69. jnm 9f
  70. al %r0,12f-6b(%r5)
  71. 9: srl %r0,6
  72. st %r0,4(%r2) /* store tv->tv_usec */
  73. 10: slr %r2,%r2
  74. ahi %r15,16
  75. br %r14
  76. 11: .long 1000000000
  77. 12: .long 274877907
  78. 13: .long _vdso_data - 0b
  79. .cfi_endproc
  80. .size __kernel_gettimeofday,.-__kernel_gettimeofday