Greg Watson | 95e9147 | 2003-11-02 17:01:47 +0000 | [diff] [blame] | 1 | /* |
| 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 Reinauer | 6ab43fc | 2005-10-05 18:17:45 +0000 | [diff] [blame^] | 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 23 | * MA 02110-1301 USA |
Greg Watson | 95e9147 | 2003-11-02 17:01:47 +0000 | [diff] [blame] | 24 | */ |
| 25 | #include <ppc_asm.tmpl> |
Greg Watson | 0322115 | 2003-06-09 21:29:23 +0000 | [diff] [blame] | 26 | |
| 27 | .text |
Greg Watson | 95e9147 | 2003-11-02 17:01:47 +0000 | [diff] [blame] | 28 | /* |
| 29 | * unsigned long long _get_ticks(void); |
| 30 | */ |
| 31 | .globl _get_ticks |
| 32 | _get_ticks: |
| 33 | 1: mftbu r3 |
| 34 | mftb r4 |
| 35 | mftbu r5 |
| 36 | cmpw 0,r3,r5 |
| 37 | bne 1b |
Greg Watson | 0322115 | 2003-06-09 21:29:23 +0000 | [diff] [blame] | 38 | blr |
Greg Watson | 95e9147 | 2003-11-02 17:01:47 +0000 | [diff] [blame] | 39 | |
| 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 | |
| 53 | 1: 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 | |