Deleted Added
full compact
acpi_hpet.c (246128) acpi_hpet.c (247463)
1/*-
2 * Copyright (c) 2005 Poul-Henning Kamp
3 * Copyright (c) 2010 Alexander Motin <mav@FreeBSD.org>
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:

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2005 Poul-Henning Kamp
3 * Copyright (c) 2010 Alexander Motin <mav@FreeBSD.org>
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:

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_hpet.c 246128 2013-01-30 18:01:20Z sbz $");
29__FBSDID("$FreeBSD: head/sys/dev/acpica/acpi_hpet.c 247463 2013-02-28 13:46:03Z mav $");
30
31#include "opt_acpi.h"
32#if defined(__amd64__) || defined(__ia64__)
33#define DEV_APIC
34#else
35#include "opt_apic.h"
36#endif
37#include <sys/param.h>

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

142 uint32_t val;
143
144 val = bus_read_4(sc->mem_res, HPET_CONFIG);
145 val &= ~HPET_CNF_ENABLE;
146 bus_write_4(sc->mem_res, HPET_CONFIG, val);
147}
148
149static int
30
31#include "opt_acpi.h"
32#if defined(__amd64__) || defined(__ia64__)
33#define DEV_APIC
34#else
35#include "opt_apic.h"
36#endif
37#include <sys/param.h>

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

142 uint32_t val;
143
144 val = bus_read_4(sc->mem_res, HPET_CONFIG);
145 val &= ~HPET_CNF_ENABLE;
146 bus_write_4(sc->mem_res, HPET_CONFIG, val);
147}
148
149static int
150hpet_start(struct eventtimer *et,
151 struct bintime *first, struct bintime *period)
150hpet_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
152{
153 struct hpet_timer *mt = (struct hpet_timer *)et->et_priv;
154 struct hpet_timer *t;
155 struct hpet_softc *sc = mt->sc;
156 uint32_t fdiv, now;
157
158 t = (mt->pcpu_master < 0) ? mt : &sc->t[mt->pcpu_slaves[curcpu]];
151{
152 struct hpet_timer *mt = (struct hpet_timer *)et->et_priv;
153 struct hpet_timer *t;
154 struct hpet_softc *sc = mt->sc;
155 uint32_t fdiv, now;
156
157 t = (mt->pcpu_master < 0) ? mt : &sc->t[mt->pcpu_slaves[curcpu]];
159 if (period != NULL) {
158 if (period != 0) {
160 t->mode = 1;
159 t->mode = 1;
161 t->div = (sc->freq * (period->frac >> 32)) >> 32;
162 if (period->sec != 0)
163 t->div += sc->freq * period->sec;
160 t->div = (sc->freq * period) >> 32;
164 } else {
165 t->mode = 2;
166 t->div = 0;
167 }
161 } else {
162 t->mode = 2;
163 t->div = 0;
164 }
168 if (first != NULL) {
169 fdiv = (sc->freq * (first->frac >> 32)) >> 32;
170 if (first->sec != 0)
171 fdiv += sc->freq * first->sec;
172 } else
165 if (first != 0)
166 fdiv = (sc->freq * first) >> 32;
167 else
173 fdiv = t->div;
174 if (t->irq < 0)
175 bus_write_4(sc->mem_res, HPET_ISR, 1 << t->num);
176 t->caps |= HPET_TCNF_INT_ENB;
177 now = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER);
178restart:
179 t->next = now + fdiv;
180 if (t->mode == 1 && (t->caps & HPET_TCAP_PER_INT)) {

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

679 t->et.et_quality = 450;
680 if (t->pcpu_master >= 0) {
681 t->et.et_flags |= ET_FLAGS_PERCPU;
682 t->et.et_quality += 100;
683 }
684 if ((t->caps & HPET_TCAP_PER_INT) == 0)
685 t->et.et_quality -= 10;
686 t->et.et_frequency = sc->freq;
168 fdiv = t->div;
169 if (t->irq < 0)
170 bus_write_4(sc->mem_res, HPET_ISR, 1 << t->num);
171 t->caps |= HPET_TCNF_INT_ENB;
172 now = bus_read_4(sc->mem_res, HPET_MAIN_COUNTER);
173restart:
174 t->next = now + fdiv;
175 if (t->mode == 1 && (t->caps & HPET_TCAP_PER_INT)) {

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

674 t->et.et_quality = 450;
675 if (t->pcpu_master >= 0) {
676 t->et.et_flags |= ET_FLAGS_PERCPU;
677 t->et.et_quality += 100;
678 }
679 if ((t->caps & HPET_TCAP_PER_INT) == 0)
680 t->et.et_quality -= 10;
681 t->et.et_frequency = sc->freq;
687 t->et.et_min_period.sec = 0;
688 t->et.et_min_period.frac =
689 (((uint64_t)(HPET_MIN_CYCLES * 2) << 32) / sc->freq) << 32;
690 t->et.et_max_period.sec = 0xfffffffeLLU / sc->freq;
691 t->et.et_max_period.frac =
692 ((0xfffffffeLLU << 32) / sc->freq) << 32;
682 t->et.et_min_period =
683 ((uint64_t)(HPET_MIN_CYCLES * 2) << 32) / sc->freq;
684 t->et.et_max_period = (0xfffffffeLLU << 32) / sc->freq;
693 t->et.et_start = hpet_start;
694 t->et.et_stop = hpet_stop;
695 t->et.et_priv = &sc->t[i];
696 if (t->pcpu_master < 0 || t->pcpu_master == i) {
697 et_register(&t->et);
698 maxhpetet++;
699 }
700 }

--- 162 unchanged lines hidden ---
685 t->et.et_start = hpet_start;
686 t->et.et_stop = hpet_stop;
687 t->et.et_priv = &sc->t[i];
688 if (t->pcpu_master < 0 || t->pcpu_master == i) {
689 et_register(&t->et);
690 maxhpetet++;
691 }
692 }

--- 162 unchanged lines hidden ---