summaryrefslogtreecommitdiffstats
path: root/sys/x86/isa
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2010-05-24 11:40:49 +0000
committermav <mav@FreeBSD.org>2010-05-24 11:40:49 +0000
commit48198e3ddd922d3260be990c8ecc8fc16f27d470 (patch)
treeba159db619ea3e7bf5e0ee0418e43865078c742f /sys/x86/isa
parent598285f6f9f5354c0c6d341c1c8cd78e9981c0f5 (diff)
downloadFreeBSD-src-48198e3ddd922d3260be990c8ecc8fc16f27d470.zip
FreeBSD-src-48198e3ddd922d3260be990c8ecc8fc16f27d470.tar.gz
- Implement MI helper functions, dividing one or two timer interrupts with
arbitrary frequencies into hardclock(), statclock() and profclock() calls. Same code with minor variations duplicated several times over the tree for different timer drivers and architectures. - Switch all x86 archs to new functions, simplifying the code and removing extra logic from timer drivers. Other archs are also welcome.
Diffstat (limited to 'sys/x86/isa')
-rw-r--r--sys/x86/isa/clock.c66
1 files changed, 13 insertions, 53 deletions
diff --git a/sys/x86/isa/clock.c b/sys/x86/isa/clock.c
index 36dc36e..b0d49d5 100644
--- a/sys/x86/isa/clock.c
+++ b/sys/x86/isa/clock.c
@@ -87,8 +87,6 @@ __FBSDID("$FreeBSD$");
#define TIMER_DIV(x) ((i8254_freq + (x) / 2) / (x))
int clkintr_pending;
-static int pscnt = 1;
-static int psdiv = 1;
#ifndef TIMER_FREQ
#define TIMER_FREQ 1193182
#endif
@@ -134,10 +132,7 @@ int
hardclockintr(struct trapframe *frame)
{
- if (PCPU_GET(cpuid) == 0)
- hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
- else
- hardclock_cpu(TRAPF_USERMODE(frame));
+ timer1clock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
return (FILTER_HANDLED);
}
@@ -145,19 +140,7 @@ int
statclockintr(struct trapframe *frame)
{
- profclockintr(frame);
- statclock(TRAPF_USERMODE(frame));
- return (FILTER_HANDLED);
-}
-
-int
-profclockintr(struct trapframe *frame)
-{
-
- if (!using_atrtc_timer)
- hardclockintr(frame);
- if (profprocs != 0)
- profclock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
+ timer2clock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
return (FILTER_HANDLED);
}
@@ -190,28 +173,11 @@ clkintr(struct trapframe *frame)
(*cyclic_clock_func[cpu])(frame);
#endif
- if (using_atrtc_timer) {
-#ifdef SMP
- if (smp_started)
- ipi_all_but_self(IPI_HARDCLOCK);
-#endif
- hardclockintr(frame);
- } else {
- if (--pscnt <= 0) {
- pscnt = psratio;
#ifdef SMP
- if (smp_started)
- ipi_all_but_self(IPI_STATCLOCK);
+ if (smp_started)
+ ipi_all_but_self(IPI_HARDCLOCK);
#endif
- statclockintr(frame);
- } else {
-#ifdef SMP
- if (smp_started)
- ipi_all_but_self(IPI_PROFCLOCK);
-#endif
- profclockintr(frame);
- }
- }
+ hardclockintr(frame);
#ifdef DEV_MCA
/* Reset clock interrupt by asserting bit 7 of port 0x61 */
@@ -295,20 +261,11 @@ rtcintr(struct trapframe *frame)
while (rtcin(RTC_INTR) & RTCIR_PERIOD) {
flag = 1;
- if (--pscnt <= 0) {
- pscnt = psdiv;
#ifdef SMP
- if (smp_started)
- ipi_all_but_self(IPI_STATCLOCK);
-#endif
- statclockintr(frame);
- } else {
-#ifdef SMP
- if (smp_started)
- ipi_all_but_self(IPI_PROFCLOCK);
+ if (smp_started)
+ ipi_all_but_self(IPI_STATCLOCK);
#endif
- profclockintr(frame);
- }
+ statclockintr(frame);
}
return(flag ? FILTER_HANDLED : FILTER_STRAY);
}
@@ -555,6 +512,7 @@ cpu_initclocks()
* timecounter to user a simpler algorithm.
*/
if (using_lapic_timer == LAPIC_CLOCK_NONE) {
+ timer1hz = hz;
intr_add_handler("clk", 0, (driver_filter_t *)clkintr, NULL,
NULL, INTR_TYPE_CLK, NULL);
i8254_intsrc = intr_lookup_source(0);
@@ -577,6 +535,7 @@ cpu_initclocks()
if (using_lapic_timer != LAPIC_CLOCK_ALL) {
using_atrtc_timer = tasc;
if (using_atrtc_timer) {
+ timer2hz = RTC_NOPROFRATE;
/* Enable periodic interrupts from the RTC. */
intr_add_handler("rtc", 8,
(driver_filter_t *)rtcintr, NULL, NULL,
@@ -588,6 +547,7 @@ cpu_initclocks()
stathz = hz;
else
stathz = hz / (hz / 128);
+ timer2hz = 0;
}
}
@@ -601,7 +561,7 @@ cpu_startprofclock(void)
if (using_lapic_timer == LAPIC_CLOCK_ALL || !using_atrtc_timer)
return;
atrtc_rate(RTCSA_PROF);
- psdiv = pscnt = psratio;
+ timer2hz = RTC_PROFRATE;
}
void
@@ -611,7 +571,7 @@ cpu_stopprofclock(void)
if (using_lapic_timer == LAPIC_CLOCK_ALL || !using_atrtc_timer)
return;
atrtc_rate(RTCSA_NOPROF);
- psdiv = pscnt = 1;
+ timer2hz = RTC_NOPROFRATE;
}
static int
OpenPOWER on IntegriCloud