]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/sparc64/sparc64/clock.c
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / sparc64 / sparc64 / clock.c
1 /*-
2  * Copyright (c) 2001 Jake Burkholder.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
29
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/pcpu.h>
33 #include <sys/proc.h>
34 #include <sys/sched.h>
35
36 #include <machine/clock.h>
37 #include <machine/cpu.h>
38 #include <machine/cpufunc.h>
39
40 void (*delay_func)(int usec);
41 u_long clock_boot;
42
43 void
44 DELAY(int usec)
45 {
46
47         (*delay_func)(usec);
48 }
49
50 void
51 delay_boot(int usec)
52 {
53         u_long end;
54
55         if (usec < 0)
56                 return;
57
58         end = rd(tick) + (u_long)usec * clock_boot / 1000000;
59         while (rd(tick) < end)
60                 cpu_spinwait();
61 }
62
63 void
64 delay_tick(int usec)
65 {
66         u_long end;
67
68         if (usec < 0)
69                 return;
70
71         /*
72          * We avoid being migrated to another CPU with a possibly
73          * unsynchronized TICK timer while spinning.
74          */
75         sched_pin();
76
77         end = rd(tick) + (u_long)usec * PCPU_GET(clock) / 1000000;
78         while (rd(tick) < end)
79                 cpu_spinwait();
80
81         sched_unpin();
82 }
83
84 void
85 cpu_startprofclock(void)
86 {
87
88 }
89
90 void
91 cpu_stopprofclock(void)
92 {
93
94 }