Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / arch / ppc / timebase.S
1 #include "asm/asmdefs.h"
2 #include "asm/processor.h"
3
4 /*
5  * unsigned long long _get_ticks(void);
6  */
7 _GLOBAL(_get_ticks):
8 1:      mftbu   r3
9         mftb    r4
10         mftbu   r5
11         cmpw    0,r3,r5
12         bne     1b
13         blr
14
15 /*
16  * Delay for a number of ticks
17  */
18 _GLOBAL(_wait_ticks):
19         mflr    r8              /* save link register */
20         mr      r7, r3          /* save tick count */
21         bl      BRANCH_LABEL(_get_ticks)       /* Get start time */
22
23         /* Calculate end time */
24         addc    r7, r4, r7      /* Compute end time lower */
25         addze   r6, r3          /*     and end time upper */
26
27 1:      bl      BRANCH_LABEL(_get_ticks)       /* Get current time */
28         subfc   r4, r4, r7      /* Subtract current time from end time */
29         subfe.  r3, r3, r6
30         bge     1b              /* Loop until time expired */
31
32         mtlr    r8              /* restore link register */
33         blr