Deleted Added
full compact
clock.c (183089) clock.c (192067)
1/*-
2 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
3 * Copyright (C) 1995, 1996 TooLs GmbH.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 42 unchanged lines hidden (view full) ---

51 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
52 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
53 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
54 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
55 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 */
57
58#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
3 * Copyright (C) 1995, 1996 TooLs GmbH.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 42 unchanged lines hidden (view full) ---

51 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
52 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
53 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
54 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
55 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 */
57
58#include <sys/cdefs.h>
59__FBSDID("$FreeBSD: head/sys/powerpc/aim/clock.c 183089 2008-09-16 17:11:33Z marcel $");
59__FBSDID("$FreeBSD: head/sys/powerpc/aim/clock.c 192067 2009-05-14 00:34:26Z nwhitehorn $");
60
61#include <sys/param.h>
62#include <sys/systm.h>
63#include <sys/kernel.h>
64#include <sys/bus.h>
65#include <sys/interrupt.h>
66#include <sys/pcpu.h>
67#include <sys/sysctl.h>

--- 52 unchanged lines hidden (view full) ---

120 while (nticks-- > 0)
121 hardclock_cpu(TRAPF_USERMODE(frame));
122 }
123}
124
125void
126decr_init(void)
127{
60
61#include <sys/param.h>
62#include <sys/systm.h>
63#include <sys/kernel.h>
64#include <sys/bus.h>
65#include <sys/interrupt.h>
66#include <sys/pcpu.h>
67#include <sys/sysctl.h>

--- 52 unchanged lines hidden (view full) ---

120 while (nticks-- > 0)
121 hardclock_cpu(TRAPF_USERMODE(frame));
122 }
123}
124
125void
126decr_init(void)
127{
128 int qhandle, phandle;
129 char name[32];
130 unsigned int msr;
128 struct cpuref cpu;
129 register_t msr;
131
130
132 phandle = 0;
133
134 /*
131 /*
135 * Get this info during autoconf? XXX
132 * Check the BSP's timebase frequency. Sometimes we can't find the BSP, so fall
133 * back to the first CPU in this case.
136 */
134 */
137 for (qhandle = OF_peer(0); qhandle; qhandle = phandle) {
138 if (OF_getprop(qhandle, "device_type", name, sizeof name) >= 0
139 && !strcmp(name, "cpu")
140 && OF_getprop(qhandle, "timebase-frequency",
141 &ticks_per_sec, sizeof ticks_per_sec) >= 0) {
142 /*
143 * Should check for correct CPU here? XXX
144 */
145 msr = mfmsr();
146 mtmsr(msr & ~PSL_EE);
147
135
148 ns_per_tick = 1000000000 / ticks_per_sec;
149 ticks_per_intr = ticks_per_sec / hz;
150 mtdec(ticks_per_intr);
136 if (platform_smp_get_bsp(&cpu) != 0)
137 platform_smp_first_cpu(&cpu);
151
138
152 mtmsr(msr);
139 ticks_per_sec = platform_timebase_freq(&cpu);
153
140
154 break;
155 }
156 if ((phandle = OF_child(qhandle)))
157 continue;
158 while (qhandle) {
159 if ((phandle = OF_peer(qhandle)))
160 break;
161 qhandle = OF_parent(qhandle);
162 }
163 }
164 if (!phandle)
165 panic("no cpu node");
141 msr = mfmsr();
142 mtmsr(msr & ~PSL_EE);
143
144 ns_per_tick = 1000000000 / ticks_per_sec;
145 ticks_per_intr = ticks_per_sec / hz;
146 mtdec(ticks_per_intr);
147
148 mtmsr(msr);
166}
167
168void
169decr_tc_init(void)
170{
171 decr_timecounter.tc_frequency = ticks_per_sec;
172 tc_init(&decr_timecounter);
173}

--- 49 unchanged lines hidden ---
149}
150
151void
152decr_tc_init(void)
153{
154 decr_timecounter.tc_frequency = ticks_per_sec;
155 tc_init(&decr_timecounter);
156}

--- 49 unchanged lines hidden ---