gettimeofday.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Userland implementation of gettimeofday() for 64 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. larl %r5,_vdso_data
  22. 0: ltgr %r3,%r3 /* check if tz is NULL */
  23. je 1f
  24. mvc 0(8,%r3),__VDSO_TIMEZONE(%r5)
  25. 1: ltgr %r2,%r2 /* check if tv is NULL */
  26. je 4f
  27. lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
  28. tmll %r4,0x0001 /* pending update ? loop */
  29. jnz 0b
  30. stck 48(%r15) /* Store TOD clock */
  31. lg %r1,48(%r15)
  32. sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
  33. msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */
  34. alg %r1,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */
  35. lg %r0,__VDSO_XTIME_SEC(%r5) /* tk->xtime_sec */
  36. clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
  37. jne 0b
  38. lgf %r5,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
  39. srlg %r1,%r1,0(%r5) /* >> tk->shift */
  40. larl %r5,5f
  41. 2: clg %r1,0(%r5)
  42. jl 3f
  43. slg %r1,0(%r5)
  44. aghi %r0,1
  45. j 2b
  46. 3: stg %r0,0(%r2) /* store tv->tv_sec */
  47. slgr %r0,%r0 /* tv_nsec -> tv_usec */
  48. ml %r0,8(%r5)
  49. srlg %r0,%r0,6
  50. stg %r0,8(%r2) /* store tv->tv_usec */
  51. 4: lghi %r2,0
  52. br %r14
  53. 5: .quad 1000000000
  54. .long 274877907
  55. .cfi_endproc
  56. .size __kernel_gettimeofday,.-__kernel_gettimeofday