File: delay.h

package info (click to toggle)
kernel-source-2.4.14 2.4.14-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 139,160 kB
  • ctags: 428,423
  • sloc: ansic: 2,435,554; asm: 141,119; makefile: 8,258; sh: 3,099; perl: 2,561; yacc: 1,177; cpp: 755; tcl: 577; lex: 352; awk: 251; lisp: 218; sed: 72
file content (85 lines) | stat: -rw-r--r-- 2,058 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef _ASM_IA64_DELAY_H
#define _ASM_IA64_DELAY_H

/*
 * Delay routines using a pre-computed "cycles/usec" value.
 *
 * Copyright (C) 1998, 1999 Hewlett-Packard Co
 * Copyright (C) 1998, 1999 David Mosberger-Tang <davidm@hpl.hp.com>
 * Copyright (C) 1999 VA Linux Systems
 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
 * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
 * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
 */

#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/sched.h>

#include <asm/processor.h>

static __inline__ void
ia64_set_itm (unsigned long val)
{
	__asm__ __volatile__("mov cr.itm=%0;; srlz.d;;" :: "r"(val) : "memory");
}

static __inline__ unsigned long
ia64_get_itm (void)
{
	unsigned long result;

	__asm__ __volatile__("mov %0=cr.itm;; srlz.d;;" : "=r"(result) :: "memory");
	return result;
}

static __inline__ void
ia64_set_itv (unsigned long val)
{
	__asm__ __volatile__("mov cr.itv=%0;; srlz.d;;" :: "r"(val) : "memory");
}

static __inline__ void
ia64_set_itc (unsigned long val)
{
	__asm__ __volatile__("mov ar.itc=%0;; srlz.d;;" :: "r"(val) : "memory");
}

static __inline__ unsigned long
ia64_get_itc (void)
{
	unsigned long result;

	__asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
#ifdef CONFIG_ITANIUM
	while (__builtin_expect ((__s32) result == -1, 0))
		__asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
#endif
	return result;
}

static __inline__ void
__delay (unsigned long loops)
{
        unsigned long saved_ar_lc;

	if (loops < 1)
		return;

	__asm__ __volatile__("mov %0=ar.lc;;" : "=r"(saved_ar_lc));
	__asm__ __volatile__("mov ar.lc=%0;;" :: "r"(loops - 1));
        __asm__ __volatile__("1:\tbr.cloop.sptk.few 1b;;");
	__asm__ __volatile__("mov ar.lc=%0" :: "r"(saved_ar_lc));
}

static __inline__ void
udelay (unsigned long usecs)
{
	unsigned long start = ia64_get_itc();
	unsigned long cycles = usecs*local_cpu_data->cyc_per_usec;

	while (ia64_get_itc() - start < cycles)
		/* skip */;
}

#endif /* _ASM_IA64_DELAY_H */