From: Kenn H. <ke...@us...> - 2001-01-26 00:26:38
|
Update of /cvsroot/linux-vax/kernel-2.4/include/asm-vax In directory usw-pr-cvs1:/tmp/cvs-serv25353/include/asm-vax Modified Files: delay.h Log Message: Bring forward all 2.2 work from before new year. This should give us all a (somewhat) bootable kernel. Index: delay.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/asm-vax/delay.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- delay.h 2001/01/17 16:18:52 1.1 +++ delay.h 2001/01/26 00:27:00 1.2 @@ -3,11 +3,52 @@ extern unsigned long loops_per_sec; -/* Bodies of these functions moved to arch/vax/kernel/delay.c - since we can't inline stuff until we compile with - optimizations */ -void __delay(unsigned long loops); -void udelay(unsigned long usecs); +/* + * Copyright (C) 1993 Linus Torvalds + * + * Delay routines, using a pre-computed "loops_per_second" value. + * VAX port Copyright 1998 atp. + */ + +/* well, if you have CISC instructions lying around, might as well use them*/ +extern __inline__ void +__delay(unsigned long loops) +{ + __asm__ __volatile__("1:\tsobgtr %0, 1b\n" : "=r" (loops) : "0" (loops)); +} + +/* + * division by multiplication: you don't have to worry about + * loss of precision. + * + * Use only for very small delays ( < 1 msec). Should probably use a + * lookup table, really, as the multiplications take much too long with + * short delays. This is a "reasonable" implementation, though (and the + * first constant multiplications gets optimized away if the delay is + * a constant) + */ +extern __inline__ void +__udelay(unsigned long usecs, unsigned long lpj) +{ + struct { + unsigned long lo; + unsigned long hi; + } prod; + + usecs *= 0x000010c6UL * HZ; /* (2**32 / 1000000) * HZ */ + __asm__("emul %1,%2,$0,%0" + :"=g" (prod) + :"g" (usecs),"g" (lpj)); + __delay(prod.hi); +} + +#ifdef __SMP__ +#define udelay(usecs) \ + __udelay(usecs, cpu_data[smp_processor_id()].loops_per_jiffy) +#else +#define udelay(usecs) \ + __udelay(usecs, loops_per_jiffy) +#endif #endif /* _VAX_DELAY_H */ |