summaryrefslogtreecommitdiffstats
path: root/sys/x86
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2013-02-28 13:46:03 +0000
committermav <mav@FreeBSD.org>2013-02-28 13:46:03 +0000
commit6cf7cc6e4d8da1cf9aba1c481b914e4ca5e9f38f (patch)
treec8556591f85961643a9b4ddfaaa7c1008bb03d81 /sys/x86
parent240074414d4919ebd889f27087c72783a7ed9b19 (diff)
downloadFreeBSD-src-6cf7cc6e4d8da1cf9aba1c481b914e4ca5e9f38f.zip
FreeBSD-src-6cf7cc6e4d8da1cf9aba1c481b914e4ca5e9f38f.tar.gz
MFcalloutng:
Switch eventtimers(9) from using struct bintime to sbintime_t. Even before this not a single driver really supported full dynamic range of struct bintime even in theory, not speaking about practical inexpediency. This change legitimates the status quo and cleans up the code.
Diffstat (limited to 'sys/x86')
-rw-r--r--sys/x86/isa/atrtc.c11
-rw-r--r--sys/x86/isa/clock.c17
-rw-r--r--sys/x86/x86/local_apic.c31
3 files changed, 19 insertions, 40 deletions
diff --git a/sys/x86/isa/atrtc.c b/sys/x86/isa/atrtc.c
index c6a6f8c..69c2157 100644
--- a/sys/x86/isa/atrtc.c
+++ b/sys/x86/isa/atrtc.c
@@ -164,11 +164,10 @@ struct atrtc_softc {
};
static int
-rtc_start(struct eventtimer *et,
- struct bintime *first, struct bintime *period)
+rtc_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
- atrtc_rate(max(fls((period->frac + (period->frac >> 1)) >> 32) - 17, 1));
+ atrtc_rate(max(fls(period + (period >> 1)) - 17, 1));
atrtc_enable_intr();
return (0);
}
@@ -277,10 +276,8 @@ atrtc_attach(device_t dev)
sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_POW2DIV;
sc->et.et_quality = 0;
sc->et.et_frequency = 32768;
- sc->et.et_min_period.sec = 0;
- sc->et.et_min_period.frac = 0x0008LLU << 48;
- sc->et.et_max_period.sec = 0;
- sc->et.et_max_period.frac = 0x8000LLU << 48;
+ sc->et.et_min_period = 0x00080000;
+ sc->et.et_max_period = 0x80000000;
sc->et.et_start = rtc_start;
sc->et.et_stop = rtc_stop;
sc->et.et_priv = dev;
diff --git a/sys/x86/isa/clock.c b/sys/x86/isa/clock.c
index 232c913..29ec02d 100644
--- a/sys/x86/isa/clock.c
+++ b/sys/x86/isa/clock.c
@@ -589,18 +589,17 @@ i8254_get_timecount(struct timecounter *tc)
}
static int
-attimer_start(struct eventtimer *et,
- struct bintime *first, struct bintime *period)
+attimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
device_t dev = (device_t)et->et_priv;
struct attimer_softc *sc = device_get_softc(dev);
- if (period != NULL) {
+ if (period != 0) {
sc->mode = MODE_PERIODIC;
- sc->period = period->frac >> 32;
+ sc->period = period;
} else {
sc->mode = MODE_ONESHOT;
- sc->period = first->frac >> 32;
+ sc->period = first;
}
if (!sc->intr_en) {
i8254_intsrc->is_pic->pic_enable_source(i8254_intsrc);
@@ -755,12 +754,8 @@ attimer_attach(device_t dev)
sc->et.et_flags |= ET_FLAGS_ONESHOT;
sc->et.et_quality = 100;
sc->et.et_frequency = i8254_freq;
- sc->et.et_min_period.sec = 0;
- sc->et.et_min_period.frac =
- ((0x0002LLU << 48) / i8254_freq) << 16;
- sc->et.et_max_period.sec = 0xffff / i8254_freq;
- sc->et.et_max_period.frac =
- ((0xfffeLLU << 48) / i8254_freq) << 16;
+ sc->et.et_min_period = (0x0002LLU << 32) / i8254_freq;
+ sc->et.et_max_period = (0xfffeLLU << 32) / i8254_freq;
sc->et.et_start = attimer_start;
sc->et.et_stop = attimer_stop;
sc->et.et_priv = dev;
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index c60db22..ac87ebd 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -169,7 +169,7 @@ static void lapic_timer_stop(struct lapic *);
static void lapic_timer_set_divisor(u_int divisor);
static uint32_t lvt_mode(struct lapic *la, u_int pin, uint32_t value);
static int lapic_et_start(struct eventtimer *et,
- struct bintime *first, struct bintime *period);
+ sbintime_t first, sbintime_t period);
static int lapic_et_stop(struct eventtimer *et);
struct pic lapic_pic = { .pic_resume = lapic_resume };
@@ -268,10 +268,8 @@ lapic_init(vm_paddr_t addr)
}
lapic_et.et_frequency = 0;
/* We don't know frequency yet, so trying to guess. */
- lapic_et.et_min_period.sec = 0;
- lapic_et.et_min_period.frac = 0x00001000LL << 32;
- lapic_et.et_max_period.sec = 1;
- lapic_et.et_max_period.frac = 0;
+ lapic_et.et_min_period = 0x00001000LL;
+ lapic_et.et_max_period = SBT_1S;
lapic_et.et_start = lapic_et_start;
lapic_et.et_stop = lapic_et_stop;
lapic_et.et_priv = NULL;
@@ -487,8 +485,7 @@ lapic_disable_pmc(void)
}
static int
-lapic_et_start(struct eventtimer *et,
- struct bintime *first, struct bintime *period)
+lapic_et_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
struct lapic *la;
u_long value;
@@ -513,28 +510,18 @@ lapic_et_start(struct eventtimer *et,
printf("lapic: Divisor %lu, Frequency %lu Hz\n",
lapic_timer_divisor, value);
et->et_frequency = value;
- et->et_min_period.sec = 0;
- et->et_min_period.frac =
- ((0x00000002LLU << 32) / et->et_frequency) << 32;
- et->et_max_period.sec = 0xfffffffeLLU / et->et_frequency;
- et->et_max_period.frac =
- ((0xfffffffeLLU << 32) / et->et_frequency) << 32;
+ et->et_min_period = (0x00000002LLU << 32) / et->et_frequency;
+ et->et_max_period = (0xfffffffeLLU << 32) / et->et_frequency;
}
if (la->la_timer_mode == 0)
lapic_timer_set_divisor(lapic_timer_divisor);
- if (period != NULL) {
+ if (period != 0) {
la->la_timer_mode = 1;
- la->la_timer_period =
- (et->et_frequency * (period->frac >> 32)) >> 32;
- if (period->sec != 0)
- la->la_timer_period += et->et_frequency * period->sec;
+ la->la_timer_period = ((uint32_t)et->et_frequency * period) >> 32;
lapic_timer_periodic(la, la->la_timer_period, 1);
} else {
la->la_timer_mode = 2;
- la->la_timer_period =
- (et->et_frequency * (first->frac >> 32)) >> 32;
- if (first->sec != 0)
- la->la_timer_period += et->et_frequency * first->sec;
+ la->la_timer_period = ((uint32_t)et->et_frequency * first) >> 32;
lapic_timer_oneshot(la, la->la_timer_period, 1);
}
return (0);
OpenPOWER on IntegriCloud