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 16 .text 17 .align 4 18 .globl __kernel_gettimeofday 19 .type __kernel_gettimeofday,@function 20__kernel_gettimeofday: 21 .cfi_startproc 22 ahi %r15,-16 23 basr %r5,0 240: al %r5,13f-0b(%r5) /* get &_vdso_data */ 251: ltr %r3,%r3 /* check if tz is NULL */ 26 je 2f 27 mvc 0(8,%r3),__VDSO_TIMEZONE(%r5) 282: ltr %r2,%r2 /* check if tv is NULL */ 29 je 10f 30 l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */ 31 tml %r4,0x0001 /* pending update ? loop */ 32 jnz 1b 33 stcke 0(%r15) /* Store TOD clock */ 34 lm %r0,%r1,1(%r15) 35 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ 36 sl %r1,__VDSO_XTIME_STAMP+4(%r5) 37 brc 3,3f 38 ahi %r0,-1 393: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */ 40 st %r0,0(%r15) 41 l %r0,__VDSO_TK_MULT(%r5) 42 ltr %r1,%r1 43 mr %r0,%r0 44 jnm 4f 45 a %r0,__VDSO_TK_MULT(%r5) 464: al %r0,0(%r15) 47 al %r0,__VDSO_XTIME_NSEC(%r5) /* + xtime */ 48 al %r1,__VDSO_XTIME_NSEC+4(%r5) 49 brc 12,5f 50 ahi %r0,1 515: mvc 0(4,%r15),__VDSO_XTIME_SEC+4(%r5) 52 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */ 53 jne 1b 54 l %r4,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */ 55 srdl %r0,0(%r4) /* >> tk->shift */ 56 l %r4,0(%r15) /* get tv_sec from stack */ 57 basr %r5,0 586: ltr %r0,%r0 59 jnz 7f 60 cl %r1,11f-6b(%r5) 61 jl 8f 627: ahi %r4,1 63 sl %r1,11f-6b(%r5) 64 brc 3,6b 65 ahi %r0,-1 66 j 6b 678: st %r4,0(%r2) /* store tv->tv_sec */ 68 ltr %r1,%r1 69 m %r0,12f-6b(%r5) 70 jnm 9f 71 al %r0,12f-6b(%r5) 729: srl %r0,6 73 st %r0,4(%r2) /* store tv->tv_usec */ 7410: slr %r2,%r2 75 ahi %r15,16 76 br %r14 7711: .long 1000000000 7812: .long 274877907 7913: .long _vdso_data - 0b 80 .cfi_endproc 81 .size __kernel_gettimeofday,.-__kernel_gettimeofday 82