OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [include/] [asm-alpha/] [delay.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#ifndef __ALPHA_DELAY_H
2
#define __ALPHA_DELAY_H
3
 
4
extern unsigned long loops_per_sec;
5
 
6
/*
7
 * Copyright (C) 1993 Linus Torvalds
8
 *
9
 * Delay routines, using a pre-computed "loops_per_second" value.
10
 */
11
 
12
extern __inline__ void __delay(unsigned long loops)
13
{
14
        __asm__ __volatile__(".align 3\n"
15
                "1:\tsubq %0,1,%0\n\t"
16
                "bge %0,1b": "=r" (loops) : "0" (loops));
17
}
18
 
19
/*
20
 * division by multiplication: you don't have to worry about
21
 * loss of precision.
22
 *
23
 * Use only for very small delays ( < 1 msec).  Should probably use a
24
 * lookup table, really, as the multiplications take much too long with
25
 * short delays.  This is a "reasonable" implementation, though (and the
26
 * first constant multiplications gets optimized away if the delay is
27
 * a constant)
28
 */
29
extern __inline__ void udelay(unsigned long usecs)
30
{
31
        usecs *= 0x000010c6f7a0b5edUL;          /* 2**64 / 1000000 */
32
        __asm__("umulh %1,%2,%0"
33
                :"=r" (usecs)
34
                :"r" (usecs),"r" (loops_per_sec));
35
        __delay(usecs);
36
}
37
 
38
/*
39
 * 64-bit integers means we don't have to worry about overflow as
40
 * on some other architectures..
41
 */
42
extern __inline__ unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
43
{
44
        return (a*b)/c;
45
}
46
 
47
#endif /* defined(__ALPHA_DELAY_H) */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.