summaryrefslogtreecommitdiffstats
path: root/sys/x86
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
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')
-rw-r--r--sys/x86/isa/clock.c66
-rw-r--r--sys/x86/x86/local_apic.c33
2 files changed, 16 insertions, 83 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
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 29b078e..f40026b 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -118,9 +118,6 @@ struct lapic {
u_int la_cluster_id:2;
u_int la_present:1;
u_long *la_timer_count;
- u_long la_hard_ticks;
- u_long la_stat_ticks;
- u_long la_prof_ticks;
/* Include IDT_SYSCALL to make indexing easier. */
int la_ioint_irqs[APIC_NUM_IOINTS + 1];
} static lapics[MAX_APIC_ID + 1];
@@ -493,12 +490,14 @@ lapic_setup_clock(enum lapic_clock srcsdes)
} else
lapic_timer_hz = hz;
lapic_timer_period = value / lapic_timer_hz;
+ timer1hz = lapic_timer_hz;
if (srcsdes == LAPIC_CLOCK_ALL) {
if (lapic_timer_hz < 128)
stathz = lapic_timer_hz;
else
stathz = lapic_timer_hz / (lapic_timer_hz / 128);
profhz = lapic_timer_hz;
+ timer2hz = 0;
}
/*
@@ -790,33 +789,7 @@ lapic_handle_timer(struct trapframe *frame)
(*cyclic_clock_func[cpu])(frame);
#endif
- /* Fire hardclock at hz. */
- la->la_hard_ticks += hz;
- if (la->la_hard_ticks >= lapic_timer_hz) {
- la->la_hard_ticks -= lapic_timer_hz;
- if (PCPU_GET(cpuid) == 0)
- hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
- else
- hardclock_cpu(TRAPF_USERMODE(frame));
- }
- if (clockcoverage == LAPIC_CLOCK_ALL) {
-
- /* Fire statclock at stathz. */
- la->la_stat_ticks += stathz;
- if (la->la_stat_ticks >= lapic_timer_hz) {
- la->la_stat_ticks -= lapic_timer_hz;
- statclock(TRAPF_USERMODE(frame));
- }
-
- /* Fire profclock at profhz, but only when needed. */
- la->la_prof_ticks += profhz;
- if (la->la_prof_ticks >= lapic_timer_hz) {
- la->la_prof_ticks -= lapic_timer_hz;
- if (profprocs != 0)
- profclock(TRAPF_USERMODE(frame),
- TRAPF_PC(frame));
- }
- }
+ timer1clock(TRAPF_USERMODE(frame), TRAPF_PC(frame));
critical_exit();
}
OpenPOWER on IntegriCloud