blob: 9e0b2a9290222d41bee031f0d4e5afe208f1323c [file] [log] [blame]
Greg Watson95e91472003-11-02 17:01:47 +00001/*
2 * (C) Copyright 2000, 2001
3 * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
4 * base on code by
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
Stefan Reinauer6ab43fc2005-10-05 18:17:45 +000022 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
23 * MA 02110-1301 USA
Greg Watson95e91472003-11-02 17:01:47 +000024 */
25#include <ppc_asm.tmpl>
Greg Watson03221152003-06-09 21:29:23 +000026
27 .text
Greg Watson95e91472003-11-02 17:01:47 +000028/*
29 * unsigned long long _get_ticks(void);
30 */
31 .globl _get_ticks
32_get_ticks:
331: mftbu r3
34 mftb r4
35 mftbu r5
36 cmpw 0,r3,r5
37 bne 1b
Greg Watson03221152003-06-09 21:29:23 +000038 blr
Greg Watson95e91472003-11-02 17:01:47 +000039
40/*
41 * Delay for a number of ticks
42 */
43 .globl _wait_ticks
44_wait_ticks:
45 mflr r8 /* save link register */
46 mr r7, r3 /* save tick count */
47 bl _get_ticks /* Get start time */
48
49 /* Calculate end time */
50 addc r7, r4, r7 /* Compute end time lower */
51 addze r6, r3 /* and end time upper */
52
531: bl _get_ticks /* Get current time */
54 subfc r4, r4, r7 /* Subtract current time from end time */
55 subfe. r3, r3, r6
56 bge 1b /* Loop until time expired */
57
58 mtlr r8 /* restore link register */
59 blr
60