patch-1.3.44 linux/include/asm-sparc/delay.h
Next file: linux/include/asm-sparc/dma.h
Previous file: linux/include/asm-sparc/cypress.h
Back to the patch index
Back to the overall index
- Lines: 64
- Date:
Sat Nov 25 04:31:33 1995
- Orig file:
v1.3.43/linux/include/asm-sparc/delay.h
- Orig date:
Tue Jun 27 14:11:45 1995
diff -u --recursive --new-file v1.3.43/linux/include/asm-sparc/delay.h linux/include/asm-sparc/delay.h
@@ -1,38 +1,41 @@
-#ifndef __SPARC_DELAY_H
-#define __SPARC_DELAY_H
-
-extern unsigned long loops_per_sec;
-
-/*
- * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu).
+/* $Id: delay.h,v 1.7 1995/11/25 02:31:32 davem Exp $
+ * delay.h: Linux delay routines on the Sparc.
*
- * Delay quick inlined code using 'loops_per_second' which is
- * calculated in calibrate_delay() in main.c (ie. BogoMIPS :-)
+ * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu).
*/
-extern __inline__ void __delay(unsigned int loops)
+#ifndef __SPARC_DELAY_H
+#define __SPARC_DELAY_H
+
+extern __inline__ void __delay(unsigned long loops)
{
- __asm__ __volatile__("\n1:\tcmp %0, 0\n\t"
- "bne,a 1b\n\t"
- "sub %0, 1, %0\n": "=&r" (loops) : "0" (loops));
+ __asm__ __volatile__("cmp %0, 0\n\t"
+ "1: bne 1b\n\t"
+ "subcc %0, 1, %0\n" :
+ "=&r" (loops) :
+ "0" (loops));
}
-/* udelay(usecs) is used for very short delays up to 1 millisecond. */
+/* udelay(usecs) is used for very short delays up to 1 millisecond. On
+ * the Sparc (both sun4c and sun4m) we have a free running usec counter
+ * available to us already.
+ */
+extern volatile unsigned int *master_l10_counter;
extern __inline__ void udelay(unsigned int usecs)
{
- usecs *= 0x000010c6; /* Sparc is 32-bit just like ix86 */
-
- __delay(loops_per_sec*usecs);
+ unsigned int ccnt;
+ if(!master_l10_counter)
+ return;
+ ccnt=*master_l10_counter;
+ for(usecs+=1; usecs; usecs--, ccnt=*master_l10_counter)
+ while(*master_l10_counter == ccnt)
+ __asm__("": : :"memory");
}
/* calibrate_delay() wants this... */
-
-extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
-{
- return ((a*b)/c);
-}
+#define muldiv(a, b, c) (((a)*(b))/(c))
#endif /* defined(__SPARC_DELAY_H) */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this