2 BootMii - a Free Software replacement for the Nintendo/BroadOn bootloader.
5 Copyright (C) 2008 Segher Boessenkool <segher@kernel.crashing.org>
7 # This code is licensed to you under the terms of the GNU GPL, version 2;
8 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
11 #include "bootmii_ppc.h"
13 // Timebase frequency is bus frequency / 4. Ignore roundoff, this
14 // doesn't have to be very accurate.
15 #define TICKS_PER_USEC (243/4)
21 asm("0: mftbu %0 ; mftb %1 ; mftbu %2 ; cmplw %0,%2 ; bne 0b"
22 : "=r"(hi), "=r"(lo), "=r"(dum));
23 return ((u64)hi << 32) | lo;
26 static void __delay(u64 ticks)
30 while (mftb() - start < ticks)
36 __delay(TICKS_PER_USEC * (u64)us);